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

---
 src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java                 |    9 ++++
 src/main/java/cc/mrbird/febs/mall/service/IApiMallOrderInfoService.java         |    1 
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java   |   11 +++++
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java |   24 ++++++++++++
 src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java                         |   16 ++++----
 5 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java b/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
index f9114ff..9260f64 100644
--- a/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
+++ b/src/main/java/cc/mrbird/febs/mall/quartz/ProfitJob.java
@@ -143,14 +143,14 @@
         agentService.timeGetOrderBuyCancel();
     }
 
-    /**
-     * 卖单
-     * 看是否是开始显示订单的时间段,超出结束时间的卖单,全部超时失败
-     */
-    @Scheduled(cron = "0 0/30 * * * ? ")
-    public void timeGetOrderSell() {
-        agentService.timeGetOrderSell();
-    }
+//    /**
+//     * 卖单
+//     * 看是否是开始显示订单的时间段,超出结束时间的卖单,全部超时失败
+//     */
+//    @Scheduled(cron = "0 0/30 * * * ? ")
+//    public void timeGetOrderSell() {
+//        agentService.timeGetOrderSell();
+//    }
 
 
 
diff --git a/src/main/java/cc/mrbird/febs/mall/service/IApiMallOrderInfoService.java b/src/main/java/cc/mrbird/febs/mall/service/IApiMallOrderInfoService.java
index 4bf0bca..3417541 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/IApiMallOrderInfoService.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/IApiMallOrderInfoService.java
@@ -41,4 +41,5 @@
 
     ApiScoreSetVo myScoreSet();
 
+    void fcmPayBuyTimeTTLMsg(Long id);
 }
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 d23ad06..65770e2 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
@@ -83,6 +83,8 @@
     private final MallAchieveRecordMapper mallAchieveRecordMapper;
     private final MallMemberWalletMapper mallMemberWalletMapper;
     private final MallMqRecordMapper mallMqRecordMapper;
+    private final MallProductSellMapper mallProductSellMapper;
+    private final MallProductSellRecordMapper mallProductSellRecordMapper;
 
     private final ICommonService commonService;
 
@@ -803,4 +805,26 @@
         return apiScoreSetVo;
     }
 
+    @Override
+    public void fcmPayBuyTimeTTLMsg(Long id) {
+        /**
+         * 卖方
+         * 1:冻结账户
+         */
+        MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(id);
+        if(ObjectUtil.isEmpty(mallProductSellRecord)){
+            return;
+        }
+        MallProductSell mallProductSell = mallProductSellMapper.selectById(mallProductSellRecord.getSellId());
+        if(ObjectUtil.isEmpty(mallProductSell)){
+            return;
+        }
+        MallMember mallMember = memberMapper.selectById(mallProductSell.getMemberId());
+        if(ObjectUtil.isEmpty(mallMember)){
+            return;
+        }
+        mallMember.setIsFrozen(ProductEnum.MEMBER_FROZEN.getValue());
+        memberMapper.updateById(mallMember);
+    }
+
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
index 42b7034..a70f9fe 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
@@ -17,6 +17,7 @@
 import cc.mrbird.febs.rabbit.producter.AgentProducer;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.crypto.SecureUtil;
@@ -30,6 +31,7 @@
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 
 @Slf4j
@@ -497,6 +499,15 @@
                 mallMember.getId(),
                 FlowTypeNewEnum.NFT.getValue(),
                 MoneyFlowTypeNewEnum.PAY.getDescrition());
+
+        DataDictionaryCustom insureMinuteDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.INSURE_END_MINUTE.getType(),
+                DataDictionaryEnum.INSURE_END_MINUTE.getCode()
+        );
+        Integer insureMinute = Integer.parseInt(ObjectUtil.isEmpty(insureMinuteDic) ? "60" : insureMinuteDic.getValue());
+        Date endTime = DateUtil.offsetMinute(payTime, insureMinute);
+        long remainTime = DateUtil.between(payTime, endTime, DateUnit.SECOND, false);
+        agentProducer.sendFcmPayBuyTimeTTLMsg(mallProductSellRecord.getId(), remainTime * 1000L);
         return new FebsResponse().success();
     }
 
diff --git a/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java b/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java
index 5597736..ec3b19a 100644
--- a/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java
+++ b/src/main/java/cc/mrbird/febs/rabbit/consumer/AgentConsumer.java
@@ -132,4 +132,13 @@
 
         }
     }
+
+    @RabbitListener(queues = QueueConstants.QUEUE_FCMPAY_BUY_TIME)
+    public void fcmPayBuyTimeTTLMsg(Long id) {
+        try {
+            orderInfoService.fcmPayBuyTimeTTLMsg(id);
+        } catch (Exception e) {
+            log.error("订单待收款异常", e);
+        }
+    }
 }

--
Gitblit v1.9.1