|
@@ -1,6 +1,7 @@
|
|
|
package com.zhongzheng.framework.web.service;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.codec.Base64;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
import cn.hutool.core.lang.Validator;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -14,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
|
+import com.google.common.base.Splitter;
|
|
|
import com.zhongzheng.common.constant.Constants;
|
|
|
import com.zhongzheng.common.core.domain.model.LoginUser;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
@@ -30,20 +32,30 @@ import com.zhongzheng.modules.collect.domain.CollectNote;
|
|
|
import com.zhongzheng.modules.collect.mapper.CollectBankMapper;
|
|
|
import com.zhongzheng.modules.collect.mapper.CollectCourseMapper;
|
|
|
import com.zhongzheng.modules.collect.mapper.CollectNoteMapper;
|
|
|
+import com.zhongzheng.modules.course.domain.Course;
|
|
|
+import com.zhongzheng.modules.course.domain.CourseSection;
|
|
|
import com.zhongzheng.modules.course.domain.CourseSubject;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseSectionService;
|
|
|
+import com.zhongzheng.modules.course.service.ICourseService;
|
|
|
import com.zhongzheng.modules.course.service.ICourseSubjectService;
|
|
|
+import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.grade.bo.ClassGradeUserQueryBo;
|
|
|
import com.zhongzheng.modules.grade.service.IClassGradeUserService;
|
|
|
import com.zhongzheng.modules.grade.vo.ClassGradeUserGoodsVo;
|
|
|
-import com.zhongzheng.modules.inform.domain.InformRemind;
|
|
|
+import com.zhongzheng.modules.system.domain.SysTenant;
|
|
|
import com.zhongzheng.modules.system.service.ISysConfigService;
|
|
|
+import com.zhongzheng.modules.system.service.ISysTenantService;
|
|
|
import com.zhongzheng.modules.user.bo.*;
|
|
|
-import com.zhongzheng.modules.user.domain.*;
|
|
|
+import com.zhongzheng.modules.user.domain.User;
|
|
|
+import com.zhongzheng.modules.user.domain.UserStudyLog;
|
|
|
+import com.zhongzheng.modules.user.domain.UserVisitLog;
|
|
|
import com.zhongzheng.modules.user.entity.ClientLoginUser;
|
|
|
import com.zhongzheng.modules.user.mapper.UserMapper;
|
|
|
import com.zhongzheng.modules.user.service.*;
|
|
|
import com.zhongzheng.modules.user.vo.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
@@ -115,6 +127,17 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
private IUserLoginErrorService iUserLoginErrorService;
|
|
|
@Autowired
|
|
|
private ISysConfigService configService;
|
|
|
+ @Autowired
|
|
|
+ private IGoodsService iGoodsService;
|
|
|
+ @Autowired
|
|
|
+ private ISysTenantService iSysTenantService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICourseService iCourseService;
|
|
|
+ @Autowired
|
|
|
+ private ICourseSectionService iCourseSectionService;
|
|
|
+ @Value("${liveGotoURL}")
|
|
|
+ private String liveGotoURL;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -1089,6 +1112,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private Long findSubjectId(String subject){
|
|
|
if(subject!=null){
|
|
|
String key = "SUB_"+subject;
|
|
@@ -1212,6 +1237,299 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
return this.updateById(update);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public UserLiveAccountLoginVo liveUnifyLogin(UserLiveAccountLoginBo bo) {
|
|
|
+ if (bo.getType() != 1){
|
|
|
+ throw new CustomException("登录错误");
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(bo.getAccount())){
|
|
|
+ throw new CustomException("账号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<User> userList = baseMapper.getUserByTel(bo.getAccount());
|
|
|
+ if (CollectionUtils.isEmpty(userList)){
|
|
|
+ throw new CustomException("账号不存在!请检查");
|
|
|
+ }
|
|
|
+ //参数解析
|
|
|
+ String param = new String(Base64.decode(bo.getParam()));
|
|
|
+ if (StringUtils.isBlank(param)){
|
|
|
+ throw new CustomException("参数为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> split = Splitter.on("&").withKeyValueSeparator("=").split(param);
|
|
|
+ Long goodsId = Long.valueOf(split.get("gid"));
|
|
|
+
|
|
|
+ //获取对应商品
|
|
|
+ Goods goods = iGoodsService.getGoodsByIdNotTenant(goodsId);
|
|
|
+
|
|
|
+ User user = userList.stream().filter(item -> {
|
|
|
+ //判断用户是否购买商品
|
|
|
+ Long count = baseMapper.getUserOrderCount(item.getUserId(), item.getTenantId(), goods.getCode(), goods.getGoodsName());
|
|
|
+ return count > 0;
|
|
|
+ }).findFirst().orElse(null);
|
|
|
+
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("登录信息错误");
|
|
|
+ }
|
|
|
+ else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
|
|
+ {
|
|
|
+ throw new BaseException("对不起,您的账号:已停用");
|
|
|
+ }
|
|
|
+ String password = null;
|
|
|
+ if(bo.getPwd().length()>20){
|
|
|
+ String rsaPrivate = null;
|
|
|
+ try {
|
|
|
+ InputStream certStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("config/pri.key");
|
|
|
+ rsaPrivate = AES.getStringByInputStream_1(certStream);
|
|
|
+ certStream.close();
|
|
|
+ password = AES.decrypt(bo.getPwd(),rsaPrivate);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ password = bo.getPwd();
|
|
|
+ }
|
|
|
+ if (!SecurityUtils.matchesPassword(password,user.getPassword()))
|
|
|
+ {
|
|
|
+ iUserLoginErrorService.saveErrorLog(bo.getAccount());
|
|
|
+ throw new BaseException("登录信息错误");
|
|
|
+ }
|
|
|
+ Long tenantId = user.getTenantId();
|
|
|
+ //组装跳转路径
|
|
|
+ SysTenant tenant = iSysTenantService.getById(tenantId);
|
|
|
+ String post = "";
|
|
|
+ String path = "";
|
|
|
+ switch (bo.getUrlType()){
|
|
|
+ case 1://H5
|
|
|
+ post = tenant.getHostH5();
|
|
|
+ path = "pages/webview/index";
|
|
|
+ break;
|
|
|
+ case 2://PC
|
|
|
+ post = tenant.getHostPc();
|
|
|
+ path = "living-room";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ String cid = split.get("cid");
|
|
|
+ String sid = split.get("sid");
|
|
|
+ Course course = iCourseService.getCourseByNotTenant(Long.valueOf(cid));
|
|
|
+ Long courseId = iCourseService.getCourseByTenantTwo(course.getCourseName(),course.getCode(),tenantId);
|
|
|
+ CourseSection section = iCourseSectionService.getSectionByNotTenant(Long.valueOf(sid));
|
|
|
+ CourseSection courseSection = iCourseSectionService.getSectionByTenantTwo(section.getName(),section.getCode(),tenantId);
|
|
|
+ Goods goodsTwo = iGoodsService.getGoodsByTenantTwo(goods.getGoodsName(),goods.getCode(),tenantId);
|
|
|
+
|
|
|
+ String url = "";
|
|
|
+ switch (bo.getUrlType()){
|
|
|
+ case 1://H5
|
|
|
+ String format1 = String.format("cid=%s&gid=%s&sid=%s&a=1", courseId, goodsTwo.getGoodsId(), courseSection.getSectionId());
|
|
|
+ String s1 = Base64.encode(format1);
|
|
|
+ url = String.format("%s/%s/%s?scene=%s",liveGotoURL, post,path, s1);
|
|
|
+ break;
|
|
|
+ case 2://Pc
|
|
|
+ String format = String.format("cid=%s&gid=%s&sid=%s", courseId, goodsTwo.getGoodsId(), courseSection.getSectionId());
|
|
|
+ String s = Base64.encode(format);
|
|
|
+ url = String.format("%s/%s/%s/%s?a=1&%s",liveGotoURL, post,path,courseSection.getLiveUrl(), s);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserLiveAccountLoginVo vo = new UserLiveAccountLoginVo();
|
|
|
+ vo.setTel(user.getTelphone());
|
|
|
+ vo.setUser_account(user.getUserAccount());
|
|
|
+ vo.setUrl(url);
|
|
|
+ vo.setTenantId(tenantId);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> automaticAccountLogin(UserAppTelphoneLoginBo bo) {
|
|
|
+ User user = baseMapper.getUserByAccount(bo.getUserAccount());
|
|
|
+
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("该账号不存在");
|
|
|
+ }
|
|
|
+ ClientLoginUser loginUser = new ClientLoginUser();
|
|
|
+ loginUser.setUser(user);
|
|
|
+ Map<String,Object> map = new HashMap<>();
|
|
|
+ map.put(Constants.TOKEN,wxTokenService.createToken(loginUser));
|
|
|
+ map.put("user_account",user.getUserAccount());
|
|
|
+ map.put("full_info",Validator.isEmpty(user.getIdCard())?false:true); //是否完善身份信息
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UserLiveAccountLoginVo smsLiveUnifyLogin(UserLiveAccountLoginBo bo) {
|
|
|
+ if(bo.getTel()==null){
|
|
|
+ throw new CustomException("手机号不能为空");
|
|
|
+ }
|
|
|
+ String key = Constants.LOGIN_SMS + bo.getTel();
|
|
|
+ String code = redisCache.getCacheObject(key);
|
|
|
+ if(code==null){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ if(!code.equals(bo.getCode())){
|
|
|
+ throw new CustomException("验证码错误");
|
|
|
+ }
|
|
|
+ redisCache.deleteObject(key);
|
|
|
+
|
|
|
+ if (bo.getType() != 1){
|
|
|
+ throw new CustomException("登录错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<User> userList = baseMapper.getUserByTel(bo.getTel());
|
|
|
+ if (CollectionUtils.isEmpty(userList)){
|
|
|
+ throw new CustomException("账号不存在!请检查");
|
|
|
+ }
|
|
|
+ //参数解析
|
|
|
+ String param = new String(Base64.decode(bo.getParam()));
|
|
|
+ if (StringUtils.isBlank(param)){
|
|
|
+ throw new CustomException("参数为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> split = Splitter.on("&").withKeyValueSeparator("=").split(param);
|
|
|
+ Long goodsId = Long.valueOf(split.get("gid"));
|
|
|
+
|
|
|
+ //获取对应商品
|
|
|
+ Goods goods = iGoodsService.getGoodsByIdNotTenant(goodsId);
|
|
|
+
|
|
|
+ User user = userList.stream().filter(item -> {
|
|
|
+ //判断用户是否购买商品
|
|
|
+ Long count = baseMapper.getUserOrderCount(item.getUserId(), item.getTenantId(), goods.getCode(), goods.getGoodsName());
|
|
|
+ return count > 0;
|
|
|
+ }).findFirst().orElse(null);
|
|
|
+
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("登录信息错误");
|
|
|
+ }
|
|
|
+ else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
|
|
+ {
|
|
|
+ throw new BaseException("对不起,您的账号:已停用");
|
|
|
+ }
|
|
|
+
|
|
|
+ Long tenantId = user.getTenantId();
|
|
|
+ //组装跳转路径
|
|
|
+ SysTenant tenant = iSysTenantService.getById(tenantId);
|
|
|
+ String post = "";
|
|
|
+ String path = "";
|
|
|
+ switch (bo.getUrlType()){
|
|
|
+ case 1://H5
|
|
|
+ post = tenant.getHostH5();
|
|
|
+ path = "pages/webview/index";
|
|
|
+ break;
|
|
|
+ case 2://PC
|
|
|
+ post = tenant.getHostPc();
|
|
|
+ path = "living-room";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ String cid = split.get("cid");
|
|
|
+ String sid = split.get("sid");
|
|
|
+ Course course = iCourseService.getCourseByNotTenant(Long.valueOf(cid));
|
|
|
+ Long courseId = iCourseService.getCourseByTenantTwo(course.getCourseName(),course.getCode(),tenantId);
|
|
|
+ CourseSection section = iCourseSectionService.getSectionByNotTenant(Long.valueOf(sid));
|
|
|
+ CourseSection courseSection = iCourseSectionService.getSectionByTenantTwo(section.getName(),section.getCode(),tenantId);
|
|
|
+ Goods goodsTwo = iGoodsService.getGoodsByTenantTwo(goods.getGoodsName(),goods.getCode(),tenantId);
|
|
|
+
|
|
|
+ String url = "";
|
|
|
+ switch (bo.getUrlType()){
|
|
|
+ case 1://H5
|
|
|
+ String format1 = String.format("cid=%s&gid=%s&sid=%s&a=1", courseId, goodsTwo.getGoodsId(), courseSection.getSectionId());
|
|
|
+ String s1 = Base64.encode(format1);
|
|
|
+ url = String.format("%s/%s/%s?scene=%s",liveGotoURL, post,path, s1);
|
|
|
+ break;
|
|
|
+ case 2://Pc
|
|
|
+ String format = String.format("cid=%s&gid=%s&sid=%s", courseId, goodsTwo.getGoodsId(), courseSection.getSectionId());
|
|
|
+ String s = Base64.encode(format);
|
|
|
+ url = String.format("%s/%s/%s/%s?a=1&%s",liveGotoURL, post,path,courseSection.getLiveUrl(), s);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserLiveAccountLoginVo vo = new UserLiveAccountLoginVo();
|
|
|
+ vo.setTel(user.getTelphone());
|
|
|
+ vo.setUser_account(user.getUserAccount());
|
|
|
+ vo.setUrl(url);
|
|
|
+ vo.setTenantId(tenantId);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UserLiveAccountLoginVo liveUnifyLoginRefresh(UserLiveAccountLoginBo bo) {
|
|
|
+ if(Validator.isEmpty(bo.getUser_account())){
|
|
|
+ throw new CustomException("账号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ User user = baseMapper.getUserByAccount(bo.getUser_account());
|
|
|
+ if(Validator.isEmpty(user)){
|
|
|
+ throw new CustomException("登录信息错误");
|
|
|
+ }
|
|
|
+ else if (UserStatus.DISABLE.getCode().equals(user.getStatus()))
|
|
|
+ {
|
|
|
+ throw new BaseException("对不起,您的账号:已停用");
|
|
|
+ }
|
|
|
+ //参数解析
|
|
|
+ String param = new String(Base64.decode(bo.getParam()));
|
|
|
+ if (StringUtils.isBlank(param)){
|
|
|
+ throw new CustomException("参数为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, String> split = Splitter.on("&").withKeyValueSeparator("=").split(param);
|
|
|
+ Long goodsId = Long.valueOf(split.get("gid"));
|
|
|
+
|
|
|
+ //获取对应商品
|
|
|
+ Goods goods = iGoodsService.getGoodsByIdNotTenant(goodsId);
|
|
|
+
|
|
|
+ Long tenantId = user.getTenantId();
|
|
|
+ //组装跳转路径
|
|
|
+ SysTenant tenant = iSysTenantService.getById(tenantId);
|
|
|
+ String post = "";
|
|
|
+ String path = "";
|
|
|
+ switch (bo.getUrlType()){
|
|
|
+ case 1://H5
|
|
|
+ post = tenant.getHostH5();
|
|
|
+ path = "pages/webview/index";
|
|
|
+ break;
|
|
|
+ case 2://PC
|
|
|
+ post = tenant.getHostPc();
|
|
|
+ path = "living-room";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ String cid = split.get("cid");
|
|
|
+ String sid = split.get("sid");
|
|
|
+ Course course = iCourseService.getCourseByNotTenant(Long.valueOf(cid));
|
|
|
+ Long courseId = iCourseService.getCourseByTenantTwo(course.getCourseName(),course.getCode(),tenantId);
|
|
|
+ CourseSection section = iCourseSectionService.getSectionByNotTenant(Long.valueOf(sid));
|
|
|
+ CourseSection courseSection = iCourseSectionService.getSectionByTenantTwo(section.getName(),section.getCode(),tenantId);
|
|
|
+ Goods goodsTwo = iGoodsService.getGoodsByTenantTwo(goods.getGoodsName(),goods.getCode(),tenantId);
|
|
|
+
|
|
|
+ String url = "";
|
|
|
+ switch (bo.getUrlType()){
|
|
|
+ case 1://H5
|
|
|
+ String format1 = String.format("cid=%s&gid=%s&sid=%s&a=1", courseId, goodsTwo.getGoodsId(), courseSection.getSectionId());
|
|
|
+ String s1 = Base64.encode(format1);
|
|
|
+ url = String.format("%s/%s/%s?scene=%s",liveGotoURL, post,path, s1);
|
|
|
+ break;
|
|
|
+ case 2://Pc
|
|
|
+ String format = String.format("cid=%s&gid=%s&sid=%s", courseId, goodsTwo.getGoodsId(), courseSection.getSectionId());
|
|
|
+ String s = Base64.encode(format);
|
|
|
+ url = String.format("%s/%s/%s/%s?a=1&%s",liveGotoURL, post,path,courseSection.getLiveUrl(), s);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserLiveAccountLoginVo vo = new UserLiveAccountLoginVo();
|
|
|
+ vo.setTel(user.getTelphone());
|
|
|
+ vo.setUser_account(user.getUserAccount());
|
|
|
+ vo.setUrl(url);
|
|
|
+ vo.setTenantId(tenantId);
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Map<String, Object> accountLogin(UserAppAccountLoginBo bo) {
|
|
|
if(Validator.isEmpty(bo.getAccount())){
|