|
|
@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.constant.HttpStatus;
|
|
|
+import com.fs.common.core.domain.AjaxResult;
|
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.domain.ResponseResult;
|
|
|
import com.fs.common.core.domain.entity.SysDictData;
|
|
|
@@ -31,6 +32,7 @@ import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.DictUtils;
|
|
|
import com.fs.common.utils.ParseUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
+import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.company.cache.ICompanyTagCacheService;
|
|
|
import com.fs.company.cache.ICompanyUserCacheService;
|
|
|
import com.fs.company.domain.*;
|
|
|
@@ -80,6 +82,7 @@ import com.fs.qw.param.QwFsUserParam;
|
|
|
import com.fs.qw.vo.QwFsUserVO;
|
|
|
import com.fs.store.domain.FsUserCourseCount;
|
|
|
import com.fs.store.mapper.FsUserCourseCountMapper;
|
|
|
+import com.fs.store.param.h5.FsUserPageListExportParam;
|
|
|
import com.fs.store.param.h5.FsUserPageListParam;
|
|
|
import com.fs.store.param.h5.UserStatisticsCommonParam;
|
|
|
import com.fs.store.service.cache.IFsUserCourseCountCacheService;
|
|
|
@@ -196,6 +199,8 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
private FsPatientMapper fsPatientMapper;
|
|
|
@Autowired
|
|
|
private FsCourseWatchLogMapper courseWatchLogMapper;
|
|
|
+ @Autowired
|
|
|
+ FsExportTaskMapper fsExportTaskMapper;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -1619,4 +1624,137 @@ public class FsUserServiceImpl implements IFsUserService {
|
|
|
return fsUserMapper.selectFsUserListByPhone(phone);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 项目会员导出数据条数查询
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Long selectProjectUserExportCount(FsUserPageListExportParam param) {
|
|
|
+ return fsUserMapper.selectProjectUserExportCount(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 项目会员导出
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public void exportProjectUserData(FsUserPageListExportParam param) {
|
|
|
+ // 找出下级销售
|
|
|
+ String companyUserId = param.getCompanyUserId();
|
|
|
+ if (StringUtils.isNotBlank(companyUserId)) {
|
|
|
+ Long companyUser = Long.parseLong(companyUserId);
|
|
|
+ Set<Long> userIds = companyUserCacheService.selectUserAllCompanyUserId(companyUser);
|
|
|
+ if (userIds != null || userIds.size() <= 1) {
|
|
|
+ if (param.getIsAdmin() != null && param.getIsAdmin()) {
|
|
|
+ List<CompanyUser> companyUsers = companyUserMapper.selectCompanyUserByCompanyId(param.getCompanyId());
|
|
|
+ userIds = companyUsers.stream().map(CompanyUser::getUserId).collect(Collectors.toSet());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ param.setCompanyUserIds(userIds);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<FsUserPageListExportVO> fsUserPageListVOS = fsUserMapper.FsUserPageListExportVO(param);
|
|
|
+ Map<Long, CompanyTag> tagMap = companyTagCacheService.queryAllTagMap();
|
|
|
+ //获取会员的最新的看课状态和最后看课时间
|
|
|
+ Set<Long> userIds = fsUserPageListVOS.stream().map(FsUserPageListExportVO::getUserId).collect(Collectors.toSet());
|
|
|
+ List<FsUserLastCount> fsUserCourseCounts = Collections.emptyList();
|
|
|
+ if (!userIds.isEmpty()) {
|
|
|
+ fsUserCourseCounts = fsUserCourseCountMapper.selectUserLastCount(userIds);
|
|
|
+ }
|
|
|
+ Map<Long, FsUserLastCount> countMap = fsUserCourseCounts.stream().collect(Collectors.toMap(FsUserLastCount::getUserId, Function.identity()));
|
|
|
+
|
|
|
+ List<UserProjectPair> pairs = fsUserPageListVOS.stream()
|
|
|
+ .map(user -> new UserProjectPair(user.getUserId(), user.getProjectId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ Map<Object, Date> watchTimeMap = new HashMap<>();
|
|
|
+ if(CollectionUtils.isNotEmpty(pairs)){
|
|
|
+ List<Map<String, Object>> mapList = fsUserMapper.selectLastWatchTimeByUserAndProject(pairs);
|
|
|
+ if (!CollectionUtils.isEmpty(mapList)) {
|
|
|
+ watchTimeMap = mapList.stream()
|
|
|
+ .collect(HashMap::new,
|
|
|
+ (map, item) -> map.put(
|
|
|
+ item.get("userProjectKey"),
|
|
|
+ (Date) item.get("lastWatchTime")
|
|
|
+ ),
|
|
|
+ HashMap::putAll
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (FsUserPageListExportVO item : fsUserPageListVOS) {
|
|
|
+ if (item.getCompanyUserId() != null) {
|
|
|
+ String companyUserName = companyUserCacheService.selectCompanyUserNameUserById(item.getCompanyUserId());
|
|
|
+ if (companyUserName != null) {
|
|
|
+ item.setCompanyUserNickName(companyUserName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.getPhone() != null) {
|
|
|
+ item.setPhone(ParseUtils.parsePhone(item.getPhone()));
|
|
|
+ }
|
|
|
+ if (item.getStatus() != null) {
|
|
|
+ String userStatus = DictUtils.getDictLabel("user_status", String.valueOf(item.getStatus()));
|
|
|
+ if (StringUtils.isNotBlank(userStatus)) {
|
|
|
+ item.setStatusText(userStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item.getUserId() != null) {
|
|
|
+ FsUserCourseCount byUserId = fsUserCourseCountCacheService.findByUserId(item.getUserId());
|
|
|
+ if (byUserId != null) {
|
|
|
+ item.setWatchCourseCount(byUserId.getWatchCourseCount());
|
|
|
+ item.setMissCourseCount(byUserId.getMissCourseCount());
|
|
|
+ item.setMissCourseStatus(byUserId.getMissCourseStatus());
|
|
|
+ if (StringUtils.isNotEmpty(byUserId.getPartCourseCount())) {
|
|
|
+ item.setPartCourseCount(new BigDecimal(byUserId.getPartCourseCount()).longValue());
|
|
|
+ }
|
|
|
+// item.setCourseCountStatus(byUserId.getStatus());
|
|
|
+ item.setStopWatchDays(byUserId.getStopWatchDays());
|
|
|
+ item.setCompleteWatchDate(byUserId.getCompleteWatchDate());
|
|
|
+ item.setLastWatchDate(watchTimeMap.getOrDefault(item.getUserId() + "_" + item.getProjectId(),null));
|
|
|
+ }
|
|
|
+ FsUserLastCount fsUserCourseCount = countMap.get(item.getUserId());
|
|
|
+ if (fsUserCourseCount != null) {
|
|
|
+ item.setCourseCountStatus(fsUserCourseCount.getStatus());
|
|
|
+ }
|
|
|
+ String userTagByUserId = companyTagCacheService
|
|
|
+ .findUserTagByUserId(item.getUserId(), item.getCompanyUserId());
|
|
|
+ if (StringUtils.isNotEmpty(userTagByUserId)) {
|
|
|
+ String[] split = userTagByUserId.split(",");
|
|
|
+ Set<String> tagNames = new HashSet<>();
|
|
|
+ for (String tag : split) {
|
|
|
+ if (StringUtils.isNotBlank(tag)) {
|
|
|
+ Long tagL = Long.parseLong(tag);
|
|
|
+ CompanyTag companyTag = tagMap.get(tagL);
|
|
|
+ if (companyTag != null) {
|
|
|
+ tagNames.add(companyTag.getTag());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setTagIds(userTagByUserId);
|
|
|
+ item.setTag(String.join(",", tagNames));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 是否宠粉
|
|
|
+// Integer isRepeat = qwExternalContactCacheService.selectQwIsRepeat(item.getUserId());
|
|
|
+// if(isRepeat != null) {
|
|
|
+// item.setIsRepeat(isRepeat);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 解密
|
|
|
+ if (item.getPhone() != null && item.getPhone() != "") {
|
|
|
+ if (item.getPhone().length() > 11) {
|
|
|
+ item.setPhone(decryptPhoneMk(item.getPhone()));
|
|
|
+ } else {
|
|
|
+ item.setPhone(item.getPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelUtil<FsUserPageListExportVO> util = new ExcelUtil<>(FsUserPageListExportVO.class);
|
|
|
+ AjaxResult result = util.exportExcel(fsUserPageListVOS, "项目会员");
|
|
|
+ FsExportTask task=fsExportTaskMapper.selectFsExportTaskByTaskId(param.getTaskId());
|
|
|
+ task.setFinishTime(new Date());
|
|
|
+ task.setStatus(1);
|
|
|
+ task.setFileUrl(result.get("msg").toString());
|
|
|
+ fsExportTaskMapper.updateFsExportTask(task);
|
|
|
+ }
|
|
|
+
|
|
|
}
|