Commit 4c828a8a authored by lee_mingzhu's avatar lee_mingzhu

增加限制,用户已保存的联系人>=2时,不允许再保存联系人信息

parent e659fbd2
...@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.Constants; ...@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.Constants;
import cn.quantgroup.xyqb.entity.Merchant; import cn.quantgroup.xyqb.entity.Merchant;
import cn.quantgroup.xyqb.entity.User; import cn.quantgroup.xyqb.entity.User;
import cn.quantgroup.xyqb.entity.WechatUserInfo; import cn.quantgroup.xyqb.entity.WechatUserInfo;
import cn.quantgroup.xyqb.event.UserinfoChangedEvent;
import cn.quantgroup.xyqb.model.AuthBean; import cn.quantgroup.xyqb.model.AuthBean;
import cn.quantgroup.xyqb.model.JsonResult; import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse; import cn.quantgroup.xyqb.model.webchat.AccessTokenResponse;
...@@ -173,7 +174,7 @@ public class WeChatController { ...@@ -173,7 +174,7 @@ public class WeChatController {
* @return * @return
*/ */
@RequestMapping("/receiveCode/{key}") @RequestMapping("/receiveCode/{key}")
public void receiveCode(String code, @PathVariable(value = "key") String systemKey, HttpServletResponse response) { public void receiveCode(String code, @PathVariable(value = "key") String systemKey, String redirect, HttpServletResponse response) {
LOGGER.info("微信登录:" + systemKey); LOGGER.info("微信登录:" + systemKey);
// 从code获取token // 从code获取token
Merchant merchant = merchantService.findMerchantByName(systemKey); Merchant merchant = merchantService.findMerchantByName(systemKey);
...@@ -214,18 +215,24 @@ public class WeChatController { ...@@ -214,18 +215,24 @@ public class WeChatController {
} }
// 已经关联了用户 // 已经关联了用户
// create session, 登进去,该怎么玩怎么玩。 // create session, 登进去,该怎么玩怎么玩。
String redirectUrl = createUserSession(user, merchant); String redirectUrl = createUserSession(user, merchant, redirect);
response.setHeader("Location", redirectUrl); response.setHeader("Location", redirectUrl);
response.setStatus(301); response.setStatus(301);
} }
private String createUserSession(User user, Merchant merchant) { private String createUserSession(User user, Merchant merchant, String redirect) {
LOGGER.info("微信登录: createUserSession:{} merchant is null:", merchant == null); if(StringUtils.isEmpty(redirect)) {
if ("baitiao".equals(merchant.getName())) { LOGGER.info("微信登录: createUserSession:{} merchant is null:", merchant == null);
return loginInWechatWithSessionCreated(user, merchant, "cashTarget5", Constants.Channel.BAITIAO); if ("baitiao".equals(merchant.getName())) {
} else { return loginInWechatWithSessionCreated(user, merchant, "cashTarget5", Constants.Channel.BAITIAO);
return loginInWechatWithSessionCreated(user, merchant, "cashTarget4", 1L); } else {
return loginInWechatWithSessionCreated(user, merchant, "cashTarget4", 1L);
}
} else if(redirect.equals("redirect")){
AuthBean authBean = sessionService.createSession(Constants.Channel.WECHAT, Constants.Channel.WECHAT, "", user, merchant);
return userUIAddr + "/weixin/callback?phoneNo=" + user.getPhoneNo() + "&token=" + authBean.getToken();
} }
return null;
} }
private String loginInWechatWithSessionCreated(User user, Merchant merchant, String target, Long channelId) { private String loginInWechatWithSessionCreated(User user, Merchant merchant, String target, Long channelId) {
......
...@@ -49,18 +49,20 @@ public class UserDetailServiceImpl implements IUserDetailService { ...@@ -49,18 +49,20 @@ public class UserDetailServiceImpl implements IUserDetailService {
Specification<UserDetail> specification = new Specification<UserDetail>() { Specification<UserDetail> specification = new Specification<UserDetail>() {
@Override @Override
public Predicate toPredicate(Root<UserDetail> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) { public Predicate toPredicate(Root<UserDetail> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
if (!StringUtils.isEmpty(name)) { //以下条件不做非空判断,如果判断非空当不填任何条件查询时,会将user_detail表的所有数据都查询出来
Path<String> namePath = root.get("name"); //不做非空判断,当不填任何条件查询时将返回空列表[]
criteriaQuery.where(criteriaBuilder.equal(namePath, name)); //if (!StringUtils.isEmpty(name)) {
} Path<String> namePath = root.get("name");
if (!StringUtils.isEmpty(phoneNo)) { criteriaQuery.where(criteriaBuilder.equal(namePath, name));
Path<String> phonePath = root.get("phoneNo"); //}
criteriaQuery.where(criteriaBuilder.equal(phonePath, phoneNo)); //if (!StringUtils.isEmpty(phoneNo)) {
} Path<String> phonePath = root.get("phoneNo");
if (!StringUtils.isEmpty(idNo)) { criteriaQuery.where(criteriaBuilder.equal(phonePath, phoneNo));
Path<String> idNoPath = root.get("idNo"); //}
criteriaQuery.where(criteriaBuilder.equal(idNoPath, idNo)); //if (!StringUtils.isEmpty(idNo)) {
} Path<String> idNoPath = root.get("idNo");
criteriaQuery.where(criteriaBuilder.equal(idNoPath, idNo));
//}
return null; return null;
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment