Administrator
2018-11-21 d5b2327e25bf77aff724c00aa0b3032a8d7d3d3a
fanli/src/main/java/com/yeshi/fanli/controller/client/UserAccountController.java
@@ -723,6 +723,99 @@
         redisManager.removeCommonString(key);
      }
   }
   @RequestMapping(value = "bindalipaywithverifynew")
   public void bindAlipayWithVerifyNew(AcceptData acceptData, Long uid, String name, String account, PrintWriter out) {
      System system = systemService.getSystemCache(acceptData.getPlatform(), acceptData.getPackages());
      if (system == null) {
         out.print(JsonUtil.loadFalseResult("系统不存在"));
         return;
      }
      if (uid == null || uid == 0) {
         out.print(JsonUtil.loadFalseResult(1, "请上传用户ID"));
         return;
      }
      if (StringUtil.isNullOrEmpty(name)) {
         out.print(JsonUtil.loadFalseResult(1, "请上传支付宝实名名称"));
         return;
      }
      if (StringUtil.isNullOrEmpty(account)) {
         out.print(JsonUtil.loadFalseResult(1, "请上传支付宝账号"));
         return;
      }
      UserInfo user = userInfoService.getUserById(uid);
      boolean bind = redisManager.isBindAlipayAccountSMSStateValid(user.getPhone());
      if (!bind) {
         out.print(JsonUtil.loadFalseResult(90002, "手机验证超时"));
         return;
      }
      String key = "bindalipay-" + uid;
      if (!StringUtil.isNullOrEmpty(redisManager.getCommonString(key))) {
         out.print(JsonUtil.loadFalseResult(1001, "服务器繁忙,请稍后重试"));
         return;
      }
      redisManager.cacheCommonString(key, "1", 120);
      // 可以展示给用户看的错误码
      String[] ALIPAY_CODES = new String[] { "SYSTEM_ERROR", "PERMIT_CHECK_PERM_LIMITED", "PERM_AML_NOT_REALNAME_REV",
            "PERM_AML_NOT_REALNAME_REV", "PAYEE_USER_INFO_ERROR", "PAYEE_ACC_OCUPIED",
            "PERMIT_CHECK_PERM_IDENTITY_THEFT", "PERMIT_NON_BANK_LIMIT_PAYEE", "EXCEED_LIMIT_UNRN_DM_AMOUNT" };
      try {
         BindingAccount bindingAccount = bindingAccountService.changeAlipayBindingWithVerify(uid, name, account);
         out.print(JsonUtil.loadTrue(0, JsonUtil.getGson().toJson(bindingAccount), "系统已成功转账0.1元到提现账号中,提现账号验证通过,恭喜你!可以提现了。"));
      } catch (AlipayTransferException e1) {
         if (e1.getSubCode().equalsIgnoreCase("PAYEE_NOT_EXIST")) {
            String msg = "系统未能成功转账0.1元,提现账号信息有误,请核对后重新填写。";
            out.print(JsonUtil.loadFalseResult(1, msg));
         } else {
            for (String st : ALIPAY_CODES) {
               if (st.equalsIgnoreCase(e1.getSubCode())) {
                  out.print(JsonUtil.loadFalseResult(2, e1.getMsg()));
                  return;
               }
            }
            out.print(JsonUtil.loadFalseResult(3, "支付宝接口出错,验证失败,请联系客服。"));
            return;
         }
      } catch (AlipayApiException e2) {
         out.print(JsonUtil.loadFalseResult(4, e2.getErrMsg()));
         return;
      } catch (AlipayAccountException e3) {
         // 账户无余额
         if (e3.getCode() == AlipayAccountException.CODE_NO_MONEY) {
            out.print(JsonUtil.loadFalseResult(5, "你的账户目前没有余额,无需绑定提现账号。"));
            return;
            // 提现次数限制
         } else if (e3.getCode() == AlipayAccountException.CODE_TIMES_LIMIT) {
            out.print(JsonUtil.loadFalseResult(6, "每月仅可修改1次提现账号,请下月再试吧。"));
            return;
         } else {
            out.print(JsonUtil.loadFalseResult(7, e3.getMsg()));
            return;
         }
      } catch (Exception e) {
         try {
            LogHelper.errorDetailInfo(e);
         } catch (Exception e1) {
            e1.printStackTrace();
         }
         out.print(JsonUtil.loadFalseResult(8, "服务器内部错误,验证失败,请联系客服。"));
      } finally {
         redisManager.removeCommonString(key);
      }
   }
   /**
    * 获取用户资金详情