From 0d881874136ef0fecf31af98419af6bebdef1ac6 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Thu, 20 May 2021 16:40:13 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java | 101 ++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 97 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java
index 9c3a8c1..f0838ba 100644
--- a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java
@@ -8,19 +8,27 @@
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.exception.GlobalException;
+import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.common.system.service.CommonService;
import com.xcong.excoin.modules.member.dao.MemberDao;
+import com.xcong.excoin.modules.member.dao.MemberPaymentMethodDao;
import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
import com.xcong.excoin.modules.member.entity.MemberEntity;
+import com.xcong.excoin.modules.member.entity.MemberPaymentMethodEntity;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.modules.otc.dao.OtcEntrustOrderDao;
+import com.xcong.excoin.modules.otc.dao.OtcMarketBussinessDao;
+import com.xcong.excoin.modules.otc.dto.HasPayDto;
import com.xcong.excoin.modules.otc.dto.OrderAddDto;
import com.xcong.excoin.modules.otc.dto.OrderListDto;
import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder;
+import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness;
import com.xcong.excoin.modules.otc.entity.OtcOrder;
import com.xcong.excoin.modules.otc.dao.OtcOrderDao;
import com.xcong.excoin.modules.otc.service.OtcOrderService;
+import com.xcong.excoin.modules.otc.vo.BuyOrderDetailVo;
import com.xcong.excoin.modules.otc.vo.OrderListVo;
+import com.xcong.excoin.modules.otc.vo.SaleOrderDetailVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
@@ -36,10 +44,13 @@
@RequiredArgsConstructor
public class OtcOrderServiceImpl extends ServiceImpl<OtcOrderDao, OtcOrder> implements OtcOrderService {
+ private final OtcMarketBussinessDao otcMarketBussinessDao;
private final OtcEntrustOrderDao otcEntrustOrderDao;
private final CommonService commonService;
private final MemberWalletCoinDao memberWalletCoinDao;
private final MemberDao memberDao;
+ private final MemberPaymentMethodDao memberPaymentMethodDao;
+
@Override
@Transactional(rollbackFor = Exception.class)
@@ -153,8 +164,9 @@
}
@Override
- public void hasPay(Long id) {
- OtcOrder otcOrder = this.baseMapper.selectById(id);
+ public void hasPay(HasPayDto hasPayDto) {
+ MemberEntity member = LoginUserUtils.getAppLoginUser();
+ OtcOrder otcOrder = this.baseMapper.selectById(hasPayDto.getId());
if (otcOrder == null) {
throw new GlobalException("订单不存在");
@@ -168,7 +180,12 @@
throw new GlobalException("不是购买单");
}
- this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_PAY, otcOrder.getOrderNo());
+ if (StrUtil.isBlank(hasPayDto.getName())) {
+ MemberPaymentMethodEntity defualtMethod = memberPaymentMethodDao.selectDefualtMethod(member.getId(), 3, "1");
+ hasPayDto.setName(defualtMethod.getName());
+ }
+
+ this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_PAY, hasPayDto.getName(), otcOrder.getOrderNo());
}
@Override
@@ -200,6 +217,82 @@
// 出售者钱包冻结减少币
memberWalletCoinDao.reduceFrozenBalance(saleWallet.getId(), buyOrder.getCoinAmount());
- this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_PAY, otcOrder.getOrderNo());
+ this.baseMapper.updateOrderStatusByOrderNo(OtcOrder.STATUS_PAY, null, otcOrder.getOrderNo());
+ }
+
+ @Override
+ public Result findBuyOrderDetail(Long id) {
+ MemberEntity member = LoginUserUtils.getAppLoginUser();
+ member = memberDao.selectById(member.getId());
+ OtcOrder otcOrder = this.baseMapper.selectById(id);
+ if (otcOrder == null) {
+ return Result.fail("订单不存在");
+ }
+
+ OtcOrder buyOrder = this.baseMapper.selectOrderByOrderNoAndType(otcOrder.getOrderNo(), OtcEntrustOrder.ORDER_TYPE_B);
+ if (buyOrder == null) {
+ return Result.fail("参数错误");
+ }
+
+ BuyOrderDetailVo buyDetail = new BuyOrderDetailVo();
+ buyDetail.setOrderNo(buyOrder.getOrderNo());
+ buyDetail.setUsdtAmount(buyOrder.getCoinAmount());
+ buyDetail.setStatus(buyOrder.getStatus());
+ buyDetail.setTotalAmount(buyOrder.getTotalAmount());
+ buyDetail.setUnitPrice(buyOrder.getUnitPrice());
+ buyDetail.setCreateTime(new Date());
+ buyDetail.setIsMb(member.getIsTrader());
+
+ OtcOrder saleOrder = this.baseMapper.selectOrderByOrderNoAndType(otcOrder.getOrderNo(), OtcEntrustOrder.ORDER_TYPE_S);
+ MemberEntity saleMember = memberDao.selectById(saleOrder.getMemberId());
+
+ buyDetail.setSaleName(saleMember.getName());
+ MemberPaymentMethodEntity defaultMethod = memberPaymentMethodDao.selectDefualtMethod(saleOrder.getMemberId(), 3, "1");
+ buyDetail.setBankName(defaultMethod.getName());
+ buyDetail.setBankNo(defaultMethod.getAccount());
+ buyDetail.setPayName(defaultMethod.getName());
+ buyDetail.setPayTime(buyDetail.getPayTime());
+
+ if (!buyOrder.getMemberId().equals(buyOrder.getEntrustMemberId())) {
+ OtcMarketBussiness otcMb = otcMarketBussinessDao.selectMarketBussinessByMemberId(buyOrder.getEntrustMemberId());
+ buyDetail.setMbId(otcMb.getId());
+ buyDetail.setFinishRatio(otcMb.getFinishRatio());
+ buyDetail.setOrderCnt(otcMb.getBuyCnt());
+ }
+
+ return Result.ok(buyDetail);
+ }
+
+ @Override
+ public Result findSaleOrderDetail(Long id) {
+ MemberEntity member = LoginUserUtils.getAppLoginUser();
+ OtcOrder otcOrder = this.baseMapper.selectById(id);
+ if (otcOrder == null) {
+ return Result.fail("订单不存在");
+ }
+
+ OtcOrder saleOrder = this.baseMapper.selectOrderByOrderNoAndType(otcOrder.getOrderNo(), OtcEntrustOrder.ORDER_TYPE_S);
+ if (saleOrder == null) {
+ return Result.fail("参数错误");
+ }
+
+ SaleOrderDetailVo saleDetail = new SaleOrderDetailVo();
+ saleDetail.setOrderNo(saleOrder.getOrderNo());
+ saleDetail.setUsdtAmount(saleOrder.getCoinAmount());
+ saleDetail.setStatus(saleOrder.getStatus());
+ saleDetail.setTotalAmount(saleOrder.getTotalAmount());
+ saleDetail.setUnitPrice(saleOrder.getUnitPrice());
+ saleDetail.setCreateTime(new Date());
+ saleDetail.setIsMb(member.getIsTrader());
+ saleDetail.setPayName(saleOrder.getPayName());
+
+ if (!saleOrder.getMemberId().equals(saleOrder.getEntrustMemberId())) {
+ OtcMarketBussiness otcMb = otcMarketBussinessDao.selectMarketBussinessByMemberId(saleOrder.getEntrustMemberId());
+ saleDetail.setMbId(otcMb.getId());
+ saleDetail.setFinishRatio(otcMb.getFinishRatio());
+ saleDetail.setOrderCnt(otcMb.getBuyCnt());
+ }
+
+ return Result.ok(saleDetail);
}
}
--
Gitblit v1.9.1