KKSU
2023-12-11 b6ad0f29932c0a4f6053a765723aa4d80adcc706
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java
@@ -46,6 +46,7 @@
    private final MallProductSellMapper mallProductSellMapper;
    private final MallProductSellRecordMapper mallProductSellRecordMapper;
    private final MallProductBuyRecordMapper mallProductBuyRecordMapper;
    private final MallMemberSpeakMapper mallMemberSpeakMapper;
    @Override
    public List<ApiMallProductNftVo> productNFTList() {
@@ -281,21 +282,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 +312,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 +330,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();
    }
@@ -554,4 +548,34 @@
        }
        return false;
    }
    @Override
    public FebsResponse orderSellComplain(ApiOrderSellComplainDto apiOrderSellComplainDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        Long sellRecordId = apiOrderSellComplainDto.getSellRecordId();
        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);
        MallMemberSpeak mallMemberSpeak = new MallMemberSpeak();
        mallMemberSpeak.setMemberId(memberId);
        mallMemberSpeak.setState(ProductEnum.SPEAK_NO_DEAL.getValue());
        String description = apiOrderSellComplainDto.getDescription();
        String buyOrderNo = mallProductBuyRecord.getBuyOrderNo();
        mallMemberSpeak.setDescription("编号:"+buyOrderNo+","+description);
        mallMemberSpeakMapper.insert(mallMemberSpeak);
        return new FebsResponse().success();
    }
}