From 0ca7bf5c850eaef852a6b49d4b94e8366deedb29 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Wed, 26 May 2021 15:03:51 +0800
Subject: [PATCH] 20210525 申诉
---
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java | 65 ++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 12 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java
index 72d212c..da8e856 100644
--- a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcMarketBussinessServiceImpl.java
@@ -1,5 +1,6 @@
package com.xcong.excoin.modules.otc.service.impl;
+import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.LoginUserUtils;
import com.xcong.excoin.common.exception.GlobalException;
@@ -8,9 +9,13 @@
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.otc.dao.OtcEntrustOrderDao;
import com.xcong.excoin.modules.otc.dao.OtcMarketBussinessDao;
+import com.xcong.excoin.modules.otc.dao.OtcOrderDao;
+import com.xcong.excoin.modules.otc.dao.OtcSettingDao;
import com.xcong.excoin.modules.otc.dto.MbAddDto;
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.entity.OtcSetting;
import com.xcong.excoin.modules.otc.mapper.OtcEntrustOrderMapper;
import com.xcong.excoin.modules.otc.mapper.OtcMarketBussinessMapper;
import com.xcong.excoin.modules.otc.service.OtcMarketBussinessService;
@@ -28,25 +33,61 @@
private final OtcEntrustOrderDao otcEntrustOrderDao;
private final MemberDao memberDao;
+ private final OtcSettingDao otcSettingDao;
+ private final OtcOrderDao otcOrderDao;
+
@Override
public void add() {
MemberEntity member = LoginUserUtils.getAppLoginUser();
+ member = memberDao.selectById(member.getId());
+// long memberId = 444L;
+// MemberEntity member = memberDao.selectById(memberId);
- OtcMarketBussiness mb = this.baseMapper.selectMarketBussinessByMemberId(member.getId());
- if (mb != null) {
- throw new GlobalException("该用户已经是市商或正在审核");
+ if (MemberEntity.IS_TRADER_Y.equals(member.getIsTrader())) {
+ throw new GlobalException("已经是市商");
+ }
+ OtcSetting setting = otcSettingDao.selectById(1L);
+ // 所有已完成订单
+ List<OtcOrder> finishOrders = otcOrderDao.selectOrderListForUser(member.getId(), 0);
+ if (CollUtil.isEmpty(finishOrders) || setting.getOrderNum() > finishOrders.size()) {
+ throw new GlobalException("条件未达标");
}
- OtcMarketBussiness otcMb = new OtcMarketBussiness();
- otcMb.setMemberId(member.getId());
- otcMb.setAvgCoinTime(0);
- otcMb.setAvgPayTime(0);
- otcMb.setTotalOrderCnt(0);
- otcMb.setBuyCnt(0);
- otcMb.setFinishRatio(BigDecimal.ZERO);
- otcMb.setStatus(OtcMarketBussiness.CHECK_WAIT);
+ List<OtcOrder> unFinishOrders = otcOrderDao.selectOrderListForUser(member.getId(), 4);
+ if (CollUtil.isNotEmpty(unFinishOrders)) {
+ //完成率 = 已完成 / 总单数
+ BigDecimal finishRatio = BigDecimal.valueOf(finishOrders.size()).divide(BigDecimal.valueOf(finishOrders.size() + unFinishOrders.size()), 4, BigDecimal.ROUND_DOWN).multiply(BigDecimal.valueOf(100));
+ if (setting.getCompletionRate().compareTo(finishRatio) > 0) {
+ throw new GlobalException("条件未达标");
+ }
+ }
- this.baseMapper.insert(otcMb);
+ BigDecimal totalAmount = otcOrderDao.selectOrderTotalAmount(member.getId());
+ if (setting.getTotalAmount().compareTo(totalAmount) > 0) {
+ throw new GlobalException("条件未达标");
+ }
+
+ OtcMarketBussiness mb = this.baseMapper.selectMarketBussinessByMemberId(member.getId());
+ OtcMarketBussiness otcMb = new OtcMarketBussiness();
+ if (mb != null) {
+ if (OtcMarketBussiness.CHECK_PASS.equals(mb.getStatus()) || OtcMarketBussiness.CHECK_WAIT.equals(mb.getStatus())) {
+ throw new GlobalException("已经是市商或正在审核");
+ }
+
+ otcMb = mb;
+ otcMb.setStatus(OtcMarketBussiness.CHECK_WAIT);
+ this.baseMapper.updateById(otcMb);
+ } else {
+ otcMb.setMemberId(member.getId());
+ otcMb.setAvgCoinTime(0);
+ otcMb.setAvgPayTime(0);
+ otcMb.setTotalOrderCnt(0);
+ otcMb.setBuyCnt(0);
+ otcMb.setFinishRatio(BigDecimal.ZERO);
+ otcMb.setStatus(OtcMarketBussiness.CHECK_WAIT);
+
+ this.baseMapper.insert(otcMb);
+ }
}
@Override
--
Gitblit v1.9.1