Helius
2021-05-21 d30d959c8f249c20b39e66dd0c48341a77751d21
src/main/java/com/xcong/excoin/quartz/job/OtcOrderJob.java
@@ -4,6 +4,8 @@
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
import com.xcong.excoin.modules.otc.dao.OtcEntrustOrderDao;
import com.xcong.excoin.modules.otc.dao.OtcMarketBussinessDao;
import com.xcong.excoin.modules.otc.dao.OtcOrderDao;
@@ -32,9 +34,11 @@
    private OtcEntrustOrderDao otcEntrustOrderDao;
    @Autowired
    private OtcMarketBussinessDao otcMarketBussinessDao;
    @Autowired
    private MemberWalletCoinDao memberWalletCoinDao;
    @Scheduled(cron = "0/1 * * * * ? ")
//    @Scheduled(cron = "0/1 * * * * ? ")
    public void autoCancelOrder() {
        List<OtcOrder> otcOrders = otcOrderDao.selectOrderListWithStatusAndType(OtcEntrustOrder.ORDER_TYPE_B, OtcOrder.STATUS_SUBMIT);
        if (CollUtil.isNotEmpty(otcOrders)) {
@@ -42,6 +46,12 @@
                long between = DateUtil.between(new Date(), DateUtil.offsetMinute(otcOrder.getCreateTime(), 30), DateUnit.SECOND, false);
                if (between <= 0) {
                    OtcOrder saleOrder = otcOrderDao.selectOrderByOrderNoAndType(otcOrder.getOrderNo(), OtcEntrustOrder.ORDER_TYPE_S);
                    if (!saleOrder.getMemberId().equals(saleOrder.getEntrustMemberId())) {
                        MemberWalletCoinEntity wallet = memberWalletCoinDao.selectWalletCoinBymIdAndCode(saleOrder.getMemberId(), "USDT");
                        memberWalletCoinDao.subFrozenBalance(saleOrder.getMemberId(), wallet.getId(), saleOrder.getCoinAmount());
                    }
                    otcEntrustOrderDao.updateRemainAmount(otcOrder.getEntrustOrderId(), otcOrder.getCoinAmount());
                    otcOrderDao.updateOrderStatusByOrderNo(OtcOrder.STATUS_CANCEL, null, otcOrder.getOrderNo());
                }