From 0d30c93d000413c6eb34f489ef17688ad4175201 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Mon, 29 Apr 2024 18:18:21 +0800 Subject: [PATCH] 55测试环境 --- src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java | 48 ++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java index 9c5e38f..a7c1c69 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcEntrustOrderServiceImpl.java @@ -2,6 +2,7 @@ import cn.hutool.core.collection.CollUtil; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -16,10 +17,12 @@ 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.OtcBlackListDao; import com.xcong.excoin.modules.otc.dao.OtcMarketBussinessDao; import com.xcong.excoin.modules.otc.dao.OtcOrderDao; import com.xcong.excoin.modules.otc.dto.EntrustOrderAddDto; import com.xcong.excoin.modules.otc.dto.EntrustOrderListDto; +import com.xcong.excoin.modules.otc.entity.OtcBlackList; import com.xcong.excoin.modules.otc.entity.OtcEntrustOrder; import com.xcong.excoin.modules.otc.dao.OtcEntrustOrderDao; import com.xcong.excoin.modules.otc.entity.OtcMarketBussiness; @@ -30,21 +33,26 @@ import com.xcong.excoin.modules.otc.vo.EntrustListVo; import com.xcong.excoin.modules.otc.vo.EntrustOrderDetailVo; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import netscape.javascript.JSObject; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; import java.util.List; +@Slf4j @Service @RequiredArgsConstructor public class OtcEntrustOrderServiceImpl extends ServiceImpl<OtcEntrustOrderDao, OtcEntrustOrder> implements OtcEntrustOrderService { private final MemberDao memberDao; private final MemberPaymentMethodDao memberPaymentMethodDao; + private final OtcMarketBussinessDao otcMarketBussinessDao; private final MemberWalletCoinDao memberWalletCoinDao; private final OtcOrderDao otcOrderDao; private final CommonService commonService; + private final OtcBlackListDao otcBlackListDao; @Override @Transactional(rollbackFor = Exception.class) @@ -65,16 +73,25 @@ BigDecimal totalAmount = addDto.getUnitPrice().multiply(addDto.getAmount()); otcEntrustOrder.setTotalAmount(totalAmount); + + if (totalAmount.compareTo(addDto.getMax()) < 0) { + throw new GlobalException("最大限额应小于总金额"); + } + if (OtcEntrustOrder.ORDER_TYPE_S.equals(addDto.getType())) { MemberWalletCoinEntity coinWallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT"); - if(coinWallet.getAvailableBalance().compareTo(totalAmount) < 0) { +// BigDecimal multiply = addDto.getUnitPrice().multiply(coinWallet.getAvailableBalance()); + if(coinWallet.getAvailableBalance().compareTo(addDto.getAmount()) < 0) { throw new GlobalException("可用金额不足"); } - memberWalletCoinDao.updateFrozenBalance(member.getId(), coinWallet.getId(), totalAmount); + memberWalletCoinDao.updateFrozenBalance(member.getId(), coinWallet.getId(), addDto.getAmount()); } -// OtcMarketBussiness mb = otcMarketBussinessDao.selectMarketBussinessByMemberId(member.getId()); + if (!MemberEntity.IS_TRADER_Y.equals(member.getIsTrader())) { + throw new GlobalException("不是市商"); + } + if (member.getIsTrader() == 2) { otcEntrustOrder.setIsMb(OtcEntrustOrder.IS_MB_N); } else { @@ -137,7 +154,12 @@ @Override public IPage<EntrustListVo> findEntrustListInPage(EntrustOrderListDto dto) { + MemberEntity member = LoginUserUtils.getAppLoginUser(); Page<EntrustListVo> page = new Page<>(dto.getPageNum(), dto.getPageSize()); +// List<OtcBlackList> blackLists = otcBlackListDao.selectBlackListByMemberId(member.getId()); +// if (CollUtil.isNotEmpty(blackLists)) { + dto.setMemberId(member.getId()); +// } return this.baseMapper.selectEntrustListInPage(dto, page); } @@ -174,7 +196,7 @@ if (OtcEntrustOrder.ORDER_TYPE_S.equals(otcEntrustOrder.getOrderType())) { MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(member.getId(), "USDT"); - memberWalletCoinDao.subFrozenBalance(member.getId(), wallet.getId(), wallet.getFrozenBalance()); + memberWalletCoinDao.subFrozenBalance(member.getId(), wallet.getId(), otcEntrustOrder.getRemainCoinAmount()); } otcEntrustOrder = new OtcEntrustOrder(); @@ -185,18 +207,24 @@ @Override public Result findEntrustOrderDetail(Long id) { - MemberEntity member = LoginUserUtils.getAppLoginUser(); - OtcEntrustOrder otcEntrustOrder = this.baseMapper.selectById(id); if (otcEntrustOrder == null) { return Result.fail("参数错误"); } - if (!member.getId().equals(otcEntrustOrder.getMemberId())) { - return Result.fail("请求有误"); - } - + MemberPaymentMethodEntity defualtMethod = memberPaymentMethodDao.selectDefualtMethod(otcEntrustOrder.getMemberId(), null, "1"); + MemberEntity member = memberDao.selectById(otcEntrustOrder.getMemberId()); + OtcMarketBussiness mb = otcMarketBussinessDao.selectMarketBussinessByMemberId(member.getId()); EntrustOrderDetailVo detail = OtcEntrustOrderMapper.INSTANCE.entityToOrderDetail(otcEntrustOrder); + detail.setName(member.getName()); + if (OtcEntrustOrder.ORDER_TYPE_S.equals(otcEntrustOrder.getOrderType())) { + detail.setOrderCnt(mb.getSaleOrderCnt()); + detail.setFinishRatio(mb.getSaleFinishRatio()); + } else { + detail.setOrderCnt(mb.getBuyOrderCnt()); + detail.setFinishRatio(mb.getFinishRatio()); + } + detail.setPayType(defualtMethod.getPaymentType()); return Result.ok(detail); } } -- Gitblit v1.9.1