From fa677dec1c55db004a31beefb1e346e18c7858c2 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 20 二月 2025 18:41:29 +0800 Subject: [PATCH] bug修改 --- src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java | 90 +++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 86 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java b/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java index 23003d1..1ade385 100644 --- a/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java +++ b/src/main/java/com/taoke/autopay/task/KeyOrderDistributeTask.java @@ -1,12 +1,20 @@ package com.taoke.autopay.task; +import com.taoke.autopay.dao.KeyOrderMapper; +import com.taoke.autopay.dto.DYOrderDto; import com.taoke.autopay.entity.KeyOrder; +import com.taoke.autopay.exception.KeyOrderException; +import com.taoke.autopay.manager.OrderPayFailProcessor; 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; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.Scheduled; import javax.annotation.Resource; +import java.util.Arrays; import java.util.Date; import java.util.List; @@ -17,15 +25,15 @@ private KeyOrderService keyOrderService; @Scheduled(cron = "0/5 * * * * ? ") - private void distribute(){ + private void distribute() { try { List<KeyOrder> results = keyOrderService.listNotDistributed(1, 20); if (results != null) { for (KeyOrder order : results) { - if (order.getDistributeClientUid() == null) { + 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()); @@ -35,9 +43,83 @@ } } } - }catch(Exception e){ + } catch (Exception e) { } } + /** + * @return void + * @author hxh + * @description 淇宸茬粡澶勭悊鐨勮鍗� + * @date 17:53 2024/6/20 + **/ + @Scheduled(cron = "0/5 * * * * ? ") + private void repaireProcessedOrders() { + // TODO 寰呭畬鎴� + KeyOrderMapper.DaoQuery query = new KeyOrderMapper.DaoQuery(); + // 淇1鍒嗛挓鍒�1灏忔椂鐨勬暟鎹箣鍓嶆墽琛岀殑鏁版嵁 + query.maxUpdateTime = new Date(System.currentTimeMillis() - 1000 * 60 * 1L); + query.minUpdateTime = new Date(System.currentTimeMillis() - 1000 * 60 * 60L); + query.sortList = Arrays.asList(new String[]{"update_time asc"}); + query.stateList = Arrays.asList(new Integer[]{KeyOrder.STATE_NOT_PAY, KeyOrder.STATE_PAY}); + query.orderState = DYOrderDto.ORDER_STATUS_NOT_PAY; + query.start = 0; + query.count = 20; + List<KeyOrder> list = keyOrderService.list(query); + if (list != null && list.size() > 0) { + for (KeyOrder order : list) { + // 濡傛灉娌℃湁鎷垮埌璁㈠崟灏变笉鍋氬鐞� + if (StringUtil.isNullOrEmpty(order.getOrderNo())) { + continue; + } + // 鏌ヨ缁撴灉 + DYOrderDto dto = null; + try { + dto = DYOrderApi.getOrderDetail(order.getOrderNo()); + if (dto.getOrder_status() != DYOrderDto.ORDER_STATUS_NOT_PAY) { + // 璁㈠崟涓嶅浜庡皻鏈粯娆剧姸鎬� + KeyOrder orderUpdate = new KeyOrder(); + orderUpdate.setId(order.getId()); + orderUpdate.setOrderState(dto.getOrder_status()); + orderUpdate.setState(KeyOrder.STATE_PAY); + orderUpdate.setStateDesc(dto.getOrder_status_desc()); + keyOrderService.update(orderUpdate); + } else { + KeyOrder update = new KeyOrder(); + update.setId(order.getId()); + update.setState(KeyOrder.STATE_NOT_PROCESS); + update.setStateDesc("閲嶇疆鏈垎閰�"); + update.setOrderState(dto.getOrder_status()); + keyOrderService.update(update); + } + } catch (KeyOrderException e) { + e.printStackTrace(); + KeyOrder orderUpdate = new KeyOrder(); + orderUpdate.setId(order.getId()); + orderUpdate.setState(KeyOrder.STATE_PAY); + orderUpdate.setStateDesc(e.getMessage()); + keyOrderService.update(orderUpdate); + } + } + } + } + + + @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(); + } + } -- Gitblit v1.8.0