|
|
@@ -5,6 +5,7 @@ import com.uas.platform.b2c.common.account.model.Enterprise;
|
|
|
import com.uas.platform.b2c.common.account.model.User;
|
|
|
import com.uas.platform.b2c.common.weixin.exception.WeChatException;
|
|
|
import com.uas.platform.b2c.common.weixin.model.MessageModel;
|
|
|
+import com.uas.platform.b2c.common.weixin.model.UserVo;
|
|
|
import com.uas.platform.b2c.common.weixin.model.req.AuthTokenParams;
|
|
|
import com.uas.platform.b2c.common.weixin.model.req.AuthUserParams;
|
|
|
import com.uas.platform.b2c.common.weixin.model.req.WechatTemplateMsg;
|
|
|
@@ -161,18 +162,25 @@ public class WeChatServiceImpl implements WeChatService{
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public ModelMap bindUser(User user) {
|
|
|
+ public ModelMap bindUser(UserVo user) {
|
|
|
logger.info("微信绑定用户 userUU: {}", user.getUserUU());
|
|
|
ModelMap result = new ModelMap();
|
|
|
// 账户中心校验手机号和密码是否正确
|
|
|
if (StringUtils.isEmpty(user) || StringUtils.isEmpty(user.getUserTel()) || StringUtils.isEmpty(user.getUserPwd()) || StringUtils.isEmpty(user.getOpenId())) {
|
|
|
- throw new IllegalOperatorException("信息不完整!");
|
|
|
+ if (StringUtils.isEmpty(user.getCode())) {
|
|
|
+ throw new IllegalOperatorException("信息不完整!");
|
|
|
+ } else {
|
|
|
+ boolean verifyCode = verifyCode(user.getUserTel(), user.getCode());
|
|
|
+ if (!verifyCode) {
|
|
|
+ return new ModelMap("error", true).addAttribute("errMsg", "验证码错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
// 是否存在用户信息
|
|
|
List<User> oldUsers = userDao.findUserByUserTel(user.getUserTel());
|
|
|
if (CollectionUtils.isEmpty(oldUsers)) {
|
|
|
throw new IllegalOperatorException("未找到用户信息");
|
|
|
- }
|
|
|
+ }
|
|
|
List<User> judgeUser = userDao.findUsersByOpenId(user.getOpenId());
|
|
|
if (!CollectionUtils.isEmpty(judgeUser)) {
|
|
|
throw new IllegalOperatorException("该微信号已被绑定");
|
|
|
@@ -191,11 +199,11 @@ public class WeChatServiceImpl implements WeChatService{
|
|
|
throw new IllegalOperatorException("手机号或密码不正确");
|
|
|
}
|
|
|
oldUser.setOpenId(user.getOpenId());
|
|
|
- user = userDao.save(oldUser);
|
|
|
+ User newUser = userDao.save(oldUser);
|
|
|
// 转成UserAccount便于登录
|
|
|
- UserAccount userAccount = convertUserAccount(user);
|
|
|
+ UserAccount userAccount = convertUserAccount(newUser);
|
|
|
// 企业信息单独提出
|
|
|
- Set<Enterprise> enterprises = user.getEnterprises();
|
|
|
+ Set<Enterprise> enterprises = newUser.getEnterprises();
|
|
|
result.put("userAccount", userAccount);
|
|
|
result.put("enterprises", enterprises);
|
|
|
result.put("success", true);
|