From 595b7935a30e84fba1bc3561d05f9d19d3e32e1f Mon Sep 17 00:00:00 2001
From: Administrator <1101184511@qq.com>
Date: 星期三, 23 四月 2025 00:45:48 +0800
Subject: [PATCH] 后台管理页面完成

---
 src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java |   54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java b/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java
index e6626bc..98631fb 100644
--- a/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java
+++ b/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java
@@ -2,9 +2,13 @@
 
 import com.taoke.autopay.dao.KeyOrderMapper;
 import com.taoke.autopay.dto.DYOrderDto;
+import com.taoke.autopay.entity.ClientInfo;
 import com.taoke.autopay.entity.KeyOrder;
 import com.taoke.autopay.exception.KeyOrderException;
+import com.taoke.autopay.manager.OrderPayFailProcessor;
+import com.taoke.autopay.service.ClientInfoService;
 import com.taoke.autopay.service.KeyOrderService;
+import com.taoke.autopay.utils.Constant;
 import com.taoke.autopay.utils.StringUtil;
 import com.taoke.autopay.utils.order.DYOrderApi;
 import org.springframework.context.annotation.Configuration;
@@ -31,7 +35,7 @@
                     if (order.getDistributeClientUid() != null) {
                         continue;
                     }
-                    Long uid = keyOrderService.getCanDistributeUid();
+                    Long uid = keyOrderService.getCanDistributeUid(Constant.MAX_PAY_ACCOUNT_QUEUE_SIZE);
                     if (uid != null) {
                         KeyOrder orderUpdate = new KeyOrder();
                         orderUpdate.setId(order.getId());
@@ -103,4 +107,52 @@
         }
     }
 
+
+    @Resource
+    private OrderPayFailProcessor orderPayFailProcessor;
+
+    @Scheduled(cron = "0/5 * * * * ? ")
+    private void processPayFail() {
+        for (int i = 0; i < 10; i++) {
+            // 涓�娆℃渶澶氬鐞�10鏉℃暟鎹�
+            orderPayFailProcessor.processFromQueue();
+        }
+    }
+
+    @Scheduled(cron = "0 0 3 * * ? ")
+    private void clearProcessPayFailCache() {
+        orderPayFailProcessor.clearCacheData();
+    }
+
+    @Resource
+    private ClientInfoService clientInfoService;
+
+    // 澶勭悊璁惧涓嬬嚎
+    @Scheduled(cron = "0 0/1 * * * ? ")
+    private void processPayClientOffLine() {
+        KeyOrderMapper.DaoQuery daoQuery = new KeyOrderMapper.DaoQuery();
+        // 鍒嗛厤鏃堕棿鍦ㄦ渶杩�5鍒嗛挓鍒版渶杩�30鍒嗛挓鐨勶紝鐘舵�佷负鏈鐞嗙殑闇�瑕侀噸鏂板垎閰�
+        daoQuery.stateList = Arrays.asList(new Integer[]{KeyOrder.STATE_NOT_PAY, KeyOrder.STATE_NOT_PROCESS});
+        daoQuery.minDistributeTime = new Date(System.currentTimeMillis() - 1000 * 60 * 30L);
+        daoQuery.maxDistributeTime = new Date(System.currentTimeMillis() - 1000 * 60 * 5L);
+        daoQuery.sortList = Arrays.asList(new String[]{"create_time desc"});
+        daoQuery.count = 10;
+        List<KeyOrder> orderList = keyOrderService.list(daoQuery);
+        for (KeyOrder order : orderList) {
+            // 鏌ヨ璁惧娲昏穬鏃堕棿鏄惁宸茬粡鏈�5鍒嗛挓鏈椿璺�
+            if (order.getDistributeClientUid() == null) {
+                continue;
+            }
+
+            ClientInfo clientInfo = clientInfoService.selectByPrimaryKey(order.getDistributeClientUid());
+            if (clientInfo.getActiveTime()==null||System.currentTimeMillis() - clientInfo.getActiveTime().getTime() < 1000 * 60 * 5L) {
+                continue;
+            }
+            // 閲嶆柊鍒嗛厤
+            keyOrderService.removeDistributedClient(order.getId());
+        }
+
+
+    }
+
 }

--
Gitblit v1.8.0