From e89fa51bb8592aae31ed345400c5a632e394739d Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Wed, 13 Dec 2023 15:06:43 +0800
Subject: [PATCH] 微信小程序配置

---
 src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java |   68 +++++++++++++++++++++++----------
 1 files changed, 47 insertions(+), 21 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java
index 2c83e72..3f4d33c 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MemberProfitServiceImpl.java
@@ -1129,8 +1129,8 @@
         BigDecimal divide = fcmDestoryCntAdd.divide(AppContants.FCM_BASIC, 0, BigDecimal.ROUND_DOWN);
         if(BigDecimal.ZERO.compareTo(divide) == 0){
             commonService.updateDataDic(
-                    DataDictionaryEnum.BANK_TRANS_URL.getType(),
-                    DataDictionaryEnum.BANK_TRANS_URL.getCode(),
+                    DataDictionaryEnum.FCM_DESTORY_CNT.getType(),
+                    DataDictionaryEnum.FCM_DESTORY_CNT.getCode(),
                     fcmDestoryCntAdd.toString());
         }
 
@@ -1200,32 +1200,58 @@
 
         //已完成的买单
         List<MallProductSellRecord> mallProductSellRecords = mallProductSellRecordMapper.selectListBySellId(sellId,ProductEnum.PRODUCT_MATE_STATE_FINISH.getValue());
-        if(CollUtil.isEmpty(mallProductSellRecords)){
-            return;
+        if(CollUtil.isNotEmpty(mallProductSellRecords)){
+            //实际支付总数
+            BigDecimal nftCntTotal = mallProductSellRecords.stream().map(MallProductSellRecord::getNftCnt).reduce(BigDecimal.ZERO, BigDecimal::add);
+            MallProductSell mallProductSell = mallProductSellMapper.selectById(sellId);
+            if(nftCntTotal.compareTo(mallProductSell.getNftCnt()) >= 0){
+                mallProductSell.setState(ProductEnum.PRODUCT_SELL_SUCCESS.getValue());
+                mallProductSellMapper.updateById(mallProductSell);
+            }
         }
-        //实际支付总数
-        BigDecimal nftCntTotal = mallProductSellRecords.stream().map(MallProductSellRecord::getNftCnt).reduce(BigDecimal.ZERO, BigDecimal::add);
-        MallProductSell mallProductSell = mallProductSellMapper.selectById(sellId);
-        if(nftCntTotal.compareTo(mallProductSell.getNftCnt()) < 0){
-            return;
-        }
-        mallProductSell.setState(ProductEnum.PRODUCT_SELL_SUCCESS.getValue());
-        mallProductSellMapper.updateById(mallProductSell);
+
 
         Long buyId = mallProductBuyRecord.getBuyId();
         List<MallProductBuyRecord> mallProductBuyRecords = mallProductBuyRecordMapper.selectListByBuyId(buyId,ProductEnum.PRODUCT_MATE_STATE_FINISH.getValue());
-        if(CollUtil.isEmpty(mallProductBuyRecords)){
+        if(CollUtil.isNotEmpty(mallProductBuyRecords)){
+            //实际支付总数
+            BigDecimal nftCntTotalBuy = mallProductBuyRecords.stream().map(MallProductBuyRecord::getPickNftCnt).reduce(BigDecimal.ZERO, BigDecimal::add);
+            MallProductBuy mallProductBuy = mallProductBuyMapper.selectById(buyId);
+            if(nftCntTotalBuy.compareTo(mallProductBuy.getNftTotal()) >= 0){
+                mallProductBuy.setState(ProductEnum.PRODUCT_BUY_SUCCESS.getValue());
+                mallProductBuy.setPayTime(DateUtil.date());
+                mallProductBuyMapper.updateById(mallProductBuy);
+            }
+        }
+    }
+
+    @Override
+    public void fcmOrderBuyCancelMsg(Long buyRecordId) {
+        MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(buyRecordId);
+        if(ProductEnum.PRODUCT_MATE_STATE_WAIT_PAY.getValue() != mallProductBuyRecord.getState()){
             return;
         }
-        //实际支付总数
-        BigDecimal nftCntTotalBuy = mallProductBuyRecords.stream().map(MallProductBuyRecord::getPickNftCnt).reduce(BigDecimal.ZERO, BigDecimal::add);
-        MallProductBuy mallProductBuy = mallProductBuyMapper.selectById(buyId);
-        if(nftCntTotalBuy.compareTo(mallProductBuy.getNftTotal()) < 0){
-            return;
-        }
-        mallProductBuy.setState(ProductEnum.PRODUCT_BUY_SUCCESS.getValue());
-        mallProductBuy.setPayTime(DateUtil.date());
+        Long sellRecordId = mallProductBuyRecord.getSellRecordId();
+        //更新买单子表的数据
+        mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_FAIL.getValue());
+        mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
+        //更新买单主表
+        MallProductBuy mallProductBuy = mallProductBuyMapper.selectById(mallProductBuyRecord.getBuyId());
+        mallProductBuy.setNftAva(mallProductBuy.getNftAva().add(mallProductBuyRecord.getPickNftCnt()));
         mallProductBuyMapper.updateById(mallProductBuy);
+        Long memberId = mallProductBuy.getMemberId();
+        MallMember mallMember = mallMemberMapper.selectById(memberId);
+        mallMember.setIsFrozen(ProductEnum.MEMBER_FROZEN.getValue());
+        mallMemberMapper.updateById(mallMember);
+        //更新卖单子表的数据
+        MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(sellRecordId);
+        mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_FAIL.getValue());
+        mallProductSellRecordMapper.updateById(mallProductSellRecord);
+        //更新卖单主表
+        Long sellId = mallProductSellRecord.getSellId();
+        MallProductSell mallProductSell = mallProductSellMapper.selectById(sellId);
+        mallProductSell.setNftCntAva(mallProductSell.getNftCntAva().add(mallProductSellRecord.getNftCnt()));
+        mallProductSellMapper.updateById(mallProductSell);
     }
 
     public static void main(String[] args) {

--
Gitblit v1.9.1