|
@@ -4,28 +4,21 @@ import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.app.param.LoginMaWxParam;
|
|
|
import com.fs.app.utils.JwtUtils;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
-import com.fs.common.core.redis.RedisCache;
|
|
|
-
|
|
|
import com.fs.common.utils.IpUtil;
|
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
|
-
|
|
|
import com.fs.his.domain.FsUserWx;
|
|
|
import com.fs.his.service.IFsUserWxService;
|
|
|
import com.fs.store.domain.FsUser;
|
|
|
import com.fs.store.domain.FsUserCompanyUser;
|
|
|
import com.fs.store.service.IFsUserCompanyUserService;
|
|
|
import com.fs.store.service.IFsUserService;
|
|
|
-import com.fs.system.mapper.SysConfigMapper;
|
|
|
import com.fs.wx.miniapp.config.WxMaConfiguration;
|
|
|
-import com.fs.wx.miniapp.config.WxMaProperties;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -53,19 +46,12 @@ import static com.fs.common.utils.PhoneUtil.encryptPhone;
|
|
|
public class WxCompanyUserController extends AppBaseController {
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
- @Autowired
|
|
|
- private WxMaProperties maProperties;
|
|
|
-
|
|
|
@Autowired
|
|
|
JwtUtils jwtUtils;
|
|
|
|
|
|
- @Autowired
|
|
|
- RedisCache redisCache;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ICompanyUserService companyUserService;
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
private IFsUserService userService;
|
|
|
|
|
@@ -74,9 +60,6 @@ public class WxCompanyUserController extends AppBaseController {
|
|
|
@Autowired
|
|
|
private IFsUserCompanyUserService userCompanyUserService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private SysConfigMapper sysConfigMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IFsUserWxService fsUserWxService;
|
|
|
|
|
@@ -127,9 +110,10 @@ public class WxCompanyUserController extends AppBaseController {
|
|
|
|
|
|
FsUser user = getUserByAuthType(param, wxService, session, phoneNoInfo);
|
|
|
|
|
|
-
|
|
|
- if (user!=null && user.getCompanyUserId() != null && !param.getCompanyUserId().equals(user.getCompanyUserId())) {
|
|
|
+ FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(user.getUserId(), param.getProjectId());
|
|
|
+ if (Objects.nonNull(userCompanyUser) && !param.getCompanyUserId().equals(userCompanyUser.getCompanyUserId())){
|
|
|
return R.error(500, "该用户("+user.getUserId() + ")已成为其他销售会员");
|
|
|
+ }
|
|
|
|
|
|
// 3. 处理用户注册或更新
|
|
|
String ip = IpUtil.getRequestIp();
|
|
@@ -189,6 +173,7 @@ public class WxCompanyUserController extends AppBaseController {
|
|
|
}
|
|
|
if((companyUser.getIsAllowedAllRegister() == null || companyUser.getIsAllowedAllRegister() == 1)
|
|
|
&& companyUser.getIsNeedRegisterMember() != null && companyUser.getIsNeedRegisterMember() != 1){
|
|
|
+ int defaultStatus = (company != null ? company.getFsUserIsDefaultBlack() : 0) == 1 ? 0 : 1;
|
|
|
userCompanyUserService.bindRelationship(user.getUserId(), param.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
|
|
|
}
|
|
|
userService.insertFsUser(user);
|
|
@@ -207,11 +192,6 @@ public class WxCompanyUserController extends AppBaseController {
|
|
|
userMap.setPhone(phoneNoInfo.getPhoneNumber());
|
|
|
}
|
|
|
|
|
|
- FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(user.getUserId(), param.getProjectId());
|
|
|
- if (Objects.nonNull(userCompanyUser) && !param.getCompanyUserId().equals(userCompanyUser.getCompanyUserId())){
|
|
|
- return R.error(500, "该用户("+user.getUserId() + ")已成为其他销售会员");
|
|
|
- }
|
|
|
-
|
|
|
userService.updateFsUser(userMap);
|
|
|
return userMap;
|
|
|
}
|
|
@@ -222,26 +202,6 @@ public class WxCompanyUserController extends AppBaseController {
|
|
|
*/
|
|
|
private void handleFsUserWx(FsUser user, LoginMaWxParam param, Company company, WxMaJscode2SessionResult session) {
|
|
|
if (user == null) return;
|
|
|
-// FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(company.getCourseMiniAppId(), user.getUserId(), 1);
|
|
|
-// if (fsUserWx == null) {
|
|
|
-// fsUserWx = new FsUserWx();
|
|
|
-// fsUserWx.setType(1);
|
|
|
-// fsUserWx.setFsUserId(user.getUserId());
|
|
|
-// fsUserWx.setCompanyId(param.getCompanyId());
|
|
|
-// fsUserWx.setAppId(company.getCourseMiniAppId());
|
|
|
-// fsUserWx.setOpenId(session.getOpenid());
|
|
|
-// fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
|
|
|
-// fsUserWx.setCreateTime(new Date());
|
|
|
-// fsUserWxService.save(fsUserWx);
|
|
|
-// } else {
|
|
|
-// fsUserWx.setFsUserId(user.getUserId());
|
|
|
-// fsUserWx.setCompanyId(param.getCompanyId());
|
|
|
-// fsUserWx.setAppId(company.getCourseMiniAppId());
|
|
|
-// fsUserWx.setOpenId(session.getOpenid());
|
|
|
-// fsUserWx.setUnionId(session.getUnionid() == null ? "" : session.getUnionid());
|
|
|
-// fsUserWx.setUpdateTime(new Date());
|
|
|
-// fsUserWxService.updateById(fsUserWx);
|
|
|
-// }
|
|
|
// 尝试更新
|
|
|
boolean updated = fsUserWxService.lambdaUpdate()
|
|
|
.eq(FsUserWx::getFsUserId, user.getUserId())
|
|
@@ -267,33 +227,4 @@ public class WxCompanyUserController extends AppBaseController {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-// @Login(isMiniLogin = true)
|
|
|
-// @ApiOperation("获取销售通过小程序登录后的用户信息")
|
|
|
-// @GetMapping("/getMaUser")
|
|
|
-// public R getUserInfo() {
|
|
|
-// try {
|
|
|
-// CompanyUser companyUser = companyUserService.selectCompanyUserById(Long.parseLong(getUserId()));
|
|
|
-// if (companyUser == null) {
|
|
|
-// return R.error(401, "用户信息不存在");
|
|
|
-// }
|
|
|
-// return R.ok().put("user", companyUser);
|
|
|
-// } catch (Exception e) {
|
|
|
-// return R.error("操作异常");
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
- /**
|
|
|
- * 特殊要求:销售小程序临时登录,登录后页面中还有一个之前常用的登录,所以为了区分,token名称不能跟之前的一样
|
|
|
- *
|
|
|
- * @return 用户id
|
|
|
- */
|
|
|
-// public String getUserId() {
|
|
|
-// String headValue = ServletUtils.getRequest().getHeader("UserToken");
|
|
|
-// Claims claims = jwtUtils.getClaimByToken(headValue);
|
|
|
-// String userId = claims.getSubject().toString();
|
|
|
-// return userId;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
}
|