|
@@ -10,6 +10,7 @@ import com.caimei365.user.mapper.RegisterMapper;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
import com.caimei365.user.model.dto.AuthBindDto;
|
|
import com.caimei365.user.model.dto.AuthBindDto;
|
|
import com.caimei365.user.model.dto.LoginPasswordDto;
|
|
import com.caimei365.user.model.dto.LoginPasswordDto;
|
|
|
|
+import com.caimei365.user.model.dto.ScanBindDto;
|
|
import com.caimei365.user.model.po.OperationPo;
|
|
import com.caimei365.user.model.po.OperationPo;
|
|
import com.caimei365.user.model.vo.UserLoginVo;
|
|
import com.caimei365.user.model.vo.UserLoginVo;
|
|
import com.caimei365.user.service.LoginService;
|
|
import com.caimei365.user.service.LoginService;
|
|
@@ -115,17 +116,17 @@ public class LoginServiceImpl implements LoginService {
|
|
return ResponseJson.error(appletsInfo.getMsg(), null);
|
|
return ResponseJson.error(appletsInfo.getMsg(), null);
|
|
}
|
|
}
|
|
Map<String, Object> infoData = appletsInfo.getData();
|
|
Map<String, Object> infoData = appletsInfo.getData();
|
|
- String openId = (String) infoData.get("openId");
|
|
|
|
- String unionId = (String) infoData.get("unionId");
|
|
|
|
- String sessionKey = (String) infoData.get("sessionKey");
|
|
|
|
|
|
+ String openId = (String) infoData.get("openid");
|
|
|
|
+ String unionId = (String) infoData.get("unionid");
|
|
|
|
+ String sessionKey = (String) infoData.get("session_key");
|
|
try {
|
|
try {
|
|
if (StringUtils.isEmpty(unionId) || StringUtils.isBlank(unionId)) {
|
|
if (StringUtils.isEmpty(unionId) || StringUtils.isBlank(unionId)) {
|
|
String result = WeChatService.decrypt(encryptedData, sessionKey, iv, "UTF-8");
|
|
String result = WeChatService.decrypt(encryptedData, sessionKey, iv, "UTF-8");
|
|
log.info("解密数据>>>>>>" + result);
|
|
log.info("解密数据>>>>>>" + result);
|
|
Map parseMap = JSONObject.parseObject(result, Map.class);
|
|
Map parseMap = JSONObject.parseObject(result, Map.class);
|
|
assert parseMap != null;
|
|
assert parseMap != null;
|
|
- unionId = parseMap.get("unionId").toString();
|
|
|
|
- infoData.put("unionId", unionId);
|
|
|
|
|
|
+ unionId = parseMap.get("unionid").toString();
|
|
|
|
+ infoData.put("unionid", unionId);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -231,7 +232,7 @@ public class LoginServiceImpl implements LoginService {
|
|
operation = new UserLoginVo();
|
|
operation = new UserLoginVo();
|
|
operation.setOpenId(openId);
|
|
operation.setOpenId(openId);
|
|
operation.setUnionId(unionId);
|
|
operation.setUnionId(unionId);
|
|
- return ResponseJson.error("您的微信尚未绑定任何机构", operation);
|
|
|
|
|
|
+ return ResponseJson.error(-4, "您的微信尚未绑定任何机构", operation);
|
|
} else {
|
|
} else {
|
|
// 表示 openId存在, unionId不存在
|
|
// 表示 openId存在, unionId不存在
|
|
operationMapper.updateOperationUnionId(operation.getUserId(), unionId);
|
|
operationMapper.updateOperationUnionId(operation.getUserId(), unionId);
|
|
@@ -360,6 +361,89 @@ public class LoginServiceImpl implements LoginService {
|
|
return operationAuthLogin(openId, unionId, "www");
|
|
return operationAuthLogin(openId, unionId, "www");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 微信扫码后,绑定机构账号
|
|
|
|
+ *
|
|
|
|
+ * @param scanBindDto {
|
|
|
|
+ * mobileOrEmail 手机号或邮箱
|
|
|
|
+ * password 密码
|
|
|
|
+ * mobile 手机号
|
|
|
|
+ * smsCode 手机验证码
|
|
|
|
+ * linkName 联系人
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<UserLoginVo> qrCodeAuthScanBind(ScanBindDto scanBindDto) {
|
|
|
|
+ String mobileOrEmail = scanBindDto.getMobileOrEmail();
|
|
|
|
+ String password = scanBindDto.getPassword();
|
|
|
|
+ String mobile = scanBindDto.getMobile();
|
|
|
|
+ String smsCode = scanBindDto.getSmsCode();
|
|
|
|
+ String linkName = scanBindDto.getLinkName();
|
|
|
|
+ String unionId = scanBindDto.getUnionId();
|
|
|
|
+ //处理比对密码
|
|
|
|
+ UserLoginVo user = loginMapper.getLoginUserByMobileOrEmail(mobileOrEmail);
|
|
|
|
+ String md5Password = Md5Util.md5(password);
|
|
|
|
+ if (null != user && md5Password.equals(user.getPassword())) {
|
|
|
|
+ // 查询使用该手机号的运营人员或用户
|
|
|
|
+ String checkRust = operationBindCheck(mobile, smsCode);
|
|
|
|
+ if (checkRust != null) {
|
|
|
|
+ return ResponseJson.error(checkRust, null);
|
|
|
|
+ }
|
|
|
|
+ Map<Object, Object> infoData = redisService.getEntries("wxInfo:website:" + unionId);
|
|
|
|
+ log.info("扫码绑定微信, 获取unionId>>>>>>" + unionId);
|
|
|
|
+ String openId = (String) infoData.get("openid");
|
|
|
|
+ String nickName = (String) infoData.get("nickname");
|
|
|
|
+ String avatarUrl = (String) infoData.get("headimgurl");
|
|
|
|
+ // 判断微信是否已经绑定
|
|
|
|
+ UserLoginVo operationByUnionId = loginMapper.getLoginUserByUnionId(unionId,"www");
|
|
|
|
+ if (operationByUnionId != null) {
|
|
|
|
+ return ResponseJson.error("该微信已绑定,请重新刷新首页", null);
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ 组装运营人员数据 operation
|
|
|
|
+ */
|
|
|
|
+ OperationPo operation = new OperationPo();
|
|
|
|
+ // 用户Id
|
|
|
|
+ operation.setUserId(user.getUserId());
|
|
|
|
+ // 手机号
|
|
|
|
+ operation.setMobile(mobile);
|
|
|
|
+ operation.setLinkName(linkName);
|
|
|
|
+ // 微信昵称头像
|
|
|
|
+ operation.setNickName(nickName);
|
|
|
|
+ operation.setAvatarUrl(avatarUrl);
|
|
|
|
+ // unionId,openId
|
|
|
|
+ operation.setUnionId(unionId);
|
|
|
|
+ operation.setPcOpenId(openId);
|
|
|
|
+ // 组织机构0
|
|
|
|
+ operation.setOrganizeId(0);
|
|
|
|
+ // 绑定的机构/供应商Id,绑定的用户类型
|
|
|
|
+ if (user != null && 3 == user.getUserIdentity() ) {
|
|
|
|
+ operation.setShopId(user.getShopId());
|
|
|
|
+ operation.setUserType(2);
|
|
|
|
+ } else if (user != null) {
|
|
|
|
+ operation.setClubId(user.getClubId());
|
|
|
|
+ operation.setUserType(1);
|
|
|
|
+ }
|
|
|
|
+ // 绑定状态
|
|
|
|
+ operation.setStatus(2);
|
|
|
|
+ // 删除标识
|
|
|
|
+ operation.setDelFlag(0);
|
|
|
|
+ Date time = new Date();
|
|
|
|
+ // 添加时间
|
|
|
|
+ operation.setAddTime(time);
|
|
|
|
+ // 绑定时间
|
|
|
|
+ operation.setBindTime(time);
|
|
|
|
+ // 更新时间
|
|
|
|
+ operation.setUpdateTime(time);
|
|
|
|
+ /*
|
|
|
|
+ 保存数据库 operation
|
|
|
|
+ */
|
|
|
|
+ registerMapper.insertOperation(operation);
|
|
|
|
+ return logonVerify(user);
|
|
|
|
+ }
|
|
|
|
+ return ResponseJson.error("输入的密码和账户名不匹配", null);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 邀请码登录
|
|
* 邀请码登录
|
|
*
|
|
*
|
|
@@ -391,10 +475,10 @@ public class LoginServiceImpl implements LoginService {
|
|
}
|
|
}
|
|
// 用户身份:1机构,2供应商
|
|
// 用户身份:1机构,2供应商
|
|
int userIdentity = 3 == operation.getUserIdentity() ? 2 : 1;
|
|
int userIdentity = 3 == operation.getUserIdentity() ? 2 : 1;
|
|
- if (operation.getClubStatus() != null && 1 == userIdentity && 91 != operation.getClubStatus()) {
|
|
|
|
|
|
+ if (1 == userIdentity && operation.getClubStatus() != null && 91 == operation.getClubStatus()) {
|
|
return ResponseJson.error("您的机构已冻结", null);
|
|
return ResponseJson.error("您的机构已冻结", null);
|
|
}
|
|
}
|
|
- if (operation.getShopStatus() != null && 2 == userIdentity && 91 != operation.getShopStatus()) {
|
|
|
|
|
|
+ if (2 == userIdentity && operation.getShopStatus() != null && 91 == operation.getShopStatus()) {
|
|
return ResponseJson.error("您的企业账号已被冻结,请联系客服处理", null);
|
|
return ResponseJson.error("您的企业账号已被冻结,请联系客服处理", null);
|
|
}
|
|
}
|
|
if (0 != operation.getDelFlag()) {
|
|
if (0 != operation.getDelFlag()) {
|
|
@@ -406,7 +490,7 @@ public class LoginServiceImpl implements LoginService {
|
|
operationPo.setUnionId(unionId);
|
|
operationPo.setUnionId(unionId);
|
|
Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
|
|
Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
|
|
// 微信openId
|
|
// 微信openId
|
|
- operationPo.setOpenId((String) infoData.get("openId"));
|
|
|
|
|
|
+ operationPo.setOpenId((String) infoData.get("openid"));
|
|
// 微信昵称
|
|
// 微信昵称
|
|
operationPo.setNickName(nickName);
|
|
operationPo.setNickName(nickName);
|
|
// 微信头像
|
|
// 微信头像
|
|
@@ -456,33 +540,14 @@ public class LoginServiceImpl implements LoginService {
|
|
if (null == userId || StringUtils.isBlank(mobile) || StringUtils.isBlank(smsCode)) {
|
|
if (null == userId || StringUtils.isBlank(mobile) || StringUtils.isBlank(smsCode)) {
|
|
return ResponseJson.error("参数异常", null);
|
|
return ResponseJson.error("参数异常", null);
|
|
}
|
|
}
|
|
- String redisSmsCode = (String) redisService.get("code:" + mobile);
|
|
|
|
- if (!redisSmsCode.equals(smsCode)) {
|
|
|
|
- return ResponseJson.error("手机验证码错误", null);
|
|
|
|
- }
|
|
|
|
- // 手机号验证
|
|
|
|
- String result = commonService.mobileAndCodeValidate(mobile, null);
|
|
|
|
- if (result != null) {
|
|
|
|
- // 查询使用该手机号的运营人员或用户
|
|
|
|
- UserLoginVo dbUser = loginMapper.getLoginUserByMobile(mobile);
|
|
|
|
- boolean offlineClub = false;
|
|
|
|
- boolean offlineShop = false;
|
|
|
|
- if (null != dbUser){
|
|
|
|
- // 已下线机构
|
|
|
|
- offlineClub = null != dbUser.getClubStatus() && 91 == dbUser.getClubStatus();
|
|
|
|
- // 已下线供应商
|
|
|
|
- offlineShop = null != dbUser.getShopStatus() && 91 == dbUser.getShopStatus();
|
|
|
|
- }
|
|
|
|
- if (offlineClub || offlineShop) {
|
|
|
|
- // 解绑已下线的运营人员
|
|
|
|
- unbindOperation(dbUser.getOperationId());
|
|
|
|
- } else {
|
|
|
|
- return ResponseJson.error(result, null);
|
|
|
|
- }
|
|
|
|
|
|
+ // 查询使用该手机号的运营人员或用户
|
|
|
|
+ String checkRust = operationBindCheck(mobile, smsCode);
|
|
|
|
+ if (checkRust != null) {
|
|
|
|
+ return ResponseJson.error(checkRust, null);
|
|
}
|
|
}
|
|
Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
|
|
Map<Object, Object> infoData = redisService.getEntries("wxInfo:applets:" + unionId);
|
|
log.info("绑定微信bindingWx,获取unionId>>>>>>" + unionId);
|
|
log.info("绑定微信bindingWx,获取unionId>>>>>>" + unionId);
|
|
- String openId = (String) infoData.get("openId");
|
|
|
|
|
|
+ String openId = (String) infoData.get("openid");
|
|
// 判断微信是否已经绑定
|
|
// 判断微信是否已经绑定
|
|
UserLoginVo operationByUnionId = loginMapper.getLoginUserByUnionId(unionId,"mini");
|
|
UserLoginVo operationByUnionId = loginMapper.getLoginUserByUnionId(unionId,"mini");
|
|
if (operationByUnionId != null) {
|
|
if (operationByUnionId != null) {
|
|
@@ -532,6 +597,38 @@ public class LoginServiceImpl implements LoginService {
|
|
registerMapper.insertOperation(operation);
|
|
registerMapper.insertOperation(operation);
|
|
return ResponseJson.success("绑定微信成功", user);
|
|
return ResponseJson.success("绑定微信成功", user);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询使用该手机号的运营人员或用户
|
|
|
|
+ */
|
|
|
|
+ private String operationBindCheck(String mobile, String smsCode) {
|
|
|
|
+ String redisSmsCode = (String) redisService.get("code:" + mobile);
|
|
|
|
+ if (redisSmsCode == null || !redisSmsCode.equals(smsCode)) {
|
|
|
|
+ return "手机验证码错误";
|
|
|
|
+ }
|
|
|
|
+ // 手机号验证
|
|
|
|
+ String result = commonService.mobileAndCodeValidate(mobile, null);
|
|
|
|
+ if (result != null) {
|
|
|
|
+ // 查询使用该手机号的运营人员或用户
|
|
|
|
+ UserLoginVo dbUser = loginMapper.getLoginUserByMobile(mobile);
|
|
|
|
+ boolean offlineClub = false;
|
|
|
|
+ boolean offlineShop = false;
|
|
|
|
+ if (null != dbUser){
|
|
|
|
+ // 已下线机构
|
|
|
|
+ offlineClub = null != dbUser.getClubStatus() && 91 == dbUser.getClubStatus();
|
|
|
|
+ // 已下线供应商
|
|
|
|
+ offlineShop = null != dbUser.getShopStatus() && 91 == dbUser.getShopStatus();
|
|
|
|
+ }
|
|
|
|
+ if (offlineClub || offlineShop) {
|
|
|
|
+ // 解绑已下线的运营人员
|
|
|
|
+ unbindOperation(dbUser.getOperationId());
|
|
|
|
+ } else {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 解绑运营人员
|
|
* 解绑运营人员
|
|
*
|
|
*
|