From efe9744eb6651298be9f48b84a5f17c58d7b64eb Mon Sep 17 00:00:00 2001
From: rentaiming <806181062@qq.com>
Date: 星期五, 19 七月 2024 14:10:26 +0800
Subject: [PATCH] 修改bug

---
 ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java |  120 +++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 94 insertions(+), 26 deletions(-)

diff --git a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
index 595a1a4..a330f40 100644
--- a/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
+++ b/ruoyi-modules/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/OrderServiceImpl.java
@@ -36,7 +36,18 @@
 import com.ruoyi.order.util.OrderUtil;
 import com.ruoyi.order.util.SinataUtil;
 import com.ruoyi.system.api.constants.DelayTaskEnum;
-import com.ruoyi.system.api.domain.*;
+import com.ruoyi.system.api.domain.AuctionSalesroom;
+import com.ruoyi.system.api.domain.CouponMember;
+import com.ruoyi.system.api.domain.CustomConfig;
+import com.ruoyi.system.api.domain.DelayTask;
+import com.ruoyi.system.api.domain.GoodsGroupPurchase;
+import com.ruoyi.system.api.domain.GoodsGroupPurchaseInfo;
+import com.ruoyi.system.api.domain.GoodsSeckill;
+import com.ruoyi.system.api.domain.GoodsSku;
+import com.ruoyi.system.api.domain.Member;
+import com.ruoyi.system.api.domain.MemberAddress;
+import com.ruoyi.system.api.domain.Order;
+import com.ruoyi.system.api.domain.OrderAuctionBond;
 import com.ruoyi.system.api.domain.dto.CouponMemberDTO;
 import com.ruoyi.system.api.domain.dto.GoodsStockUpdDTO;
 import com.ruoyi.system.api.domain.dto.HomeGoodsSkuDTO;
@@ -60,7 +71,10 @@
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.time.LocalDateTime;
-import java.util.*;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.function.Function;
 import java.util.regex.Matcher;
@@ -71,6 +85,7 @@
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * <p>
@@ -123,6 +138,7 @@
     private  GoodsSkuClient GoodsSkuClient;
 
 
+
     @Override
     public void saveOrderOne(OrderDTO OrderDTO) {
         Order order=new Order();
@@ -162,6 +178,7 @@
         order.setSkuName(OrderDTO.getSkuName());
         order.setPrice(OrderDTO.getPrice());
         order.setCoverPic(OrderDTO.getCoverPic());
+        order.setOrderTimeSx(OrderDTO.getOrderTimeSx());
         this.save(order);
 
         if (OrderDTO.getOrderFrom().getCode()==4){
@@ -331,9 +348,12 @@
 
 
             GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData();
-            if (data.getLimitNumber()<num1) {
-                throw new ServiceException("该商品已售罄,暂无库存");
+            if (data.getLimitNumber()!=0){
+                if (data.getLimitNumber()<num1) {
+                    throw new ServiceException("对不起,大于商品购买数");
+                }
             }
+
 
             order.setOrderFrom(OrderFromEnum.SNAP_ORDERS);
             memberOrderVO.setGoodsSkuId(memberOrderDTO.getGoodsSkuId());
@@ -381,8 +401,6 @@
             memberOrderVO.setYouhiPrice(data.getGroupPurchasePrice());
             pice=data.getGroupPurchasePrice();
 
-
-
             order.setSkuName(goodsSku.getSkuName());
             order.setPrice(data.getGroupPurchasePrice());
             order.setCoverPic(goodsSku.getCoverPic());
@@ -412,6 +430,11 @@
             order.setReceiverCity(data.getReceiverCity());
             order.setReceiverDetailAddress(data.getDetailedAddress());
             order.setReceiverPhone(data.getRecipientPhone());
+
+            memberOrderVO.setReceiverName(data.getRecipientName());
+            memberOrderVO.setReceiverCity(data.getReceiverCity());
+            memberOrderVO.setReceiverDetailAddress(data.getDetailedAddress());
+            memberOrderVO.setReceiverphone(data.getRecipientPhone());
         }
 
         order.setGoodsSkuId(memberOrderDTO.getGoodsSkuId());
@@ -494,17 +517,22 @@
                 memberOrderDTO1.setGoodsSkuId(order.getGoodsSkuId());
                 Integer num=baseMapper.getSeckillMembers1(memberOrderDTO1);
                 Integer num1=0;
-                if (num!=null){
-                    num1 =num+order.getGoodsQuantity();
+                if(num!=order.getGoodsQuantity()){
+                    if (num!=null){
+                        num1 =num+order.getGoodsQuantity();
+                    }else{
+                        num1=order.getGoodsQuantity();
+                    }
                 }else{
-                    num1=order.getGoodsQuantity();
+                      num1=num;
                 }
+
 
                 GoodsSeckill data = goodsSkuClient.getGoodsSeckillOne(order.getGoodsSkuId(), SecurityConstants.INNER).getData();
                 GoodsSku goodsSku = goodsSkuClient.getGoodsSkuOne(data.getGoodsSkuId(), SecurityConstants.INNER).getData();
 
                 if (num1!=order.getGoodsQuantity()){
-                    if (data.getLimitNumber()<num1){
+                    if (data.getLimitNumber()!=0||data.getLimitNumber()<num1){
                         throw new ServiceException("对不起,大于商品购买数");
                     }else{
 
@@ -593,6 +621,7 @@
                         pice=pice.subtract(data.getReductionAmount());
                         order.setDiscountMoney(data.getReductionAmount());
                     }else{
+                        order.setDiscountMoney(pice);
                         pice=new BigDecimal(0);
 
                     }
@@ -600,10 +629,13 @@
                 if (data.getCouponType().getCode()==2){
                     pice= order.getTotalAmount();
                     if(pice.compareTo(data.getVoucherAmount())<0){
-                        throw new ServiceException("优惠卷抵扣金额不能大于实际支付金额");
+                        order.setDiscountMoney(pice);
+                        pice=new BigDecimal(0);
+                    }else{
+                        pice=pice.subtract(data.getVoucherAmount());
+                        order.setDiscountMoney(data.getVoucherAmount());
                     }
-                    pice=pice.subtract(data.getVoucherAmount());
-                    order.setDiscountMoney(data.getVoucherAmount());
+
                 }
                 if (data.getCouponType().getCode()==3){
                     pice= order.getTotalAmount();
@@ -614,17 +646,20 @@
                         pice3=new BigDecimal(data.getMaxDiscount().doubleValue());
                     }
                     if(pice.compareTo(pice3)<0){
-                        throw new ServiceException("优惠卷抵扣金额不能大于实际支付金额");
+                        BigDecimal pice4= pice.subtract(pice3);
+                        if (pice4.doubleValue()>data.getMaxDiscount().doubleValue()){
+                            pice=pice.subtract(data.getMaxDiscount());
+                            order.setDiscountMoney(data.getMaxDiscount());
+                        }else{
+                            order.setDiscountMoney(pice4);
+                            pice=pice3;
+                        }
+                    }else{
+                        order.setDiscountMoney(pice);
+                        pice=new BigDecimal(0);
                     }
 
-                    BigDecimal pice4= pice.subtract(pice3);
-                    if (pice4.doubleValue()>data.getMaxDiscount().doubleValue()){
-                        pice=pice.subtract(data.getMaxDiscount());
-                        order.setDiscountMoney(data.getMaxDiscount());
-                    }else{
-                        order.setDiscountMoney(pice4);
-                        pice=pice3;
-                    }
+
 
                 }
                 order.setCouponId(memberOrderDTO.getCouponId());
@@ -687,7 +722,7 @@
         Page<Order> page = new Page<>(memberOrderListDTO.getPageCurr(), memberOrderListDTO.getPageSize());
         LambdaQueryWrapper<Order> wrapper= Wrappers.lambdaQuery();
         wrapper.eq(Order::getMemberId,memberOrderListDTO.getMemberId());
-        if(memberOrderListDTO.getGoodsSkuName()!=null){
+        if(memberOrderListDTO.getGoodsSkuName()!=null&&memberOrderListDTO.getGoodsSkuName()!=""){
             wrapper.like(Order::getSkuName,memberOrderListDTO.getGoodsSkuName());
         }
         if(memberOrderListDTO.getOrderNo()!=null){
@@ -745,6 +780,11 @@
             }else {
                 MemberOrderList.setIsAuctionBond(1);
             }
+
+            CustomConfig memberPointsPoints = sysUserClient.getconfig("MALL_ORDER_DESCRIPTION").getData();
+            MemberOrderList.setOrderShuoMin(memberPointsPoints.getConfigValue());
+            CustomConfig ReturnCycle = sysUserClient.getconfig("RETURN_CYCLE").getData();
+            MemberOrderList.setOrderZq(Integer.valueOf(ReturnCycle.getConfigValue()));
         }
 
 
@@ -1172,8 +1212,9 @@
             pageVO = PageDTO.empty(page);
         }
         pageVO = PageDTO.of(page, MgtOrderVO.class);
+        List<MgtOrderVO> voList = pageVO.getList();
         if (query.getOrderFrom() == OrderFromEnum.AUCTION_ORDERS) {
-            List<MgtOrderVO> list = pageVO.getList();
+            List<MgtOrderVO> list = voList;
             // 封装参数查询拍卖会
             Set<Long> auctionSalesroomGoodsIdSet = list.stream()
                     .filter(order -> order.getAuctionType() == AuctionOrderTypeEnum.AUCTION_ITEMS)
@@ -1238,6 +1279,19 @@
                 }
             });
         }
+        Set<Long> memberVoIdSet = voList.stream().map(MgtOrderVO::getMemberId)
+                .collect(Collectors.toSet());
+        List<Member> data = memberClient.getMemberListByIds(memberVoIdSet, SecurityConstants.INNER)
+                .getData();
+        Map<Long, Member> memberMap = data.stream()
+                .collect(Collectors.toMap(Member::getId, e -> e));
+        voList = voList.stream().peek(order -> {
+            Member member = memberMap.get(order.getMemberId());
+            if (StringUtils.isNotNull(member)) {
+                order.setNickname(member.getNickname());
+                order.setPhone(member.getPhone());
+            }
+        }).collect(Collectors.toList());
         return pageVO;
     }
 
@@ -1269,7 +1323,7 @@
             }
         }
         // 查询售后信息
-        if (order.getOrderStatus() == OrderStatusEnum.AFTER_SALE) {
+        if (order.getIsRequest() == 2) {
             OrderReturnRequest orderReturnRequest = orderReturnRequestService.getOne(
                     Wrappers.lambdaQuery(OrderReturnRequest.class)
                             .eq(OrderReturnRequest::getOrderId,
@@ -1340,6 +1394,7 @@
      * @param id 订单id
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public void refund(Long id) {
         Order order = getOrder(id);
         String orderNo = order.getOrderNo();
@@ -1362,6 +1417,8 @@
             orderReturnRequest.setAuditStatus(AuditStatusEnum.PASSED);
             orderReturnRequestService.save(orderReturnRequest);
         }
+        order.setIsRequest(2);
+        this.updateById(order);
     }
 
     private boolean handleRefund(PaymentMethodEnum paymentMethod, Paylog paylog, String orderNo) {
@@ -1396,7 +1453,7 @@
         Order order = getOrder(id);
         if (order.getOrderStatus() == OrderStatusEnum.FINISHED) {
             OrderReturnRequest orderReturnRequest = new OrderReturnRequest();
-            order.setOrderStatus(OrderStatusEnum.AFTER_SALE);
+            order.setIsRequest(2);
             this.updateById(order);
             MgtAfterSaleSettingDTO data = sysUserClient.getAfterSaleSetting().getData();
             if (StringUtils.isNull(data)) {
@@ -1479,4 +1536,15 @@
     public List<Order> getStaticsOrderList(LocalDateTime startTime, LocalDateTime endTime) {
         return baseMapper.getStaticsOrderList(startTime, endTime);
     }
+
+    @Override
+    public List<Order> getOrderListByMubres(List<String> mubres) {
+        return this.lambdaQuery().in(Order::getGroupNo, mubres).list();
+    }
+
+    @Override
+    public void updateOrderStatusByMubres(List<String> formedGroupMubres) {
+        this.lambdaUpdate().set(Order::getIsOrder, 1).in(Order::getGroupNo, formedGroupMubres)
+                .update();
+    }
 }

--
Gitblit v1.7.1