mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 07:11:52 +08:00
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # yudao-module-mall/yudao-module-product-biz/src/main/java/cn/iocoder/yudao/module/product/controller/app/history/AppProductBrowseHistoryController.java
This commit is contained in:
commit
30fce2911f
@ -1,34 +0,0 @@
|
||||
CREATE TABLE product_statistics
|
||||
(
|
||||
id bigint AUTO_INCREMENT COMMENT '编号,主键自增' PRIMARY KEY,
|
||||
time date NOT NULL COMMENT '统计日期',
|
||||
spu_id bigint NOT NULL COMMENT '商品SPU编号',
|
||||
browse_count int DEFAULT 0 NOT NULL COMMENT '浏览量',
|
||||
browse_user_count int DEFAULT 0 NOT NULL COMMENT '访客量',
|
||||
favorite_count int DEFAULT 0 NOT NULL COMMENT '收藏数量',
|
||||
cart_count int DEFAULT 0 NOT NULL COMMENT '加购数量',
|
||||
order_count int DEFAULT 0 NOT NULL COMMENT '下单件数',
|
||||
order_pay_count int DEFAULT 0 NOT NULL COMMENT '支付件数',
|
||||
order_pay_price int DEFAULT 0 NOT NULL COMMENT '支付金额,单位:分',
|
||||
after_sale_count int DEFAULT 0 NOT NULL COMMENT '退款件数',
|
||||
after_sale_refund_price int DEFAULT 0 NOT NULL COMMENT '退款金额,单位:分',
|
||||
browse_convert_percent int DEFAULT 0 NOT NULL COMMENT '访客支付转化率(百分比)',
|
||||
creator varchar(64) DEFAULT '' NULL COMMENT '创建者',
|
||||
create_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL COMMENT '创建时间',
|
||||
updater varchar(64) DEFAULT '' NULL COMMENT '更新者',
|
||||
update_time datetime DEFAULT CURRENT_TIMESTAMP NOT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
deleted bit DEFAULT b'0' NOT NULL COMMENT '是否删除',
|
||||
tenant_id bigint DEFAULT 0 NOT NULL COMMENT '租户编号'
|
||||
)
|
||||
COMMENT '商品统计表';
|
||||
|
||||
CREATE INDEX idx_time
|
||||
ON product_statistics (time);
|
||||
|
||||
CREATE INDEX idx_spu_id
|
||||
ON product_statistics (spu_id);
|
||||
|
||||
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name, status, visible, keep_alive, always_show, creator, create_time, updater, update_time, deleted) VALUES ('商品统计', '', 2, 6, 2358, 'product', 'fa:product-hunt', 'statistics/product/index', 'ProductStatistics', 0, true, true, true, '', '2023-12-15 18:54:28', '', '2023-12-15 18:54:33', false);
|
||||
SELECT @parentId1 := LAST_INSERT_ID();
|
||||
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name, status, visible, keep_alive, always_show, creator, create_time, updater, update_time, deleted) VALUES ('商品统计查询', 'statistics:product:query', 3, 1, @parentId, '', '', '', null, 0, true, true, true, '', '2023-09-30 03:22:40', '', '2023-09-30 03:22:40', false);
|
||||
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name, status, visible, keep_alive, always_show, creator, create_time, updater, update_time, deleted) VALUES ('商品统计导出', 'statistics:product:export', 3, 2, @parentId, '', '', '', null, 0, true, true, true, '', '2023-09-30 03:22:40', '', '2023-09-30 03:22:40', false);
|
@ -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,9 @@ public class LocalDateTimeUtils {
|
||||
return date.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
|
||||
}
|
||||
|
||||
// TODO @puhui999:加下注释哈;
|
||||
public static Long between(LocalDateTime dateTime) {
|
||||
return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,15 @@
|
||||
package cn.iocoder.yudao.framework.common.util.object;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.func.Func1;
|
||||
import cn.hutool.core.lang.func.LambdaUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortablePageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortingField;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link cn.iocoder.yudao.framework.common.pojo.PageParam} 工具类
|
||||
@ -9,8 +18,50 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
*/
|
||||
public class PageUtils {
|
||||
|
||||
private static final Object[] ORDER_TYPES = new String[]{SortingField.ORDER_ASC, SortingField.ORDER_DESC};
|
||||
|
||||
public static int getStart(PageParam pageParam) {
|
||||
return (pageParam.getPageNo() - 1) * pageParam.getPageSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建排序字段(默认倒序)
|
||||
*
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param <T> 排序字段所属的类型
|
||||
* @return 排序字段
|
||||
*/
|
||||
public static <T> SortingField buildSortingField(Func1<T, ?> func) {
|
||||
return buildSortingField(func, SortingField.ORDER_DESC);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建排序字段
|
||||
*
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param order 排序类型 {@link SortingField#ORDER_ASC} {@link SortingField#ORDER_DESC}
|
||||
* @param <T> 排序字段所属的类型
|
||||
* @return 排序字段
|
||||
*/
|
||||
public static <T> SortingField buildSortingField(Func1<T, ?> func, String order) {
|
||||
Assert.isTrue(ArrayUtil.contains(ORDER_TYPES, order), String.format("字段的排序类型只能是 %s/%s", ORDER_TYPES));
|
||||
|
||||
String fieldName = LambdaUtil.getFieldName(func);
|
||||
return new SortingField(fieldName, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建默认的排序字段
|
||||
* 如果排序字段为空,则设置排序字段;否则忽略
|
||||
*
|
||||
* @param sortablePageParam 排序分页查询参数
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param <T> 排序字段所属的类型
|
||||
*/
|
||||
public static <T> void buildDefaultSortingField(SortablePageParam sortablePageParam, Func1<T, ?> func) {
|
||||
if (sortablePageParam != null && CollUtil.isEmpty(sortablePageParam.getSortingFields())) {
|
||||
sortablePageParam.setSortingFields(List.of(buildSortingField(func)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,7 @@
|
||||
package cn.iocoder.yudao.framework.mybatis.core.util;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.func.Func1;
|
||||
import cn.hutool.core.lang.func.LambdaUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortablePageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortingField;
|
||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
||||
@ -16,7 +11,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import net.sf.jsqlparser.expression.Alias;
|
||||
import net.sf.jsqlparser.schema.Column;
|
||||
import net.sf.jsqlparser.schema.Table;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -91,46 +85,4 @@ public class MyBatisUtils {
|
||||
return new Column(tableName + StringPool.DOT + column);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 构建排序字段(默认倒序)
|
||||
*
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param <T> 排序字段所属的类型
|
||||
* @return 排序字段
|
||||
*/
|
||||
public static <T> SortingField buildSortingField(Func1<T, ?> func) {
|
||||
return buildSortingField(func, SortingField.ORDER_DESC);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建排序字段
|
||||
*
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param order 排序类型 {@link SortingField#ORDER_ASC} {@link SortingField#ORDER_DESC}
|
||||
* @param <T> 排序字段所属的类型
|
||||
* @return 排序字段
|
||||
*/
|
||||
public static <T> SortingField buildSortingField(Func1<T, ?> func, String order) {
|
||||
Object[] orderTypes = {SortingField.ORDER_ASC, SortingField.ORDER_DESC};
|
||||
Assert.isTrue(ArrayUtil.contains(orderTypes, order), String.format("字段的排序类型只能是%s/%s", orderTypes));
|
||||
|
||||
String fieldName = LambdaUtil.getFieldName(func);
|
||||
return new SortingField(fieldName, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建默认的排序字段
|
||||
* 如果排序字段为空,则设置排序字段;否则忽略
|
||||
*
|
||||
* @param sortablePageParam 排序分页查询参数
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param <T> 排序字段所属的类型
|
||||
*/
|
||||
public static <T> void buildDefaultSortingField(SortablePageParam sortablePageParam, Func1<T, ?> func) {
|
||||
if (sortablePageParam != null && CollUtil.isEmpty(sortablePageParam.getSortingFields())) {
|
||||
sortablePageParam.setSortingFields(List.of(buildSortingField(func)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package cn.iocoder.yudao.framework.operatelog.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.service.ILogRecordServiceImpl;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.service.LogRecordServiceImpl;
|
||||
import com.mzt.logapi.service.ILogRecordService;
|
||||
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -21,7 +21,7 @@ public class YudaoOperateLogV2Configuration {
|
||||
@Bean
|
||||
@Primary
|
||||
public ILogRecordService iLogRecordServiceImpl() {
|
||||
return new ILogRecordServiceImpl();
|
||||
return new LogRecordServiceImpl();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,8 @@ package cn.iocoder.yudao.framework.operatelog.core.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2CreateReqDTO;
|
||||
import com.mzt.logapi.beans.LogRecord;
|
||||
@ -13,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// TODO @puhui999:LogRecordServiceImpl 改成这个名字哈
|
||||
/**
|
||||
* 操作日志 ILogRecordService 实现类
|
||||
*
|
||||
@ -22,7 +22,7 @@ import java.util.List;
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Slf4j
|
||||
public class ILogRecordServiceImpl implements ILogRecordService {
|
||||
public class LogRecordServiceImpl implements ILogRecordService {
|
||||
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
@ -46,9 +46,13 @@ public class ILogRecordServiceImpl implements ILogRecordService {
|
||||
}
|
||||
|
||||
private static void fillUserFields(OperateLogV2CreateReqDTO reqDTO) {
|
||||
// TODO @puhui999:使用 SecurityFrameworkUtils。因为要考虑,rpc、mq、job,它其实不是 web;
|
||||
reqDTO.setUserId(WebFrameworkUtils.getLoginUserId());
|
||||
reqDTO.setUserType(WebFrameworkUtils.getLoginUserType());
|
||||
// 使用 SecurityFrameworkUtils。因为要考虑,rpc、mq、job,它其实不是 web;
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return;
|
||||
}
|
||||
reqDTO.setUserId(loginUser.getId());
|
||||
reqDTO.setUserType(loginUser.getUserType());
|
||||
}
|
||||
|
||||
public static void fillModuleFields(OperateLogV2CreateReqDTO reqDTO, LogRecord logRecord) {
|
@ -24,6 +24,7 @@ public interface ErrorCodeConstants {
|
||||
// ========== 联系人管理 1-020-003-000 ==========
|
||||
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
|
||||
ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在");
|
||||
ErrorCode CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS = new ErrorCode( 1_020_003_002, "联系人已关联合同,不能删除");
|
||||
|
||||
// ========== 回款 1-020-004-000 ==========
|
||||
ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在");
|
||||
@ -40,7 +41,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定");
|
||||
ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常");
|
||||
ErrorCode CUSTOMER_LOCK_FAIL_IS_LOCK = new ErrorCode(1_020_006_007, "锁定客户失败,它已经处于锁定状态");
|
||||
ErrorCode CUSTOMER_UNLOCK_FAIL_IS_UNLOCK = new ErrorCode(1_020_006_008, "锁定客户失败,它已经处于未锁定状态");
|
||||
ErrorCode CUSTOMER_UNLOCK_FAIL_IS_UNLOCK = new ErrorCode(1_020_006_008, "解锁客户失败,它已经处于未锁定状态");
|
||||
ErrorCode CUSTOMER_LOCK_EXCEED_LIMIT = new ErrorCode(1_020_006_009, "锁定客户失败,超出锁定规则上限");
|
||||
ErrorCode CUSTOMER_OWNER_EXCEED_LIMIT = new ErrorCode(1_020_006_010, "操作失败,超出客户数拥有上限");
|
||||
|
||||
|
@ -2,32 +2,86 @@ package cn.iocoder.yudao.module.crm.enums;
|
||||
|
||||
/**
|
||||
* CRM 操作日志枚举
|
||||
* 目的:统一管理,也减少 Service 里各种“复杂”字符串
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface LogRecordConstants {
|
||||
|
||||
//======================= 客户模块类型 =======================
|
||||
// TODO puhui999: 确保模块命名方式为 module + 子模块名称的方式。统一定义模块名称是为了方便查询各自记录的操作日志,列如说:查询客户【张三的操作日志】就可以 module + bizId
|
||||
String CRM_LEADS = "CRM 线索";
|
||||
String CRM_CUSTOMER = "CRM 客户";
|
||||
String CRM_CONTACT = "CRM 联系人";
|
||||
String CRM_BUSINESS = "CRM 商机";
|
||||
String CRM_CONTRACT = "CRM 合同";
|
||||
String CRM_PRODUCT = "CRM 产品";
|
||||
String CRM_RECEIVABLE = "CRM 回款";
|
||||
String CRM_RECEIVABLE_PLAN = "CRM 回款计划";
|
||||
// ======================= CRM_LEADS 线索 =======================
|
||||
|
||||
//======================= 客户转移操作日志 =======================
|
||||
String CRM_LEADS_TYPE = "CRM 线索";
|
||||
|
||||
String TRANSFER_CUSTOMER_LOG_SUCCESS = "把客户【{{#crmCustomer.name}}】的负责人从【{getAdminUserById{#crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
|
||||
// ======================= CRM_CUSTOMER 客户 =======================
|
||||
|
||||
// TODO @puhui999:这里格式是不是可以这样;目的是:统一管理,也减少 Service 里各种“复杂”字符串
|
||||
// ======================= Customer 客户 =======================
|
||||
String CUSTOMER_TYPE = "CRM 客户";
|
||||
String CUSTOMER_CREATE_SUB_TYPE = "创建客户";
|
||||
String CUSTOMER_CREATE_SUCCESS = "更新了客户{_DIFF{#updateReqVO}}";
|
||||
String CRM_CUSTOMER_TYPE = "CRM 客户";
|
||||
String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户";
|
||||
String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}";
|
||||
String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户";
|
||||
String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户";
|
||||
String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】";
|
||||
String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户";
|
||||
String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#crmCustomer.name}}】的负责人从【{getAdminUserById{#crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
|
||||
String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#crmCustomer.lockStatus ? '解锁客户' : '锁定客户'}}";
|
||||
String CRM_CUSTOMER_LOCK_SUCCESS = "{{#crmCustomer.lockStatus ? '将客户【' + #crmCustomer.name + '】解锁' : '将客户【' + #crmCustomer.name + '】锁定'}}";
|
||||
String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海";
|
||||
String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海";
|
||||
String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}";
|
||||
String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}";
|
||||
|
||||
String CUSTOMER_UPDATE_SUB_TYPE = "更新客户";
|
||||
// ======================= CRM_CUSTOMER_LIMIT_CONFIG 客户限制配置 =======================
|
||||
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_TYPE = "CRM 客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE = "创建客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS = "创建了【{{#limitType}}】类型的客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE = "更新客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS = "更新了客户限制配置: {_DIFF{#updateReqVO}}";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE = "删除客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS = "删除了【{{#limitType}}】类型的客户限制配置";
|
||||
|
||||
// ======================= CRM_CUSTOMER_POOL_CONFIG 客户公海规则 =======================
|
||||
|
||||
String CRM_CUSTOMER_POOL_CONFIG_TYPE = "CRM 客户公海规则";
|
||||
String CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新客户公海规则' : '创建客户公海规则'}}";
|
||||
String CRM_CUSTOMER_POOL_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了客户公海规则' : '创建了客户公海规则'}}";
|
||||
|
||||
// ======================= CRM_CONTACT 联系人 =======================
|
||||
|
||||
String CRM_CONTACT_TYPE = "CRM 联系人";
|
||||
|
||||
// ======================= CRM_BUSINESS 商机 =======================
|
||||
|
||||
String CRM_BUSINESS_TYPE = "CRM 商机";
|
||||
|
||||
// ======================= CRM_CONTRACT 合同 =======================
|
||||
|
||||
String CRM_CONTRACT_TYPE = "CRM 合同";
|
||||
|
||||
// ======================= CRM_PRODUCT 产品 =======================
|
||||
|
||||
// TODO @hao:可以把 CRM 产品、和 CRM 产品分类分开哈,量程两个 type;
|
||||
String CRM_PRODUCT_TYPE = "CRM 产品";
|
||||
String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品";
|
||||
String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】";
|
||||
String CRM_PRODUCT_UPDATE_SUB_TYPE = "更新产品";
|
||||
String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品";
|
||||
String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】";
|
||||
String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】";
|
||||
String CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE = "更新产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS = "更新了产品分类【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE = "删除产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_DELETE_SUCCESS = "删除了产品分类【{{#productCategory.name}}】";
|
||||
|
||||
// ======================= CRM_RECEIVABLE 回款 =======================
|
||||
|
||||
String CRM_RECEIVABLE_TYPE = "CRM 回款";
|
||||
|
||||
// ======================= CRM_RECEIVABLE_PLAN 回款计划 =======================
|
||||
|
||||
String CRM_RECEIVABLE_PLAN_TYPE = "CRM 回款计划";
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.customer;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@ -36,6 +38,12 @@ public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable {
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
public static String getNameByType(Integer type) {
|
||||
CrmCustomerLimitConfigTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmCustomerLimitConfigTypeEnum.values()),
|
||||
item -> ObjUtil.equal(item.type, type));
|
||||
return typeEnum == null ? null : typeEnum.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
@ -29,11 +28,13 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
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.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
||||
|
||||
@Tag(name = "管理后台 - 商机")
|
||||
@RestController
|
||||
@ -95,7 +96,9 @@ public class CrmBusinessController {
|
||||
@GetMapping("/page-by-customer")
|
||||
@Operation(summary = "获得商机分页,基于指定客户")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) {
|
||||
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
|
||||
if (pageReqVO.getCustomerId() == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomerId(pageReqVO);
|
||||
return success(buildBusinessDetailPageResult(pageResult));
|
||||
}
|
||||
|
@ -38,14 +38,14 @@ public class CrmClueController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建线索")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:create')")
|
||||
public CommonResult<Long> createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createClue(@Valid @RequestBody CrmClueSaveReqVO createReqVO) {
|
||||
return success(clueService.createClue(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新线索")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||
public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueSaveReqVO updateReqVO) {
|
||||
clueService.updateClue(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -96,4 +96,13 @@ public class CrmClueController {
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/transform")
|
||||
@Operation(summary = "线索转化为客户")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||
// TODO @min:方法改成 translateCustomer
|
||||
public CommonResult<Boolean> translate(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
|
||||
clueService.translate(reqVO, getLoginUserId());
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,10 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
@ -24,7 +23,6 @@ public class CrmClueBaseVO {
|
||||
private String name;
|
||||
|
||||
@Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520")
|
||||
@NotNull(message = "客户不能为空")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
||||
@ -46,6 +44,9 @@ public class CrmClueBaseVO {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "负责人编号")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
|
@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 线索创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmClueCreateReqVO extends CrmClueBaseVO {
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 线索 创建/更新 Request VO")
|
||||
@Data
|
||||
public class CrmClueSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "10969")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx")
|
||||
@NotEmpty(message = "线索名称不能为空")
|
||||
private String name;
|
||||
|
||||
// TODO @min:是不是不传递 customerId?
|
||||
@Schema(description = "客户 id", example = "520")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "电话", example = "18000000000")
|
||||
@Telephone
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "手机号", example = "18000000000")
|
||||
@Mobile
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地址", example = "北京市海淀区")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "负责人编号", example = "2048")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 线索转化为客户 Request VO")
|
||||
@Data
|
||||
public class CrmClueTransformReqVO {
|
||||
|
||||
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]")
|
||||
@NotEmpty(message = "线索编号不能为空") Set<Long> ids; // TODO @min:应该空行噢
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 线索更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmClueUpdateReqVO extends CrmClueBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -17,6 +17,9 @@ import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService;
|
||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -40,10 +43,10 @@ import java.util.stream.Stream;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
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.convertListByFlatMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
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_CONTACT_TYPE;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 联系人")
|
||||
@RestController
|
||||
@ -56,24 +59,26 @@ public class CrmContactController {
|
||||
private CrmContactService contactService;
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Resource
|
||||
private CrmContactBusinessService contactBusinessLinkService;
|
||||
|
||||
// TODO @zyna:CrmContactCreateReqVO、CrmContactUpdateReqVO、CrmContactRespVO 按照新的 VO 规范搞哈;可以参考 dept 模块
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建联系人")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:create')")
|
||||
public CommonResult<Long> createContact(@Valid @RequestBody CrmContactCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createContact(@Valid @RequestBody CrmContactSaveReqVO createReqVO) {
|
||||
return success(contactService.createContact(createReqVO, getLoginUserId()));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新联系人")
|
||||
@OperateLog(enable = false)
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
|
||||
public CommonResult<Boolean> updateContact(@Valid @RequestBody CrmContactUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateContact(@Valid @RequestBody CrmContactSaveReqVO updateReqVO) {
|
||||
contactService.updateContact(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -109,14 +114,12 @@ public class CrmContactController {
|
||||
}
|
||||
|
||||
@GetMapping("/simple-all-list")
|
||||
@Operation(summary = "获得联系人列表")
|
||||
@Operation(summary = "获得联系人的精简列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||
public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() {
|
||||
// TODO @zyna:建议 contactService 单独搞个 list 接口哈
|
||||
CrmContactPageReqVO pageReqVO = new CrmContactPageReqVO();
|
||||
pageReqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
List<CrmContactDO> list = contactService.getContactPage(pageReqVO, getLoginUserId()).getList();
|
||||
return success(BeanUtils.toBean(list, CrmContactSimpleRespVO.class));
|
||||
public CommonResult<List<CrmContactRespVO>> getSimpleContactList() {
|
||||
List<CrmContactDO> list = contactService.getContactList();
|
||||
return success(convertList(list, contact -> // 只返回 id、name 字段
|
||||
new CrmContactRespVO().setId(contact.getId()).setName(contact.getName())));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -147,6 +150,17 @@ public class CrmContactController {
|
||||
buildContactDetailPage(pageResult).getList());
|
||||
}
|
||||
|
||||
@GetMapping("/operate-log-page")
|
||||
@Operation(summary = "获得客户操作日志")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
||||
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("bizId")Long bizId) {
|
||||
OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO();
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||
reqVO.setBizType(CRM_CONTACT_TYPE);
|
||||
reqVO.setBizId(bizId);
|
||||
return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建详细的联系人分页结果
|
||||
*
|
||||
@ -181,7 +195,7 @@ public class CrmContactController {
|
||||
// ================== 关联/取关联系人 ===================
|
||||
|
||||
@PostMapping("/create-business-list")
|
||||
@Operation(summary = "创建联系人与联系人的关联")
|
||||
@Operation(summary = "创建联系人与商机的关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:create-business')")
|
||||
public CommonResult<Boolean> createContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO createReqVO) {
|
||||
contactBusinessLinkService.createContactBusinessList(createReqVO);
|
||||
|
@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmContactCreateReqVO extends CrmContactBaseVO {
|
||||
|
||||
}
|
@ -1,28 +1,90 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmContactRespVO extends CrmContactBaseVO {
|
||||
public class CrmContactRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty(value = "创建时间", order = 8)
|
||||
private LocalDateTime createTime;
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
@ExcelProperty(value = "姓名", order = 1)
|
||||
private String name;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@ExcelProperty(value = "更新时间", order = 8)
|
||||
private LocalDateTime updateTime;
|
||||
@Schema(description = "客户编号", example = "10795")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "性别")
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX)
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "职位")
|
||||
@ExcelProperty(value = "职位", order = 3)
|
||||
private String post;
|
||||
|
||||
@Schema(description = "是否关键决策人")
|
||||
@ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean master;
|
||||
|
||||
@Schema(description = "直属上级", example = "23457")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "手机号", example = "1387171766")
|
||||
@ExcelProperty(value = "手机号", order = 4)
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "电话", example = "021-0029922")
|
||||
@ExcelProperty(value = "电话", order = 4)
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "QQ", example = "197272662")
|
||||
@ExcelProperty(value = "QQ", order = 4)
|
||||
private Long qq;
|
||||
|
||||
@Schema(description = "微信", example = "zzz3883")
|
||||
@ExcelProperty(value = "微信", order = 4)
|
||||
private String wechat;
|
||||
|
||||
@Schema(description = "电子邮箱", example = "1111@22.com")
|
||||
@ExcelProperty(value = "邮箱", order = 4)
|
||||
private String email;
|
||||
|
||||
@Schema(description = "地区编号", example = "20158")
|
||||
private Integer areaId;
|
||||
|
||||
@Schema(description = "地址")
|
||||
@ExcelProperty(value = "地址", order = 5)
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty(value = "备注", order = 6)
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "负责人用户编号", example = "14334")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@ExcelProperty(value = "最后跟进时间", order = 6)
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@ExcelProperty(value = "下次联系时间", order = 6)
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "创建人", example = "25682")
|
||||
private String creator;
|
||||
@ -31,7 +93,7 @@ public class CrmContactRespVO extends CrmContactBaseVO {
|
||||
@ExcelProperty(value = "创建人", order = 8)
|
||||
private String creatorName;
|
||||
|
||||
@ExcelProperty(value = "客户名称",order = 2)
|
||||
@ExcelProperty(value = "客户名称", order = 2)
|
||||
@Schema(description = "客户名字", example = "test")
|
||||
private String customerName;
|
||||
|
||||
|
@ -2,11 +2,8 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import cn.iocoder.yudao.module.crm.framework.operatelog.core.*;
|
||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -18,86 +15,89 @@ import java.time.LocalDateTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
// TODO zyna:要不按照新的,干掉这个 basevo,都放子类里
|
||||
/**
|
||||
* CRM 联系人 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - CRM 联系人创建/更新 Request VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmContactBaseVO {
|
||||
public class CrmContactSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", example = "3167")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty(value = "姓名",order = 1)
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
@NotNull(message = "姓名不能为空")
|
||||
@DiffLogField(name = "姓名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "客户编号", example = "10795")
|
||||
@DiffLogField(name = "姓名", function = CrmCustomerParseFunction.NAME)
|
||||
private Long customerId;
|
||||
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX)
|
||||
@Schema(description = "性别")
|
||||
@DiffLogField(name = "性别", function = CrmSexParseFunction.NAME)
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "职位")
|
||||
@ExcelProperty(value = "职位", order = 3)
|
||||
@DiffLogField(name = "职位")
|
||||
private String post;
|
||||
|
||||
@Schema(description = "是否关键决策人")
|
||||
@ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
@DiffLogField(name = "关键决策人", function = CrmBooleanParseFunction.NAME)
|
||||
private Boolean master;
|
||||
|
||||
@Schema(description = "直属上级", example = "23457")
|
||||
@DiffLogField(name = "直属上级", function = CrmContactParseFunction.NAME)
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "手机号",example = "1387171766")
|
||||
@Schema(description = "手机号", example = "1387171766")
|
||||
@Mobile
|
||||
@ExcelProperty(value = "手机号",order = 4)
|
||||
@DiffLogField(name = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "座机",example = "021-0029922")
|
||||
@Schema(description = "电话", example = "021-0029922")
|
||||
@Telephone
|
||||
@ExcelProperty(value = "座机",order = 4)
|
||||
@DiffLogField(name = "电话")
|
||||
private String telephone;
|
||||
|
||||
@ExcelProperty(value = "QQ",order = 4)
|
||||
@Schema(description = "QQ",example = "197272662")
|
||||
@Schema(description = "QQ", example = "197272662")
|
||||
@DiffLogField(name = "QQ")
|
||||
private Long qq;
|
||||
|
||||
@ExcelProperty(value = "微信",order = 4)
|
||||
@Schema(description = "微信",example = "zzz3883")
|
||||
@Schema(description = "微信", example = "zzz3883")
|
||||
@DiffLogField(name = "微信")
|
||||
private String wechat;
|
||||
|
||||
@Schema(description = "电子邮箱",example = "1111@22.com")
|
||||
@Schema(description = "电子邮箱", example = "1111@22.com")
|
||||
@DiffLogField(name = "邮箱")
|
||||
@Email
|
||||
@ExcelProperty(value = "邮箱",order = 4)
|
||||
private String email;
|
||||
|
||||
@Schema(description = "地区编号", example = "20158")
|
||||
@DiffLogField(name = "所在地", function = "getAreaById")
|
||||
private Integer areaId;
|
||||
|
||||
@ExcelProperty(value = "地址",order = 5)
|
||||
@Schema(description = "地址")
|
||||
@DiffLogField(name = "地址")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty(value = "备注",order = 6)
|
||||
@DiffLogField(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "负责人用户编号", example = "14334")
|
||||
@NotNull(message = "负责人不能为空")
|
||||
@DiffLogField(name = "负责人", function = CrmSysUserParseFunction.NAME)
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ExcelProperty(value = "最后跟进时间",order = 6)
|
||||
@DiffLogField(name = "最后跟进时间")
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@ExcelProperty(value = "下次联系时间",order = 6)
|
||||
@DiffLogField(name = "下次联系时间")
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "关联商机 ID", example = "122233")
|
||||
private Long businessId; // 注意:该字段用于在【商机】详情界面「新建联系人」时,自动进行关联
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人的精简 Response VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class CrmContactSimpleRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmContactUpdateReqVO extends CrmContactBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -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;
|
||||
@ -19,7 +22,6 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.Parameters;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
@ -36,11 +38,10 @@ 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;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CUSTOMER_TYPE;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 客户")
|
||||
@RestController
|
||||
@ -50,7 +51,8 @@ public class CrmCustomerController {
|
||||
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
|
||||
@Resource
|
||||
private CrmCustomerPoolConfigService customerPoolConfigService;
|
||||
@Resource
|
||||
private DeptApi deptApi;
|
||||
@Resource
|
||||
@ -58,28 +60,24 @@ public class CrmCustomerController {
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
|
||||
// TODO @puhui999:把 CrmCustomerCreateReqVO、CrmCustomerUpdateReqVO、CrmCustomerRespVO 按照新的规范,搞一下哈;
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建客户")
|
||||
@OperateLog(enable = false) // TODO 关闭原有日志记录;@puhui999:注解都先删除。先记录,没关系。我们下个迭代,就都删除掉操作日志了;
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:create')")
|
||||
public CommonResult<Long> createCustomer(@Valid @RequestBody CrmCustomerCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createCustomer(@Valid @RequestBody CrmCustomerSaveReqVO createReqVO) {
|
||||
return success(customerService.createCustomer(createReqVO, getLoginUserId()));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新客户")
|
||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerSaveReqVO updateReqVO) {
|
||||
customerService.updateCustomer(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除客户")
|
||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@Parameter(name = "id", description = "客户编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:delete')")
|
||||
public CommonResult<Boolean> deleteCustomer(@RequestParam("id") Long id) {
|
||||
customerService.deleteCustomer(id);
|
||||
@ -103,7 +101,6 @@ public class CrmCustomerController {
|
||||
return success(CrmCustomerConvert.INSTANCE.convert(customer, userMap, deptMap));
|
||||
}
|
||||
|
||||
// TODO @puhui999:这个查询会查出多个;微信发你图了
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得客户分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
||||
@ -115,11 +112,42 @@ 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));
|
||||
}
|
||||
|
||||
// TODO @puhui999:加下注释哈;
|
||||
private Map<Long, Long> getPoolDayMap(PageResult<CrmCustomerDO> pageResult) {
|
||||
Map<Long, Long> poolDayMap = null;
|
||||
CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig();
|
||||
// TODO @puhui999:if return 减少括号
|
||||
if (customerPoolConfig != null && customerPoolConfig.getEnabled()) { // 有公海配置的情况
|
||||
// TODO @puhui999:item 改成 customer 更好,容易理解;
|
||||
poolDayMap = convertMap(pageResult.getList(), CrmCustomerDO::getId, item -> {
|
||||
long dealExpireDay = 0;
|
||||
if (!item.getDealStatus()) { // 检查是否成交
|
||||
dealExpireDay = customerPoolConfig.getDealExpireDays() - LocalDateTimeUtils.between(item.getCreateTime());
|
||||
}
|
||||
// TODO @puhui999:需要考虑 contactLastTime 为空的情况哈;
|
||||
long contactExpireDay = customerPoolConfig.getContactExpireDays() - LocalDateTimeUtils.between(item.getContactLastTime());
|
||||
return dealExpireDay == 0 ? contactExpireDay : Math.min(dealExpireDay, contactExpireDay);
|
||||
});
|
||||
// TODO @puhui999:需要考虑 lock 的情况么?
|
||||
}
|
||||
return poolDayMap;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/list-all-simple")
|
||||
@Operation(summary = "获取客户精简信息列表", description = "只包含有读权限的客户,主要用于前端的下拉选项")
|
||||
public CommonResult<List<CrmCustomerRespVO>> getSimpleDeptList() {
|
||||
CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO();
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||
List<CrmCustomerDO> list = customerService.getCustomerPage(reqVO, getLoginUserId()).getList();
|
||||
return success(convertList(list, customer -> // 只返回 id、name 精简字段
|
||||
new CrmCustomerRespVO().setId(customer.getId()).setName(customer.getName())));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ -131,32 +159,32 @@ public class CrmCustomerController {
|
||||
pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||
List<CrmCustomerDO> list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList();
|
||||
// 导出 Excel
|
||||
List<CrmCustomerExcelVO> datas = CrmCustomerConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerExcelVO.class, datas);
|
||||
ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class,
|
||||
BeanUtils.toBean(list, CrmCustomerRespVO.class));
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "转移客户")
|
||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) {
|
||||
customerService.transferCustomer(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO @puhui999:是不是接口只要传递 bizId,由 Controller 自己组装出 OperateLogV2PageReqDTO
|
||||
@GetMapping("/operate-log-page")
|
||||
@Operation(summary = "获得客户操作日志")
|
||||
@Parameter(name = "id", description = "客户编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
||||
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(CrmCustomerOperateLogPageReqVO reqVO) {
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||
reqVO.setBizType(CRM_CUSTOMER);
|
||||
return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class)));
|
||||
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("id") Long id) {
|
||||
OperateLogV2PageReqDTO reqDTO = new OperateLogV2PageReqDTO();
|
||||
reqDTO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||
reqDTO.setBizType(CRM_CUSTOMER_TYPE);
|
||||
reqDTO.setBizId(id);
|
||||
return success(operateLogApi.getOperateLogPage(reqDTO));
|
||||
}
|
||||
|
||||
@PutMapping("/lock")
|
||||
@Operation(summary = "锁定/解锁客户")
|
||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> lockCustomer(@Valid @RequestBody CrmCustomerLockReqVO lockReqVO) {
|
||||
customerService.lockCustomer(lockReqVO, getLoginUserId());
|
||||
@ -167,7 +195,6 @@ public class CrmCustomerController {
|
||||
|
||||
@PutMapping("/put-pool")
|
||||
@Operation(summary = "数据放入公海")
|
||||
@OperateLog(enable = false) // TODO 关闭原有日志记录
|
||||
@Parameter(name = "id", description = "客户编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:update')")
|
||||
public CommonResult<Boolean> putCustomerPool(@RequestParam("id") Long id) {
|
||||
@ -180,32 +207,16 @@ public class CrmCustomerController {
|
||||
@Parameter(name = "ids", description = "编号数组", required = true, example = "1,2,3")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:receive')")
|
||||
public CommonResult<Boolean> receiveCustomer(@RequestParam(value = "ids") List<Long> ids) {
|
||||
customerService.receiveCustomer(ids, getLoginUserId());
|
||||
customerService.receiveCustomer(ids, getLoginUserId(), Boolean.TRUE);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO @puhui999:需要搞个 VO 类
|
||||
@PutMapping("/distribute")
|
||||
@Operation(summary = "分配公海给对应负责人")
|
||||
@Parameters({
|
||||
@Parameter(name = "ids", description = "客户编号数组", required = true, example = "1,2,3"),
|
||||
@Parameter(name = "ownerUserId", description = "分配的负责人编号", required = true, example = "12345")
|
||||
})
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:distribute')")
|
||||
public CommonResult<Boolean> distributeCustomer(@RequestParam(value = "ids") List<Long> ids,
|
||||
@RequestParam(value = "ownerUserId") Long ownerUserId) {
|
||||
customerService.receiveCustomer(ids, ownerUserId);
|
||||
public CommonResult<Boolean> distributeCustomer(@Valid @RequestBody CrmCustomerDistributeReqVO distributeReqVO) {
|
||||
customerService.receiveCustomer(distributeReqVO.getIds(), distributeReqVO.getOwnerUserId(), Boolean.FALSE);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO 芋艿:这个接口要调整下
|
||||
@GetMapping("/query-all-list")
|
||||
@Operation(summary = "查询客户列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:all')")
|
||||
public CommonResult<List<CrmCustomerQueryAllRespVO>> queryAll() {
|
||||
List<CrmCustomerDO> crmCustomerDOList = customerService.getCustomerList();
|
||||
List<CrmCustomerQueryAllRespVO> data = CrmCustomerConvert.INSTANCE.convertQueryAll(crmCustomerDOList);
|
||||
return success(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,10 +3,9 @@ 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.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService;
|
||||
@ -17,12 +16,12 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
@ -43,18 +42,17 @@ public class CrmCustomerLimitConfigController {
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
// TODO @puhui999:可以把 vo 改下哈
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建客户限制配置")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer-limit-config:create')")
|
||||
public CommonResult<Long> createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO createReqVO) {
|
||||
return success(customerLimitConfigService.createCustomerLimitConfig(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新客户限制配置")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer-limit-config:update')")
|
||||
public CommonResult<Boolean> updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO updateReqVO) {
|
||||
customerLimitConfigService.updateCustomerLimitConfig(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
@ -8,13 +8,12 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfig
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 客户公海配置")
|
||||
@ -26,7 +25,6 @@ public class CrmCustomerPoolConfigController {
|
||||
@Resource
|
||||
private CrmCustomerPoolConfigService customerPoolConfigService;
|
||||
|
||||
// TODO @puhui999:可以把 vo 改下哈
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取客户公海规则设置")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')")
|
||||
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerCreateReqVO extends CrmCustomerBaseVO {
|
||||
|
||||
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@NotNull(message = "负责人不能为空")
|
||||
private Long ownerUserId;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户分配公海给对应负责人 Request VO")
|
||||
@Data
|
||||
public class CrmCustomerDistributeReqVO {
|
||||
|
||||
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]")
|
||||
@NotNull(message = "客户编号不能为空") // TODO @puhui999:list 是 @NotEmpty
|
||||
private List<Long> ids;
|
||||
|
||||
@Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "负责人不能为空")
|
||||
private Long ownerUserId;
|
||||
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
// TODO 芋艿:导出最后做,等基本确认的差不多之后;
|
||||
/**
|
||||
* CRM 客户 Excel VO
|
||||
*
|
||||
* @author Wanwan
|
||||
*/
|
||||
@Data
|
||||
public class CrmCustomerExcelVO {
|
||||
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("客户名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean followUpStatus;
|
||||
|
||||
@ExcelProperty(value = "锁定状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean lockStatus;
|
||||
|
||||
@ExcelProperty(value = "成交状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean dealStatus;
|
||||
|
||||
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY)
|
||||
private Integer industryId;
|
||||
|
||||
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL)
|
||||
private Integer level;
|
||||
|
||||
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE)
|
||||
private Integer source;
|
||||
|
||||
@ExcelProperty("手机")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty("电话")
|
||||
private String telephone;
|
||||
|
||||
@ExcelProperty("网址")
|
||||
private String website;
|
||||
|
||||
@ExcelProperty("QQ")
|
||||
private String qq;
|
||||
|
||||
@ExcelProperty("wechat")
|
||||
private String wechat;
|
||||
|
||||
@ExcelProperty("email")
|
||||
private String email;
|
||||
|
||||
@ExcelProperty("客户描述")
|
||||
private String description;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("负责人的用户编号")
|
||||
private Long ownerUserId;
|
||||
|
||||
@ExcelProperty("地区编号")
|
||||
private Integer areaId;
|
||||
|
||||
@ExcelProperty("详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
@ExcelProperty("最后跟进时间")
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@ExcelProperty("下次联系时间")
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - crm 客户操作日志分页 Request VO")
|
||||
@Data
|
||||
public class CrmCustomerOperateLogPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "模块数据编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Long bizId;
|
||||
|
||||
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "模块类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private String bizType;
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
// TODO 芋艿:这块要统一下;
|
||||
@Schema(description = "管理后台 - CRM 全部客户 Response VO")
|
||||
@Data
|
||||
public class CrmCustomerQueryAllRespVO{
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
private String name;
|
||||
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -12,45 +15,124 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerRespVO extends CrmCustomerBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmCustomerRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty("客户名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean followUpStatus;
|
||||
|
||||
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@Schema(description = "锁定状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty(value = "锁定状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean lockStatus;
|
||||
|
||||
@Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@Schema(description = "成交状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty(value = "成交状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean dealStatus;
|
||||
|
||||
@Schema(description = "所属行业", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty(value = "所属行业", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY)
|
||||
private Integer industryId;
|
||||
|
||||
@Schema(description = "客户等级", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty(value = "客户等级", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL)
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "客户来源", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@ExcelProperty(value = "客户来源", converter = DictConvert.class)
|
||||
@DictFormat(cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE)
|
||||
private Integer source;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("手机")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("电话")
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("网址")
|
||||
private String website;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("QQ")
|
||||
private String qq;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("wechat")
|
||||
private String wechat;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("email")
|
||||
private String email;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("客户描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "25682")
|
||||
@ExcelProperty("负责人的用户编号")
|
||||
private Long ownerUserId;
|
||||
@Schema(description = "负责人名字", example = "25682")
|
||||
@ExcelProperty("负责人名字")
|
||||
private String ownerUserName;
|
||||
@Schema(description = "负责人部门")
|
||||
@ExcelProperty("负责人部门")
|
||||
private String ownerUserDeptName;
|
||||
|
||||
@Schema(description = "地区编号", example = "1024")
|
||||
@ExcelProperty("地区编号")
|
||||
private Integer areaId;
|
||||
@Schema(description = "地区名称", example = "北京市")
|
||||
@ExcelProperty("地区名称")
|
||||
private String areaName;
|
||||
@Schema(description = "详细地址", example = "北京市成华大道")
|
||||
@ExcelProperty("详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@ExcelProperty("最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@ExcelProperty("下次联系时间")
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "更新时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
@Schema(description = "创建人", example = "1024")
|
||||
@ExcelProperty("创建人")
|
||||
private String creator;
|
||||
@Schema(description = "创建人名字")
|
||||
@Schema(description = "创建人名字", example = "芋道源码")
|
||||
@ExcelProperty("创建人名字")
|
||||
private String creatorName;
|
||||
|
||||
@Schema(description = "距离加入公海时间", example = "1")
|
||||
private Long poolDay;
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmIndustryParseFunction;
|
||||
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmLevelParseFunction;
|
||||
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmSourceParseFunction;
|
||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
@ -18,12 +21,12 @@ import java.time.LocalDateTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
|
||||
|
||||
/**
|
||||
* 客户 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - CRM 客户新增/修改 Request VO")
|
||||
@Data
|
||||
public class CrmCustomerBaseVO {
|
||||
public class CrmCustomerSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
|
||||
@DiffLogField(name = "客户名称")
|
||||
@ -31,17 +34,17 @@ public class CrmCustomerBaseVO {
|
||||
private String name;
|
||||
|
||||
@Schema(description = "所属行业", example = "1")
|
||||
@DiffLogField(name = "所属行业", function = "getIndustryById")
|
||||
@DiffLogField(name = "所属行业", function = CrmIndustryParseFunction.NAME)
|
||||
@DictFormat(CRM_CUSTOMER_INDUSTRY)
|
||||
private Integer industryId;
|
||||
|
||||
@Schema(description = "客户等级", example = "2")
|
||||
@DiffLogField(name = "客户等级", function = "getLevel")
|
||||
@DiffLogField(name = "客户等级", function = CrmLevelParseFunction.NAME)
|
||||
@InEnum(CrmCustomerLevelEnum.class)
|
||||
private Integer level;
|
||||
|
||||
@Schema(description = "客户来源", example = "3")
|
||||
@DiffLogField(name = "客户来源", function = "getSource")
|
||||
@DiffLogField(name = "客户来源", function = CrmSourceParseFunction.NAME)
|
||||
private Integer source;
|
||||
|
||||
@Schema(description = "手机", example = "18000000000")
|
||||
@ -96,4 +99,7 @@ public class CrmCustomerBaseVO {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
private Long ownerUserId;
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerUpdateReqVO extends CrmCustomerBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "13563")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 客户限制配置创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerLimitConfigCreateReqVO extends CrmCustomerLimitConfigBaseVO {
|
||||
|
||||
}
|
@ -4,21 +4,32 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 客户限制配置 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerLimitConfigRespVO extends CrmCustomerLimitConfigBaseVO {
|
||||
public class CrmCustomerLimitConfigRespVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "规则适用人群")
|
||||
private List<Long> userIds;
|
||||
|
||||
@Schema(description = "规则适用部门")
|
||||
private List<Long> deptIds;
|
||||
|
||||
@Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384")
|
||||
private Integer maxCount;
|
||||
|
||||
@Schema(description = "成交客户是否占有拥有客户数")
|
||||
private Boolean dealCountEnabled;
|
||||
|
||||
@Schema(description = "规则适用人群名称")
|
||||
private List<AdminUserRespDTO> users;
|
||||
|
||||
|
@ -1,33 +1,40 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
|
||||
|
||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 客户限制配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - 客户限制配置创建/更新 Request VO")
|
||||
@Data
|
||||
public class CrmCustomerLimitConfigBaseVO {
|
||||
public class CrmCustomerLimitConfigSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@NotNull(message = "规则类型不能为空")
|
||||
@DiffLogField(name = "规则类型")
|
||||
private Integer type;
|
||||
|
||||
// TODO @puhui999:可以把 Function 那的 functionName 搞成 NAME 枚举,这里直接引用。这样后续改动更方便哈。
|
||||
@Schema(description = "规则适用人群")
|
||||
@DiffLogField(name = "规则适用人群", function = "getAdminUserById")
|
||||
private List<Long> userIds;
|
||||
|
||||
@Schema(description = "规则适用部门")
|
||||
@DiffLogField(name = "规则适用部门", function = "getDeptById")
|
||||
private List<Long> deptIds;
|
||||
|
||||
@Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384")
|
||||
@NotNull(message = "数量上限不能为空")
|
||||
@DiffLogField(name = "数量上限")
|
||||
private Integer maxCount;
|
||||
|
||||
@Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)")
|
||||
@DiffLogField(name = "成交客户是否占有拥有客户数")
|
||||
private Boolean dealCountEnabled;
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 客户限制配置更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerLimitConfigUpdateReqVO extends CrmCustomerLimitConfigBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 客户公海配置 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class CrmCustomerPoolConfigBaseVO {
|
||||
|
||||
@Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否启用客户公海不能为空")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "未跟进放入公海天数", example = "2")
|
||||
private Integer contactExpireDays;
|
||||
|
||||
@Schema(description = "未成交放入公海天数", example = "2")
|
||||
private Integer dealExpireDays;
|
||||
|
||||
@Schema(description = "是否开启提前提醒", example = "true")
|
||||
private Boolean notifyEnabled;
|
||||
|
||||
@Schema(description = "提前提醒天数", example = "2")
|
||||
private Integer notifyDays;
|
||||
|
||||
}
|
@ -1,14 +1,27 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户公海规则 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerPoolConfigRespVO extends CrmCustomerPoolConfigBaseVO {
|
||||
public class CrmCustomerPoolConfigRespVO {
|
||||
|
||||
@Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@NotNull(message = "是否启用客户公海不能为空")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "未跟进放入公海天数", example = "2")
|
||||
private Integer contactExpireDays;
|
||||
|
||||
@Schema(description = "未成交放入公海天数", example = "2")
|
||||
private Integer dealExpireDays;
|
||||
|
||||
@Schema(description = "是否开启提前提醒", example = "true")
|
||||
private Boolean notifyEnabled;
|
||||
|
||||
@Schema(description = "提前提醒天数", example = "2")
|
||||
private Integer notifyDays;
|
||||
|
||||
}
|
||||
|
@ -1,34 +1,61 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig;
|
||||
|
||||
import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO")
|
||||
@Schema(description = "管理后台 - CRM 客户公海配置的创建/更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO {
|
||||
public class CrmCustomerPoolConfigSaveReqVO {
|
||||
|
||||
// TODO @puhui999:AssertTrue 必须 is 开头哈;注意需要 json 忽略下,避免被序列化;
|
||||
@AssertTrue(message = "客户公海规则设置不正确")
|
||||
// TODO @puhui999:这个方法,是不是拆成 2 个,一个校验 contactExpireDays、一个校验 dealExpireDays;
|
||||
public boolean poolEnableValid() {
|
||||
@Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@DiffLogField(name = "是否启用客户公海")
|
||||
@NotNull(message = "是否启用客户公海不能为空")
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "未跟进放入公海天数", example = "2")
|
||||
@DiffLogField(name = "未跟进放入公海天数")
|
||||
private Integer contactExpireDays;
|
||||
|
||||
@Schema(description = "未成交放入公海天数", example = "2")
|
||||
@DiffLogField(name = "未成交放入公海天数")
|
||||
private Integer dealExpireDays;
|
||||
|
||||
@Schema(description = "是否开启提前提醒", example = "true")
|
||||
@DiffLogField(name = "是否开启提前提醒")
|
||||
private Boolean notifyEnabled;
|
||||
|
||||
@Schema(description = "提前提醒天数", example = "2")
|
||||
@DiffLogField(name = "提前提醒天数")
|
||||
private Integer notifyDays;
|
||||
|
||||
@AssertTrue(message = "未成交放入公海天数不能为空")
|
||||
@JsonIgnore
|
||||
public boolean isDealExpireDaysValid() {
|
||||
if (!BooleanUtil.isTrue(getEnabled())) {
|
||||
return true;
|
||||
}
|
||||
return ObjectUtil.isAllNotEmpty(getContactExpireDays(), getDealExpireDays());
|
||||
return Objects.nonNull(getDealExpireDays());
|
||||
}
|
||||
|
||||
@AssertTrue(message = "客户公海规则设置不正确")
|
||||
// TODO @puhui999:这个方法,是不是改成 isNotifyDaysValid() 更好点?本质校验的是 notifyDays 是否为空
|
||||
public boolean notifyEnableValid() {
|
||||
@AssertTrue(message = "未跟进放入公海天数不能为空")
|
||||
@JsonIgnore
|
||||
public boolean isContactExpireDaysValid() {
|
||||
if (!BooleanUtil.isTrue(getEnabled())) {
|
||||
return true;
|
||||
}
|
||||
return Objects.nonNull(getContactExpireDays());
|
||||
}
|
||||
|
||||
@AssertTrue(message = "提前提醒天数不能为空")
|
||||
@JsonIgnore
|
||||
public boolean isNotifyDaysValid() {
|
||||
if (!BooleanUtil.isTrue(getNotifyEnabled())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -1,7 +1,10 @@
|
||||
package cn.iocoder.yudao.module.crm.convert.clue;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueExcelVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
|
||||
import org.mapstruct.Mapper;
|
||||
@ -20,9 +23,8 @@ public interface CrmClueConvert {
|
||||
|
||||
CrmClueConvert INSTANCE = Mappers.getMapper(CrmClueConvert.class);
|
||||
|
||||
CrmClueDO convert(CrmClueCreateReqVO bean);
|
||||
|
||||
CrmClueDO convert(CrmClueUpdateReqVO bean);
|
||||
// TODO @min:这几个 convert,都使用 BeanUtils 替代哈
|
||||
CrmClueDO convert(CrmClueSaveReqVO bean);
|
||||
|
||||
CrmClueRespVO convert(CrmClueDO bean);
|
||||
|
||||
|
@ -29,10 +29,6 @@ public interface CrmContactConvert {
|
||||
|
||||
CrmContactConvert INSTANCE = Mappers.getMapper(CrmContactConvert.class);
|
||||
|
||||
CrmContactDO convert(CrmContactCreateReqVO bean);
|
||||
|
||||
CrmContactDO convert(CrmContactUpdateReqVO bean);
|
||||
|
||||
CrmContactRespVO convert(CrmContactDO bean);
|
||||
|
||||
List<CrmContactRespVO> convertList(List<CrmContactDO> list);
|
||||
|
@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.crm.convert.customer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
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.permission.bo.CrmPermissionTransferReqBO;
|
||||
@ -14,7 +17,6 @@ import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen;
|
||||
@ -29,18 +31,17 @@ public interface CrmCustomerConvert {
|
||||
|
||||
CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class);
|
||||
|
||||
CrmCustomerDO convert(CrmCustomerCreateReqVO bean);
|
||||
|
||||
CrmCustomerDO convert(CrmCustomerUpdateReqVO bean);
|
||||
// TODO @puhui999:可以清理掉可以用 BeanUtil 替代的方法哈
|
||||
CrmCustomerDO convert(CrmCustomerSaveReqVO bean);
|
||||
|
||||
CrmCustomerRespVO convert(CrmCustomerDO bean);
|
||||
|
||||
/**
|
||||
* 设置用户信息
|
||||
*
|
||||
* @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()));
|
||||
@ -51,8 +52,6 @@ public interface CrmCustomerConvert {
|
||||
findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname()));
|
||||
}
|
||||
|
||||
List<CrmCustomerExcelVO> convertList02(List<CrmCustomerDO> list);
|
||||
|
||||
@Mapping(target = "bizId", source = "reqVO.id")
|
||||
CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId);
|
||||
|
||||
@ -66,9 +65,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;
|
||||
}
|
||||
|
||||
@ -76,6 +78,8 @@ public interface CrmCustomerConvert {
|
||||
|
||||
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
|
||||
|
||||
List<CrmCustomerQueryAllRespVO> convertQueryAll(List<CrmCustomerDO> crmCustomerDO);
|
||||
// TODO @min:使用 BeanUtils 拷贝哈。我们慢慢简单的对象,不再直接基于 convert 做啦。
|
||||
@Mapping(ignore = true, target = "id")
|
||||
CrmCustomerSaveReqVO convert(CrmClueDO bean);
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.crm.convert.customer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
@ -24,9 +23,8 @@ public interface CrmCustomerLimitConfigConvert {
|
||||
|
||||
CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class);
|
||||
|
||||
CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigCreateReqVO bean);
|
||||
|
||||
CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigUpdateReqVO bean);
|
||||
// TODO @puhui999:可以把 convert 改成 BeanUtils
|
||||
CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean);
|
||||
|
||||
CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
@ -46,10 +48,12 @@ public interface CrmPermissionConvert {
|
||||
return CollectionUtils.convertList(convert(permission), item -> {
|
||||
findAndThen(userMap, item.getUserId(), user -> {
|
||||
item.setNickname(user.getNickname());
|
||||
findAndThen(deptMap, user.getDeptId(), deptRespDTO -> {
|
||||
item.setDeptName(deptRespDTO.getName());
|
||||
});
|
||||
findAndThen(deptMap, user.getDeptId(), deptRespDTO -> 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;
|
||||
|
@ -60,4 +60,8 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
|
||||
return selectJoinList(CrmContractDO.class, mpjLambdaWrapperX);
|
||||
}
|
||||
|
||||
default Long selectCountByContactId(Long contactId) {
|
||||
return selectCount(CrmContractDO::getContactId, contactId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -28,6 +29,12 @@ public interface CrmPermissionMapper extends BaseMapperX<CrmPermissionDO> {
|
||||
.eq(CrmPermissionDO::getBizId, bizId));
|
||||
}
|
||||
|
||||
default List<CrmPermissionDO> selectByBizTypeAndBizIds(Integer bizType, Collection<Long> bizIds) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmPermissionDO>()
|
||||
.eq(CrmPermissionDO::getBizType, bizType)
|
||||
.in(CrmPermissionDO::getBizId, bizIds));
|
||||
}
|
||||
|
||||
default List<CrmPermissionDO> selectListByBizTypeAndUserId(Integer bizType, Long userId) {
|
||||
return selectList(new LambdaQueryWrapperX<CrmPermissionDO>()
|
||||
.eq(CrmPermissionDO::getBizType, bizType)
|
||||
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.mzt.logapi.service.IParseFunction;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 行业的 {@link IParseFunction} 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmBooleanParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getBooleanById";
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
}
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Object value) {
|
||||
if (StrUtil.isEmptyIfStr(value)) {
|
||||
return "";
|
||||
}
|
||||
return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BOOLEAN_STRING, value.toString());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||
import com.mzt.logapi.service.IParseFunction;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 行业的 {@link IParseFunction} 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmContactParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getContactById";
|
||||
|
||||
@Resource
|
||||
private CrmContactService contactService;
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
}
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Object value) {
|
||||
if (StrUtil.isEmptyIfStr(value)) {
|
||||
return "";
|
||||
}
|
||||
CrmContactDO contactDO = contactService.getContact(Long.parseLong(value.toString()));
|
||||
return contactDO == null ? "" : contactDO.getName();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import com.mzt.logapi.service.IParseFunction;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 行业的 {@link IParseFunction} 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmCustomerParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getCustomerById";
|
||||
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
}
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Object value) {
|
||||
if (StrUtil.isEmptyIfStr(value)) {
|
||||
return "";
|
||||
}
|
||||
CrmCustomerDO crmCustomerDO = customerService.getCustomer(Long.parseLong(value.toString()));
|
||||
return crmCustomerDO == null ? "" : crmCustomerDO.getName();
|
||||
}
|
||||
|
||||
}
|
@ -13,10 +13,12 @@ import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_I
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmIndustryParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getIndustryById";
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
@ -24,7 +26,7 @@ public class CrmIndustryParseFunction implements IParseFunction {
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return "getIndustryById";
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -13,10 +13,12 @@ import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_L
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmLevelParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getLevel";
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
@ -24,7 +26,7 @@ public class CrmLevelParseFunction implements IParseFunction {
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return "getLevel";
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
|
||||
import com.mzt.logapi.service.IParseFunction;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 行业的 {@link IParseFunction} 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmSexParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getSexById";
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
}
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Object value) {
|
||||
if (StrUtil.isEmptyIfStr(value)) {
|
||||
return "";
|
||||
}
|
||||
return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.USER_SEX, value.toString());
|
||||
}
|
||||
|
||||
}
|
@ -13,10 +13,12 @@ import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_S
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmSourceParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getSource";
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
@ -24,7 +26,7 @@ public class CrmSourceParseFunction implements IParseFunction {
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return "getSource";
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.mzt.logapi.service.IParseFunction;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 行业的 {@link IParseFunction} 实现类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CrmSysUserParseFunction implements IParseFunction {
|
||||
|
||||
public static final String NAME = "getUserById";
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public boolean executeBefore() {
|
||||
return true; // 先转换值后对比
|
||||
}
|
||||
|
||||
@Override
|
||||
public String functionName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(Object value) {
|
||||
if (StrUtil.isEmptyIfStr(value)) {
|
||||
return "";
|
||||
}
|
||||
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(Long.parseLong(value.toString()));
|
||||
return adminUserRespDTO == null ? "" : adminUserRespDTO.getNickname();
|
||||
}
|
||||
|
||||
}
|
@ -18,12 +18,10 @@ import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Before;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.anyMatch;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CRM_PERMISSION_DENIED;
|
||||
|
||||
@ -42,28 +40,40 @@ public class CrmPermissionAspect {
|
||||
|
||||
@Before("@annotation(crmPermission)")
|
||||
public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) {
|
||||
// 获取相关属性值
|
||||
// 1.1 获取相关属性值
|
||||
Map<String, Object> expressionValues = parseExpressions(joinPoint, crmPermission);
|
||||
Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ?
|
||||
crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型
|
||||
Long bizId = (Long) expressionValues.get(crmPermission.bizId()); // 模块数据编号
|
||||
// 1.2 处理兼容多个 bizId 的情况
|
||||
Object object = expressionValues.get(crmPermission.bizId()); // 模块数据编号
|
||||
Set<Long> bizIds = new HashSet<>();
|
||||
if (object instanceof Collection<?>) {
|
||||
bizIds.addAll(convertSet((Collection<?>) object, item -> Long.parseLong(item.toString())));
|
||||
} else {
|
||||
bizIds.add(Long.parseLong(object.toString()));
|
||||
}
|
||||
Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别
|
||||
|
||||
// 1.1 如果是超级管理员则直接通过
|
||||
// 2. 逐个校验权限
|
||||
List<CrmPermissionDO> permissionList = crmPermissionService.getPermissionListByBiz(bizType, bizIds);
|
||||
Map<Long, List<CrmPermissionDO>> multiMap = convertMultiMap(permissionList, CrmPermissionDO::getBizId);
|
||||
bizIds.forEach(bizId -> validatePermission(bizType, multiMap.get(bizId), permissionLevel));
|
||||
}
|
||||
|
||||
private void validatePermission(Integer bizType, List<CrmPermissionDO> bizPermissions, Integer permissionLevel) {
|
||||
// 1. 如果是超级管理员则直接通过
|
||||
if (CrmPermissionUtils.isCrmAdmin()) {
|
||||
return;
|
||||
}
|
||||
// 1.2 获取数据权限
|
||||
List<CrmPermissionDO> bizPermissions = crmPermissionService.getPermissionListByBiz(bizType, bizId);
|
||||
if (CollUtil.isEmpty(bizPermissions)) { // 没有数据权限的情况
|
||||
// 1.1 没有数据权限的情况
|
||||
if (CollUtil.isEmpty(bizPermissions)) {
|
||||
// 公海数据如果没有团队成员大家也因该有读权限才对
|
||||
if (CrmPermissionLevelEnum.isRead(permissionLevel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 没有数据权限的情况下超出了读权限直接报错,避免后面校验空指针
|
||||
throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType));
|
||||
} else { // 有数据权限但是没有负责人的情况
|
||||
} else { // 1.2 有数据权限但是没有负责人的情况
|
||||
if (!anyMatch(bizPermissions, item -> CrmPermissionLevelEnum.isOwner(item.getLevel()))) {
|
||||
if (CrmPermissionLevelEnum.isRead(permissionLevel)) {
|
||||
return;
|
||||
@ -91,9 +101,8 @@ public class CrmPermissionAspect {
|
||||
}
|
||||
}
|
||||
}
|
||||
// 2.4 没有权限!
|
||||
// 打个 info 日志,方便后续排查问题、审计
|
||||
log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]",
|
||||
// 2.4 没有权限,抛出异常
|
||||
log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", // 打个 info 日志,方便后续排查问题、审计
|
||||
getUserId(), permissionLevel, toJsonString(userPermission));
|
||||
throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType));
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package cn.iocoder.yudao.module.crm.service.clue;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@ -24,14 +24,14 @@ public interface CrmClueService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createClue(@Valid CrmClueCreateReqVO createReqVO);
|
||||
Long createClue(@Valid CrmClueSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新线索
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateClue(@Valid CrmClueUpdateReqVO updateReqVO);
|
||||
void updateClue(@Valid CrmClueSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除线索
|
||||
@ -73,4 +73,12 @@ public interface CrmClueService {
|
||||
*/
|
||||
void transferClue(CrmClueTransferReqVO reqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 线索转化为客户
|
||||
*
|
||||
* @param reqVO 线索编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void translate(CrmClueTransformReqVO reqVO, Long userId);
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,12 @@ package cn.iocoder.yudao.module.crm.service.clue;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueTransformReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
@ -15,15 +16,20 @@ import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CLUE_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 线索 Service 实现类
|
||||
@ -39,13 +45,19 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
|
||||
@Resource
|
||||
private CrmPermissionService crmPermissionService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public Long createClue(CrmClueCreateReqVO createReqVO) {
|
||||
// 校验客户是否存在
|
||||
customerService.validateCustomer(createReqVO.getCustomerId());
|
||||
// TODO @min:补充相关几个方法的操作日志;
|
||||
public Long createClue(CrmClueSaveReqVO createReqVO) {
|
||||
// 校验关联数据
|
||||
validateRelationDataExists(createReqVO);
|
||||
|
||||
// 插入
|
||||
CrmClueDO clue = CrmClueConvert.INSTANCE.convert(createReqVO);
|
||||
clueMapper.insert(clue);
|
||||
@ -55,11 +67,11 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public void updateClue(CrmClueUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
public void updateClue(CrmClueSaveReqVO updateReqVO) {
|
||||
// 校验线索是否存在
|
||||
validateClueExists(updateReqVO.getId());
|
||||
// 校验客户是否存在
|
||||
customerService.validateCustomer(updateReqVO.getCustomerId());
|
||||
// 校验关联数据
|
||||
validateRelationDataExists(updateReqVO);
|
||||
|
||||
// 更新
|
||||
CrmClueDO updateObj = CrmClueConvert.INSTANCE.convert(updateReqVO);
|
||||
@ -108,12 +120,47 @@ public class CrmClueServiceImpl implements CrmClueService {
|
||||
validateClueExists(reqVO.getId());
|
||||
|
||||
// 2.1 数据权限转移
|
||||
crmPermissionService.transferPermission(
|
||||
CrmClueConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_LEADS.getType()));
|
||||
crmPermissionService.transferPermission(CrmClueConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_LEADS.getType()));
|
||||
// 2.2 设置新的负责人
|
||||
clueMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
||||
// 3. TODO 记录转移日志
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void translate(CrmClueTransformReqVO reqVO, Long userId) {
|
||||
// 校验线索都存在
|
||||
List<CrmClueDO> clues = getClueList(reqVO.getIds(), userId);
|
||||
if (CollUtil.isEmpty(clues)) {
|
||||
throw exception(CLUE_NOT_EXISTS);
|
||||
}
|
||||
// TODO @min:如果已经转化,则不能重复转化
|
||||
|
||||
// 遍历线索,创建对应的客户
|
||||
clues.forEach(clue -> {
|
||||
// 创建客户
|
||||
customerService.createCustomer(CrmCustomerConvert.INSTANCE.convert(clue), userId);
|
||||
// 更新线索状态
|
||||
// TODO @min:新建一个 CrmClueDO 去更新。尽量规避直接用原本的对象去更新。因为这样万一并发更新,会存在覆盖的问题。
|
||||
// TODO @puhui999:如果有跟进记录,需要一起转过去;
|
||||
clue.setTransformStatus(Boolean.TRUE);
|
||||
clueMapper.updateById(clue);
|
||||
});
|
||||
}
|
||||
|
||||
private void validateRelationDataExists(CrmClueSaveReqVO reqVO) {
|
||||
// 校验客户
|
||||
if (Objects.nonNull(reqVO.getCustomerId()) &&
|
||||
Objects.isNull(customerService.getCustomer(reqVO.getCustomerId()))) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
// 校验负责人
|
||||
// 2. 校验负责人
|
||||
if (Objects.nonNull(reqVO.getOwnerUserId()) &&
|
||||
Objects.isNull(adminUserApi.getUser(reqVO.getOwnerUserId()))) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -27,6 +27,13 @@ public interface CrmContactBusinessService {
|
||||
*/
|
||||
void deleteContactBusinessList(@Valid CrmContactBusinessReqVO deleteReqVO);
|
||||
|
||||
/**
|
||||
* 删除联系人与商机的关联,基于联系人编号
|
||||
*
|
||||
* @param contactId 联系人编号
|
||||
*/
|
||||
void deleteContactBusinessByContactId(Long contactId);
|
||||
|
||||
/**
|
||||
* 获得联系人与商机的关联列表,基于联系人编号
|
||||
*
|
||||
|
@ -75,6 +75,11 @@ public class CrmContactBusinessServiceImpl implements CrmContactBusinessService
|
||||
deleteReqVO.getContactId(), deleteReqVO.getBusinessIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteContactBusinessByContactId(Long contactId) {
|
||||
contactBusinessMapper.delete(CrmContactBusinessDO::getContactId,contactId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmContactBusinessDO> getContactBusinessListByContactId(Long contactId) {
|
||||
return contactBusinessMapper.selectListByContactId(contactId);
|
||||
|
@ -1,10 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.service.contact;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import jakarta.validation.Valid;
|
||||
@ -26,14 +23,14 @@ public interface CrmContactService {
|
||||
* @param userId 用户编号
|
||||
* @return 编号
|
||||
*/
|
||||
Long createContact(@Valid CrmContactCreateReqVO createReqVO, Long userId);
|
||||
Long createContact(@Valid CrmContactSaveReqVO createReqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 更新联系人
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateContact(@Valid CrmContactUpdateReqVO updateReqVO);
|
||||
void updateContact(@Valid CrmContactSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除联系人
|
||||
@ -59,6 +56,13 @@ public interface CrmContactService {
|
||||
*/
|
||||
List<CrmContactDO> getContactList(Collection<Long> ids, Long userId);
|
||||
|
||||
/**
|
||||
* 获得联系人列表
|
||||
*
|
||||
* @return 联系人列表
|
||||
*/
|
||||
List<CrmContactDO> getContactList();
|
||||
|
||||
/**
|
||||
* 获得联系人分页
|
||||
*
|
||||
|
@ -3,17 +3,26 @@ package cn.iocoder.yudao.module.crm.service.contact;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactBusinessReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.contact.CrmContactMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -23,9 +32,10 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CONTACT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT_TYPE;
|
||||
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
|
||||
import static java.util.Collections.singletonList;
|
||||
|
||||
/**
|
||||
* CRM 联系人 Service 实现类
|
||||
@ -42,41 +52,60 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
@Resource
|
||||
private CrmPermissionService crmPermissionService;
|
||||
private CrmPermissionService permissionService;
|
||||
@Resource
|
||||
private CrmContractService contractService;
|
||||
@Resource
|
||||
private CrmContactBusinessService contactBusinessService;
|
||||
@Resource
|
||||
private CrmBusinessService businessService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
// TODO @zyna:增加操作日志,可以参考 CustomerService;内容是 新建了联系人【名字】
|
||||
public Long createContact(CrmContactCreateReqVO createReqVO, Long userId) {
|
||||
@LogRecord(type = CRM_CONTACT_TYPE, subType = "创建联系人", bizNo = "{{#contactId}}", success = "创建了联系人[{{#contactName}}]")
|
||||
public Long createContact(CrmContactSaveReqVO createReqVO, Long userId) {
|
||||
// 1. 校验
|
||||
validateRelationDataExists(createReqVO);
|
||||
|
||||
// 2. 插入联系人
|
||||
CrmContactDO contact = CrmContactConvert.INSTANCE.convert(createReqVO);
|
||||
CrmContactDO contact = BeanUtils.toBean(createReqVO, CrmContactDO.class);
|
||||
contactMapper.insert(contact);
|
||||
|
||||
// 3. 创建数据权限
|
||||
crmPermissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId)
|
||||
permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(userId)
|
||||
.setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()).setBizId(contact.getId())
|
||||
.setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
|
||||
|
||||
// TODO @zyna:特殊逻辑:如果在【商机】详情那,点击【新增联系人】时,可以自动绑定商机
|
||||
// 4. 如果有关联商机,则需要创建关联
|
||||
if (createReqVO.getBusinessId() != null) {
|
||||
contactBusinessService.createContactBusinessList(new CrmContactBusinessReqVO()
|
||||
.setContactId(contact.getId()).setBusinessIds(singletonList(createReqVO.getBusinessId())));
|
||||
}
|
||||
|
||||
// 5. 记录操作日志
|
||||
LogRecordContext.putVariable("contactId", contact.getId());
|
||||
LogRecordContext.putVariable("contactName", contact.getName());
|
||||
return contact.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CONTACT_TYPE, subType = "更新联系人", bizNo = "{{#updateReqVO.id}}", success = "更新了联系人{_DIFF{#updateReqVO}}")
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
// TODO @zyna:增加操作日志,可以参考 CustomerService;需要 diff 出字段
|
||||
public void updateContact(CrmContactUpdateReqVO updateReqVO) {
|
||||
public void updateContact(CrmContactSaveReqVO updateReqVO) {
|
||||
// 1. 校验存在
|
||||
validateContactExists(updateReqVO.getId());
|
||||
CrmContactDO contactDO = validateContactExists(updateReqVO.getId());
|
||||
validateRelationDataExists(updateReqVO);
|
||||
|
||||
// 2. 更新联系人
|
||||
CrmContactDO updateObj = CrmContactConvert.INSTANCE.convert(updateReqVO);
|
||||
CrmContactDO updateObj = BeanUtils.toBean(updateReqVO, CrmContactDO.class);
|
||||
contactMapper.updateById(updateObj);
|
||||
|
||||
// 3. 记录操作日志
|
||||
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(contactDO, CrmContactSaveReqVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -84,7 +113,7 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
*
|
||||
* @param saveReqVO 新增/修改请求 VO
|
||||
*/
|
||||
private void validateRelationDataExists(CrmContactBaseVO saveReqVO) {
|
||||
private void validateRelationDataExists(CrmContactSaveReqVO saveReqVO) {
|
||||
// 1. 校验客户
|
||||
if (saveReqVO.getCustomerId() != null && customerService.getCustomer(saveReqVO.getCustomerId()) == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
@ -97,28 +126,39 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
if (saveReqVO.getParentId() != null && contactMapper.selectById(saveReqVO.getParentId()) == null) {
|
||||
throw exception(CONTACT_NOT_EXISTS);
|
||||
}
|
||||
// 4. 如果有关联商机,则需要校验存在
|
||||
if (saveReqVO.getBusinessId() != null && businessService.getBusiness(saveReqVO.getBusinessId()) == null) {
|
||||
throw exception(BUSINESS_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteContact(Long id) {
|
||||
// 校验存在
|
||||
// 1.1 校验存在
|
||||
validateContactExists(id);
|
||||
// TODO @zyna:如果有关联的合同,不允许删除;Contract.contactId
|
||||
// 1.2 校验是否关联合同
|
||||
if (contractService.getContractCountByContactId(id) > 0) {
|
||||
throw exception(CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS);
|
||||
}
|
||||
|
||||
// 删除
|
||||
// 2. 删除联系人
|
||||
contactMapper.deleteById(id);
|
||||
// 删除数据权限
|
||||
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id);
|
||||
// TODO @zyna:删除商机联系人关联
|
||||
|
||||
// 4.1 删除数据权限
|
||||
permissionService.deletePermission(CrmBizTypeEnum.CRM_CONTACT.getType(), id);
|
||||
// 4.2 删除商机关联
|
||||
contactBusinessService.deleteContactBusinessByContactId(id);
|
||||
// TODO @puhui999:删除跟进记录
|
||||
}
|
||||
|
||||
private void validateContactExists(Long id) {
|
||||
if (contactMapper.selectById(id) == null) {
|
||||
private CrmContactDO validateContactExists(Long id) {
|
||||
CrmContactDO contactDO = contactMapper.selectById(id);
|
||||
if (contactDO == null) {
|
||||
throw exception(CONTACT_NOT_EXISTS);
|
||||
}
|
||||
return contactDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,6 +175,11 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
return contactMapper.selectBatchIds(ids, userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmContactDO> getContactList() {
|
||||
return contactMapper.selectList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO, Long userId) {
|
||||
return contactMapper.selectPage(pageReqVO, userId);
|
||||
@ -154,7 +199,7 @@ public class CrmContactServiceImpl implements CrmContactService {
|
||||
validateContactExists(reqVO.getId());
|
||||
|
||||
// 2.1 数据权限转移
|
||||
crmPermissionService.transferPermission(
|
||||
permissionService.transferPermission(
|
||||
CrmContactConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CONTACT.getType()));
|
||||
// 2.2 设置新的负责人
|
||||
contactMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
@ -87,4 +87,12 @@ public interface CrmContractService {
|
||||
*/
|
||||
void transferContract(CrmContractTransferReqVO reqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 查询属于某个联系人的合同数量
|
||||
*
|
||||
* @param contactId 联系人ID
|
||||
* @return 合同
|
||||
*/
|
||||
Long getContractCountByContactId(Long contactId);
|
||||
|
||||
}
|
||||
|
@ -135,5 +135,10 @@ public class CrmContractServiceImpl implements CrmContractService {
|
||||
contractMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getContractCountByContactId(Long contactId) {
|
||||
return contractMapper.selectCountByContactId(contactId);
|
||||
}
|
||||
|
||||
// TODO @合同待定:需要新增一个 ContractConfigDO 表,合同配置,重点是到期提醒;
|
||||
}
|
||||
|
@ -1,9 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.service.customer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@ -22,14 +21,14 @@ public interface CrmCustomerLimitConfigService {
|
||||
* @param createReqVO 创建信息
|
||||
* @return 编号
|
||||
*/
|
||||
Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigCreateReqVO createReqVO);
|
||||
Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 更新客户限制配置
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigUpdateReqVO updateReqVO);
|
||||
void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除客户限制配置
|
||||
@ -57,7 +56,7 @@ public interface CrmCustomerLimitConfigService {
|
||||
/**
|
||||
* 查询用户对应的配置列表
|
||||
*
|
||||
* @param type 类型
|
||||
* @param type 类型
|
||||
* @param userId 用户类型
|
||||
*/
|
||||
List<CrmCustomerLimitConfigDO> getCustomerLimitConfigListByUserId(Integer type, Long userId);
|
||||
|
@ -2,25 +2,29 @@ package cn.iocoder.yudao.module.crm.service.customer;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
||||
|
||||
/**
|
||||
* 客户限制配置 Service 实现类
|
||||
@ -40,34 +44,46 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
public Long createCustomerLimitConfig(CrmCustomerLimitConfigCreateReqVO createReqVO) {
|
||||
@LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}",
|
||||
success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS)
|
||||
public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) {
|
||||
validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds());
|
||||
// 插入
|
||||
CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO);
|
||||
customerLimitConfigMapper.insert(customerLimitConfig);
|
||||
// 返回
|
||||
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(customerLimitConfig.getType()));
|
||||
LogRecordContext.putVariable("limitId", customerLimitConfig.getId());
|
||||
return customerLimitConfig.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
public void updateCustomerLimitConfig(CrmCustomerLimitConfigUpdateReqVO updateReqVO) {
|
||||
@LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||
success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS)
|
||||
public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateCustomerLimitConfigExists(updateReqVO.getId());
|
||||
CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId());
|
||||
validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds());
|
||||
// 更新
|
||||
CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO);
|
||||
customerLimitConfigMapper.updateById(updateObj);
|
||||
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldLimitConfig, CrmCustomerLimitConfigSaveReqVO.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}",
|
||||
success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS)
|
||||
public void deleteCustomerLimitConfig(Long id) {
|
||||
// 校验存在
|
||||
validateCustomerLimitConfigExists(id);
|
||||
CrmCustomerLimitConfigDO limitConfigDO = validateCustomerLimitConfigExists(id);
|
||||
// 删除
|
||||
customerLimitConfigMapper.deleteById(id);
|
||||
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(limitConfigDO.getType()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -80,10 +96,12 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig
|
||||
return customerLimitConfigMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
private void validateCustomerLimitConfigExists(Long id) {
|
||||
if (customerLimitConfigMapper.selectById(id) == null) {
|
||||
private CrmCustomerLimitConfigDO validateCustomerLimitConfigExists(Long id) {
|
||||
CrmCustomerLimitConfigDO limitConfigDO = customerLimitConfigMapper.selectById(id);
|
||||
if (limitConfigDO == null) {
|
||||
throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS);
|
||||
}
|
||||
return limitConfigDO;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,12 +5,16 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCu
|
||||
import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper;
|
||||
import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
||||
|
||||
/**
|
||||
* 客户公海配置 Service 实现类
|
||||
*
|
||||
@ -19,6 +23,7 @@ import java.util.Objects;
|
||||
@Service
|
||||
@Validated
|
||||
public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService {
|
||||
|
||||
@Resource
|
||||
private CrmCustomerPoolConfigMapper customerPoolConfigMapper;
|
||||
|
||||
@ -29,6 +34,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe
|
||||
*/
|
||||
@Override
|
||||
public CrmCustomerPoolConfigDO getCustomerPoolConfig() {
|
||||
// TODO @puhui999:这个要搞到 mapper 里噢。
|
||||
return customerPoolConfigMapper.selectOne(new LambdaQueryWrapperX<CrmCustomerPoolConfigDO>().last("LIMIT 1"));
|
||||
}
|
||||
|
||||
@ -38,16 +44,24 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe
|
||||
* @param saveReqVO 更新信息
|
||||
*/
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}",
|
||||
success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS)
|
||||
public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) {
|
||||
// 存在,则进行更新
|
||||
CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig();
|
||||
CrmCustomerPoolConfigDO poolConfig = CrmCustomerConvert.INSTANCE.convert(saveReqVO);
|
||||
if (Objects.nonNull(dbConfig)) {
|
||||
customerPoolConfigMapper.updateById(CrmCustomerConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId()));
|
||||
customerPoolConfigMapper.updateById(poolConfig.setId(dbConfig.getId()));
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.TRUE);
|
||||
LogRecordContext.putVariable("poolConfigId", poolConfig.getId());
|
||||
return;
|
||||
}
|
||||
// 不存在,则进行插入
|
||||
customerPoolConfigMapper.insert(CrmCustomerConvert.INSTANCE.convert(saveReqVO));
|
||||
customerPoolConfigMapper.insert(poolConfig);
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.FALSE);
|
||||
LogRecordContext.putVariable("poolConfigId", poolConfig.getId());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
package cn.iocoder.yudao.module.crm.service.customer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLockReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
@ -22,14 +25,14 @@ public interface CrmCustomerService {
|
||||
* @param userId 用户编号
|
||||
* @return 编号
|
||||
*/
|
||||
Long createCustomer(@Valid CrmCustomerCreateReqVO createReqVO, Long userId);
|
||||
Long createCustomer(@Valid CrmCustomerSaveReqVO createReqVO, Long userId);
|
||||
|
||||
/**
|
||||
* 更新客户
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void updateCustomer(@Valid CrmCustomerUpdateReqVO updateReqVO);
|
||||
void updateCustomer(@Valid CrmCustomerSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 删除客户
|
||||
@ -83,7 +86,7 @@ public interface CrmCustomerService {
|
||||
* 锁定/解锁客户
|
||||
*
|
||||
* @param lockReqVO 更新信息
|
||||
* @param userId 用户编号
|
||||
* @param userId 用户编号
|
||||
*/
|
||||
void lockCustomer(@Valid CrmCustomerLockReqVO lockReqVO, Long userId);
|
||||
|
||||
@ -101,15 +104,8 @@ public interface CrmCustomerService {
|
||||
*
|
||||
* @param ids 要领取的客户编号数组
|
||||
* @param ownerUserId 负责人
|
||||
* @param isReceive 是/否领取
|
||||
*/
|
||||
void receiveCustomer(List<Long> ids, Long ownerUserId);
|
||||
|
||||
/**
|
||||
* 获取客户列表
|
||||
*
|
||||
* @return 客户列表
|
||||
* @author zyna
|
||||
*/
|
||||
List<CrmCustomerDO> getCustomerList();
|
||||
void receiveCustomer(List<Long> ids, Long ownerUserId, Boolean isReceive);
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,15 @@
|
||||
package cn.iocoder.yudao.module.crm.service.customer;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerLockReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
|
||||
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.CrmCustomerLimitConfigDO;
|
||||
@ -12,9 +17,11 @@ import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.framework.permission.core.util.CrmPermissionUtils;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.mzt.logapi.context.LogRecordContext;
|
||||
import com.mzt.logapi.service.impl.DiffParseFunction;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
@ -24,12 +31,14 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CUSTOMER;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.TRANSFER_CUSTOMER_LOG_SUCCESS;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_LOCK_LIMIT;
|
||||
import static cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum.CUSTOMER_OWNER_LIMIT;
|
||||
import static java.util.Collections.singletonList;
|
||||
@ -56,8 +65,10 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CUSTOMER, subType = "创建客户", bizNo = "{{#customerId}}", success = "创建了客户") // TODO @puhui999:创建了客户【客户名】,要记录进去;不然在展示操作日志的全列表,看不清楚是哪个客户哈;
|
||||
public Long createCustomer(CrmCustomerCreateReqVO createReqVO, Long userId) {
|
||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}",
|
||||
success = CRM_CUSTOMER_CREATE_SUCCESS)
|
||||
public Long createCustomer(CrmCustomerSaveReqVO createReqVO, Long userId) {
|
||||
createReqVO.setId(null);
|
||||
// 1. 校验拥有客户是否到达上限
|
||||
validateCustomerExceedOwnerLimit(createReqVO.getOwnerUserId(), 1);
|
||||
|
||||
@ -72,17 +83,19 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType())
|
||||
.setBizId(customer.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人
|
||||
|
||||
// 4. 记录操作日志
|
||||
LogRecordContext.putVariable("customerId", customer.getId());
|
||||
// 4. 记录操作日志上下文
|
||||
LogRecordContext.putVariable("customer", customer);
|
||||
return customer.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CUSTOMER, subType = "更新客户", bizNo = "{{#updateReqVO.id}}", success = "更新了客户{_DIFF{#updateReqVO}}", extra = "{{#extra}}")
|
||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||
success = CRM_CUSTOMER_UPDATE_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) {
|
||||
// TODO @puhui999:更新的时候,要把 updateReqVO 负责人设置为空,避免修改。
|
||||
public void updateCustomer(CrmCustomerSaveReqVO updateReqVO) {
|
||||
Assert.notNull(updateReqVO.getId(), "客户编号不能为空");
|
||||
updateReqVO.setOwnerUserId(null); // 更新的时候,要把 updateReqVO 负责人设置为空,避免修改
|
||||
// 1. 校验存在
|
||||
CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId());
|
||||
|
||||
@ -90,21 +103,19 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO);
|
||||
customerMapper.updateById(updateObj);
|
||||
|
||||
// 3. 记录操作日志
|
||||
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomer, CrmCustomerUpdateReqVO.class));
|
||||
// TODO 扩展信息测试 @puhui999:看着没啥问题,可以删除啦;
|
||||
HashMap<String, Object> extra = new HashMap<>();
|
||||
extra.put("tips", "随便记录一点啦");
|
||||
LogRecordContext.putVariable("extra", extra);
|
||||
// 3. 记录操作日志上下文
|
||||
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomer, CrmCustomerSaveReqVO.class));
|
||||
LogRecordContext.putVariable("customerName", oldCustomer.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CUSTOMER, subType = "删除客户", bizNo = "{{#id}}", success = "删除了客户")
|
||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_DELETE_SUB_TYPE, bizNo = "{{#id}}",
|
||||
success = CRM_CUSTOMER_DELETE_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void deleteCustomer(Long id) {
|
||||
// 校验存在
|
||||
validateCustomerExists(id);
|
||||
CrmCustomerDO customer = validateCustomerExists(id);
|
||||
// TODO @puhui999:如果有联系人、商机,则不允许删除;
|
||||
|
||||
// 删除
|
||||
@ -112,16 +123,152 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
// 删除数据权限
|
||||
permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id);
|
||||
// TODO @puhui999:删除跟进记录
|
||||
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable("customerName", customer.getName());
|
||||
}
|
||||
|
||||
private CrmCustomerDO validateCustomerExists(Long id) {
|
||||
CrmCustomerDO customerDO = customerMapper.selectById(id);
|
||||
if (customerDO == null) {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}",
|
||||
success = CRM_CUSTOMER_TRANSFER_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
||||
// 1.1 校验客户是否存在
|
||||
CrmCustomerDO customer = validateCustomerExists(reqVO.getId());
|
||||
// 1.2 校验拥有客户是否到达上限
|
||||
validateCustomerExceedOwnerLimit(reqVO.getNewOwnerUserId(), 1);
|
||||
|
||||
// 2.1 数据权限转移
|
||||
permissionService.transferPermission(
|
||||
CrmCustomerConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()));
|
||||
// 2.2 转移后重新设置负责人
|
||||
customerMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
||||
// 3. TODO 记录转移日志
|
||||
// 记录操作日志上下文
|
||||
// TODO @puhui999:crmCustomer=》customer,也看看其他有没类似的情况哈
|
||||
LogRecordContext.putVariable("crmCustomer", customer);
|
||||
}
|
||||
|
||||
@Override
|
||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}",
|
||||
success = CRM_CUSTOMER_LOCK_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#lockReqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void lockCustomer(CrmCustomerLockReqVO lockReqVO, Long userId) {
|
||||
// 1.1 校验当前客户是否存在
|
||||
CrmCustomerDO customer = validateCustomerExists(lockReqVO.getId());
|
||||
// 1.2 校验当前是否重复操作锁定/解锁状态
|
||||
if (customer.getLockStatus().equals(lockReqVO.getLockStatus())) {
|
||||
throw exception(customer.getLockStatus() ? CUSTOMER_LOCK_FAIL_IS_LOCK : CUSTOMER_UNLOCK_FAIL_IS_UNLOCK);
|
||||
}
|
||||
// 1.3 校验锁定上限。
|
||||
if (lockReqVO.getLockStatus()) {
|
||||
validateCustomerExceedLockLimit(userId);
|
||||
}
|
||||
|
||||
// 2. 更新锁定状态
|
||||
customerMapper.updateById(BeanUtils.toBean(lockReqVO, CrmCustomerDO.class));
|
||||
|
||||
// 3. 记录操作日志上下文
|
||||
// tips: 因为这里使用的是老的状态所以记录时反着记录,也就是 lockStatus 为 true 那么就是解锁反之为锁定
|
||||
LogRecordContext.putVariable("crmCustomer", customer);
|
||||
}
|
||||
|
||||
// ==================== 公海相关操作 ====================
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_POOL_SUB_TYPE, bizNo = "{{#id}}",
|
||||
success = CRM_CUSTOMER_POOL_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void putCustomerPool(Long id) {
|
||||
// 1. 校验存在
|
||||
CrmCustomerDO customer = customerMapper.selectById(id);
|
||||
if (customer == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
return customerDO;
|
||||
// 1.2. 校验是否为公海数据
|
||||
validateCustomerOwnerExists(customer, true);
|
||||
// 1.3. 校验客户是否锁定
|
||||
validateCustomerIsLocked(customer, true);
|
||||
|
||||
// 2. 设置负责人为 NULL
|
||||
int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null);
|
||||
if (updateOwnerUserIncr == 0) {
|
||||
throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL);
|
||||
}
|
||||
// 3. 删除负责人数据权限
|
||||
permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(),
|
||||
CrmPermissionLevelEnum.OWNER.getLevel());
|
||||
// TODO @puhui999:联系人的负责人,也要设置为 null;这块和领取是对应的;因为领取后,负责人也要关联过来;
|
||||
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable("customerName", customer.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void receiveCustomer(List<Long> ids, Long ownerUserId, Boolean isReceive) {
|
||||
if (!isReceive && !CrmPermissionUtils.isCrmAdmin()) { // 只有管理员可以分配
|
||||
throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.CRM_CUSTOMER.getName());
|
||||
}
|
||||
|
||||
// 1.1 校验存在
|
||||
List<CrmCustomerDO> customers = customerMapper.selectBatchIds(ids);
|
||||
if (customers.size() != ids.size()) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
// 1.2. 校验负责人是否存在
|
||||
adminUserApi.validateUserList(singletonList(ownerUserId));
|
||||
// 1.3. 校验状态
|
||||
customers.forEach(customer -> {
|
||||
// 校验是否已有负责人
|
||||
validateCustomerOwnerExists(customer, false);
|
||||
// 校验是否锁定
|
||||
validateCustomerIsLocked(customer, false);
|
||||
// 校验成交状态
|
||||
validateCustomerDeal(customer);
|
||||
});
|
||||
// 1.4 校验负责人是否到达上限
|
||||
validateCustomerExceedOwnerLimit(ownerUserId, customers.size());
|
||||
|
||||
// 2.1 领取公海数据
|
||||
List<CrmCustomerDO> updateCustomers = new ArrayList<>();
|
||||
List<CrmPermissionCreateReqBO> createPermissions = new ArrayList<>();
|
||||
customers.forEach(customer -> {
|
||||
// 2.1. 设置负责人
|
||||
updateCustomers.add(new CrmCustomerDO().setId(customer.getId()).setOwnerUserId(ownerUserId));
|
||||
// 2.2. 创建负责人数据权限
|
||||
createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType())
|
||||
.setBizId(customer.getId()).setUserId(ownerUserId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
|
||||
});
|
||||
// 2.2 更新客户负责人
|
||||
customerMapper.updateBatch(updateCustomers);
|
||||
// 2.3 创建负责人数据权限
|
||||
permissionService.createPermissionBatch(createPermissions);
|
||||
// TODO @芋艿:要不要处理关联的联系人???
|
||||
|
||||
// 3. 记录操作日志
|
||||
AdminUserRespDTO user = null;
|
||||
if (!isReceive) {
|
||||
user = adminUserApi.getUser(ownerUserId);
|
||||
}
|
||||
for (CrmCustomerDO customer : customers) {
|
||||
getSelf().receiveCustomerLog(customer, user == null ? null : user.getNickname());
|
||||
}
|
||||
}
|
||||
|
||||
@LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}",
|
||||
success = CRM_CUSTOMER_RECEIVE_SUCCESS)
|
||||
public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) {
|
||||
// 记录操作日志上下文
|
||||
LogRecordContext.putVariable("customer", customer);
|
||||
LogRecordContext.putVariable("ownerUserName", ownerUserName);
|
||||
}
|
||||
|
||||
//======================= 查询相关 =======================
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmCustomerDO getCustomer(Long id) {
|
||||
@ -141,6 +288,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
return customerMapper.selectPage(pageReqVO, userId);
|
||||
}
|
||||
|
||||
// ======================= 校验相关 =======================
|
||||
|
||||
/**
|
||||
* 校验客户是否存在
|
||||
*
|
||||
@ -151,53 +300,44 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
validateCustomerExists(customerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CUSTOMER, subType = "转移客户", bizNo = "{{#reqVO.id}}", success = TRANSFER_CUSTOMER_LOG_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
|
||||
// 1.1 校验客户是否存在
|
||||
CrmCustomerDO customer = validateCustomerExists(reqVO.getId());
|
||||
// 1.2 校验拥有客户是否到达上限
|
||||
validateCustomerExceedOwnerLimit(reqVO.getNewOwnerUserId(), 1);
|
||||
|
||||
// 2.1 数据权限转移
|
||||
permissionService.transferPermission(
|
||||
CrmCustomerConvert.INSTANCE.convert(reqVO, userId).setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType()));
|
||||
// 2.2 转移后重新设置负责人
|
||||
customerMapper.updateOwnerUserIdById(reqVO.getId(), reqVO.getNewOwnerUserId());
|
||||
|
||||
// 3. TODO 记录转移日志
|
||||
LogRecordContext.putVariable("crmCustomer", customer);
|
||||
private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) {
|
||||
if (customer == null) { // 防御一下
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
// 校验是否为公海数据
|
||||
if (pool && customer.getOwnerUserId() == null) {
|
||||
throw exception(CUSTOMER_IN_POOL, customer.getName());
|
||||
}
|
||||
// 负责人已存在
|
||||
if (!pool && customer.getOwnerUserId() != null) {
|
||||
throw exception(CUSTOMER_OWNER_EXISTS, customer.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:看看这个能不能根据条件,写操作日志;
|
||||
// TODO 如果是 锁定,则 subType 为 锁定客户;success 为 将客户【】锁定
|
||||
// TODO 如果是 解锁,则 subType 为 解锁客户;success 为 将客户【】解锁
|
||||
@LogRecord(type = CRM_CUSTOMER, subType = "锁定/解锁客户", bizNo = "{{#updateReqVO.id}}", success = "锁定了客户")
|
||||
// TODO @puhui999:数据权限
|
||||
public void lockCustomer(CrmCustomerLockReqVO lockReqVO, Long userId) {
|
||||
// 1.1 校验当前客户是否存在
|
||||
validateCustomerExists(lockReqVO.getId());
|
||||
// 1.2 校验当前是否重复操作锁定/解锁状态
|
||||
CrmCustomerDO customer = customerMapper.selectById(lockReqVO.getId());
|
||||
if (customer.getLockStatus().equals(lockReqVO.getLockStatus())) {
|
||||
throw exception(customer.getLockStatus() ? CUSTOMER_LOCK_FAIL_IS_LOCK : CUSTOMER_UNLOCK_FAIL_IS_UNLOCK);
|
||||
}
|
||||
// 1.3 校验锁定上限。
|
||||
if (lockReqVO.getLockStatus()) {
|
||||
validateCustomerExceedLockLimit(userId);
|
||||
private CrmCustomerDO validateCustomerExists(Long id) {
|
||||
CrmCustomerDO customerDO = customerMapper.selectById(id);
|
||||
if (customerDO == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
return customerDO;
|
||||
}
|
||||
|
||||
// 2. 更新锁定状态
|
||||
customerMapper.updateById(BeanUtils.toBean(lockReqVO, CrmCustomerDO.class));
|
||||
private void validateCustomerIsLocked(CrmCustomerDO customer, Boolean pool) {
|
||||
if (customer.getLockStatus()) {
|
||||
throw exception(pool ? CUSTOMER_LOCKED_PUT_POOL_FAIL : CUSTOMER_LOCKED, customer.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCustomerDeal(CrmCustomerDO customer) {
|
||||
if (customer.getDealStatus()) {
|
||||
throw exception(CUSTOMER_ALREADY_DEAL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户拥有的客户数量,是否到达上限
|
||||
*
|
||||
* @param userId 用户编号
|
||||
* @param userId 用户编号
|
||||
* @param newCount 附加数量
|
||||
*/
|
||||
private void validateCustomerExceedOwnerLimit(Long userId, int newCount) {
|
||||
@ -235,105 +375,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_CUSTOMER, subType = "客户放入公海", bizNo = "{{#id}}", success = "将客户放入了公海") // TODO @puhui999:将客户【】放入了公海
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void putCustomerPool(Long id) {
|
||||
// 1. 校验存在
|
||||
CrmCustomerDO customer = customerMapper.selectById(id);
|
||||
if (customer == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
// 1.2. 校验是否为公海数据
|
||||
validateCustomerOwnerExists(customer, true);
|
||||
// 1.3. 校验客户是否锁定
|
||||
validateCustomerIsLocked(customer, true);
|
||||
|
||||
// 2. 设置负责人为 NULL
|
||||
int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null);
|
||||
if (updateOwnerUserIncr == 0) {
|
||||
throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL);
|
||||
}
|
||||
// 3. 删除负责人数据权限
|
||||
permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(),
|
||||
CrmPermissionLevelEnum.OWNER.getLevel());
|
||||
// TODO @puhui999:联系人的负责人,也要设置为 null;这块和领取是对应的;因为领取后,负责人也要关联过来;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
// TODO @puhui999:权限校验
|
||||
|
||||
// TODO @puhui999:如果是分配,操作日志是 “将客户【】分配给【】”
|
||||
// TODO @puhui999:如果是领取,操作日志是“领取客户【】”;
|
||||
// TODO @puhui999:如果是多条,则需要记录多条操作日志;不然 bizId 不好关联
|
||||
public void receiveCustomer(List<Long> ids, Long ownerUserId) {
|
||||
// 1.1 校验存在
|
||||
List<CrmCustomerDO> customers = customerMapper.selectBatchIds(ids);
|
||||
if (customers.size() != ids.size()) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
// 1.2. 校验负责人是否存在
|
||||
adminUserApi.validateUserList(singletonList(ownerUserId));
|
||||
// 1.3. 校验状态
|
||||
customers.forEach(customer -> {
|
||||
// 校验是否已有负责人
|
||||
validateCustomerOwnerExists(customer, false);
|
||||
// 校验是否锁定
|
||||
validateCustomerIsLocked(customer, false);
|
||||
// 校验成交状态
|
||||
validateCustomerDeal(customer);
|
||||
});
|
||||
// 1.4 校验负责人是否到达上限
|
||||
validateCustomerExceedOwnerLimit(ownerUserId, customers.size());
|
||||
|
||||
// 2.1 领取公海数据
|
||||
List<CrmCustomerDO> updateCustomers = new ArrayList<>();
|
||||
List<CrmPermissionCreateReqBO> createPermissions = new ArrayList<>();
|
||||
customers.forEach(customer -> {
|
||||
// 2.1. 设置负责人
|
||||
updateCustomers.add(new CrmCustomerDO().setId(customer.getId()).setOwnerUserId(ownerUserId));
|
||||
// 2.2. 创建负责人数据权限
|
||||
createPermissions.add(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_CUSTOMER.getType())
|
||||
.setBizId(customer.getId()).setUserId(ownerUserId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
|
||||
});
|
||||
// 2.2 更新客户负责人
|
||||
customerMapper.updateBatch(updateCustomers);
|
||||
// 2.3 创建负责人数据权限
|
||||
permissionService.createPermissionBatch(createPermissions);
|
||||
// TODO @芋艿:要不要处理关联的联系人???
|
||||
}
|
||||
|
||||
private void validateCustomerOwnerExists(CrmCustomerDO customer, Boolean pool) {
|
||||
if (customer == null) { // 防御一下
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
// 校验是否为公海数据
|
||||
if (pool && customer.getOwnerUserId() == null) {
|
||||
throw exception(CUSTOMER_IN_POOL, customer.getName());
|
||||
}
|
||||
// 负责人已存在
|
||||
if (customer.getOwnerUserId() != null) {
|
||||
throw exception(CUSTOMER_OWNER_EXISTS, customer.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCustomerIsLocked(CrmCustomerDO customer, Boolean pool) {
|
||||
if (customer.getLockStatus()) {
|
||||
throw exception(pool ? CUSTOMER_LOCKED_PUT_POOL_FAIL : CUSTOMER_LOCKED, customer.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void validateCustomerDeal(CrmCustomerDO customer) {
|
||||
if (customer.getDealStatus()) {
|
||||
throw exception(CUSTOMER_ALREADY_DEAL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmCustomerDO> getCustomerList() {
|
||||
return customerMapper.selectList();
|
||||
/**
|
||||
* 获得自身的代理对象,解决 AOP 生效问题
|
||||
*
|
||||
* @return 自己
|
||||
*/
|
||||
private CrmCustomerServiceImpl getSelf() {
|
||||
return SpringUtil.getBean(getClass());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,6 +90,15 @@ public interface CrmPermissionService {
|
||||
*/
|
||||
List<CrmPermissionDO> getPermissionListByBiz(Integer bizType, Long bizId);
|
||||
|
||||
/**
|
||||
* 获取数据权限列表,通过 数据类型 x 某个数据
|
||||
*
|
||||
* @param bizType 数据类型,关联 {@link CrmBizTypeEnum}
|
||||
* @param bizIds 数据编号,关联 {@link CrmBizTypeEnum} 对应模块 DO#getId()
|
||||
* @return Crm 数据权限列表
|
||||
*/
|
||||
List<CrmPermissionDO> getPermissionListByBiz(Integer bizType, Collection<Long> bizIds);
|
||||
|
||||
/**
|
||||
* 获取用户参与的模块数据列表
|
||||
*
|
||||
|
@ -187,6 +187,11 @@ public class CrmPermissionServiceImpl implements CrmPermissionService {
|
||||
return crmPermissionMapper.selectByBizTypeAndBizId(bizType, bizId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmPermissionDO> getPermissionListByBiz(Integer bizType, Collection<Long> bizIds) {
|
||||
return crmPermissionMapper.selectByBizTypeAndBizIds(bizType, bizIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CrmPermissionDO> getPermissionListByBizTypeAndUserId(Integer bizType, Long userId) {
|
||||
return crmPermissionMapper.selectListByBizTypeAndUserId(bizType, userId);
|
||||
|
@ -5,6 +5,10 @@ import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProdu
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductCategoryMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -17,6 +21,7 @@ import java.util.Objects;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO.PARENT_ID_NULL;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
||||
|
||||
/**
|
||||
* CRM 产品分类 Service 实现类
|
||||
@ -35,12 +40,16 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
|
||||
private CrmProductService crmProductService;
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE, bizNo = "{{#createReqVO.id}}",
|
||||
success = CRM_PRODUCT_CATEGORY_CREATE_SUCCESS)
|
||||
// TODO @hao:产品分类,应该没数据权限。可以删除下哈;
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#createReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public Long createProductCategory(CrmProductCategoryCreateReqVO createReqVO) {
|
||||
// 1.1 校验父分类存在
|
||||
validateParentProductCategory(createReqVO.getParentId());
|
||||
// 1.2 分类名称是否存在
|
||||
validateProductNameExists(null, createReqVO.getParentId(), createReqVO.getName());
|
||||
|
||||
// 2. 插入分类
|
||||
CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class);
|
||||
productCategoryMapper.insert(category);
|
||||
@ -48,7 +57,9 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||
success = CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public void updateProductCategory(CrmProductCategoryCreateReqVO updateReqVO) {
|
||||
// 1.1 校验存在
|
||||
validateProductCategoryExists(updateReqVO.getId());
|
||||
@ -56,6 +67,7 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
|
||||
validateParentProductCategory(updateReqVO.getParentId());
|
||||
// 1.3 分类名称是否存在
|
||||
validateProductNameExists(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
|
||||
|
||||
// 2. 更新分类
|
||||
CrmProductCategoryDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductCategoryDO.class);
|
||||
productCategoryMapper.updateById(updateObj);
|
||||
@ -93,7 +105,9 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE, bizNo = "{{#id}}",
|
||||
success = CRM_PRODUCT_CATEGORY_DELETE_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void deleteProductCategory(Long id) {
|
||||
// 1.1 校验存在
|
||||
validateProductCategoryExists(id);
|
||||
@ -110,16 +124,19 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmProductCategoryDO getProductCategory(Long id) {
|
||||
return productCategoryMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#listReqVO.id", level = CrmPermissionLevelEnum.READ)
|
||||
public List<CrmProductCategoryDO> getProductCategoryList(CrmProductCategoryListReqVO listReqVO) {
|
||||
return productCategoryMapper.selectList(listReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#listReqVO.id", level = CrmPermissionLevelEnum.READ)
|
||||
public List<CrmProductCategoryDO> getProductCategoryList(Collection<Long> ids) {
|
||||
return productCategoryMapper.selectBatchIds(ids);
|
||||
}
|
||||
|
@ -11,22 +11,26 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductMapper;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mzt.logapi.starter.annotation.LogRecord;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
|
||||
|
||||
|
||||
// TODO 芋艿:数据权限
|
||||
/**
|
||||
* CRM 产品 Service 实现类
|
||||
*
|
||||
@ -48,7 +52,10 @@ public class CrmProductServiceImpl implements CrmProductService {
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#createReqVO.id}}",
|
||||
success = CRM_PRODUCT_CREATE_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#createReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public Long createProduct(CrmProductSaveReqVO createReqVO) {
|
||||
// 校验产品
|
||||
adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId()));
|
||||
@ -67,7 +74,9 @@ public class CrmProductServiceImpl implements CrmProductService {
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
|
||||
success = CRM_PRODUCT_UPDATE_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
|
||||
public void updateProduct(CrmProductSaveReqVO updateReqVO) {
|
||||
// 校验产品
|
||||
updateReqVO.setOwnerUserId(null); // 不修改负责人
|
||||
@ -90,7 +99,7 @@ public class CrmProductServiceImpl implements CrmProductService {
|
||||
private void validateProductNoDuplicate(Long id, String no) {
|
||||
CrmProductDO product = productMapper.selectByNo(no);
|
||||
if (product == null
|
||||
|| product.getId().equals(id)) {
|
||||
|| product.getId().equals(id)) {
|
||||
return;
|
||||
}
|
||||
throw exception(PRODUCT_NO_EXISTS);
|
||||
@ -104,7 +113,9 @@ public class CrmProductServiceImpl implements CrmProductService {
|
||||
}
|
||||
|
||||
@Override
|
||||
// TODO @puhui999:操作日志
|
||||
@LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_DELETE_SUB_TYPE, bizNo = "{{#id}}",
|
||||
success = CRM_PRODUCT_DELETE_SUCCESS)
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
|
||||
public void deleteProduct(Long id) {
|
||||
// 校验存在
|
||||
validateProductExists(id);
|
||||
@ -113,6 +124,7 @@ public class CrmProductServiceImpl implements CrmProductService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.READ)
|
||||
public CrmProductDO getProduct(Long id) {
|
||||
return productMapper.selectById(id);
|
||||
}
|
||||
@ -126,6 +138,7 @@ public class CrmProductServiceImpl implements CrmProductService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#pageReqVO.id", level = CrmPermissionLevelEnum.READ)
|
||||
public PageResult<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO) {
|
||||
return productMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
@ -2,9 +2,8 @@ package cn.iocoder.yudao.module.crm.service.clue;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmCluePageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.clue.CrmClueMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
@ -43,7 +42,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateClue_success() {
|
||||
// 准备参数
|
||||
CrmClueCreateReqVO reqVO = randomPojo(CrmClueCreateReqVO.class);
|
||||
CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long clueId = clueService.createClue(reqVO);
|
||||
@ -60,7 +59,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest {
|
||||
CrmClueDO dbClue = randomPojo(CrmClueDO.class);
|
||||
clueMapper.insert(dbClue);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class, o -> {
|
||||
CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class, o -> {
|
||||
o.setId(dbClue.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
@ -74,7 +73,7 @@ public class CrmClueServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateClue_notExists() {
|
||||
// 准备参数
|
||||
CrmClueUpdateReqVO reqVO = randomPojo(CrmClueUpdateReqVO.class);
|
||||
CrmClueSaveReqVO reqVO = randomPojo(CrmClueSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> clueService.updateClue(reqVO), CLUE_NOT_EXISTS);
|
||||
|
@ -2,19 +2,17 @@ package cn.iocoder.yudao.module.crm.service.customer;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerMapper;
|
||||
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
@ -47,7 +45,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateCustomer_success() {
|
||||
// 准备参数
|
||||
CrmCustomerCreateReqVO reqVO = randomPojo(CrmCustomerCreateReqVO.class);
|
||||
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long customerId = customerService.createCustomer(reqVO, getLoginUserId());
|
||||
@ -64,7 +62,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
|
||||
CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class);
|
||||
customerMapper.insert(dbCustomer);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class, o -> {
|
||||
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class, o -> {
|
||||
o.setId(dbCustomer.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
@ -78,7 +76,7 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateCustomer_notExists() {
|
||||
// 准备参数
|
||||
CrmCustomerUpdateReqVO reqVO = randomPojo(CrmCustomerUpdateReqVO.class);
|
||||
CrmCustomerSaveReqVO reqVO = randomPojo(CrmCustomerSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> customerService.updateCustomer(reqVO), CUSTOMER_NOT_EXISTS);
|
||||
@ -140,38 +138,4 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest {
|
||||
//assertPojoEquals(dbCustomer, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解
|
||||
public void testGetCustomerList() {
|
||||
// mock 数据
|
||||
CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到
|
||||
o.setName(null);
|
||||
o.setMobile(null);
|
||||
o.setTelephone(null);
|
||||
o.setWebsite(null);
|
||||
});
|
||||
customerMapper.insert(dbCustomer);
|
||||
// 测试 name 不匹配
|
||||
customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null)));
|
||||
// 测试 mobile 不匹配
|
||||
customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null)));
|
||||
// 测试 telephone 不匹配
|
||||
customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null)));
|
||||
// 测试 website 不匹配
|
||||
customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null)));
|
||||
// 准备参数
|
||||
CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO();
|
||||
reqVO.setName("张三");
|
||||
reqVO.setMobile("13888888888");
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
//reqVO.setTelephone(null);
|
||||
//reqVO.setWebsite(null);
|
||||
|
||||
// 调用
|
||||
PageResult<CrmCustomerDO> pageResult = customerService.getCustomerPage(reqVO, 1L);
|
||||
// 断言
|
||||
assertEquals(1, pageResult.getList().size());
|
||||
assertPojoEquals(dbCustomer, pageResult.getList().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,18 +2,16 @@ package cn.iocoder.yudao.module.crm.service.customerlimitconfig;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId;
|
||||
@ -40,7 +38,7 @@ public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testCreateCustomerLimitConfig_success() {
|
||||
// 准备参数
|
||||
CrmCustomerLimitConfigCreateReqVO reqVO = randomPojo(CrmCustomerLimitConfigCreateReqVO.class);
|
||||
CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class);
|
||||
|
||||
// 调用
|
||||
Long customerLimitConfigId = customerLimitConfigService.createCustomerLimitConfig(reqVO);
|
||||
@ -57,7 +55,7 @@ public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest {
|
||||
CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class);
|
||||
customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据
|
||||
// 准备参数
|
||||
CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class, o -> {
|
||||
CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class, o -> {
|
||||
o.setId(dbCustomerLimitConfig.getId()); // 设置更新的 ID
|
||||
});
|
||||
|
||||
@ -71,7 +69,7 @@ public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest {
|
||||
@Test
|
||||
public void testUpdateCustomerLimitConfig_notExists() {
|
||||
// 准备参数
|
||||
CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class);
|
||||
CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class);
|
||||
|
||||
// 调用, 并断言异常
|
||||
assertServiceException(() -> customerLimitConfigService.updateCustomerLimitConfig(reqVO), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS);
|
||||
|
@ -252,15 +252,11 @@ import ${subSimpleClassName}List from './components/${subSimpleClassName}List.vu
|
||||
/** ${table.classComment} 列表 */
|
||||
defineOptions({ name: '${table.className}' })
|
||||
|
||||
// 消息弹窗
|
||||
const message = useMessage()
|
||||
// 国际化
|
||||
const { t } = useI18n()
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
// 列表的加载中
|
||||
const loading = ref(true)
|
||||
// 列表的数据
|
||||
const list = ref<${simpleClassName}VO[]>([])
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<${simpleClassName}VO[]>([]) // 列表的数据
|
||||
## 特殊:树表专属逻辑(树不需要分页接口)
|
||||
#if ( $table.templateType != 2 )
|
||||
// 列表的总页数
|
||||
@ -283,10 +279,8 @@ const queryParams = reactive({
|
||||
#end
|
||||
#end
|
||||
})
|
||||
// 搜索的表单
|
||||
const queryFormRef = ref()
|
||||
// 导出的加载中
|
||||
const exportLoading = ref(false)
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
|
@ -67,8 +67,8 @@ public class ProductCategoryController {
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得商品分类列表")
|
||||
@PreAuthorize("@ss.hasPermission('product:category:query')")
|
||||
public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO treeListReqVO) {
|
||||
List<ProductCategoryDO> list = categoryService.getEnableCategoryList(treeListReqVO);
|
||||
public CommonResult<List<ProductCategoryRespVO>> getCategoryList(@Valid ProductCategoryListReqVO listReqVO) {
|
||||
List<ProductCategoryDO> list = categoryService.getCategoryList(listReqVO);
|
||||
list.sort(Comparator.comparing(ProductCategoryDO::getSort));
|
||||
return success(ProductCategoryConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.product.controller.admin.category.vo;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Schema(description = "管理后台 - 商品分类列表查询 Request VO")
|
||||
@Data
|
||||
public class ProductCategoryListReqVO {
|
||||
@ -16,4 +18,7 @@ public class ProductCategoryListReqVO {
|
||||
@Schema(description = "父分类编号", example = "1")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "父分类编号数组", example = "1,2,3")
|
||||
private Collection<Long> parentIds;
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
// TODO 芋艿:后面再看
|
||||
@Tag(name = "用户 APP - 商品浏览记录")
|
||||
@RestController
|
||||
@RequestMapping("/product/browse-history")
|
||||
@ -65,10 +66,9 @@ public class AppProductBrowseHistoryController {
|
||||
@Operation(summary = "获得商品浏览记录分页")
|
||||
@PreAuthenticated
|
||||
public CommonResult<PageResult<AppProductBrowseHistoryRespVO>> getBrowseHistoryPage(AppProductBrowseHistoryPageReqVO reqVO) {
|
||||
ProductBrowseHistoryPageReqVO pageReqVO = BeanUtils.toBean(reqVO, ProductBrowseHistoryPageReqVO.class);
|
||||
pageReqVO.setUserId(getLoginUserId());
|
||||
// 排除用户已删除的(隐藏的)
|
||||
pageReqVO.setUserDeleted(false);
|
||||
ProductBrowseHistoryPageReqVO pageReqVO = BeanUtils.toBean(reqVO, ProductBrowseHistoryPageReqVO.class)
|
||||
.setUserId(getLoginUserId())
|
||||
.setUserDeleted(false); // 排除用户已删除的(隐藏的)
|
||||
PageResult<ProductBrowseHistoryDO> pageResult = productBrowseHistoryService.getBrowseHistoryPage(pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty());
|
||||
@ -77,15 +77,9 @@ public class AppProductBrowseHistoryController {
|
||||
// 得到商品 spu 信息
|
||||
Set<Long> spuIds = convertSet(pageResult.getList(), ProductBrowseHistoryDO::getSpuId);
|
||||
Map<Long, ProductSpuDO> spuMap = convertMap(productSpuService.getSpuList(spuIds), ProductSpuDO::getId);
|
||||
|
||||
// 转换 VO 结果
|
||||
PageResult<AppProductBrowseHistoryRespVO> result = BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class,
|
||||
vo -> Optional.ofNullable(spuMap.get(vo.getSpuId())).ifPresent(spu -> {
|
||||
vo.setSpuName(spu.getName())
|
||||
.setPicUrl(spu.getPicUrl())
|
||||
.setPrice(spu.getPrice());
|
||||
}));
|
||||
return success(result);
|
||||
return success(BeanUtils.toBean(pageResult, AppProductBrowseHistoryRespVO.class,
|
||||
vo -> Optional.ofNullable(spuMap.get(vo.getSpuId()))
|
||||
.ifPresent(spu -> vo.setSpuName(spu.getName()).setPicUrl(spu.getPicUrl()).setPrice(spu.getPrice()))));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class AppProductBrowseHistoryPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
@ -4,11 +4,12 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.AssertTrue;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 商品 SPU 分页 Request VO")
|
||||
@Data
|
||||
@ -26,9 +27,15 @@ public class AppProductSpuPageReqVO extends PageParam {
|
||||
public static final String RECOMMEND_TYPE_NEW = "new";
|
||||
public static final String RECOMMEND_TYPE_GOOD = "good";
|
||||
|
||||
@Schema(description = "商品 SPU 编号数组", example = "1,3,5")
|
||||
private List<Long> ids;
|
||||
|
||||
@Schema(description = "分类编号", example = "1")
|
||||
private Long categoryId;
|
||||
|
||||
@Schema(description = "分类编号数组", example = "1,2,3")
|
||||
private List<Long> categoryIds;
|
||||
|
||||
@Schema(description = "关键字", example = "好看")
|
||||
private String keyword;
|
||||
|
||||
|
@ -21,6 +21,7 @@ public interface ProductCategoryMapper extends BaseMapperX<ProductCategoryDO> {
|
||||
return selectList(new LambdaQueryWrapperX<ProductCategoryDO>()
|
||||
.likeIfPresent(ProductCategoryDO::getName, listReqVO.getName())
|
||||
.eqIfPresent(ProductCategoryDO::getParentId, listReqVO.getParentId())
|
||||
.inIfPresent(ProductCategoryDO::getId, listReqVO.getParentIds())
|
||||
.eqIfPresent(ProductCategoryDO::getStatus, listReqVO.getStatus())
|
||||
.orderByDesc(ProductCategoryDO::getId));
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public interface ProductCategoryService {
|
||||
* @param listReqVO 查询条件
|
||||
* @return 商品分类列表
|
||||
*/
|
||||
List<ProductCategoryDO> getEnableCategoryList(ProductCategoryListReqVO listReqVO);
|
||||
List<ProductCategoryDO> getCategoryList(ProductCategoryListReqVO listReqVO);
|
||||
|
||||
/**
|
||||
* 获得开启状态的商品分类列表
|
||||
|
@ -161,7 +161,7 @@ public class ProductCategoryServiceImpl implements ProductCategoryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductCategoryDO> getEnableCategoryList(ProductCategoryListReqVO listReqVO) {
|
||||
public List<ProductCategoryDO> getCategoryList(ProductCategoryListReqVO listReqVO) {
|
||||
return productCategoryMapper.selectList(listReqVO);
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.product.service.history;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.product.controller.admin.history.vo.ProductBrowseHistoryPageReqVO;
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.history.ProductBrowseHistoryDO;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@ -20,6 +21,7 @@ public interface ProductBrowseHistoryService {
|
||||
* @param spuId SPU 编号
|
||||
* @return 编号
|
||||
*/
|
||||
@Async
|
||||
Long createBrowseHistory(Long userId, Long spuId);
|
||||
|
||||
/**
|
||||
@ -30,14 +32,6 @@ public interface ProductBrowseHistoryService {
|
||||
*/
|
||||
void hideUserBrowseHistory(Long userId, Collection<Long> spuId);
|
||||
|
||||
/**
|
||||
* 获得商品浏览记录
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 商品浏览记录
|
||||
*/
|
||||
ProductBrowseHistoryDO getBrowseHistory(Long id);
|
||||
|
||||
/**
|
||||
* 获取用户记录数量
|
||||
*
|
||||
|
@ -50,7 +50,6 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ
|
||||
.setUserId(userId)
|
||||
.setSpuId(spuId);
|
||||
browseHistoryMapper.insert(browseHistory);
|
||||
// 返回
|
||||
return browseHistory.getId();
|
||||
}
|
||||
|
||||
@ -59,11 +58,6 @@ public class ProductBrowseHistoryServiceImpl implements ProductBrowseHistoryServ
|
||||
browseHistoryMapper.updateUserDeletedByUserId(userId, spuIds, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductBrowseHistoryDO getBrowseHistory(Long id) {
|
||||
return browseHistoryMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getBrowseHistoryCount(Long userId, Boolean userDeleted) {
|
||||
return browseHistoryMapper.selectCountByUserIdAndUserDeleted(userId, userDeleted);
|
||||
|
@ -6,6 +6,8 @@ import cn.iocoder.yudao.module.product.controller.app.spu.vo.AppProductSpuPageRe
|
||||
import cn.iocoder.yudao.module.product.dal.dataobject.spu.ProductSpuDO;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -154,6 +156,7 @@ public interface ProductSpuService {
|
||||
* @param id 商品 SPU 编号
|
||||
* @param incrCount 增加的数量
|
||||
*/
|
||||
@Async
|
||||
void updateBrowseCount(Long id, int incrCount);
|
||||
|
||||
}
|
||||
|
@ -18,17 +18,16 @@ import cn.iocoder.yudao.module.product.service.brand.ProductBrandService;
|
||||
import cn.iocoder.yudao.module.product.service.category.ProductCategoryService;
|
||||
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
|
||||
import com.google.common.collect.Maps;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getMinValue;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.getSumValue;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
||||
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.*;
|
||||
|
||||
@ -220,9 +219,15 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
||||
Set<Long> categoryIds = new HashSet<>();
|
||||
if (pageReqVO.getCategoryId() != null && pageReqVO.getCategoryId() > 0) {
|
||||
categoryIds.add(pageReqVO.getCategoryId());
|
||||
List<ProductCategoryDO> categoryChildren = categoryService.getEnableCategoryList(new ProductCategoryListReqVO()
|
||||
.setParentId(pageReqVO.getCategoryId()).setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
categoryIds.addAll(CollectionUtils.convertList(categoryChildren, ProductCategoryDO::getId));
|
||||
List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentId(pageReqVO.getCategoryId()));
|
||||
categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(pageReqVO.getCategoryIds())) {
|
||||
categoryIds.addAll(pageReqVO.getCategoryIds());
|
||||
List<ProductCategoryDO> categoryChildren = categoryService.getCategoryList(new ProductCategoryListReqVO()
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus()).setParentIds(pageReqVO.getCategoryIds()));
|
||||
categoryIds.addAll(convertList(categoryChildren, ProductCategoryDO::getId));
|
||||
}
|
||||
// 分页查询
|
||||
return productSpuMapper.selectPage(pageReqVO, categoryIds);
|
||||
|
@ -6,6 +6,7 @@ import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// TODO 芋艿:弱化这个状态
|
||||
/**
|
||||
* 促销活动的状态枚举
|
||||
*
|
||||
|
@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.promotion.controller.admin.reward.vo;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionConditionTypeEnum;
|
||||
import cn.iocoder.yudao.module.promotion.enums.common.PromotionProductScopeEnum;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
@ -50,7 +51,7 @@ public class RewardActivityBaseVO {
|
||||
|
||||
@Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
@NotNull(message = "商品范围不能为空")
|
||||
@InEnum(value = PromotionConditionTypeEnum.class, message = "商品范围必须是 {value}")
|
||||
@InEnum(value = PromotionProductScopeEnum.class, message = "商品范围必须是 {value}")
|
||||
private Integer productScope;
|
||||
|
||||
@Schema(description = "商品 SPU 编号的数组", example = "1,2,3")
|
||||
|
@ -145,6 +145,7 @@ public class AppActivityController {
|
||||
}
|
||||
|
||||
private void getRewardActivities(Collection<Long> spuIds, LocalDateTime now, List<AppActivityRespVO> activityList) {
|
||||
// TODO @puhui999:有 3 范围,不只 spuId,还有 categoryId,全部
|
||||
List<RewardActivityDO> rewardActivityList = rewardActivityService.getRewardActivityBySpuIdsAndStatusAndDateTimeLt(
|
||||
spuIds, PromotionActivityStatusEnum.RUN.getStatus(), now);
|
||||
if (CollUtil.isEmpty(rewardActivityList)) {
|
||||
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.reward;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.promotion.controller.app.reward.vo.AppRewardActivityRespVO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.reward.RewardActivityDO;
|
||||
import cn.iocoder.yudao.module.promotion.service.reward.RewardActivityService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
|
||||
@Tag(name = "用户 App - 满减送活动")
|
||||
@RestController
|
||||
@RequestMapping("/promotion/reward-activity")
|
||||
@Validated
|
||||
public class AppRewardActivityController {
|
||||
|
||||
@Resource
|
||||
private RewardActivityService rewardActivityService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得满减送活动")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
public CommonResult<AppRewardActivityRespVO> getRewardActivity(@RequestParam("id") Long id) {
|
||||
RewardActivityDO rewardActivity = rewardActivityService.getRewardActivity(id);
|
||||
return success(BeanUtils.toBean(rewardActivity, AppRewardActivityRespVO.class));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package cn.iocoder.yudao.module.promotion.controller.app.reward.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.promotion.controller.admin.reward.vo.RewardActivityBaseVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "用户 App - 满减送活动 Response VO")
|
||||
@Data
|
||||
public class AppRewardActivityRespVO {
|
||||
|
||||
@Schema(description = "活动编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "活动状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "活动标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "满啦满啦")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "条件类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer conditionType;
|
||||
|
||||
@Schema(description = "商品范围", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||
private Integer productScope;
|
||||
|
||||
@Schema(description = "商品 SPU 编号的数组", example = "1,2,3")
|
||||
private List<Long> productSpuIds;
|
||||
|
||||
@Schema(description = "优惠规则的数组")
|
||||
private List<RewardActivityBaseVO.Rule> rules;
|
||||
|
||||
}
|
@ -79,13 +79,9 @@ public class ProductStatisticsController {
|
||||
// 处理商品信息
|
||||
Set<Long> spuIds = convertSet(pageResult.getList(), ProductStatisticsDO::getSpuId);
|
||||
Map<Long, ProductSpuRespDTO> spuMap = convertMap(productSpuApi.getSpuList(spuIds), ProductSpuRespDTO::getId);
|
||||
// 拼接返回
|
||||
return success(BeanUtils.toBean(pageResult, ProductStatisticsRespVO.class,
|
||||
// 拼接商品信息
|
||||
item -> Optional.ofNullable(spuMap.get(item.getSpuId())).ifPresent(spu -> {
|
||||
item.setName(spu.getName());
|
||||
item.setPicUrl(spu.getPicUrl());
|
||||
})));
|
||||
item -> Optional.ofNullable(spuMap.get(item.getSpuId()))
|
||||
.ifPresent(spu -> item.setName(spu.getName()).setPicUrl(spu.getPicUrl()))));
|
||||
}
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ public class ProductStatisticsRespVO {
|
||||
@ExcelProperty("商品SPU编号")
|
||||
private Long spuId;
|
||||
|
||||
//region 商品信息
|
||||
// region 商品信息
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "商品名称")
|
||||
@ExcelProperty("商品名称")
|
||||
@ -37,7 +37,7 @@ public class ProductStatisticsRespVO {
|
||||
@ExcelProperty("商品封面图")
|
||||
private String picUrl;
|
||||
|
||||
//endregion
|
||||
// endregion
|
||||
|
||||
@Schema(description = "浏览量", requiredMode = Schema.RequiredMode.REQUIRED, example = "17505")
|
||||
@ExcelProperty("浏览量")
|
||||
|
@ -49,7 +49,6 @@ public class TradeStatisticsController {
|
||||
@Resource
|
||||
private BrokerageStatisticsService brokerageStatisticsService;
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
@GetMapping("/summary")
|
||||
@Operation(summary = "获得交易统计")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||
@ -75,7 +74,6 @@ public class TradeStatisticsController {
|
||||
ArrayUtil.get(reqVO.getTimes(), 1)));
|
||||
}
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
@GetMapping("/list")
|
||||
@Operation(summary = "获得交易状况明细")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||
@ -85,7 +83,6 @@ public class TradeStatisticsController {
|
||||
return success(TradeStatisticsConvert.INSTANCE.convertList(list));
|
||||
}
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出获得交易状况明细 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:export')")
|
||||
@ -98,7 +95,6 @@ public class TradeStatisticsController {
|
||||
ExcelUtils.write(response, "交易状况.xls", "数据", TradeTrendSummaryExcelVO.class, data);
|
||||
}
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
@GetMapping("/order-count")
|
||||
@Operation(summary = "获得交易订单数量")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||
@ -116,7 +112,6 @@ public class TradeStatisticsController {
|
||||
return success(TradeStatisticsConvert.INSTANCE.convert(undeliveredCount, pickUpCount, afterSaleApplyCount, auditingWithdrawCount));
|
||||
}
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
@GetMapping("/order-comparison")
|
||||
@Operation(summary = "获得交易订单数量")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||
@ -124,7 +119,6 @@ public class TradeStatisticsController {
|
||||
return success(tradeOrderStatisticsService.getOrderComparison());
|
||||
}
|
||||
|
||||
// TODO 芋艿:已经 review
|
||||
@GetMapping("/order-count-trend")
|
||||
@Operation(summary = "获得订单量趋势统计")
|
||||
@PreAuthorize("@ss.hasPermission('statistics:trade:query')")
|
||||
|
@ -33,7 +33,7 @@ public class ProductStatisticsDO extends BaseDO {
|
||||
*/
|
||||
private LocalDate time;
|
||||
/**
|
||||
* 商品SPU编号
|
||||
* 商品 SPU 编号
|
||||
*/
|
||||
private Long spuId;
|
||||
/**
|
||||
|
@ -45,4 +45,5 @@ public class ProductStatisticsJob implements JobHandler {
|
||||
String result = productStatisticsService.statisticsProduct(days);
|
||||
return StrUtil.format("商品统计:\n{}", result);
|
||||
}
|
||||
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user