Administrator
2025-02-12 7f8ea22902fe145fb266df3cf69cbd533d768fbb
src/main/java/com/taoke/autopay/controller/WebApiController.java
@@ -49,7 +49,7 @@
    private SystemConfigService systemConfigService;
    private void addKey(SubmitKeyInfo keyInfo, Long wxUid) throws KeyVerifyException, KeyOrderException, WxOrderCountException {
    private void addKey(SubmitKeyInfo keyInfo, Long wxUid, String ip, IPUtil.IPInfo ipInfo) throws KeyVerifyException, KeyOrderException, WxOrderCountException {
        // 查询没有处理的数量
        long notProcessCount = keyOrderService.countUserNotDoOrder(wxUid, new Date(System.currentTimeMillis() - 1000*60*30));
@@ -97,8 +97,6 @@
                throw new KeyVerifyException(KeyVerifyException.CODE_COMMON, e.getMessage());
            }
        }
        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) {
@@ -122,6 +120,7 @@
        }
    }
    private Map<String, IPUtil.IPInfo> ipInfoMap=new HashMap<>();
    @ResponseBody
    @RequestMapping(value = "submitKeyV4")
    public String submitKeyV4(SubmitKeyInfo keyInfo, HttpSession session, HttpServletRequest request) {
@@ -130,6 +129,25 @@
        WxUserInfo user = (WxUserInfo) session.getAttribute(Constant.SESSION_KEY_USER);
        if (StringUtil.isNullOrEmpty(keyInfo.getKey())) {
            return JsonUtil.loadFalseResult("请上传key");
        }
        String ip = IPUtil.getRemotIP(request);
        keyInfo.setIp(ip);
        if(!ipInfoMap.containsKey(ip)){
            try {
                IPUtil.IPInfo ipInfo =  IPUtil.getLocalIPInfo(ip);
                ipInfoMap.put(ip, ipInfo);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        String citys =  systemConfigService.getValueCache(SystemConfigKeyEnum.FORBIDDEN_SUBMIT_CITYS);
        if(citys!=null&&ipInfoMap.get(ip)!=null){
           List<String> cityList = Arrays.asList(citys.split(","));
           if(cityList.contains(ipInfoMap.get(ip).getCity())){
               LogUtil.loggerDebug.warn("区域屏蔽:{}-{}", ip, new Gson().toJson(ipInfoMap.get(ip)));
               return JsonUtil.loadFalseResult("暂时无法上传口令");
           }
        }
        try {
@@ -165,8 +183,9 @@
            return JsonUtil.loadTrueResult(Constant.RESULT_CODE_NEED_LOGIN, root);
        }
        wxLogger.info("微信有授权:" + session.getId());
        LogUtil.loggerDebug.warn("GEO信息:{}-{}-{}", user.getId(),ip, new Gson().toJson(ipInfoMap.get(ip)));
        try {
            addKey(keyInfo, user.getId());
            addKey(keyInfo, user.getId(),ip, ipInfoMap.get(ip));
            return JsonUtil.loadTrueResult("");
        } catch (KeyOrderException e) {
            e.printStackTrace();
@@ -226,7 +245,15 @@
                wxLogger.info("从session读取到key:{}", alipayKeyInfo);
                if (alipayKeyInfo != null) {
                    addKey(alipayKeyInfo, user.getId());
                    if(!ipInfoMap.containsKey(alipayKeyInfo.getIp())){
                        try {
                            IPUtil.IPInfo ipInfo =  IPUtil.getLocalIPInfo(alipayKeyInfo.getIp());
                            ipInfoMap.put(alipayKeyInfo.getIp(), ipInfo);
                        } catch (Exception e) {
                            throw new RuntimeException(e);
                        }
                    }
                    addKey(alipayKeyInfo, user.getId(),alipayKeyInfo.getIp(),ipInfoMap.get(alipayKeyInfo.getIp()));
                }
                response.sendRedirect(successLink);
                return;