Browse Source

修改订单

zhijiezhao 2 năm trước cách đây
mục cha
commit
516dfd461c

+ 2 - 0
src/main/java/com/caimei365/order/mapper/SubmitMapper.java

@@ -174,4 +174,6 @@ public interface SubmitMapper {
     void updateOrderProduct(OrderProductPo o);
 
     void updateShopOrder(ShopOrderVo shopOrder);
+
+    void updateUserMoneyByChange(Integer userId, double change);
 }

+ 25 - 12
src/main/java/com/caimei365/order/service/impl/SubmitServiceImpl.java

@@ -937,9 +937,9 @@ public class SubmitServiceImpl implements SubmitService {
             }
             // 需要支付金额 shouldPayFee +运费
             needPayAmount.set(MathUtil.add(needPayAmount.get(), postage).doubleValue());
-            log.info("postage=-***===="+postage);
+            log.info("postage=-***====" + postage);
             isColdChina.set(MathUtil.add(isColdChina.get(), shopIsColdChina.get()).doubleValue());
-            log.info("isColdChina.get()=------=-=-===="+isColdChina.get());
+            log.info("isColdChina.get()=------=-=-====" + isColdChina.get());
             // 需要支付金额 shouldPayFee + 冷链费
             needPayAmount.set(MathUtil.add(needPayAmount.get(), isColdChina.get()).doubleValue());
             // 统计总运费
@@ -1137,12 +1137,12 @@ public class SubmitServiceImpl implements SubmitService {
         // 设置运费
         // mainOrder.setPostage(orderParamBo.getPostage());
         // 订单总额 = 商品费 + 运费
-        log.info("总运费"+postageFee.get());
+        log.info("总运费" + postageFee.get());
         payTotalFee.set(MathUtil.add(productTotalFee.get(), postageFee.get()).doubleValue());
         // 总金额 + 冷链运输费
-        log.info("isColdChina.get()=------=-=-===="+isColdChina.get());
+        log.info("isColdChina.get()=------=-=-====" + isColdChina.get());
         payTotalFee.set(MathUtil.add(payTotalFee.get(), isColdChina.get()).doubleValue());
-        log.info("payTotalFee.get()=------=-=-===="+payTotalFee.get());
+        log.info("payTotalFee.get()=------=-=-====" + payTotalFee.get());
         // 运费标志:0包邮 -1到付 1遵循运费规则
         // mainOrder.setPostageFlag(orderParamBo.getPostageFlag());
         /*if (1 == orderParamBo.getPostageFlag() && orderParamBo.getOffsetBeans() > 0) {
@@ -1214,7 +1214,7 @@ public class SubmitServiceImpl implements SubmitService {
             // 支付时间
             mainOrder.setPayTime(curDateStr);
         } else {
-            log.info("payTotalFee.get()=------=-=-===="+payTotalFee.get());
+            log.info("payTotalFee.get()=------=-=-====" + payTotalFee.get());
             //不用余额的情况下真是支付金额赋值为订单总额
             payableAmount.set(payTotalFee.get());
         }
@@ -2717,17 +2717,30 @@ public class SubmitServiceImpl implements SubmitService {
             double total = records.stream().mapToDouble(BalanceRecordPo::getAmount).sum();
             /**
              * 总抵扣金额 < 子订单应收,改变子订单状态,子订单部分收,抵扣金额>子订单应收,退余额,子订单已收
-             * shopOrderStatus:  0待确认,11待收待发,12待收部发,13待收全发,21部收待发,22部收部发,23部收全发,31已收待发,
-             *                  32已收部发,33已收全发,4交易完成,5订单完成,6已关闭,7交易全退
              */
-            String status = shopOrder.getStatus().toString();
-            if (total < shopOrder.getNeedPayAmount()) {
+            double change = MathUtil.sub(total, shopOrder.getNeedPayAmount()).doubleValue();
+            if (change < 0) {
                 shopOrder.setReceiptStatus(2);
-            }else{
+            } else {
                 shopOrder.setReceiptStatus(3);
                 shopOrder.setAccountAmount(total);
+                if (change > 0) {
+                    // 修改user
+                    submitMapper.updateUserMoneyByChange(shopOrder.getUserId(), change);
+                    // 生成多收退余额记录
+                    BalanceRecordPo balanceRecordPo = new BalanceRecordPo();
+                    balanceRecordPo.setShopOrderId(shopOrder.getShopOrderId());
+                    balanceRecordPo.setUserId(shopOrder.getUserId());
+                    balanceRecordPo.setType(1);
+                    balanceRecordPo.setBalanceType(2);
+                    balanceRecordPo.setAddDate(new Date());
+                    balanceRecordPo.setAmount(change);
+                    balanceRecordPo.setOrderId(shopOrder.getOrderId());
+                    balanceRecordPo.setRemark("修改子订单,总金额降低,退还抵扣余额");
+                    balanceRecordPo.setDelFlag(0);
+                    baseMapper.insertBalanceRecord(balanceRecordPo);
+                }
             }
-
         }
         submitMapper.updateShopOrder(shopOrder);
         return ResponseJson.success();

+ 4 - 11
src/main/resources/mapper/OrderRefundMapper.xml

@@ -11,6 +11,7 @@
             parameterType="com.caimei365.order.model.vo.CmReturnedPurchase" useGeneratedKeys="true">
         INSERT INTO cm_returned_purchase(returnedNo,
                                          orderID,
+                                         shopOrderId,
                                          userID,
                                          status,
                                          returnedWay,
@@ -25,11 +26,6 @@
                                          refundBalanceFee,
                                          refundOnlineFee,
                                          refundOfflineFee,
-                                         image1,
-                                         image2,
-                                         image3,
-                                         image4,
-                                         image5,
                                          remarks,
                                          reviewRemarks,
                                          applicationUserID,
@@ -39,6 +35,7 @@
                                          refundType)
         VALUES (#{returnedNo},
                 #{orderId},
+                #{shopOrderId},
                 #{userId},
                 #{status},
                 #{returnedWay},
@@ -53,11 +50,6 @@
                 #{refundBalanceFee},
                 #{refundOnlineFee},
                 #{refundOfflineFee},
-                #{image1},
-                #{image2},
-                #{image3},
-                #{image4},
-                #{image5},
                 #{remarks},
                 #{reviewRemarks},
                 #{applicationUserId},
@@ -97,7 +89,8 @@
 
     <update id="updateShopOrder">
         update cm_shop_order
-        set refundStatus = 3
+        set refundStatus = 3,
+            shopStatus = 5
         where shopOrderID = #{shopOrderId}
     </update>
 

+ 58 - 0
src/main/resources/mapper/SubmitMapper.xml

@@ -427,4 +427,62 @@
             #{orderProductId}
         </foreach>
     </select>
+    <update id="updateOrderProduct">
+        update cm_order_product
+        set price                   = #{price},
+            costPrice               = #{costPrice},
+            totalAmount             = #{totalAmount},
+            totalFee                = #{totalFee},
+            shouldPayFee            = #{shouldPayFee},
+            ladderPriceFlag         = #{ladderPriceFlag},
+            taxRate                 = #{taxRate},
+            addedValueTax           = #{addedValueTax},
+            totalAddedValueTax      = #{totalAddedValueTax},
+            shouldPayTotalTax       = #{shouldPayTotalTax},
+            singleShouldPayTotalTax = #{singleShouldPayTotalTax},
+            shopProductAmount       = #{shopProductAmount},
+            singleShopFee           = #{singleShopFee}
+        where orderProductId = #{orderProductId}
+    </update>
+    <update id="updateShopOrder">
+        update cm_shop_order
+        set
+        <if test="status != null">
+            shopStatus = #{status},
+        </if>
+        <if test="realPay != null">
+            realPay = #{realPay},
+        </if>
+        <if test="receiptAmount != null">
+            receiptAmount = #{receiptAmount},
+        </if>
+        <if test="accountAmount != null">
+            accountAmount = #{accountAmount},
+        </if>
+        <if test="productAmount != null">
+            productAmount = #{productAmount},
+        </if>
+        <if test="totalAmount != null">
+            totalAmount = #{totalAmount},
+        </if>
+        <if test="needPayAmount != null">
+            needPayAmount = #{needPayAmount},
+        </if>
+        <if test="promotionFullReduction != null">
+            promotionFullReduction = #{promotionFullReduction},
+        </if>
+        <if test="receiptStatus != null">
+            receiptStatus = #{receiptStatus},
+        </if>
+        <if test="shopProductAmount != null">
+            shopProductAmount = #{shopProductAmount}
+        </if>
+        where shopOrderId = #{shopOrderId}
+    </update>
+    <update id="updateUserMoneyByChange">
+        update user
+        set userMoney = userMoney + #{change},
+            ableUserMoney = ableUserMoney + #{change}
+        where userId = #{userId}
+    </update>
 </mapper>