zainali5120
2020-10-08 0f25ef5fe5076be73cf7d40b2f0f9c3f7293eadb
修复冻结问题
2 files modified
25 ■■■■ changed files
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/quartz/job/NotionalPoolingJob.java 6 ●●●● patch | view | raw | blame | history
src/main/java/com/xcong/excoin/modules/coin/service/impl/OrderCoinServiceImpl.java
@@ -10,6 +10,8 @@
import com.alibaba.fastjson.JSONObject;
import com.xcong.excoin.modules.blackchain.service.RocService;
import com.xcong.excoin.modules.coin.mapper.OrderCoinsDealMapper;
import com.xcong.excoin.modules.member.dao.MemberDao;
import com.xcong.excoin.modules.member.entity.MemberEntity;
import com.xcong.excoin.modules.platform.entity.PlatformCnyUsdtExchangeEntity;
import com.xcong.excoin.modules.platform.entity.PlatformSymbolsCoinEntity;
@@ -85,6 +87,9 @@
    @Resource
    private CoinTraderFactory factory;
    @Resource
    private MemberDao memberDao;
    @Override
@@ -332,6 +337,11 @@
    public Result submitSalesWalletCoinOrderWithMatch(String symbol, Integer type, Integer tradeType, BigDecimal price, BigDecimal amount, BigDecimal entrustAmount) {
        //获取用户ID
        Long memberId = LoginUserUtils.getAppLoginUser().getId();
        // 需要实名
        MemberEntity memberEntity = memberDao.selectById(memberId);
        if(!MemberEntity.CERTIFY_STATUS_Y.equals(memberEntity.getCertifyStatus())){
            return Result.fail(MessageSourceUtils.getString("member_controller_0001"));
        }
        BigDecimal nowPriceinBigDecimal = price;
        //查询当前价
        //BigDecimal nowPrice = new BigDecimal(redisUtils.getString(CoinTypeConvert.convertToKey(symbol + "/USDT")));
@@ -616,6 +626,8 @@
                if (ObjectUtil.isNotEmpty(walletCoin)) {
                    //手续费 = 开仓价*数量*手续费率
                    //返还金额=开仓价*未成交数量+手续费
                    // 市价的按成交额退款
                    BigDecimal returnBalance = orderCoinsEntity.getEntrustAmount().subtract(orderCoinsEntity.getDealAmount());
                    // 需要退回的手续费
                    BigDecimal returnFee = BigDecimal.ZERO;
@@ -946,6 +958,13 @@
                    update.setOrderStatus(OrderCoinsEntity.ORDERSTATUS_DONE);
                    update.setUpdateTime(new Date());
                    orderCoinsDao.updateById(update);
                    // 限价买入时,如果成交价比设置的价格低,需要退还多余的冻结
                    OrderCoinsEntity coinsEntity = orderCoinsDao.selectById(buyOrderId);
                    BigDecimal subtract = coinsEntity.getEntrustAmount().subtract(coinsEntity.getDealAmount());
                    if(subtract.compareTo(BigDecimal.ZERO)>=0){
                        // 下单扣的比较多
                        memberWalletCoinDao.updateWalletBalance(coinsEntity.getId(),subtract,subtract,subtract.negate());
                    }
                } else {
                    OrderCoinsEntity update = new OrderCoinsEntity();
                    update.setId(buyOrderId);
src/main/java/com/xcong/excoin/quartz/job/NotionalPoolingJob.java
@@ -27,7 +27,7 @@
    /**
     * usdt 归集
     */
   // @Scheduled(cron = "0 5/30 * * * ? ")
   @Scheduled(cron = "0 5/30 * * * ? ")
    public void poolUsdtEth() {
        try {
            log.info("USDT归集开始");
@@ -38,13 +38,13 @@
        }
    }
    //@Scheduled(cron = "0 2/8 * * * ? ")
    @Scheduled(cron = "0 2/8 * * * ? ")
    public void usdtEthPoolCheck() {
        log.info("USDTETH归集结果扫描开始");
        usdtEthService.usdtEthPoolCheck();
    }
    //@Scheduled(cron = "0 2/30 * * * ? ")
    @Scheduled(cron = "0 2/30 * * * ? ")
    public void poolEth() {
        try {
            usdtEthService.ethPool();