| | |
| | | import com.ruoyi.order.mapper.OrderMapper; |
| | | import com.ruoyi.order.model.Order; |
| | | import com.ruoyi.order.model.OrderGood; |
| | | import com.ruoyi.order.service.CommissionService; |
| | | import com.ruoyi.order.service.OrderService; |
| | | import com.ruoyi.order.vo.OrderDetailVO; |
| | | import com.ruoyi.order.vo.OrderGoodsVO; |
| | | import com.ruoyi.order.vo.OrderVO; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.api.feignClient.BaseSettingClient; |
| | | import com.ruoyi.other.api.feignClient.ShopClient; |
| | | import com.ruoyi.other.api.feignClient.TechnicianClient; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | |
| | | private TechnicianClient technicianClient; |
| | | @Resource |
| | | private ShopClient shopClient; |
| | | @Resource |
| | | private CommissionService commissionService; |
| | | @Resource |
| | | private BaseSettingClient baseSettingClient; |
| | | |
| | | |
| | | @Override |
| | |
| | | } |
| | | technician = shopdetail.getData(); |
| | | } |
| | | R<TechnicianSubscribe> subscribeR = technicianClient.getSubscribeByOrderId(orderId); |
| | | if (!R.isSuccess(subscribeR)){ |
| | | throw new ServiceException("获取预约信息失败"); |
| | | } |
| | | TechnicianSubscribe subscribe = subscribeR.getData(); |
| | | |
| | | Shop shop = shopR.getData(); |
| | | orderDetailVO.setId(order.getId()); |
| | | orderDetailVO.setOrderStatus(order.getOrderStatus()); |
| | |
| | | orderDetailVO.setLatitude(shop.getLatitude()); |
| | | orderDetailVO.setShopId(shop.getId()); |
| | | orderDetailVO.setTechnicianName(technician.getName()); |
| | | orderDetailVO.setTechnicianSubscribeId(String.valueOf(subscribe.getId())); |
| | | return orderDetailVO; |
| | | } |
| | | |
| | |
| | | public void writeOff(String code,Integer shopId) { |
| | | LoginUser loginUserApplet = tokenService.getLoginUserApplet(); |
| | | Order order = orderMapper.selectOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getOrderNumber, code)); |
| | | .eq(Order::getId, code)); |
| | | boolean check = check(order, shopId, loginUserApplet.getUserid()); |
| | | if (!check){ |
| | | throw new ServiceException("订单不存在"); |
| | |
| | | orderMapper.updateById(order); |
| | | Integer orderType = order.getOrderType(); |
| | | if (orderType.equals(OrderType.SERVICE.getCode())){ |
| | | R<Technician> shopdetail = technicianClient.shopdetail(order.getTechnicianId()); |
| | | if (shopdetail.getCode() != R.SUCCESS){ |
| | | throw new ServiceException("获取技师信息失败"); |
| | | R<TechnicianSubscribe> subscribeR = technicianClient.getSubscribeByOrderId(order.getId()); |
| | | if (R.isError(subscribeR)){ |
| | | throw new ServiceException("获取预约信息失败"); |
| | | } |
| | | Technician technician = shopdetail.getData(); |
| | | R<Void> r = technicianClient.updateStatus(2, technician.getId()); |
| | | if (r.getCode() != R.SUCCESS){ |
| | | throw new ServiceException("修改技师状态失败"); |
| | | TechnicianSubscribe subscribe = subscribeR.getData(); |
| | | subscribe.setStatus(2); |
| | | R<Void> r = technicianClient.updateStatus(subscribe.getStatus(), subscribe.getId()); |
| | | if (R.isError(r)){ |
| | | throw new ServiceException("更新预约状态失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public void commission(Long orderId) { |
| | | |
| | | // 售后设置 |
| | | R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5); |
| | | if (R.isError(baseSettingR)) { |
| | | throw new ServiceException("售后设置获取失败"); |
| | | } |
| | | BaseSetting baseSetting = baseSettingR.getData(); |
| | | if (baseSetting == null) { |
| | | throw new ServiceException("售后设置获取失败"); |
| | | } |
| | | String content = baseSetting.getContent(); |
| | | JSONObject jsonObject = JSONObject.parseObject(content); |
| | | Long days = jsonObject.getLong("days"); |
| | | commissionService.addToCommissionDelayQueue(order.getId(), LocalDateTime.now().plusDays(days)); |
| | | } |
| | | } |