From 2221ee0ef3e6d04433c5610783a79ee242c5029c Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 27 Jun 2022 11:18:38 +0800
Subject: [PATCH] 20220528

---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java |   65 ++++++++++++++++++++++++++++----
 1 files changed, 57 insertions(+), 8 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
index 6b4d1a8..b525076 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -6,6 +6,7 @@
 import cc.mrbird.febs.common.utils.LoginUserUtil;
 import cc.mrbird.febs.common.utils.MallUtils;
 import cc.mrbird.febs.common.utils.RedisUtils;
+import cc.mrbird.febs.mall.conversion.MallGoodsCommentConversion;
 import cc.mrbird.febs.mall.conversion.MallOrderInfoConversion;
 import cc.mrbird.febs.mall.conversion.MallOrderRefundConversion;
 import cc.mrbird.febs.mall.dto.*;
@@ -31,7 +32,6 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.text.SimpleDateFormat;
 import java.util.*;
 
 /**
@@ -48,6 +48,7 @@
     private final MallAddressInfoMapper mallAddressInfoMapper;
     private final MallOrderItemMapper mallOrderItemMapper;
     private final MallMemberMapper memberMapper;
+    private final MallGoodsCommentMapper mallGoodsCommentMapper;
     private final IApiMallMemberWalletService memberWalletService;
     private final MallExpressInfoMapper expressInfoMapper;
     private final MallOrderRefundMapper mallOrderRefundMapper;
@@ -249,6 +250,8 @@
                         if (mallGoods.getIsNormal() == 2) {
                             hasTc = true;
                             score = sku.getPresentPrice().multiply(mallGoods.getStaticMulti());
+//                            BigDecimal staticMulti = mallGoods.getStaticMulti() == null ? BigDecimal.ZERO : mallGoods.getStaticMulti();
+//                            score = sku.getPresentPrice().multiply(staticMulti);
                         }
 
                         if (score.compareTo(BigDecimal.ZERO) > 0) {
@@ -413,13 +416,6 @@
 
         MallOrderRefund orderRefund = mallOrderRefundMapper.selectOrderRefundByOrderId(orderInfo.getId());
         if (orderRefund == null) {
-            // 未发货则退运费,发货了则不退
-            if (orderInfo.getStatus() == 2) {
-                orderRefund.setAmount(orderInfo.getAmount().add(orderInfo.getCarriage()));
-            } else {
-                orderRefund.setAmount(orderInfo.getAmount());
-            }
-
             orderRefund = new MallOrderRefund();
             orderRefund.setOrderId(orderInfo.getId());
             orderRefund.setMemberId(member.getId());
@@ -429,6 +425,13 @@
             orderRefund.setRefundTime(new Date());
             orderRefund.setBeforeStatus(beforeStatus);
             orderRefund.setStatus(OrderRefundStatusEnum.REFUND_APPLY.getValue());
+
+            // 未发货则退运费,发货了则不退
+            if (beforeStatus == 2) {
+                orderRefund.setAmount(orderInfo.getAmount().add(orderInfo.getCarriage()));
+            } else {
+                orderRefund.setAmount(orderInfo.getAmount());
+            }
             mallOrderRefundMapper.insert(orderRefund);
         } else {
             orderRefund.setDesp(addRefundDto.getDesp());
@@ -437,6 +440,12 @@
             orderRefund.setRefundTime(new Date());
             orderRefund.setBeforeStatus(beforeStatus);
             orderRefund.setStatus(OrderRefundStatusEnum.REFUND_APPLY.getValue());
+            // 未发货则退运费,发货了则不退
+            if (beforeStatus == 2) {
+                orderRefund.setAmount(orderInfo.getAmount().add(orderInfo.getCarriage()));
+            } else {
+                orderRefund.setAmount(orderInfo.getAmount());
+            }
             mallOrderRefundMapper.updateById(orderRefund);
         }
 
@@ -483,4 +492,44 @@
             this.baseMapper.updateById(orderInfo);
         }
     }
+
+    @Override
+    @Transactional
+    public void goodsComment(ApiAddCommentDtos addCommentDtos) {
+        Long orderId = addCommentDtos.getOrderId();
+        MallMember member = LoginUserUtil.getLoginUser();
+        MallOrderInfo orderInfo = this.baseMapper.selectOrderDetailsById(orderId);
+        if (orderInfo == null || AppContants.DEL_FLAG_Y == orderInfo.getDelFlag()) {
+            throw new FebsException("订单不存在");
+        }
+        if (OrderStatusEnum.FINISH.getValue() != orderInfo.getStatus()) {
+            throw new FebsException("该状态不能评价");
+        }
+        if (MallOrderInfo.COMMENT_STATE_YES == orderInfo.getCommentState()) {
+            throw new FebsException("该状态不能评价");
+        }
+
+        orderInfo.setCommentState(MallOrderInfo.COMMENT_STATE_YES);
+        this.baseMapper.updateById(orderInfo);
+
+        List<ApiAddCommentDto> apiAddCommentDtos = addCommentDtos.getApiAddCommentDtos();
+        if(CollUtil.isNotEmpty(apiAddCommentDtos)){
+            for(ApiAddCommentDto apiAddCommentDto : apiAddCommentDtos){
+                Long skuId = apiAddCommentDto.getSkuId();
+                MallGoodsSku mallGoodsSku = mallGoodsSkuMapper.selectById(skuId);
+                Long goodsId = apiAddCommentDto.getGoodsId();
+                MallGoods mallGoods = mallGoodsMapper.selectById(goodsId);
+                MallGoodsComment mallGoodsComment = MallGoodsCommentConversion.INSTANCE.dtoToEntity(apiAddCommentDto);
+                mallGoodsComment.setMemberId(member.getId());
+                mallGoodsComment.setOrderId(orderId);
+                mallGoodsComment.setGoodsName(mallGoods.getGoodsName());
+                mallGoodsComment.setSkuName(mallGoodsSku.getSkuName());
+                mallGoodsComment.setStyleId(mallGoodsSku.getStyleId());
+                mallGoodsComment.setStyleName(mallGoodsSku.getStyleName());
+                mallGoodsComment.setShowState(MallGoodsComment.SHOW_STATE_ENABLE);
+                mallGoodsCommentMapper.insert(mallGoodsComment);
+            }
+        }
+    }
+
 }

--
Gitblit v1.9.1