| | |
| | | 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; |
| | |
| | | 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)) { |
| | |
| | | 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()); |
| | | } |