|
@@ -2,11 +2,11 @@ package com.fs.store.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.fs.common.constant.HttpStatus;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.ResponseResult;
|
|
|
+import com.fs.common.core.domain.entity.SysDictData;
|
|
|
import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.DictUtils;
|
|
@@ -31,21 +31,23 @@ import com.fs.course.vo.newfs.FsCourseAnalysisCountVO;
|
|
|
import com.fs.course.vo.newfs.FsCourseAnalysisVO;
|
|
|
import com.fs.course.vo.newfs.FsUserCourseVideoPageListVO;
|
|
|
import com.fs.his.vo.OptionsVO;
|
|
|
-import com.fs.qw.cache.IQwExternalContactCacheService;
|
|
|
-import com.fs.qw.mapper.QwExternalContactMapper;
|
|
|
-import com.fs.qw.mapper.QwSessionMapper;
|
|
|
import com.fs.qw.param.QwFsUserParam;
|
|
|
import com.fs.qw.vo.QwFsUserVO;
|
|
|
import com.fs.store.domain.*;
|
|
|
import com.fs.store.dto.FsStoreCartDTO;
|
|
|
import com.fs.store.dto.FsUserTransferParamDTO;
|
|
|
import com.fs.store.enums.BillDetailEnum;
|
|
|
-import com.fs.store.mapper.*;
|
|
|
+import com.fs.store.mapper.FsStoreOrderMapper;
|
|
|
+import com.fs.store.mapper.FsStoreProductAttrValueMapper;
|
|
|
+import com.fs.store.mapper.FsUserCourseCountMapper;
|
|
|
+import com.fs.store.mapper.FsUserMapper;
|
|
|
import com.fs.store.param.SelectCusListPageParam;
|
|
|
import com.fs.store.param.h5.CourseAnalysisParam;
|
|
|
import com.fs.store.param.h5.FsUserPageListParam;
|
|
|
import com.fs.store.param.h5.UserStatisticsCommonParam;
|
|
|
import com.fs.store.service.IFsUserBillService;
|
|
|
+import com.fs.store.service.IFsUserCompanyUserService;
|
|
|
+import com.fs.store.service.IFsUserProjectTagService;
|
|
|
import com.fs.store.service.IFsUserService;
|
|
|
import com.fs.store.service.cache.IFsUserCourseCountCacheService;
|
|
|
import com.fs.store.vo.FSUserVO;
|
|
@@ -53,6 +55,7 @@ import com.fs.store.vo.FsCompanyUserListQueryVO;
|
|
|
import com.fs.store.vo.FsUserLastCount;
|
|
|
import com.fs.store.vo.FsUserTuiVO;
|
|
|
import com.fs.store.vo.h5.*;
|
|
|
+import com.fs.system.mapper.SysDictDataMapper;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -118,24 +121,23 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
private ICompanyTagCacheService companyTagCacheService;
|
|
|
|
|
|
@Autowired
|
|
|
- private IQwExternalContactCacheService qwExternalContactCacheService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private FsUserCompanyUserMapper fsUserCompanyUserMapper;
|
|
|
+ private IFsUserCompanyUserService userCompanyUserService;
|
|
|
|
|
|
@Autowired
|
|
|
private ICompanyTagService companyTagService;
|
|
|
|
|
|
@Autowired
|
|
|
CompanyTagMapper companyTagMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
- private QwSessionMapper qwSessionMapper;
|
|
|
- @Autowired
|
|
|
- private QwExternalContactMapper qwExternalContactMapper;
|
|
|
+ private SysDictDataMapper dictDataMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private FsUserCourseCountMapper fsUserCourseCountMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IFsUserProjectTagService userProjectTagService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询用户
|
|
|
*
|
|
@@ -257,12 +259,6 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
fsUser.setStatusText("正常");
|
|
|
}
|
|
|
}
|
|
|
- if(ObjectUtils.isNotNull(fsUser.getCompanyUserId())){
|
|
|
- CompanyUser companyUser = companyUserCacheService.selectCompanyUserById(fsUser.getCompanyUserId());
|
|
|
- if(ObjectUtils.isNotNull(companyUser)){
|
|
|
- fsUser.setCompanyUserName(String.format("%s_%d",companyUser.getUserName(),companyUser.getUserId()));
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
TableDataInfo tableDataInfo = new TableDataInfo();
|
|
|
tableDataInfo.setRows(fsUsers);
|
|
@@ -481,7 +477,6 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<FsUserPageListVO> selectFsUserPageList(FsUserPageListParam param) {
|
|
|
-// System.out.println("参数:" + Arrays.toString(param.getTagIds()));
|
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserById(param.getUserId());
|
|
|
if (companyUser!=null && companyUser.isAdmin()){
|
|
|
param.setUserId(0L);
|
|
@@ -503,7 +498,14 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
}
|
|
|
List<FsUserPageListVO> fsUserPageListVOS = fsUserMapper.selectFsUserPageList(param);
|
|
|
|
|
|
+
|
|
|
+ List<SysDictData> courseProject = dictDataMapper.selectDictDataByType("sys_course_project");
|
|
|
for (FsUserPageListVO fsUserPageListVO : fsUserPageListVOS) {
|
|
|
+ // 项目
|
|
|
+ courseProject.stream()
|
|
|
+ .filter(c -> c.getDictValue().equals(fsUserPageListVO.getProjectId().toString()))
|
|
|
+ .findFirst()
|
|
|
+ .ifPresent(c -> fsUserPageListVO.setProjectName(c.getDictLabel()));
|
|
|
if (StringUtils.isEmpty(fsUserPageListVO.getNickname())){
|
|
|
fsUserPageListVO.setNickname("用户暂未授权昵称");
|
|
|
}
|
|
@@ -511,29 +513,6 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
|
|
|
return new PageInfo<>(fsUserPageListVOS);
|
|
|
|
|
|
- // 获取当前销售所有重粉会员
|
|
|
-// List<FsUserCompanyUser> fsUserCompanyUsers = fsUserCompanyUserMapper.selectRepeatUser(param.getUserId());
|
|
|
-
|
|
|
-// if(!fsUserCompanyUsers.isEmpty()){
|
|
|
-// List<Long> userIds = fsUserCompanyUsers.stream().map(FsUserCompanyUser::getUserId).collect(Collectors.toList());
|
|
|
-// // 获取会员所属的重粉销售
|
|
|
-// List<FsUserCompanyUser> repeatCompanyUserNames = fsUserCompanyUserMapper.selectRepeatCompanyUserName(userIds);
|
|
|
-// Map<Long, String> map = repeatCompanyUserNames.stream().collect(Collectors.toMap(FsUserCompanyUser::getUserId, FsUserCompanyUser::getRepeatCompanyUserName));
|
|
|
-//
|
|
|
-// for (FsUserPageListVO fsUserPageListVO : fsUserPageListVOS) {
|
|
|
-// fsUserPageListVO.setRepeatCompanyUserName(map.get(fsUserPageListVO.getUserId()));
|
|
|
-// if ("微信用户".equals(fsUserPageListVO.getNickname()) && StringUtils.isNotEmpty(fsUserPageListVO.getPhone())) {
|
|
|
-// fsUserPageListVO.setNickname(fsUserPageListVO.getPhone());
|
|
|
-// }
|
|
|
-// if(StringUtils.isNotEmpty(fsUserPageListVO.getTag()) && fsUserPageListVO.getIsRepeatFans() == 0){
|
|
|
-// StringBuilder newTag = removeRepeatFansTag(fsUserPageListVO);
|
|
|
-// fsUserPageListVO.setTag(newTag.toString());
|
|
|
-// }
|
|
|
-// }
|
|
|
-// return new PageInfo<>(fsUserPageListVOS);
|
|
|
-// } else {
|
|
|
-// return new PageInfo<>(fsUserPageListVOS);
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
private static StringBuilder removeRepeatFansTag(FsUserPageListVO fsUserPageListVO) {
|
|
@@ -659,24 +638,28 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
}
|
|
|
List<UserListCountVO> list = fsUserMapper.getUserNumber(userId, companyId);
|
|
|
Map<String, Integer> map = list.stream()
|
|
|
- .collect(Collectors.toMap(UserListCountVO::getStatus, UserListCountVO::getNum, (v1, v2) -> v1));
|
|
|
+ .collect(Collectors.toMap(UserListCountVO::getStatus, UserListCountVO::getNum, (v1, v2) -> v1 + v2));
|
|
|
UserListPageVO pageVO = new UserListPageVO();
|
|
|
Integer normalNum = map.getOrDefault("1", 0);
|
|
|
- Integer blackNum = map.getOrDefault("0", 0);
|
|
|
+ Integer smallBlackNum = map.getOrDefault("0", 0);
|
|
|
+ Integer blackNum = map.getOrDefault("2", 0);
|
|
|
|
|
|
// 黑名单人数加上重粉的数量,正常人数去掉重粉数量
|
|
|
int repeatUserNumber = fsUserMapper.getRepeatUserNumber(userId);
|
|
|
pageVO.setNumber(normalNum - repeatUserNumber);
|
|
|
pageVO.setBlackNum(blackNum + repeatUserNumber);
|
|
|
+ pageVO.setSmallBlackNum(smallBlackNum + repeatUserNumber);
|
|
|
|
|
|
return pageVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public UserDetailsVO getUserDetails(Long userId, Long fsUserId, String dateTag) {
|
|
|
- UserDetailsVO countWatchCourse = fsUserMapper.getCountWatchCourse(userId, fsUserId, dateTag);
|
|
|
- UserDetailsVO countAnswer = fsUserMapper.getCountAnswer(userId, fsUserId, dateTag);
|
|
|
- UserDetailsVO countRedPacket = fsUserMapper.getCountRedPacket(userId, fsUserId, dateTag);
|
|
|
+ public UserDetailsVO getUserDetails(Long userId, Long fsUserId, String dateTag, Long userCompanyId) {
|
|
|
+ UserDetailsVO countWatchCourse = fsUserMapper.getCountWatchCourse(userId, fsUserId, dateTag,userCompanyId);
|
|
|
+ FsUserCompanyUser fsUserCompanyUser = userCompanyUserService.selectFsUserCompanyUserById(userCompanyId);
|
|
|
+
|
|
|
+ UserDetailsVO countAnswer = fsUserMapper.getCountAnswer(fsUserCompanyUser.getCompanyUserId(), fsUserId, dateTag);
|
|
|
+ UserDetailsVO countRedPacket = fsUserMapper.getCountRedPacket(fsUserCompanyUser.getCompanyUserId(), fsUserId, dateTag);
|
|
|
UserDetailsVO vo = new UserDetailsVO();
|
|
|
if (countWatchCourse != null){
|
|
|
BeanUtils.copyProperties(countWatchCourse, vo);
|
|
@@ -1012,56 +995,27 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
return ResponseResult.fail(407,"不允许注册会员,请联系管理员");
|
|
|
}
|
|
|
|
|
|
- //2025.7.10 解决在不知销售已经审核的情况下 多次点击
|
|
|
- if (fsUser.getIsBecomeMember() == 1){
|
|
|
- if(fsUser.getStatus() == 0){
|
|
|
- //禁用
|
|
|
- return ResponseResult.fail(402, "已成功注册,待管理审核");
|
|
|
- } else {
|
|
|
- return ResponseResult.ok(Boolean.TRUE); //已经成为会员
|
|
|
- }
|
|
|
- }
|
|
|
- fsUser.setIsBecomeMember(1);
|
|
|
-
|
|
|
- // 添加关系表数据
|
|
|
- FsUserCompanyUser fsUserCompanyUser = getFsUserCompanyUser(param, fsUser);
|
|
|
- QueryWrapper<FsUserCompanyUser> queryWrapper = new QueryWrapper<FsUserCompanyUser>().eq("user_id", param.getUserId()).eq("company_user_id", param.getCompanyUserId());
|
|
|
- Integer i = fsUserCompanyUserMapper.selectCount(queryWrapper);
|
|
|
- if(i == 0) {
|
|
|
- fsUserCompanyUserMapper.insertFsUserCompanyUser(fsUserCompanyUser);
|
|
|
+ // 逻辑调整:如果会员已经绑定了销售,直接提示,不添加重粉数据了-2025年6月16日14点53分
|
|
|
+ // 逻辑调整:会员与销售的绑定关系通过中间表关联 /20250625 17:13
|
|
|
+ FsUserCompanyUser userCompanyUser = userCompanyUserService.selectByUserIdAndProjectId(fsUser.getUserId(), param.getProjectId());
|
|
|
+ if (Objects.nonNull(userCompanyUser) && !userCompanyUser.getCompanyUserId().equals(param.getCompanyUserId())){
|
|
|
+ return ResponseResult.fail(406,"该用户已成为其他销售会员");
|
|
|
}
|
|
|
|
|
|
- // 关联销售
|
|
|
- if(fsUser.getCompanyUserId() == null) {
|
|
|
- fsUser.setCompanyId(param.getCompanyId());
|
|
|
- fsUser.setCompanyUserId(param.getCompanyUserId());
|
|
|
- }
|
|
|
// 特殊(需求设计:需要根据公司是否开启黑名单来设置会员初始化的状态)
|
|
|
- Company company = null;
|
|
|
- if(param.getCompanyId() != null) {
|
|
|
- company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
- }
|
|
|
+ Company company = companyMapper.selectCompanyById(param.getCompanyId());
|
|
|
// isDefaultBlack 值为1 ,表示需要加入小黑屋,否则不加
|
|
|
int isDefaultBlack = company != null ? company.getFsUserIsDefaultBlack() : 0;
|
|
|
- fsUser.setStatus(isDefaultBlack == 1 ? 0 : 1);
|
|
|
- fsUserMapper.updateFsUser(fsUser);
|
|
|
+
|
|
|
+ // 添加关系表数据
|
|
|
+ if (Objects.isNull(userCompanyUser)){
|
|
|
+ int defaultStatus = isDefaultBlack == 1 ? 0 : 1;
|
|
|
+ userCompanyUser = userCompanyUserService.bindRelationship(param.getUserId(), param.getProjectId(), companyUser.getCompanyId(), companyUser.getUserId(), defaultStatus);
|
|
|
+ }
|
|
|
|
|
|
// 不为空则添加新标签
|
|
|
if (Objects.nonNull(param.getTagIds()) && param.getTagIds().length > 0) {
|
|
|
- //关联会员标签,先删除再新增
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("userId", param.getUserId());
|
|
|
- map.put("companyId", fsUser.getCompanyId());
|
|
|
- map.put("companyUserId", fsUser.getCompanyUserId());
|
|
|
- companyTagUserMapper.deleteCompanyTagUserByMap(map);
|
|
|
-
|
|
|
- CompanyTagUser companyTagUser = new CompanyTagUser();
|
|
|
- companyTagUser.setUserId(param.getUserId());
|
|
|
- companyTagUser.setCompanyId(fsUser.getCompanyId());
|
|
|
- companyTagUser.setCompanyUserId(fsUser.getCompanyUserId());
|
|
|
- companyTagUser.setTagIds(String.join(",", param.getTagIds()));
|
|
|
- companyTagUser.setCreateTime(new Date());
|
|
|
- companyTagUserMapper.insertCompanyTagUser(companyTagUser);
|
|
|
+ userProjectTagService.addUserProjectTag(userCompanyUser.getId(), Arrays.stream(param.getTagIds()).map(Long::valueOf).collect(Collectors.toList()));
|
|
|
}
|
|
|
|
|
|
// // 如果是重粉,直接打上重粉的标签
|
|
@@ -1114,19 +1068,9 @@ public class FsUserServiceImpl implements IFsUserService
|
|
|
return fsUserMapper.selectFsUserListByJointUserNameKey(userNameKey);
|
|
|
}
|
|
|
|
|
|
- // 添加关系表数据
|
|
|
- private static FsUserCompanyUser getFsUserCompanyUser(FsUserCourseBeMemberParam param, FsUser fsUser) {
|
|
|
- FsUserCompanyUser fsUserCompanyUser = new FsUserCompanyUser();
|
|
|
- // 判断是否绑定了销售,如果已绑定,则需要标识为重粉,且放黑名单
|
|
|
- if (fsUser.getCompanyUserId() != null && !fsUser.getCompanyUserId().equals(param.getCompanyUserId())) {
|
|
|
- fsUserCompanyUser.setIsRepeatFans(1);
|
|
|
- } else {
|
|
|
- fsUserCompanyUser.setIsRepeatFans(0);
|
|
|
- }
|
|
|
- fsUserCompanyUser.setUserId(param.getUserId());
|
|
|
- fsUserCompanyUser.setCompanyId(param.getCompanyId());
|
|
|
- fsUserCompanyUser.setCompanyUserId(param.getCompanyUserId());
|
|
|
- return fsUserCompanyUser;
|
|
|
+ @Override
|
|
|
+ public List<FSUserVO> selectFsUserVOListByProject(FsUser fsUser) {
|
|
|
+ return fsUserMapper.selectFsUserVOListByProject(fsUser);
|
|
|
}
|
|
|
|
|
|
/**
|