From e9892b2cfb4b33ecb80c033e4074f65a341fc1b3 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Fri, 24 Nov 2023 11:56:13 +0800
Subject: [PATCH] 匹配

---
 src/main/java/cc/mrbird/febs/mall/service/impl/AgentServiceImpl.java |   82 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 82 insertions(+), 0 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AgentServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AgentServiceImpl.java
index e89a8e9..8c177c2 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/AgentServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AgentServiceImpl.java
@@ -864,6 +864,88 @@
             }
         }
     }
+
+    @Override
+    public void timeGetOrderBuy() {
+        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
+        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
+                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
+        );
+        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
+        /**
+         * 当前时间比结束时间大
+         */
+        if(nowTime.compareTo(endTime) >= 0){
+            List<MallProductBuyRecord> mallProductBuyRecords = mallProductBuyRecordMapper.selectByState(ProductEnum.PRODUCT_MATE_STATE_WAIT_PAY.getValue());
+            if(CollUtil.isNotEmpty(mallProductBuyRecords)){
+                for(MallProductBuyRecord mallProductBuyRecord : mallProductBuyRecords){
+                    /**
+                     * 用户有超时未支付的订单
+                     * 1、冻结账户
+                     * 2、更新买单主表
+                     * 2、更新卖单主表
+                     * 3、更新买单子表的数据
+                     * 3、更新卖单子表的数据
+                     */
+                    Long buyId = mallProductBuyRecord.getBuyId();
+                    Long sellRecordId = mallProductBuyRecord.getSellRecordId();
+                    MallProductBuy mallProductBuy = mallProductBuyMapper.selectById(buyId);
+                    Long memberIdBuy = mallProductBuy.getMemberId();
+                    //冻结账户
+                    MallMember mallMemberBuy = memberMapper.selectById(memberIdBuy);
+                    mallMemberBuy.setIsFrozen(ProductEnum.MEMBER_FROZEN.getValue());
+                    memberMapper.updateById(mallMemberBuy);
+                    //更新买单子表的数据
+                    mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_FAIL.getValue());
+                    mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
+                    //更新买单主表
+                    mallProductBuy.setNftAva(mallProductBuy.getNftAva().add(mallProductBuyRecord.getPickNftCnt()));
+                    mallProductBuyMapper.updateById(mallProductBuy);
+                    //更新卖单子表的数据
+                    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);
+                }
+            }
+        }
+
+    }
+
+    @Override
+    public void timeGetOrderSell() {
+        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
+        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
+                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
+        );
+        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
+        /**
+         * 当前时间比结束时间大
+         */
+        if(nowTime.compareTo(endTime) >= 0){
+            List<MallProductSellRecord> mallProductSellRecords = mallProductSellRecordMapper.selectListByState(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue());
+            if(CollUtil.isNotEmpty(mallProductSellRecords)){
+                for(MallProductSellRecord mallProductSellRecord : mallProductSellRecords){
+                    /**
+                     * 卖方
+                     * 1:冻结账户
+                     */
+                    Long sellId = mallProductSellRecord.getSellId();
+                    MallProductSell mallProductSell = mallProductSellMapper.selectById(sellId);
+                    MallMember mallMember = memberMapper.selectById(mallProductSell.getMemberId());
+                    mallMember.setIsFrozen(ProductEnum.MEMBER_FROZEN.getValue());
+                    memberMapper.updateById(mallMember);
+                }
+            }
+        }
+    }
+
     public void insertSell(Long memberId,BigDecimal nftCnt,BigDecimal nftCntAva,
                            BigDecimal nftFee,BigDecimal fcmFeeCnt){
         String orderNo = MallUtils.getOrderNum("NFT");

--
Gitblit v1.9.1