| | |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @RequestMapping(value = "submitKeyV3") |
| | | public String submitKeyV4(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( "请上传key"); |
| | | } |
| | | try{ |
| | | verifySubmitKey(keyInfo.getKey()); |
| | | }catch (Exception e){ |
| | | return JsonUtil.loadFalseResult("支付宝口令不正确"); |
| | | } |
| | | // 验证提交时间 |
| | | 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("口令提交时间段为:%s-%s",timeStr.split(",")[0],timeStr.split(",")[1])); |
| | | } |
| | | if (user == null) { |
| | | // 先保存KEY |
| | | // 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("无法获取到授权链接"); |
| | | } |
| | | |
| | | redictLink=redictLink.replace("",""); |
| | | // 没有登录,返回登录链接 |
| | | 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("口令校验失败:{}-{}-{}", 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()); |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "wxLogin") |
| | | public void wxLogin(String code, String state, HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException { |
| | | // 根据code获取openid |