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

---
 src/main/java/com/taoke/autopay/controller/WebApiController.java |  162 ++---------------------------------------------------
 1 files changed, 8 insertions(+), 154 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/controller/WebApiController.java b/src/main/java/com/taoke/autopay/controller/WebApiController.java
index 4f1a0ee..a5077ec 100644
--- a/src/main/java/com/taoke/autopay/controller/WebApiController.java
+++ b/src/main/java/com/taoke/autopay/controller/WebApiController.java
@@ -48,37 +48,6 @@
     @Resource
     private SystemConfigService systemConfigService;
 
-    @ResponseBody
-    @RequestMapping(value = "submitKey")
-    public String submitKey(String key) {
-        if (1 > 0) {
-            return JsonUtil.loadFalseResult(0, "鎺ュ彛宸插叧闂�");
-        }
-        if (StringUtil.isNullOrEmpty(key)) {
-            return JsonUtil.loadFalseResult(0, "璇蜂笂浼爇ey");
-        }
-        List<String> urllist = UrlUtils.parseUrlsFromText(key);
-        if (urllist.isEmpty() || !urllist.get(0).contains("ur.alipay.com")) {
-            return JsonUtil.loadFalseResult("鏀粯瀹濆彛浠や笉姝g‘");
-        }
-        try {
-            KeyOrder order = keyOrderService.addKeyOrder(new SubmitKeyInfo(key), null, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd"));
-            Long uid = keyOrderService.getCanDistributeUid();
-            if (uid != null) {
-                KeyOrder orderUpdate = new KeyOrder();
-                orderUpdate.setId(order.getId());
-                orderUpdate.setDistributeClientUid(uid);
-                orderUpdate.setDistributeTime(new Date());
-                keyOrderService.update(orderUpdate);
-            }
-            return JsonUtil.loadTrueResult("");
-        } catch (KeyOrderException e) {
-            e.printStackTrace();
-            return JsonUtil.loadFalseResult(e.getMessage());
-        } catch (WxOrderCountException e) {
-            return JsonUtil.loadFalseResult("浠婃棩瓒呰繃鏈�澶ф彁浜ゆ鏁�");
-        }
-    }
 
     private void addKey(SubmitKeyInfo keyInfo, Long wxUid) throws KeyVerifyException, KeyOrderException, WxOrderCountException {
         // 瑙f瀽閾炬帴
@@ -86,6 +55,8 @@
 
 
         String verifyAlipayKey = systemConfigService.getValueCache(SystemConfigKeyEnum.ALIPAY_KEY_VERIFY);
+        DYOrderDto orderDto =null;
+        int orderType = Constant.ORDER_TYPE_UNKNOWN;
         if (verifyAlipayKey != null && verifyAlipayKey.trim().equalsIgnoreCase("1")) {
             try {
                 // 闇�瑕侀獙璇佹敮浠樺疂鍙d护
@@ -108,8 +79,9 @@
                 if (tradeInfo == null) {
                     throw new Exception("鍙d护鍐呭鑾峰彇澶辫触");
                 }
+                orderType = AlipayOrderUtil.getOrderType(tradeInfo.getGoodsTitle());
                 // 楠岃瘉鍐呭
-                DYOrderDto dto = keyOrderService.verifyKey(tradeInfo.getGoodsTitle(), orderStatus, tradeInfo.getItemRealAmount(), wxUid);
+                orderDto = keyOrderService.verifyKey(tradeInfo.getGoodsTitle(), orderStatus, tradeInfo.getItemRealAmount(), wxUid, null);
             } catch (KeyVerifyException ee) {
                 try {
                     verifyLogger.warn("鏍¢獙涓嶉�氳繃锛氥�恵}銆�-{}", keyInfo.getKey(), ee.getMessage());
@@ -122,8 +94,8 @@
         }
 
 
-        KeyOrder order = keyOrderService.addKeyOrder(keyInfo, wxUid, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd"));
-        Long uid = keyOrderService.getCanDistributeUid();
+        KeyOrder order = keyOrderService.addKeyOrder(keyInfo, wxUid, TimeUtil.getGernalTime(System.currentTimeMillis(), Constant.DB_DAY_FORMAT),orderType, orderDto);
+        Long uid = keyOrderService.getCanDistributeUid(Constant.MAX_PAY_ACCOUNT_QUEUE_SIZE);
         if (uid != null) {
             KeyOrder orderUpdate = new KeyOrder();
             orderUpdate.setId(order.getId());
@@ -142,126 +114,6 @@
         }
         if (!key.contains("鏀粯瀹�")) {
             throw new Exception("娌″寘鍚敮浠樺疂姹夊瓧");
-        }
-    }
-
-    @ResponseBody
-    @RequestMapping(value = "submitKeyV2")
-    public String submitKeyV2(SubmitKeyInfo keyInfo, HttpSession session) {
-        WxUserInfo user = (WxUserInfo) session.getAttribute(Constant.SESSION_KEY_USER);
-        if (StringUtil.isNullOrEmpty(keyInfo.getKey())) {
-            return JsonUtil.loadFalseResult("璇蜂笂浼爇ey");
-        }
-        try {
-            verifySubmitKey(keyInfo.getKey());
-        } catch (Exception e) {
-            return JsonUtil.loadFalseResult("鏀粯瀹濆彛浠や笉姝g‘");
-        }
-
-        if (user == null) {
-            // 鍏堜繚瀛楰EY
-//            SESSION_KEY_TEMP_ALIPAY_KEY
-            session.setAttribute(Constant.SESSION_KEY_TEMP_ALIPAY_KEY, keyInfo);
-            wxLogger.info("寰俊娌℃湁鎺堟潈:" + session.getId());
-            String redictLink = systemConfigService.getValueCache(SystemConfigKeyEnum.WX_REDIRECT_LINK);
-            if (StringUtil.isNullOrEmpty(redictLink)) {
-                return JsonUtil.loadFalseResult("鏃犳硶鑾峰彇鍒版巿鏉冮摼鎺�");
-            }
-            // 娌℃湁鐧诲綍锛岃繑鍥炵櫥褰曢摼鎺�
-            JSONObject root = new JSONObject();
-            root.put("link", redictLink);
-            return JsonUtil.loadTrueResult(Constant.RESULT_CODE_NEED_LOGIN, root);
-        }
-        wxLogger.info("寰俊鏈夋巿鏉�:" + session.getId());
-
-        try {
-            addKey(keyInfo, user.getId());
-            return JsonUtil.loadTrueResult("");
-        } catch (KeyOrderException e) {
-            e.printStackTrace();
-            return JsonUtil.loadFalseResult(e.getMessage());
-        } catch (WxOrderCountException e) {
-            return JsonUtil.loadFalseResult(e.getMessage());
-        } catch (KeyVerifyException e) {
-            switch (e.getCode()) {
-                case KeyVerifyException.CODE_KEY_MONEY_NOT_MATCH:
-                    return JsonUtil.loadFalseResult("璇ョ瑪璁㈠崟鏈夎锛屼笉浜堟彁浜�");
-                case KeyVerifyException.CODE_ORDER_MONEY_NOT_MATCH:
-                    return JsonUtil.loadFalseResult("鎻愪氦閲戦涓嶅尮閰�");
-            }
-            logger.debug("鍙d护楠岃瘉缁撴灉寮傚父锛歿}-{}", keyInfo.getKey(), e.getMessage());
-            return JsonUtil.loadFalseResult(e.getMessage());
-        }
-    }
-
-    /**
-     * @return java.lang.String
-     * @author hxh
-     * @description 甯﹀彛浠や笌閲戦鐨勫彛浠ゆ彁浜ゆ帴鍙�
-     * @date 0:12 2024/7/9
-     * @param: keyInfo
-     * @param: session
-     **/
-    @ResponseBody
-    @RequestMapping(value = "submitKeyV3")
-    public String submitKeyV3(SubmitKeyInfo keyInfo, HttpSession session, HttpServletRequest request) {
-        String referer = request.getHeader("Referer");
-        keyInfo.setReferer(referer);
-        WxUserInfo user = (WxUserInfo) session.getAttribute(Constant.SESSION_KEY_USER);
-        if (StringUtil.isNullOrEmpty(keyInfo.getKey())) {
-            return JsonUtil.loadFalseResult("璇蜂笂浼爇ey");
-        }
-//        if (StringUtil.isNullOrEmpty(keyInfo.getMoney())) {
-//            return JsonUtil.loadFalseResult("璇蜂笂浼爉oney");
-//        }
-        try {
-            verifySubmitKey(keyInfo.getKey());
-        } catch (Exception e) {
-            return JsonUtil.loadFalseResult("鏀粯瀹濆彛浠や笉姝g‘");
-        }
-        // 楠岃瘉鎻愪氦鏃堕棿
-        String timeStr = systemConfigService.getValueCache(SystemConfigKeyEnum.KEY_SUBMIT_TIME_RANGE);
-        if (StringUtil.isNullOrEmpty(timeStr)) {
-            return JsonUtil.loadFalseResult("灏氭湭閰嶇疆鐢熸晥鏃堕棿");
-        }
-        String startTime = timeStr.split(",")[0].trim().replace(":", "");
-        String endTime = timeStr.split(",")[1].trim().replace(":", "");
-        String now = TimeUtil.getGernalTime(System.currentTimeMillis(), "HHmmss");
-        if (Integer.parseInt(now) < Integer.parseInt(startTime) || Integer.parseInt(now) > Integer.parseInt(endTime)) {
-            return JsonUtil.loadFalseResult(String.format("鍙d护鎻愪氦鏃堕棿娈典负锛�%s-%s", timeStr.split(",")[0], timeStr.split(",")[1]));
-        }
-        if (user == null) {
-            // 鍏堜繚瀛楰EY
-//            SESSION_KEY_TEMP_ALIPAY_KEY
-            session.setAttribute(Constant.SESSION_KEY_TEMP_ALIPAY_KEY, keyInfo);
-            wxLogger.info("寰俊娌℃湁鎺堟潈:" + session.getId());
-            String redictLink = systemConfigService.getValueCache(SystemConfigKeyEnum.WX_REDIRECT_LINK);
-            if (StringUtil.isNullOrEmpty(redictLink)) {
-                return JsonUtil.loadFalseResult("鏃犳硶鑾峰彇鍒版巿鏉冮摼鎺�");
-            }
-            // 娌℃湁鐧诲綍锛岃繑鍥炵櫥褰曢摼鎺�
-            JSONObject root = new JSONObject();
-            root.put("link", redictLink);
-            return JsonUtil.loadTrueResult(Constant.RESULT_CODE_NEED_LOGIN, root);
-        }
-        wxLogger.info("寰俊鏈夋巿鏉�:" + session.getId());
-        try {
-            addKey(keyInfo, user.getId());
-            return JsonUtil.loadTrueResult("");
-        } catch (KeyOrderException e) {
-            e.printStackTrace();
-            return JsonUtil.loadFalseResult(e.getMessage());
-        } catch (WxOrderCountException e) {
-            return JsonUtil.loadFalseResult(e.getMessage());
-        } catch (KeyVerifyException e) {
-            logger.debug("鍙d护鏍¢獙澶辫触锛歿}-{}-{}", keyInfo.getKey(), e.getCode(), e.getMessage());
-            switch (e.getCode()) {
-                case KeyVerifyException.CODE_KEY_MONEY_NOT_MATCH:
-                    return JsonUtil.loadFalseResult("璇ョ瑪璁㈠崟鏈夎锛屼笉浜堟彁浜�");
-                case KeyVerifyException.CODE_ORDER_MONEY_NOT_MATCH:
-                    return JsonUtil.loadFalseResult("鎻愪氦閲戦涓嶅尮閰�");
-            }
-            return JsonUtil.loadFalseResult(e.getMessage());
         }
     }
 
@@ -323,6 +175,8 @@
                     return JsonUtil.loadFalseResult("璇ョ瑪璁㈠崟鏈夎锛屼笉浜堟彁浜�");
                 case KeyVerifyException.CODE_ORDER_MONEY_NOT_MATCH:
                     return JsonUtil.loadFalseResult("鎻愪氦閲戦涓嶅尮閰�");
+                case KeyVerifyException.CODE_ORDER_NO_REPEAT:
+                    return JsonUtil.loadFalseResult("閲嶅鎻愪氦璁㈠崟");
             }
             return JsonUtil.loadFalseResult(e.getMessage());
         }

--
Gitblit v1.8.0