From 177e5d562eb317843f6e7ddf89bfbf7aadc7e99b Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Wed, 28 Aug 2024 11:19:29 +0800
Subject: [PATCH] 新增功能操作按钮,和更新了数据库数据

---
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java |   72 ++++++++++++++++++++++++++++++++++--
 1 files changed, 68 insertions(+), 4 deletions(-)

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 7b39e38..d4ffe38 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
@@ -6,6 +6,7 @@
 import cc.mrbird.febs.common.enumerates.MoneyFlowTypeNewEnum;
 import cc.mrbird.febs.common.enumerates.ProductEnum;
 import cc.mrbird.febs.common.exception.FebsException;
+import cc.mrbird.febs.common.utils.AppContants;
 import cc.mrbird.febs.common.utils.LoginUserUtil;
 import cc.mrbird.febs.common.utils.MallUtils;
 import cc.mrbird.febs.mall.dto.*;
@@ -33,6 +34,7 @@
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 
 @Slf4j
@@ -126,14 +128,14 @@
         MallProductBuy mallProductBuy = mallProductBuyMapper.selectMemberIdAndNFTIdAndStateAndMateState(
                 memberId,productNFTId,ProductEnum.PRODUCT_BUY_ON_GOING.getValue(),ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
         if(ObjectUtil.isNotEmpty(mallProductBuy)){
-            throw new FebsException("不可重复预约");
+            throw new FebsException("不可重复开启");
         }
         QueryWrapper<MallProductBuy> mallProductBuyDone = new QueryWrapper<>();
         mallProductBuyDone.like("CREATED_TIME", DateUtil.today());
         mallProductBuyDone.eq("member_id",memberId);
         Integer selectCount = mallProductBuyMapper.selectCount(mallProductBuyDone);
         if(0 < selectCount){
-            throw new FebsException("每日预约一次");
+            throw new FebsException("每日开启一次");
         }
 
         BigDecimal priceToken = mallProductNft.getPriceToken();
@@ -152,6 +154,8 @@
         mallProductBuy.setMateState(ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
         mallProductBuy.setNftTotal(mallProductNft.getPriceNft());
         mallProductBuy.setNftAva(mallProductNft.getPriceNft());
+        mallProductBuy.setCycle(mallProductNft.getCycle());
+        mallProductBuy.setProfit(mallProductNft.getProfit());
 //        mallProductBuy.setNftAva(BigDecimal.ZERO);
         mallProductBuyMapper.insert(mallProductBuy);
         //令牌 可用减少,冻结增加
@@ -166,7 +170,10 @@
                 null,
                 FlowTypeNewEnum.TOKEN.getValue(),
                 MoneyFlowTypeNewEnum.TOKEN_BUY_FROZEN.getDescrition());
-        return new FebsResponse().success();
+        HashMap<String, Long> objectObjectHashMap = new HashMap<>();
+        objectObjectHashMap.put("id",productNFTId);
+        objectObjectHashMap.put("time",5L);
+        return new FebsResponse().success().data(objectObjectHashMap);
     }
 
     @Override
@@ -181,6 +188,13 @@
          * 计算手续费、减少用户的fcm余额
          * 增加流水
          */
+
+        DataDictionaryCustom coinChangeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.COIN_CHANGE.getType(),
+                DataDictionaryEnum.COIN_CHANGE.getCode());
+        if(!"1".equals(coinChangeDic.getValue())){
+            throw new FebsException("暂未开放");
+        }
 
         Boolean aBoolean = operationPermissionMemberFrozen(memberId);
         if(aBoolean){
@@ -205,7 +219,7 @@
         DataDictionaryCustom fcmPriceDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                 DataDictionaryEnum.FCM_PRICE.getType(),
                 DataDictionaryEnum.FCM_PRICE.getCode());
-        BigDecimal fcmPrice = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(2) : new BigDecimal(fcmPriceDic.getValue());
+        BigDecimal fcmPrice = ObjectUtil.isEmpty(fcmPriceDic) ? new BigDecimal(8) : new BigDecimal(fcmPriceDic.getValue());
         //手续费
         DataDictionaryCustom outFcmFeeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                 DataDictionaryEnum.OUT_FCM_FEE.getType(),
@@ -275,6 +289,11 @@
             throw new FebsException("请输入正确的交易密码");
         }
         BigDecimal nftCnt = outNFTDto.getNftCnt();
+        BigDecimal remainder = nftCnt.remainder(BigDecimal.TEN);
+        if(remainder.compareTo(BigDecimal.ZERO) != 0){
+            throw new FebsException("数量需要为10的倍数");
+        }
+
         DataDictionaryCustom nftMinDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                 DataDictionaryEnum.NFT_MIN.getType(),
                 DataDictionaryEnum.NFT_MIN.getCode());
@@ -564,6 +583,25 @@
         mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_CONFIRM.getValue());
         mallProductSellRecordMapper.updateById(mallProductSellRecord);
 
+        DataDictionaryCustom gsdInDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                DataDictionaryEnum.FCM_GSD_IN.getType(),
+                DataDictionaryEnum.FCM_GSD_IN.getCode()
+        );
+        BigDecimal gsdInPercent = new BigDecimal(gsdInDic.getValue()).multiply(AppContants.BASIC_PERCENT);
+        BigDecimal gsdIn = gsdInPercent.multiply(mallProductSellRecord.getNftCnt()).setScale(2,BigDecimal.ROUND_DOWN);
+        MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
+        mallMemberAmount.setGsd(mallMemberAmount.getGsd().add(gsdIn));
+        mallMemberAmountMapper.updateGsdById(mallMemberAmount);
+
+        iMallMoneyFlowService.addMoneyFlow(
+                memberId,
+                gsdIn,
+                MoneyFlowTypeNewEnum.NFT_TRANS_GFD.getValue(),
+                null,
+                mallMember.getId(),
+                FlowTypeNewEnum.GSD.getValue(),
+                MoneyFlowTypeNewEnum.NFT_TRANS_GFD.getDescrition());
+
         agentProducer.sendFcmOrderSellInsureMsg(sellRecordId);
         return new FebsResponse().success();
     }
@@ -646,6 +684,9 @@
         List<ApiOrderRecordListVo> objects = new ArrayList<>();
         apiOrderListDto.setMemberId(memberId);
         DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
+        if(memberId == 2374L){
+            log.info("当前系统时间1"+nowTime);
+        }
         DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                 DataDictionaryEnum.YU_YUE_START_TIME.getType(),
                 DataDictionaryEnum.YU_YUE_START_TIME.getCode()
@@ -657,6 +698,9 @@
         );
         DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
         if(nowTime.compareTo(startTime) >= 0 && nowTime.compareTo(endTime) <= 0){
+            if(memberId == 2374L){
+                log.info("当前系统时间2"+nowTime);
+            }
             IPage<ApiOrderRecordListVo> pageBuy = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
             IPage<ApiOrderRecordListVo> apiOrderListVoIPageBuy = mallProductBuyRecordMapper.selectListInPage(pageBuy, apiOrderListDto);
             if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){
@@ -665,9 +709,20 @@
                 }
             }
         }
+
+//        IPage<ApiOrderRecordListVo> pageBuy = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
+//        IPage<ApiOrderRecordListVo> apiOrderListVoIPageBuy = mallProductBuyRecordMapper.selectListInPage(pageBuy, apiOrderListDto);
+//        if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){
+//            for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){
+//                objects.add(apiOrderListVo);
+//            }
+//        }
         IPage<ApiOrderRecordListVo> pageSell = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
         IPage<ApiOrderRecordListVo> apiOrderListVoIPageSell = mallProductSellRecordMapper.selectListInPage(pageSell, apiOrderListDto);
         if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){
+            if(memberId == 2374L){
+                log.info("当前系统时间3"+nowTime);
+            }
             for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){
                 objects.add(apiOrderListVo);
             }
@@ -830,4 +885,13 @@
         }
         return new FebsResponse().success();
     }
+
+    @Override
+    public FebsResponse orderSellList(ApiOrderSellDto apiOrderBuyDto) {
+        Long memberId = LoginUserUtil.getLoginUser().getId();
+        IPage<ApiOrderSellVo> page = new Page<>(apiOrderBuyDto.getPageNum(), apiOrderBuyDto.getPageSize());
+        apiOrderBuyDto.setMemberId(memberId);
+        IPage<ApiOrderSellVo> apiOrderBuyVoIPage = mallProductBuyMapper.selectSellListInPage(page, apiOrderBuyDto);
+        return new FebsResponse().success().data(apiOrderBuyVoIPage);
+    }
 }

--
Gitblit v1.9.1