admin
2021-05-29 e75b0d79535a6bcd147cca4a54632b70b42afdb9
fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserAccountController.java
@@ -29,6 +29,7 @@
import com.yeshi.fanli.util.*;
import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.wx.MyWXLoginUtil;
import com.yeshi.fanli.vo.user.QQUserInfoVO;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -1080,7 +1081,7 @@
     * @param out
     */
    @RequestMapping(value = "loginNew", method = RequestMethod.POST)
    public void loginNew(AcceptData acceptData, String vcode, String phone, String code, int loginType,
    public void loginNew(AcceptData acceptData, String vcode, String phone, String code, String aliAccessToken, int loginType,
                         HttpServletRequest request, PrintWriter out) {
        // 2.0以下版本不允许登录
@@ -1099,7 +1100,7 @@
            UserInfo userInfo = null;
            // 手机登录
            if (loginType == 1) {
                userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, system);
                userInfo = userAccountService.loginPhone(new ProxyIP(request.getRemoteHost(), request.getRemotePort()), loginType, vcode, phone, aliAccessToken, system);
            }
            // 微信登录
@@ -1162,43 +1163,29 @@
     * @param out
     */
    @RequestMapping(value = "bindPhoneNew")
    public void bindPhoneNew(AcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
    public void bindPhoneNew(AcceptData acceptData, Long uid, String vcode, String phone, String aliAccessToken, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(vcode)) {
            out.print(JsonUtil.loadFalseResult("验证码不能为空"));
        String mobile = null;
        try {
            mobile = userAccountService.getMobile(vcode, phone, aliAccessToken, acceptData.getSystem(), SMSHistory.TYPE_BIND);
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getMsg()));
            return;
        }
        if (StringUtil.isNullOrEmpty(phone)) {
            out.print(JsonUtil.loadFalseResult("电话号码不能为空"));
            return;
        }
        phone = phone.replaceAll(" ", "");
        String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
        if (Constant.IS_OUTNET) {
            if (!vcode.equalsIgnoreCase(oldVCode)) {
                out.print(JsonUtil.loadFalseResult(9001, "验证码错误,重新输入"));
                return;
            }
            redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
        }
        try {
            // 绑定用户
            userAccountService.bindPhoneNew(uid, phone);
            userAccountService.bindPhoneNew(uid, mobile);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断电话号码是否已经封禁
            ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
                    .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, mobile);
            if (ic != null && ic.getEffective() != null && ic.getEffective()) {
                out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
                // 封禁用户
@@ -1243,7 +1230,7 @@
        }
        try {
            userAccountService.bindWeiXin(acceptData, uid, code);
            userAccountService.bindWeiXin(system, uid, code);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            // 判断taoBaoUid是否已经封禁
@@ -1267,4 +1254,42 @@
        }
    }
    /**
     * 更改微信
     *
     * @param acceptData
     * @param uid
     * @param qqUser
     * @param out
     */
    @RequestMapping(value = "bindQQ")
    public void bindQQ(AcceptData acceptData, Long uid, String qqUser, PrintWriter out) {
        BusinessSystem system = getSystem(acceptData);
        if (system == null) {
            out.print(JsonUtil.loadFalseResult("系统不存在"));
            return;
        }
        if (StringUtil.isNullOrEmpty(qqUser)) {
            out.print(JsonUtil.loadFalseResult("请上传qqUser"));
            return;
        }
        String qqUserStr = StringUtil.getFromBase64(qqUser);
        QQUserInfoVO qqUserInfo = new Gson().fromJson(qqUserStr, QQUserInfoVO.class);
        try {
            userAccountService.bindQQ(uid, qqUserInfo);
            UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
            JSONObject data = new JSONObject();
            data.put("userInfo", UserUtil.filterForClientUser(user));
            out.print(JsonUtil.loadTrueResult(data));
        } catch (UserAccountException e) {
            out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
        }
    }
}