|
|
|
@ -1,6 +1,5 @@ |
|
|
|
|
package com.blockchain.server.otc.service.impl; |
|
|
|
|
|
|
|
|
|
import com.blockchain.common.base.dto.ResultDTO; |
|
|
|
|
import com.blockchain.server.otc.common.constant.AdConstants; |
|
|
|
|
import com.blockchain.server.otc.common.constant.BillConstants; |
|
|
|
|
import com.blockchain.server.otc.common.constant.MarketApplyConstants; |
|
|
|
@ -8,7 +7,6 @@ import com.blockchain.server.otc.common.constant.MarketUserConstants; |
|
|
|
|
import com.blockchain.server.otc.common.enums.OtcEnums; |
|
|
|
|
import com.blockchain.server.otc.common.exception.OtcException; |
|
|
|
|
import com.blockchain.server.otc.dto.ad.ListUserAdDTO; |
|
|
|
|
import com.blockchain.server.otc.entity.Ad; |
|
|
|
|
import com.blockchain.server.otc.entity.MarketApply; |
|
|
|
|
import com.blockchain.server.otc.entity.MarketFreeze; |
|
|
|
|
import com.blockchain.server.otc.entity.MarketUser; |
|
|
|
@ -90,14 +88,14 @@ public class MarketApplyServiceImpl implements MarketApplyService { |
|
|
|
|
//市商保证金代币
|
|
|
|
|
String coinName = configService.selectMarketFreezeCoin(); |
|
|
|
|
//新建市商申请
|
|
|
|
|
//市商申请id
|
|
|
|
|
String applyId = insertAgreeMarketApply(userId, coinName, MarketApplyConstants.MARKET); |
|
|
|
|
//市商保证金数量
|
|
|
|
|
BigDecimal amount = configService.selectMarketFreezeAmount(); |
|
|
|
|
//防止保证金代币和数量为空
|
|
|
|
|
if (coinName != null && amount.compareTo(BigDecimal.ZERO) > 0) { |
|
|
|
|
//新建冻结记录
|
|
|
|
|
marketFreezeService.insertMarketFreeze(userId, amount, coinName); |
|
|
|
|
//市商申请id
|
|
|
|
|
String applyId = insertAgreeMarketApply(userId, coinName, MarketApplyConstants.MARKET,amount.multiply(BigDecimal.valueOf(-1))); |
|
|
|
|
//冻结余额
|
|
|
|
|
walletService.handleBalance(userId, applyId, coinName, UNIT_NAME, BigDecimal.ZERO, amount); |
|
|
|
|
//增加余额变更记录
|
|
|
|
@ -138,7 +136,7 @@ public class MarketApplyServiceImpl implements MarketApplyService { |
|
|
|
|
//解冻的币种
|
|
|
|
|
String coinName = marketFreeze.getCoinName(); |
|
|
|
|
//新建市商申请
|
|
|
|
|
String applyId = insertAgreeMarketApply(userId, coinName, MarketApplyConstants.CANCEL); |
|
|
|
|
String applyId = insertAgreeMarketApply(userId, coinName, MarketApplyConstants.CANCEL, freeAmount); |
|
|
|
|
//解冻余额
|
|
|
|
|
walletService.handleBalance(userId, applyId, coinName, UNIT_NAME, freeAmount, freezeAmount); |
|
|
|
|
//增加余额变更记录
|
|
|
|
@ -217,9 +215,10 @@ public class MarketApplyServiceImpl implements MarketApplyService { |
|
|
|
|
* @param userId |
|
|
|
|
* @param coinName |
|
|
|
|
* @param applyType |
|
|
|
|
* @param amount |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private String insertAgreeMarketApply(String userId, String coinName, String applyType) { |
|
|
|
|
private String insertAgreeMarketApply(String userId, String coinName, String applyType, BigDecimal amount) { |
|
|
|
|
MarketApply marketApply = new MarketApply(); |
|
|
|
|
Date now = new Date(); |
|
|
|
|
String applyId = UUID.randomUUID().toString(); |
|
|
|
@ -230,6 +229,7 @@ public class MarketApplyServiceImpl implements MarketApplyService { |
|
|
|
|
marketApply.setCreateTime(now); |
|
|
|
|
marketApply.setModifyTime(now); |
|
|
|
|
marketApply.setStatus(MarketApplyConstants.AGREE); |
|
|
|
|
marketApply.setAmount(amount); |
|
|
|
|
|
|
|
|
|
marketApplyMapper.insertSelective(marketApply); |
|
|
|
|
return applyId; |
|
|
|
|