| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public FebsResponse transGfd(ApiTransGfdDto transGfdDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | BigDecimal cnt = transGfdDto.getCnt();//兑换数量 |
| | |
| | | } |
| | | 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(); |
| | | } |
| | | } |