mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
CRM-客户: 完善一些 TODO
This commit is contained in:
parent
3170e7fd97
commit
68f5edaa88
@ -6,6 +6,7 @@ import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
|
||||
/**
|
||||
@ -121,4 +122,8 @@ public class LocalDateTimeUtils {
|
||||
return date.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
|
||||
}
|
||||
|
||||
public static Long between(LocalDateTime dateTime) {
|
||||
return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,12 +3,15 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
@ -35,8 +38,7 @@ import java.util.stream.Stream;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CUSTOMER_TYPE;
|
||||
@ -49,7 +51,8 @@ public class CrmCustomerController {
|
||||
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
|
||||
@Resource
|
||||
private CrmCustomerPoolConfigService customerPoolConfigService;
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
@Resource
|
||||
@ -109,11 +112,28 @@ public class CrmCustomerController {
|
||||
}
|
||||
|
||||
// 2. 拼接数据
|
||||
// TODO @puhui999:距离进入公海的时间
|
||||
// 距离进入公海的时间
|
||||
Map<Long, Long> poolDayMap = getPoolDayMap(pageResult);
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
|
||||
convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId())));
|
||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
|
||||
return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap));
|
||||
return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap));
|
||||
}
|
||||
|
||||
private Map<Long, Long> getPoolDayMap(PageResult<CrmCustomerDO> pageResult) {
|
||||
Map<Long, Long> poolDayMap = null;
|
||||
CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig();
|
||||
if (customerPoolConfig != null && customerPoolConfig.getEnabled()) { // 有公海配置的情况
|
||||
poolDayMap = convertMap(pageResult.getList(), CrmCustomerDO::getId, item -> {
|
||||
long dealExpireDay = 0;
|
||||
if (!item.getDealStatus()) { // 检查是否成交
|
||||
dealExpireDay = customerPoolConfig.getDealExpireDays() - LocalDateTimeUtils.between(item.getCreateTime());
|
||||
}
|
||||
long contactExpireDay = customerPoolConfig.getContactExpireDays() - LocalDateTimeUtils.between(item.getContactLastTime());
|
||||
return dealExpireDay == 0 ? contactExpireDay : Math.min(dealExpireDay, contactExpireDay);
|
||||
});
|
||||
}
|
||||
return poolDayMap;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/list-all-simple")
|
||||
|
@ -132,4 +132,7 @@ public class CrmCustomerRespVO {
|
||||
@ExcelProperty("创建人名字")
|
||||
private String creatorName;
|
||||
|
||||
@Schema(description = "距离加入公海时间", example = "1")
|
||||
private Long poolDay;
|
||||
|
||||
}
|
||||
|
@ -103,7 +103,6 @@ public class CrmPermissionController {
|
||||
// 拼接数据
|
||||
List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertSet(permission, CrmPermissionDO::getUserId));
|
||||
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userList, AdminUserRespDTO::getDeptId));
|
||||
// TODO @puhui999:可能 postIds 为空的时候,会导致报错,看看怎么 fix 下
|
||||
Set<Long> postIds = CollectionUtils.convertSetByFlatMap(userList, AdminUserRespDTO::getPostIds, Collection::stream);
|
||||
Map<Long, PostRespDTO> postMap = postApi.getPostMap(postIds);
|
||||
return success(CrmPermissionConvert.INSTANCE.convert(permission, userList, deptMap, postMap));
|
||||
|
@ -38,9 +38,9 @@ public interface CrmCustomerConvert {
|
||||
/**
|
||||
* 设置用户信息
|
||||
*
|
||||
* @param customer CRM 客户 Response VO
|
||||
* @param userMap 用户信息 map
|
||||
* @param deptMap 用户部门信息 map
|
||||
* @param customer CRM 客户 Response VO
|
||||
* @param userMap 用户信息 map
|
||||
* @param deptMap 用户部门信息 map
|
||||
*/
|
||||
static void setUserInfo(CrmCustomerRespVO customer, Map<Long, AdminUserRespDTO> userMap, Map<Long, DeptRespDTO> deptMap) {
|
||||
customer.setAreaName(AreaUtils.format(customer.getAreaId()));
|
||||
@ -66,9 +66,12 @@ public interface CrmCustomerConvert {
|
||||
}
|
||||
|
||||
default PageResult<CrmCustomerRespVO> convertPage(PageResult<CrmCustomerDO> pageResult, Map<Long, AdminUserRespDTO> userMap,
|
||||
Map<Long, DeptRespDTO> deptMap) {
|
||||
Map<Long, DeptRespDTO> deptMap, Map<Long, Long> poolDayMap) {
|
||||
PageResult<CrmCustomerRespVO> result = convertPage(pageResult);
|
||||
result.getList().forEach(item -> setUserInfo(item, userMap, deptMap));
|
||||
result.getList().forEach(item -> {
|
||||
setUserInfo(item, userMap, deptMap);
|
||||
findAndThen(poolDayMap, item.getId(), item::setPoolDay);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.permission;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.permission.vo.CrmPermissionCreateReqVO;
|
||||
@ -15,6 +16,7 @@ import com.google.common.collect.Multimaps;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -50,6 +52,10 @@ public interface CrmPermissionConvert {
|
||||
item.setDeptName(deptRespDTO.getName());
|
||||
});
|
||||
List<PostRespDTO> postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds());
|
||||
if (CollUtil.isEmpty(postRespList)) {
|
||||
item.setPostNames(Collections.emptySet());
|
||||
return;
|
||||
}
|
||||
item.setPostNames(CollectionUtils.convertSet(postRespList, PostRespDTO::getName));
|
||||
});
|
||||
return item;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.system.api.dept;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.PostRespDTO;
|
||||
|
||||
@ -26,6 +28,10 @@ public interface PostApi {
|
||||
List<PostRespDTO> getPostList(Collection<Long> ids);
|
||||
|
||||
default Map<Long, PostRespDTO> getPostMap(Collection<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return MapUtil.empty();
|
||||
}
|
||||
|
||||
List<PostRespDTO> list = getPostList(ids);
|
||||
return CollectionUtils.convertMap(list, PostRespDTO::getId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user