From bc56870059cca013649077af0e53891cba8dbfd1 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期日, 04 八月 2024 09:43:41 +0800 Subject: [PATCH] 代理新功能完善 --- src/main/java/com/taoke/autopay/manager/OrderPayFailProcessor.java | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/taoke/autopay/manager/OrderPayFailProcessor.java b/src/main/java/com/taoke/autopay/manager/OrderPayFailProcessor.java index 9c3e4df..bf505de 100644 --- a/src/main/java/com/taoke/autopay/manager/OrderPayFailProcessor.java +++ b/src/main/java/com/taoke/autopay/manager/OrderPayFailProcessor.java @@ -2,6 +2,7 @@ import com.taoke.autopay.entity.KeyOrder; import com.taoke.autopay.entity.SystemConfigKeyEnum; +import com.taoke.autopay.service.ClientInfoService; import com.taoke.autopay.service.KeyOrderService; import com.taoke.autopay.service.SystemConfigService; import com.taoke.autopay.utils.StringUtil; @@ -11,10 +12,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.Queue; +import java.util.*; /** * @author hxh @@ -47,6 +45,9 @@ @Resource private SystemConfigService systemConfigService; + @Resource + private ClientInfoService clientInfoService; + public void clearCacheData() { reProcessCountMap.clear(); orderQueues.clear(); @@ -68,27 +69,29 @@ return; } + // 瓒呮椂30鍒嗛挓涓嶆墽琛� + if(System.currentTimeMillis() - order.getCreateTime().getTime()> 30*60*1000L){ + return; + } + if (!reProcessCountMap.containsKey(queue.getId())) { reProcessCountMap.put(queue.getId(), 0); } reProcessCountMap.put(queue.getId(), reProcessCountMap.get(queue.getId()) + 1); keyOrderService.removeDistributedClient(queue.getId()); - String clientIds = systemConfigService.getValueCache(SystemConfigKeyEnum.RE_EXCUTE_PAY_CLIENTS); - - + List<Long> clientIds = clientInfoService.getRePayClientIds(); // 绉婚櫎宸茬粡鍒嗛厤鐨勮澶囷紝鏀瑰彉鐘舵�佷负鏈垎閰� KeyOrder update = new KeyOrder(); update.setId(queue.getId()); update.setState(KeyOrder.STATE_NOT_PROCESS); update.setStateDesc("閲嶆柊鍒嗛厤"); - if (!StringUtil.isNullOrEmpty(clientIds)) { - String[] cids = clientIds.split(","); - int index = (int) Math.round(Math.random() * cids.length); - if (index + 1 > cids.length) { - index = cids.length - 1; + if (clientIds!=null&&clientIds.size()>0) { + int index = (int) Math.round(Math.random() *clientIds.size()); + if (index + 1 > clientIds.size()) { + index = clientIds.size() - 1; } - update.setDistributeClientUid(Long.parseLong(cids[index])); + update.setDistributeClientUid(clientIds.get(index)); } keyOrderService.update(update); } @@ -108,7 +111,7 @@ return; } //鍔犲叆閲嶈瘯闃熷垪 - orderQueues.add(OrderQueue.builder().id(id).expireTime(System.currentTimeMillis() + 2 * 60 * 1000).build()); + orderQueues.add(OrderQueue.builder().id(id).expireTime(System.currentTimeMillis() + 1 * 60 * 1000).build()); KeyOrder update = new KeyOrder(); update.setId(id); update.setState(KeyOrder.STATE_REJECT_PAY); -- Gitblit v1.8.0