KKSU
2023-11-27 46e65fb48af4fda3c8fd32abb948365fd1cbaa3a
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
@@ -49,7 +49,32 @@
    @Override
    public List<ApiMallProductNftVo> productNFTList() {
        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
        DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_START_TIME.getType(),
                DataDictionaryEnum.YU_YUE_START_TIME.getCode()
        );
        DateTime startTime = DateUtil.parseTime(startTimeDic.getValue());
        DataDictionaryCustom endTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_END_TIME.getType(),
                DataDictionaryEnum.YU_YUE_END_TIME.getCode()
        );
        DateTime endTime = DateUtil.parseTime(endTimeDic.getValue());
        List<ApiMallProductNftVo> list = this.baseMapper.selectByState(ProductEnum.PRODUCT_NFT_OPEN.getValue());
        if(CollUtil.isNotEmpty(list)){
            for(ApiMallProductNftVo apiMallProductNftVo : list){
                if(nowTime.compareTo(startTime) < 0){
                    apiMallProductNftVo.setYuYueState(1);
                }
                if(nowTime.compareTo(startTime) >= 0 && nowTime.compareTo(endTime) <= 0){
                    apiMallProductNftVo.setYuYueState(2);
                }
                if(nowTime.compareTo(endTime) > 0){
                    apiMallProductNftVo.setYuYueState(3);
                }
            }
        }
        return list;
    }
@@ -64,6 +89,20 @@
         * 预约,验证交易密码、预约产品是否开启状态、该产品是否已经预约、token是否足够
         * 冻结对应的令牌数量、生成预约记录、生成流水记录
         */
        DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date()));
        DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
                DataDictionaryEnum.YU_YUE_START_TIME.getType(),
                DataDictionaryEnum.YU_YUE_START_TIME.getCode()
        );
        DateTime startTime = DateUtil.parseTime(startTimeDic.getValue());
        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(startTime) >= 0 && nowTime.compareTo(endTime) <= 0)){
            throw new FebsException("预约未开始");
        }
        if(!tradePassword.equals(mallMember.getTradePassword())){
            throw new FebsException("请输入正确的交易密码");
        }
@@ -75,7 +114,7 @@
            throw new FebsException("预约超时");
        }
        MallProductBuy mallProductBuy = mallProductBuyMapper.selectMemberIdAndNFTIdAndStateAndMateState(
                memberId,productNFTId,ProductEnum.PRODUCT_BUY_ON_GOING.getValue(),null);
                memberId,productNFTId,ProductEnum.PRODUCT_BUY_ON_GOING.getValue(),ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
        if(ObjectUtil.isNotEmpty(mallProductBuy)){
            throw new FebsException("不可重复预约");
        }
@@ -95,7 +134,8 @@
        mallProductBuy.setState(ProductEnum.PRODUCT_BUY_ON_GOING.getValue());
        mallProductBuy.setMateState(ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
        mallProductBuy.setNftTotal(mallProductNft.getPriceNft());
        mallProductBuy.setNftAva(BigDecimal.ZERO);
        mallProductBuy.setNftAva(mallProductNft.getPriceNft());
//        mallProductBuy.setNftAva(BigDecimal.ZERO);
        mallProductBuyMapper.insert(mallProductBuy);
        //令牌 可用减少,冻结增加
        mallMemberAmount.setTokenAva(mallMemberAmount.getTokenAva().subtract(priceToken));
@@ -248,6 +288,9 @@
        mallMemberAmount.setTrendsNft(mallMemberAmount.getTrendsNft().subtract(nftCnt));
        mallMemberAmountMapper.updateTrendsNftById(mallMemberAmount);
        mallMemberAmount.setFcmCntAva(mallMemberAmount.getFcmCntAva().subtract(fcmFeeCnt));
        mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmount);
        mallMemberAmount.setFrozenNft(mallMemberAmount.getFrozenNft().add(nftCntAva));
        mallMemberAmountMapper.updateFrozenNftById(mallMemberAmount);
        iMallMoneyFlowService.addMoneyFlow(