|
|
@@ -25,6 +25,7 @@ import com.sqx.modules.common.service.CommonInfoService;
|
|
|
import com.sqx.modules.errand.dao.ErrandEvaluateDao;
|
|
|
import com.sqx.modules.errand.dao.TbIndentDao;
|
|
|
import com.sqx.modules.errand.dto.RiderDeliveryDTO;
|
|
|
+import com.sqx.modules.errand.dto.WaitForAcceptOrderQueryDTO;
|
|
|
import com.sqx.modules.errand.entity.ErrandAddress;
|
|
|
import com.sqx.modules.errand.entity.ErrandEvaluate;
|
|
|
import com.sqx.modules.errand.entity.ErrandRedPacket;
|
|
|
@@ -33,6 +34,7 @@ import com.sqx.modules.errand.service.TbIndentService;
|
|
|
import com.sqx.modules.errand.service.TbIndentSmsSendLogService;
|
|
|
import com.sqx.modules.errand.service.TbIndentSmsTemplateService;
|
|
|
import com.sqx.modules.errand.util.LonLatUtil;
|
|
|
+import com.sqx.modules.errand.vo.ShopWaitAcceptOrderVO;
|
|
|
import com.sqx.modules.goods.dao.GoodsShopDao;
|
|
|
import com.sqx.modules.goods.dao.GoodsShopRelevancyDao;
|
|
|
import com.sqx.modules.goods.entity.GoodsShop;
|
|
|
@@ -191,7 +193,36 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result findNewIndent(Long userId, String receivingPettern, Integer page, Integer limit, double riderLng, double riderLat, String indentType, String buyType) {
|
|
|
+ Page<TbIndent> pages=new Page<>(page,limit);
|
|
|
+ IPage<TbIndent> indent = null;
|
|
|
+ if(receivingPettern.equals("1")){
|
|
|
+ CommonInfo one = commonInfoService.findOne(274);
|
|
|
+ Integer value =Integer.valueOf(one.getValue());
|
|
|
+ double distances = value;
|
|
|
+ indent = baseMapper.findNewIndent(pages, riderLng, riderLat, distances, indentType);
|
|
|
+ for (int i = 0;i<indent.getRecords().size();i++){
|
|
|
+ if("4".equals(indent.getRecords().get(i).getIndentType())){
|
|
|
+ Result distance = distance(riderLng, riderLat, indent.getRecords().get(i).getUserLng(), indent.getRecords().get(i).getUserLat());
|
|
|
+ Object data = distance.get("data");
|
|
|
+ indent.getRecords().get(i).setDistancess(Double.valueOf(data.toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if("2".equals(receivingPettern)){
|
|
|
+ String address = getCurrentCityByLngAndLat(riderLng, riderLat);
|
|
|
|
|
|
+ indent = baseMapper.findNewIndentcity(pages, riderLng, riderLat, address, indentType);
|
|
|
+ for (int i = 0;i<indent.getRecords().size();i++){
|
|
|
+ if("4".equals(indent.getRecords().get(i).getIndentType())){
|
|
|
+ Result distance = distance(riderLng, riderLat, indent.getRecords().get(i).getUserLng(), indent.getRecords().get(i).getUserLat());
|
|
|
+ Object data1 = distance.get("data");
|
|
|
+ indent.getRecords().get(i).setDistancess(Double.valueOf(data1.toString()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.success().put("data",new PageUtils(indent));
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public Result insertIndent(TbOrder order) {
|
|
|
@@ -492,30 +523,66 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result findNewIndent(Long userId, String receivingPettern, Integer page, Integer limit, double riderLng, double riderLat, String indentType, String buyType) {
|
|
|
- Page<TbIndent> pages=new Page<>(page,limit);
|
|
|
- IPage<TbIndent> indent = null;
|
|
|
- String address = "";
|
|
|
- if(receivingPettern.equals("1")){
|
|
|
+ public PageUtils findNewIndent(WaitForAcceptOrderQueryDTO queryDTO) {
|
|
|
+ Page<TbIndent> pages = new Page<>(queryDTO.getPage(), queryDTO.getLimit());
|
|
|
+
|
|
|
+ String receivingPattern = queryDTO.getReceivingPattern();
|
|
|
+
|
|
|
+ IPage<TbIndent> indent;
|
|
|
+ // 接单模式 1近单模式,2同城模式
|
|
|
+ if(ObjectUtil.equal(receivingPattern, "1")) {
|
|
|
CommonInfo one = commonInfoService.findOne(274);
|
|
|
- Integer value =Integer.valueOf(one.getValue());
|
|
|
- double distances = value;
|
|
|
- indent = baseMapper.findNewIndent(pages, riderLng, riderLat, distances, indentType);
|
|
|
- for (int i = 0;i<indent.getRecords().size();i++){
|
|
|
- if("4".equals(indent.getRecords().get(i).getIndentType())){
|
|
|
- Result distance = distance(riderLng, riderLat, indent.getRecords().get(i).getUserLng(), indent.getRecords().get(i).getUserLat());
|
|
|
- Object data = distance.get("data");
|
|
|
- indent.getRecords().get(i).setDistancess(Double.valueOf(data.toString()));
|
|
|
- }
|
|
|
- }
|
|
|
- }else if("2".equals(receivingPettern)){
|
|
|
- String way = commonInfoService.findOne(416).getValue();
|
|
|
+ queryDTO.setDistances(Double.valueOf(one.getValue()));
|
|
|
+ indent = baseMapper.findNewIndentByDistances(pages, queryDTO);
|
|
|
+ } else {
|
|
|
+ String city = getCurrentCityByLngAndLat(queryDTO.getRiderLng(), queryDTO.getRiderLat());
|
|
|
+ queryDTO.setCity(city);
|
|
|
+
|
|
|
+ indent = baseMapper.findNewIndentByCity(pages, queryDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ // indentType为4时调用distance()重新计算距离步骤去除
|
|
|
+
|
|
|
+ return new PageUtils(indent);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageUtils findNewIndentGroupByShop(WaitForAcceptOrderQueryDTO queryDTO) {
|
|
|
+ Page<ShopWaitAcceptOrderVO> pages = new Page<>(queryDTO.getPage(), queryDTO.getLimit());
|
|
|
+
|
|
|
+ String receivingPattern = queryDTO.getReceivingPattern();
|
|
|
+
|
|
|
+ IPage<ShopWaitAcceptOrderVO> indent;
|
|
|
+ // 接单模式 1近单模式,2同城模式
|
|
|
+ if(ObjectUtil.equal(receivingPattern, "1")) {
|
|
|
+ CommonInfo one = commonInfoService.findOne(274);
|
|
|
+ queryDTO.setDistances(Double.valueOf(one.getValue()));
|
|
|
+ indent = baseMapper.findNewIndentByDistancesGroupByShop(pages, queryDTO);
|
|
|
+ } else {
|
|
|
+ String city = getCurrentCityByLngAndLat(queryDTO.getRiderLng(), queryDTO.getRiderLat());
|
|
|
+ queryDTO.setCity(city);
|
|
|
+
|
|
|
+ indent = baseMapper.findNewIndentByCityGroupByShop(pages, queryDTO);
|
|
|
+ }
|
|
|
+ return new PageUtils(indent);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取当前经纬度所在城市
|
|
|
+ * @param lng 经度 xxx.yyyy
|
|
|
+ * @param lat 纬度 xx.yyyy
|
|
|
+ * @return 城市名称
|
|
|
+ */
|
|
|
+ private String getCurrentCityByLngAndLat(Double lng, Double lat) {
|
|
|
+ String way = commonInfoService.findOne(416).getValue();
|
|
|
+ String city = null;
|
|
|
+ try {
|
|
|
if("1".equals(way)){
|
|
|
//根据骑手经纬度获取骑手所在城市
|
|
|
CommonInfo one = commonInfoService.findOne(235);
|
|
|
String url="https://apis.map.qq.com/ws/geocoder/v1/";
|
|
|
Map<String,String> maps=new HashMap<>();
|
|
|
- maps.put("location",riderLat+","+riderLng);
|
|
|
+ maps.put("location", lat + "," + lng);
|
|
|
maps.put("key",one.getValue());
|
|
|
String data = HttpClientUtil.doGet(url, maps);
|
|
|
JSONObject jsonObject = JSON.parseObject(data);
|
|
|
@@ -524,46 +591,39 @@ public class TbIndentServiceImpl extends ServiceImpl<TbIndentDao, TbIndent> impl
|
|
|
if("0".equals(status)){
|
|
|
JSONObject result = jsonObject.getJSONObject("result");
|
|
|
JSONObject adInfo = result.getJSONObject("ad_info");
|
|
|
- if(adInfo!=null){
|
|
|
- String province = String.valueOf(adInfo.get("province"));
|
|
|
- String city = String.valueOf(adInfo.get("city"));
|
|
|
- address = city;
|
|
|
+ if(adInfo != null){
|
|
|
+ city = String.valueOf(adInfo.get("city"));
|
|
|
}
|
|
|
-
|
|
|
- }else{
|
|
|
- log.error("转换失败!!!原因:"+jsonObject.getString("message"));
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
String value = commonInfoService.findOne(417).getValue();
|
|
|
String url="http://api.tianditu.gov.cn/geocoder";
|
|
|
Map<String,String> param=new HashMap<>();
|
|
|
JSONObject postStr=new JSONObject();
|
|
|
- postStr.put("lon",riderLng);
|
|
|
- postStr.put("lat",riderLat);
|
|
|
- postStr.put("ver","1");
|
|
|
- param.put("postStr",postStr.toJSONString());
|
|
|
- param.put("type","geocode");
|
|
|
- param.put("tk",value);
|
|
|
+ postStr.put("lon", lng);
|
|
|
+ postStr.put("lat", lat);
|
|
|
+ postStr.put("ver", "1");
|
|
|
+ param.put("postStr", postStr.toJSONString());
|
|
|
+ param.put("type", "geocode");
|
|
|
+ param.put("tk", value);
|
|
|
String s = HttpClientUtil.doGet(url,param);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
|
|
String status = jsonObject.getString("status");
|
|
|
if("0".equals(status)){
|
|
|
JSONObject result = jsonObject.getJSONObject("result");
|
|
|
JSONObject addressComponent = result.getJSONObject("addressComponent");
|
|
|
- address = addressComponent.getString("city");
|
|
|
+ city = addressComponent.getString("city");
|
|
|
}
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new SqxException("获取当前用户位置失败,失败原因:【" + e.getMessage() + "】");
|
|
|
+ }
|
|
|
|
|
|
- indent = baseMapper.findNewIndentcity(pages, riderLng, riderLat, address, indentType);
|
|
|
- for (int i = 0;i<indent.getRecords().size();i++){
|
|
|
- if("4".equals(indent.getRecords().get(i).getIndentType())){
|
|
|
- Result distance = distance(riderLng, riderLat, indent.getRecords().get(i).getUserLng(), indent.getRecords().get(i).getUserLat());
|
|
|
- Object data1 = distance.get("data");
|
|
|
- indent.getRecords().get(i).setDistancess(Double.valueOf(data1.toString()));
|
|
|
- }
|
|
|
- }
|
|
|
+ if (ObjectUtil.isNull(city)) {
|
|
|
+ throw new SqxException("获取当前用户位置失败");
|
|
|
}
|
|
|
- return Result.success().put("data",new PageUtils(indent));
|
|
|
+
|
|
|
+ return city;
|
|
|
}
|
|
|
|
|
|
|