From e75b0d79535a6bcd147cca4a54632b70b42afdb9 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期六, 29 五月 2021 18:10:18 +0800
Subject: [PATCH] 特价完善

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java |  339 ++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 257 insertions(+), 82 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
index 3411c70..9b5ac8e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java
@@ -8,11 +8,13 @@
 import javax.servlet.http.HttpSession;
 
 import com.yeshi.fanli.entity.SystemEnum;
+import com.yeshi.fanli.entity.config.SMSConfig;
 import com.yeshi.fanli.entity.system.BusinessSystem;
 import com.yeshi.fanli.entity.system.ConfigKeyEnum;
 import com.yeshi.fanli.service.inter.config.ConfigService;
 import com.yeshi.fanli.util.*;
 import com.yeshi.fanli.vo.taobao.TaoBaoUser;
+import com.yeshi.fanli.vo.user.QQUserInfoVO;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -123,7 +125,7 @@
         if (first != null && first == true) {
             session.removeAttribute("LAST_LOGIN_USER");
         }
-            // 浼氳瘽涓笂娆$櫥褰曠殑鐢ㄦ埛
+        // 浼氳瘽涓笂娆$櫥褰曠殑鐢ㄦ埛
         if (wxinstall) {// 瀹夎浜嗗井淇$殑鐘舵��
             UserInfo lastUser = (UserInfo) session.getAttribute("LAST_LOGIN_USER");
             UserInfo userInfo = null;
@@ -795,72 +797,80 @@
                 return portrait;
             }
         }
-
         return user.getPortrait();
     }
 
+    @Override
+    public String getMobile(String vcode, String phone, String aliAccessToken, SystemEnum system, int vcodeType) throws UserAccountException {
+        if (!StringUtil.isNullOrEmpty(aliAccessToken)) {
+            String mobile = AliyunOneKeyLoginUtil.getMobile(aliAccessToken, "");
+            if (StringUtil.isNullOrEmpty(mobile)) {
+                throw new UserAccountException(1, "鎵嬫満鍙疯幏鍙栧け璐�");
+            }
+            return mobile;
+        } else {
+            // 绌洪娓呯悊
+            if (phone == null || phone.trim().length() == 0) {
+                throw new UserAccountException(1, "璇疯緭鍏ユ墜鏈哄彿鐮�");
+            }
+            phone = phone.replaceAll(" ", "");
+            boolean isDemo = false;
+            //鏌ヨ涓婄嚎娴嬭瘯鐨勫彿鐮佷笌楠岃瘉鐮�
+            String demoLogin = configService.getValue(ConfigKeyEnum.demoLoginUser, system);
+            if (!StringUtil.isNullOrEmpty(demoLogin)) {
+                String demoPhone = demoLogin.split("#")[0];
+                String demoCode = demoLogin.split("#")[1];
+                if (phone.equalsIgnoreCase(demoPhone) && demoCode.equalsIgnoreCase(vcode)) {
+                    isDemo = true;
+                }
+            }
+            // 鑻规灉搴旂敤鍟嗗簵涓婄嚎娴嬭瘯鍙风爜
+            if (!isDemo) {
+                if (StringUtil.isNullOrEmpty(vcode)) {
+                    throw new UserAccountException(1, "璇疯緭鍏ラ獙璇佺爜");
+                }
+
+                String oldVcode = redisManager.getSMSVCode(phone, vcodeType);
+                LogHelper.test("----------------------鐧诲綍楠岃瘉鐮侊細 " + oldVcode);
+                if (!Constant.IS_TEST)
+                    if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
+                        throw new UserAccountException(1, "楠岃瘉鐮侀敊璇紝閲嶆柊杈撳叆");
+                    } else {// 楠岃瘉鐮佽緭鍏ユ纭�
+                        redisManager.clearSMSVCode(phone, vcodeType);
+                    }
+            }
+            return phone;
+        }
+
+    }
+
+
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public UserInfo loginPhone(ProxyIP ipInfo, int loginType, String vcode, String phone, BusinessSystem businessSystem)
+    public UserInfo loginPhone(ProxyIP ipInfo, int loginType, String vcode, String phone, String aliAccessToken, BusinessSystem businessSystem)
             throws UserAccountException {
-
-        // 绌洪娓呯悊
-        if (phone == null || phone.trim().length() == 0) {
-            throw new UserAccountException(1, "璇疯緭鍏ユ墜鏈哄彿鐮�");
-        }
-        phone = phone.replaceAll(" ", "");
-        boolean isDemo=false;
-        //鏌ヨ涓婄嚎娴嬭瘯鐨勫彿鐮佷笌楠岃瘉鐮�
-        String demoLogin = configService.getValue(ConfigKeyEnum.demoLoginUser, businessSystem.getSystem());
-        if (!StringUtil.isNullOrEmpty(demoLogin)) {
-            String demoPhone = demoLogin.split("#")[0];
-            String demoCode = demoLogin.split("#")[1];
-            if(phone.equalsIgnoreCase(demoPhone)&&demoCode.equalsIgnoreCase(vcode)){
-                isDemo=true;
-            }
-        }
-
-//        "17316780233".equalsIgnoreCase(phone) && "2581".equalsIgnoreCase(vcode);
-
-        // 鑻规灉搴旂敤鍟嗗簵涓婄嚎娴嬭瘯鍙风爜
-        if (isDemo) {//娴嬭瘯鍙风爜
-            ;
-        } else {
-            if (StringUtil.isNullOrEmpty(vcode)) {
-                throw new UserAccountException(1, "璇疯緭鍏ラ獙璇佺爜");
-            }
-
-            String oldVcode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_LOGIN);
-            LogHelper.test("----------------------鐧诲綍楠岃瘉鐮侊細 " + oldVcode);
-            if (!Constant.IS_TEST)
-                if (StringUtil.isNullOrEmpty(oldVcode) || !oldVcode.equalsIgnoreCase(vcode)) {
-                    throw new UserAccountException(1, "楠岃瘉鐮侀敊璇紝閲嶆柊杈撳叆");
-                } else {// 楠岃瘉鐮佽緭鍏ユ纭�
-                    redisManager.clearSMSVCode(phone, SMSHistory.TYPE_LOGIN);
-                }
-        }
-
+        String mobile = getMobile(vcode, phone, aliAccessToken, businessSystem.getSystem(), SMSHistory.TYPE_LOGIN);
         JSONObject logInfo = new JSONObject();
         logInfo.put("appId", businessSystem.getAppid());
-        logInfo.put("phone", phone);
+        logInfo.put("phone", mobile);
         logInfo.put("loginType", loginType);
         LogHelper.lgoinInfo(logInfo.toString());
 
         // 鍒ゆ柇鎵嬫満鍙风爜鏄惁琚皝绂�
         ForbiddenUserIdentifyCode identifyCode1 = forbiddenUserIdentifyCodeService
-                .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
+                .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, mobile);
         if (identifyCode1 != null && identifyCode1.getEffective() != null && identifyCode1.getEffective()) {
             throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
         }
 
         // 娓呯┖闄愬埗
-        redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_LOGIN);
+        redisManager.clearSMSFrequencyLimit(mobile, SMSHistory.TYPE_LOGIN);
         // 娓呯悊娆℃暟
-        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, phone);
+        String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.SMSLoginCount, mobile);
         redisManager.removeCommonString(key);
 
         // 閲囩敤redis浜嬪姟闃叉涓�涓墜鏈哄彿澶氭娉ㄥ唽闂
-        String watchKey = StringUtil.Md5("REGISTER:" + phone);
+        String watchKey = StringUtil.Md5("REGISTER:" + mobile);
         Jedis jedis = redisManager.getJedis();
         try {
             jedis.watch(watchKey);
@@ -874,7 +884,7 @@
             } else {
 
                 // 鏌ヨ鏄惁瀛樺湪璇ョ數璇濆巻鍙茬敤鎴�
-                UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(phone, businessSystem.getSystem());
+                UserInfo userInfo = userInfoService.getEffectiveUserInfoByPhone(mobile, businessSystem.getSystem());
                 if (userInfo != null) {
                     // 鏇存柊璐︽埛鐧诲綍淇℃伅
                     updateLonginInfo(userInfo, loginType, ipInfo);
@@ -882,7 +892,7 @@
                     userInfo = new UserInfo();
                     userInfo.setAppId(businessSystem.getAppid());
                     userInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait());
-                    userInfo.setPhone(phone);
+                    userInfo.setPhone(mobile);
                     userInfo.setLoginType(loginType);
                     userInfo.setState(UserInfo.STATE_NORMAL);
                     userInfo.setSystem(businessSystem.getSystem());
@@ -895,7 +905,7 @@
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
-                    userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindPhone, phone);
+                    userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindPhone, mobile);
                 }
                 return userInfo;
             }
@@ -1158,9 +1168,35 @@
         UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), businessSystem.getSystem());
         if (userInfo == null) {
             String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
-                    StringUtil.Md5("WXLogin:" + weiXinUser.getUnionid()));
+                    "WXLogin#" + StringUtil.Md5(weiXinUser.getUnionid()));
             redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(weiXinUser), 60 * 20);
-            throw new UserAccountException(101, key);
+            throw new UserAccountException(UserAccountException.CODE_NEED_BIND_PHONE, key);
+        }
+        // 鏇存柊璐︽埛鐧诲綍淇℃伅
+        updateLonginInfo(userInfo, loginType, ipInfo);
+        Long uid = userInfo.getId();
+        ThreadUtil.run(new Runnable() {
+            public void run() {
+                // 鍒犻櫎閭�璇峰垎浜浘
+                spreadUserImgService.deleteImgUrl(uid);
+            }
+        });
+        return userInfo;
+    }
+
+    @Override
+    public UserInfo loginQQ(ProxyIP ipInfo, int loginType, QQUserInfoVO qqUserInfo, BusinessSystem businessSystem) throws UserAccountException {
+        // 閫氳繃Code鎹㈠彇淇℃伅
+        if (qqUserInfo == null) {
+            throw new UserAccountException(1, "QQ淇℃伅涓虹┖");
+        }
+
+        UserInfo userInfo = userInfoService.getEffectiveUserInfoByQQOpenId(qqUserInfo.getOpenid(), businessSystem.getSystem());
+        if (userInfo == null) {
+            String key = RedisKeyEnum.getRedisKey(RedisKeyEnum.emptyKey,
+                    "QQLogin#" + StringUtil.Md5(qqUserInfo.getOpenid()));
+            redisManager.cacheCommonString(key, JsonUtil.getSimpleGson().toJson(qqUserInfo), 60 * 20);
+            throw new UserAccountException(UserAccountException.CODE_NEED_BIND_PHONE, key);
         }
         // 鏇存柊璐︽埛鐧诲綍淇℃伅
         updateLonginInfo(userInfo, loginType, ipInfo);
@@ -1233,9 +1269,8 @@
 
     @Transactional(rollbackFor = UserAccountException.class)
     @Override
-    public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException {
-        WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion());
-        WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret());
+    public void bindWeiXin(BusinessSystem system, Long uid, String code) throws UserAccountException {
+        WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(code, system.getWxAppId(), system.getWxAppSecret());
         if (weiXinUser == null) {
             throw new UserAccountException(2, "寰俊甯愬彿鎺堟潈澶辫触");
         }
@@ -1334,6 +1369,73 @@
     }
 
     @Override
+    public void bindQQ(Long uid, QQUserInfoVO qqUser) throws UserAccountException {
+        UserInfo user = userInfoService.selectAvailableByPrimaryKey(uid);
+        if (user == null) {
+            throw new UserAccountException(1, "鐢ㄦ埛涓嶅瓨鍦�");
+        }
+
+        if (qqUser == null || StringUtil.isNullOrEmpty(qqUser.getOpenid())) {
+            throw new UserAccountException(2, "qq鐢ㄦ埛淇℃伅涓虹┖");
+        }
+
+
+        String qqOpenIdExist = user.getQqOpenId();
+
+        if (StringUtil.isNullOrEmpty(qqOpenIdExist)) {
+            UserInfo newUser = userInfoService.getEffectiveUserInfoByQQOpenId(qqUser.getOpenid(), user.getSystem());
+            if (newUser != null) {
+                throw new UserAccountException(4, "璇Q鍙峰凡琚叾浠栧笎鍙风粦瀹�");
+            }
+        } else if (qqUser.getOpenid().equalsIgnoreCase(qqOpenIdExist)) {
+            throw new UserAccountException(3, "QQ甯愬彿涓�鑷存棤闇�鏇存崲");
+        }
+
+        if (StringUtil.isNullOrEmpty(user.getPhone())) {
+            throw new UserAccountException(5, "璇ュ笎鍙锋病鏈夌粦瀹氭墜鏈哄彿鐮侊紝闇�缁戝畾鎵嬫満鍙风爜鎵嶈兘瀹屾垚QQ鏇存崲");
+        }
+
+        UserInfo updateUserInfo = new UserInfo(uid);
+        updateUserInfo.setQqNickName(qqUser.getNickname());
+        updateUserInfo.setQqOpenId(qqUser.getOpenid());
+
+        // 灏嗛粯璁ゆ樀绉版浛鎹㈡垚寰俊鏄电О
+        String defaultNickName = Constant.systemCommonConfig.getDefaultNickName();
+        if (!StringUtil.isNullOrEmpty(defaultNickName) && !StringUtil.isNullOrEmpty(qqUser.getNickname())) {
+            defaultNickName = defaultNickName + uid;
+            if ((defaultNickName.equals(user.getNickName()) || "鏉挎牀蹇渷".equals(user.getNickName()))) {
+                updateUserInfo.setNickName(qqUser.getNickname());
+            }
+        }
+
+        // 灏嗛粯璁ゅご鍍忔浛鎹㈡垚QQ澶村儚
+        String defaultPortrait = Constant.systemCommonConfig.getDefaultPortrait();
+        if (!StringUtil.isNullOrEmpty(qqUser.getFigureurl_2()) && !StringUtil.isNullOrEmpty(defaultPortrait)
+                && defaultPortrait.equals(user.getPortrait())) {
+            String headimgurl = qqUser.getFigureurl_2();
+            updateUserInfo.setPortrait(headimgurl);
+        }
+        userInfoService.updateByPrimaryKeySelective(updateUserInfo);
+
+        // 鍔犲叆缁戝畾璁板綍
+        UserAccountBindingHistory history = new UserAccountBindingHistory();
+        history.setContent(qqUser.getOpenid());
+        history.setType(UserAccountBindingHistory.TYPE_QQ);
+        history.setUid(uid);
+
+        // 涔嬪墠宸茬粡缁戝畾鐢佃瘽鍙风爜
+        if (!StringUtil.isNullOrEmpty(user.getQqOpenId()))
+            history.setFirst(false);
+        else
+            history.setFirst(true);
+        userAccountBindingHistoryService.addUserAccountBindingHistory(history);
+
+        userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_QQ);
+
+        userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindQQ, user.getQqOpenId());
+    }
+
+    @Override
     public UserInfo bindPhoneToLogin(ProxyIP ipinfo, AcceptData acceptData, String phone, String key)
             throws UserAccountException {
 
@@ -1343,32 +1445,77 @@
         if (identifyCode1 != null && identifyCode1.getEffective() != null && identifyCode1.getEffective())
             throw new UserAccountException(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC);
 
+        int loginType = 0;
+        String loginName = "";
+        if (key.contains("QQLogin#")) {
+            //qq鐧诲綍
+            loginType = 4;
+            loginName = "QQ";
+        } else {
+            //寰俊鐧诲綍
+            loginType = 2;
+            loginName = "寰俊";
+        }
+
+
         String value = redisManager.getCommonString(key);
         if (StringUtil.isNullOrEmpty(value))
-            throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥锛岃浣跨敤寰俊閲嶆柊鐧诲綍");
-
-        WeiXinUser weiXinUser = JsonUtil.getSimpleGson().fromJson(value, WeiXinUser.class);
-        if (weiXinUser == null)
-            throw new UserAccountException(1, "寰俊鎺堟潈澶辨晥锛岃浣跨敤寰俊閲嶆柊鐧诲綍");
+            throw new UserAccountException(1, String.format("%s鎺堟潈澶辨晥锛岃浣跨敤%s閲嶆柊鐧诲綍", loginName, loginName));
 
         SystemEnum system = SystemInfoUtil.getSystem(acceptData);
+        String thirdPortrait;
+        String thirdCode;
+        String thirdNickName;
+        QQUserInfoVO qqUser = null;
+        WeiXinUser weiXinUser = null;
+        if (loginType == 4) {
+            qqUser = JsonUtil.getSimpleGson().fromJson(value, QQUserInfoVO.class);
 
-        UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), system);
-        // 鐩存帴鐢ㄧ殑寰俊鐧诲綍
-        if (userInfo != null)
-            throw new UserAccountException(10, "璇ュ井淇″彿宸茶鍗犵敤");
+            if (qqUser == null)
+                throw new UserAccountException(1, "QQ鎺堟潈澶辨晥锛岃浣跨敤QQ閲嶆柊鎺堟潈鐧诲綍");
+
+            thirdPortrait = qqUser.getFigureurl_2();
+            thirdCode = qqUser.getOpenid();
+            thirdNickName = qqUser.getNickname();
+
+            UserInfo userInfo = userInfoService.getEffectiveUserInfoByQQOpenId(qqUser.getOpenid(), system);
+            // 鐩存帴鐢ㄧ殑QQ鐧诲綍
+            if (userInfo != null)
+                throw new UserAccountException(10, "璇Q鍙峰凡琚崰鐢�");
+
+        } else {
+            weiXinUser = JsonUtil.getSimpleGson().fromJson(value, WeiXinUser.class);
+            if (weiXinUser == null)
+                throw new UserAccountException(1, "涓夋柟鎺堟潈澶辨晥锛岃浣跨敤涓夋柟閲嶆柊鎺堟潈鐧诲綍");
+
+            thirdPortrait = weiXinUser.getHeadimgurl();
+            thirdCode = weiXinUser.getUnionid();
+            thirdNickName = weiXinUser.getNickname();
+
+            UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), system);
+            // 鐩存帴鐢ㄧ殑寰俊鐧诲綍
+            if (userInfo != null)
+                throw new UserAccountException(10, "璇ュ井淇″彿宸茶鍗犵敤");
+        }
 
         String portrait = null;
-        if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl())) {
-            InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
+        if (!StringUtil.isNullOrEmpty(thirdPortrait)) {
+            InputStream asInputStream = HttpUtil.getAsInputStream(thirdPortrait);
             if (asInputStream != null) {
-                FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
-                        String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
-                                System.currentTimeMillis() + ""));
+                String path = "";
+                if (loginType == 4) {
+                    path = String.format(FilePathEnum.userQQPortrait.getPath() + "%s_%s.jpg", thirdCode,
+                            System.currentTimeMillis() + "");
+                } else {
+                    path = String.format(FilePathEnum.userWXPortrait.getPath() + "%s_%s.jpg", thirdCode,
+                            System.currentTimeMillis() + "");
+                }
+
+                FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, path);
                 if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
                     portrait = result.getUrl();
             } else {
-                portrait = weiXinUser.getHeadimgurl();
+                portrait = thirdPortrait;
             }
         }
 
@@ -1377,17 +1524,32 @@
 
         // 鏄惁闇�瑕佸垱寤烘柊璐︽埛
         UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone, system);
+        UserInfo userInfo = null;
         if (phoneUser != null) {
             // 缁戝畾寰俊
-            if (StringUtil.isNullOrEmpty(phoneUser.getWxUnionId())) {
-                try {
-                    bindWeiXin(phoneUser.getId(), weiXinUser);
-                } catch (Exception e) {
-                    throw new UserAccountException(1, "寰俊缁戝畾澶辫触");
+            if (weiXinUser != null) {
+                if (StringUtil.isNullOrEmpty(phoneUser.getWxUnionId())) {
+                    try {
+                        bindWeiXin(phoneUser.getId(), weiXinUser);
+                    } catch (Exception e) {
+                        throw new UserAccountException(1, "寰俊缁戝畾澶辫触");
+                    }
+                } else {
+                    throw new UserAccountException(1, "璇ュ井淇″凡琚粦瀹�");
                 }
-            } else {
-                throw new UserAccountException(1, "璇ュ井淇″凡琚粦瀹�");
             }
+            if (qqUser != null) {
+                if (StringUtil.isNullOrEmpty(phoneUser.getQqOpenId())) {
+                    try {
+                        bindQQ(phoneUser.getId(), qqUser);
+                    } catch (Exception e) {
+                        throw new UserAccountException(1, "QQ缁戝畾澶辫触");
+                    }
+                } else {
+                    throw new UserAccountException(1, "璇Q宸茶缁戝畾");
+                }
+            }
+
             userInfo = userInfoService.selectAvailableByPrimaryKey(phoneUser.getId());
         } else {
             // 鍒涘缓鏂拌处鎴�
@@ -1395,13 +1557,21 @@
             userInfo.setPhone(phone);
             userInfo.setPortrait(portrait);
             userInfo.setAppId(null);
-            userInfo.setNickName(weiXinUser.getNickname());
-            userInfo.setWxName(weiXinUser.getNickname());
-            userInfo.setWxOpenId(weiXinUser.getOpenid());
-            userInfo.setWxUnionId(weiXinUser.getUnionid());
-            userInfo.setWxPic(weiXinUser.getHeadimgurl());
+            if (weiXinUser != null) {
+                userInfo.setNickName(weiXinUser.getNickname());
+                userInfo.setWxName(weiXinUser.getNickname());
+                userInfo.setWxOpenId(weiXinUser.getOpenid());
+                userInfo.setWxUnionId(weiXinUser.getUnionid());
+                userInfo.setWxPic(weiXinUser.getHeadimgurl());
+                userInfo.setLoginType(2);
+            }
+
+            if (qqUser != null) {
+                userInfo.setQqOpenId(qqUser.getOpenid());
+                userInfo.setQqNickName(qqUser.getNickname());
+                userInfo.setLoginType(4);
+            }
             userInfo.setLastLoginTime(System.currentTimeMillis());
-            userInfo.setLoginType(2);
             userInfo.setLastLoginIp(ipinfo.getIp());
             userInfo.setState(UserInfo.STATE_NORMAL);
             userInfo.setSystem(system);
@@ -1409,6 +1579,8 @@
         }
 
         Long uid = userInfo.getId();
+        final WeiXinUser tempWeiXinUser = weiXinUser;
+        final QQUserInfoVO tempQQUser = qqUser;
         ThreadUtil.run(new Runnable() {
             public void run() {
                 try {
@@ -1427,7 +1599,10 @@
                 userAccountBindingHistoryService.addUserAccountBindingHistory(history);
 
                 userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, phone);
-                userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid());
+                if (tempWeiXinUser != null)
+                    userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, tempWeiXinUser.getUnionid());
+                if (tempQQUser != null)
+                    userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindQQ, tempQQUser.getOpenid());
             }
         });
         // 鍒犻櫎缂撳瓨

--
Gitblit v1.8.0