From 27c6695551c7229786ef2cf7dae722886c9edf53 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期五, 09 八月 2024 22:53:44 +0800
Subject: [PATCH] 代理新功能完善

---
 src/test/java/com/taoke/autopay/KeyTest.java |  126 ++++++++++++++++++++++++++++++++++++++---
 1 files changed, 116 insertions(+), 10 deletions(-)

diff --git a/src/test/java/com/taoke/autopay/KeyTest.java b/src/test/java/com/taoke/autopay/KeyTest.java
index 4c75ed2..9df8b32 100644
--- a/src/test/java/com/taoke/autopay/KeyTest.java
+++ b/src/test/java/com/taoke/autopay/KeyTest.java
@@ -1,14 +1,18 @@
 package com.taoke.autopay;
 
+import com.taoke.autopay.dao.KeyOrderMapper;
 import com.taoke.autopay.dto.DYOrderDto;
 import com.taoke.autopay.entity.KeyOrder;
+import com.taoke.autopay.entity.OrderCountTypeEnum;
 import com.taoke.autopay.entity.SystemConfigKeyEnum;
+import com.taoke.autopay.entity.WxUserSettings;
 import com.taoke.autopay.exception.KeyOrderException;
 import com.taoke.autopay.exception.KeyVerifyException;
 import com.taoke.autopay.exception.WxOrderCountException;
-import com.taoke.autopay.service.KeyOrderService;
-import com.taoke.autopay.service.SystemConfigService;
+import com.taoke.autopay.manager.OrderPayFailProcessor;
+import com.taoke.autopay.service.*;
 import com.taoke.autopay.utils.AlipayOrderUtil;
+import com.taoke.autopay.utils.Constant;
 import com.taoke.autopay.utils.TimeUtil;
 import com.taoke.autopay.vo.SubmitKeyInfo;
 import org.junit.jupiter.api.Test;
@@ -16,6 +20,7 @@
 import org.yeshi.utils.UrlUtils;
 
 import javax.annotation.Resource;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 
@@ -35,13 +40,16 @@
     @Resource
     private KeyOrderService keyOrderService;
 
+    @Resource
+    private OrderPayFailProcessor orderPayFailProcessor;
+
     private void addKey(SubmitKeyInfo keyInfo, Long wxUid) throws KeyVerifyException, KeyOrderException, WxOrderCountException {
         // 瑙f瀽閾炬帴
         List<String> urllist = UrlUtils.parseUrlsFromText(keyInfo.getKey());
 
 
         String verifyAlipayKey = systemConfigService.getValueCache(SystemConfigKeyEnum.ALIPAY_KEY_VERIFY);
-        if(verifyAlipayKey!=null&&verifyAlipayKey.trim().equalsIgnoreCase("1")||true) {
+        if (verifyAlipayKey != null && verifyAlipayKey.trim().equalsIgnoreCase("1") || true) {
             try {
                 // 闇�瑕侀獙璇佹敮浠樺疂鍙d护
                 if (urllist.size() < 1) {
@@ -66,19 +74,18 @@
                     throw new Exception("鍙d护鍐呭鑾峰彇澶辫触");
                 }
                 // 楠岃瘉鍐呭
-                DYOrderDto dto = keyOrderService.verifyKey(tradeInfo.getGoodsTitle(), orderStatus, tradeInfo.getItemRealAmount());
-            }catch(KeyVerifyException ee){
-                throw  ee;
-            }
-            catch(Exception e){
+                DYOrderDto dto = keyOrderService.verifyKey(tradeInfo.getGoodsTitle(), orderStatus, tradeInfo.getItemRealAmount(),null, null);
+            } catch (KeyVerifyException ee) {
+                throw ee;
+            } catch (Exception e) {
                 throw new KeyVerifyException(KeyVerifyException.CODE_COMMON, e.getMessage());
             }
         }
     }
 
     @Test
-    public void test1()  {
-        SubmitKeyInfo keyInfo=new SubmitKeyInfo();
+    public void test1() {
+        SubmitKeyInfo keyInfo = new SubmitKeyInfo();
         keyInfo.setKey("銆愭敮fu`瀵炽�戜翰锛屽鍒� Q:/dYsUzQV77s5  p:/S ZH2412 2020/11/27鎵撳紑鏀粯瀹濆氨鍙互甯垜馃彯浠樻鍟︷煉猦ttps://ur.alipay.com/_Ig4toHTlLHbBqiJqb3dpC");
         try {
             addKey(keyInfo, 1L);
@@ -91,4 +98,103 @@
         }
     }
 
+    @Test
+    public void testRePay() throws InterruptedException {
+        for (int i = 0; i < 10; i++) {
+            orderPayFailProcessor.processPayFail("2c9d0dd55cd845819c8e6010fe10def4", "璇诲彇鏀粯瀹濈矘璐存澘瓒呮椂");
+            Thread.sleep(2000);
+            orderPayFailProcessor.processFromQueue();
+        }
+    }
+
+    @Test
+    public void statisticAgentId() {
+        KeyOrderMapper.DaoQuery query=new KeyOrderMapper.DaoQuery();
+        query.hasAgentId=true;
+        query.hasPayTime = true;
+        query.state =2;
+        query.count = 100;
+
+        List<Long> list =   keyOrderService.listAgentId(query);
+        System.out.println(list);
+    }
+
+    @Test
+    public void repaire(){
+        KeyOrderMapper.DaoQuery query=new KeyOrderMapper.DaoQuery();
+        query.state=3;
+        query.minCreateTime=new Date(TimeUtil.convertToTimeTemp("2024-08-02","yyyy-MM-dd"));
+        query.stateDesc="璁㈠崟宸叉敮浠�";
+        query.count = 1000;
+        List<KeyOrder>  list =  keyOrderService.list(query);
+        for(KeyOrder o:list){
+            KeyOrder update=new KeyOrder();
+            update.setId(o.getId());
+            update.setState(KeyOrder.STATE_PAY);
+            update.setPayTime(o.getExcutePayTime());
+            keyOrderService.update(update);
+        }
+
+    }
+
+    @Resource
+    private ClientInfoService clientInfoService;
+
+    @Test
+    public void test2(){
+        List<Long> clientIds = clientInfoService.getRePayClientIds();
+        if (clientIds!=null&&clientIds.size()>0) {
+            Collections.shuffle(clientIds);
+            // 鏌ヨ璁惧鏈墽琛岀殑鏁伴噺
+            for(Long cuid:clientIds) {
+                KeyOrderMapper.DaoQuery daoQuery = new KeyOrderMapper.DaoQuery();
+                daoQuery.distributeClientUid =cuid;
+                daoQuery.state =  KeyOrder.STATE_NOT_PAY;
+                daoQuery.minCreateTime=new Date(System.currentTimeMillis() - 1000*60*30L);
+                long count =  keyOrderService.count(daoQuery);
+                if(count <=1){
+                    // 鍒嗛厤
+                    System.out.println( cuid);
+                }
+            }
+        }
+
+
+    }
+
+    @Resource
+    private WxUserSettingService wxUserSettingService;
+
+    @Resource
+    private WxUserOrderCountService wxUserOrderCountService;
+
+    @Test
+    public void testCount() throws Exception{
+        Long uid = 5413L;
+        int orderType = Constant.ORDER_TYPE_DY;
+        WxUserSettings settings = wxUserSettingService.getUserSettings(uid);
+
+        OrderCountTypeEnum orderCountType = OrderCountTypeEnum.SUBMIT_TOKEN_COUNT;
+        int maxCount = settings.getTotalOrderCountPerDay();
+        switch (orderType) {
+            case Constant.ORDER_TYPE_DY:
+                orderCountType = OrderCountTypeEnum.DY_ORDER_PAY;
+                maxCount = settings.getDyOrderCountPerDay();
+                break;
+            case Constant.ORDER_TYPE_KS:
+                orderCountType = OrderCountTypeEnum.KS_ORDER_PAY;
+                maxCount = settings.getKsOrderCountPerDay();
+                break;
+        }
+
+        try {
+            wxUserOrderCountService.isOrderCountLimit(uid, orderCountType, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyy-MM-dd"), 1, maxCount);
+        } catch (WxOrderCountException e) {
+            e.printStackTrace();
+            throw new KeyVerifyException(KeyVerifyException.CODE_COMMON, "浠婃棩鎻愪氦瓒呰繃" + maxCount + "娆�");
+        }
+
+    }
+
+
 }

--
Gitblit v1.8.0