| | |
| | | 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()); |
| | | } |
| | |
| | | Integer finishCnt = otcOrderDao.selectTotalOrderCount(mb.getMemberId(), OtcOrder.STATUS_FINISH); |
| | | BigDecimal finishRatio = BigDecimal.valueOf(finishCnt).divide(BigDecimal.valueOf(totalCnt), 4, BigDecimal.ROUND_DOWN); |
| | | // 平均付款时间 |
| | | |
| | | BigDecimal avgPayTime = otcOrderDao.selectMemberAvgPayTime(mb.getMemberId()); |
| | | // 平均放币时间 |
| | | BigDecimal avgCoinTime = otcOrderDao.selectMemberAvgCoinTime(mb.getMemberId()); |
| | | |
| | | mb.setBuyCnt(buyCnt); |
| | | mb.setTotalOrderCnt(totalCnt); |
| | | mb.setFinishRatio(finishRatio); |
| | | mb.setAvgPayTime(avgPayTime.intValue()); |
| | | mb.setAvgCoinTime(avgCoinTime.intValue()); |
| | | |
| | | otcMarketBussinessDao.updateById(mb); |
| | | } |
| | | } |
| | | } |