xiaoyong931011
2021-05-25 0830a387f0c28c2d448714ad184fd0c17bf27ea9
src/main/java/com/xcong/excoin/modules/otc/service/impl/OtcServiceImpl.java
@@ -227,4 +227,41 @@
        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();
    }
}