From 2034f221437ecc32d5ebf01544987d17241c39c8 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Fri, 15 Dec 2023 10:39:00 +0800 Subject: [PATCH] 微信小程序配置 --- src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java | 183 +++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 167 insertions(+), 16 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 1f2f630..f3d9fea 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,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 @@ -46,6 +49,7 @@ private final MallProductSellMapper mallProductSellMapper; private final MallProductSellRecordMapper mallProductSellRecordMapper; private final MallProductBuyRecordMapper mallProductBuyRecordMapper; + private final MallMemberSpeakMapper mallMemberSpeakMapper; @Override public List<ApiMallProductNftVo> productNFTList() { @@ -122,6 +126,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(); @@ -362,24 +373,41 @@ ); DateTime endTime = DateUtil.parseTime(endTimeDic.getValue()); if(nowTime.compareTo(startTime) >= 0 && nowTime.compareTo(endTime) <= 0){ - //买单 - if(2 == orderType){ - IPage<ApiOrderListVo> page = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize()); - IPage<ApiOrderListVo> apiOrderListVoIPageBuy = mallProductBuyMapper.selectListInPage(page, apiOrderListDto); - if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){ - for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){ - objects.add(apiOrderListVo); - } +// //买单 +// if(2 == orderType){ +// IPage<ApiOrderListVo> page = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize()); +// IPage<ApiOrderListVo> apiOrderListVoIPageBuy = mallProductBuyMapper.selectListInPage(page, apiOrderListDto); +// if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){ +// for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){ +// objects.add(apiOrderListVo); +// } +// } +// } +// //卖单 +// if(1 == orderType){ +// IPage<ApiOrderListVo> page = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize()); +// IPage<ApiOrderListVo> apiOrderListVoIPageSell = mallProductSellMapper.selectListInPage(page, apiOrderListDto); +// if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){ +// for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){ +// objects.add(apiOrderListVo); +// } +// } +// } + + IPage<ApiOrderListVo> pageBuy = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize()); + IPage<ApiOrderListVo> apiOrderListVoIPageBuy = mallProductBuyMapper.selectListInPage(pageBuy, apiOrderListDto); + if(CollUtil.isNotEmpty(apiOrderListVoIPageBuy.getRecords())){ + for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageBuy.getRecords()){ + objects.add(apiOrderListVo); } } - //卖单 - if(1 == orderType){ - IPage<ApiOrderListVo> page = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize()); - IPage<ApiOrderListVo> apiOrderListVoIPageSell = mallProductSellMapper.selectListInPage(page, apiOrderListDto); - if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){ - for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){ - objects.add(apiOrderListVo); - } + + + IPage<ApiOrderListVo> pageSell = new Page<>(apiOrderListDto.getPageNum(), apiOrderListDto.getPageSize()); + IPage<ApiOrderListVo> apiOrderListVoIPageSell = mallProductSellMapper.selectListInPage(pageSell, apiOrderListDto); + if(CollUtil.isNotEmpty(apiOrderListVoIPageSell.getRecords())){ + for(ApiOrderListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){ + objects.add(apiOrderListVo); } } } @@ -479,6 +507,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(); } @@ -547,4 +584,118 @@ } return false; } + + @Override + public FebsResponse orderSellComplain(ApiOrderSellComplainDto apiOrderSellComplainDto) { + Long memberId = LoginUserUtil.getLoginUser().getId(); + Long sellRecordId = apiOrderSellComplainDto.getSellRecordId(); + Integer orderType = apiOrderSellComplainDto.getOrderType(); + String buyOrderNo = null; + if(orderType == 1){ + + MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(sellRecordId); + if(ObjectUtil.isEmpty(mallProductSellRecord)){ + throw new FebsException("记录不存在"); + } + MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(mallProductSellRecord.getBuyRecordId()); + if(ObjectUtil.isEmpty(mallProductBuyRecord)){ + throw new FebsException("记录不存在"); + } + + mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue()); + mallProductBuyRecordMapper.updateById(mallProductBuyRecord); + + mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue()); + mallProductSellRecordMapper.updateById(mallProductSellRecord); + buyOrderNo = mallProductBuyRecord.getBuyOrderNo(); + } + if(orderType == 2){ + MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(sellRecordId); + if(ObjectUtil.isEmpty(mallProductBuyRecord)){ + throw new FebsException("记录不存在"); + } + + MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(mallProductBuyRecord.getSellRecordId()); + if(ObjectUtil.isEmpty(mallProductSellRecord)){ + throw new FebsException("记录不存在"); + } + + + mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue()); + mallProductBuyRecordMapper.updateById(mallProductBuyRecord); + + mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_COMPLAIN.getValue()); + mallProductSellRecordMapper.updateById(mallProductSellRecord); + buyOrderNo = mallProductBuyRecord.getBuyOrderNo(); + + } + + MallMemberSpeak mallMemberSpeak = new MallMemberSpeak(); + mallMemberSpeak.setMemberId(memberId); + mallMemberSpeak.setState(ProductEnum.SPEAK_NO_DEAL.getValue()); + String description = apiOrderSellComplainDto.getDescription(); + mallMemberSpeak.setDescription("编号:"+buyOrderNo+","+description); + mallMemberSpeakMapper.insert(mallMemberSpeak); + return new FebsResponse().success(); + } + + @Override + public FebsResponse orderRecordList(ApiOrderRecordListDto apiOrderListDto) { + Long memberId = LoginUserUtil.getLoginUser().getId(); + List<ApiOrderRecordListVo> objects = new ArrayList<>(); + apiOrderListDto.setMemberId(memberId); + 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){ + 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())){ + for(ApiOrderRecordListVo apiOrderListVo : apiOrderListVoIPageSell.getRecords()){ + objects.add(apiOrderListVo); + } + } + + return new FebsResponse().success().data(objects); + } + + @Override + public FebsResponse orderSellRecord(ApiOrderSellInfoDto apiOrderSellInfoDto) { + Long productSellRecordId = apiOrderSellInfoDto.getId(); + Long memberId = LoginUserUtil.getLoginUser().getId(); + MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(productSellRecordId); + if(ObjectUtil.isEmpty(mallProductSellRecord)){ + throw new FebsException("记录不存在"); + } + ApiOrderSellRecordInfoVo apiOrderSellRecordInfoVo = mallProductSellRecordMapper.selectBySellRecordId(productSellRecordId); + return new FebsResponse().success().data(apiOrderSellRecordInfoVo); + } + + @Override + public FebsResponse orderBuyRecord(ApiOrderBuyInfoDto apiOrderBuyInfoDto) { + Long productBuyRecordId = apiOrderBuyInfoDto.getId(); + Long memberId = LoginUserUtil.getLoginUser().getId(); + MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(productBuyRecordId); + if(ObjectUtil.isEmpty(mallProductBuyRecord)){ + throw new FebsException("记录不存在"); + } + ApiOrderBuyRecordInfoVo apiOrderBuyRecordInfoVo = mallProductBuyRecordMapper.selectByBuyRecordId(productBuyRecordId); + return new FebsResponse().success().data(apiOrderBuyRecordInfoVo); + } } -- Gitblit v1.9.1