From d4c0bf0a7cf69d58f87b07031aa6ba1ecfaa012b Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Wed, 22 May 2024 10:41:34 +0800
Subject: [PATCH] 增加支付宝收款码
---
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java | 436 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 380 insertions(+), 56 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 ed4476f..763df18 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.*;
@@ -17,9 +18,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 +33,8 @@
import java.math.BigDecimal;
import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
import java.util.List;
@Slf4j
@@ -46,6 +51,7 @@
private final MallProductSellMapper mallProductSellMapper;
private final MallProductSellRecordMapper mallProductSellRecordMapper;
private final MallProductBuyRecordMapper mallProductBuyRecordMapper;
+ private final MallMemberSpeakMapper mallMemberSpeakMapper;
@Override
public List<ApiMallProductNftVo> productNFTList() {
@@ -64,15 +70,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;
@@ -94,20 +101,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("请输入正确的交易密码");
}
@@ -121,7 +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("每日开启一次");
}
BigDecimal priceToken = mallProductNft.getPriceToken();
@@ -140,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);
//令牌 可用减少,冻结增加
@@ -154,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
@@ -193,7 +212,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(),
@@ -263,6 +282,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());
@@ -281,21 +305,23 @@
BigDecimal nftFeePercent = ObjectUtil.isEmpty(nftFeeDic) ? new BigDecimal(20) : new BigDecimal(nftFeeDic.getValue());
nftFeePercent = nftFeePercent.divide(new BigDecimal(100),4,BigDecimal.ROUND_DOWN);
BigDecimal nftFee = nftCnt.multiply(nftFeePercent);
- BigDecimal nftCntAva = nftCnt.subtract(nftFee);
-
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 fcmFeeCnt = nftFee.divide(fcmPrice, 2, BigDecimal.ROUND_DOWN);
+ if(BigDecimal.ZERO.compareTo(mallMemberAmount.getTrendsNft()) >= 0
+ || fcmFeeCnt.compareTo(mallMemberAmount.getFcmCntAva()) > 0){
+ throw new FebsException("手续费不足");
+ }
String orderNo = MallUtils.getOrderNum("NFT");
MallProductSell mallProductSell = new MallProductSell();
mallProductSell.setMemberId(memberId);
mallProductSell.setOrderNo(orderNo);
mallProductSell.setNftTotal(nftCnt);
- mallProductSell.setNftCnt(nftCntAva);
- mallProductSell.setNftCntAva(nftCntAva);
+ mallProductSell.setNftCnt(nftCnt);
+ mallProductSell.setNftCntAva(nftCnt);
mallProductSell.setNftFee(nftFee);
mallProductSell.setFcmFee(fcmFeeCnt);
mallProductSell.setState(ProductEnum.PRODUCT_SELL_ON_GOING.getValue());
@@ -309,7 +335,7 @@
mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmountFcm);
MallMemberAmount mallMemberAmountFrozenNFT = mallMemberAmountMapper.selectByMemberId(memberId);
- mallMemberAmountFrozenNFT.setFrozenNft(mallMemberAmountFrozenNFT.getFrozenNft().add(nftCntAva));
+ mallMemberAmountFrozenNFT.setFrozenNft(mallMemberAmountFrozenNFT.getFrozenNft().add(nftCnt));
mallMemberAmountMapper.updateFrozenNftById(mallMemberAmountFrozenNFT);
iMallMoneyFlowService.addMoneyFlow(
memberId,
@@ -327,15 +353,6 @@
mallMember.getId(),
FlowTypeNewEnum.FCM_COIN.getValue(),
MoneyFlowTypeNewEnum.NFT_OUT_FEE_FCM.getDescrition());
- iMallMoneyFlowService.addMoneyFlow(
- memberId,
- nftFee.negate(),
- MoneyFlowTypeNewEnum.NFT_OUT_FEE.getValue(),
- orderNo,
- mallMember.getId(),
- FlowTypeNewEnum.NFT.getValue(),
- MoneyFlowTypeNewEnum.NFT_OUT_FEE.getDescrition());
-
agentProducer.sendFcmNFTExchangeMsg(fcmFeeCnt.toString());
return new FebsResponse().success();
}
@@ -369,24 +386,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);
}
}
}
@@ -486,6 +520,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();
}
@@ -533,6 +576,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();
}
@@ -554,4 +616,266 @@
}
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> 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);
+ }
+
+ @Override
+ @Transactional
+ public FebsResponse transGfd(ApiTransGfdDto transGfdDto) {
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ BigDecimal cnt = transGfdDto.getCnt();//兑换数量
+
+ MallMember mallMember = memberMapper.selectById(memberId);
+ String tradePassword = SecureUtil.md5(transGfdDto.getTradePassword());
+ Boolean aBoolean = operationPermissionMemberFrozen(memberId);
+ if(aBoolean){
+ throw new FebsException("用户已冻结");
+ }
+ if(!tradePassword.equals(mallMember.getTradePassword())){
+ throw new FebsException("请输入正确的交易密码");
+ }
+ MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
+ Integer type = transGfdDto.getType();
+ String orderNo = MallUtils.getOrderNum("GSD");
+ if(1 == type){//NFT兑换GFD
+ BigDecimal trendsNft = mallMemberAmount.getTrendsNft();
+ if(BigDecimal.ZERO.compareTo(trendsNft) >= 0){
+ throw new FebsException("NFT不足");
+ }
+ if(cnt.compareTo(trendsNft) > 0){
+ throw new FebsException("NFT不足");
+ }
+ mallMemberAmount.setTrendsNft(trendsNft.subtract(cnt));
+ mallMemberAmount.setGsd(mallMemberAmount.getGsd().add(cnt));
+ mallMemberAmountMapper.updateTrendsNftAndGsdById(mallMemberAmount);
+ iMallMoneyFlowService.addMoneyFlow(
+ memberId,
+ cnt,
+ MoneyFlowTypeNewEnum.NFT_GSD.getValue(),
+ orderNo,
+ mallMember.getId(),
+ FlowTypeNewEnum.GSD.getValue(),
+ MoneyFlowTypeNewEnum.NFT_GSD.getDescrition());
+
+ }
+ if(2 == type){//GFA兑换GFD
+ BigDecimal fcmCntAva = mallMemberAmount.getFcmCntAva();
+ if(BigDecimal.ZERO.compareTo(fcmCntAva) >= 0){
+ throw new FebsException("代币不足");
+ }
+ if(cnt.compareTo(fcmCntAva) > 0){
+ throw new FebsException("代币不足");
+ }
+ 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 gsdCnt = fcmPrice.multiply(cnt);
+ mallMemberAmount.setFcmCntAva(fcmCntAva.subtract(cnt));
+ mallMemberAmount.setGsd(mallMemberAmount.getGsd().add(gsdCnt));
+ mallMemberAmountMapper.updateFcmCntAvaAndGsdById(mallMemberAmount);
+ iMallMoneyFlowService.addMoneyFlow(
+ memberId,
+ cnt,
+ MoneyFlowTypeNewEnum.GFA_GSD.getValue(),
+ orderNo,
+ mallMember.getId(),
+ FlowTypeNewEnum.GSD.getValue(),
+ MoneyFlowTypeNewEnum.GFA_GSD.getDescrition());
+
+ }
+ return new FebsResponse().success();
+ }
+
+ @Override
+ @Transactional
+ public FebsResponse gfdTrans(ApiGfdTransDto transGfdDto) {
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ BigDecimal cnt = transGfdDto.getCnt();//兑换数量
+
+ MallMember mallMember = memberMapper.selectById(memberId);
+ String tradePassword = SecureUtil.md5(transGfdDto.getTradePassword());
+ Boolean aBoolean = operationPermissionMemberFrozen(memberId);
+ if(aBoolean){
+ throw new FebsException("用户已冻结");
+ }
+ if(!tradePassword.equals(mallMember.getTradePassword())){
+ throw new FebsException("请输入正确的交易密码");
+ }
+ MallMemberAmount mallMemberAmount = mallMemberAmountMapper.selectByMemberId(memberId);
+ BigDecimal gsd = mallMemberAmount.getGsd();
+ if(BigDecimal.ZERO.compareTo(gsd) >= 0){
+ throw new FebsException("积分不足");
+ }
+ if(cnt.compareTo(gsd) > 0){
+ throw new FebsException("积分不足");
+ }
+ Integer type = transGfdDto.getType();
+ String orderNo = MallUtils.getOrderNum("GSD");
+ if(1 == type){//GFD兑换NFT
+ BigDecimal trendsNft = mallMemberAmount.getTrendsNft();
+ mallMemberAmount.setTrendsNft(trendsNft.add(cnt));
+ mallMemberAmount.setGsd(mallMemberAmount.getGsd().subtract(cnt));
+ mallMemberAmountMapper.updateTrendsNftAndGsdById(mallMemberAmount);
+ iMallMoneyFlowService.addMoneyFlow(
+ memberId,
+ cnt,
+ MoneyFlowTypeNewEnum.GSD_NFT.getValue(),
+ orderNo,
+ mallMember.getId(),
+ FlowTypeNewEnum.GSD.getValue(),
+ MoneyFlowTypeNewEnum.GSD_NFT.getDescrition());
+
+ }
+ if(2 == type){//GFD兑换GFA
+ BigDecimal fcmCntAva = mallMemberAmount.getFcmCntAva();
+ 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 gsdCnt = cnt.divide(fcmPrice,2,BigDecimal.ROUND_DOWN);
+ mallMemberAmount.setFcmCntAva(fcmCntAva.add(gsdCnt));
+ mallMemberAmount.setGsd(mallMemberAmount.getGsd().subtract(cnt));
+ mallMemberAmountMapper.updateFcmCntAvaAndGsdById(mallMemberAmount);
+ iMallMoneyFlowService.addMoneyFlow(
+ memberId,
+ cnt,
+ MoneyFlowTypeNewEnum.GSD_GFA.getValue(),
+ orderNo,
+ mallMember.getId(),
+ FlowTypeNewEnum.GSD.getValue(),
+ MoneyFlowTypeNewEnum.GSD_GFA.getDescrition());
+
+ }
+ 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