From cf200a1f92c01ba22c326c49391f748ffb006910 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Mon, 05 Jul 2021 17:28:35 +0800 Subject: [PATCH] 20210617 开售开关 --- src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java | 148 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 139 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java index c240dcc..a90136b 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java +++ b/src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java @@ -1,6 +1,7 @@ package com.xcong.excoin.modules.otc.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -15,14 +16,8 @@ import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity; import com.xcong.excoin.modules.member.mapper.MemberMapper; import com.xcong.excoin.modules.member.mapper.MemberWalletCoinMapper; -import com.xcong.excoin.modules.otc.entity.OtcEntrustOrderEntity; -import com.xcong.excoin.modules.otc.entity.OtcMarketBussinessEntity; -import com.xcong.excoin.modules.otc.entity.OtcOrderAppealEntity; -import com.xcong.excoin.modules.otc.entity.OtcOrderEntity; -import com.xcong.excoin.modules.otc.mapper.OtcEntrustOrderMapper; -import com.xcong.excoin.modules.otc.mapper.OtcMarketBussinessMapper; -import com.xcong.excoin.modules.otc.mapper.OtcOrderAppealMapper; -import com.xcong.excoin.modules.otc.mapper.OtcOrderMapper; +import com.xcong.excoin.modules.otc.entity.*; +import com.xcong.excoin.modules.otc.mapper.*; import com.xcong.excoin.modules.otc.service.OtcService; import com.xcong.excoin.modules.otc.vo.OtcAppealInfoVo; import lombok.RequiredArgsConstructor; @@ -31,6 +26,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -46,6 +42,8 @@ private OtcEntrustOrderMapper otcEntrustOrderMapper; @Resource private OtcOrderMapper otcOrderMapper; + @Resource + private OtcSettingMapper otcSettingMapper; @Resource private MemberWalletCoinMapper memberWalletCoinMapper; @Resource @@ -153,7 +151,8 @@ String reason = otcOrderAppealEntity.getReason(); otcAppealInfoVo.setReason(reason); String content = otcOrderAppealEntity.getContent(); - otcAppealInfoVo.setContent(content); + List arr = Arrays.asList(content.split(",")); + otcAppealInfoVo.setContent(arr); } //获取对应的订单详情 long orderId = otcOrderAppealEntity.getOrderId(); @@ -227,4 +226,135 @@ return new FebsResponse().success(); } + @Override + public OtcMarketBussinessEntity otcHuiKuan(long id) { + return otcMarketBussinessMapper.selectById(id); + } + + @Override + @Transactional + public FebsResponse otcHuiKuan(OtcMarketBussinessEntity otcMarketBussinessEntity) { + Long id = otcMarketBussinessEntity.getId(); + OtcMarketBussinessEntity otcMarketBussiness = otcMarketBussinessMapper.selectById(id); + if(ObjectUtil.isNotEmpty(otcMarketBussiness)){ + return new FebsResponse().fail().message("连接超时,请刷新页面重试"); + } + BigDecimal coinAmount = otcMarketBussinessEntity.getCoinAmount(); + if(coinAmount.compareTo(BigDecimal.ZERO) <= 0){ + return new FebsResponse().fail().message("请输入正确的回款金额"); + } + BigDecimal waitBackMoney = otcMarketBussiness.getWaitBackMoney(); + if(coinAmount.compareTo(waitBackMoney) > 0){ + return new FebsResponse().fail().message("请输入正确的回款金额"); + } + /** + * 增加已回款金额 + * 减少待回款金额 + * 增加汇款记录 + */ + BigDecimal hasBackMoney = otcMarketBussiness.getHasBackMoney(); + BigDecimal add = hasBackMoney.add(coinAmount); + otcMarketBussiness.setHasBackMoney(add); + + BigDecimal subtract = waitBackMoney.subtract(coinAmount); + otcMarketBussiness.setWaitBackMoney(subtract); + otcMarketBussinessMapper.updateById(otcMarketBussiness); + + return new FebsResponse().success(); + } + + @Override + public IPage<OtcSettingEntity> otcSettingList(OtcSettingEntity otcSettingEntity, QueryRequest request) { + Page<OtcSettingEntity> page = new Page<>(request.getPageNum(), request.getPageSize()); + IPage<OtcSettingEntity> otcSettingEntitys = otcSettingMapper.otcSettingList(page, otcSettingEntity); + return otcSettingEntitys; + } + + @Override + public OtcSettingEntity otcSettingUpdate(long id) { + return otcSettingMapper.selectById(id); + } + + @Override + public FebsResponse updateOtcSetting(OtcSettingEntity otcSettingEntity) { + Integer orderNum = otcSettingEntity.getOrderNum(); + if(ObjectUtil.isEmpty(orderNum) || orderNum < 0){ + return new FebsResponse().fail().message("请设置正确的总单数"); + } + BigDecimal completionRate = otcSettingEntity.getCompletionRate(); + if(ObjectUtil.isEmpty(completionRate) || completionRate.compareTo(BigDecimal.ZERO) < 0){ + return new FebsResponse().fail().message("请设置正确的完成率"); + } + BigDecimal totalAmount = otcSettingEntity.getTotalAmount(); + if(ObjectUtil.isEmpty(totalAmount) || totalAmount.compareTo(BigDecimal.ZERO) < 0){ + return new FebsResponse().fail().message("请设置正确的总金额"); + } + + Integer cancellNum = otcSettingEntity.getCancellNum(); + if(ObjectUtil.isEmpty(cancellNum) || cancellNum < 0){ + return new FebsResponse().fail().message("请设置正确的取消次数"); + } + otcSettingMapper.updateById(otcSettingEntity); + return new FebsResponse().success(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int reduceCoin(Long id) { + OtcOrderEntity order = otcOrderMapper.selectById(id); + + MemberWalletCoinEntity saleWallet = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(order.getMemberId(), "USDT"); + MemberWalletCoinEntity buyWallet = memberWalletCoinMapper.findWalletCoinByMemberIdAndWalletCode(order.getOppositeMemberId(), "USDT"); + + memberWalletCoinMapper.updateBlockBalance(order.getCoinAmount(), buyWallet.getId()); + memberWalletCoinMapper.reduceFrozenBalance(order.getCoinAmount(), saleWallet.getId()); + + otcOrderMapper.updateOrderStatusByOrderNo(OtcOrderEntity.STATUS_THREE, order.getOrderNo()); + return 1; + } + + @Override + public OtcEntrustOrderEntity otcEntrustListUpdate(long id) { + return otcEntrustOrderMapper.selectById(id); + } + + @Override + public FebsResponse otcEntrustConfirm(OtcEntrustOrderEntity otcEntrustOrderEntity) { + Long id = otcEntrustOrderEntity.getId(); + OtcEntrustOrderEntity otcEntrustOrder = otcEntrustOrderMapper.selectById(id); + BigDecimal unitPrice = otcEntrustOrderEntity.getUnitPrice(); + if(ObjectUtil.isEmpty(unitPrice) || unitPrice.compareTo(BigDecimal.ZERO) < 0){ + return new FebsResponse().fail().message("请设置正确的单价"); + } + otcEntrustOrder.setUnitPrice(unitPrice); + BigDecimal coinAmount = otcEntrustOrderEntity.getCoinAmount(); + if(ObjectUtil.isEmpty(coinAmount) || coinAmount.compareTo(BigDecimal.ZERO) < 0){ + return new FebsResponse().fail().message("请设置正确的数量"); + } + otcEntrustOrder.setCoinAmount(coinAmount); + BigDecimal totalAmount = coinAmount.multiply(unitPrice); + otcEntrustOrder.setTotalAmount(totalAmount); + + BigDecimal remainCoinAmount = otcEntrustOrderEntity.getRemainCoinAmount(); + if(ObjectUtil.isEmpty(remainCoinAmount) || remainCoinAmount.compareTo(BigDecimal.ZERO) < 0 + || totalAmount.compareTo(remainCoinAmount) < 0){ + return new FebsResponse().fail().message("请设置正确的剩余数量"); + } + otcEntrustOrder.setRemainCoinAmount(remainCoinAmount); + BigDecimal limitMinAmount = otcEntrustOrderEntity.getLimitMinAmount(); + if(ObjectUtil.isEmpty(limitMinAmount) || limitMinAmount.compareTo(BigDecimal.ZERO) < 0){ + return new FebsResponse().fail().message("请设置正确的最小限额"); + } + otcEntrustOrder.setLimitMinAmount(limitMinAmount); + BigDecimal limitMaxAmount = otcEntrustOrderEntity.getLimitMaxAmount(); + if(ObjectUtil.isEmpty(limitMaxAmount) || limitMaxAmount.compareTo(BigDecimal.ZERO) < 0 + || limitMaxAmount.compareTo(limitMinAmount) < 0 || totalAmount.compareTo(limitMaxAmount) < 0){ + return new FebsResponse().fail().message("请设置正确的最大限额"); + } + otcEntrustOrder.setLimitMaxAmount(limitMaxAmount); + otcEntrustOrder.setStatus(otcEntrustOrderEntity.getStatus()); + otcEntrustOrderMapper.updateById(otcEntrustOrder); + + return new FebsResponse().success(); + } } -- Gitblit v1.9.1