市商申请调整

pull/1/head
huangxinlu 5 years ago
parent ee8ca05ad3
commit f2b5db2aeb
  1. 12
      blockchain-server/blockchain-server-otc/src/main/java/com/blockchain/server/otc/service/impl/MarketApplyServiceImpl.java

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

Loading…
Cancel
Save