| | |
| | | package com.ruoyi.worker.controller; |
| | | |
| | | |
| | | import com.ruoyi.admin.api.entity.ExchangeDispatch; |
| | | import com.ruoyi.admin.api.entity.ChangeDispatch; |
| | | import com.ruoyi.admin.api.feignClient.AdminClient; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.worker.entity.Evaluate; |
| | | import com.ruoyi.worker.entity.MasterWorker; |
| | |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | ChangeDispatch data = adminClient.changeDispatchOne(orderId).getData(); |
| | | if (null != data) { |
| | | return R.fail("当前订单已提交改派申请!"); |
| | | } |
| | | MasterWorker masterWorker = masterWorkerService.getById(loginWorker.getUserid()); |
| | | // 订单改派信息 |
| | | ExchangeDispatch exchangeDispatch = new ExchangeDispatch(); |
| | | exchangeDispatch.setWorkerId(masterWorker.getId()); |
| | | exchangeDispatch.setWorkerName(masterWorker.getRealName()); |
| | | exchangeDispatch.setApplyReason(reason); |
| | | exchangeDispatch.setApplyTime(DateUtils.getNowDate()); |
| | | exchangeDispatch.setState(0); |
| | | ChangeDispatch changeDispatch = new ChangeDispatch(); |
| | | changeDispatch.setWorkerId(masterWorker.getId()); |
| | | changeDispatch.setWorkerName(masterWorker.getRealName()); |
| | | changeDispatch.setApplyReason(reason); |
| | | changeDispatch.setApplyTime(DateUtils.getNowDate()); |
| | | changeDispatch.setState(0); |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderId).eq(Order::getIsDelete, 0).one(); |
| | | if (null == order) { |
| | | throw new GlobalException("订单信息异常!"); |
| | | } |
| | | exchangeDispatch.setOrderId(orderId); |
| | | exchangeDispatch.setOrderNumber(order.getOrderNumber()); |
| | | exchangeDispatch.setUserId(order.getUserId()); |
| | | exchangeDispatch.setUserName(order.getReservationName()); |
| | | changeDispatch.setOrderId(orderId); |
| | | changeDispatch.setOrderNumber(order.getOrderNumber()); |
| | | changeDispatch.setUserId(order.getUserId()); |
| | | changeDispatch.setUserName(order.getReservationName()); |
| | | // 添加改派信息 |
| | | Boolean save = adminClient.changeDispatchSave(exchangeDispatch).getData(); |
| | | Boolean save = adminClient.changeDispatchSave(changeDispatch).getData(); |
| | | return save ? R.ok() : R.fail(); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param orderId 订单id |
| | | */ |
| | | @ApiOperation(value = "订单路线导航", tags = {"师傅端-首页"}) |
| | | @GetMapping(value = "/orderNavigation") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "师傅所在经度", name = "longitude", dataType = "String", required = true), |
| | | @ApiImplicitParam(value = "师傅所在纬度", name = "latitude", dataType = "String", required = true) |
| | | }) |
| | | public R<Object> orderNavigation(@RequestParam Integer orderId, @RequestParam String longitude, |
| | | @RequestParam String latitude) { |
| | | LoginUserInfo loginWorker = tokenService.getLoginUserByWorker(); |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderId) |
| | | .eq(Order::getServerId, loginWorker.getUserid()) |
| | | .eq(Order::getIsDelete, 0).one(); |
| | | if (null == order) { |
| | | throw new GlobalException("请确认当前订单所派单师傅是否是您!"); |
| | | } |
| | | // 用户下单经纬度 |
| | | Double userLongitude = order.getLongitude(); |
| | | Double userLatitude = order.getLatitude(); |
| | | String userPosition = userLongitude + "," + userLatitude; |
| | | // 师傅当前位置 经纬度 |
| | | String workerPosition = longitude + "," + latitude; |
| | | return R.ok(orderService.orderNavigation(userPosition, workerPosition)); |
| | | } |
| | | |
| | | /** |
| | | * 师傅端-已到达预约地点 |
| | | * |
| | | * @param orderId 订单id |
| | | */ |
| | | @ApiOperation(value = "已到达预约地点", tags = {"师傅端-订单列表"}) |
| | | @GetMapping(value = "/reachPosition") |
| | | @ApiImplicitParams({ |