Upd:App微信绑定字段增加union_id

master
duLingLing 5 years ago
parent c4ac20095e
commit 60e59c538f

@ -2185,6 +2185,7 @@ public class RetailAppServiceImp implements RetailAppService {
updateAccount.put("account_id", account.getString("account_id")); updateAccount.put("account_id", account.getString("account_id"));
updateAccount.put("wechat_openid", params.getString("wechat_openid")); updateAccount.put("wechat_openid", params.getString("wechat_openid"));
updateAccount.put("wechat_name", params.getString("nick_name")); updateAccount.put("wechat_name", params.getString("nick_name"));
updateAccount.put("wx_unionid", params.getString("union_id"));
clientAccountMapper.update(updateAccount); clientAccountMapper.update(updateAccount);
} }
@ -2215,6 +2216,7 @@ public class RetailAppServiceImp implements RetailAppService {
account.put("account_id", device.getString("account_id")); account.put("account_id", device.getString("account_id"));
account.put("wechat_openid", null); account.put("wechat_openid", null);
account.put("wechat_name", null); account.put("wechat_name", null);
account.put("wx_unionid", null);
clientAccountMapper.update(account); clientAccountMapper.update(account);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("status", "success"); result.put("status", "success");
@ -2237,6 +2239,7 @@ public class RetailAppServiceImp implements RetailAppService {
updateAccount.put("account_id", device.getString("account_id")); updateAccount.put("account_id", device.getString("account_id"));
updateAccount.put("wechat_openid", openId); updateAccount.put("wechat_openid", openId);
updateAccount.put("wechat_name",wechatUserInfo.getString("nickname")); updateAccount.put("wechat_name",wechatUserInfo.getString("nickname"));
updateAccount.put("wx_unionid",wechatUserInfo.getString("unionid"));
clientAccountMapper.update(updateAccount); clientAccountMapper.update(updateAccount);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("status", "success"); result.put("status", "success");

@ -287,13 +287,14 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
*/ */
@PostMapping("/login/wechat_bind") @PostMapping("/login/wechat_bind")
public JSONObject wechatLoginBind(@RequestBody JSONObject params){ public JSONObject wechatLoginBind(@RequestBody JSONObject params){
String nickName = signInStatusManager.verifyClientLoginWechatBindCode(params.getString("wechat_openid"),RequestEnvironment.getClientIp()); JSONObject wechatInfo = signInStatusManager.verifyClientLoginWechatBindCode(params.getString("wechat_openid"),RequestEnvironment.getClientIp());
LoginInfo loginInfo = new LoginInfo(); LoginInfo loginInfo = new LoginInfo();
loginInfo.setLoginId(params.getString("loginId")); loginInfo.setLoginId(params.getString("loginId"));
loginInfo.setPassword(params.getString("password")); loginInfo.setPassword(params.getString("password"));
String signKey = signInStatusManager.verifyClientAccountLogin(loginInfo,"wechat"); String signKey = signInStatusManager.verifyClientAccountLogin(loginInfo,"wechat");
JSONObject account = signInStatusManager.getCurrentClient(signKey); JSONObject account = signInStatusManager.getCurrentClient(signKey);
params.put("nick_name",nickName); params.put("nick_name",wechatInfo.getString("nick_name"));
params.put("union_id",wechatInfo.getString("union_id"));
retailAppService.updateLoginClientAccountOpenId(account,params); retailAppService.updateLoginClientAccountOpenId(account,params);
account = JSON.parseObject(account.toJSONString()); account = JSON.parseObject(account.toJSONString());
if (params.getString("devId") != null) { if (params.getString("devId") != null) {

@ -91,4 +91,8 @@ public interface ClientAccountMapper {
JSONObject findOneByOpenIdAndCreateTimeDesc(@Param("wechat_openid")String openid); JSONObject findOneByOpenIdAndCreateTimeDesc(@Param("wechat_openid")String openid);
JSONObject findOneByPhoneAndCreateTimeDesc(@Param("contact_phone")String contactPhone,@Param("nation_code")String nationCode); JSONObject findOneByPhoneAndCreateTimeDesc(@Param("contact_phone")String contactPhone,@Param("nation_code")String nationCode);
@AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid=1", excludeColumns = {"salt", "password_hash"})
JSONObject findByWechatOpenId(@Param("wechat_openid")String openid);
} }

@ -1542,6 +1542,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
checkOrgPermission(manager, client); checkOrgPermission(manager, client);
checkPhoneAndWechatExist(account);
JSONObject accountJson = account.toJson(); JSONObject accountJson = account.toJson();
JSONObject accountCheck = clientAccountMapper.findByUsernameForDuplicate(accountJson.getString("username")); JSONObject accountCheck = clientAccountMapper.findByUsernameForDuplicate(accountJson.getString("username"));
if (accountCheck != null) { if (accountCheck != null) {
@ -1562,6 +1563,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
return accountJson; return accountJson;
} }
private void checkPhoneAndWechatExist(NewAccountBean account){
if(clientAccountMapper.findByPhone(account.getContactPhone(),"+"+account.getNation_code())!=null){
throw new BadRequestException("Mobile phone number has been bound to other accounts");
};
}
@Override @Override
@Transactional @Transactional
public void resetAccountPwd(JSONObject manager, String clientMoniker, String accountId, String pwd) { public void resetAccountPwd(JSONObject manager, String clientMoniker, String accountId, String pwd) {
@ -1630,6 +1637,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (account == null) { if (account == null) {
throw new BadRequestException("account not exists"); throw new BadRequestException("account not exists");
} }
if(clientAccountMapper.findByWechatOpenId(user.getString("openid"))!=null || clientAccountMapper.findByWxUnioinId(user.getString("unioinid"))!=null){
throw new BadRequestException("The WeChat has been linked to other accounts");
}
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
if (StringUtils.equals(user.getString("openid"), account.getString("wechat_openid"))) { if (StringUtils.equals(user.getString("openid"), account.getString("wechat_openid"))) {
res.put("notitle", true); res.put("notitle", true);

@ -96,7 +96,7 @@ public interface SignInStatusManager {
* @param ip * @param ip
* @return * @return
*/ */
String verifyClientLoginWechatBindCode (String codeId,String ip); JSONObject verifyClientLoginWechatBindCode (String codeId,String ip);
/** /**
* *

@ -391,11 +391,12 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
JSONObject wechatUserInfo = mpClientAppWechatApiProvider.getApi("merchant-app").appUserInfo(openId,user.getString("access_token")); JSONObject wechatUserInfo = mpClientAppWechatApiProvider.getApi("merchant-app").appUserInfo(openId,user.getString("access_token"));
JSONObject res = new JSONObject(); JSONObject res = new JSONObject();
String nickName = wechatUserInfo.getString("nickname"); String nickName = wechatUserInfo.getString("nickname");
String unionId = wechatUserInfo.getString("unionid");
res.put("bind_status", false); res.put("bind_status", false);
res.put("app_openid", openId); res.put("app_openid", openId);
res.put("status", "success"); res.put("status", "success");
String expireMin = "5"; String expireMin = "5";
stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId,ip)).set(openId+"&"+nickName, Long.parseLong(expireMin), TimeUnit.MINUTES); stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId,ip)).set(openId+"&"+nickName+"&"+unionId, Long.parseLong(expireMin), TimeUnit.MINUTES);
return res; return res;
} }
String statusKey = newStatusKey(); String statusKey = newStatusKey();
@ -416,15 +417,19 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
@Override @Override
public String verifyClientLoginWechatBindCode(String openId,String ip){ public JSONObject verifyClientLoginWechatBindCode(String openId,String ip){
String rediskey = getClientLoginWechatBindRedisKey(openId,ip); String rediskey = getClientLoginWechatBindRedisKey(openId,ip);
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get(); String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
if (codeValue == null || !codeValue.split("&")[0].equals(openId)) { if (codeValue == null || !codeValue.split("&")[0].equals(openId)) {
throw new BadRequestException("The WeChat ID does not apply for binding"); throw new BadRequestException("The WeChat ID does not apply for binding");
} }
String nickName = codeValue.split("&")[1]; String nickName = codeValue.split("&")[1];
String unionId = codeValue.split("&")[2];
stringRedisTemplate.delete(rediskey); stringRedisTemplate.delete(rediskey);
return nickName; return new JSONObject(){{
put("nick_name",nickName);
put("union_id",unionId);
}};
} }
private String getClientLoginPhoneBindRedisKey(String phone,String nationCode,String ip){ private String getClientLoginPhoneBindRedisKey(String phone,String nationCode,String ip){

@ -176,6 +176,7 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
params.account_id = account.account_id; params.account_id = account.account_id;
} }
$http.get('/client/partner_info/bind_qrcode', {params: params}).then(function (resp) { $http.get('/client/partner_info/bind_qrcode', {params: params}).then(function (resp) {
debugger
$scope.checkCode = resp.data.key; $scope.checkCode = resp.data.key;
$scope.checkModal = $uibModal.open({ $scope.checkModal = $uibModal.open({
templateUrl: '/static/boot/templates/bind_qrcode_dialog.html', templateUrl: '/static/boot/templates/bind_qrcode_dialog.html',

@ -2888,6 +2888,7 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
}; };
}]); }]);
app.controller('partnerAddAccountDialogCtrl', ['$scope', '$http', 'partner', function ($scope, $http, partner) { app.controller('partnerAddAccountDialogCtrl', ['$scope', '$http', 'partner', function ($scope, $http, partner) {
debugger
$scope.account = {role: 1}; $scope.account = {role: 1};
$scope.partnerRoles = partnerRoles; $scope.partnerRoles = partnerRoles;
$scope.account.nation_code = 61; $scope.account.nation_code = 61;

Loading…
Cancel
Save