From ca1ad791b7b7b04e57db6bd4fb93f0c1066a9f99 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 24 九月 2020 18:31:23 +0800 Subject: [PATCH] 淘口令格式兼容 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java | 104 ++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 77 insertions(+), 27 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 581e3bd..82d4087 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 @@ -9,7 +9,10 @@ import com.yeshi.fanli.entity.SystemEnum; 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 org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -17,6 +20,7 @@ import org.yeshi.utils.JsonUtil; import org.yeshi.utils.entity.FileUploadResult; import org.yeshi.utils.entity.ProxyIP; +import org.yeshi.utils.entity.wx.WeiXinUser; import org.yeshi.utils.tencentcloud.COSManager; import com.google.gson.Gson; @@ -33,7 +37,6 @@ import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoModifyRecord.ModifyTypeEnum; -import com.yeshi.fanli.entity.bus.user.WeiXinUser; import com.yeshi.fanli.exception.user.ForbiddenUserIdentifyCodeException; import com.yeshi.fanli.exception.user.UserAccountException; import com.yeshi.fanli.log.LogHelper; @@ -50,11 +53,11 @@ import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService; import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService; import com.yeshi.fanli.util.factory.msg.MsgAccountDetailFactory; -import com.yeshi.fanli.util.wx.WXLoginUtil; +import com.yeshi.fanli.util.wx.MyWXLoginUtil; import net.sf.json.JSONObject; +import org.yeshi.utils.wx.WXAppLoginUtil; import redis.clients.jedis.Jedis; -import redis.clients.jedis.JedisPool; import redis.clients.jedis.Transaction; @Service @@ -62,9 +65,6 @@ @Resource private RedisManager redisManager; - -// @Resource -// private UserInfoMapper userInfoMapper; @Resource private UserInfoService userInfoService; @@ -96,8 +96,9 @@ @Resource private UserInfoDeleteRecordService userInfoDeleteRecordService; + @Resource - private JedisPool jedisPool; + private ConfigService configService; @Lazy @Resource @@ -119,9 +120,10 @@ LogHelper.lgoinInfo(logInfo.toString()); HttpSession session = request.getSession(); - if (first != null && first == true) + if (first != null && first == true) { session.removeAttribute("LAST_LOGIN_USER"); - // 浼氳瘽涓笂娆$櫥褰曠殑鐢ㄦ埛 + } + // 浼氳瘽涓笂娆$櫥褰曠殑鐢ㄦ埛 if (wxinstall) {// 瀹夎浜嗗井淇$殑鐘舵�� UserInfo lastUser = (UserInfo) session.getAttribute("LAST_LOGIN_USER"); UserInfo userInfo = null; @@ -169,7 +171,7 @@ case 2:// 寰俊 // 閫氳繃Code鎹㈠彇淇℃伅 WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + weiXinUser = MyWXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) throw new UserAccountException(1001, "鏃犳硶鑾峰彇鍒板井淇′釜浜轰俊鎭�"); @@ -386,7 +388,7 @@ case 2:// 寰俊 // 閫氳繃Code鎹㈠彇淇℃伅 WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + weiXinUser = MyWXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) throw new UserAccountException(1001, "鏃犳硶鑾峰彇鍒板井淇′釜浜轰俊鎭�"); @@ -451,6 +453,7 @@ /** * 鏍规嵁绯荤粺涓巙nionid瀵绘壘鐢ㄦ埛 + * * @param system * @param unionId * @return @@ -479,7 +482,8 @@ /** - *鏍规嵁绯荤粺鍜屾窐瀹濈殑Openid瀵绘壘鐢ㄦ埛 + * 鏍规嵁绯荤粺鍜屾窐瀹濈殑Openid瀵绘壘鐢ㄦ埛 + * * @param system * @param openId * @return @@ -508,6 +512,7 @@ /** * 鏍规嵁绯荤粺鍜岀數璇濆彿鐮佸鎵剧敤鎴� + * * @param system * @param phone * @return @@ -571,7 +576,7 @@ user.setRank(0); if (StringUtil.isNullOrEmpty(user.getPortrait())) user.setPortrait(Constant.systemCommonConfig.getDefaultPortrait()); - userInfoService.createUser(user,user.getSystem()); + userInfoService.createUser(user, user.getSystem()); // 鏄电О涓虹┖鏃� 榛樿鏄电О if (StringUtil.isNullOrEmpty(user.getNickName())) { UserInfo updateUserInfo = new UserInfo(user.getId()); @@ -706,7 +711,7 @@ if (user == null) throw new UserAccountException(4, "鐢ㄦ埛涓嶅瓨鍦�"); WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + WeiXinUser weiXinUser = MyWXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) throw new UserAccountException(10, "鑾峰彇寰俊鐢ㄦ埛淇℃伅澶辫触"); @@ -804,12 +809,23 @@ 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 ("17316780233".equalsIgnoreCase(phone) && "2581".equalsIgnoreCase(vcode)) { + if (isDemo) {//娴嬭瘯鍙风爜 ; } else { - if (StringUtil.isNullOrEmpty(vcode)) { throw new UserAccountException(1, "璇疯緭鍏ラ獙璇佺爜"); } @@ -869,7 +885,7 @@ userInfo.setPhone(phone); userInfo.setLoginType(loginType); userInfo.setState(UserInfo.STATE_NORMAL); - userInfo.setSystem( businessSystem.getSystem()); + userInfo.setSystem(businessSystem.getSystem()); // 鍒涘缓鐢ㄦ埛 addUser(userInfo); @@ -893,10 +909,43 @@ throw new UserAccountException(10, "璇风◢鍚庡啀璇�"); } + @Override + public UserInfo loginTB(ProxyIP ipInfo, TaoBaoUser taoBaoUser, BusinessSystem businessSystem) throws UserAccountException { + + if (StringUtil.isNullOrEmpty(taoBaoUser.getUserid())) + throw new UserAccountException(1, "娣樺疂鎺堟潈淇℃伅涓嶅畬鏁�"); + + UserInfo userInfo = userInfoService.getEffectiveUserInfoByOpenId(taoBaoUser.getOpenId(), businessSystem.getSystem()); + if (userInfo != null) { + // 鏇存柊璐︽埛鐧诲綍淇℃伅 + updateLonginInfo(userInfo, 1, ipInfo); + } else { + userInfo = new UserInfo(); + userInfo.setNickName(taoBaoUser.getNick()); + userInfo.setPortrait(taoBaoUser.getAvatarUrl()); + userInfo.setAppId(businessSystem.getAppid()); + userInfo.setTaoBaoUid(taoBaoUser.getUserid()); + userInfo.setOpenid(taoBaoUser.getOpenId()); + userInfo.setLoginType(1); + userInfo.setState(UserInfo.STATE_NORMAL); + userInfo.setSystem(businessSystem.getSystem()); + // 鍒涘缓鐢ㄦ埛 + addUser(userInfo); + try { + // 绗竴娆$櫥褰曟椂鍒涘缓鐢ㄦ埛棰濆淇℃伅 + userInfoExtraService.createUserInfoExtra(userInfo.getId()); + } catch (Exception e) { + e.printStackTrace(); + } + } + return userInfo; + } + @Transactional(rollbackFor = Exception.class) @Override - public UserInfo loginPhoneNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String phone, String appId) + public UserInfo loginPhoneNew(ProxyIP ipInfo, AcceptData acceptData, int loginType, String vcode, String + phone, String appId) throws UserAccountException { // 绌洪娓呯悊 if (phone == null || phone.trim().length() == 0) { @@ -989,7 +1038,7 @@ LogHelper.lgoinInfo(logInfo.toString()); // 閫氳繃Code鎹㈠彇淇℃伅 - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code,businessSystem.getWxAppId(), businessSystem.getWxAppSecret()); + WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(code, businessSystem.getWxAppId(), businessSystem.getWxAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1015,12 +1064,12 @@ if (exec == null || exec.size() == 0) { throw new UserAccountException(10, "璇风◢鍚庡啀璇�"); } else { - UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(),businessSystem.getSystem()); + UserInfo userInfo = userInfoService.getEffectiveUserInfoByWXUnionId(weiXinUser.getUnionid(), businessSystem.getSystem()); // 鐩存帴鐢ㄧ殑寰俊鐧诲綍 if (userInfo != null) { LogHelper.test("寰俊unionID瀛樺湪:" + weiXinUser.getUnionid()); // 鏇存柊璐︽埛鐧诲綍淇℃伅 - updateLonginInfo(userInfo, loginType,ipInfo ); + updateLonginInfo(userInfo, loginType, ipInfo); // 鍒犻櫎閭�璇峰垎浜浘 spreadUserImgService.deleteImgUrl(userInfo.getId()); } else { @@ -1084,7 +1133,7 @@ @Transactional(rollbackFor = Exception.class) @Override public UserInfo loginWeiXinNew(ProxyIP ipInfo, int loginType, String wxCode, - BusinessSystem businessSystem) throws UserAccountException { + BusinessSystem businessSystem) throws UserAccountException { // 鏃ュ織淇℃伅 JSONObject logInfo = new JSONObject(); logInfo.put("appId", businessSystem.getAppid()); @@ -1093,7 +1142,7 @@ LogHelper.lgoinInfo(logInfo.toString()); // 閫氳繃Code鎹㈠彇淇℃伅 - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(wxCode, businessSystem.getWxAppId(),businessSystem.getWxAppSecret()); + WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(wxCode, businessSystem.getWxAppId(), businessSystem.getWxAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1153,7 +1202,7 @@ throw new UserAccountException(2, "鎮ㄥ凡缁忕粦瀹氫簡璇ョ數璇濆彿鐮�"); } - UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone,user.getSystem()); + UserInfo phoneUser = userInfoService.getEffectiveUserInfoByPhone(phone, user.getSystem()); if (phoneUser != null) { throw new UserAccountException(2, "鍙风爜宸茬粡琚崰鐢�"); } @@ -1186,7 +1235,7 @@ @Override public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException { WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); + WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) { throw new UserAccountException(2, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1389,7 +1438,8 @@ @Override - public UserInfo bindWXToLogin(ProxyIP ipInfo, AcceptData acceptData, String code, String appId, String key) throws UserAccountException { + public UserInfo bindWXToLogin(ProxyIP ipInfo, AcceptData acceptData, String code, String appId, String key) throws + UserAccountException { // 鏃ュ織淇℃伅 JSONObject logInfo = new JSONObject(); logInfo.put("appId", appId); @@ -1401,7 +1451,7 @@ // 閫氳繃Code鎹㈠彇淇℃伅 WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); + WeiXinUser weiXinUser = WXAppLoginUtil.getWeiXinUser(code, wxAccount.getAppId(), wxAccount.getAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } -- Gitblit v1.8.0