KKSU
2024-01-04 56c7e8bcb5e8e020d28c642260a1cadb681be4bb
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
@@ -17,9 +17,11 @@
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;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -30,6 +32,7 @@
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@Slf4j
@@ -65,15 +68,16 @@
        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);
                }
                apiMallProductNftVo.setYuYueState(2);
//                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;
@@ -95,20 +99,20 @@
            throw new FebsException("用户已冻结");
        }
        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("预约未开始");
        }
//        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("请输入正确的交易密码");
        }
@@ -123,6 +127,13 @@
                memberId,productNFTId,ProductEnum.PRODUCT_BUY_ON_GOING.getValue(),ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
        if(ObjectUtil.isNotEmpty(mallProductBuy)){
            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("每日预约一次");
        }
        BigDecimal priceToken = mallProductNft.getPriceToken();
@@ -497,6 +508,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();
    }
@@ -644,13 +664,12 @@
                    objects.add(apiOrderListVo);
                }
            }
            IPage<ApiOrderRecordListVo> pageSell = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize());
            IPage<ApiOrderRecordListVo> apiOrderListVoIPageSell = mallProductSellRecordMapper.selectListInPage(pageSell, apiOrderListDto);
            if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){
                for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageSell.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())){
            for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){
                objects.add(apiOrderListVo);
            }
        }