From 5575818556096be1dadaf5ff356b5db4c832aaa2 Mon Sep 17 00:00:00 2001
From: Helius <wangdoubleone@gmail.com>
Date: Wed, 26 May 2021 19:27:09 +0800
Subject: [PATCH] modify
---
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcOrderServiceImpl.java | 68 ++++++++++++++++++++++++++-------
1 files changed, 53 insertions(+), 15 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 c422f84..695709c 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
@@ -10,6 +10,7 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcong.excoin.common.LoginUserUtils;
+import com.xcong.excoin.common.contants.AppContants;
import com.xcong.excoin.common.exception.GlobalException;
import com.xcong.excoin.common.response.Result;
import com.xcong.excoin.common.system.service.CommonService;
@@ -19,22 +20,17 @@
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.dao.OtcOrderAppealDao;
+import com.xcong.excoin.modules.otc.dao.*;
import com.xcong.excoin.modules.otc.dto.HasPayDto;
import com.xcong.excoin.modules.otc.dto.OrderApealDto;
import com.xcong.excoin.modules.otc.dto.OrderListDto;
import com.xcong.excoin.modules.otc.dto.OtcOrderAddDto;
-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.entity.OtcOrderAppeal;
+import com.xcong.excoin.modules.otc.entity.*;
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 com.xcong.excoin.utils.RedisUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
@@ -49,7 +45,6 @@
@Service
@RequiredArgsConstructor
public class OtcOrderServiceImpl extends ServiceImpl<OtcOrderDao, OtcOrder> implements OtcOrderService {
-
private final OtcMarketBussinessDao otcMarketBussinessDao;
private final OtcEntrustOrderDao otcEntrustOrderDao;
private final OtcOrderAppealDao otcOrderAppealDao;
@@ -57,6 +52,9 @@
private final MemberWalletCoinDao memberWalletCoinDao;
private final MemberDao memberDao;
private final MemberPaymentMethodDao memberPaymentMethodDao;
+ private final OtcBlackListDao otcBlackListDao;
+ private final OtcSettingDao otcSettingDao;
+ private final RedisUtils redisUtils;
@Override
@@ -74,6 +72,13 @@
if (!OtcEntrustOrder.ORDER_TYPE_S.equals(entrustOrder.getOrderType())) {
throw new GlobalException("无法购买");
+ }
+
+ OtcSetting setting = otcSettingDao.selectById(1L);
+ String times = redisUtils.getString(AppContants.OTC_ORDER_CANCEL_TIMES + member.getId());
+ times = times == null ? "0" :times;
+ if (setting.getCancellNum() <= Integer.parseInt(times)) {
+ throw new GlobalException("订单取消次数过多, 限制交易24小时");
}
if (orderAddDto.getCnyAmount().compareTo(entrustOrder.getLimitMinAmount()) < 0) {
@@ -147,6 +152,13 @@
if (!OtcEntrustOrder.ORDER_TYPE_B.equals(entrustOrder.getOrderType())) {
throw new GlobalException("无法出售");
+ }
+
+ OtcSetting setting = otcSettingDao.selectById(1L);
+ String times = redisUtils.getString(AppContants.OTC_ORDER_CANCEL_TIMES + member.getId());
+ times = times == null ? "0" :times;
+ if (setting.getCancellNum() <= Integer.parseInt(times)) {
+ throw new GlobalException("订单取消次数过多, 限制交易24小时");
}
if (orderAddDto.getCnyAmount().compareTo(entrustOrder.getLimitMinAmount()) < 0) {
@@ -312,9 +324,17 @@
buyDetail.setCreateTime(buyOrder.getCreateTime());
buyDetail.setIsMb(member.getIsTrader());
buyDetail.setPayName(buyOrder.getPayName());
+ buyDetail.setIsOwnEntrust(member.getId().equals(buyOrder.getEntrustMemberId()) ? 1 : 2);
OtcOrder saleOrder = this.baseMapper.selectOrderByOrderNoAndType(otcOrder.getOrderNo(), OtcEntrustOrder.ORDER_TYPE_S);
MemberEntity saleMember = memberDao.selectById(saleOrder.getMemberId());
+
+ OtcBlackList otcBlackList = otcBlackListDao.selectByMemberIdAndBlackMemberId(member.getId(), buyOrder.getEntrustMemberId());
+ if (otcBlackList != null) {
+ buyDetail.setIsBlack(1);
+ } else {
+ buyDetail.setIsBlack(2);
+ }
buyDetail.setSaleName(saleMember.getName());
@@ -353,7 +373,6 @@
}
MemberEntity buyMember = memberDao.selectById(saleOrder.getOppositeMemberId());
-
SaleOrderDetailVo saleDetail = new SaleOrderDetailVo();
saleDetail.setOrderNo(saleOrder.getOrderNo());
saleDetail.setUsdtAmount(saleOrder.getCoinAmount());
@@ -365,7 +384,14 @@
saleDetail.setPayName(saleOrder.getPayName());
saleDetail.setSaleName(buyMember.getName());
saleDetail.setPayType(saleOrder.getPayType());
+ saleDetail.setIsOwnEntrust(member.getId().equals(saleOrder.getEntrustMemberId()) ? 1 : 2);
+ OtcBlackList otcBlackList = otcBlackListDao.selectByMemberIdAndBlackMemberId(member.getId(), saleOrder.getEntrustMemberId());
+ if (otcBlackList != null) {
+ saleDetail.setIsBlack(1);
+ } else {
+ saleDetail.setIsBlack(2);
+ }
if (!saleOrder.getMemberId().equals(saleOrder.getEntrustMemberId())) {
OtcMarketBussiness otcMb = otcMarketBussinessDao.selectMarketBussinessByMemberId(saleOrder.getEntrustMemberId());
saleDetail.setMbId(otcMb.getId());
@@ -383,6 +409,7 @@
@Override
public void cancelOrder(Long id) {
+ MemberEntity member = LoginUserUtils.getAppLoginUser();
OtcOrder otcOrder = this.baseMapper.selectById(id);
if (otcOrder == null) {
throw new GlobalException("订单不存在");
@@ -396,6 +423,20 @@
if (!saleOrder.getMemberId().equals(saleOrder.getEntrustMemberId())) {
MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(saleOrder.getMemberId(), "USDT");
memberWalletCoinDao.subFrozenBalance(saleOrder.getMemberId(), wallet.getId(), saleOrder.getCoinAmount());
+ }
+
+ OtcSetting setting = otcSettingDao.selectById(1L);
+ String times = redisUtils.getString(AppContants.OTC_ORDER_CANCEL_TIMES + member.getId());
+ if (StrUtil.isNotBlank(times)) {
+ int i = Integer.parseInt(times);
+ i++;
+ if (i >= setting.getCancellNum()) {
+ redisUtils.set(AppContants.OTC_ORDER_CANCEL_TIMES + member.getId(), i, 86400);
+ } else {
+ redisUtils.set(AppContants.OTC_ORDER_CANCEL_TIMES + member.getId(), i);
+ }
+ } else {
+ redisUtils.set(AppContants.OTC_ORDER_CANCEL_TIMES + member.getId(), 1, 86400);
}
otcEntrustOrderDao.updateRemainAmount(otcOrder.getEntrustOrderId(), otcOrder.getCoinAmount());
@@ -416,15 +457,12 @@
if(StrUtil.isEmpty(reason)){
return Result.fail("请填写申诉原因");
}
- String content = orderApealDto.getContent();
- if(StrUtil.isEmpty(content)){
- return Result.fail("请填写申诉内容");
- }
+ List<String> content = orderApealDto.getContent();
OtcOrderAppeal otcOrderAppeal = new OtcOrderAppeal();
otcOrderAppeal.setMemberId(memberId);
otcOrderAppeal.setOrderId(orderId);
otcOrderAppeal.setReason(reason);
- otcOrderAppeal.setContent(content);
+ otcOrderAppeal.setContent(content.toString());
otcOrderAppeal.setStatus(OtcOrderAppeal.STATUS_ONE);
otcOrderAppealDao.insert(otcOrderAppeal);
return Result.ok("成功");
--
Gitblit v1.9.1