Merge remote-tracking branch 'upstream/develop' into crm-msg

This commit is contained in:
dhb52 2024-01-20 22:03:32 +08:00
commit 231fd68435
103 changed files with 2870 additions and 1014 deletions

View File

@ -1,14 +0,0 @@
-- `ruoyi-vue-pro`.crm_contact_business_link definition
CREATE TABLE `crm_contact_business` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
`contact_id` int(11) DEFAULT NULL COMMENT '联系人id',
`business_id` int(11) DEFAULT NULL COMMENT '商机id',
`creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='联系人商机关联表';

View File

@ -1,256 +0,0 @@
-- ----------------------------
-- 转账单表
-- ----------------------------
DROP TABLE IF EXISTS `pay_transfer`;
CREATE TABLE `pay_transfer`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`no` varchar(64) NOT NULL COMMENT '转账单号',
`app_id` bigint NOT NULL COMMENT '应用编号',
`channel_id` bigint NOT NULL COMMENT '转账渠道编号',
`channel_code` varchar(32) NOT NULL COMMENT '转账渠道编码',
`merchant_transfer_id` varchar(64) NOT NULL COMMENT '商户转账单编号',
`type` int NOT NULL COMMENT '类型',
`status` tinyint NOT NULL COMMENT '转账状态',
`success_time` datetime NULL COMMENT '转账成功时间',
`price` int NOT NULL COMMENT '转账金额,单位:分',
`subject` varchar(512) NOT NULL COMMENT '转账标题',
`user_name` varchar(64) NULL COMMENT '收款人姓名',
`alipay_logon_id` varchar(64) NULL COMMENT '支付宝登录号',
`openid` varchar(64) NULL COMMENT '微信 openId',
`notify_url` varchar(1024) NOT NULL COMMENT '异步通知商户地址',
`user_ip` varchar(50) NOT NULL COMMENT '用户 IP',
`channel_extras` varchar(512) NULL DEFAULT NULL COMMENT '渠道的额外参数',
`channel_transfer_no` varchar(64) NULL DEFAULT NULL COMMENT '渠道转账单号',
`channel_error_code` varchar(128) NULL DEFAULT NULL COMMENT '调用渠道的错误码',
`channel_error_msg` varchar(256) NULL DEFAULT NULL COMMENT '调用渠道的错误提示',
`channel_notify_data` varchar(4096) NULL DEFAULT NULL COMMENT '渠道的同步/异步通知的内容',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='转账单表';
-- ----------------------------
-- Table structure for pay_demo_transfer
-- ----------------------------
DROP TABLE IF EXISTS `pay_demo_transfer`;
CREATE TABLE `pay_demo_transfer` (
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单编号',
`app_id` bigint NOT NULL COMMENT '应用编号',
`type` int NOT NULL COMMENT '转账类型',
`price` int NOT NULL COMMENT '转账金额,单位:分',
`user_name` varchar(64) NULL COMMENT '收款人姓名',
`alipay_logon_id` varchar(64) NULL COMMENT '支付宝登录号',
`openid` varchar(64) NULL COMMENT '微信 openId',
`transfer_status` tinyint NOT NULL DEFAULT 0 COMMENT '转账状态',
`pay_transfer_id` bigint NULL DEFAULT NULL COMMENT '转账订单编号',
`pay_channel_code` varchar(16) NULL DEFAULT NULL COMMENT '转账支付成功渠道',
`transfer_time` datetime NULL DEFAULT NULL COMMENT '转账支付时间',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB COMMENT = '示例业务转账订单';
-- ALTER TABLE `pay_channel`
-- MODIFY COLUMN `config` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '支付渠道配置' AFTER `app_id`;
-- ----------------------------
-- 充值套餐表
-- ----------------------------
DROP TABLE IF EXISTS `pay_wallet_recharge_package`;
CREATE TABLE `pay_wallet_recharge_package`
(
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
`name` varchar(64) NOT NULL COMMENT '套餐名',
`pay_price` int NOT NULL COMMENT '支付金额',
`bonus_price` int NOT NULL COMMENT '赠送金额',
`status` tinyint NOT NULL COMMENT '状态',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB COMMENT='充值套餐表';
-- ----------------------------
-- Table structure for pay_wallet_recharge
-- ----------------------------
DROP TABLE IF EXISTS `pay_wallet_recharge`;
CREATE TABLE `pay_wallet_recharge` (
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '编号',
`wallet_id` bigint(0) NOT NULL COMMENT '会员钱包 id',
`total_price` int(0) NOT NULL COMMENT '用户实际到账余额,例如充 100 送 20则该值是 120',
`pay_price` int(0) NOT NULL COMMENT '实际支付金额',
`bonus_price` int(0) NOT NULL COMMENT '钱包赠送金额',
`package_id` bigint(0) DEFAULT NULL COMMENT '充值套餐编号',
`pay_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已支付:[0:未支付 1:已经支付过]',
`pay_order_id` bigint(0) DEFAULT NULL COMMENT '支付订单编号',
`pay_channel_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付成功的支付渠道',
`pay_time` datetime(0) DEFAULT NULL COMMENT '订单支付时间',
`pay_refund_id` bigint(0) DEFAULT NULL COMMENT '支付退款单编号',
`refund_total_price` int(0) NOT NULL DEFAULT 0 COMMENT '退款金额,包含赠送金额',
`refund_pay_price` int(0) NOT NULL DEFAULT 0 COMMENT '退款支付金额',
`refund_bonus_price` int(0) NOT NULL DEFAULT 0 COMMENT '退款钱包赠送金额',
`refund_time` datetime(0) DEFAULT NULL COMMENT '退款时间',
`refund_status` int(0) NOT NULL DEFAULT 0 COMMENT '退款状态',
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
`update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员钱包充值' ROW_FORMAT = Dynamic;
-- 钱包充值套餐,钱包余额菜单脚本
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'钱包管理', '', 1, 5, 1117,
'wallet', 'ep:caret-right', '', 0, ''
);
SELECT @parentId1 := LAST_INSERT_ID();
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'充值套餐', '', 2, 2, @parentId1,
'wallet-recharge-package', 'fa:leaf', 'pay/wallet/rechargePackage/index', 0, 'WalletRechargePackage'
);
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐查询', 'pay:wallet-recharge-package:query', 3, 1, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐创建', 'pay:wallet-recharge-package:create', 3, 2, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐更新', 'pay:wallet-recharge-package:update', 3, 3, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐删除', 'pay:wallet-recharge-package:delete', 3, 4, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'钱包余额', '', 2, 1, @parentId1,
'wallet-balance', 'fa:leaf', 'pay/wallet/balance/index', 0, 'WalletBalance'
);
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包余额查询', 'pay:wallet:query', 3, 1, @parentId,
'', '', '', 0
);
-- 支付实战和转账实战数据库脚本
update system_menu set deleted = 1 where id = 2161;
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'接入示例', '', 1, 99, 1117,
'demo', 'ep:caret-right', '', 0, ''
);
SELECT @parentId1 := LAST_INSERT_ID();
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'支付实战', '', 2, 1, @parentId1,
'demo-order', 'fa:leaf', 'pay/demo/order/index', 0, NULL
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'转账实战', '', 2, 1, @parentId1,
'demo-transfer', 'fa:leaf', 'pay/demo/transfer/index', 0, NULL
);
-- 转账状态和转账类型数据字典
INSERT INTO `system_dict_type`(`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('支付转账类型', 'pay_transfer_type', 0, '', '1', '2023-10-28 16:27:18', '1', '2023-10-28 16:27:18', b'0', '1970-01-01 00:00:00');
INSERT INTO `system_dict_type`(`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('转账订单状态', 'pay_transfer_status', 0, '', '1', '2023-10-28 16:18:32', '1', '2023-10-28 16:18:32', b'0', '1970-01-01 00:00:00');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (4, '钱包余额', '4', 'pay_transfer_type', 0, 'info', '', '', '1', '2023-10-28 16:28:37', '1', '2023-10-28 16:28:37', b'0');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3, '银行卡', '3', 'pay_transfer_type', 0, 'default', '', '', '1', '2023-10-28 16:28:21', '1', '2023-10-28 16:28:21', b'0');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2, '微信余额', '2', 'pay_transfer_type', 0, 'info', '', '', '1', '2023-10-28 16:28:07', '1', '2023-10-28 16:28:07', b'0');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '支付宝余额', '1', 'pay_transfer_type', 0, 'default', '', '', '1', '2023-10-28 16:27:44', '1', '2023-10-28 16:27:44', b'0');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (4, '转账失败', '30', 'pay_transfer_status', 0, 'warning', '', '', '1', '2023-10-28 16:24:16', '1', '2023-10-28 16:24:16', b'0');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3, '转账成功', '20', 'pay_transfer_status', 0, 'success', '', '', '1', '2023-10-28 16:23:50', '1', '2023-10-28 16:23:50', b'0');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2, '转账进行中', '10', 'pay_transfer_status', 0, 'info', '', '', '1', '2023-10-28 16:23:12', '1', '2023-10-28 16:23:12', b'0');
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '等待转账', '0', 'pay_transfer_status', 0, 'default', '', '', '1', '2023-10-28 16:21:43', '1', '2023-10-28 16:23:22', b'0');
-- 转账订单菜单脚本
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'转账订单', '', 2, 3, 1117,
'transfer', 'ep:credit-card', 'pay/transfer/index', 0, 'PayTransfer'
);
-- 转账通知脚本
ALTER TABLE `pay_app`
ADD COLUMN `transfer_notify_url` varchar(1024) NOT NULL COMMENT '转账结果的回调地址' AFTER `refund_notify_url`;
ALTER TABLE `pay_notify_task`
MODIFY COLUMN `merchant_order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '商户订单编号' AFTER `status`,
ADD COLUMN `merchant_transfer_id` varchar(64) COMMENT '商户转账单编号' AFTER `merchant_order_id`;

View File

@ -1,22 +0,0 @@
CREATE TABLE product_browse_history
(
id bigint AUTO_INCREMENT COMMENT '记录编号'
PRIMARY KEY,
user_id bigint NOT NULL COMMENT '用户编号',
spu_id bigint NOT NULL COMMENT '商品 SPU 编号',
user_deleted bit DEFAULT b'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_spuId
ON product_browse_history (spu_id);
CREATE INDEX idx_userId
ON product_browse_history (user_id);

View File

@ -2370,6 +2370,7 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
INSERT INTO `system_menu` (`id`, `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 (2369, '拼团记录', 'promotion:combination-record:query', 2, 2, 2303, 'record', 'ep:avatar', 'mall/promotion/combination/record/index.vue', 'PromotionCombinationRecord', 0, b'1', b'1', b'1', '1', '2023-10-08 07:10:22', '1', '2023-10-08 07:34:11', b'0');
INSERT INTO `system_menu` (`id`, `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 (2374, '会员统计', '', 2, 2, 2358, 'member', 'ep:avatar', 'statistics/member/index', 'MemberStatistics', 0, b'1', b'1', b'1', '', '2023-10-11 04:39:24', '1', '2023-10-11 12:50:22', b'0');
INSERT INTO `system_menu` (`id`, `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 (2375, '会员统计查询', 'statistics:member:query', 3, 1, 2374, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-11 04:39:24', '', '2023-10-11 04:39:24', b'0');
--trade:order:query trade:order:update权限
INSERT INTO `system_menu` (`id`, `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 (2376, '订单核销', 'trade:order:pick-up', 3, 10, 2076, '', '', '', '', 0, b'1', b'1', b'1', '1', '2023-10-14 17:11:58', '1', '2023-10-14 17:11:58', b'0');
INSERT INTO `system_menu` (`id`, `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 (2377, '文章分类', '', 2, 0, 2387, 'article/category', 'fa:certificate', 'mall/promotion/article/category/index', 'ArticleCategory', 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '1', '2023-10-16 09:38:26', b'0');
INSERT INTO `system_menu` (`id`, `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 (2378, '分类查询', 'promotion:article-category:query', 3, 1, 2377, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
@ -2478,6 +2479,15 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
INSERT INTO `system_menu` (`id`, `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 (2523, '客户限制配置导出', 'crm:customer-limit-config:export', 3, 5, 2518, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-18 13:33:53', '', '2023-11-18 13:33:53', b'0');
INSERT INTO `system_menu` (`id`, `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 (2524, '系统配置', '', 1, 99, 2397, 'config', 'ep:connection', '', '', 0, b'1', b'1', b'1', '1', '2023-11-18 21:58:00', '1', '2023-11-18 21:58:00', b'0');
INSERT INTO `system_menu` (`id`, `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 (2525, 'WebSocket 测试', '', 2, 7, 2, 'websocket', 'ep:connection', 'infra/webSocket/index', 'InfraWebSocket', 0, b'1', b'1', b'1', '1', '2023-11-23 19:41:55', '1', '2023-11-24 19:22:30', b'0');
INSERT INTO `system_menu` (`id`, `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 (2526, '抄送流程', '', 2, 21, 1200, 'processInstanceCC', 'eye', '/bpm/task/cc/index',
'BpmCCProcessInstance', 0, true, true, true, 1, '2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', false),
(2527, '抄送流程查询', 'bpm:process-instance-cc:query', 3, 1, 2526, '', '', '', NULL, 0, b'1', b'1', b'1', '1',
'2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', b'0'),
(2528, '抄送流程创建', 'bpm:process-instance-cc:create', 3, 2, 2526, '', '', '', NULL, 0, b'1', b'1', b'1', '1',
'2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', b'0');
COMMIT;
-- ----------------------------

View File

@ -17,8 +17,8 @@ public class YudaoFlowableConfiguration {
*
* 如果不创建会导致项目启动时Flowable 报错的问题
*/
@Bean
@ConditionalOnMissingBean
@Bean(name = "applicationTaskExecutor")
@ConditionalOnMissingBean(name = "applicationTaskExecutor")
public AsyncListenableTaskExecutor taskExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(8);

View File

@ -151,7 +151,7 @@ public class QueryWrapperX<T> extends QueryWrapper<T> {
switch (SqlConstants.DB_TYPE) {
case ORACLE:
case ORACLE_12C:
super.eq("ROWNUM", n);
super.le("ROWNUM", n);
break;
case SQL_SERVER:
case SQL_SERVER2005:

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleBaseVO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.util.Set;
/**
* 流程任务分配规则 Base VO提供给添加修改详细的子 VO 使用
* 如果子 VO 存在差异的字段请不要添加到这里影响 Swagger 文档生成
*
* @see BpmTaskAssignRuleBaseVO
*/
@Data
public class BpmTaskCandidateRuleVO {
@Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "bpm_task_assign_rule_type")
@NotNull(message = "规则类型不能为空")
private Integer type;
@Schema(description = "规则值数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3")
@NotNull(message = "规则值数组不能为空")
private Set<Long> options;
}

View File

@ -3,17 +3,17 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.*;
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService;
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@ -26,6 +26,9 @@ public class BpmProcessInstanceController {
@Resource
private BpmProcessInstanceService processInstanceService;
@Resource
private BpmProcessInstanceCopyService processInstanceCopyService;
@GetMapping("/my-page")
@Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用")
@PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
@ -56,4 +59,22 @@ public class BpmProcessInstanceController {
processInstanceService.cancelProcessInstance(getLoginUserId(), cancelReqVO);
return success(true);
}
// TODO @kyle抄送要不单独 controller
@PostMapping("/cc/create")
@Operation(summary = "抄送流程")
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')")
public CommonResult<Boolean> createProcessInstanceCC(@Valid @RequestBody BpmProcessInstanceCCReqVO createReqVO) {
return success(processInstanceCopyService.ccProcessInstance(getLoginUserId(), createReqVO));
}
@GetMapping("/cc/my-page")
@Operation(summary = "获得抄送流程分页列表")
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')")
public CommonResult<PageResult<BpmProcessInstanceCCPageItemRespVO>> getProcessInstanceCCPage(
@Valid BpmProcessInstanceCCMyPageReqVO pageReqVO) {
return success(processInstanceCopyService.getMyProcessInstanceCCPage(getLoginUserId(), pageReqVO));
}
}

View File

@ -0,0 +1,31 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
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;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
// TODO @kyle建议改成 BpmProcessInstanceCopyMyPageReqVOcc 缩写不容易理解所以改成 copy虽然会长一点但是可读性更重要
@Schema(description = "管理后台 - 流程实例抄送的分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BpmProcessInstanceCCMyPageReqVO extends PageParam {
@Schema(description = "流程名称", example = "芋道")
private String processInstanceName;
@Schema(description = "流程编号", example = "123456768")
private String processInstanceId;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,57 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO")
@Data
public class BpmProcessInstanceCCPageItemRespVO {
// TODO @kyle如果已经写了 swagger 注解可以不用写 java 注释哈
/**
* 编号
*/
@Schema(description = "抄送主键")
private Long id;
/**
* 发起人Id
*/
@Schema(description = "发起人Id")
private Long startUserId;
@Schema(description = "发起人别名")
private String startUserNickname;
/**
* 流程主键
*/
@Schema(description = "流程实例的主键")
private String processInstanceId;
@Schema(description = "流程实例的名称")
private String processInstanceName;
/**
* 任务主键
*/
@Schema(description = "发起抄送的任务编号")
private String taskId;
@Schema(description = "发起抄送的任务名称")
private String taskName;
@Schema(description = "抄送原因")
private String reason;
@Schema(description = "抄送人")
private String creator;
@Schema(description = "抄送人别名")
private String creatorNickname;
@Schema(description = "抄送时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,47 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
// TODO @kyle这个 VO 可以改成 BpmProcessInstanceCopyCreateReqVO
@Schema(description = "管理后台 - 流程实例的抄送 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class BpmProcessInstanceCCReqVO extends BpmTaskCandidateRuleVO {
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "任务编号不能为空")
private String taskKey;
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "任务名称不能为空")
private String taskName;
@Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "流程实例的编号不能为空")
private String processInstanceKey;
@Schema(description = "发起流程的用户的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotNull(message = "发起流程的用户的编号不能为空")
private Long startUserId;
@Schema(description = "任务实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
@NotEmpty(message = "任务实例名称不能为空")
private String processInstanceName;
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
@NotBlank(message = "抄送原因不能为空")
private String reason;
// TODO @kyle看了下字段有点多尽量不传递可推导的字段
// 需要传递taskId任务编号reasonuserIds被抄送的人
// 不需要传递taskKeytaskNameprocessInstanceKeystartUserIdprocessInstanceName 因为这些可以后端查询到
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -0,0 +1,61 @@
package cn.iocoder.yudao.module.bpm.convert.cc;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
// TODO kyle类注释不太对
/**
* 动态表单 Convert
*
* @author 芋艿
*/
@Mapper
public interface BpmProcessInstanceCopyConvert {
BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class);
// TODO @kyle可以使用 BeanUtils copy 替代这些简单的哈
BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean);
BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean);
List<BpmProcessInstanceCCPageItemRespVO> convertList(List<BpmProcessInstanceCopyDO> list);
// TODO @kyle/* taskId */ 这种注释一般不用写可以一眼看明白的避免变量看着略微不清晰哈
default PageResult<BpmProcessInstanceCCPageItemRespVO> convertPage(PageResult<BpmProcessInstanceCopyDO> page
, Map<String/* taskId */, String/* taskName */> taskMap
, Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap
, Map<Long/* userId */, String/* userName */> userMap
) {
List<BpmProcessInstanceCCPageItemRespVO> list = convertList(page.getList());
for (BpmProcessInstanceCCPageItemRespVO vo : list) {
MapUtils.findAndThen(userMap, Long.valueOf(vo.getCreator()),
vo::setCreatorNickname);
MapUtils.findAndThen(userMap, vo.getStartUserId(),
vo::setStartUserNickname);
MapUtils.findAndThen(taskMap, vo.getTaskId(),
vo::setTaskName);
MapUtils.findAndThen(processInstaneMap, vo.getProcessInstanceId(),
vo::setProcessInstanceName);
}
// TODO @kyle可以精简成下面的哈
// List<BpmProcessInstanceCCPageItemRespVO> list2 = BeanUtils.toBean(page.getList(),
// BpmProcessInstanceCCPageItemRespVO.class,
// copy -> {
// MapUtils.findAndThen(userMap, Long.valueOf(copy.getCreator()), copy::setCreatorNickname);
// MapUtils.findAndThen(userMap, copy.getStartUserId(), copy::setStartUserNickname);
// MapUtils.findAndThen(taskMap, copy.getTaskId(), copy::setTaskName);
// MapUtils.findAndThen(processInstaneMap, copy.getProcessInstanceId(), copy::setProcessInstanceName);
// });
return new PageResult<>(list, page.getTotal());
}
}

View File

@ -0,0 +1,71 @@
package cn.iocoder.yudao.module.bpm.dal.dataobject.cc;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* 流程抄送 DO
*
* @author kyle
* @date 2022-05-19 TODO @kyle@date 不是标准 java doc可以使用 @since 替代然后日期是不是不对
*/
@TableName(value = "bpm_process_instance_copy", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class BpmProcessInstanceCopyDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
// TODO @kyle字段如果是关联或者冗余要写下注释 processInstanceId 举例子
/**
* 发起人 Id
*/
private Long startUserId;
/**
* 流程名
*/
private String processInstanceName;
/**
* 流程实例的编号
*
* 关联 ProcessInstance id 属性
*/
private String processInstanceId;
/**
* 任务主键
*/
private String taskId;
/**
* 任务名称
*/
private String taskName;
/**
* 用户编号
*/
private Long userId;
/**
* 抄送原因
*/
private String reason;
// TODO @kyle这个字段可以用 category 简化点
/**
* 流程分类
*/
private String processDefinitionCategory;
}

View File

@ -0,0 +1,20 @@
package cn.iocoder.yudao.module.bpm.dal.mysql.cc;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BpmProcessInstanceCopyMapper extends BaseMapperX<BpmProcessInstanceCopyDO> { // TODO @kyle方法和类之间要空行下
default PageResult<BpmProcessInstanceCopyDO> selectPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO reqVO){
return selectPage(reqVO, new LambdaQueryWrapperX<BpmProcessInstanceCopyDO>()
.eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId)
.eqIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceId, reqVO.getProcessInstanceId())
.likeIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceName, reqVO.getProcessInstanceName())
.betweenIfPresent(BpmProcessInstanceCopyDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(BpmProcessInstanceCopyDO::getId));
}
}

View File

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.bpm.framework.bpm.config;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor.*;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
// TODO @芋艿Candidate 相关还在完善中用户可以暂时忽略 yudao 开发的同学需要关注~计划是把 Candidate Assign 融合成一套
/**
* BPM 通用的 Configuration 配置类提供给 Activiti Flowable
* @author kyle
*/
@Configuration(proxyBeanMethods = false)
public class BpmCandidateProcessorConfiguration {
@Bean
public BpmCandidateAdminUserApiSourceInfoProcessor bpmCandidateAdminUserApiSourceInfoProcessor() {
return new BpmCandidateAdminUserApiSourceInfoProcessor();
}
@Bean
public BpmCandidateDeptApiSourceInfoProcessor bpmCandidateDeptApiSourceInfoProcessor() {
return new BpmCandidateDeptApiSourceInfoProcessor();
}
@Bean
public BpmCandidatePostApiSourceInfoProcessor bpmCandidatePostApiSourceInfoProcessor() {
return new BpmCandidatePostApiSourceInfoProcessor();
}
@Bean
public BpmCandidateRoleApiSourceInfoProcessor bpmCandidateRoleApiSourceInfoProcessor() {
return new BpmCandidateRoleApiSourceInfoProcessor();
}
@Bean
public BpmCandidateUserGroupApiSourceInfoProcessor bpmCandidateUserGroupApiSourceInfoProcessor() {
return new BpmCandidateUserGroupApiSourceInfoProcessor();
}
/**
* 可以自己定制脚本然后通过这里设置到处理器里面去
* @param scriptsOp 脚本包装对象
* @return
*/
@Bean
public BpmCandidateScriptApiSourceInfoProcessor bpmCandidateScriptApiSourceInfoProcessor(ObjectProvider<BpmTaskAssignScript> scriptsOp) {
BpmCandidateScriptApiSourceInfoProcessor bpmCandidateScriptApiSourceInfoProcessor = new BpmCandidateScriptApiSourceInfoProcessor();
bpmCandidateScriptApiSourceInfoProcessor.setScripts(scriptsOp);
return bpmCandidateScriptApiSourceInfoProcessor;
}
}

View File

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.bpm.service.candidate;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.HashSet;
import java.util.Set;
/**
* 获取候选人信息
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
public class BpmCandidateSourceInfo {
@Schema(description = "流程id")
@NotNull
private String processInstanceId;
@Schema(description = "当前任务ID")
@NotNull
private String taskId;
/**
* 通过这些规则生成最终需要生成的用户
*/
@Schema(description = "当前任务预选规则")
@NotEmpty(message = "不允许空规则")
private Set<BpmTaskCandidateRuleVO> rules;
@Schema(description = "发起抄送的用户")
private String creator;
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
@NotEmpty(message = "抄送原因不能为空")
private String reason;
public void addRule(BpmTaskCandidateRuleVO vo) {
assert vo != null;
if (rules == null) {
rules = new HashSet<>();
}
rules.add(vo);
}
}

View File

@ -0,0 +1,53 @@
package cn.iocoder.yudao.module.bpm.service.candidate;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import org.flowable.engine.delegate.DelegateExecution;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
public interface BpmCandidateSourceInfoProcessor {
/**
* 获取该处理器支持的类型
* 来自 {@link BpmTaskAssignRuleTypeEnum}
*
* @return
*/
Set<Integer> getSupportedTypes();
/**
* 对规则和人员做校验
*
* @param type 规则
* @param options 人员id
*/
void validRuleOptions(Integer type, Set<Long> options);
/**
* 默认的处理
* 如果想去操作所有的规则则可以覆盖此方法
*
* @param request 原始请求
* @param delegateExecution 审批过程中的对象
* @return 必须包含的是用户ID而不是其他的ID
* @throws Exception
*/
default Set<Long> process(BpmCandidateSourceInfo request, DelegateExecution delegateExecution) throws Exception {
Set<BpmTaskCandidateRuleVO> rules = request.getRules();
Set<Long> results = new HashSet<>();
for (BpmTaskCandidateRuleVO rule : rules) {
// 每个处理器都有机会处理自己支持的事件
if (CollUtil.contains(getSupportedTypes(), rule.getType())) {
results.addAll(doProcess(request, rule, delegateExecution));
}
}
return results;
}
default Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
return Collections.emptySet();
}
}

View File

@ -0,0 +1,107 @@
package cn.iocoder.yudao.module.bpm.service.candidate;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.*;
@Service
public class BpmCandidateSourceInfoProcessorChain {
// 保存处理节点
private List<BpmCandidateSourceInfoProcessor> processorList;
@Resource
private AdminUserApi adminUserApi;
/**
* 可添加其他处理器
*
* @param processorOp
* @return
*/
@Resource
// 动态扩展处理节点
public BpmCandidateSourceInfoProcessorChain addProcessor(ObjectProvider<BpmCandidateSourceInfoProcessor> processorOp) {
List<BpmCandidateSourceInfoProcessor> processor = ListUtil.toList(processorOp.iterator());
if (null == processorList) {
processorList = new ArrayList<>(processor.size());
}
processorList.addAll(processor);
return this;
}
// 获取处理器处理
public Set<Long> process(BpmCandidateSourceInfo sourceInfo, DelegateExecution execution) throws Exception {
// Verify our parameters
if (sourceInfo == null) {
throw new IllegalArgumentException();
}
for (BpmCandidateSourceInfoProcessor processor : processorList) {
try {
for (BpmTaskCandidateRuleVO vo : sourceInfo.getRules()) {
if (CollUtil.contains(processor.getSupportedTypes(), vo.getType())) {
processor.validRuleOptions(vo.getType(), vo.getOptions());
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
Set<Long> saveResult = Collections.emptySet();
Exception saveException = null;
for (BpmCandidateSourceInfoProcessor processor : processorList) {
try {
saveResult = processor.process(sourceInfo, execution);
if (CollUtil.isNotEmpty(saveResult)) {
removeDisableUsers(saveResult);
break;
}
} catch (Exception e) {
saveException = e;
break;
}
}
// Return the exception or result state from the last execute()
if ((saveException != null)) {
throw saveException;
} else {
return (saveResult);
}
}
public Set<Long> calculateTaskCandidateUsers(DelegateExecution execution, BpmCandidateSourceInfo sourceInfo) {
Set<Long> results = Collections.emptySet();
try {
results = process(sourceInfo, execution);
} catch (Exception e) {
e.printStackTrace();
}
return results;
}
/**
* 移除禁用用户
*
* @param assigneeUserIds
*/
public void removeDisableUsers(Set<Long> assigneeUserIds) {
if (CollUtil.isEmpty(assigneeUserIds)) {
return;
}
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(assigneeUserIds);
assigneeUserIds.removeIf(id -> {
AdminUserRespDTO user = userMap.get(id);
return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus());
});
}
}

View File

@ -0,0 +1,32 @@
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import org.flowable.engine.delegate.DelegateExecution;
import jakarta.annotation.Resource;
import java.util.Set;
public class BpmCandidateAdminUserApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
@Resource
private AdminUserApi api;
@Override
public Set<Integer> getSupportedTypes() {
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.USER.getType());
}
@Override
public void validRuleOptions(Integer type, Set<Long> options) {
api.validateUserList(options);
}
@Override
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
return rule.getOptions();
}
}

View File

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.flowable.engine.delegate.DelegateExecution;
import jakarta.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
public class BpmCandidateDeptApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
@Resource
private DeptApi api;
@Resource
private AdminUserApi adminUserApi;
@Override
public Set<Integer> getSupportedTypes() {
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(),
BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType());
}
@Override
public void validRuleOptions(Integer type, Set<Long> options) {
api.validateDeptList(options);
}
@Override
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) {
List<AdminUserRespDTO> users = adminUserApi.getUserListByDeptIds(rule.getOptions());
return convertSet(users, AdminUserRespDTO::getId);
} else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) {
List<DeptRespDTO> depts = api.getDeptList(rule.getOptions());
return convertSet(depts, DeptRespDTO::getLeaderUserId);
}
return Collections.emptySet();
}
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
import cn.iocoder.yudao.module.system.api.dept.PostApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.flowable.engine.delegate.DelegateExecution;
import jakarta.annotation.Resource;
import java.util.List;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
public class BpmCandidatePostApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
@Resource
private PostApi api;
@Resource
private AdminUserApi adminUserApi;
@Override
public Set<Integer> getSupportedTypes() {
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.POST.getType());
}
@Override
public void validRuleOptions(Integer type, Set<Long> options) {
api.validPostList(options);
}
@Override
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
List<AdminUserRespDTO> users = adminUserApi.getUserListByPostIds(rule.getOptions());
return convertSet(users, AdminUserRespDTO::getId);
}
}

View File

@ -0,0 +1,37 @@
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
import org.flowable.engine.delegate.DelegateExecution;
import jakarta.annotation.Resource;
import java.util.Set;
public class BpmCandidateRoleApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
@Resource
private RoleApi api;
@Resource
private PermissionApi permissionApi;
@Override
public Set<Integer> getSupportedTypes() {
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.ROLE.getType());
}
@Override
public void validRuleOptions(Integer type, Set<Long> options) {
api.validRoleList(options);
}
@Override
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions());
}
}

View File

@ -0,0 +1,73 @@
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.beans.factory.ObjectProvider;
import jakarta.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_ASSIGN_SCRIPT_NOT_EXISTS;
public class BpmCandidateScriptApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
@Resource
private DictDataApi dictDataApi;
/**
* 任务分配脚本
*/
private Map<Long, BpmTaskAssignScript> scriptMap = Collections.emptyMap();
public void setScripts(ObjectProvider<BpmTaskAssignScript> scriptsOp) {
List<BpmTaskAssignScript> scripts = scriptsOp.orderedStream().collect(Collectors.toList());
setScripts(scripts);
}
public void setScripts(List<BpmTaskAssignScript> scripts) {
this.scriptMap = convertMap(scripts, script -> script.getEnum().getId());
}
@Override
public Set<Integer> getSupportedTypes() {
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.SCRIPT.getType());
}
@Override
public void validRuleOptions(Integer type, Set<Long> options) {
dictDataApi.validateDictDataList(DictTypeConstants.TASK_ASSIGN_SCRIPT,
CollectionUtils.convertSet(options, String::valueOf));
}
@Override
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
return calculateTaskCandidateUsersByScript(delegateExecution, rule.getOptions());
}
private Set<Long> calculateTaskCandidateUsersByScript(DelegateExecution execution, Set<Long> options) {
// 获得对应的脚本
List<BpmTaskAssignScript> scripts = new ArrayList<>(options.size());
options.forEach(id -> {
BpmTaskAssignScript script = scriptMap.get(id);
if (script == null) {
throw exception(TASK_ASSIGN_SCRIPT_NOT_EXISTS, id);
}
scripts.add(script);
});
// 逐个计算任务
Set<Long> userIds = new HashSet<>();
scripts.forEach(script -> CollUtil.addAll(userIds, script.calculateTaskCandidateUsers(execution)));
return userIds;
}
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import org.flowable.engine.delegate.DelegateExecution;
import jakarta.annotation.Resource;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class BpmCandidateUserGroupApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
@Resource
private BpmUserGroupService api;
@Resource
private BpmUserGroupService userGroupService;
@Override
public Set<Integer> getSupportedTypes() {
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType());
}
@Override
public void validRuleOptions(Integer type, Set<Long> options) {
api.validUserGroups(options);
}
@Override
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
List<BpmUserGroupDO> userGroups = userGroupService.getUserGroupList(rule.getOptions());
Set<Long> userIds = new HashSet<>();
userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds()));
return userIds;
}
}

View File

@ -0,0 +1,53 @@
package cn.iocoder.yudao.module.bpm.service.cc;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
// TODO @kyle这个 Service 要不挪到 task 包下保持统一task 下有流程任务抄送等
// TODO @kyle中文和英文之间有个空格会更清晰点例如说流程抄送 Service 接口中文写作习惯~
/**
* 流程抄送Service接口
*
* 现在是在审批的时候进行流程抄送
*/
public interface BpmProcessInstanceCopyService {
// TODO @kyle无用的方法可以去掉哈另外考虑到避免过多的 VO这里就可以返回 BpmProcessInstanceCopyDO
/**
* 查询流程抄送
*
* @param copyId 流程抄送主键
* @return 流程抄送
*/
BpmProcessInstanceCopyVO queryById(Long copyId);
// TODO 芋艿这块要 review 思考下~~
/**
* 抄送
* @param sourceInfo 抄送源信息方便抄送处理
* @return
*/
boolean makeCopy(BpmCandidateSourceInfo sourceInfo);
// TODO @kyle可以方法名改成 createProcessInstanceCopy现在项目一般新增都用 create 为主
/**
* 流程实例的抄送
*
* @param userId 当前登录用户
* @param createReqVO 创建的抄送请求
* @return 是否抄送成功抄送成功则返回true TODO @kyle这里可以不用返回哈目前一般是失败就抛出业务异常
*/
boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO createReqVO);
/**
* 抄送的流程
* @param loginUserId 登录用户id
* @param pageReqVO 分页请求
* @return 抄送的分页结果
*/
PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId,
BpmProcessInstanceCCMyPageReqVO pageReqVO);
}

View File

@ -0,0 +1,165 @@
package cn.iocoder.yudao.module.bpm.service.cc;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
import cn.iocoder.yudao.module.bpm.convert.cc.BpmProcessInstanceCopyConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.cc.BpmProcessInstanceCopyMapper;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain;
import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO;
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
import cn.iocoder.yudao.module.bpm.util.FlowableUtils;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
// TODO @kyle类注释要写下
@Slf4j // TODO @kyle按照 @Service@Validated@Slf4j从重要到不重要的顺序
@Service
@Validated
public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService {
@Resource // TODO @kyle第一个变量和类之间要有空行
private BpmProcessInstanceCopyMapper processInstanceCopyMapper;
/**
* 和flowable有关的查询流程名用的 TODO @kyle可以不写哈注释
*/
@Resource
private RuntimeService runtimeService;
/**
* 找抄送人用的 TODO @kyle可以不写哈注释
*/
@Resource
private BpmCandidateSourceInfoProcessorChain processorChain;
// TODO @kyle多余的变量可以去掉哈
@Resource
@Lazy // 解决循环依赖
private BpmTaskService bpmTaskService;
@Resource
@Lazy // 解决循环依赖
private BpmProcessInstanceService bpmProcessInstanceService;
@Resource
private AdminUserApi adminUserApi;
@Override
public BpmProcessInstanceCopyVO queryById(Long copyId) {
BpmProcessInstanceCopyDO bpmProcessInstanceCopyDO = processInstanceCopyMapper.selectById(copyId);
return BpmProcessInstanceCopyConvert.INSTANCE.convert(bpmProcessInstanceCopyDO);
}
// TODO @kylemakeCopy ccProcessInstance 的调用关系感受上反了
// makeCopy 有点像基于规则查找抄送人然后创建
// ccProcessInstance 是已经有了抄送人然后创建
// 建议的改造独立基于 processInstanceCopyMapper insert
@Override
public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) {
if (null == sourceInfo) {
return false;
}
DelegateExecution executionEntity = new BpmDelegateExecutionDTO(sourceInfo.getProcessInstanceId());
Set<Long> ccCandidates = processorChain.calculateTaskCandidateUsers(executionEntity, sourceInfo);
if (CollUtil.isEmpty(ccCandidates)) {
log.warn("相关抄送人不存在 {}", sourceInfo.getTaskId());
return false;
} else {
BpmProcessInstanceCopyDO copyDO = new BpmProcessInstanceCopyDO();
// 调用
// 设置任务id
copyDO.setTaskId(sourceInfo.getTaskId());
copyDO.setTaskName(FlowableUtils.getTaskNameByTaskId(sourceInfo.getTaskId()));
copyDO.setProcessInstanceId(sourceInfo.getProcessInstanceId());
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(sourceInfo.getProcessInstanceId())
.singleResult();
if (null == processInstance) {
log.warn("相关流程实例不存在 {}", sourceInfo.getTaskId());
return false;
}
copyDO.setStartUserId(FlowableUtils.getStartUserIdFromProcessInstance(processInstance));
copyDO.setProcessInstanceName(processInstance.getName());
ProcessDefinition processDefinition = FlowableUtils.getProcessDefinition(processInstance.getProcessDefinitionId());
copyDO.setProcessDefinitionCategory(processDefinition.getCategory());
copyDO.setReason(sourceInfo.getReason());
copyDO.setCreator(sourceInfo.getCreator());
copyDO.setCreateTime(LocalDateTime.now());
List<BpmProcessInstanceCopyDO> copyList = new ArrayList<>(ccCandidates.size());
for (Long userId : ccCandidates) {
BpmProcessInstanceCopyDO copy = BpmProcessInstanceCopyConvert.INSTANCE.copy(copyDO);
copy.setUserId(userId);
copyList.add(copy);
}
return processInstanceCopyMapper.insertBatch(copyList);
}
}
@Override
public boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO reqVO) {
// 在能正常审批的情况下抄送流程
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.setTaskId(reqVO.getTaskKey());
sourceInfo.setProcessInstanceId(reqVO.getProcessInstanceKey());
sourceInfo.addRule(reqVO);
sourceInfo.setCreator(String.valueOf(userId));
sourceInfo.setReason(reqVO.getReason());
if (!makeCopy(sourceInfo)) {
throw new RuntimeException("抄送任务失败");
}
return false;
}
//获取流程抄送分页 TODO @kyle接口已经注释这里不用注释了哈
@Override
public PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO) {
// 通过 BpmProcessInstanceExtDO 先查询到对应的分页
// TODO @kyle一般读逻辑Service 返回 PageResult<BpmProcessInstanceCopyDO> 即可关联数据的查询和拼接交给 Controller目的是保证 Service 聚焦写逻辑清晰简洁
PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyMapper.selectPage(loginUserId, pageReqVO);
if (CollUtil.isEmpty(pageResult.getList())) {
return new PageResult<>(pageResult.getTotal());
}
// TODO @kyle这种可以简洁点参考如下
// Map<String, ProcessInstance> processInstanceMap = bpmProcessInstanceService.getProcessInstanceMap(
// convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId));
Set<String/* taskId */> taskIds = new HashSet<>();
Set<String/* processInstaneId */> processInstaneIds = new HashSet<>();
Set<Long/* userId */> userIds = new HashSet<>();
for (BpmProcessInstanceCopyDO doItem : pageResult.getList()) {
taskIds.add(doItem.getTaskId());
processInstaneIds.add(doItem.getProcessInstanceId());
userIds.add(doItem.getStartUserId());
Long userId = Long.valueOf(doItem.getCreator());
userIds.add(userId);
}
Map<String, String> taskNameByTaskIds = FlowableUtils.getTaskNameByTaskIds(taskIds);
Map<String, String> processInstanceNameByTaskIds = FlowableUtils.getProcessInstanceNameByTaskIds(processInstaneIds);
Map<Long, String> userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(
AdminUserRespDTO::getId, AdminUserRespDTO::getNickname));
// 转换返回
return BpmProcessInstanceCopyConvert.INSTANCE.convertPage(pageResult, taskNameByTaskIds, processInstanceNameByTaskIds, userMap);
}
}

View File

@ -0,0 +1,67 @@
package cn.iocoder.yudao.module.bpm.service.cc;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
// TODO @kyle看看是不是要删除
/**
* 流程抄送视图对象 wf_copy
*
* @author ruoyi
* @date 2022-05-19
*/
@Data
public class BpmProcessInstanceCopyVO {
/**
* 编号
*/
@Schema(description = "抄送主键")
private Long id;
/**
* 发起人Id
*/
@Schema(description = "发起人Id")
private Long startUserId;
@Schema(description = "发起人别名")
private String startUserNickname;
/**
* 流程主键
*/
@Schema(description = "流程实例的主键")
private String processInstanceId;
@Schema(description = "流程实例的名字")
private String processInstanceName;
/**
* 任务主键
*/
@Schema(description = "发起抄送的任务编号")
private String taskId;
@Schema(description = "发起抄送的任务名称")
private String taskName;
/**
* 用户主键
*/
@Schema(description = "用户编号")
private Long userId;
@Schema(description = "用户别名")
private Long userNickname;
@Schema(description = "抄送原因")
private String reason;
@Schema(description = "抄送人")
private String creator;
@Schema(description = "抄送时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,439 @@
package cn.iocoder.yudao.module.bpm.service.cc.dto;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.FlowableListener;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ReadOnlyDelegateExecution;
import org.flowable.variable.api.persistence.entity.VariableInstance;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 仅为了传输processInstanceId
*/
public class BpmDelegateExecutionDTO implements DelegateExecution {
public BpmDelegateExecutionDTO(String getProcessInstanceId) {
this.getProcessInstanceId = getProcessInstanceId;
}
private final String getProcessInstanceId;
@Override
public String getId() {
return null;
}
@Override
public String getProcessInstanceId() {
return null;
}
@Override
public String getRootProcessInstanceId() {
return null;
}
@Override
public String getEventName() {
return null;
}
@Override
public void setEventName(String eventName) {
}
@Override
public String getProcessInstanceBusinessKey() {
return null;
}
@Override
public String getProcessInstanceBusinessStatus() {
return null;
}
@Override
public String getProcessDefinitionId() {
return null;
}
@Override
public String getPropagatedStageInstanceId() {
return null;
}
@Override
public String getParentId() {
return null;
}
@Override
public String getSuperExecutionId() {
return null;
}
@Override
public String getCurrentActivityId() {
return null;
}
@Override
public String getTenantId() {
return null;
}
@Override
public FlowElement getCurrentFlowElement() {
return null;
}
@Override
public void setCurrentFlowElement(FlowElement flowElement) {
}
@Override
public FlowableListener getCurrentFlowableListener() {
return null;
}
@Override
public void setCurrentFlowableListener(FlowableListener currentListener) {
}
@Override
public ReadOnlyDelegateExecution snapshotReadOnly() {
return null;
}
@Override
public DelegateExecution getParent() {
return null;
}
@Override
public List<? extends DelegateExecution> getExecutions() {
return null;
}
@Override
public void setActive(boolean isActive) {
}
@Override
public boolean isActive() {
return false;
}
@Override
public boolean isEnded() {
return false;
}
@Override
public void setConcurrent(boolean isConcurrent) {
}
@Override
public boolean isConcurrent() {
return false;
}
@Override
public boolean isProcessInstanceType() {
return false;
}
@Override
public void inactivate() {
}
@Override
public boolean isScope() {
return false;
}
@Override
public void setScope(boolean isScope) {
}
@Override
public boolean isMultiInstanceRoot() {
return false;
}
@Override
public void setMultiInstanceRoot(boolean isMultiInstanceRoot) {
}
@Override
public Map<String, Object> getVariables() {
return null;
}
@Override
public Map<String, VariableInstance> getVariableInstances() {
return null;
}
@Override
public Map<String, Object> getVariables(Collection<String> collection) {
return null;
}
@Override
public Map<String, VariableInstance> getVariableInstances(Collection<String> collection) {
return null;
}
@Override
public Map<String, Object> getVariables(Collection<String> collection, boolean b) {
return null;
}
@Override
public Map<String, VariableInstance> getVariableInstances(Collection<String> collection, boolean b) {
return null;
}
@Override
public Map<String, Object> getVariablesLocal() {
return null;
}
@Override
public Map<String, VariableInstance> getVariableInstancesLocal() {
return null;
}
@Override
public Map<String, Object> getVariablesLocal(Collection<String> collection) {
return null;
}
@Override
public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> collection) {
return null;
}
@Override
public Map<String, Object> getVariablesLocal(Collection<String> collection, boolean b) {
return null;
}
@Override
public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> collection, boolean b) {
return null;
}
@Override
public Object getVariable(String s) {
return null;
}
@Override
public VariableInstance getVariableInstance(String s) {
return null;
}
@Override
public Object getVariable(String s, boolean b) {
return null;
}
@Override
public VariableInstance getVariableInstance(String s, boolean b) {
return null;
}
@Override
public Object getVariableLocal(String s) {
return null;
}
@Override
public VariableInstance getVariableInstanceLocal(String s) {
return null;
}
@Override
public Object getVariableLocal(String s, boolean b) {
return null;
}
@Override
public VariableInstance getVariableInstanceLocal(String s, boolean b) {
return null;
}
@Override
public <T> T getVariable(String s, Class<T> aClass) {
return null;
}
@Override
public <T> T getVariableLocal(String s, Class<T> aClass) {
return null;
}
@Override
public Set<String> getVariableNames() {
return null;
}
@Override
public Set<String> getVariableNamesLocal() {
return null;
}
@Override
public void setVariable(String s, Object o) {
}
@Override
public void setVariable(String s, Object o, boolean b) {
}
@Override
public Object setVariableLocal(String s, Object o) {
return null;
}
@Override
public Object setVariableLocal(String s, Object o, boolean b) {
return null;
}
@Override
public void setVariables(Map<String, ?> map) {
}
@Override
public void setVariablesLocal(Map<String, ?> map) {
}
@Override
public boolean hasVariables() {
return false;
}
@Override
public boolean hasVariablesLocal() {
return false;
}
@Override
public boolean hasVariable(String s) {
return false;
}
@Override
public boolean hasVariableLocal(String s) {
return false;
}
@Override
public void removeVariable(String s) {
}
@Override
public void removeVariableLocal(String s) {
}
@Override
public void removeVariables(Collection<String> collection) {
}
@Override
public void removeVariablesLocal(Collection<String> collection) {
}
@Override
public void removeVariables() {
}
@Override
public void removeVariablesLocal() {
}
@Override
public void setTransientVariable(String s, Object o) {
}
@Override
public void setTransientVariableLocal(String s, Object o) {
}
@Override
public void setTransientVariables(Map<String, Object> map) {
}
@Override
public Object getTransientVariable(String s) {
return null;
}
@Override
public Map<String, Object> getTransientVariables() {
return null;
}
@Override
public void setTransientVariablesLocal(Map<String, Object> map) {
}
@Override
public Object getTransientVariableLocal(String s) {
return null;
}
@Override
public Map<String, Object> getTransientVariablesLocal() {
return null;
}
@Override
public void removeTransientVariableLocal(String s) {
}
@Override
public void removeTransientVariable(String s) {
}
@Override
public void removeTransientVariables() {
}
@Override
public void removeTransientVariablesLocal() {
}
}

View File

@ -19,6 +19,8 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum;
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService;
import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
@ -94,6 +96,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Resource
private ManagementService managementService;
@Resource
private BpmProcessInstanceCopyService processInstanceCopyService;
@Override
public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) {
// 查询待办任务

View File

@ -0,0 +1,127 @@
package cn.iocoder.yudao.module.bpm.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.spring.SpringUtil;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.ExtensionElement;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.FlowNode;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import java.util.*;
/**
* 流程引擎工具类封装
*
* @author: linjinp
* @create: 2019-12-24 13:51
**/
public class FlowableUtils {
/**
* 获取流程名称
*
* @param processDefinitionId
* @return
*/
public static String getProcessDefinitionName(String processDefinitionId) {
RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class);
ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId);
return processDefinition.getName();
}
public static ProcessDefinition getProcessDefinition(String processDefinitionId) {
RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class);
return repositoryService.getProcessDefinition(processDefinitionId);
}
/**
* 获取节点数据
*
* @param processInstanceId
* @param nodeId
* @return
*/
public static FlowNode getFlowNode(String processInstanceId, String nodeId) {
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class);
String definitionld = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId(); // 获取bpm模型对象
BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionld);
// 传节点定义key获取当前节点
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(nodeId);
return flowNode;
}
public static ExtensionElement generateFlowNodeIdExtension(String nodeId) {
ExtensionElement extensionElement = new ExtensionElement();
extensionElement.setElementText(nodeId);
extensionElement.setName("nodeId");
extensionElement.setNamespacePrefix("flowable");
extensionElement.setNamespace("nodeId");
return extensionElement;
}
public static String getNodeIdFromExtension(FlowElement flowElement) {
Map<String, List<ExtensionElement>> extensionElements = flowElement.getExtensionElements();
return extensionElements.get("nodeId").get(0).getElementText();
}
public static Long getStartUserIdFromProcessInstance(ProcessInstance instance) {
if (null == instance) {
return null;
}
return NumberUtils.parseLong(instance.getStartUserId());
}
public static String getTaskNameByTaskId(String taskId) {
TaskService taskService = SpringUtil.getBean(TaskService.class);
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
return task.getName();
}
// TODO @kyleUtils 里不做查询可以封装到 bpmTaskService
public static Map<String/* taskId */, String/* taskName */> getTaskNameByTaskIds(Collection<String> taskIds) {
TaskService taskService = SpringUtil.getBean(TaskService.class);
List<Task> tasks = taskService.createTaskQuery().taskIds(taskIds).list();
if (CollUtil.isNotEmpty(tasks)) {
Map<String/* taskId */, String/* taskName */> taskMap = new HashMap<>(tasks.size());
for (Task task : tasks) {
taskMap.putIfAbsent(task.getId(), task.getName());
}
return taskMap;
}
return Collections.emptyMap();
}
public static String getProcessInstanceNameByTaskId(String processInstanceId) {
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstanceId)
.singleResult();
return processInstance.getName();
}
// TODO @kyleUtils 里不做查询可以封装到 bpmTaskService
public static Map<String/* processInstaneId */, String/* processInstaneName */> getProcessInstanceNameByTaskIds(Set<String> taskIds) {
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processInstanceIds(taskIds).list();
if (CollUtil.isNotEmpty(processInstances)) {
Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap = new HashMap<>(processInstances.size());
for (ProcessInstance processInstance : processInstances) {
processInstaneMap.putIfAbsent(processInstance.getId(), processInstance.getName());
}
return processInstaneMap;
}
return Collections.emptyMap();
}
}

View File

@ -0,0 +1,242 @@
package cn.iocoder.yudao.module.bpm.service.candidate;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX1Script;
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX2Script;
import cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor.BpmCandidateScriptApiSourceInfoProcessor;
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.PostApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import jakarta.annotation.Resource;
import org.flowable.engine.delegate.DelegateExecution;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static java.util.Collections.singleton;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
@Import({BpmCandidateSourceInfoProcessorChain.class,
BpmCandidateScriptApiSourceInfoProcessor.class, BpmTaskAssignLeaderX1Script.class,
BpmTaskAssignLeaderX2Script.class})
public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest {
@Resource
private BpmCandidateSourceInfoProcessorChain processorChain;
@MockBean
private BpmUserGroupService userGroupService;
@MockBean
private DeptApi deptApi;
@MockBean
private AdminUserApi adminUserApi;
@MockBean
private PermissionApi permissionApi;
@MockBean
private RoleApi roleApi;
@MockBean
private PostApi postApi;
@MockBean
private DictDataApi dictDataApi;
@Resource
private BpmCandidateScriptApiSourceInfoProcessor bpmCandidateScriptApiSourceInfoProcessor;
@Test
public void testCalculateTaskCandidateUsers_Role() {
// 准备参数
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.ROLE.getType());
// mock 方法
when(permissionApi.getUserRoleIdListByRoleIds(eq(rule.getOptions())))
.thenReturn(asSet(11L, 22L));
mockGetUserMap(asSet(11L, 22L));
// 调用
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.addRule(rule);
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
// 断言
assertEquals(asSet(11L, 22L), results);
}
@Test
public void testCalculateTaskCandidateUsers_DeptMember() {
// 准备参数
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType());
// mock 方法
List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L),
id -> new AdminUserRespDTO().setId(id));
when(adminUserApi.getUserListByDeptIds(eq(rule.getOptions()))).thenReturn(users);
mockGetUserMap(asSet(11L, 22L));
// 调用
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.addRule(rule);
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
// 断言
assertEquals(asSet(11L, 22L), results);
}
@Test
public void testCalculateTaskCandidateUsers_DeptLeader() {
// 准备参数
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType());
// mock 方法
DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L));
DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L));
when(deptApi.getDeptList(eq(rule.getOptions()))).thenReturn(Arrays.asList(dept1, dept2));
mockGetUserMap(asSet(11L, 22L));
// 调用
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.addRule(rule);
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
// 断言
assertEquals(asSet(11L, 22L), results);
}
@Test
public void testCalculateTaskCandidateUsers_Post() {
// 准备参数
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.POST.getType());
// mock 方法
List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L),
id -> new AdminUserRespDTO().setId(id));
when(adminUserApi.getUserListByPostIds(eq(rule.getOptions()))).thenReturn(users);
mockGetUserMap(asSet(11L, 22L));
// 调用
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.addRule(rule);
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
// 断言
assertEquals(asSet(11L, 22L), results);
}
@Test
public void testCalculateTaskCandidateUsers_User() {
// 准备参数
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.USER.getType());
// mock 方法
mockGetUserMap(asSet(1L, 2L));
// 调用
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.addRule(rule);
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
// 断言
assertEquals(asSet(1L, 2L), results);
}
@Test
public void testCalculateTaskCandidateUsers_UserGroup() {
// 准备参数
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
.setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType());
// mock 方法
BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L)));
BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(21L, 22L)));
when(userGroupService.getUserGroupList(eq(rule.getOptions()))).thenReturn(Arrays.asList(userGroup1, userGroup2));
mockGetUserMap(asSet(11L, 12L, 21L, 22L));
// 调用
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.addRule(rule);
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
// 断言
assertEquals(asSet(11L, 12L, 21L, 22L), results);
}
private void mockGetUserMap(Set<Long> assigneeUserIds) {
Map<Long, AdminUserRespDTO> userMap = CollectionUtils.convertMap(assigneeUserIds, id -> id,
id -> new AdminUserRespDTO().setId(id).setStatus(CommonStatusEnum.ENABLE.getStatus()));
when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
}
@Test
public void testCalculateTaskCandidateUsers_Script() {
// 准备参数
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(20L, 21L))
.setType(BpmTaskAssignRuleTypeEnum.SCRIPT.getType());
// mock 方法
BpmTaskAssignScript script1 = new BpmTaskAssignScript() {
@Override
public Set<Long> calculateTaskCandidateUsers(DelegateExecution task) {
return singleton(11L);
}
@Override
public BpmTaskRuleScriptEnum getEnum() {
return BpmTaskRuleScriptEnum.LEADER_X1;
}
};
BpmTaskAssignScript script2 = new BpmTaskAssignScript() {
@Override
public Set<Long> calculateTaskCandidateUsers(DelegateExecution task) {
return singleton(22L);
}
@Override
public BpmTaskRuleScriptEnum getEnum() {
return BpmTaskRuleScriptEnum.LEADER_X2;
}
};
bpmCandidateScriptApiSourceInfoProcessor.setScripts(Arrays.asList(script1, script2));
mockGetUserMap(asSet(11L, 22L));
// 调用
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
sourceInfo.addRule(rule);
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
// 断言
assertEquals(asSet(11L, 22L), results);
}
@Test
public void testRemoveDisableUsers() {
// 准备参数. 1L 可以找到2L 是禁用的3L 找不到
Set<Long> assigneeUserIds = asSet(1L, 2L, 3L);
// mock 方法
AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L)
.setStatus(CommonStatusEnum.ENABLE.getStatus()));
AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L)
.setStatus(CommonStatusEnum.DISABLE.getStatus()));
Map<Long, AdminUserRespDTO> userMap = MapUtil.builder(user1.getId(), user1)
.put(user2.getId(), user2).build();
when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
// 调用
processorChain.removeDisableUsers(assigneeUserIds);
// 断言
assertEquals(asSet(1L), assigneeUserIds);
}
}

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.bpm.service.cc;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
@Import({BpmProcessInstanceCopyServiceImpl.class})
class BpmProcessInstanceCopyServiceTest extends BaseDbUnitTest {
@Resource
private BpmProcessInstanceCopyServiceImpl service;
@Test
void queryById() {
}
}

View File

@ -13,6 +13,6 @@ public interface DictTypeConstants {
String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态
String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位
String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态
String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // 跟进方式
String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // CRM 跟进方式
}

View File

@ -19,6 +19,7 @@ public interface ErrorCodeConstants {
// ========== 商机管理 1-020-002-000 ==========
ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在");
ErrorCode BUSINESS_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除");
// TODO @lilleo商机状态商机类型都单独错误码段
@ -83,6 +84,7 @@ public interface ErrorCodeConstants {
// ========== 跟进记录 1_020_013_000 ==========
ErrorCode FOLLOW_UP_RECORD_NOT_EXISTS = new ErrorCode(1_020_013_000, "跟进记录不存在");
ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限");
// ========== 待办消息 1_020_014_000 ==========
ErrorCode BACKLOG_CONTACT_STATUS_INVALID = new ErrorCode(1_020_014_000, "客户联系状态有误");

View File

@ -11,6 +11,12 @@ public interface LogRecordConstants {
// ======================= CRM_LEADS 线索 =======================
String CRM_LEADS_TYPE = "CRM 线索";
String CRM_LEADS_CREATE_SUB_TYPE = "创建线索";
String CRM_LEADS_CREATE_SUCCESS = "创建了线索{{#clue.name}}";
String CRM_LEADS_UPDATE_SUB_TYPE = "更新线索";
String CRM_LEADS_UPDATE_SUCCESS = "更新了线索【{{#clueName}}】: {_DIFF{#updateReqVO}}";
String CRM_LEADS_DELETE_SUB_TYPE = "删除线索";
String CRM_LEADS_DELETE_SUCCESS = "删除了线索【{{#clueName}}】";
// ======================= CRM_CUSTOMER 客户 =======================

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.crm.enums.business;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.Arrays;
// TODO @lzxhqs1titledescriptioncreate 可以删除非标准的 javadoc 注释哈然后可以在类上加下这个类的注释2CrmBizEndStatus 改成 CrmBusinessEndStatus非必要不缩写哈可阅读比较重要
/**
* @author lzxhqs
* @version 1.0
* @title CrmBizEndStatus
* @description
* @create 2024/1/12
*/
@RequiredArgsConstructor
@Getter
public enum CrmBizEndStatus implements IntArrayValuable {
WIN(1, "赢单"),
LOSE(2, "输单"),
INVALID(3, "无效");
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizEndStatus::getStatus).toArray();
// TODO @lzxhqs这里的方法建议放到 49 行之后一般类里是静态变量普通变量静态方法普通方法
public static boolean isWin(Integer status) {
return ObjectUtil.equal(WIN.getStatus(), status);
}
public static boolean isLose(Integer status) {
return ObjectUtil.equal(LOSE.getStatus(), status);
}
public static boolean isInvalid(Integer status) {
return ObjectUtil.equal(INVALID.getStatus(), status);
}
/**
* 场景类型
*/
private final Integer status;
/**
* 场景名称
*/
private final String name;
@Override
public int[] array() {
return ARRAYS;
}
}

View File

@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
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.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
@ -24,19 +25,17 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
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.servlet.http.HttpServletResponse;
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.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@ -85,13 +84,13 @@ public class CrmBusinessStatusTypeController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id);
// 处理状态回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作更简洁一点下面几个也是
// TODO @lzxhqs可以在 businessStatusService 加个 getBusinessStatusListByTypeId 方法直接返回 List<CrmBusinessStatusDO> 常用的尽量封装个简单易懂的方法不用追求绝对通用
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
queryVO.setTypeId(id);
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType, statusList));
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(statusType, statusList));
}
@GetMapping("/page")
@ -100,12 +99,7 @@ public class CrmBusinessStatusTypeController {
public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) {
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
// 处理部门回显
// TODO @ljlleo可以使用 CollectionUtils.convertSet 替代常用的 stream 操作更简洁一点下面几个也是哈
Set<Long> deptIds = pageResult.getList().stream()
.map(CrmBusinessStatusTypeDO::getDeptIds)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.collect(Collectors.toSet());
Set<Long> deptIds = CollectionUtils.convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds,Collection::stream);
List<DeptRespDTO> deptList = deptApi.getDeptList(deptIds);
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList));
}

View File

@ -1,5 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO;
import cn.iocoder.yudao.module.crm.enums.business.CrmBizEndStatus;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
@ -9,10 +12,11 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
// TODO @ljileoDiffLogField function 完善一下
@Schema(description = "管理后台 - CRM 商机创建/更新 Request VO")
@Data
public class CrmBusinessSaveReqVO {
@ -54,7 +58,7 @@ public class CrmBusinessSaveReqVO {
@DiffLogField(name = "商机金额")
private Integer price;
// TODO @ljileo折扣使用 Integer 类型存储时默认 * 100展示的时候前端需要 / 100避免精度丢失问题
// TODO @lzxhqs折扣使用 Integer 类型存储时默认 * 100展示的时候前端需要 / 100避免精度丢失问题
@Schema(description = "整单折扣")
@DiffLogField(name = "整单折扣")
private Integer discountPercent;
@ -67,6 +71,15 @@ public class CrmBusinessSaveReqVO {
@DiffLogField(name = "备注")
private String remark;
// TODO @ljileo修改的时候应该可以传递添加的产品
@Schema(description = "结束状态", example = "1")
@InEnum(CrmBizEndStatus.class)
private Integer endStatus;
// TODO @lzxhqs不设置默认 new ArrayList<>()一般 pojo 不设置默认值哈
@Schema(description = "商机产品列表")
private List<CrmBusinessProductSaveReqVO> products = new ArrayList<>();
@Schema(description = "联系人编号", example = "110")
private Long contactId; // 使用场景联系人详情添加商机时如果需要关联两者需要传递 contactId 字段
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
// TODO @lzxhqs这个类如果没用到可以考虑删除哈
@Schema(description = "管理后台 - 商机产品分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class CrmBusinessProductPageReqVO extends PageParam {
}

View File

@ -0,0 +1,11 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 商机产品关联 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CrmBusinessProductRespVO {
}

View File

@ -0,0 +1,51 @@
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - CRM 商机产品关联表 创建/更新 Request VO")
@Data
public class CrmBusinessProductSaveReqVO {
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
private Long id;
// TODO @lzxhqs这个字段应该是 Long 类型
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "商机编号不能为空")
private Integer businessId;
// TODO @lzxhqs这个字段应该是 Long 类型
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "产品编号不能为空")
private Integer productId;
@Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "产品单价不能为空")
private BigDecimal price;
@Schema(description = "销售价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "销售价格不能为空")
private BigDecimal salesPrice;
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "数量不能为空")
private BigDecimal num;
@Schema(description = "折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "折扣不能为空")
private BigDecimal discount;
@Schema(description = "小计(折扣后价格)", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "小计(折扣后价格)不能为空")
private BigDecimal subtotal;
// TODO @lzxhqs字符串 @NotEmpty因为要考虑 "" 前端搞了这个玩意
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
@NotNull(message = "单位不能为空")
private String unit;
}

View File

@ -21,11 +21,11 @@ public class CrmBusinessStatusSaveReqVO {
@NotEmpty(message = "状态名不能为空")
private String name;
// TODO @lilleopercent 应该是 Integer
// TODO @lzxhqspercent 应该是 Integer
@Schema(description = "赢单率")
private String percent;
// TODO @lilleo这个是不是不用前端新增和修改的时候传递交给顺序计算出来存储起来就好了
// TODO @lzxhqs这个是不是不用前端新增和修改的时候传递交给顺序计算出来存储起来就好了
@Schema(description = "排序")
private Integer sort;

View File

@ -19,11 +19,11 @@ public class CrmBusinessStatusTypeSaveReqVO {
@NotEmpty(message = "状态类型名不能为空")
private String name;
// TODO @lzxhqs VO 里面我们不使用默认值哈这里 Lists.newArrayList() 看看怎么去掉上面 deptIds 也是类似噢
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
private List<Long> deptIds = Lists.newArrayList();
// TODO @ljlleo VO 里面我们不使用默认值哈这里 Lists.newArrayList() 看看怎么去掉上面 deptIds 也是类似噢
@Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
private List<CrmBusinessStatusSaveReqVO> statusList = Lists.newArrayList();
private List<CrmBusinessStatusSaveReqVO> statusList;
}

View File

@ -125,11 +125,8 @@ public class CrmContactController {
@Operation(summary = "获得联系人的精简列表")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<CrmContactRespVO>> getSimpleContactList() {
// TODO @puhui999这种还是搞个 getContactList 方法好点哈
CrmContactPageReqVO reqVO = new CrmContactPageReqVO();
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
PageResult<CrmContactDO> pageResult = contactService.getContactPage(reqVO, getLoginUserId());
return success(convertList(pageResult.getList(), contact -> // 只返回 idname 字段
List<CrmContactDO> list = contactService.getSimpleContactList(getLoginUserId());
return success(convertList(list, contact -> // 只返回 idname 字段
new CrmContactRespVO().setId(contact.getId()).setName(contact.getName())));
}

View File

@ -1,83 +1,116 @@
package cn.iocoder.yudao.module.crm.controller.admin.contract.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
// TODO @puhui999导出注解哈
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - CRM 合同 Response VO")
@Data
@ExcelIgnoreUnannotated
public class CrmContractRespVO {
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
@ExcelProperty("合同编号")
private Long id;
@Schema(description = "合同名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "王五")
@ExcelProperty("合同名称")
private String name;
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "18336")
@ExcelProperty("客户编号")
private Long customerId;
@Schema(description = "商机编号", example = "10864")
@ExcelProperty("商机编号")
private Long businessId;
@Schema(description = "工作流编号", example = "1043")
@ExcelProperty("工作流编号")
private Long processInstanceId;
@Schema(description = "下单日期", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("下单日期")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime orderDate;
@Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "17144")
@ExcelProperty("负责人的用户编号")
private Long ownerUserId;
// TODO @芋艿未来应该支持自动生成
@Schema(description = "合同编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20230101")
@ExcelProperty("合同编号")
private String no;
@Schema(description = "开始时间")
@ExcelProperty("开始时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime startTime;
@Schema(description = "结束时间")
@ExcelProperty("结束时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime endTime;
@Schema(description = "合同金额", example = "5617")
@ExcelProperty("合同金额")
private Integer price;
@Schema(description = "整单折扣")
@ExcelProperty("整单折扣")
private Integer discountPercent;
@Schema(description = "产品总金额", example = "19510")
@ExcelProperty("产品总金额")
private Integer productPrice;
@Schema(description = "联系人编号", example = "18546")
@ExcelProperty("联系人编号")
private Long contactId;
@Schema(description = "公司签约人", example = "14036")
@ExcelProperty("公司签约人")
private Long signUserId;
@Schema(description = "最后跟进时间")
@ExcelProperty("最后跟进时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime contactLastTime;
@Schema(description = "备注", example = "你猜")
@ExcelProperty("备注")
private String remark;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime createTime;
@Schema(description = "创建人", example = "25682")
@ExcelProperty("创建人")
private String creator;
@Schema(description = "创建人名字", example = "test")
@ExcelProperty("创建人名字")
private String creatorName;
@Schema(description = "客户名字", example = "test")
@ExcelProperty("客户名字")
private String customerName;
@Schema(description = "负责人", example = "test")
@ExcelProperty("负责人")
private String ownerUserName;
@Schema(description = "审批状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
@ExcelProperty("审批状态")
private Integer auditStatus;
}

View File

@ -28,6 +28,7 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "管理后台 - 跟进记录")
@ -37,7 +38,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
public class CrmFollowUpRecordController {
@Resource
private CrmFollowUpRecordService crmFollowUpRecordService;
private CrmFollowUpRecordService followUpRecordService;
@Resource
private CrmContactService contactService;
@Resource
@ -47,15 +48,7 @@ public class CrmFollowUpRecordController {
@Operation(summary = "创建跟进记录")
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:create')")
public CommonResult<Long> createFollowUpRecord(@Valid @RequestBody CrmFollowUpRecordSaveReqVO createReqVO) {
return success(crmFollowUpRecordService.createFollowUpRecord(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新跟进记录")
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:update')")
public CommonResult<Boolean> updateFollowUpRecord(@Valid @RequestBody CrmFollowUpRecordSaveReqVO updateReqVO) {
crmFollowUpRecordService.updateFollowUpRecord(updateReqVO);
return success(true);
return success(followUpRecordService.createFollowUpRecord(createReqVO));
}
@DeleteMapping("/delete")
@ -63,7 +56,7 @@ public class CrmFollowUpRecordController {
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:delete')")
public CommonResult<Boolean> deleteFollowUpRecord(@RequestParam("id") Long id) {
crmFollowUpRecordService.deleteFollowUpRecord(id);
followUpRecordService.deleteFollowUpRecord(id, getLoginUserId());
return success(true);
}
@ -72,7 +65,7 @@ public class CrmFollowUpRecordController {
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')")
public CommonResult<CrmFollowUpRecordRespVO> getFollowUpRecord(@RequestParam("id") Long id) {
CrmFollowUpRecordDO followUpRecord = crmFollowUpRecordService.getFollowUpRecord(id);
CrmFollowUpRecordDO followUpRecord = followUpRecordService.getFollowUpRecord(id);
return success(BeanUtils.toBean(followUpRecord, CrmFollowUpRecordRespVO.class));
}
@ -80,7 +73,7 @@ public class CrmFollowUpRecordController {
@Operation(summary = "获得跟进记录分页")
@PreAuthorize("@ss.hasPermission('crm:follow-up-record:query')")
public CommonResult<PageResult<CrmFollowUpRecordRespVO>> getFollowUpRecordPage(@Valid CrmFollowUpRecordPageReqVO pageReqVO) {
PageResult<CrmFollowUpRecordDO> pageResult = crmFollowUpRecordService.getFollowUpRecordPage(pageReqVO);
PageResult<CrmFollowUpRecordDO> pageResult = followUpRecordService.getFollowUpRecordPage(pageReqVO);
/// 拼接数据
Map<Long, CrmContactDO> contactMap = convertMap(contactService.getContactList(
convertSetByFlatMap(pageResult.getList(), item -> item.getContactIds().stream())), CrmContactDO::getId);

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.crm.convert.business;
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.business.vo.business.CrmBusinessRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
@ -8,6 +9,7 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusTypeDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
@ -45,4 +47,11 @@ public interface CrmBusinessConvert {
return voPageResult;
}
@Mapping(target = "id", source = "reqBO.bizId")
CrmBusinessDO convert(CrmUpdateFollowUpReqBO reqBO);
default List<CrmBusinessDO> convertList(List<CrmUpdateFollowUpReqBO> list) {
return CollectionUtils.convertList(list, INSTANCE::convert);
}
}

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.crm.convert.businessproduct;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
// TODO @lzxhqs看看是不是用 BeanUtils 替代了
/**
* @author lzxhqs
* @version 1.0
* @title CrmBusinessProductConvert
* @description
* @create 2024/1/12
*/
@Mapper
public interface CrmBusinessProductConvert {
CrmBusinessProductConvert INSTANCE = Mappers.getMapper(CrmBusinessProductConvert.class);
CrmBusinessProductDO convert(CrmBusinessProductSaveReqVO product);
}

View File

@ -14,6 +14,7 @@ import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
// TODO @lzxhqs看看是不是用 BeanUtils 替代了
/**
* 商机状态类型 Convert
*
@ -24,7 +25,6 @@ public interface CrmBusinessStatusTypeConvert {
CrmBusinessStatusTypeConvert INSTANCE = Mappers.getMapper(CrmBusinessStatusTypeConvert.class);
CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean);
PageResult<CrmBusinessStatusTypeRespVO> convertPage(PageResult<CrmBusinessStatusTypeDO> page);
@ -38,10 +38,7 @@ public interface CrmBusinessStatusTypeConvert {
}
default CrmBusinessStatusTypeRespVO convert(CrmBusinessStatusTypeDO bean, List<CrmBusinessStatusDO> statusList) {
// TODO @ljlleo 可以链式赋值简化成一行
CrmBusinessStatusTypeRespVO result = convert(bean);
result.setStatusList(statusList);
return result;
return convert(bean).setStatusList(statusList);
}
}

View File

@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
@ -66,4 +67,11 @@ public interface CrmContactConvert {
findAndThen(userMap, Long.parseLong(contactRespVO.getCreator()), user -> contactRespVO.setCreatorName(user.getNickname()));
}
@Mapping(target = "id", source = "reqBO.bizId")
CrmContactDO convert(CrmUpdateFollowUpReqBO reqBO);
default List<CrmContactDO> convertList(List<CrmUpdateFollowUpReqBO> list) {
return CollectionUtils.convertList(list, INSTANCE::convert);
}
}

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.business;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.enums.business.CrmBizEndStatus;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -52,6 +54,7 @@ public class CrmBusinessDO extends BaseDO {
* 客户编号
*
* TODO @ljileo这个字段后续要写下关联的实体哈
* 关联 {@link CrmCustomerDO#getId()}
*/
private Long customerId;
/**
@ -77,9 +80,9 @@ public class CrmBusinessDO extends BaseDO {
*/
private String remark;
/**
* 1赢单2输单3无效
* 结束状态
*
* TODO @lijie搞个枚举
* 枚举 {@link CrmBizEndStatus}
*/
private Integer endStatus;
/**
@ -93,7 +96,7 @@ public class CrmBusinessDO extends BaseDO {
/**
* 跟进状态
*
* TODO @lijie目前就是 Boolean是否跟进
* TODO @lzxhqs目前就是 Boolean是否跟进
*/
private Integer followUpStatus;

View File

@ -0,0 +1,80 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.business;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.math.BigDecimal;
/**
* 商机产品关联表 DO
*
* @author lzxhqs
*/
@TableName("crm_business_product")
@KeySequence("crm_business_product_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CrmBusinessProductDO extends BaseDO {
/**
* 主键
*/
@TableId
private Long id;
/**
* 商机编号
*
* 关联 {@link CrmBusinessDO#getId()}
*/
private Long businessId;
/**
* 产品编号
*
* 关联 {@link CrmProductDO#getId()}
*/
private Long productId;
// TODO @lzxhqs改成 Integer单位目前整体倾向放大 100 倍哈
/**
* 产品单价
*/
private BigDecimal price;
/**
* 销售价格
*/
private BigDecimal salesPrice;
// TODO @lzxhqs改成 count
/**
* 数量
*/
private BigDecimal num;
// TODO @lzxhqs改成 discountPercent
/**
* 折扣
*/
private BigDecimal discount;
// TODO @lzxhqs改成 totalPrice总计价格和现有项目风格一致
/**
* 小计折扣后价格
*/
private BigDecimal subtotal;
/**
* 单位
*/
private String unit;
}

View File

@ -35,11 +35,9 @@ public class CrmBusinessStatusDO {
*/
private String name;
/**
* 赢单率
*
* TODO 这里是不是改成 Integer 存储百分比 * 100
* 赢单率百分比
*/
private String percent;
private Integer percent;
/**
* 排序
*/

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.crm.dal.dataobject.business;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
import com.baomidou.mybatisplus.annotation.KeySequence;
@ -43,6 +44,7 @@ public class CrmBusinessStatusTypeDO extends BaseDO {
* 开启状态
*
* TODO 改成 Integer关联 CommonStatus
* 枚举 {@link CommonStatusEnum}
*/
private Boolean status;

View File

@ -0,0 +1,21 @@
package cn.iocoder.yudao.module.crm.dal.mysql.business;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 商机产品 Mapper // TODO @lzxhqs类注释和作者之间要有一个空行
* @author lzxhqs
*/
@Mapper
public interface CrmBusinessProductMapper extends BaseMapperX<CrmBusinessProductDO> {
default void deleteByBusinessId(Long id) { // TODO @lzxhqs第一个方法和类之间最好空一行
delete(CrmBusinessProductDO::getBusinessId, id);
}
default CrmBusinessProductDO selectByBusinessId(Long id) { // TODO @lzxhqsid 最好改成 businessId上面也是这样一看更容易懂
return selectOne(CrmBusinessProductDO::getBusinessId, id);
}
}

View File

@ -28,4 +28,17 @@ public interface CrmBusinessStatusTypeMapper extends BaseMapperX<CrmBusinessStat
.eqIfPresent(CrmBusinessStatusTypeDO::getStatus, queryVO.getStatus())
.inIfPresent(CrmBusinessStatusTypeDO::getId, queryVO.getIdList()));
}
// TODO @lzxhqs这个可以改成 selectByName业务上基于在判断 id 匹配这样更通用一些mapper 尽量通用不关注或者特别关联业务
/**
* 根据ID和name查询
*
* @param id 商机状态类型id
* @param name 状态类型名
* @return result
*/
default CrmBusinessStatusTypeDO selectByIdAndName(Long id, String name) {
return selectOne(CrmBusinessStatusTypeDO::getId, id, CrmBusinessStatusTypeDO::getName, name);
}
}

View File

@ -63,5 +63,8 @@ public interface CrmContractMapper extends BaseMapperX<CrmContractDO> {
default Long selectCountByContactId(Long contactId) {
return selectCount(CrmContractDO::getContactId, contactId);
}
default CrmContractDO selectByBizId(Long businessId) { // TODO @lzxhqs1方法和方法之间要有空行2selectCountByBusinessId一个是应该求数量一个是不要缩写 BizId 可读性
return selectOne(CrmContractDO::getBusinessId, businessId);
}
}

View File

@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusi
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -35,6 +36,13 @@ public interface CrmBusinessService {
*/
void updateBusiness(@Valid CrmBusinessSaveReqVO updateReqVO);
/**
* 更新商机相关跟进信息
*
* @param updateFollowUpReqBOList 跟进信息
*/
void updateBusinessFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList);
/**
* 删除商机
*

View File

@ -7,14 +7,22 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO;
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
import cn.iocoder.yudao.module.crm.convert.businessproduct.CrmBusinessProductConvert;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessProductDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactBusinessDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.business.CrmBusinessProductMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.contactbusinesslink.CrmContactBusinessMapper;
import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
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.contact.CrmContactBusinessService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import com.mzt.logapi.context.LogRecordContext;
@ -25,11 +33,13 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_CONTRACT_EXISTS;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
@ -45,6 +55,15 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
@Resource
private CrmBusinessMapper businessMapper;
@Resource
private CrmBusinessProductMapper businessProductMapper;
// TODO @lzxhqs不直接调用这个 mapper要调用对方的 service每个业务独立收敛
@Resource
private CrmContractMapper contractMapper;
// TODO @lzxhqs不直接调用这个 mapper要调用对方的 service每个业务独立收敛
@Resource
private CrmContactBusinessMapper contactBusinessMapper;
@Resource
private CrmPermissionService permissionService;
@Resource
@ -61,18 +80,72 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
.setOwnerUserId(userId);
businessMapper.insert(business);
// TODO 商机待定插入商机与产品的关联表校验商品存在
// TODO lzxhqs新增时是不是不用调用这个方法哈
verifyCrmBusinessProduct(business.getId());
// TODO @lzxhqs CollUtils.isNotEmpty
if (!createReqVO.getProducts().isEmpty()) {
createBusinessProducts(createReqVO.getProducts(), business.getId());
}
// TODO 商机待定在联系人的详情页如果直接新建商机则需要关联下这里要搞个 CrmContactBusinessDO
createContactBusiness(business.getId(), createReqVO.getContactId());
// 2. 创建数据权限
// 设置当前操作的人为负责人
permissionService.createPermission(new CrmPermissionCreateReqBO().setBizType(CrmBizTypeEnum.CRM_BUSINESS.getType())
.setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); // 设置当前操作的人为负责人
.setBizId(business.getId()).setUserId(userId).setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
// 4. 记录操作日志上下文
LogRecordContext.putVariable("business", business);
return business.getId();
}
// TODO @lzxhqsCrmContactBusinessService 调用这个这样逻辑才能收敛哈
/**
* @param businessId 商机id
* @param contactId 联系人id
* @throws
* @description 联系人与商机的关联
* @author lzxhqs
*/
private void createContactBusiness(Long businessId, Long contactId) {
CrmContactBusinessDO contactBusiness = new CrmContactBusinessDO();
contactBusiness.setBusinessId(businessId);
contactBusiness.setContactId(contactId);
contactBusinessMapper.insert(contactBusiness);
}
// TODO @lzxhqs这个方法注释格式不对删除@description然后把 插入商机产品关联表 作为方法注释
/**
* @param products 产品集合
* @description 插入商机产品关联表
* @author lzxhqs
*/
private void createBusinessProducts(List<CrmBusinessProductSaveReqVO> products, Long businessId) {
// TODO @lzxhqs可以用 CollectionUtils.convertList
List<CrmBusinessProductDO> list = new ArrayList<>();
for (CrmBusinessProductSaveReqVO product : products) {
CrmBusinessProductDO businessProductDO = CrmBusinessProductConvert.INSTANCE.convert(product);
businessProductDO.setBusinessId(businessId);
list.add(businessProductDO);
}
businessProductMapper.insertBatch(list);
}
/**
* @param id businessId
* @description 校验管理的产品存在则删除
* @author lzxhqs
*/
private void verifyCrmBusinessProduct(Long id) {
CrmBusinessProductDO businessProductDO = businessProductMapper.selectByBusinessId(id);
if (businessProductDO != null) {
//通过商机Id删除
businessProductMapper.deleteByBusinessId(id);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
@ -86,6 +159,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
CrmBusinessDO updateObj = BeanUtils.toBean(updateReqVO, CrmBusinessDO.class);
businessMapper.updateById(updateObj);
// TODO 商机待定插入商机与产品的关联表校验商品存在
// TODO @lzxhqs更新时可以调用 CollectionUtils diffList尽量避免这种先删除再插入而是新增的插入变更的更新没的删除不然这个表每次更新会多好多数据
verifyCrmBusinessProduct(updateReqVO.getId());
if (!updateReqVO.getProducts().isEmpty()) {
createBusinessProducts(updateReqVO.getProducts(), updateReqVO.getId());
}
// TODO @商机待定如果状态发生变化插入商机状态变更记录表
// 3. 记录操作日志上下文
@ -93,6 +171,11 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
LogRecordContext.putVariable("businessName", oldBusiness.getName());
}
@Override
public void updateBusinessFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList) {
businessMapper.updateBatch(CrmBusinessConvert.INSTANCE.convertList(updateFollowUpReqBOList));
}
@Override
@Transactional(rollbackFor = Exception.class)
@LogRecord(type = CRM_BUSINESS_TYPE, subType = CRM_BUSINESS_DELETE_SUB_TYPE, bizNo = "{{#id}}",
@ -102,6 +185,7 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
// 校验存在
CrmBusinessDO business = validateBusinessExists(id);
// TODO @商机待定需要校验有没关联合同CrmContractDO businessId 字段
validateContractExists(id);
// 删除
businessMapper.deleteById(id);
@ -112,6 +196,19 @@ public class CrmBusinessServiceImpl implements CrmBusinessService {
LogRecordContext.putVariable("businessName", business.getName());
}
/**
* @param businessId 商机id
* @throws
* @description 删除校验合同是关联合同
* @author lzxhqs
*/
private void validateContractExists(Long businessId) {
CrmContractDO contract = contractMapper.selectByBizId(businessId);
if (contract != null) {
throw exception(BUSINESS_CONTRACT_EXISTS);
}
}
private CrmBusinessDO validateBusinessExists(Long id) {
CrmBusinessDO crmBusiness = businessMapper.selectById(id);
if (crmBusiness == null) {

View File

@ -95,14 +95,18 @@ public class CrmBusinessStatusTypeServiceImpl implements CrmBusinessStatusTypeSe
// TODO @ljlleo 这个方法这个参考 validateDeptNameUnique 实现
private void validateBusinessStatusTypeExists(String name, Long id) {
LambdaQueryWrapper<CrmBusinessStatusTypeDO> wrapper = new LambdaQueryWrapperX<>();
if(null != id) {
wrapper.ne(CrmBusinessStatusTypeDO::getId, id);
}
long cnt = businessStatusTypeMapper.selectCount(wrapper.eq(CrmBusinessStatusTypeDO::getName, name));
if (cnt > 0) {
CrmBusinessStatusTypeDO businessStatusTypeDO = businessStatusTypeMapper.selectByIdAndName(id, name);
if (businessStatusTypeDO != null) {
throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS);
}
// LambdaQueryWrapper<CrmBusinessStatusTypeDO> wrapper = new LambdaQueryWrapperX<>();
// if(null != id) {
// wrapper.ne(CrmBusinessStatusTypeDO::getId, id);
// }
// long cnt = businessStatusTypeMapper.selectCount(wrapper.eq(CrmBusinessStatusTypeDO::getName, name));
// if (cnt > 0) {
// throw exception(BUSINESS_STATUS_TYPE_NAME_EXISTS);
// }
}
@Override

View File

@ -6,6 +6,7 @@ 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.CrmClueTransformReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -33,6 +34,13 @@ public interface CrmClueService {
*/
void updateClue(@Valid CrmClueSaveReqVO updateReqVO);
/**
* 更新线索相关的跟进信息
*
* @param clueUpdateFollowUpReqBO 信息
*/
void updateClueFollowUp(CrmUpdateFollowUpReqBO clueUpdateFollowUpReqBO);
/**
* 删除线索
*

View File

@ -2,8 +2,11 @@ package cn.iocoder.yudao.module.crm.service.clue;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
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.clue.vo.CrmCluePageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.CrmClueSaveReqVO;
@ -17,8 +20,13 @@ 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.customer.CrmCustomerService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
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;
@ -28,11 +36,12 @@ import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
/**
@ -57,46 +66,82 @@ public class CrmClueServiceImpl implements CrmClueService {
private AdminUserApi adminUserApi;
@Override
// TODO @min补充相关几个方法的操作日志
@Transactional(rollbackFor = Exception.class)
@LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_CREATE_SUB_TYPE, bizNo = "{{#clue.id}}",
success = CRM_LEADS_CREATE_SUCCESS)
public Long createClue(CrmClueSaveReqVO createReqVO) {
// 校验关联数据
// 1. 校验关联数据
validateRelationDataExists(createReqVO);
// 插入
// 2. 插入
CrmClueDO clue = BeanUtils.toBean(createReqVO, CrmClueDO.class);
clueMapper.insert(clue);
// 返回
// 3. 创建数据权限
CrmPermissionCreateReqBO createReqBO = new CrmPermissionCreateReqBO()
.setBizType(CrmBizTypeEnum.CRM_LEADS.getType())
.setBizId(clue.getId())
// 设置当前操作的人为负责人
.setUserId(getLoginUserId())
.setLevel(CrmPermissionLevelEnum.OWNER.getLevel());
crmPermissionService.createPermission(createReqBO);
// 4. 记录操作日志上下文
LogRecordContext.putVariable("clue", clue);
return clue.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
@LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
success = CRM_LEADS_UPDATE_SUCCESS)
@CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
public void updateClue(CrmClueSaveReqVO updateReqVO) {
// 校验线索是否存在
validateClueExists(updateReqVO.getId());
// 校验关联数据
Assert.notNull(updateReqVO.getId(), "线索编号不能为空");
// 1. 校验线索是否存在
CrmClueDO oldClue = validateClueExists(updateReqVO.getId());
// 2. 校验关联数据
validateRelationDataExists(updateReqVO);
// 更新
// 3. 更新
CrmClueDO updateObj = BeanUtils.toBean(updateReqVO, CrmClueDO.class);
clueMapper.updateById(updateObj);
// 3. 记录操作日志上下文
LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldClue, CrmCustomerSaveReqVO.class));
LogRecordContext.putVariable("clueName", oldClue.getName());
}
@Override
@CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
public void deleteClue(Long id) {
// 校验存在
validateClueExists(id);
// 删除
clueMapper.deleteById(id);
// 删除数据权限
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_LEADS.getType(), id);
public void updateClueFollowUp(CrmUpdateFollowUpReqBO clueUpdateFollowUpReqBO) {
clueMapper.updateById(BeanUtils.toBean(clueUpdateFollowUpReqBO, CrmClueDO.class).setId(clueUpdateFollowUpReqBO.getBizId()));
}
private void validateClueExists(Long id) {
if (clueMapper.selectById(id) == null) {
@Override
@Transactional(rollbackFor = Exception.class)
@LogRecord(type = CRM_LEADS_TYPE, subType = CRM_LEADS_DELETE_SUB_TYPE, bizNo = "{{#id}}",
success = CRM_LEADS_DELETE_SUCCESS)
@CrmPermission(bizType = CrmBizTypeEnum.CRM_LEADS, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)
public void deleteClue(Long id) {
// 1. 校验存在
CrmClueDO clue = validateClueExists(id);
// 2. 删除
clueMapper.deleteById(id);
// 3. 删除数据权限
crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_LEADS.getType(), id);
// 4. 记录操作日志上下文
LogRecordContext.putVariable("clueName", clue.getName());
}
private CrmClueDO validateClueExists(Long id) {
CrmClueDO crmClueDO = clueMapper.selectById(id);
if (crmClueDO == null) {
throw exception(CLUE_NOT_EXISTS);
}
return crmClueDO;
}
@Override
@ -139,29 +184,24 @@ public class CrmClueServiceImpl implements CrmClueService {
List<CrmClueDO> clues = getClueList(clueIds, userId);
if (CollUtil.isEmpty(clues) || ObjectUtil.notEqual(clues.size(), clueIds.size())) {
clueIds.removeAll(convertSet(clues, CrmClueDO::getId));
// TODO @min可以使用 StrUtil.join(",", clueIds) 简化这种常见操作
throw exception(CLUE_ANY_CLUE_NOT_EXISTS, clueIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
throw exception(CLUE_ANY_CLUE_NOT_EXISTS, StrUtil.join(",", clueIds));
}
// 过滤出未转化的客户
// TODO @min1存在已经转化的直接提示哈避免操作的用户以为都转化成功了2常见的过滤逻辑可以使用 CollectionUtils.filterList()
List<CrmClueDO> unTransformClues = clues.stream()
.filter(clue -> ObjectUtil.notEqual(Boolean.TRUE, clue.getTransformStatus())).toList();
// 传入的线索中包含已经转化的情况抛出业务异常
if (ObjectUtil.notEqual(clues.size(), unTransformClues.size())) {
// TODO @min可以使用 StrUtil.join(",", clueIds) 简化这种常见操作
clueIds.removeAll(convertSet(unTransformClues, CrmClueDO::getId));
throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, clueIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
// 存在已经转化的直接提示哈避免操作的用户以为都转化成功了
List<CrmClueDO> translatedClues = CollectionUtils.filterList(clues,
clue -> ObjectUtil.equal(Boolean.TRUE, clue.getTransformStatus()));
if (CollUtil.isNotEmpty(translatedClues)) {
throw exception(CLUE_ANY_CLUE_ALREADY_TRANSLATED, StrUtil.join(",", convertSet(translatedClues, CrmClueDO::getId)));
}
// 遍历线索(未转化的线索)创建对应的客户
unTransformClues.forEach(clue -> {
reqVO.getIds().forEach(id -> {
// 1. 创建客户
CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(clue, CrmCustomerSaveReqVO.class).setId(null);
CrmCustomerSaveReqVO customerSaveReqVO = BeanUtils.toBean(id, CrmCustomerSaveReqVO.class).setId(null);
Long customerId = customerService.createCustomer(customerSaveReqVO, userId);
// TODO @puhui999如果有跟进记录需要一起转过去
// TODO @puhui999如果有跟进记录需要一起转过去提问艿艿这里是复制线索所有的跟进吗还是直接把线索相关的跟进 bizTypebizId 全改为关联客户
// 2. 更新线索
clueMapper.updateById(new CrmClueDO().setId(clue.getId())
clueMapper.updateById(new CrmClueDO().setId(id)
.setTransformStatus(Boolean.TRUE).setCustomerId(customerId));
});
}

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactSaveReq
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.CrmContactTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -57,6 +58,13 @@ public interface CrmContactService {
*/
void updateOwnerUserIdByCustomerId(Long customerId, Long ownerUserId);
/**
* 更新联系人相关跟进信息
*
* @param updateFollowUpReqBOList 跟进信息
*/
void updateContactFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList);
/**
* 获得联系人
*
@ -89,6 +97,14 @@ public interface CrmContactService {
*/
List<CrmContactDO> getContactList();
/**
* 获取联系人列表校验权限
*
* @param userId 用户编号
* @return 联系人列表
*/
List<CrmContactDO> getSimpleContactList(Long userId);
/**
* 获得联系人分页
*

View File

@ -17,6 +17,7 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPerm
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.followup.bo.CrmUpdateFollowUpReqBO;
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;
@ -32,6 +33,7 @@ import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS;
@ -192,6 +194,11 @@ public class CrmContactServiceImpl implements CrmContactService {
contactMapper.updateOwnerUserIdByCustomerId(customerId, ownerUserId);
}
@Override
public void updateContactFollowUpBatch(List<CrmUpdateFollowUpReqBO> updateFollowUpReqBOList) {
contactMapper.updateBatch(CrmContactConvert.INSTANCE.convertList(updateFollowUpReqBOList));
}
//======================= 查询相关 =======================
@Override
@ -221,6 +228,13 @@ public class CrmContactServiceImpl implements CrmContactService {
return contactMapper.selectList();
}
@Override
public List<CrmContactDO> getSimpleContactList(Long userId) {
CrmContactPageReqVO reqVO = new CrmContactPageReqVO();
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
return contactMapper.selectPage(reqVO, userId).getList();
}
@Override
public PageResult<CrmContactDO> getContactPage(CrmContactPageReqVO pageReqVO, Long userId) {
return contactMapper.selectPage(pageReqVO, userId);

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractSaveR
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractTransferReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -41,6 +42,21 @@ public interface CrmContractService {
*/
void deleteContract(Long id);
/**
* 合同转移
*
* @param reqVO 请求
* @param userId 用户编号
*/
void transferContract(CrmContractTransferReqVO reqVO, Long userId);
/**
* 更新合同相关的更进信息
*
* @param contractUpdateFollowUpReqBO 信息
*/
void updateContractFollowUp(CrmUpdateFollowUpReqBO contractUpdateFollowUpReqBO);
/**
* 获得合同
*
@ -78,14 +94,6 @@ public interface CrmContractService {
*/
PageResult<CrmContractDO> getContractPageByCustomerId(CrmContractPageReqVO pageReqVO);
/**
* 合同转移
*
* @param reqVO 请求
* @param userId 用户编号
*/
void transferContract(CrmContractTransferReqVO reqVO, Long userId);
/**
* 查询属于某个联系人的合同数量
*

View File

@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.crm.dal.mysql.contract.CrmContractMapper;
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.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
import com.mzt.logapi.context.LogRecordContext;
@ -135,6 +136,11 @@ public class CrmContractServiceImpl implements CrmContractService {
LogRecordContext.putVariable("contract", contract);
}
@Override
public void updateContractFollowUp(CrmUpdateFollowUpReqBO contractUpdateFollowUpReqBO) {
contractMapper.updateById(BeanUtils.toBean(contractUpdateFollowUpReqBO, CrmContractDO.class).setId(contractUpdateFollowUpReqBO.getBizId()));
}
//======================= 查询相关 =======================
@Override

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageR
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 cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
import jakarta.validation.Valid;
import java.util.Collection;
@ -90,6 +91,13 @@ public interface CrmCustomerService {
*/
void lockCustomer(@Valid CrmCustomerLockReqVO lockReqVO, Long userId);
/**
* 更新客户相关更进信息
*
* @param customerUpdateFollowUpReqBO 请求
*/
void updateCustomerFollowUp(CrmUpdateFollowUpReqBO customerUpdateFollowUpReqBO);
// ==================== 公海相关操作 ====================
/**

View File

@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.crm.framework.permission.core.util.CrmPermissionU
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
import cn.iocoder.yudao.module.crm.service.followup.bo.CrmUpdateFollowUpReqBO;
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;
@ -203,6 +204,11 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
LogRecordContext.putVariable("customer", customer);
}
@Override
public void updateCustomerFollowUp(CrmUpdateFollowUpReqBO customerUpdateFollowUpReqBO) {
customerMapper.updateById(BeanUtils.toBean(customerUpdateFollowUpReqBO, CrmCustomerDO.class).setId(customerUpdateFollowUpReqBO.getBizId()));
}
// ==================== 公海相关操作 ====================
@Override
@ -221,16 +227,16 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
// 1.3. 校验客户是否锁定
validateCustomerIsLocked(customer, true);
// 2. 设置负责人为 NULL
// 2.1 设置负责人为 NULL
int updateOwnerUserIncr = customerMapper.updateOwnerUserIdById(customer.getId(), null);
if (updateOwnerUserIncr == 0) {
throw exception(CUSTOMER_UPDATE_OWNER_USER_FAIL);
}
// 3. 删除负责人数据权限
// 2.2 删除负责人数据权限
permissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), customer.getId(),
CrmPermissionLevelEnum.OWNER.getLevel());
// TODO @puhui999联系人的负责人也要设置为 null这块和领取是对应的因为领取后负责人也要关联过来
// 提问那是不是可以这样理解客户所有联系人的负责人默认为客户的负责人然后添加客户团队成员时才存在同时分配给的操作
// 3. 联系人的负责人也要设置为 null因为因为领取后负责人也要关联过来这块和 receiveCustomer 是对应的
contactService.updateOwnerUserIdByCustomerId(customer.getId(), null);
// 记录操作日志上下文

View File

@ -14,7 +14,7 @@ import jakarta.validation.Valid;
public interface CrmFollowUpRecordService {
/**
* 创建跟进记录
* 创建跟进记录 (数据权限基于 bizType bizId)
*
* @param createReqVO 创建信息
* @return 编号
@ -22,18 +22,12 @@ public interface CrmFollowUpRecordService {
Long createFollowUpRecord(@Valid CrmFollowUpRecordSaveReqVO createReqVO);
/**
* 更新跟进记录
* 删除跟进记录 (数据权限基于 bizType bizId)
*
* @param updateReqVO 更新信息
* @param id 编号
* @param userId 用户编号
*/
void updateFollowUpRecord(@Valid CrmFollowUpRecordSaveReqVO updateReqVO);
/**
* 删除跟进记录
*
* @param id 编号
*/
void deleteFollowUpRecord(Long id);
void deleteFollowUpRecord(Long id, Long userId);
/**
* 获得跟进记录
@ -44,7 +38,7 @@ public interface CrmFollowUpRecordService {
CrmFollowUpRecordDO getFollowUpRecord(Long id);
/**
* 获得跟进记录分页
* 获得跟进记录分页 (数据权限基于 bizType bizId)
*
* @param pageReqVO 分页查询
* @return 跟进记录分页

View File

@ -1,16 +1,36 @@
package cn.iocoder.yudao.module.crm.service.followup;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordPageReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.followup.vo.CrmFollowUpRecordSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.followup.CrmFollowUpRecordDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.permission.CrmPermissionDO;
import cn.iocoder.yudao.module.crm.dal.mysql.followup.CrmFollowUpRecordMapper;
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.clue.CrmClueService;
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
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.followup.bo.CrmUpdateFollowUpReqBO;
import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;
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.convertList;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_DELETE_DENIED;
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.FOLLOW_UP_RECORD_NOT_EXISTS;
/**
@ -25,36 +45,134 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
@Resource
private CrmFollowUpRecordMapper crmFollowUpRecordMapper;
@Resource
private CrmPermissionService permissionService;
@Resource
private CrmBusinessService businessService;
@Resource
private CrmClueService clueService;
@Resource
private CrmContactService contactService;
@Resource
private CrmContractService contractService;
@Resource
private CrmCustomerService customerService;
@Override
@CrmPermission(bizTypeValue = "#createReqVO.bizType", bizId = "#createReqVO.bizId", level = CrmPermissionLevelEnum.WRITE)
public Long createFollowUpRecord(CrmFollowUpRecordSaveReqVO createReqVO) {
// 创建更进记录
CrmFollowUpRecordDO followUpRecord = BeanUtils.toBean(createReqVO, CrmFollowUpRecordDO.class);
crmFollowUpRecordMapper.insert(followUpRecord);
// TODO @puhui999需要更新 bizId 对应的记录
// TODO @puhui999需要更新 businessIdscontactIds 对应的记录
LocalDateTime now = LocalDateTime.now();
// TODO @puhui999感觉可以这里基于 type 102 104 这种判断然后每个类型的调用封装一个小方法之后调用这些小方法再之后74-7680-82 也是等价的处理
// 2. 更新 bizId 对应的记录
updateBizTypeFollowUp(followUpRecord, now);
// 3.1 更新 contactIds 对应的记录
if (CollUtil.isNotEmpty(createReqVO.getContactIds())) {
contactService.updateContactFollowUpBatch(convertList(createReqVO.getContactIds(), contactId ->
new CrmUpdateFollowUpReqBO().setBizId(contactId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent())));
}
// 3.2 需要更新 businessIdscontactIds 对应的记录
if (CollUtil.isNotEmpty(createReqVO.getBusinessIds())) {
businessService.updateBusinessFollowUpBatch(convertList(createReqVO.getBusinessIds(), businessId ->
new CrmUpdateFollowUpReqBO().setBizId(businessId).setContactNextTime(followUpRecord.getNextTime())
.setContactLastTime(now).setContactLastContent(followUpRecord.getContent())));
}
return followUpRecord.getId();
}
@Override
public void updateFollowUpRecord(CrmFollowUpRecordSaveReqVO updateReqVO) {
// 校验存在
validateFollowUpRecordExists(updateReqVO.getId());
// 更新
CrmFollowUpRecordDO updateObj = BeanUtils.toBean(updateReqVO, CrmFollowUpRecordDO.class);
crmFollowUpRecordMapper.updateById(updateObj);
/**
* 执行更新
*
* @param followUpRecord 跟进记录
* @param now 跟进时间
*/
private void updateBizTypeFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
updateBusinessFollowUp(followUpRecord, now);
updateClueFollowUp(followUpRecord, now);
updateContactFollowUp(followUpRecord, now);
updateContractFollowUp(followUpRecord, now);
updateCustomerFollowUp(followUpRecord, now);
}
private void updateBusinessFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_BUSINESS.getType(), followUpRecord.getBizType())) {
return;
}
// 更新商机跟进信息
businessService.updateBusinessFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO()
.setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now)
.setContactLastContent(followUpRecord.getContent())));
}
private void updateClueFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_LEADS.getType(), followUpRecord.getBizType())) {
return;
}
// 更新线索跟进信息
clueService.updateClueFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now)
.setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()));
}
private void updateContactFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTACT.getType(), followUpRecord.getBizType())) {
return;
}
// 更新联系人跟进信息
contactService.updateContactFollowUpBatch(Collections.singletonList(new CrmUpdateFollowUpReqBO()
.setBizId(followUpRecord.getBizId()).setContactNextTime(followUpRecord.getNextTime()).setContactLastTime(now)
.setContactLastContent(followUpRecord.getContent())));
}
private void updateContractFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CONTRACT.getType(), followUpRecord.getBizType())) {
return;
}
// 更新合同跟进信息
contractService.updateContractFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now)
.setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()));
}
private void updateCustomerFollowUp(CrmFollowUpRecordDO followUpRecord, LocalDateTime now) {
if (ObjUtil.notEqual(CrmBizTypeEnum.CRM_CUSTOMER.getType(), followUpRecord.getBizType())) {
return;
}
// 更新客户跟进信息
customerService.updateCustomerFollowUp(new CrmUpdateFollowUpReqBO().setBizId(followUpRecord.getBizId()).setContactLastTime(now)
.setContactNextTime(followUpRecord.getNextTime()).setContactLastContent(followUpRecord.getContent()));
}
@Override
public void deleteFollowUpRecord(Long id) {
public void deleteFollowUpRecord(Long id, Long userId) {
// 校验存在
validateFollowUpRecordExists(id);
CrmFollowUpRecordDO followUpRecord = validateFollowUpRecordExists(id);
// 校验权限
List<CrmPermissionDO> permissionList = permissionService.getPermissionListByBiz(
followUpRecord.getBizType(), followUpRecord.getBizId());
boolean condition = anyMatch(permissionList, permission ->
ObjUtil.equal(permission.getUserId(), userId) && ObjUtil.equal(permission.getLevel(), CrmPermissionLevelEnum.OWNER.getLevel()));
if (!condition) {
throw exception(FOLLOW_UP_RECORD_DELETE_DENIED);
}
// 删除
crmFollowUpRecordMapper.deleteById(id);
}
private void validateFollowUpRecordExists(Long id) {
if (crmFollowUpRecordMapper.selectById(id) == null) {
private CrmFollowUpRecordDO validateFollowUpRecordExists(Long id) {
CrmFollowUpRecordDO followUpRecord = crmFollowUpRecordMapper.selectById(id);
if (followUpRecord == null) {
throw exception(FOLLOW_UP_RECORD_NOT_EXISTS);
}
return followUpRecord;
}
@Override
@ -62,7 +180,9 @@ public class CrmFollowUpRecordServiceImpl implements CrmFollowUpRecordService {
return crmFollowUpRecordMapper.selectById(id);
}
@Override
@CrmPermission(bizTypeValue = "#pageReqVO.bizType", bizId = "#pageReqVO.bizId", level = CrmPermissionLevelEnum.READ)
public PageResult<CrmFollowUpRecordDO> getFollowUpRecordPage(CrmFollowUpRecordPageReqVO pageReqVO) {
return crmFollowUpRecordMapper.selectPage(pageReqVO);
}

View File

@ -0,0 +1,36 @@
package cn.iocoder.yudao.module.crm.service.followup.bo;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 跟进信息 Update Req BO
*
* @author HUIHUI
*/
@Data
public class CrmUpdateFollowUpReqBO {
@Schema(description = "数据编号", example = "3167")
@NotNull(message = "数据编号不能为空")
private Long bizId;
@Schema(description = "最后跟进时间")
@DiffLogField(name = "最后跟进时间")
@NotNull(message = "最后跟进时间不能为空")
private LocalDateTime contactLastTime;
@Schema(description = "下次联系时间")
@DiffLogField(name = "下次联系时间")
private LocalDateTime contactNextTime;
@Schema(description = "最后更进内容")
@DiffLogField(name = "最后更进内容")
@NotNull(message = "最后更进内容不能为空")
private String contactLastContent;
}

View File

@ -2,16 +2,15 @@ package cn.iocoder.yudao.module.product.service.category;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryCreateReqVO;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryListReqVO;
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategorySaveReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper;
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 java.util.List;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
@ -21,7 +20,8 @@ import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
import static cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO.PARENT_ID_NULL;
import static cn.iocoder.yudao.module.product.enums.ErrorCodeConstants.CATEGORY_NOT_EXISTS;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
* {@link ProductCategoryServiceImpl} 的单元测试类
@ -41,22 +41,22 @@ public class ProductCategoryServiceImplTest extends BaseDbUnitTest {
@Test
public void testCreateCategory_success() {
// 准备参数
ProductCategoryCreateReqVO reqVO = randomPojo(ProductCategoryCreateReqVO.class);
//ProductCategoryCreateReqVO reqVO = randomPojo(ProductCategoryCreateReqVO.class);
// mock 父类
ProductCategoryDO parentProductCategory = randomPojo(ProductCategoryDO.class, o -> {
reqVO.setParentId(o.getId());
o.setParentId(PARENT_ID_NULL);
});
productCategoryMapper.insert(parentProductCategory);
// 调用
Long categoryId = productCategoryService.createCategory(reqVO);
// 断言
assertNotNull(categoryId);
// 校验记录的属性是否正确
ProductCategoryDO category = productCategoryMapper.selectById(categoryId);
assertPojoEquals(reqVO, category);
//ProductCategoryDO parentProductCategory = randomPojo(ProductCategoryDO.class, o -> {
// reqVO.setParentId(o.getId());
// o.setParentId(PARENT_ID_NULL);
//});
//productCategoryMapper.insert(parentProductCategory);
//
//// 调用
//Long categoryId = productCategoryService.createCategory(reqVO);
//// 断言
//assertNotNull(categoryId);
//// 校验记录的属性是否正确
//ProductCategoryDO category = productCategoryMapper.selectById(categoryId);
//assertPojoEquals(reqVO, category);
}
@Test

View File

@ -3,26 +3,25 @@ package cn.iocoder.yudao.module.product.service.comment;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentPageReqVO;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentReplyReqVO;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentRespVO;
import cn.iocoder.yudao.module.product.controller.admin.comment.vo.ProductCommentUpdateVisibleReqVO;
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentPageReqVO;
import cn.iocoder.yudao.module.product.controller.app.comment.vo.AppCommentStatisticsRespVO;
import cn.iocoder.yudao.module.product.convert.comment.ProductCommentConvert;
import cn.iocoder.yudao.module.product.dal.dataobject.comment.ProductCommentDO;
import cn.iocoder.yudao.module.product.dal.mysql.comment.ProductCommentMapper;
import cn.iocoder.yudao.module.product.enums.comment.ProductCommentScoresEnum;
import cn.iocoder.yudao.module.product.service.sku.ProductSkuService;
import cn.iocoder.yudao.module.product.service.spu.ProductSpuService;
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 org.springframework.context.annotation.Lazy;
import jakarta.annotation.Resource;
import java.time.LocalDateTime;
import java.util.Date;
@ -129,7 +128,8 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest {
productCommentPageReqVO.setReplyStatus(Boolean.TRUE);
PageResult<ProductCommentDO> commentPage = productCommentService.getCommentPage(productCommentPageReqVO);
PageResult<ProductCommentRespVO> result = ProductCommentConvert.INSTANCE.convertPage(productCommentMapper.selectPage(productCommentPageReqVO));
PageResult<ProductCommentRespVO> result = BeanUtils.toBean(productCommentMapper.selectPage(productCommentPageReqVO),
ProductCommentRespVO.class);
assertEquals(result.getTotal(), commentPage.getTotal());
PageResult<ProductCommentDO> all = productCommentService.getCommentPage(new ProductCommentPageReqVO());
@ -148,10 +148,10 @@ public class ProductCommentServiceImplTest extends BaseDbUnitTest {
assertEquals(2, result3.getTotal());
// 测试分页 tab count
AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE);
assertEquals(4, tabsCount.getGoodCount());
assertEquals(2, tabsCount.getMediocreCount());
assertEquals(0, tabsCount.getNegativeCount());
//AppCommentStatisticsRespVO tabsCount = productCommentService.getCommentStatistics(spuId, Boolean.TRUE);
//assertEquals(4, tabsCount.getGoodCount());
//assertEquals(2, tabsCount.getMediocreCount());
//assertEquals(0, tabsCount.getNegativeCount());
}

View File

@ -1,61 +0,0 @@
package cn.iocoder.yudao.module.promotion.enums.decorate;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 页面组件枚举
*
* @author jason
*/
@Getter
@AllArgsConstructor
@SuppressWarnings("JavadocLinkAsPlainText")
public enum DecorateComponentEnum {
/**
* 格式[{
* "name": "标题"
* "picUrl": "https://www.iocoder.cn/xxx.png",
* "url": "/pages/users/index"
* }]
*
* 最多 10
*/
MENU("menu", "菜单"),
/**
* 格式[{
* "name": "标题"
* "url": "/pages/users/index"
* }]
*/
ROLLING_NEWS("scrolling-news", "滚动新闻"),
/**
* 格式[{
* "picUrl": "https://www.iocoder.cn/xxx.png",
* "url": "/pages/users/index"
* }]
*/
SLIDE_SHOW("slide-show", "轮播图"),
/**
* 格式[{
* "name": "标题"
* "type": "类型", // besthotnewbenefitgood
* "tag": "标签" // 例如说多买多省
* }]
*
* 最多 4
*/
PRODUCT_RECOMMEND("product-recommend", "商品推荐");
/**
* 页面组件代码
*/
private final String code;
/**
* 页面组件说明
*/
private final String desc;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.promotion.enums.decorate;
package cn.iocoder.yudao.module.promotion.enums.diy;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import lombok.AllArgsConstructor;
@ -13,13 +13,13 @@ import java.util.Arrays;
*/
@AllArgsConstructor
@Getter
public enum DecoratePageEnum implements IntArrayValuable {
public enum DiyPageEnum implements IntArrayValuable {
INDEX(1, "首页"),
MY(2, "我的"),
;
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DecoratePageEnum::getPage).toArray();
private static final int[] ARRAYS = Arrays.stream(values()).mapToInt(DiyPageEnum::getPage).toArray();
/**
* 页面编号

View File

@ -43,7 +43,8 @@ public class CombinationRecordController {
@GetMapping("/page")
@Operation(summary = "获得拼团记录分页")
@PreAuthorize("@ss.hasPermission('promotion:combination-record:query')")
public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getBargainRecordPage(@Valid CombinationRecordReqPageVO pageVO) {
public CommonResult<PageResult<CombinationRecordPageItemRespVO>> getCombinationRecordPage(
@Valid CombinationRecordReqPageVO pageVO) {
PageResult<CombinationRecordDO> recordPage = combinationRecordService.getCombinationRecordPage(pageVO);
// 拼接数据
List<CombinationActivityDO> activities = combinationActivityService.getCombinationActivityListByIds(

View File

@ -1,18 +0,0 @@
### /promotion/decorate/save 保存页面装修组件
POST {{baseUrl}}/promotion/decorate/save
Content-Type: application/json
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}
{
"page": 1,
"code": "slide-show",
"status": 0,
"value": "null"
}
### /promotion/decorate/list 获取指定页面的组件列表
GET {{baseUrl}}/promotion/decorate/list?page=1
Content-Type: application/json
Authorization: Bearer {{token}}
tenant-id: {{adminTenentId}}

View File

@ -1,50 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.admin.decorate;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
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.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 店铺页面装修")
@RestController
@RequestMapping("/promotion/decorate")
@Validated
public class DecorateComponentController {
@Resource
private DecorateComponentService decorateComponentService;
@PostMapping("/save")
@Operation(summary = "保存页面装修组件")
@PreAuthorize("@ss.hasPermission('promotion:decorate:save')")
public CommonResult<Boolean> saveDecorateComponent(@Valid @RequestBody DecorateComponentSaveReqVO reqVO) {
decorateComponentService.saveDecorateComponent(reqVO);
return success(true);
}
@GetMapping("/list")
@Operation(summary = "获取指定页面的组件列表")
@Parameter(name = "page", description = "页面 id", required = true)
@PreAuthorize("@ss.hasPermission('promotion:decorate:query')")
public CommonResult<List<DecorateComponentRespVO>> getDecorateComponentListByPage(
@RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) {
return success(DecorateComponentConvert.INSTANCE.convertList02(
decorateComponentService.getDecorateComponentListByPage(page, null)));
}
}

View File

@ -1,19 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 页面装修 Resp VO")
@Data
public class DecorateComponentRespVO {
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
private String code;
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
private String value;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@Schema(description = "管理后台 - 页面装修的保存 Request VO ")
@Data
public class DecorateComponentSaveReqVO {
@Schema(description = "页面 id ", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "页面 id 不能为空")
@InEnum(DecoratePageEnum.class)
private Integer page;
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
@NotEmpty(message = "组件编码不能为空")
private String code;
@Schema(description = "组件对应值, json 字符串, 含内容配置,具体数据", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "组件值为空")
private String value;
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer status;
}

View File

@ -1,43 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.app.decorate;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.validation.InEnum;
import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO;
import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import cn.iocoder.yudao.module.promotion.service.decorate.DecorateComponentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
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 jakarta.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "用户 APP - 店铺装修")
@RestController
@RequestMapping("/promotion/decorate")
@Validated
@Deprecated // 废弃
public class AppDecorateController {
@Resource
private DecorateComponentService decorateComponentService;
@GetMapping("/list")
@Operation(summary = "获取指定页面的组件列表")
@Parameter(name = "page", description = "页面编号", required = true)
public CommonResult<List<AppDecorateComponentRespVO>> getDecorateComponentListByPage(
@RequestParam("page") @InEnum(DecoratePageEnum.class) Integer page) {
return success(DecorateComponentConvert.INSTANCE.convertList(
decorateComponentService.getDecorateComponentListByPage(page, CommonStatusEnum.ENABLE.getStatus())));
}
}

View File

@ -1,16 +0,0 @@
package cn.iocoder.yudao.module.promotion.controller.app.decorate.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 App - 页面组件 Resp VO")
@Data
public class AppDecorateComponentRespVO {
@Schema(description = "组件编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "nav-menu")
private String code;
@Schema(description = "组件的内容配置项", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "TODO")
private String value;
}

View File

@ -5,19 +5,19 @@ import cn.iocoder.yudao.module.promotion.controller.app.diy.vo.AppDiyTemplatePro
import cn.iocoder.yudao.module.promotion.convert.diy.DiyTemplateConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyPageDO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.diy.DiyTemplateDO;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import cn.iocoder.yudao.module.promotion.enums.diy.DiyPageEnum;
import cn.iocoder.yudao.module.promotion.service.diy.DiyPageService;
import cn.iocoder.yudao.module.promotion.service.diy.DiyTemplateService;
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 jakarta.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -56,8 +56,8 @@ public class AppDiyTemplateController {
}
// 查询模板下的页面
List<DiyPageDO> pages = diyPageService.getDiyPageByTemplateId(diyTemplate.getId());
String home = findFirst(pages, page -> DecoratePageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty);
String user = findFirst(pages, page -> DecoratePageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty);
String home = findFirst(pages, page -> DiyPageEnum.INDEX.getName().equals(page.getName()), DiyPageDO::getProperty);
String user = findFirst(pages, page -> DiyPageEnum.MY.getName().equals(page.getName()), DiyPageDO::getProperty);
// 拼接返回
return DiyTemplateConvert.INSTANCE.convertPropertyVo2(diyTemplate, home, user);
}

View File

@ -1,23 +0,0 @@
package cn.iocoder.yudao.module.promotion.convert.decorate;
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentRespVO;
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
import cn.iocoder.yudao.module.promotion.controller.app.decorate.vo.AppDecorateComponentRespVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper
public interface DecorateComponentConvert {
DecorateComponentConvert INSTANCE = Mappers.getMapper(DecorateComponentConvert.class);
List<DecorateComponentRespVO> convertList02(List<DecorateComponentDO> list);
DecorateComponentDO convert(DecorateComponentSaveReqVO bean);
List<AppDecorateComponentRespVO> convertList(List<DecorateComponentDO> list);
}

View File

@ -63,7 +63,7 @@ public class BargainRecordDO extends BaseDO {
*
* 砍价成功的条件是2 1
* 1. 砍价到 {@link BargainActivityDO#getBargainMinPrice()} 底价
* 2. 助力人数到达 {@link BargainActivityDO#getUserSize()}
* 2. 助力人数到达 {@link BargainActivityDO#getHelpMaxCount()}
*
* 枚举 {@link BargainRecordStatusEnum}
*/

View File

@ -1,52 +0,0 @@
package cn.iocoder.yudao.module.promotion.dal.dataobject.decorate;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecorateComponentEnum;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
/**
* 页面装修组件 DO, 一个页面由多个组件构成
*
* @author jason
*/
@TableName(value ="promotion_decorate_component")
@KeySequence("promotion_decorate_component_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
public class DecorateComponentDO extends BaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 所属页面 id
*
* 枚举 {@link DecoratePageEnum#getPage()}
*/
private Integer page;
/**
* 组件编码
* 枚举 {@link DecorateComponentEnum#getCode()}
*/
private String code;
/**
* 组件值json 格式包含配置和数据
*/
private String value;
/**
* 状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@ -1,28 +0,0 @@
package cn.iocoder.yudao.module.promotion.dal.mysql.decorate;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface DecorateComponentMapper extends BaseMapperX<DecorateComponentDO> {
default List<DecorateComponentDO> selectListByPageAndStatus(Integer page, Integer status) {
return selectList(new LambdaQueryWrapperX<DecorateComponentDO>()
.eq(DecorateComponentDO::getPage, page)
.eqIfPresent(DecorateComponentDO::getStatus, status));
}
default DecorateComponentDO selectByPageAndCode(Integer page, String code) {
return selectOne(DecorateComponentDO::getPage, page,
DecorateComponentDO::getCode, code);
}
}

View File

@ -1,31 +0,0 @@
package cn.iocoder.yudao.module.promotion.service.decorate;
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
import cn.iocoder.yudao.module.promotion.enums.decorate.DecoratePageEnum;
import java.util.List;
/**
* 装修组件 Service 接口
*
* @author jason
*/
public interface DecorateComponentService {
/**
* 保存页面的组件信息
*
* @param reqVO 请求 VO
*/
void saveDecorateComponent(DecorateComponentSaveReqVO reqVO);
/**
* 根据页面 id获取页面的组件信息
*
* @param page 页面编号 {@link DecoratePageEnum#getPage()}
* @param status 状态
*/
List<DecorateComponentDO> getDecorateComponentListByPage(Integer page, Integer status);
}

View File

@ -1,40 +0,0 @@
package cn.iocoder.yudao.module.promotion.service.decorate;
import cn.iocoder.yudao.module.promotion.controller.admin.decorate.vo.DecorateComponentSaveReqVO;
import cn.iocoder.yudao.module.promotion.convert.decorate.DecorateComponentConvert;
import cn.iocoder.yudao.module.promotion.dal.dataobject.decorate.DecorateComponentDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import java.util.List;
/**
* 装修组件 Service 实现
*
* @author jason
*/
@Service
public class DecorateComponentServiceImpl implements DecorateComponentService {
@Resource
private DecorateComponentMapper decorateComponentMapper;
@Override
public void saveDecorateComponent(DecorateComponentSaveReqVO reqVO) {
// 1. 如果存在则进行更新
DecorateComponentDO dbComponent = decorateComponentMapper.selectByPageAndCode(reqVO.getPage(), reqVO.getCode());
if (dbComponent != null) {
decorateComponentMapper.updateById(DecorateComponentConvert.INSTANCE.convert(reqVO).setId(dbComponent.getId()));
return;
}
// 2. 不存在则进行新增
decorateComponentMapper.insert(DecorateComponentConvert.INSTANCE.convert(reqVO));
}
@Override
public List<DecorateComponentDO> getDecorateComponentListByPage(Integer page, Integer status) {
return decorateComponentMapper.selectListByPageAndStatus(page, status);
}
}

View File

@ -1,36 +0,0 @@
package cn.iocoder.yudao.module.promotion.service.decorate;
import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
import cn.iocoder.yudao.module.promotion.dal.mysql.decorate.DecorateComponentMapper;
import org.junit.jupiter.api.BeforeEach;
import org.mockito.InjectMocks;
import org.mockito.Mock;
// TODO @芋艿后续 review
/**
* @author jason
*/
public class DecorateComponentServiceImplTest extends BaseMockitoUnitTest {
@InjectMocks
private DecorateComponentServiceImpl decoratePageService;
@Mock
private DecorateComponentMapper decorateComponentMapper;
@BeforeEach
public void init(){
}
// @Test
// void testResp(){
// List<DecorateComponentDO> list = new ArrayList<>(1);
// DecorateComponentDO decorateDO = new DecorateComponentDO()
// .setPage(INDEX.getPage()).setValue("")
// .setCode(ROLLING_NEWS.getCode()).setId(1L);
// list.add(decorateDO);
// //mock 方法
// Mockito.when(decorateComponentMapper.selectListByPageAndStatus(eq(1))).thenReturn(list);
// }
}

View File

@ -1,70 +0,0 @@
package cn.iocoder.yudao.module.statistics.dal.dataobject.member;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.time.LocalDateTime;
/**
* 会员统计 DO
* <p>
* 以天为维度统计全部的数据
*
* @author 芋道源码
*/
@TableName("member_statistics")
@KeySequence("member_statistics_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class MemberStatisticsDO extends BaseDO {
/**
* 编号主键自增
*/
@TableId
private Long id;
/**
* 统计日期
*/
private LocalDateTime time;
/**
* 注册用户数量
*/
private Integer userRegisterCount;
/**
* 访问用户数量UV
*/
private Integer userVisitCount;
/**
* 访问页面数量PV
*/
private Integer pageVisitCount;
/**
* 充值用户数量
*/
private Integer rechargeUserCount;
/**
* 创建订单用户数
*/
private Integer orderCreateUserCount;
/**
* 支付订单用户数
*/
private Integer orderPayUserCount;
/**
* 总支付金额单位
*/
private Integer orderPayPrice;
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.trade.service.aftersale;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
@ -368,7 +369,8 @@ public class AfterSaleServiceImpl implements AfterSaleService {
@Override
public void afterCommit() {
// 创建退款单
PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties);
PayRefundCreateReqDTO createReqDTO = AfterSaleConvert.INSTANCE.convert(userIp, afterSale, tradeOrderProperties)
.setReason(StrUtil.format("退款【{}】", afterSale.getSpuName()));
Long payRefundId = payRefundApi.createRefund(createReqDTO);
// 更新售后单的退款单号
tradeAfterSaleMapper.updateById(new AfterSaleDO().setId(afterSale.getId()).setPayRefundId(payRefundId));

View File

@ -64,7 +64,6 @@ public interface MemberGroupService {
*/
PageResult<MemberGroupDO> getGroupPage(MemberGroupPageReqVO pageReqVO);
/**
* 获得指定状态的用户分组列表
*
@ -73,7 +72,6 @@ public interface MemberGroupService {
*/
List<MemberGroupDO> getGroupListByStatus(Integer status);
/**
* 获得开启状态的用户分组列表
*

View File

@ -1,6 +1,5 @@
package cn.iocoder.yudao.module.member.service.point;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.member.controller.admin.point.vo.recrod.MemberPointRecordPageReqVO;
import cn.iocoder.yudao.module.member.controller.app.point.vo.AppMemberPointRecordPageReqVO;

View File

@ -10,6 +10,7 @@ import lombok.Data;
import java.time.LocalDateTime;
// TODO 芋艿需要详细 review
/**
* 示例转账订单
*

View File

@ -16,6 +16,7 @@ import lombok.Data;
import java.time.LocalDateTime;
import java.util.Map;
// TODO 芋艿需要详细 review
/**
* 转账单 DO
*

View File

@ -2,11 +2,11 @@ package cn.iocoder.yudao.module.system.controller.admin.ip;
import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.ip.core.Area;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.framework.ip.core.utils.IPUtils;
import cn.iocoder.yudao.module.system.controller.admin.ip.vo.AreaNodeRespVO;
import cn.iocoder.yudao.module.system.convert.ip.AreaConvert;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
@ -31,7 +31,7 @@ public class AreaController {
public CommonResult<List<AreaNodeRespVO>> getAreaTree() {
Area area = AreaUtils.getArea(Area.ID_CHINA);
Assert.notNull(area, "获取不到中国");
return success(AreaConvert.INSTANCE.convertList(area.getChildren()));
return success(BeanUtils.toBean(area.getChildren(), AreaNodeRespVO.class));
}
@GetMapping("/get-by-ip")

Some files were not shown because too many files have changed in this diff Show More