| | |
| | | private final MallProductSellMapper mallProductSellMapper; |
| | | private final MallProductSellRecordMapper mallProductSellRecordMapper; |
| | | private final MallProductBuyRecordMapper mallProductBuyRecordMapper; |
| | | private final MallMemberSpeakMapper mallMemberSpeakMapper; |
| | | |
| | | @Override |
| | | public List<ApiMallProductNftVo> productNFTList() { |
| | |
| | | * 预约,验证交易密码、预约产品是否开启状态、该产品是否已经预约、token是否足够 |
| | | * 冻结对应的令牌数量、生成预约记录、生成流水记录 |
| | | */ |
| | | Boolean aBoolean = operationPermissionMemberFrozen(memberId); |
| | | if(aBoolean){ |
| | | throw new FebsException("用户已冻结"); |
| | | } |
| | | |
| | | DateTime nowTime = DateUtil.parseTime(DateUtil.formatTime(DateUtil.date())); |
| | | DataDictionaryCustom startTimeDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( |
| | | DataDictionaryEnum.YU_YUE_START_TIME.getType(), |
| | |
| | | * 计算手续费、减少用户的fcm余额 |
| | | * 增加流水 |
| | | */ |
| | | |
| | | Boolean aBoolean = operationPermissionMemberFrozen(memberId); |
| | | if(aBoolean){ |
| | | throw new FebsException("用户已冻结"); |
| | | } |
| | | if(!tradePassword.equals(mallMember.getTradePassword())){ |
| | | throw new FebsException("请输入正确的交易密码"); |
| | | } |
| | |
| | | FlowTypeNewEnum.FCM_COIN.getValue(), |
| | | MoneyFlowTypeNewEnum.FCM_OUT_FEE.getDescrition()); |
| | | |
| | | mallMemberAmount.setTrendsNft(mallMemberAmount.getTrendsNft().add(nftCnt)); |
| | | mallMemberAmountMapper.updateTrendsNftById(mallMemberAmount); |
| | | MallMemberAmount mallMemberAmountNft = mallMemberAmountMapper.selectByMemberId(memberId); |
| | | mallMemberAmountNft.setTrendsNft(mallMemberAmountNft.getTrendsNft().add(nftCnt)); |
| | | mallMemberAmountMapper.updateTrendsNftById(mallMemberAmountNft); |
| | | String orderNoNFT = MallUtils.getOrderNum("NFT"); |
| | | iMallMoneyFlowService.addMoneyFlow( |
| | | memberId, |
| | |
| | | * 计算手续费、减少动态NFT、增加冻结NFT |
| | | * 增加流水 |
| | | */ |
| | | |
| | | Boolean aBoolean = operationPermissionMemberFrozen(memberId); |
| | | if(aBoolean){ |
| | | throw new FebsException("用户已冻结"); |
| | | } |
| | | if(!tradePassword.equals(mallMember.getTradePassword())){ |
| | | throw new FebsException("请输入正确的交易密码"); |
| | | } |
| | |
| | | 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()); |
| | |
| | | mallMemberAmount.setTrendsNft(mallMemberAmount.getTrendsNft().subtract(nftCnt)); |
| | | mallMemberAmountMapper.updateTrendsNftById(mallMemberAmount); |
| | | |
| | | mallMemberAmount.setFcmCntAva(mallMemberAmount.getFcmCntAva().subtract(fcmFeeCnt)); |
| | | mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmount); |
| | | MallMemberAmount mallMemberAmountFcm = mallMemberAmountMapper.selectByMemberId(memberId); |
| | | mallMemberAmountFcm.setFcmCntAva(mallMemberAmountFcm.getFcmCntAva().subtract(fcmFeeCnt)); |
| | | mallMemberAmountMapper.updateFcmCntAvaById(mallMemberAmountFcm); |
| | | |
| | | mallMemberAmount.setFrozenNft(mallMemberAmount.getFrozenNft().add(nftCntAva)); |
| | | mallMemberAmountMapper.updateFrozenNftById(mallMemberAmount); |
| | | MallMemberAmount mallMemberAmountFrozenNFT = mallMemberAmountMapper.selectByMemberId(memberId); |
| | | mallMemberAmountFrozenNFT.setFrozenNft(mallMemberAmountFrozenNFT.getFrozenNft().add(nftCnt)); |
| | | mallMemberAmountMapper.updateFrozenNftById(mallMemberAmountFrozenNFT); |
| | | iMallMoneyFlowService.addMoneyFlow( |
| | | memberId, |
| | | nftCnt.negate(), |
| | |
| | | MoneyFlowTypeNewEnum.NFT_OUT.getDescrition()); |
| | | iMallMoneyFlowService.addMoneyFlow( |
| | | memberId, |
| | | nftFee.negate(), |
| | | MoneyFlowTypeNewEnum.NFT_OUT_FEE.getValue(), |
| | | fcmFeeCnt.negate(), |
| | | MoneyFlowTypeNewEnum.NFT_OUT_FEE_FCM.getValue(), |
| | | orderNo, |
| | | mallMember.getId(), |
| | | FlowTypeNewEnum.NFT.getValue(), |
| | | MoneyFlowTypeNewEnum.NFT_OUT_FEE.getDescrition()); |
| | | iMallMoneyFlowService.addMoneyFlow( |
| | | memberId, |
| | | nftFee.negate(), |
| | | MoneyFlowTypeNewEnum.NFT_OUT_FEE.getValue(), |
| | | orderNo, |
| | | mallMember.getId(), |
| | | FlowTypeNewEnum.NFT.getValue(), |
| | | MoneyFlowTypeNewEnum.NFT_OUT_FEE.getDescrition()); |
| | | |
| | | FlowTypeNewEnum.FCM_COIN.getValue(), |
| | | MoneyFlowTypeNewEnum.NFT_OUT_FEE_FCM.getDescrition()); |
| | | agentProducer.sendFcmNFTExchangeMsg(fcmFeeCnt.toString()); |
| | | return new FebsResponse().success(); |
| | | } |
| | |
| | | ); |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | |
| | | * 更新卖单状态 |
| | | * 生成流水信息 |
| | | */ |
| | | |
| | | Boolean aBoolean = operationPermissionMemberFrozen(memberId); |
| | | if(aBoolean){ |
| | | throw new FebsException("用户已冻结"); |
| | | } |
| | | if(!tradePassword.equals(mallMember.getTradePassword())){ |
| | | throw new FebsException("请输入正确的交易密码"); |
| | | } |
| | |
| | | * 更新卖单状态 |
| | | * 生成流水信息 |
| | | */ |
| | | |
| | | Boolean aBoolean = operationPermissionMemberFrozen(memberId); |
| | | if(aBoolean){ |
| | | throw new FebsException("用户已冻结"); |
| | | } |
| | | if(!tradePassword.equals(mallMember.getTradePassword())){ |
| | | throw new FebsException("请输入正确的交易密码"); |
| | | } |
| | |
| | | agentProducer.sendFcmOrderSellInsureMsg(sellRecordId); |
| | | return new FebsResponse().success(); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse orderBuyList(ApiOrderBuyDto apiOrderBuyDto) { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | IPage<ApiOrderBuyVo> page = new Page<>(apiOrderBuyDto.getPageNum(), apiOrderBuyDto.getPageSize()); |
| | | apiOrderBuyDto.setMemberId(memberId); |
| | | IPage<ApiOrderBuyVo> apiOrderBuyVoIPage = mallProductBuyMapper.selectBuyListInPage(page, apiOrderBuyDto); |
| | | return new FebsResponse().success().data(apiOrderBuyVoIPage); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean operationPermissionMemberFrozen(Long memberId) { |
| | | MallMember mallMember = memberMapper.selectById(memberId); |
| | | if(ProductEnum.MEMBER_FROZEN.getValue() == mallMember.getIsFrozen()){ |
| | | return true; |
| | | } |
| | | 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); |
| | | } |
| | | } |