|
|
@ -1,6 +1,5 @@ |
|
|
package cc.hiver.mall.controller; |
|
|
package cc.hiver.mall.controller; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cc.hiver.core.common.constant.CommonConstant; |
|
|
import cc.hiver.core.common.constant.CommonConstant; |
|
|
import cc.hiver.core.common.constant.WorkerConstant; |
|
|
import cc.hiver.core.common.constant.WorkerConstant; |
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
import cc.hiver.core.common.utils.BeanUtils; |
|
|
@ -10,14 +9,18 @@ import cc.hiver.core.entity.Worker; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
import cc.hiver.core.service.WorkerService; |
|
|
import cc.hiver.core.vo.WorkerAppVO; |
|
|
import cc.hiver.core.vo.WorkerAppVO; |
|
|
import cc.hiver.core.vo.WorkerQueryVO; |
|
|
import cc.hiver.core.vo.WorkerQueryVO; |
|
|
|
|
|
import cc.hiver.mall.dao.mapper.WorkerRelaPriceMapper; |
|
|
import cc.hiver.mall.entity.Recharge; |
|
|
import cc.hiver.mall.entity.Recharge; |
|
|
import cc.hiver.mall.entity.ShopArea; |
|
|
import cc.hiver.mall.entity.ShopArea; |
|
|
|
|
|
import cc.hiver.mall.pojo.vo.WorkerAreaOnlineCountVO; |
|
|
|
|
|
import cc.hiver.mall.pojo.vo.WorkerMatchVO; |
|
|
import cc.hiver.mall.service.RechargeService; |
|
|
import cc.hiver.mall.service.RechargeService; |
|
|
import cc.hiver.mall.service.ShopAreaService; |
|
|
import cc.hiver.mall.service.ShopAreaService; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.Api; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiOperation; |
|
|
import io.swagger.annotations.ApiParam; |
|
|
import io.swagger.annotations.ApiParam; |
|
|
|
|
|
import lombok.Data; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.cache.annotation.CacheConfig; |
|
|
import org.springframework.cache.annotation.CacheConfig; |
|
|
@ -30,13 +33,13 @@ import java.math.BigDecimal; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 订单工管理接口 |
|
|
* 配送员管理接口 |
|
|
* |
|
|
* |
|
|
* @author houpn |
|
|
* @author houpn |
|
|
*/ |
|
|
*/ |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@RestController |
|
|
@RestController |
|
|
@Api(tags = "订单工接口") |
|
|
@Api(tags = "配送员接口") |
|
|
@RequestMapping("/hiver/worker") |
|
|
@RequestMapping("/hiver/worker") |
|
|
@CacheConfig(cacheNames = "worker") |
|
|
@CacheConfig(cacheNames = "worker") |
|
|
@Transactional |
|
|
@Transactional |
|
|
@ -51,6 +54,9 @@ public class WorkerController { |
|
|
@Autowired |
|
|
@Autowired |
|
|
private ShopAreaService shopAreaService; |
|
|
private ShopAreaService shopAreaService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private WorkerRelaPriceMapper workerRelaPriceMapper; |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/getByCondition", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "多条件分页获取订单列表") |
|
|
@ApiOperation(value = "多条件分页获取订单列表") |
|
|
public Result<Page<Worker>> getByCondition(@RequestBody WorkerQueryVO worker) { |
|
|
public Result<Page<Worker>> getByCondition(@RequestBody WorkerQueryVO worker) { |
|
|
@ -85,7 +91,7 @@ public class WorkerController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/admin/add", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/admin/add", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "创建抢单工") |
|
|
@ApiOperation(value = "创建配送员") |
|
|
public Result add(@Valid Worker u) { |
|
|
public Result add(@Valid Worker u) { |
|
|
|
|
|
|
|
|
// 添加商圈名称
|
|
|
// 添加商圈名称
|
|
|
@ -115,7 +121,7 @@ public class WorkerController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/admin/edit", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "修改抢单工信息", notes = "需要通过下单编号获取订单信息") |
|
|
@ApiOperation(value = "修改配送员信息", notes = "需要通过下单编号获取订单信息") |
|
|
public Result edit(Worker u) { |
|
|
public Result edit(Worker u) { |
|
|
|
|
|
|
|
|
if (StrUtil.isNotBlank(u.getRegion())) { |
|
|
if (StrUtil.isNotBlank(u.getRegion())) { |
|
|
@ -133,9 +139,9 @@ public class WorkerController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@RequestMapping(value = "/admin/editApp", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/admin/editApp", method = RequestMethod.POST) |
|
|
@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.get(u.getWorkerId()); |
|
|
if (u.getDepoNum() != null && u.getDepoNum().compareTo(BigDecimal.ZERO) > 0) { |
|
|
if (u.getDepoNum() != null && u.getDepoNum().compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
|
|
|
|
|
@ -160,7 +166,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.get(workerId); |
|
|
worker.setWorkerStatus(WorkerConstant.WORKER_STATUS_DISABLE); |
|
|
worker.setWorkerStatus(WorkerConstant.WORKER_STATUS_DISABLE); |
|
|
@ -171,8 +177,8 @@ 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.get(workerId); |
|
|
//这儿暂时有bug,启用的时候其实需要判定原状态是启用还是不可接单状态,需要进行逻辑判断
|
|
|
//这儿暂时有bug,启用的时候其实需要判定原状态是启用还是不可接单状态,需要进行逻辑判断
|
|
|
worker.setWorkerStatus(WorkerConstant.WORKER_STATUS_NORMAL); |
|
|
worker.setWorkerStatus(WorkerConstant.WORKER_STATUS_NORMAL); |
|
|
@ -183,7 +189,7 @@ public class WorkerController { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 拉包工上线 |
|
|
* 配送员上线 |
|
|
* |
|
|
* |
|
|
* @param id |
|
|
* @param id |
|
|
* @return Result<Object> |
|
|
* @return Result<Object> |
|
|
@ -191,7 +197,7 @@ public class WorkerController { |
|
|
* @date 2024/2/2 |
|
|
* @date 2024/2/2 |
|
|
*/ |
|
|
*/ |
|
|
@RequestMapping(value = "/onLine", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/onLine", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "拉包工上线") |
|
|
@ApiOperation(value = "配送员上线") |
|
|
public Result<Object> onLine(String id) { |
|
|
public Result<Object> onLine(String id) { |
|
|
try { |
|
|
try { |
|
|
workerService.onLine(id); |
|
|
workerService.onLine(id); |
|
|
@ -211,7 +217,7 @@ public class WorkerController { |
|
|
* @date 2024/2/2 |
|
|
* @date 2024/2/2 |
|
|
*/ |
|
|
*/ |
|
|
@RequestMapping(value = "/offLine", method = RequestMethod.POST) |
|
|
@RequestMapping(value = "/offLine", method = RequestMethod.POST) |
|
|
@ApiOperation(value = "拉包工下线") |
|
|
@ApiOperation(value = "配送员下线") |
|
|
public Result<Object> offLine(String id) { |
|
|
public Result<Object> offLine(String id) { |
|
|
try { |
|
|
try { |
|
|
workerService.offLine(id); |
|
|
workerService.offLine(id); |
|
|
@ -221,4 +227,55 @@ public class WorkerController { |
|
|
return ResultUtil.error("下线失败"); |
|
|
return ResultUtil.error("下线失败"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 配送员匹配 DTO(前台传入参数) |
|
|
|
|
|
*/ |
|
|
|
|
|
@Data |
|
|
|
|
|
public static class WorkerMatchDTO { |
|
|
|
|
|
/** 取货区域id(商家所在区域) */ |
|
|
|
|
|
private String shopAreaId; |
|
|
|
|
|
/** 送货区域id(用户收货区域) */ |
|
|
|
|
|
private String putAreaId; |
|
|
|
|
|
/** 交易保障:true 只查 rebate_amount > 0 的配送员 */ |
|
|
|
|
|
private Boolean baozhang; |
|
|
|
|
|
/** 相同地址:true 只查手上有相同送货区域订单的配送员 */ |
|
|
|
|
|
private Boolean xiangtong; |
|
|
|
|
|
/** 搜索关键词:模糊匹配配送员姓名或手机号 */ |
|
|
|
|
|
private String keyword; |
|
|
|
|
|
/** |
|
|
|
|
|
* 排序字段: |
|
|
|
|
|
* score -> 评分倒序(默认) |
|
|
|
|
|
* avgTime -> 平均时长正序 |
|
|
|
|
|
* orderBkge -> 配送佣金正序 |
|
|
|
|
|
*/ |
|
|
|
|
|
private String sortField; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getMatchingWorkerList", method = RequestMethod.POST) |
|
|
|
|
|
@ApiOperation(value = "匹配抢单配送员列表") |
|
|
|
|
|
public Result<List<WorkerMatchVO>> getMatchingWorkerList(@RequestBody WorkerMatchDTO dto) { |
|
|
|
|
|
// 计算排序方向:avgTime/orderBkge 默认 ASC,score 默认 DESC
|
|
|
|
|
|
String sortOrder = "DESC"; |
|
|
|
|
|
if ("avgTime".equals(dto.getSortField()) || "orderBkge".equals(dto.getSortField())) { |
|
|
|
|
|
sortOrder = "ASC"; |
|
|
|
|
|
} |
|
|
|
|
|
List<WorkerMatchVO> list = workerRelaPriceMapper.getMatchingWorkerList( |
|
|
|
|
|
dto.getShopAreaId(), |
|
|
|
|
|
dto.getPutAreaId(), |
|
|
|
|
|
StrUtil.isBlank(dto.getKeyword()) ? null : dto.getKeyword().trim(), |
|
|
|
|
|
dto.getBaozhang(), |
|
|
|
|
|
dto.getXiangtong(), |
|
|
|
|
|
dto.getSortField(), |
|
|
|
|
|
sortOrder |
|
|
|
|
|
); |
|
|
|
|
|
return new ResultUtil<List<WorkerMatchVO>>().setData(list); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value = "/getOnlineWorkerByArea", method = RequestMethod.GET) |
|
|
|
|
|
@ApiOperation(value = "查询各食堂区域在线配送员数量") |
|
|
|
|
|
public Result<List<WorkerAreaOnlineCountVO>> getOnlineWorkerByArea(String parentId) { |
|
|
|
|
|
List<WorkerAreaOnlineCountVO> list = workerRelaPriceMapper.getOnlineWorkerCountByCanteenArea(parentId); |
|
|
|
|
|
return new ResultUtil<List<WorkerAreaOnlineCountVO>>().setData(list); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|