From a9153a58538d353b3057898746710dc21c1b9769 Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Fri, 24 Nov 2023 09:33:25 +0800
Subject: [PATCH] 匹配
---
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallProductServiceImpl.java | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 106 insertions(+), 1 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 bc49198..1fdf668 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
@@ -16,6 +16,8 @@
import cc.mrbird.febs.mall.vo.*;
import cc.mrbird.febs.rabbit.producter.AgentProducer;
import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.SecureUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -91,7 +93,7 @@
mallProductBuy.setOrderNo(orderNo);
mallProductBuy.setProductNftId(mallProductNft.getId());
mallProductBuy.setState(ProductEnum.PRODUCT_BUY_ON_GOING.getValue());
- mallProductBuy.setMateState(ProductEnum.PRODUCT_MATE_STATE_ON_GOING.getValue());
+ mallProductBuy.setMateState(ProductEnum.PRODUCT_BUY_MATE_STATE_FAIL.getValue());
mallProductBuy.setNftTotal(mallProductNft.getPriceNft());
mallProductBuy.setNftAva(BigDecimal.ZERO);
mallProductBuyMapper.insert(mallProductBuy);
@@ -328,4 +330,107 @@
}
return new FebsResponse().success().data(apiOrderBuyInfoVo);
}
+
+ @Override
+ public FebsResponse orderBuyInsure(ApiOrderBuyInsureDto apiOrderBuyInsureDto) {
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ MallMember mallMember = memberMapper.selectById(memberId);
+ Long buyRecordId = apiOrderBuyInsureDto.getBuyRecordId();
+ String nftImg = apiOrderBuyInsureDto.getNftImg();
+ Integer type = apiOrderBuyInsureDto.getType();
+ String tradePassword = SecureUtil.md5(apiOrderBuyInsureDto.getTradePassword());
+ /**
+ * 验证订单是否存在
+ * 更新买单状态
+ * 更新卖单状态
+ * 生成流水信息
+ */
+ if(!tradePassword.equals(mallMember.getTradePassword())){
+ throw new FebsException("请输入正确的交易密码");
+ }
+ MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(buyRecordId);
+ if(ObjectUtil.isEmpty(mallProductBuyRecord)){
+ throw new FebsException("记录不存在");
+ }
+ Integer state = mallProductBuyRecord.getState();
+ if(ProductEnum.PRODUCT_MATE_STATE_WAIT_PAY.getValue() != state){
+ throw new FebsException("记录不是待支付状态");
+ }
+
+ MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(mallProductBuyRecord.getSellRecordId());
+ if(ObjectUtil.isEmpty(mallProductSellRecord)){
+ throw new FebsException("记录不存在");
+ }
+ Integer stateSell = mallProductSellRecord.getState();
+ if(ProductEnum.PRODUCT_MATE_STATE_WAIT_PAY.getValue() != stateSell){
+ throw new FebsException("记录不是待支付状态");
+ }
+
+ DateTime payTime = DateUtil.date();
+ mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue());
+ mallProductBuyRecord.setPayTime(payTime);
+ mallProductBuyRecord.setNftImg(nftImg);
+ mallProductBuyRecord.setType(type);
+ mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
+
+ mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue());
+ mallProductSellRecord.setPayTime(payTime);
+ mallProductSellRecord.setNftImg(nftImg);
+ mallProductSellRecord.setType(type);
+ mallProductSellRecordMapper.updateById(mallProductSellRecord);
+
+ String orderNo = MallUtils.getOrderNum("ZF");
+ iMallMoneyFlowService.addMoneyFlow(
+ memberId,
+ mallProductBuyRecord.getPickNftCnt(),
+ MoneyFlowTypeNewEnum.PAY.getValue(),
+ orderNo,
+ mallMember.getId(),
+ FlowTypeNewEnum.NFT.getValue(),
+ MoneyFlowTypeNewEnum.PAY.getDescrition());
+ return new FebsResponse().success();
+ }
+
+ @Override
+ public FebsResponse orderSellInsure(ApiOrderSellInsureDto apiOrderSellInsureDto) {
+ Long memberId = LoginUserUtil.getLoginUser().getId();
+ MallMember mallMember = memberMapper.selectById(memberId);
+ String tradePassword = SecureUtil.md5(apiOrderSellInsureDto.getTradePassword());
+ Long sellRecordId = apiOrderSellInsureDto.getSellRecordId();
+ /**
+ * 验证订单是否存在
+ * 更新买单状态
+ * 更新卖单状态
+ * 生成流水信息
+ */
+ if(!tradePassword.equals(mallMember.getTradePassword())){
+ throw new FebsException("请输入正确的交易密码");
+ }
+ MallProductSellRecord mallProductSellRecord = mallProductSellRecordMapper.selectById(sellRecordId);
+ if(ObjectUtil.isEmpty(mallProductSellRecord)){
+ throw new FebsException("记录不存在");
+ }
+ Integer stateSell = mallProductSellRecord.getState();
+ if(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue() != stateSell){
+ throw new FebsException("记录不是已支付状态");
+ }
+
+ MallProductBuyRecord mallProductBuyRecord = mallProductBuyRecordMapper.selectById(mallProductSellRecord.getBuyRecordId());
+ if(ObjectUtil.isEmpty(mallProductBuyRecord)){
+ throw new FebsException("记录不存在");
+ }
+ Integer state = mallProductBuyRecord.getState();
+ if(ProductEnum.PRODUCT_MATE_STATE_PAY.getValue() != state){
+ throw new FebsException("记录不是已支付状态");
+ }
+
+ mallProductBuyRecord.setState(ProductEnum.PRODUCT_MATE_STATE_CONFIRM.getValue());
+ mallProductBuyRecordMapper.updateById(mallProductBuyRecord);
+
+ mallProductSellRecord.setState(ProductEnum.PRODUCT_MATE_STATE_CONFIRM.getValue());
+ mallProductSellRecordMapper.updateById(mallProductSellRecord);
+
+ agentProducer.sendFcmOrderSellInsureMsg(sellRecordId);
+ return new FebsResponse().success();
+ }
}
--
Gitblit v1.9.1