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

@ -287,13 +287,14 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
*/
@PostMapping("/login/wechat_bind")
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.setLoginId(params.getString("loginId"));
loginInfo.setPassword(params.getString("password"));
String signKey = signInStatusManager.verifyClientAccountLogin(loginInfo,"wechat");
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);
account = JSON.parseObject(account.toJSONString());
if (params.getString("devId") != null) {

@ -91,4 +91,8 @@ public interface ClientAccountMapper {
JSONObject findOneByOpenIdAndCreateTimeDesc(@Param("wechat_openid")String openid);
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();
}
checkOrgPermission(manager, client);
checkPhoneAndWechatExist(account);
JSONObject accountJson = account.toJson();
JSONObject accountCheck = clientAccountMapper.findByUsernameForDuplicate(accountJson.getString("username"));
if (accountCheck != null) {
@ -1562,6 +1563,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
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
@Transactional
public void resetAccountPwd(JSONObject manager, String clientMoniker, String accountId, String pwd) {
@ -1630,6 +1637,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (account == null) {
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();
if (StringUtils.equals(user.getString("openid"), account.getString("wechat_openid"))) {
res.put("notitle", true);

@ -96,7 +96,7 @@ public interface SignInStatusManager {
* @param ip
* @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 res = new JSONObject();
String nickName = wechatUserInfo.getString("nickname");
String unionId = wechatUserInfo.getString("unionid");
res.put("bind_status", false);
res.put("app_openid", openId);
res.put("status", "success");
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;
}
String statusKey = newStatusKey();
@ -416,15 +417,19 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
@Override
public String verifyClientLoginWechatBindCode(String openId,String ip){
public JSONObject verifyClientLoginWechatBindCode(String openId,String ip){
String rediskey = getClientLoginWechatBindRedisKey(openId,ip);
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
if (codeValue == null || !codeValue.split("&")[0].equals(openId)) {
throw new BadRequestException("The WeChat ID does not apply for binding");
}
String nickName = codeValue.split("&")[1];
String unionId = codeValue.split("&")[2];
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){

@ -176,6 +176,7 @@ define(['angular', 'angularSanitize', 'angularAnimate', 'angularMessages', 'uiRo
params.account_id = account.account_id;
}
$http.get('/client/partner_info/bind_qrcode', {params: params}).then(function (resp) {
debugger
$scope.checkCode = resp.data.key;
$scope.checkModal = $uibModal.open({
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) {
debugger
$scope.account = {role: 1};
$scope.partnerRoles = partnerRoles;
$scope.account.nation_code = 61;

Loading…
Cancel
Save