From c6b07c598a9585a68547ffc2a9b540ca74a3920b Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 12 九月 2019 18:36:35 +0800 Subject: [PATCH] 项目名称bug修改,京东商品推荐修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserAccountServiceImpl.java | 94 +++++++++++++++++++++++++--------------------- 1 files changed, 51 insertions(+), 43 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 14ef53e..a46a971 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 @@ -24,6 +24,8 @@ import com.yeshi.fanli.dao.mybatis.AccountMessageMapper; import com.yeshi.fanli.dao.mybatis.UserConnectHistoryMapper; import com.yeshi.fanli.dao.mybatis.UserInfoMapper; +import com.yeshi.fanli.dto.wx.WXAccountInfoDTO; +import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.user.BindingAccount; import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode; import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum; @@ -111,16 +113,16 @@ @Resource private JedisPool jedisPool; - - + @Lazy @Resource private UserInfoModifyRecordService userInfoModifyRecordService; - + @Transactional @Override - public LoginResult login(HttpServletRequest request, Boolean first, String appId, String code, String phone, - UserInfo tbUserInfo, boolean wxinstall, int loginType) throws UserAccountException { + public LoginResult login(HttpServletRequest request, AcceptData acceptData, Boolean first, String appId, + String code, String phone, UserInfo tbUserInfo, boolean wxinstall, int loginType) + throws UserAccountException { JSONObject logInfo = new JSONObject(); logInfo.put("appId", appId); @@ -182,7 +184,9 @@ case 2:// 寰俊 // 閫氳繃Code鎹㈠彇淇℃伅 - weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code); + WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); + weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + wxAccount.getAppSecret()); if (weiXinUser == null) throw new UserAccountException(1001, "鏃犳硶鑾峰彇鍒板井淇′釜浜轰俊鎭�"); LogHelper.test("寰俊鎺堟潈鐢ㄦ埛淇℃伅锛�" + new Gson().toJson(weiXinUser)); @@ -363,7 +367,7 @@ } } else {// 娌℃湁瀹夎寰俊 - LoginResult result = loginNoInstallWX(appId, code, phone, tbUserInfo, loginType); + LoginResult result = loginNoInstallWX(acceptData, appId, code, phone, tbUserInfo, loginType); if (result.getType() == LoginResult.TYPE_CREATE) session.setAttribute("LAST_LOGIN_USER", result.getUser()); return result; @@ -372,8 +376,8 @@ @Transactional @Override - public LoginResult loginNoInstallWX(String appId, String code, String phone, UserInfo tbUserInfo, int loginType) - throws UserAccountException { + public LoginResult loginNoInstallWX(AcceptData acceptData, String appId, String code, String phone, + UserInfo tbUserInfo, int loginType) throws UserAccountException { JSONObject logInfo = new JSONObject(); logInfo.put("appId", appId); logInfo.put("code", code); @@ -397,7 +401,9 @@ break; case 2:// 寰俊 // 閫氳繃Code鎹㈠彇淇℃伅 - weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code); + WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); + weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + wxAccount.getAppSecret()); if (weiXinUser == null) throw new UserAccountException(1001, "鏃犳硶鑾峰彇鍒板井淇′釜浜轰俊鎭�"); @@ -698,7 +704,7 @@ if (StringUtil.isNullOrEmpty(user.getPortrait())) user.setPortrait(Constant.systemCommonConfig.getDefaultPortrait()); userInfoMapper.insertSelective(user); - + // 鏄电О涓虹┖鏃� 榛樿鏄电О if (StringUtil.isNullOrEmpty(user.getNickName())) { UserInfo updateUserInfo = new UserInfo(user.getId()); @@ -712,14 +718,13 @@ } catch (Exception e) { e.printStackTrace(); } - - - if (!StringUtil.isNullOrEmpty(user.getPhone())) + + if (!StringUtil.isNullOrEmpty(user.getPhone())) userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, user.getPhone()); - - if (!StringUtil.isNullOrEmpty(user.getWxUnionId())) + + if (!StringUtil.isNullOrEmpty(user.getWxUnionId())) userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, user.getWxUnionId()); - + } @Override @@ -744,8 +749,7 @@ update.setPhone(phone); userInfoMapper.updateByPrimaryKeySelective(update); userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE); - - + userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, phone); } @@ -830,11 +834,13 @@ } @Override - public void changeWXBind(Long uid, String code) throws UserAccountException { + public void changeWXBind(AcceptData acceptData, Long uid, String code) throws UserAccountException { UserInfo user = userInfoMapper.selectByPrimaryKey(uid); if (user == null) throw new UserAccountException(4, "鐢ㄦ埛涓嶅瓨鍦�"); - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code); + WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + wxAccount.getAppSecret()); if (weiXinUser == null) throw new UserAccountException(10, "鑾峰彇寰俊鐢ㄦ埛淇℃伅澶辫触"); if (weiXinUser.getUnionid().equalsIgnoreCase(user.getWxUnionId())) @@ -842,14 +848,14 @@ UserInfo newUser = getUserInfoByWXUnionId(user.getAppId(), weiXinUser.getUnionid()); if (newUser != null) - throw new UserAccountException(13, "浜诧紝浣犺鏇存崲缁戝畾鐨勫井淇″彿宸茶鍏朵粬璐﹀彿缁戝畾"); + throw new UserAccountException(13, "璇ュ井淇″彿宸茶鍏朵粬璐﹀彿缁戝畾"); UserInfo updateUserInfo = new UserInfo(uid); updateUserInfo.setWxName(weiXinUser.getNickname()); updateUserInfo.setWxOpenId(weiXinUser.getOpenid()); updateUserInfo.setWxPic(weiXinUser.getHeadimgurl()); updateUserInfo.setWxUnionId(weiXinUser.getUnionid()); - + // 灏嗛粯璁ゆ樀绉版浛鎹㈡垚寰俊鏄电О String defaultNickName = Constant.systemCommonConfig.getDefaultNickName(); if (!StringUtil.isNullOrEmpty(defaultNickName) && !StringUtil.isNullOrEmpty(weiXinUser.getNickname())) { @@ -865,12 +871,11 @@ && defaultPortrait.equals(user.getPortrait())) { updateUserInfo.setPortrait(weiXinUser.getHeadimgurl()); } - + userInfoMapper.updateByPrimaryKeySelective(updateUserInfo); userAccountMsgNotificationService.changeBindingSuccess(uid, MsgAccountDetailFactory.TYPE_WX); - - + userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid()); } @@ -1023,7 +1028,7 @@ if (exec == null || exec.size() == 0) { throw new UserAccountException(10, "璇风◢鍚庡啀璇�"); } else { - + // 鏌ヨ鏄惁瀛樺湪璇ョ數璇濆巻鍙茬敤鎴� UserInfo userInfo = userInfoMapper.getEffectiveUserInfoByPhone(phone); if (userInfo != null) { @@ -1032,7 +1037,7 @@ } else { userInfo = new UserInfo(); userInfo.setAppId(appId); - //userInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName()); + // userInfo.setNickName(Constant.systemCommonConfig.getDefaultNickName()); userInfo.setPortrait(Constant.systemCommonConfig.getDefaultPortrait()); userInfo.setPhone(phone); userInfo.setLoginType(loginType); @@ -1046,10 +1051,10 @@ } catch (Exception e) { e.printStackTrace(); } - + userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindPhone, phone); } - + return userInfo; } } catch (Exception e) { @@ -1064,8 +1069,8 @@ @Transactional @Override - public UserInfo loginWinXin(HttpServletRequest request, int loginType, String code, String appId) - throws UserAccountException { + public UserInfo loginWinXin(HttpServletRequest request, AcceptData acceptData, int loginType, String code, + String appId) throws UserAccountException { // 鏃ュ織淇℃伅 JSONObject logInfo = new JSONObject(); logInfo.put("appId", appId); @@ -1074,7 +1079,9 @@ LogHelper.lgoinInfo(logInfo.toString()); // 閫氳繃Code鎹㈠彇淇℃伅 - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code); + WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + wxAccount.getAppSecret()); if (weiXinUser == null) { throw new UserAccountException(1, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1132,8 +1139,9 @@ } catch (Exception e) { e.printStackTrace(); } - - userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindWeiXin, weiXinUser.getUnionid()); + + userInfoModifyRecordService.addModifyRecord(userInfo.getId(), ModifyTypeEnum.bindWeiXin, + weiXinUser.getUnionid()); } return userInfo; } @@ -1199,19 +1207,20 @@ // 鍙戦�佹秷鎭� userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_PHONE); - + userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindPhone, phone); - + } @Override - public void bindWeiXin(Long uid, String code) throws UserAccountException { + public void bindWeiXin(AcceptData acceptData, Long uid, String code) throws UserAccountException { UserInfo user = userInfoMapper.selectByPrimaryKey(uid); if (user == null) { throw new UserAccountException(1, "鐢ㄦ埛涓嶅瓨鍦�"); } - - WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code); + WXAccountInfoDTO wxAccount = Constant.getWXAccount(acceptData.getPlatform(), acceptData.getVersion()); + WeiXinUser weiXinUser = WXLoginUtil.getWeiXinUserWithSavePortrait(code, wxAccount.getAppId(), + wxAccount.getAppSecret()); if (weiXinUser == null) { throw new UserAccountException(2, "寰俊甯愬彿鎺堟潈澶辫触"); } @@ -1249,7 +1258,7 @@ updateUserInfo.setNickName(weiXinUser.getNickname()); } } - + // 灏嗛粯璁ゅご鍍忔浛鎹㈡垚寰俊澶村儚 String defaultPortrait = Constant.systemCommonConfig.getDefaultPortrait(); if (!StringUtil.isNullOrEmpty(weiXinUser.getHeadimgurl()) && !StringUtil.isNullOrEmpty(defaultPortrait) @@ -1272,8 +1281,7 @@ userAccountBindingHistoryService.addUserAccountBindingHistory(history); userAccountMsgNotificationService.bindingSuccess(uid, MsgAccountDetailFactory.TYPE_WX); - - + userInfoModifyRecordService.addModifyRecord(uid, ModifyTypeEnum.bindWeiXin, wxUnionId); } -- Gitblit v1.8.0