| | |
| | | ApiOrderBuyRecordInfoVo apiOrderBuyRecordInfoVo = mallProductBuyRecordMapper.selectByBuyRecordId(productBuyRecordId); |
| | | return new FebsResponse().success().data(apiOrderBuyRecordInfoVo); |
| | | } |
| | | |
| | | @Override |
| | | 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(); |
| | | } |
| | | } |