| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | |
| | | /** |
| | | * 订单改派详情 |
| | | * |
| | | * @param changeDispatch 订单改派信息 |
| | | */ |
| | | @ApiOperation(value = "新增订单改派", tags = {"后台-系统设置-订单改派管理"}) |
| | | @PostMapping(value = "/save") |
| | | public R<Boolean> save(@RequestBody ChangeDispatch changeDispatch) { |
| | | return R.ok(changeDispatchService.save(changeDispatch)); |
| | | } |
| | | |
| | | /** |
| | | * 订单改派详情 |
| | | * |
| | | * @param id 订单改派id |
| | | */ |
| | | @RequiresPermissions("reassignment_apply") |
| | |
| | | }) |
| | | public R<ChangeDispatch> detail(@RequestParam Integer id) { |
| | | return R.ok(changeDispatchService.getById(id)); |
| | | } |
| | | |
| | | /** |
| | | * 订单改派详情 远程调用 |
| | | * |
| | | * @param id 订单id |
| | | */ |
| | | @GetMapping(value = "/one") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单改派id", name = "id", dataType = "Integer", required = true) |
| | | }) |
| | | public R<ChangeDispatch> one(@RequestParam("id") Integer id) { |
| | | ChangeDispatch changeDispatch = changeDispatchService.lambdaQuery() |
| | | .eq(ChangeDispatch::getOrderId, id) |
| | | .eq(ChangeDispatch::getState, Constants.ZERO) |
| | | .one(); |
| | | return R.ok(changeDispatch); |
| | | } |
| | | |
| | | /** |
| | |
| | | /** |
| | | * 订单改派师傅 |
| | | * |
| | | * @param orderId 订单id |
| | | * @param changeId 改派订单id |
| | | * @param workerId 师傅id |
| | | */ |
| | | @RequiresPermissions("reassignment_apply") |
| | |
| | | @GetMapping(value = "/changeWorker") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "改派订单id", name = "changeId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "师傅id", name = "workerId", dataType = "Integer", required = true) |
| | | }) |
| | | public R<String> changeWorker(@RequestParam Integer changeId, @RequestParam Integer orderId, @RequestParam Integer workerId) { |
| | | public R<String> changeWorker(@RequestParam Integer changeId, @RequestParam Integer workerId) { |
| | | ChangeDispatch changeDispatch = changeDispatchService.lambdaQuery().eq(ChangeDispatch::getId, changeId) |
| | | .eq(ChangeDispatch::getIsDelete, 0).one(); |
| | | if (null == changeDispatch || Constants.ONE.equals(changeDispatch.getState())) { |
| | | throw new GlobalException("改派申请不存在或已改派!"); |
| | | } |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderId).eq(Order::getIsDelete, 0).one(); |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, changeDispatch.getOrderId()) |
| | | .eq(Order::getIsDelete, 0).one(); |
| | | if (null == order) { |
| | | throw new GlobalException("订单不存在!"); |
| | | } |
| | |
| | | if (null == masterWorker) { |
| | | throw new GlobalException("服务人员信息异常!"); |
| | | } |
| | | // 原订单状态改为 6:已改派 |
| | | // 原订单状态改为 5:已改派 |
| | | order.setState(Constants.FIVE); |
| | | boolean orderUpdate = orderService.updateById(order); |
| | | // 生成新订单信息 |