|
|
@ -242,7 +242,7 @@ public class WorkerController { |
|
|
@ApiOperation(value = "修改配送员信息-APP", notes = "需要通过下单编号获取订单信息") |
|
|
@ApiOperation(value = "修改配送员信息-APP", notes = "需要通过下单编号获取订单信息") |
|
|
public Result editApp(WorkerAppVO u) { |
|
|
public Result editApp(WorkerAppVO u) { |
|
|
//修改配送员信息时如涉及到充值押金情况,需要更新余额且重置应缴
|
|
|
//修改配送员信息时如涉及到充值押金情况,需要更新余额且重置应缴
|
|
|
Worker worker = workerService.get(u.getWorkerId()); |
|
|
Worker worker = workerService.findByWorkerId(u.getWorkerId()); |
|
|
if (u.getDepoNum() != null && u.getDepoNum().compareTo(BigDecimal.ZERO) > 0) { |
|
|
if (u.getDepoNum() != null && u.getDepoNum().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
|
|
|
|
|
Recharge recharge = new Recharge(); |
|
|
Recharge recharge = new Recharge(); |
|
|
@ -268,7 +268,7 @@ public class WorkerController { |
|
|
@RequestMapping(value = "/admin/disable/{workerId}", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/admin/disable/{workerId}", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "后台人工禁用配送员") |
|
|
@ApiOperation(value = "后台人工禁用配送员") |
|
|
public Result disable(@ApiParam("用户唯一id标识") @PathVariable String workerId) { |
|
|
public Result disable(@ApiParam("用户唯一id标识") @PathVariable String workerId) { |
|
|
Worker worker = workerService.get(workerId); |
|
|
Worker worker = workerService.findByWorkerId(workerId); |
|
|
if (worker == null) { |
|
|
if (worker == null) { |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
} |
|
|
} |
|
|
@ -284,7 +284,7 @@ public class WorkerController { |
|
|
@RequestMapping(value = "/admin/enable/{workerId}", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/admin/enable/{workerId}", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "后台人工启用配送员") |
|
|
@ApiOperation(value = "后台人工启用配送员") |
|
|
public Result enable(@ApiParam("配送员唯一id标识") @PathVariable String workerId) { |
|
|
public Result enable(@ApiParam("配送员唯一id标识") @PathVariable String workerId) { |
|
|
Worker worker = workerService.get(workerId); |
|
|
Worker worker = workerService.findByWorkerId(workerId); |
|
|
if (worker == null) { |
|
|
if (worker == null) { |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
} |
|
|
} |
|
|
@ -300,7 +300,8 @@ public class WorkerController { |
|
|
@ApiOperation(value = "后台设置配送员全职状态") |
|
|
@ApiOperation(value = "后台设置配送员全职状态") |
|
|
public Result changeFullTime(@ApiParam("配送员唯一id标识") @PathVariable String workerId, |
|
|
public Result changeFullTime(@ApiParam("配送员唯一id标识") @PathVariable String workerId, |
|
|
@RequestParam("isFullTime") Integer isFullTime) { |
|
|
@RequestParam("isFullTime") Integer isFullTime) { |
|
|
Worker worker = workerService.get(workerId); |
|
|
// 注意:不要用 workerService.get()(底层 getById 返回懒加载代理,仅有主键)
|
|
|
|
|
|
Worker worker = workerService.findByWorkerId(workerId); |
|
|
if (worker == null) { |
|
|
if (worker == null) { |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
} |
|
|
} |
|
|
@ -308,7 +309,12 @@ public class WorkerController { |
|
|
return ResultUtil.error("全职状态参数错误"); |
|
|
return ResultUtil.error("全职状态参数错误"); |
|
|
} |
|
|
} |
|
|
workerService.changeFullTime(workerId, isFullTime); |
|
|
workerService.changeFullTime(workerId, isFullTime); |
|
|
|
|
|
// 批量更新后重新查询完整对象,避免把残缺数据写入配送员缓存
|
|
|
|
|
|
worker = workerService.findByWorkerId(workerId); |
|
|
worker.setIsFullTime(isFullTime); |
|
|
worker.setIsFullTime(isFullTime); |
|
|
|
|
|
if (worker == null) { |
|
|
|
|
|
return ResultUtil.error("配送员不存在"); |
|
|
|
|
|
} |
|
|
if (StrUtil.isNotBlank(worker.getRegion())) { |
|
|
if (StrUtil.isNotBlank(worker.getRegion())) { |
|
|
WorkerRedisVo workerRedisVo = workerRedisCacheUtil.get(worker.getRegion(), worker.getWorkerId()); |
|
|
WorkerRedisVo workerRedisVo = workerRedisCacheUtil.get(worker.getRegion(), worker.getWorkerId()); |
|
|
if (workerRedisVo != null) { |
|
|
if (workerRedisVo != null) { |
|
|
@ -331,7 +337,7 @@ public class WorkerController { |
|
|
@ApiOperation(value = "配送员上线") |
|
|
@ApiOperation(value = "配送员上线") |
|
|
public Result<Object> onLine(@RequestParam("id") String id) { |
|
|
public Result<Object> onLine(@RequestParam("id") String id) { |
|
|
try { |
|
|
try { |
|
|
Worker worker = workerService.get(id); |
|
|
Worker worker = workerService.findByWorkerId(id); |
|
|
if (worker == null) { |
|
|
if (worker == null) { |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
return ResultUtil.error("配送员不存在"); |
|
|
} |
|
|
} |
|
|
@ -405,6 +411,11 @@ public class WorkerController { |
|
|
* orderBkge -> 配送佣金正序 |
|
|
* orderBkge -> 配送佣金正序 |
|
|
*/ |
|
|
*/ |
|
|
private String sortField; |
|
|
private String sortField; |
|
|
|
|
|
/** |
|
|
|
|
|
* 是否后台查询(仅后台管理系统传 true;小程序不传) |
|
|
|
|
|
* 为 true 时:优先按取收货区域规则匹配,未匹配到则补充返回全职且上线的配送员 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Boolean fromAdmin; |
|
|
/** 页码(从1开始),默认1 */ |
|
|
/** 页码(从1开始),默认1 */ |
|
|
private Integer pageNum = 1; |
|
|
private Integer pageNum = 1; |
|
|
/** 每页条数,默认10 */ |
|
|
/** 每页条数,默认10 */ |
|
|
@ -461,27 +472,34 @@ public class WorkerController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// ---- 配送规则匹配:shopAreaId + putAreaId + orderType + getPushOrder ----
|
|
|
// ---- 配送规则匹配:shopAreaId + putAreaId + orderType + getPushOrder ----
|
|
|
if (vo.getWorkerRelaPriceList() == null || vo.getWorkerRelaPriceList().isEmpty()) continue; |
|
|
|
|
|
|
|
|
|
|
|
WorkerRelaPrice matchedRule = null; |
|
|
WorkerRelaPrice matchedRule = null; |
|
|
for (WorkerRelaPrice rp : vo.getWorkerRelaPriceList()) { |
|
|
if (vo.getWorkerRelaPriceList() != null && !vo.getWorkerRelaPriceList().isEmpty()) { |
|
|
// 缓存可能残留旧数据,规则也要限定当前校区
|
|
|
for (WorkerRelaPrice rp : vo.getWorkerRelaPriceList()) { |
|
|
if (StrUtil.isNotBlank(dto.getRegionId()) && !dto.getRegionId().equals(rp.getRegionId())) continue; |
|
|
// 缓存可能残留旧数据,规则也要限定当前校区
|
|
|
// 规则必须接收指派
|
|
|
if (StrUtil.isNotBlank(dto.getRegionId()) && !dto.getRegionId().equals(rp.getRegionId())) continue; |
|
|
if (rp.getGetPushOrder() == null || rp.getGetPushOrder() != 1) continue; |
|
|
// 规则必须接收指派
|
|
|
// 取货区域匹配
|
|
|
if (rp.getGetPushOrder() == null || rp.getGetPushOrder() != 1) continue; |
|
|
if (StrUtil.isNotBlank(dto.getShopAreaId()) && !dto.getShopAreaId().equals(rp.getGetAreaId())) continue; |
|
|
// 取货区域匹配
|
|
|
// 送货区域匹配
|
|
|
if (StrUtil.isNotBlank(dto.getShopAreaId()) && !dto.getShopAreaId().equals(rp.getGetAreaId())) continue; |
|
|
if (StrUtil.isNotBlank(dto.getPutAreaId()) && !dto.getPutAreaId().equals(rp.getPutAreaId())) continue; |
|
|
// 送货区域匹配
|
|
|
// 订单类型匹配
|
|
|
if (StrUtil.isNotBlank(dto.getPutAreaId()) && !dto.getPutAreaId().equals(rp.getPutAreaId())) continue; |
|
|
if (dto.getOrderType() != null && !dto.getOrderType().equals(rp.getOrderType())) continue; |
|
|
// 订单类型匹配
|
|
|
// 改派时只允许选择接单佣金不超过当前配送单总佣金的规则
|
|
|
if (dto.getOrderType() != null && !dto.getOrderType().equals(rp.getOrderType())) continue; |
|
|
if (dto.getCommissionAmount() != null |
|
|
// 改派时只允许选择接单佣金不超过当前配送单总佣金的规则
|
|
|
&& (rp.getOrderBkge() == null || rp.getOrderBkge().compareTo(dto.getCommissionAmount()) > 0)) continue; |
|
|
if (dto.getCommissionAmount() != null |
|
|
matchedRule = rp; |
|
|
&& (rp.getOrderBkge() == null || rp.getOrderBkge().compareTo(dto.getCommissionAmount()) > 0)) continue; |
|
|
break; |
|
|
matchedRule = rp; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 后台查询:取收货区域未匹配时,全职且已上线的配送员也返回(上线已在上方过滤)
|
|
|
|
|
|
if (matchedRule == null) { |
|
|
|
|
|
boolean allowFullTimeFallback = Boolean.TRUE.equals(dto.getFromAdmin()) |
|
|
|
|
|
&& w.getIsFullTime() != null && w.getIsFullTime() == 1; |
|
|
|
|
|
if (!allowFullTimeFallback) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
if (matchedRule == null) continue; |
|
|
|
|
|
|
|
|
|
|
|
// ---- 从订单缓存获取该配送员的待完成订单,统计各状态数量 ----
|
|
|
// ---- 从订单缓存获取该配送员的待完成订单,统计各状态数量 ----
|
|
|
List<MallDeliveryOrder> workerOrders = workerOrderCacheUtil.getAllAsList(w.getWorkerId()); |
|
|
List<MallDeliveryOrder> workerOrders = workerOrderCacheUtil.getAllAsList(w.getWorkerId()); |
|
|
@ -524,8 +542,8 @@ public class WorkerController { |
|
|
matchVO.setIsFullTime(w.getIsFullTime()); |
|
|
matchVO.setIsFullTime(w.getIsFullTime()); |
|
|
matchVO.setHighFloorFee(w.getHighFloorFee()); |
|
|
matchVO.setHighFloorFee(w.getHighFloorFee()); |
|
|
matchVO.setDeliveryLocation(w.getDeliveryLocation()); |
|
|
matchVO.setDeliveryLocation(w.getDeliveryLocation()); |
|
|
matchVO.setOrderBkge(matchedRule.getOrderBkge()); |
|
|
matchVO.setOrderBkge(matchedRule != null ? matchedRule.getOrderBkge() : null); |
|
|
matchVO.setRemark(matchedRule.getRemark()); |
|
|
matchVO.setRemark(matchedRule != null ? matchedRule.getRemark() : null); |
|
|
matchVO.setOrderWaitCount(orderWaitCount); |
|
|
matchVO.setOrderWaitCount(orderWaitCount); |
|
|
matchVO.setOrderGetCount(orderGetCount); |
|
|
matchVO.setOrderGetCount(orderGetCount); |
|
|
matchVO.setOrderPutCount(orderPutCount); |
|
|
matchVO.setOrderPutCount(orderPutCount); |
|
|
@ -587,6 +605,7 @@ public class WorkerController { |
|
|
StrUtil.isBlank(dto.getKeyword()) ? null : dto.getKeyword().trim(), |
|
|
StrUtil.isBlank(dto.getKeyword()) ? null : dto.getKeyword().trim(), |
|
|
dto.getBaozhang(), |
|
|
dto.getBaozhang(), |
|
|
dto.getXiangtong(), |
|
|
dto.getXiangtong(), |
|
|
|
|
|
dto.getFromAdmin(), |
|
|
dto.getSortField(), |
|
|
dto.getSortField(), |
|
|
sortOrder |
|
|
sortOrder |
|
|
); |
|
|
); |
|
|
|