From 687dbd8e6ababc010a3da5503b95cd62cecf9f02 Mon Sep 17 00:00:00 2001
From: jiangqs <jiangqs>
Date: 星期二, 23 五月 2023 18:06:45 +0800
Subject: [PATCH] 拆分订单和商品服务

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

diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
index f3863f9..3005650 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/order/OrderServiceImpl.java
@@ -10,34 +10,25 @@
 import com.ruoyi.common.core.utils.uuid.IdUtils;
 import com.ruoyi.common.security.utils.SecurityUtils;
 import com.ruoyi.order.domain.dto.*;
-import com.ruoyi.order.domain.pojo.goods.Goods;
-import com.ruoyi.order.domain.pojo.goods.GoodsFile;
-import com.ruoyi.order.domain.pojo.goods.ShopGoods;
 import com.ruoyi.order.domain.pojo.order.ConsumerGoods;
 import com.ruoyi.order.domain.pojo.order.Order;
 import com.ruoyi.order.domain.pojo.order.OrderGoods;
-import com.ruoyi.order.domain.pojo.order.ShoppingCart;
 import com.ruoyi.order.domain.vo.*;
-import com.ruoyi.order.service.goods.GoodsFileService;
-import com.ruoyi.order.service.goods.ShopGoodsService;
 import com.ruoyi.order.service.order.ConsumerGoodsService;
 import com.ruoyi.order.service.order.OrderGoodsService;
-import com.ruoyi.order.service.order.ShoppingCartService;
 import com.ruoyi.order.util.CodeFactoryUtil;
-import com.ruoyi.system.api.RemoteMemberService;
-import com.ruoyi.system.api.RemoteShopService;
-import com.ruoyi.system.api.RemoteUserService;
+import com.ruoyi.system.api.domain.dto.*;
+import com.ruoyi.system.api.service.*;
 import com.ruoyi.system.api.constant.AppErrorConstant;
-import com.ruoyi.system.api.domain.dto.AppBaseGetDto;
-import com.ruoyi.system.api.domain.dto.AppMemberBindingDto;
-import com.ruoyi.system.api.domain.dto.AppMemberGoodsTypeDto;
+import com.ruoyi.system.api.domain.poji.goods.Goods;
+import com.ruoyi.system.api.domain.poji.goods.GoodsFile;
+import com.ruoyi.system.api.domain.poji.goods.ShopGoods;
 import com.ruoyi.system.api.domain.poji.member.Member;
 import com.ruoyi.system.api.domain.poji.shop.Shop;
 import com.ruoyi.system.api.domain.poji.sys.SysUser;
 import com.ruoyi.system.api.domain.vo.AppOrderTotalVo;
 import com.ruoyi.system.api.domain.vo.AppUserCouponVo;
 import com.ruoyi.order.mapper.order.OrderMapper;
-import com.ruoyi.order.service.goods.GoodsService;
 import com.ruoyi.order.service.order.OrderService;
 import com.ruoyi.system.api.domain.vo.MerHomeShopTotalVo;
 import org.springframework.stereotype.Service;
@@ -63,16 +54,7 @@
     private OrderMapper orderMapper;
 
     @Resource
-    private GoodsService goodsService;
-
-    @Resource
-    private ShopGoodsService shopGoodsService;
-
-    @Resource
     private RemoteMemberService remoteMemberService;
-
-    @Resource
-    private GoodsFileService goodsFileService;
 
     @Resource
     private OrderGoodsService orderGoodsService;
@@ -87,7 +69,11 @@
     private ConsumerGoodsService consumerGoodsService;
 
     @Resource
-    private ShoppingCartService shoppingCartService;
+    private RemoteGoodsService remoteGoodsService;
+
+    @Resource
+    private RemoteShoppingCartService remoteShoppingCartService;
+
 
     /**
      * @description: buyGoods
@@ -132,19 +118,22 @@
             goodsId = appBuyGoodsDto.getGoodsId();
             buyNum = appBuyGoodsDto.getBuyNum();
             userCouponId = appBuyGoodsDto.getUserCouponId();
-            goods = goodsService.getById(goodsId);
+            goods = remoteGoodsService.getGoods(goodsId).getData();
             appSureOrderGoodsVo.setGoodsId(goodsId);
             appSureOrderGoodsVo.setGoodsName(goods.getGoodsName());
             appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction());
             appSureOrderGoodsVo.setGoodsType(goods.getGoodsType());
             //商品图片
-            goodsFile = goodsFileService.getGoodsPicture(goodsId);
+            goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData();
             appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl());
             buyNum = appBuyGoodsDto.getBuyNum();
             appSureOrderGoodsVo.setBuyNum(buyNum);
             goodsPrice = goods.getSalesPrice();
             //商户定制价格
-            ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(appSureOrderDto.getShopId(),goods.getGoodsId());
+            AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto();
+            appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
+            appShopGoodsGetDto.setShopId(appSureOrderDto.getShopId());
+            ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
             if(shopGoods!=null){
                 goodsPrice = shopGoods.getSalesPrice();
             }
@@ -250,27 +239,29 @@
         String orderNo = CodeFactoryUtil.getShopOrderNo();
         OrderGoods orderGoods;
         String orderGoodsId;
-        ShoppingCart shoppingCart;
         HashSet<String> goodsTypeSet = new HashSet<>();
         for(AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList){
             appSureOrderGoodsVo = new AppSureOrderGoodsVo();
             useCoupon = 0;
             goodsId = appBuyGoodsDto.getGoodsId();
             userCouponId = appBuyGoodsDto.getUserCouponId();
-            goods = goodsService.getById(goodsId);
+            goods = remoteGoodsService.getGoods(goodsId).getData();
             appSureOrderGoodsVo.setGoodsId(goodsId);
             appSureOrderGoodsVo.setGoodsName(goods.getGoodsName());
             appSureOrderGoodsVo.setGoodsIntroduction(goods.getGoodsIntroduction());
             appSureOrderGoodsVo.setGoodsType(goods.getGoodsType());
             //商品图片
-            goodsFile = goodsFileService.getGoodsPicture(goodsId);
+            goodsFile = remoteGoodsService.getGoodsFile(goodsId).getData();
             appSureOrderGoodsVo.setGoodsPicture(goodsFile.getFileUrl());
             buyNum = appBuyGoodsDto.getBuyNum();
             appSureOrderGoodsVo.setBuyNum(buyNum);
             goodsPrice = goods.getSalesPrice();
             serviceNum = goods.getServiceNum();
             //商户定制价格
-            ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(appPlaceOrderDto.getShopId(),goods.getGoodsId());
+            AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto();
+            appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
+            appShopGoodsGetDto.setShopId(appPlaceOrderDto.getShopId());
+            ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
             if(shopGoods!=null){
                 goodsPrice = shopGoods.getSalesPrice();
                 serviceNum = shopGoods.getServiceNum();
@@ -335,7 +326,10 @@
             orderGoods.setGoodsType(goods.getGoodsType());
             orderGoodsService.save(orderGoods);
             //清空购物车
-            shoppingCartService.deleteByUserIdAndGoodsId(userId,goodsId);
+            AppShoppingCartDelDto appShoppingCartDelDto = new AppShoppingCartDelDto();
+            appShoppingCartDelDto.setGoodsId(goodsId);
+            appShoppingCartDelDto.setUserId(userId);
+            remoteShoppingCartService.deleteShoppingCart(appShoppingCartDelDto);
             if(goods.getGoodsType()==1){
                 goodsTypeSet.add("周期");
             }else if(goods.getGoodsType()==2){
@@ -359,6 +353,7 @@
         order.setCouponMoney(couponDiscount);
         order.setDiscountMoney(couponDiscount);
         order.setReceivableMoney(orderPayMoney);
+        order.setReceivableDeposit(orderPayDeposit);
         order.setPayType(appPlaceOrderDto.getPayType());
         if(order.getPayType()==1){
             order.setPayMoney(orderPayMoney);
@@ -540,6 +535,9 @@
         merVerifyOrderVo.setReceivableMoney(order.getReceivableMoney());
         merVerifyOrderVo.setPayMoney(order.getPayMoney());
         merVerifyOrderVo.setOrderRemark(order.getOrderRemark());
+        merVerifyOrderVo.setCreateTime(order.getCreateTime());
+        merVerifyOrderVo.setPayTime(order.getPayTime());
+        merVerifyOrderVo.setUseTime(order.getUseTime());
         merVerifyOrderVo.setAppUserOrderGoodsPageVoList(appUserOrderGoodsPageVoList);
         SysUser sysUser = remoteUserService.getSysUser(order.getUserId()).getData();
         merVerifyOrderVo.setUserName(sysUser.getNickName());
@@ -623,8 +621,12 @@
     public List<MerMemberNoClearOrderVo> pageMerMemberNoClearOrder(Page page, MerMemberNoClearOrderDto merMemberNoClearOrderDto){
         List<MerMemberNoClearOrderVo> merMemberNoClearOrderVoList = orderMapper.pageMerMemberNoClearOrder(page,merMemberNoClearOrderDto.getMemberUserId());
         if(merMemberNoClearOrderVoList!=null&&!merMemberNoClearOrderVoList.isEmpty()){
+            BigDecimal zeroBig = new BigDecimal("0.00");
             for(MerMemberNoClearOrderVo merMemberNoClearOrderVo : merMemberNoClearOrderVoList){
                 merMemberNoClearOrderVo.setUnPaidMoney(merMemberNoClearOrderVo.getReceivableMoney().subtract(merMemberNoClearOrderVo.getPayMoney()));
+                if(merMemberNoClearOrderVo.getUnPaidMoney()==null){
+                    merMemberNoClearOrderVo.setUnPaidMoney(zeroBig);
+                }
             }
         }
         return merMemberNoClearOrderVoList;
@@ -706,12 +708,15 @@
         for(AppBuyGoodsDto appBuyGoodsDto : appBuyGoodsDtoList){
             goodsId = appBuyGoodsDto.getGoodsId();
             userCouponId = appBuyGoodsDto.getUserCouponId();
-            goods = goodsService.getById(goodsId);
+            goods = remoteGoodsService.getGoods(goodsId).getData();
             buyNum = appBuyGoodsDto.getBuyNum();
             goodsPrice = goods.getSalesPrice();
             serviceNum = goods.getServiceNum();
             //商户定制价格
-            ShopGoods shopGoods = shopGoodsService.getByShopIdAndGoodsId(merNewOrderDto.getShopId(),goods.getGoodsId());
+            AppShopGoodsGetDto appShopGoodsGetDto = new AppShopGoodsGetDto();
+            appShopGoodsGetDto.setGoodsId(goods.getGoodsId());
+            appShopGoodsGetDto.setShopId(merNewOrderDto.getShopId());
+            ShopGoods shopGoods = remoteGoodsService.getShopGoods(appShopGoodsGetDto).getData();
             if(shopGoods!=null){
                 goodsPrice = shopGoods.getSalesPrice();
                 serviceNum = shopGoods.getServiceNum();
@@ -780,6 +785,7 @@
         order.setCouponMoney(couponDiscount);
         order.setDiscountMoney(couponDiscount);
         order.setReceivableMoney(orderPayMoney);
+        order.setReceivableDeposit(new BigDecimal("0.00"));
         order.setPayType(1);
         if(order.getPayType()==1){
             order.setPayMoney(orderPayMoney);
@@ -849,6 +855,7 @@
             Member member;
             Integer orderFrom;
             String orderFromDesc;
+            BigDecimal zeroBig = new BigDecimal("0.00");
             for(MerOrderPageVo merOrderPageVo : merOrderPageVoList){
                 userId = merOrderPageVo.getUserId();
                 member = remoteMemberService.getMember(userId).getData();
@@ -875,6 +882,10 @@
                     orderFromDesc = "商城订单";
                 }
                 merOrderPageVo.setOrderFromDesc(orderFromDesc);
+                merOrderPageVo.setUnPaidMoney(merOrderPageVo.getReceivableMoney().subtract(merOrderPageVo.getPayMoney()));
+                if(merOrderPageVo.getUnPaidMoney()==null){
+                    merOrderPageVo.setUnPaidMoney(zeroBig);
+                }
             }
         }
         return merOrderPageVoList;
@@ -890,8 +901,12 @@
     public List<MerMemberNoClearOrderVo> pageMerMemberOrder(Page page, MerMemberNoClearOrderDto merMemberNoClearOrderDto){
         List<MerMemberNoClearOrderVo> merMemberNoClearOrderVoList = orderMapper.pageMerMemberOrder(page,merMemberNoClearOrderDto.getMemberUserId());
         if(merMemberNoClearOrderVoList!=null&&!merMemberNoClearOrderVoList.isEmpty()){
+            BigDecimal zeroBig = new BigDecimal("0.00");
             for(MerMemberNoClearOrderVo merMemberNoClearOrderVo : merMemberNoClearOrderVoList){
                 merMemberNoClearOrderVo.setUnPaidMoney(merMemberNoClearOrderVo.getReceivableMoney().subtract(merMemberNoClearOrderVo.getPayMoney()));
+                if(merMemberNoClearOrderVo.getUnPaidMoney()==null){
+                    merMemberNoClearOrderVo.setUnPaidMoney(zeroBig);
+                }
             }
         }
         return merMemberNoClearOrderVoList;

--
Gitblit v1.7.1