From a8d2cb07f6440dc54dc4005b0b06d5a47cb1517d Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期一, 16 十二月 2024 13:34:03 +0800
Subject: [PATCH] 12.16

---
 ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java |   83 ++++++++++++++++++++++++-----------------
 1 files changed, 48 insertions(+), 35 deletions(-)

diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
index 9bfd041..433629f 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -12,26 +12,25 @@
 import com.ruoyi.common.core.utils.StringUtils;
 import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.order.enums.OrderStatus;
-import com.ruoyi.order.enums.OrderType;
 import com.ruoyi.order.mapper.OrderGoodMapper;
 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.CouponInfo;
-import com.ruoyi.other.api.domain.Goods;
-import com.ruoyi.other.api.domain.OrderActivityInfo;
-import com.ruoyi.other.api.domain.Technician;
-import com.ruoyi.other.api.feignClient.GoodsClient;
+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.stereotype.Service;
 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;
@@ -57,7 +56,11 @@
     @Resource
     private TechnicianClient technicianClient;
     @Resource
-    private GoodsClient goodsClient;
+    private ShopClient shopClient;
+    @Resource
+    private CommissionService commissionService;
+    @Resource
+    private BaseSettingClient baseSettingClient;
 
 
     @Override
@@ -74,6 +77,10 @@
         if (order == null){
             throw new ServiceException("订单不存在");
         }
+        R<Shop> shopR = shopClient.getShopById(order.getShopId());
+        if (!R.isSuccess(shopR)){
+            throw new ServiceException("获取门店信息失败");
+        }
 
         // 商品
         List<OrderGood> orderGoods = orderGoodMapper.selectList(new LambdaQueryWrapper<OrderGood>()
@@ -83,17 +90,14 @@
         for (OrderGood orderGood : orderGoods) {
             String goodJson = orderGood.getGoodJson();
             Goods goods = JSONObject.parseObject(goodJson, Goods.class);
-
             OrderGoodsVO orderGoodsVO = new OrderGoodsVO();
             orderGoodsVO.setGoodsId(orderGood.getGoodsId());
             orderGoodsVO.setNum(orderGood.getNum());
-            if (goods != null){
-                orderGoodsVO.setGoodsName(goods.getName());
-                orderGoodsVO.setType(goods.getType());
-                orderGoodsVO.setGoodsPic(goods.getHomePagePicture());
-                orderGoodsVO.setSellingPrice(goods.getSellingPrice());
-                orderGoodsVO.setOriginalPrice(goods.getOriginalPrice());
-            }
+            orderGoodsVO.setGoodsName(goods.getName());
+            orderGoodsVO.setType(goods.getType());
+            orderGoodsVO.setGoodsPic(goods.getHomePagePicture());
+            orderGoodsVO.setSellingPrice(goods.getSellingPrice());
+            orderGoodsVO.setOriginalPrice(goods.getOriginalPrice());
             goodsList.add(orderGoodsVO);
         }
 
@@ -129,8 +133,15 @@
             orderDetailVO.setDistributionMode(goods.getDistributionMode());
         }
 
-
-
+        Technician technician = new Technician();
+        if (order.getTechnicianId() != null){
+            R<Technician> shopdetail = technicianClient.shopdetail(order.getTechnicianId());
+            if (shopdetail.getCode() != R.SUCCESS){
+                throw new ServiceException("获取技师信息失败");
+            }
+            technician = shopdetail.getData();
+        }
+        Shop shop = shopR.getData();
         orderDetailVO.setId(order.getId());
         orderDetailVO.setOrderStatus(order.getOrderStatus());
         orderDetailVO.setPoint(order.getPoint());
@@ -148,6 +159,12 @@
         orderDetailVO.setPointAmount(order.getGetPoint());
         orderDetailVO.setPaymentAmount(order.getPaymentAmount());
         orderDetailVO.setGoodsList(goodsList);
+        orderDetailVO.setShopName(shop.getName());
+        orderDetailVO.setShopAddress(shop.getAddress());
+        orderDetailVO.setLongitude(shop.getLongitude());
+        orderDetailVO.setLatitude(shop.getLatitude());
+        orderDetailVO.setShopId(shop.getId());
+        orderDetailVO.setTechnicianName(technician.getName());
         return orderDetailVO;
     }
 
@@ -183,7 +200,7 @@
     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("订单不存在");
@@ -191,23 +208,19 @@
         order.setOrderStatus(OrderStatus.COMPLETED.getCode());
         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("获取技师信息失败");
-            }
-            Technician technician = shopdetail.getData();
-            R<Void> r = technicianClient.updateStatus(2, technician.getId());
-            if (r.getCode() != R.SUCCESS){
-                throw new ServiceException("修改技师状态失败");
-            }
+
+        // 售后设置
+        R<BaseSetting> baseSettingR = baseSettingClient.getBaseSetting(5);
+        if (R.isError(baseSettingR)) {
+            throw new ServiceException("售后设置获取失败");
         }
-    }
-
-
-
-    @Override
-    public void commission(Long orderId) {
-
+        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));
     }
 }

--
Gitblit v1.7.1