Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-staff
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 61b22715
authored
Jan 28, 2026
by
DESKTOP-3F024UL\tianming
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提成计算相关-问题修复
1 parent
5938dd5c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
2585 additions
and
16 deletions
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceCalService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceDetailService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffProductPerformanceService.java
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceCalMapper.xml
rpc-dj-staff/src/main/resources/design/260210_DATA_GENERATION_PLAN.md
rpc-dj-staff/src/main/resources/design/260210_insert_conditions.sql
rpc-dj-staff/src/main/resources/design/STAFF_PERFORMANCE_ANALYSIS.md
rpc-dj-staff/src/main/resources/design/TEST_DATA_INIT.md
rpc-dj-staff/src/main/resources/design/TEST_PLAN.md
rpc-dj-staff/src/main/resources/design/TEST_PLAN_COMPLETE.md
rpc-dj-staff/src/main/resources/design/TEST_PLAN_SQL.md
rpc-dj-staff/src/main/resources/design/generate_conditions.py
rpc-dj-staff/src/main/resources/design/init_test_data_202512.sql
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceCalService.java
View file @
61b2271
...
@@ -65,6 +65,7 @@ public class StaffPerformanceCalService {
...
@@ -65,6 +65,7 @@ public class StaffPerformanceCalService {
@Autowired
@Autowired
private
MerchantPerformanceProductDefineService
merchantPerformanceProductDefineService
;
private
MerchantPerformanceProductDefineService
merchantPerformanceProductDefineService
;
/**
/**
* 计算员工提成
* 计算员工提成
*
*
...
@@ -536,10 +537,8 @@ public class StaffPerformanceCalService {
...
@@ -536,10 +537,8 @@ public class StaffPerformanceCalService {
commission
=
detailDTO
.
getCommissionTypeValue
();
commission
=
detailDTO
.
getCommissionTypeValue
();
}
else
if
(
Objects
.
equals
(
detailDTO
.
getCommissionType
(),
CommissionTypeEnum
.
BL
.
getCode
()))
{
}
else
if
(
Objects
.
equals
(
detailDTO
.
getCommissionType
(),
CommissionTypeEnum
.
BL
.
getCode
()))
{
// 比例:基数 * 比例
// 比例:基数 * 比例
if
(
detailDTO
.
getCommissionTypeValue
()
!=
null
)
{
commission
=
detailDTO
.
getGmvOutput
()
commission
=
detailDTO
.
getGmvOutput
()
.
multiply
(
detailDTO
.
getCommissionTypeValue
());
.
multiply
(
detailDTO
.
getCommissionTypeValue
());
}
}
}
// 加上额外奖惩金额(扣减或奖励)
// 加上额外奖惩金额(扣减或奖励)
if
(
commission
!=
null
&&
detailDTO
.
getExtraPerformanceAmount
()
!=
null
)
{
if
(
commission
!=
null
&&
detailDTO
.
getExtraPerformanceAmount
()
!=
null
)
{
...
@@ -562,8 +561,10 @@ public class StaffPerformanceCalService {
...
@@ -562,8 +561,10 @@ public class StaffPerformanceCalService {
return
;
return
;
}
}
if
(!
Objects
.
equals
(
paramConfig
.
getAssessmentFactor
(),
if
(!
Objects
.
equals
(
paramConfig
.
getAssessmentFactor
(),
AssessmentFactorEnum
.
PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE
.
getCode
()))
{
AssessmentFactorEnum
.
PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE
.
getCode
())
log
.
info
(
"非个人单品渗透率考核因子,不处理条件, assessmentFactor:{}"
,
paramConfig
.
getAssessmentFactor
());
&&
!
Objects
.
equals
(
paramConfig
.
getAssessmentFactor
(),
AssessmentFactorEnum
.
PERSONAL_CUSTOMER_PENETRATION_RATE
.
getCode
()))
{
log
.
info
(
"非个人单品渗透率/个人客户渗透率考核因子,不处理条件, assessmentFactor:{}"
,
paramConfig
.
getAssessmentFactor
());
return
;
return
;
}
}
String
currentParamsJson
=
detailDTO
.
getParamsJson
();
String
currentParamsJson
=
detailDTO
.
getParamsJson
();
...
@@ -618,8 +619,8 @@ public class StaffPerformanceCalService {
...
@@ -618,8 +619,8 @@ public class StaffPerformanceCalService {
}
}
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
"条件计算异常: conditionType={}, conditionId={}"
,
condition
.
getConditionType
(),
log
.
error
(
"条件计算异常: conditionType={}, conditionId={}"
,
condition
.
getConditionType
(),
condition
.
getId
(),
condition
.
getId
(),
e
);
e
);
throw
e
;
throw
e
;
}
}
executionLog
.
put
(
"result"
,
resultLog
);
executionLog
.
put
(
"result"
,
resultLog
);
...
@@ -648,8 +649,10 @@ public class StaffPerformanceCalService {
...
@@ -648,8 +649,10 @@ public class StaffPerformanceCalService {
JSONObject
resultLog
,
JSONObject
resultLog
,
boolean
skipPenetrationRateCondition
)
{
boolean
skipPenetrationRateCondition
)
{
// 1:渗透率限制
// 1:渗透率限制
if
(!
AssessmentFactorEnum
.
PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE
.
getCode
()
if
(!
Objects
.
equals
(
paramConfig
.
getAssessmentFactor
(),
.
equals
(
paramConfig
.
getAssessmentFactor
()))
{
AssessmentFactorEnum
.
PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE
.
getCode
())
&&
!
Objects
.
equals
(
paramConfig
.
getAssessmentFactor
(),
AssessmentFactorEnum
.
PERSONAL_CUSTOMER_PENETRATION_RATE
.
getCode
()))
{
throw
new
RpcServiceException
(
"渗透率限制条件仅适用于个人单品渗透率考核因子"
);
throw
new
RpcServiceException
(
"渗透率限制条件仅适用于个人单品渗透率考核因子"
);
}
}
// 2:跳过渗透率限制条件
// 2:跳过渗透率限制条件
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceDetailService.java
View file @
61b2271
...
@@ -53,13 +53,14 @@ public class StaffPerformanceDetailService {
...
@@ -53,13 +53,14 @@ public class StaffPerformanceDetailService {
}
}
// 1. 逻辑删除旧数据
// 1. 逻辑删除旧数据
StaffPerformanceDetailDTO
firstDTO
=
performanceDetailDTOS
.
get
(
0
);
StaffPerformanceDetail
query
=
StaffPerformanceDetail
.
builder
()
StaffPerformanceDetail
query
=
StaffPerformanceDetail
.
builder
()
.
staffPhone
(
performanceDetailDTOS
.
get
(
0
)
.
getStaffPhone
())
.
staffPhone
(
firstDTO
.
getStaffPhone
())
.
merchantId
(
config
.
getMerchantId
())
.
merchantId
(
firstDTO
.
getMerchantId
())
.
businessType
(
config
.
getBusinessType
())
.
businessType
(
firstDTO
.
getBusinessType
())
.
brandId
(
config
.
getBrandId
())
.
brandId
(
firstDTO
.
getBrandId
())
.
childBrandId
(
config
.
getChildBrandId
())
.
childBrandId
(
firstDTO
.
getChildBrandId
())
.
month
(
config
.
getEffective
Month
())
.
month
(
firstDTO
.
get
Month
())
.
updatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
)
.
updatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
)
.
build
();
.
build
();
int
updatedRecord
=
staffPerformanceDetailMapper
.
removePerformanceDetail
(
query
);
int
updatedRecord
=
staffPerformanceDetailMapper
.
removePerformanceDetail
(
query
);
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffProductPerformanceService.java
View file @
61b2271
...
@@ -115,6 +115,7 @@ public class StaffProductPerformanceService {
...
@@ -115,6 +115,7 @@ public class StaffProductPerformanceService {
}
}
// 品类分组
// 品类分组
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupedMap
=
performanceDetailDTOS
.
stream
()
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupedMap
=
performanceDetailDTOS
.
stream
()
.
filter
(
o
->
o
!=
null
&&
o
.
getCommissionType
()
!=
null
&&
!
Objects
.
equals
(
o
.
getCommissionType
(),
CommissionTypeEnum
.
XS
.
getCode
()))
.
collect
(
Collectors
.
groupingBy
(
this
::
generateGroupKey
));
.
collect
(
Collectors
.
groupingBy
(
this
::
generateGroupKey
));
List
<
StaffProductPerformance
>
insertList
=
new
ArrayList
<>();
List
<
StaffProductPerformance
>
insertList
=
new
ArrayList
<>();
Date
now
=
new
Date
();
Date
now
=
new
Date
();
...
...
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceCalMapper.xml
View file @
61b2271
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
LEFT JOIN dj_car_life_goods_sub_order dclgso ON dclgo.order_code = dclgso.order_code
LEFT JOIN dj_car_life_goods_sub_order dclgso ON dclgo.order_code = dclgso.order_code
AND dclgso.deleted_flag = 'N'
AND dclgso.deleted_flag = 'N'
<where>
<where>
dclsi.deleted_flag = 'N'
<if
test=
"staffPhone != null and staffPhone != ''"
>
<if
test=
"staffPhone != null and staffPhone != ''"
>
AND dclsi.phone_number = #{staffPhone}
AND dclsi.phone_number = #{staffPhone}
</if>
</if>
...
...
rpc-dj-staff/src/main/resources/design/260210_DATA_GENERATION_PLAN.md
0 → 100644
View file @
61b2271
# 数据生成方案:门店工资绩效参数配置条件数据
## 目标
为
`dj_car_life_performance_param_config`
表中
`created_by = 'caiym_test_260123'`
的记录(id范围 4-75)生成对应的条件配置数据(
`dj_car_life_performance_param_config_condition`
)。
## 策略
使用 Python 脚本生成 SQL 语句,确保逻辑的灵活性和随机性。
##生成逻辑详情
### 1. 基础字段
-
**`performance_param_config_id`**
: 遍历现有配置ID (4-75)。
-
**`created_by`, `updated_by`**
: 'caiym_test_260123'
-
**`created_date`, `updated_date`**
: NOW()
-
**`deleted_flag`**
: 'N'
-
**`condition_type`**
: 为每个 config_id 随机分配 1, 2, 3, 4 中的一种。
### 2. 不同条件类型的处理规则
| 字段 | Type 1: 渗透率限制 | Type 2: 订单数不足扣减 | Type 3: 整体指标达成奖励 | Type 4: 订单数剔除/包含 |
| :------------------------------------ | :-------------------------- | :-------------------------- | :----------------------- | :---------------------- |
|
**需要商品信息**
|
**是**
(随机生成) | 否 (NULL) | 否 (NULL) |
**是**
(随机生成) |
|
**`condition_assessment_factors`**
|
`3`
|
`0`
(默认) |
`0`
(默认) |
`0`
(默认) |
|
**`condition_start_value`**
|
`0.00`
|
`0.00`
|
`0.00`
|
`0.00`
|
|
**`condition_end_value`**
| 随机
**1-10**
(保留2位小数) | 随机
**1-10**
(保留2位小数) |
`0.00`
|
`0.00`
|
|
**`condition_commission_type`**
|
`''`
(默认为空字符串) |
`''`
(默认为空字符串) |
**`DDJE`**
|
`''`
(默认为空字符串) |
|
**`condition_commission_type_value`**
|
`0.00`
|
`0.00`
| 随机
**100-1000**
|
`0.00`
|
|
**`condition_commission_base`**
|
`'GMV'`
(默认) |
`'GMV'`
(默认) |
`'GMV'`
(默认) |
`'GMV'`
(默认) |
> **注意**: 文档中未明确指定的必填字段 (`condition_commission_base`, `condition_commission_type` 对于非 Type 3) 将使用默认值 `'GMV'` 和空字符串 `''` 以满足非空约束。
### 3. 商品信息生成规则 (适用于 Type 1 和 Type 4)
随机选择以下 4 种类型 (-1, 0, 1, 2) 之一,并填充对应字段:
#### Type -1: 全部商品
-
`condition_goods_config_type`
= -1
-
其他商品字段均为 NULL (或 -1,视表结构默认值而定,通常类型为 -1 时,ID 字段可存 -1 或 NULL,这里统一使用 NULL 以保持整洁,若报错则改为 -1)
#### Type 0: 商品分类 (随机选择组合 1-5)
-
`condition_goods_config_type`
= 0
-
**组合 1**
:
`goods_type`
=146,
`secondary`
=-1,
`third`
=-1
-
**组合 2**
:
`goods_type`
=146,
`secondary`
=147,
`third`
=148
-
**组合 3**
:
`goods_type`
=146,
`secondary`
=147,
`third`
=-1
-
**组合 4**
:
`goods_type`
=102,
`secondary`
=-1,
`third`
=-1
-
**组合 5**
:
`goods_type`
=114,
`secondary`
=149,
`third`
=150
*注: 名称字段将填充对应的 "权益一级类目" 等文本。*
#### Type 1: 圈定产品 (随机选择 1-2)
-
`condition_goods_config_type`
= 1
-
**产品 1**
:
`define_id`
=32,
`name`
="圈定产品1"
-
**产品 2**
:
`define_id`
=33,
`name`
="圈定产品2"
#### Type 2: 圈定套餐
-
`condition_goods_config_type`
= 2
-
**套餐**
:
`define_id`
=34,
`name`
="圈定套餐3"
## 执行步骤
1.
确认当前
`dj_car_life_performance_param_config`
中
`created_by = 'caiym_test_260123'`
的 ID 列表。
2.
编写 Python 脚本
`generate_conditions.py`
生成 SQL 文件。
3.
输出 SQL 文件路径:
`src/main/resources/design/260210_insert_conditions.sql`
。
rpc-dj-staff/src/main/resources/design/260210_insert_conditions.sql
0 → 100644
View file @
61b2271
INSERT
INTO
dj_car_life_performance_param_config_condition
(
performance_param_config_id
,
condition_type
,
condition_goods_config_type
,
condition_goods_type
,
condition_goods_type_name
,
condition_secondary_goods_type
,
condition_secondary_goods_type_name
,
condition_third_level_goods_type
,
condition_third_level_goods_type_name
,
condition_product_define_id
,
condition_product_define_name
,
condition_assessment_factors
,
condition_start_value
,
condition_end_value
,
condition_commission_base
,
condition_commission_type
,
condition_commission_type_value
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
13
,
3
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'0'
,
0
.
0
,
0
.
0
,
'GMV'
,
'DDJE'
,
762
.
13
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'N'
),
(
14
,
1
,
-
1
,
-
1
,
''
,
-
1
,
''
,
-
1
,
''
,
NULL
,
''
,
'3'
,
0
.
0
,
1
.
55
,
'GMV'
,
''
,
0
.
0
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'N'
),
(
15
,
4
,
2
,
NULL
,
''
,
NULL
,
''
,
NULL
,
''
,
34
,
'圈定套餐3'
,
'0'
,
0
.
0
,
0
.
0
,
'GMV'
,
''
,
0
.
0
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'N'
),
(
49
,
4
,
2
,
NULL
,
''
,
NULL
,
''
,
NULL
,
''
,
34
,
'圈定套餐3'
,
'0'
,
0
.
0
,
0
.
0
,
'GMV'
,
''
,
0
.
0
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'N'
),
(
50
,
2
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'0'
,
0
.
0
,
1
.
04
,
'GMV'
,
''
,
0
.
0
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'N'
),
(
51
,
2
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'0'
,
0
.
0
,
9
.
94
,
'GMV'
,
''
,
0
.
0
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'caiym_test_260123'
,
'2026-01-27 17:55:29'
,
'N'
);
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/resources/design/STAFF_PERFORMANCE_ANALYSIS.md
0 → 100644
View file @
61b2271
# 提成计算模块:技术设计与逻辑分析文档
> **文档说明**:本文档基于 `StaffPerformanceCalService.java` 源码逆向分析生成,旨在揭示现有代码的核心逻辑、数据流向及潜在风险,作为测试与重构的基准参考。
## 1. 核心逻辑全景图 (High-Level Summary)
### 1.1 核心功能
该模块负责计算员工在特定月份的绩效提成。它基于员工的历史订单数据和日报数据(触客数、引荐数),按照预设的复杂商户规则(如阶梯提成、渗透率考核、降档机制、扣款规则等),计算出精确的提成金额,并进行多维度的结果汇总与持久化存储。
### 1.2 关键数据流 (Data Flow)
*
**输入 (Inputs)**
:
*
**核心参数**
:
`staffPhone`
(员工手机号),
`month`
(考评月份, 格式 yyyy-MM).
*
**依赖数据源**
:
*
`PerformanceConfig`
(商户提成规则配置).
*
`StaffPerformanceSubOrder`
(订单明细,含金额、状态、车型等).
*
`DailyReport`
(日报数据,含触客数).
*
`EffectiveReferralReview`
(有效引荐数).
*
`MerchantPerformanceProductDefine`
(圈定商品/套系定义).
*
**输出 (Outputs)**
:
*
**持久化**
: 更新
`StaffPerformanceDetail`
(提成明细),
`StaffProductPerformance`
(品类汇总),
`StaffPerformance`
(总表).
*
**返回值**
:
`List<StaffProductPerformanceDTO>`
(计算结果列表).
### 1.3 逻辑全链路流程图 (Mermaid)
```
mermaid
graph TD
Start([开始: calStaffPerformance]) --> Validate{"参数校验<br/>手机号/月份格式"}
Validate -- 失败 --> Error([抛出异常])
Validate -- 通过 --> FetchOrders[查询员工当月所有订单]
FetchOrders -- 无订单 --> EndEmpty([返回空列表])
FetchOrders -- 有订单 --> GroupOrders["数据分组<br/>按商户+业务+品牌+子品牌"]
GroupOrders --> LoopGroup[遍历每个订单组]
subgraph CoreLogic ["单组处理核心逻辑 (processOrderGroup)"]
LoopGroup --> CalcDependency[Step 1: 计算考核因子依赖基础数据]
CalcDependency --> FetchDaily[获取日报/引荐/触客数据]
CalcDependency --> AggOrder[聚合订单产值/数量]
FetchDaily --> GetConfig[Step 2: 获取当月有效提成配置]
AggOrder --> GetConfig
GetConfig -- 无配置 --> NextGroup[跳过当前组]
GetConfig -- 有配置 --> LoopConfigs[Step 3: 遍历提成参数配置组]
subgraph Evaluate ["具体提成计算 (evaluatePerformanceConfigs)"]
LoopConfigs --> CalcFactor["计算考核因子实际值<br/>(如: 渗透率, 客单价)"]
CalcFactor --> FilterOrders[按品类/套系筛选订单]
FilterOrders --> MatchTier["Step 4: 匹配阶梯规则<br/>(Start <= Actual <= End)"]
MatchTier -- 匹配成功 --> CreateDetail[创建初始明细DTO]
CreateDetail --> Conditions[Step 5: 遍历执行特殊条件逻辑]
Conditions --> CheckPenetration{"1. 渗透率是否达标?"}
CheckPenetration -- 否 --> Degrade["执行降档逻辑<br/>寻找低档位配置"]
CheckPenetration -- 是 --> CheckDeduct{"2. 订单数不足?"}
Degrade --> CheckDeduct
CheckDeduct -- 是 --> ApplyDeduct[计算扣减金额]
CheckDeduct -- 否 --> CheckReward{"3. 达标奖励?"}
ApplyDeduct --> CheckReward
CheckReward -- 是 --> ApplyReward[增加奖励金额]
CheckReward -- 否 --> CheckExclude{"4. 订单剔除?"}
ApplyReward --> CheckExclude
CheckExclude -- 是 --> ApplyExclude[扣减升级单量]
CheckExclude -- 否 --> FinalCalc[Step 6: 计算最终金额]
end
FinalCalc --> CollectResult[收集结果]
end
CollectResult --> SaveDB["Step 7: 持久化存储<br/>(逻辑删除旧数据 -> 插入新数据)"]
SaveDB --> NextGroup
NextGroup -- 所有组处理完 --> Return[返回最终结果]
```
---
## 2. 单组处理详细步骤拆解 (Step-by-Step Logic)
本章节拆解基于
`StaffPerformanceCalService.processOrderGroup`
方法的核心执行链路。
### Step 1: 考核因子依赖数据准备 (CalcDependency)
-
**方法入口**
:
`calculateDependencyData`
-
**核心动作**
:
1.
**聚合订单数据**
:
-
调用
`computePersonalMonthlyTotalOutput`
和
`computePersonalMonthlyStoreOutput`
,通过 Stream API 汇总
`outputAmount`
。
-
调用
`computeMainOrderCountByBrand`
统计去重后的
`orderCode`
数量。
2.
**获取日报数据**
:
-
调用
`staffPerformanceCalMapper.statPreSalesTouchCount`
三次,分别获取:
-
`personalTotal`
(个人总触客)
-
`storePersonal`
(个人单店触客)
-
`storeTotal`
(门店总触客)
-
调用
`effectiveReferralReviewService`
获取
`storeDeliveryCount`
(门店交车数)
`storeValidRecommendationCount`
(有效引荐数)。若未修正引荐数,则回退使用
`storeDeliveryCount`
(交车数)。
3.
**计算个人应触客数 (核心公式)**
:
-
**方法**
:
`computePersonalExpectedTouchCount`
-
**逻辑**
:
-
`门店触客率 (StoreRate)`
=
`门店总触客`
/
`门店有效引荐`
-
`个人占比 (Prop)`
=
`个人触客`
/
`门店总触客`
-
**分支 1 (StoreRate = 1)**
:
`应触客数 = 个人触客`
-
**分支 2 (StoreRate > 1)**
:
`应触客数 = 门店有效引荐 * 个人占比`
(按比例压缩)
-
**分支 3 (StoreRate < 1)**
:
`应触客数 = 个人触客 + (缺口 * 个人占比)`
(按比例分摊缺口)
-
**精度**
: 保留2位小数,
`ROUND_HALF_UP`
。
### Step 2: 获取当前生效的提成配置 (GetConfig)
-
**方法**
:
`getEffectivePerformanceConfig`
-
**动作**
: 查询
`PerformanceConfig`
表,匹配键为
`merchantId`
+
`businessType`
+
`brandId`
+
`childBrandId`
+
`month`
。
-
**异常**
: 若返回 null,记 Error 日志并
`return`
,终止该分组计算。
### Step 3: 配置分组与遍历,计算考核因子实际值 (EvaluateConfigs)
-
**方法**
:
`evaluatePerformanceConfigs`
-
**逻辑**
:
1.
将
`PerformanceParamConfigDTO`
列表按
`generateParamConfigGroupKey`
(因子+品类+定义ID) 分组。
2.
**考核因子实际值计算**
:
`getActualValue`
-
**依赖品类数据计算**
(
`calcCategoryDependencyData`
):
根据配置的
`goodsConfigType`
区分两种处理模式,结果存入
`AssessmentFactorOrderDataDTO`
中,供后续公式取用。
*
**模式 A: 指定套系 (DESIGNATED_PACKAGE)**
*
**匹配逻辑**
(
`matchesPackage`
):
*
按主订单号分组,获取该主订单下的所有子订单 (
`subOrders`
)。
*
遍历套系定义中的
**商品组列表**
(
`packageItemList`
)。每个商品组包含多个可选商品 (Item A, Item B...)。
*
**且 (AND) 关系**
: 必须满足
**每一个**
商品组的要求。
*
**或 (OR) 关系**
: 在每一个商品组内,
`subOrders`
中至少包含一个子订单的
`upgradeGoodsId`
匹配该组内的任意一个商品 ID。
*
*判定*
: 若所有商品组均被命中,则该组订单判定为匹配套系。
*
**指标计算**
:
*
`MainOrderCount`
/
`SubOrderCount`
: 均为匹配的
**套系数量**
(主订单组数)。
*
`OutputTotal`
: 仅累加套系定义内子订单的
`outputAmount`
。
*
**模式 B: 品类/单品/全部 (CATEGORY / PRODUCT)**
*
**匹配逻辑**
(
`matchesCategory`
): 遍历子订单列表,对每个
`subOrder`
进行独立判断:
*
**全部商品 (-1)**
: 直接通过。
*
**商品分类 (0)**
: 依次比对
`goodsType`
,
`secondaryGoodsType`
,
`thirdLevelGoodsType`
。配置项为
`null`
时视为通配(不过滤)。
*
**指定商品 (1)**
: 检查子订单的
`upgradeGoodsId`
是否存在于
`productDefine`
的
`itemList`
中。
*
**指标计算**
:
*
`MainOrderCount`
: 匹配子订单对应的
**去重主订单号**
数量。
*
`SubOrderCount`
: 匹配的
**子订单**
数量。
*
`OutputTotal`
: 匹配子订单的
`outputAmount`
求和。
*
**通用逻辑: 提成基数过滤**
*
在上述匹配基础上,额外读取
`valid.dj.order.type`
配置(如只算 "1,5" 类型)。
*
计算
`CommissionBaseSubOrderCount`
和
`CommissionBaseCategoryOrderOutputTotal`
,用于最终提成金额的 User Base。
| 考核因子 (AssessmentFactorEnum) | 核心计算公式 (Formula) | 数据来源 |
| :--- | :--- | :--- |
| **PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE**<br>(个人月度总产值) | `Σ(Order.outputAmount)` | 过滤:`businessType` |
| **PERSONAL_MONTHLY_SINGLE_STORE_OUTPUT_VALUE**<br>(个人月度单店产值) | `Σ(Order.outputAmount)` | 过滤:`businessType` + `merchantId` |
| **PERSONAL_CUSTOMER_PENETRATION_RATE**<br>(个人客户渗透率) | `MainOrderCount` / `PersonalTargetTouch` | 分子:主订单数(门店+业务+品牌+品类)<br>分母:个人应触客数 |
| **PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE**<br>(个人单品渗透率) | `SubOrderCount` / `PersonalTargetTouch` | 分子:子订单数(门店+业务+品牌+品类)<br>分母:个人应触客数 |
| **HIGH_CUSTOMER_UNIT_PRICE**<br>(高客单价) | `Σ(Order.outputAmount)` | 过滤:`businessType` + `merchantId` + `brand` + `category` |
| **TOTAL_CUSTOMER_CONTACT_UNIT_PRICE**<br>(总触客客单价-园区店) | `PersonalMonthlyTotalOutput` / `PersonalTotalPreSalesTouch` | 分子:个人业务总产值<br>分母:个人总实际售前触客数 |
| **CUSTOMER_CONTACT_UNIT_PRICE**<br>(触客客单价) | `PersonalMonthlyStoreOutput` / `StorePersonalPreSalesTouch` | 分子:个人单店产值<br>分母:该门店个人实际触客数 |
| **UPGRADE_UNIT_PRICE**<br>(升级客单价) | `PersonalMonthlyStoreOutput` / `MainOrderCount` | 分子:个人单店产值<br>分母:主订单成交数(门店+业务+品牌) |
| **DELIVERY_UNIT_PRICE**<br>(交车客单价) | `PersonalMonthlyStoreOutput` / `PersonalTargetTouch` | 分子:个人单店产值<br>分母:个人应触客数 |
| **STORE_CUSTOMER_CONTACT_RATE_DELIVERY**<br>(门店触客率-交车) | `StoreTotalTouch` / `StoreDeliveryCount` | 分子:门店总触客数<br>分母:门店交车数 |
| **STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL**<br>(门店触客率-有效引荐) | `StoreTotalTouch` / `StoreValidReferral` | 分子:门店总触客数<br>分母:门店有效引荐数 |
| **UPGRADE_ORDER_QUANTITY**<br>(升级订单数) | `MainOrderCount` | 来源:主订单成交数(门店+业务+品牌) |
3. **提成基数辅助过滤**:
- 计算完实际值后,会再次根据 `valid.dj.order.type` 过滤订单,用于计算 GMV 或 订单数作为提成基数。
### Step 4: 匹配阶梯规则 (MatchTier)
-
**方法**
:
`isConfigMatch`
-
**逻辑**
: 遍历同组配置,寻找满足
`config.StartValue <= actualValue <= config.EndValue`
的第一条记录。
-
**输出**
: 创建初始
`StaffPerformanceDetailDTO`
,记录基础系数 (
`commissionTypeValue`
)。
### Step 5: 执行特殊条件逻辑 (Conditions Chain)
-
**方法**
:
`calculateByConditions`
,按顺序处理
`performanceParamConfigConditions`
列表。
#### 5.1 渗透率限制 (Penetration Rate Limit)
-
**条件类型**
:
`PENETRATION_RATE_LIMIT`
-
**逻辑**
:
1.
计算
**限制商品**
的渗透率
`conditionProductPenetrationRate`
。
2.
检查是否在
`[Start, End]`
区间内。
-
**降档处理 (`handleDegradation`)**
:
-
若不在区间内,在同组配置中寻找
`StartValue < 当前StartValue`
的记录。
-
按
`StartValue`
降序排列,取第一个(即最高的“低档位”)。
-
**更新**
: 将
`DetailDTO`
的
`commissionTypeValue`
替换为新档位的值。
-
**归零**
: 若找不到更低档位,设置
`commissionType=DDJE`
,
`value=0`
。
#### 5.2 订单数不足扣减 (Order Deduction)
-
**条件类型**
:
`ORDER_COUNT_DEDUCTION`
-
**逻辑**
:
1.
检查
`个人渗透率 < conditionEndValue`
(目标值)。
2.
`渗透率缺口 = 目标值 - 实际值`
。
3.
`缺口单量 (Shortfall)`
=
`渗透率缺口 * 应触客数`
(
**向上取整**
`ROUND_UP`
)。
4.
`扣款 = 缺口单量 * 配置单价 * -1`
。
-
**副作用**
:
`ExtraPerformanceAmount += 扣款`
。
#### 5.3 整体指标达成奖励 (Target Reward)
-
**条件类型**
:
`TARGET_ACHIEVEMENT_REWARD`
-
**逻辑**
: 直接读取
`conditionCommissionTypeValue`
。
-
**副作用**
:
`ExtraPerformanceAmount += 奖励金额`
。
#### 5.4 订单剔除 (Order Exclusion)
-
**条件类型**
:
`ORDER_EXCLUSION_INCLUSION`
-
**逻辑**
:
1.
调用
`StaffPerformanceOrderUtil.countMatchingOrders`
统计符合
**剔除条件**
的单量。
2.
`新升级单量 = Max(0, 原升级单量 - 剔除单量)`
。
-
**副作用**
: 更新
`UpgradeOrderNum`
字段。
### Step 6: 计算最终金额 (FinalCalc)
-
**方法**
:
`calculateFinalCommission`
-
**公式**
:
-
**GDJE (固定金额)**
:
`BaseAmount = commissionTypeValue`
-
**BL (比例)**
:
`BaseAmount = GMV * commissionTypeValue`
-
**最终结果**
:
`PerformanceAmount = BaseAmount + ExtraPerformanceAmount`
(注: Extra可能为负)。
### Step 7: 持久化存储 (SaveDB)
-
**动作**
:
1.
**删除旧数据**
: 调用
`updateDeletedFlag`
将历史数据置为失效。
2.
**保存新数据**
:
-
`saveStaffPerformanceDetails`
(明细表)
-
`saveStaffProductPerformance`
(品类维度汇总)
-
`saveStaffPerformance`
(员工月度总表)
---
## 3. 风险与隐患分析 (Critical Code Review)
### 🚨 高危风险 (Critical)
1.
**分母为零与空值传递风险**
: (已确认兼容null或0的处理)
*
**代码位置**
:
`computePersonalExpectedTouchCount`
*
**隐患**
: 当门店有效引荐数 (
`storeValidRecommendationCount`
) 为 0 时,方法会返回
`null`
。该
`null`
值会一直向上透传至
`dailyData`
。
*
**连带影响**
:
-
后续计算
`PERSONAL_CUSTOMER_PENETRATION_RATE`
(个人渗透率) 时,调用
`DataCalUtil.divideToPercent`
。
-
若
`targetTouch`
(分母) 为 null,
`DataCalUtil`
会返回 null(已经由用户确认已做兼容)。
-
**潜在逻辑漏洞**
: 虽然代码不会抛NPE,但渗透率为 null 可能导致后续
`handleDegradation`
等逻辑失效或产生意料外行为。
### ⚠️ 逻辑关注 (Attention)
1.
**降档逻辑的非连续性 (业务规则)**
:(产品设计如此)
*
**代码位置**
:
`handleDegradation`
*
**现象**
: 降档逻辑是寻找
`StartValue < 当前StartValue`
的最大值。若配置表存在断档(如配置了 A档
[
10-20
]
和 B档
[
30-40
]
),且实际值为 35(命中B档),降档时会跨过空缺的
[
20-30
]
区间,直接降至 A 档。
*
**风险评估**
:
**经确认,此为符合预期的产品设计**
,非代码缺陷,无需修改。
2.
**循环嵌套性能**
: (数据量不会太多)
*
**隐患**
: 三层嵌套循环(订单组 -> 配置列表 -> 阶梯配置)。对于当前的业务量级(单商户配置数有限)在可接受范围内。
### 📝 维护性 (Maintainability)
1.
**外部配置耦合**
:(实时读取外部配置,不需要发版和重启)
*
`hmzxid`
(鸿蒙智行ID) 和
`valid.dj.order.type`
(提成基数有效订单类型) 均通过
`OrePropertyConfigurer`
硬编码读取。
*
**建议**
: 业务ID变更概率较低,但需确保运维文档中包含相关配置项说明。
2.
**SceneTypeEnum 转换硬编码**
:(已确认没问题)
*
`getSceneTypeFromBusinessType`
中使用了
`if-else`
判断业务类型。新增业务类型时需同步修改此处代码。
---
rpc-dj-staff/src/main/resources/design/TEST_DATA_INIT.md
0 → 100644
View file @
61b2271
## 数据要求
我需要开始集成测试的测试数据准备,数据应该满足如下要求:
-
员工
-
天明哥哥
- staffuuid:304c01b8abf14db581606ce42e35ede5
- staffname:天明哥哥
- staff_phone:15626599735
-
明明崇文园区店员工01
- staffuuid:8d3f61299d024a3dbe685687c756866d
- staffname:明明崇文园区店员工01
- staff_phone:15626599738
-
员工北森基础信息表 dj_car_life_staff_beisen_base_info
-
每个员工一条记录,entry_date分别在2025-12-15前后
-
商户
-
商户名称:明天集团4s店AG,商户号:44217734
-
商户名称:明天集团4s店AF,商户号:44217732
-
月份:2025-12
-
商品
-
商品A
- "upgrade_goods_id": 102031,
- "upgrade_goods_name": "权益一级260123",
- "goods_type": 146,
- "goods_type_name": "权益一级类目",
- "secondary_goods_type": -1,
- "secondary_goods_type_name": "",
- "third_level_goods_type": -1,
- "third_level_goods_type_name": ""
-
商品B
- "upgrade_goods_id": 102018,
- "upgrade_goods_name": "权益三级至臻多规格",
- "goods_type": 146,
- "goods_type_name": "权益一级类目",
- "secondary_goods_type": 147,
- "secondary_goods_type_name": "权益二级类目",
- "third_level_goods_type": 148,
- "third_level_goods_type_name": "权益三级类目"
-
商品C
- "upgrade_goods_id": 101673,
- "upgrade_goods_name": "权益二级25011301c",
- "goods_type": 146,
- "goods_type_name": "权益一级类目",
- "secondary_goods_type": 147,
- "secondary_goods_type_name": "权益二级类目",
- "third_level_goods_type": -1,
- "third_level_goods_type_name": ""
-
商品D
- "upgrade_goods_id": 101956,
- "upgrade_goods_name": "20250514权益第三方商品",
- "goods_type": 102,
- "goods_type_name": "11122",
- "secondary_goods_type": -1,
- "secondary_goods_type_name": "",
- "third_level_goods_type": -1,
- "third_level_goods_type_name": ""
-
商品E
- "upgrade_goods_id": 101669,
- "upgrade_goods_name": "延保三级25011301a",
- "goods_type": 114,
- "goods_type_name": "延保类",
- "secondary_goods_type": 149,
- "secondary_goods_type_name": "延保类二级",
- "third_level_goods_type": 150,
- "third_level_goods_type_name": "延保类三级"
-
品牌数据
-
品牌1
- "car_brand_id": 2978,
- "car_brand": "鸿蒙智行",
- "car_childs_brand_id": 3454,
- "car_childs_brand_name": "AITO 问界"
-
品牌2
- "car_brand_id": 2978,
- "car_brand": "鸿蒙智行",
- "car_childs_brand_id": 3547,
- "car_childs_brand_name": "尚界"
-
品牌3
- "car_brand_id": 2125,
- "car_brand": "奥迪",
- "car_childs_brand_id": 2127,
- "car_childs_brand_name": "Audi Sport"
-
品牌4
- "car_brand_id": 2365,
- "car_brand": "比亚迪",
- "car_childs_brand_id": 2695,
- "car_childs_brand_name": "比亚迪"
-
订单数据
-
以上所有员工分别在以上所有门店的多笔订单
-
订单时间及支付时间在月份:2025-12内
-
订单 scene_type = 0, business_type 1 2随机
-
订单的品牌信息随机取用上面的
-
对于同一个员工同一家门店的订单 ,一个订单的子订单信息包含多种商品A-E商品信息的排列组合,例如
- 一个订单包含有商品A的子订单
- 一个订单包含有商品B的子订单
- 一个订单包含有商品C的子订单
- 一个订单包含有商品D的子订单
- 一个订单包含有商品E的子订单
- 一个订单包含有商品A、商品B的子订单
- 一个订单包含有商品A、商品C的子订单
- 一个订单包含有商品A、商品D的子订单
- 一个订单包含有商品A、商品D的子订单
- 一个订单包含有商品B、商品C的子订单
- 一个订单包含有商品B、商品D的子订单
- 一个订单包含有商品B、商品D的子订单
- 一个订单包含有商品C、商品D的子订单
- 一个订单包含有商品A、商品B、商品C的子订单
- 一个订单包含有商品A、商品B、商品D的子订单
- 一个订单包含有商品A、商品C、商品D的子订单
- 一个订单包含有商品A、商品B、商品C、商品D的子订单
-
日报数据
-
以上所有员工分别在以上所有门店的日报数据,一个员工在一家门店至少有3天的日报数据
-
sceneType=0
-
日期所在月份是2025-12
-
圈定产品/套餐信息
-
dj_car_life_merchant_performance_product_define及dj_car_life_merchant_performance_product_define_item是一套圈定产品/套餐的组合
- 圈定产品1
- define_name: 圈定产品1
- 相关的dj_car_life_merchant_performance_product_define_item包含商品A、商品B
- item_id的值取upgrade_goods_id
- item_name的值取upgrade_goods_name
- 圈定产品2
- define_name: 圈定产品2
- 相关的dj_car_life_merchant_performance_product_define_item包含商品C、商品D
- item_id的值取upgrade_goods_id
- item_name的值取upgrade_goods_name
- 圈定套餐3
- 包含圈定产品1、圈定产品2
- item_id的值取圈定产品2的dj_car_life_merchant_performance_product_define表的id
- item_name的值取取圈定产品2的dj_car_life_merchant_performance_product_define表的define_name
-
已生效的提成配置
-
所有商户在business_type 1、2,以上所有品牌1-4 分别于有一套已生效已启用的提成配置
-
effective_month为2025-12
-
每套提成配置相关的dj_car_life_performance_param_config
- 涵盖12种assessment_factor
- goods_config_type等商品信息
- 如果goods_config_type = 0:商品分类,随机取用商品A-E的goods_type等信息
- 如果goods_config_type = 1:圈定产品,product_define_id、product_define_name随机取圈定产品1、圈定产品2信息
- 如果goods_config_type = 2圈定套餐,product_define_id、product_define_name取圈定套餐3信息
-
有效引荐数表sal_effective_referral_review
-
所有员工在所有商户所有品牌有一条数据,reviewMonth为2025-12
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/resources/design/TEST_PLAN.md
0 → 100644
View file @
61b2271
# 员工提成计算模块测试规划文档 (Test Plan)
> **文档说明**:本文档基于 `StaffPerformanceCalService.java` 及相关业务逻辑分析编写,旨在为测试开发提供详细的测试策略、用例设计及注意事项。
## 1. 测试策略 (Test Strategy)
### 1.1 测试目标
*
确保提成计算逻辑的准确性,覆盖所有商户规则配置。
*
验证数据依赖处理的正确性(订单、日报、引荐数)及考核因子计算准确性。
*
保障异常场景下的系统鲁棒性(数据缺失、格式错误)及接口幂等性。
### 1.2 测试范围
*
**代码入口**
:
`StaffPerformanceCalService.calStaffPerformance(String staffPhone, String month)`
*
**核心逻辑**
:
*
订单分组与数据聚合
*
考核因子依赖数据计算(含日报数据逻辑)
*
**考核因子实际值计算**
(12个核心因子)
*
提成配置匹配与阶梯计算
*
四大特殊条件处理(渗透率限制、扣减、奖励、剔除)
*
最终金额汇总及
**幂等性处理**
### 1.3 测试方法
*
**单元测试 (Unit Test)**
: 使用 JUnit + Mockito 对 Service 层进行隔离测试,Mock 所有 Mapper 和外部 Service 调用。
*
**集成测试 (Integration Test)**
:
**暂不考虑数据库集成**
。重点验证 Service 层与 Mapper 层(Mock)的交互逻辑,以及各 Service 间的协作。
---
## 2. 测试用例总览 (Test Case Overview)
### 2.1 P0 - 核心主流程 (Happy Path)
| ID | 用例名称 | 场景简述 |
| :--- | :--- | :--- |
|
**TC-01**
| 单商户单订单基础计算 | 基础流程验证:单订单匹配固定配置。 |
|
**TC-02**
| 12个考核因子计算覆盖 | 覆盖所有12个核心考核因子的计算逻辑。 |
|
**TC-03**
| 配置区间匹配测试 | 验证 Start/End/Middle 及边界值的匹配逻辑。 |
|
**TC-04**
| 多订单分组计算 | 验证多商户、多业务下的数据隔离与分组处理。 |
|
**TC-05**
| 提成比例计算模式 | 验证基于比例 (BL) 的提成公式计算。 |
|
**TC-20**
|
**系数与新人保护计算**
| 验证提成系数 (XS) 叠加及新人保护期逻辑。 |
### 2.2 P1 - 业务规则与复杂逻辑
| ID | 用例名称 | 场景简述 |
| :--- | :--- | :--- |
|
**TC-06**
| 渗透率限制-区间内 | 渗透率达标,不触发降档。 |
|
**TC-07**
| 渗透率限制-触发降档 | 渗透率不足,降至低档位。 |
|
**TC-08**
| 渗透率限制-降档归零 | 渗透率不足且无更低档位,提成归零。 |
|
**TC-09**
| 订单数不足扣减 | 计算渗透率缺口并执行扣款。 |
|
**TC-10**
| 整体指标达成奖励 | 满足额外指标,执行奖励增加。 |
|
**TC-11**
| 订单剔除 (升级单量修正) | 排除特定订单,修正升级单量字段。 |
|
**TC-12**
| 个人应触客数逻辑覆盖 | 验证 StoreRate =, >, < 1 三种场景下的公式。 |
|
**TC-13**
| 套系商品匹配 (Package) | 验证仅统计套系内定义商品的产值逻辑。 |
### 2.3 P2 - 边界、异常与幂等性
| ID | 用例名称 | 场景简述 |
| :--- | :--- | :--- |
|
**TC-14**
| 幂等性验证 | 重复调用接口,验证数据一致性与旧数据清理。 |
|
**TC-15**
| 月份格式错误 | 参数校验:非法月份格式。 |
|
**TC-16**
| 参数缺失 (NPE防御) | 参数校验:必填项缺失。 |
|
**TC-17**
| 日报数据缺失 | 容错处理:日报触客数为空时的默认处理。 |
|
**TC-18**
| 引荐数修正逻辑 | 数据降级:无有效引荐数时使用交车数。 |
|
**TC-19**
| 边界值测试 | 验证区间临界点 (Start/End) 的判定逻辑。 |
---
## 3. 用例详细设计 (Detailed Test Case Design)
### 3.1 P0 核心用例详细设计
#### TC-01: 单商户单订单基础计算
*
**测试目的**
: 验证最基础的单订单、单配置下的提成计算流程,确保链路通畅。
*
**前置条件**
:
1.
MySQL 中存在关联的商户、品牌基础数据。
2.
无历史提成数据干扰(或允许被逻辑删除)。
*
**数据准备 (Input)**
:
*
**Staff**
:
`phone="13800138001"`
,
`month="2025-01"`
*
**Config**
:
*
`PerformanceConfig`
:
`merchantId=1`
,
`businessType=1`
,
`brandId=100`
,
`childBrandId=101`
,
`month="2025-01"`
*
`ParamConfig`
:
*
`goodsConfigType="ALL_PRODUCT"`
(全部商品)
*
`assessmentFactor="PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE"`
(个人月度总产值)
*
`commissionType="GDJE"`
,
`commissionTypeValue=100`
(固定100元)
*
`startValue=0`
,
`endValue=null`
(无上限)
*
**Order**
:
*
1条记录:
`merchantId=1`
,
`businessType=1`
,
`brandId=100`
,
`childBrandId=101`
,
`orderCode="ORDER001"`
,
`outputAmount=1000`
,
`djOrderType=1`
(有效类型)
*
**DailyReport**
: 均不需要(Mock 为 null 或 0)。
*
**执行步骤**
:
1.
调用
`StaffPerformanceCalService.calStaffPerformance("13800138001", "2025-01")`
。
*
**期望结果 (Output)**
:
1.
**返回值**
: List size = 1。
2.
**结果验证**
:
*
`performanceAmount`
== 100.00
*
`gmvOutput`
== 1000.00
3.
**数据库状态**
:
*
`staff_performance_detail`
新增1条记录,
`is_deleted=0`
。
*
`commission_type_value`
== 100.00
*
`upgradeOrderNum`
== 1 (假设该订单符合升级条件,或需验证默认值为0/1,根据Order数据Output=1000通常对应1单) ->
*需确保 Mock Order 返回的 upgradeOrderNum 与预期一致*
。
#### TC-02: 12个考核因子计算覆盖
*
**测试目的**
: 验证所有12种
`AssessmentFactorEnum`
的计算逻辑是否准确,特别是依赖日报和多级订单聚合的指标。
*
**前置条件**
: 完整的商户、品牌结构。
*
**数据准备 (Input)**
:
*
**Staff**
:
`phone="13800138002"`
,
`month="2025-01"`
*
**Orders**
:
*
**Biz1 (业务1)**
:
*
OrderA: Merch1, Brand1, Output=2000 (主单)
*
OrderB: Merch1, Brand1, Output=1000 (主单) ->
**Biz1 Total=3000**
*
**Biz2 (业务2)**
:
*
OrderC: Merch1, Brand1, Output=500 ->
**Biz2 Total=500**
*
**Store Total Output**
(Merch1) = 3500
*
**DailyReport**
:
*
`personalTotalPreSalesTouchCount`
= 50 (个人总)
*
`storePersonalPreSalesTouchCount`
= 20 (门店个人)
*
`storeTotalTouchCount`
= 200 (门店总)
*
`storeDeliveryCount`
= 10 (门店交车)
*
`storeValidRecommendationCount`
= 20 (有效引荐)
*
**Calculated Target**
:
*
StoreReferralRate = 200/20 = 10 (>100%)
*
PersonalRatio = 50/200 = 0.25
*
**PersonalTargetTouch**
= 20
* 0.25 = **5.00*
*
*
**Config**
: 为 Merch1 配置12条 ParamConfig (goodsConfigType="ALL_PRODUCT"),对应以下因子:
1.
`PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE`
2.
`PERSONAL_MONTHLY_SINGLE_STORE_OUTPUT_VALUE`
3.
`PERSONAL_CUSTOMER_PENETRATION_RATE`
4.
`PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE`
5.
`HIGH_CUSTOMER_UNIT_PRICE`
6.
`TOTAL_CUSTOMER_CONTACT_UNIT_PRICE`
7.
`CUSTOMER_CONTACT_UNIT_PRICE`
8.
`UPGRADE_UNIT_PRICE`
9.
`DELIVERY_UNIT_PRICE`
10.
`STORE_CUSTOMER_CONTACT_RATE_DELIVERY`
11.
`STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL`
12.
`UPGRADE_ORDER_QUANTITY`
*
区间设置: Start=0, End=null (确保全部命中)。
*
**执行步骤**
:
1.
调用计算服务。
*
**期望结果 (Output)**
:
1.
**验证各因子 ActualValue**
:
*
`PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE`
(个人月度总产值):
**3000**
(Only Biz1)
*
`PERSONAL_MONTHLY_SINGLE_STORE_OUTPUT_VALUE`
(个人月度单店产值):
**3000**
(Only Biz1 in Merch1)
*
`PERSONAL_CUSTOMER_PENETRATION_RATE`
(个人客户渗透率): MainOrders(2) / Target(5.0) =
**40.00%**
*
`PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE`
(个人单品渗透率): SubOrders(2) / Target(5.0) =
**40.00%**
*
`HIGH_CUSTOMER_UNIT_PRICE`
(高客单价):
**3000**
(Biz1 Total)
*
`TOTAL_CUSTOMER_CONTACT_UNIT_PRICE`
(总触客客单价): 3000 / 50 =
**60.00**
*
`CUSTOMER_CONTACT_UNIT_PRICE`
(触客客单价): 3000 / 20 =
**150.00**
*
`UPGRADE_UNIT_PRICE`
(升级客单价): 3000 / 2 (MainCount) =
**1500.00**
*
`DELIVERY_UNIT_PRICE`
(交车客单价): 3000 / 5.0 =
**600.00**
*
`STORE_CUSTOMER_CONTACT_RATE_DELIVERY`
(门店触客率-交车): 200 / 10 =
**2000.00%**
(20.0)
*
`STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL`
(门店触客率-有效引荐): 200 / 20 =
**1000.00%**
(10.0)
*
`UPGRADE_ORDER_QUANTITY`
(升级订单数):
**2**
#### TC-03: 配置区间匹配测试
*
**测试目的**
: 验证
`actualValue`
落在不同区间时的匹配正确性(确保区间无重叠或验证首个匹配逻辑)。
*
**数据准备 (Input)**
:
*
**Config**
: 同一 Factor 下配置三个无重叠档位:
*
Tier A (Config1): Start=0, End=99 (Val=10)
*
Tier B (Config2): Start=100, End=200 (Val=20)
*
Tier C (Config3): Start=201, End=null (Val=30)
*
**Run 1 (Value=50)**
: 构造 Order Output=50
*
**Run 2 (Value=100)**
: 构造 Order Output=100
*
**Run 3 (Value=200)**
: 构造 Order Output=200
*
**Run 4 (Value=300)**
: 构造 Order Output=300
*
**期望结果 (Output)**
:
*
Run 1 -> 50 在
[
0, 99
]
-> 匹配
**Config1**
, Amount=10
*
Run 2 -> 100 在
[
100, 200
]
-> 匹配
**Config2**
, Amount=20 (边界Start)
*
Run 3 -> 200 在
[
100, 200
]
-> 匹配
**Config2**
, Amount=20 (边界End)
*
Run 4 -> 300 > 201 -> 匹配
**Config3**
, Amount=30
#### TC-04: 多订单分组计算
*
**测试目的**
: 验证系统能正确按
`Merchant + BusinessType + Brand + ChildBrand`
分组,且配置缺失时不崩塌、不混淆。
*
**数据准备 (Input)**
:
*
**Order Set 1**
: Merch_A, Brand_A. (Has Config)
*
**Order Set 2**
: Merch_A, Brand_B. (No Config)
*
**Order Set 3**
: Merch_B, Brand_A. (Has Config)
*
**期望结果 (Output)**
:
*
Service 执行完毕无异常。
*
返回结果 List 中包含 Set 1 和 Set 3 的计算结果。
*
Set 2 的数据未生成 Detail 记录,且日志中有
`warn`
信息提示 "未找到有效的提成配置"。
#### TC-05: 提成比例计算模式
*
**测试目的**
: 验证
`CommissionType=BL`
(比例) 时的计算逻辑。
*
**数据准备 (Input)**
:
*
**Config**
:
`commissionType="BL"`
,
`commissionTypeValue=0.05`
(5%)
*
**Order**
:
*
Order1: Type=1 (Valid), Output=1000
*
Order2: Type=2 (Valid), Output=2000
*
Order3: Type=99 (Invalid for Base), Output=5000 (该类型不在
`valid.dj.order.type`
中)
*
**Env**
:
`valid.dj.order.type.for.commission.basic`
= "1,2"
*
**期望结果 (Output)**
:
*
`gmvOutput`
(提成基数) = 1000 + 2000 = 3000 (排除 Order3)
*
`performanceAmount`
= 3000
* 0.05 = **150.00*
*
#### TC-20: 系数与新人保护计算
*
**测试目的**
: 验证“提成列表汇总”阶段的系数计算逻辑(基数
*
系数积),以及新人保护期(系数<1则重置为1)的处理。
*
**前置条件**
:
1.
Mock
`StaffBeisenBaseInfoService`
返回入职时间。
2.
`StaffPerformanceService`
聚合逻辑验证。
*
**数据准备 (Input)**
:
*
**Case A (Normal)**
: Not Newcomer (入职久).
*
Detail 1: Type=GDJE, Amt=100.
*
Detail 2: Type=GDJE, Amt=200.
*
Detail 3: Type=XS (Coefficient), Val=0.8.
*
Detail 4: Type=XS, Val=1.1.
*
**Case B (Protective)**
: Newcomer (刚入职).
*
Details same as above.
*
**期望结果 (Output)**
:
*
**Case A**
:
*
Base = 100 + 200 = 300.
*
Coeff = 0.8
*
1.1 = 0.88.
*
Final = 300
* 0.88 = **264.00*
*
.
*
**Case B**
:
*
Base = 300.
*
Coeff = 0.88 (
< 1
.
0
)
-
>
Reset to 1.0.
*
Final = 300
* 1.0 = **300.00*
*
.
### 3.2 P1 复杂业务用例详细设计
#### TC-06: 渗透率限制-区间内
*
**测试目的**
: 验证当实际渗透率在限制区间内时,提成计算按原配置执行,不触发降档。
*
**前置条件**
:
1.
Config 配置了
`PENETRATION_RATE_LIMIT`
条件。
2.
`AssessmentFactor`
必须是
`PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE`
。
*
**数据准备 (Input)**
:
*
**Config**
:
*
StandardTier: Start=10%, End=30%, Val=100元, Condition=
`Limit [10%, 40%]`
*
**Target**
: PersonalTargetTouch = 100
*
**Order**
:
*
Match Condition Product Orders = 25 (Rate = 25%)
*
**执行步骤**
: 调用计算服务。
*
**期望结果 (Output)**
:
1.
**ParamsJson**
:
`conditionProductPenetrationRate`
= 25.00%。
2.
**Result**
:
`commissionTypeValue`
= 100 (保持不变)。
3.
**Logs**
: 不出现 "降档" 相关日志。
#### TC-07: 渗透率限制-触发降档
*
**测试目的**
: 验证当渗透率低于 Start 值时,能自动寻找更低档位的配置。
*
**数据准备 (Input)**
:
*
**Config Group**
:
*
Tier High: Start=20%, End=50%, Val=200, Condition=
`Limit [20%, 50%]`
*
Tier Mid: Start=10%, End=20%, Val=100
*
Tier Low: Start=0%, End=10%, Val=50
*
**Target**
: TargetTouch = 100
*
**Order**
: Match Orders = 5 (Rate = 5%) -> 命中 Tier High (假设按产值或其他维度初始命中High,但渗透率校验挂了)
*
**Input**
: ActualValue(产值) 满足 Tier High 要求。
*
**期望结果 (Output)**
:
1.
**Process**
: 初始匹配 Tier High -> Check Condition (5%
< 20
%)
-
>
Fail.
2.
**Degrade**
: 寻找 Start
< 20
%
的配置
-
>
选中 Tier Mid (Start=10) ->
**注意**
: 代码仅按配置 Start 值降序寻找首个满足条件的档位,
**不会**
递归校验该目标档位的 Condition (如 Tier Mid 若有渗透率要求则被忽略,直接应用其提成值)。
3.
**Result**
:
`commissionTypeValue`
= 100 (Tier Mid Val)。
4.
**Log**
: "渗透率不达标,降档至...Tier Mid"。
#### TC-08: 渗透率限制-降档归零
*
**测试目的**
: 验证无更低档位时,提成归零。
*
**数据准备 (Input)**
:
*
**Config**
:
*
Tier High: Start=10%, Val=100.
*
**Data**
: ActualValue 满足 Tier High,但 Condition Penetration = 5% (<10%)。
*
**期望结果 (Output)**
:
1.
**Degrade**
: 找不到 Start < 10% 的 Config。
2.
**Result**
:
`commissionType`
="DDJE",
`commissionTypeValue`
=0.
3.
**Log**
: "渗透率不达标且无更低档位,提成归零"。
#### TC-09: 订单数不足扣减
*
**测试目的**
: 验证
`ORDER_COUNT_DEDUCTION`
逻辑,计算缺口单量并扣款。
*
**数据准备 (Input)**
:
*
**Config**
: Condition Target=10%, DeductUnit=50元/单。
*
**Daily**
: TargetTouch=100。
*
**Order**
: Penetration SubOrders=5 (Rate=5%)。
*
**期望结果 (Output)**
:
1.
**Shortfall**
: Target(10%) - Actual(5%) = 5%。
2.
**Missing Orders**
: (10% - 5%)
* 100 = 5.0 单 (代码逻辑:`shortfallRate *
TargetTouch
` 并**向上取整** `
BigDecimal.ROUND_UP
`)。
3. **Deduction**: 5 * 50 = 250元。
4. **Result**: `
ExtraPerformanceAmount
` = -250.00。
#### TC-10: 整体指标达成奖励
* **测试目的**: 验证 `
TARGET_ACHIEVEMENT_REWARD
` 逻辑。
* **数据准备 (Input)**:
* **Config**: Reward=500, ConditionType=3.
* **Logic**: 此条件类型 (`
TARGET_ACHIEVEMENT_REWARD
`) 在代码中为**配置即生效**,只要该条件存在于配置中,即执行奖励累加,Service 层暂无额外的指标逻辑判断(如是否达成GMV目标),需依赖配置的有效性。
* **期望结果 (Output)**:
1. **Result**: `
ExtraPerformanceAmount
` += 500。
#### TC-11: 订单剔除 (升级单量修正)
* **测试目的**: 验证 `
ORDER_EXCLUSION_INCLUSION
` 逻辑,正确扣减 `
UpgradeOrderNum
`。
* **数据准备 (Input)**:
* **Order**:
* Code1: GoodsA (Normal)
* Code2: GoodsB (Exclude Target)
* Initial UpgradeOrderNum = 2 (Main Orders).
* **Config**: Condition Exclude GoodsB.
* **期望结果 (Output)**:
1. **Calc**: Match Exclude = 1.
2. **Result**: `
UpgradeOrderNum
` 字段值被更新为 1 (原值 2 - 剔除 1)。
#### TC-12: 个人应触客数逻辑覆盖
* **测试目的**: 覆盖 `
computePersonalExpectedTouchCount
` 的三个分支。
* **数据准备 (Input)**:
* **Case 1 (Rate=1)**: StoreTotal=100, ValidRef=100, PersonTouch=10 -> Exp=10
* **Case 2 (Rate>1)**: StoreTotal=200, ValidRef=100, PersonTouch=20 -> Exp=10
* **Case 3 (Rate<1)**: StoreTotal=50, ValidRef=100, PersonTouch=5 -> Exp=10
* **期望结果 (Output)**:
* 验证三种情况下的计算结果均符合预期公式。
#### TC-13: 套系商品匹配 (Package)
* **测试目的**: 验证 `
GoodsConfigType=DESIGNATED_PACKAGE
` 时的复杂匹配。
* **数据准备 (Input)**:
* **ProductDefine**: Package Contains { [Group1: ItemA], [Group2: ItemB, ItemC] } (AND relation).
* **Order 1**: ItemA + ItemB (Match).
* **Order 2**: ItemA only (Mismatch Group2).
* **Order 3**: ItemB + ItemC (Mismatch Group1).
* **期望结果 (Output)**:
1. **MainOrderCount**: 1 (Only Order 1).
2. **OutputTotal**: Only Sum(Order1.ItemA + Order1.ItemB).
### 3.3 P2 边界与异常用例详细设计
#### TC-14: 幂等性验证
* **测试目的**: 验证对同一员工、同一月份的多次计算请求,系统能保证数据的最终一致性,且不会产生重复数据。
* **前置条件**:
1. MySQL 中已存在该员工、该月的一份计算结果 (Detail + Product + Main)。
* **执行步骤**:
1. 调用 `
StaffPerformanceCalService.calStaffPerformance
` (第1次).
2. 调用 `
StaffPerformanceCalService.calStaffPerformance
` (第2次).
* **期望结果 (Output)**:
1. **Mock Verify**: 验证 `
mapper.insertSelective
` 方法被调用的次数。
2. **Logic Delete**: 验证 `
mapper.removeStaffPerformance
` 在每次 `
insert
` 前被正确调用。
3. **Result Check**: 两次 API 返回的计算结果内容一致。
#### TC-15: 月份格式错误
* **测试目的**: 验证输入参数校验逻辑。
* **数据准备 (Input)**:
* `
month
` = "2023/01" (Invalid)
* **期望结果 (Output)**:
* 抛出 `
RpcServiceException
`,ErrorCode=`
DATA_INVALID
`。
#### TC-16: 参数缺失 (NPE防御)
* **测试目的**: 验证必填字段校验。
* **数据准备 (Input)**:
* `
staffPhone
` = null
* **期望结果 (Output)**:
* 抛出 `
RpcAssert
` 异常或 `
RpcServiceException
`。
#### TC-17: 日报数据缺失
* **测试目的**: 验证当 `
StaffPerformanceDailyReport
` 表中无数据时的容错处理。
* **数据准备 (Input)**:
* **DB**: 无 `
staff_performance_daily_report
` 记录。
* **Mock**: `
statPreSalesTouchCount
` 返回 null。
* **期望结果 (Output)**:
1. **No Crash**: 服务正常运行,不抛 NPE。
2. **Defaults**:
* `
personalTotalPreSalesTouchCount
` = 0
* `
storeTotalTouchCount
` = 0
* `
personalTargetTouchCount
` = 0
3. **Calculation**: 渗透率公式分母为0时,结果为0 (验证 `
DataCalUtil
` 兼容性)。
#### TC-18: 引荐数修正逻辑
* **测试目的**: 验证有效引荐数为空时的回退机制。
* **数据准备 (Input)**:
* **ReferralReview**:
* `
ReviewedEffectiveCount
` (修正后) = null
* `
TotalDeliveryCount
` (系统交车) = 50
* **期望结果 (Output)**:
* `
storeValidRecommendationCount
` 采用 50 进行后续计算。
#### TC-19: 边界值测试
* **测试目的**: 验证配置区间的临界点 (Start/End) 判定逻辑。
* **数据准备 (Input)**:
* **Config**: Start=100, End=200.
* **Run 1**: ActualValue = 100.
* **Run 2**: ActualValue = 200.
* **期望结果 (Output)**:
* Run 1 & Run 2 均应判定为 **Match (true)**,进入该配置计算逻辑。
---
## 4. 通用数据准备说明
### 基础数据 Mock 建议
* **Mock Strategy**: 所有外部依赖 (Mapper, RemoteService) 均采用 Mockito 模拟返回值,**不依赖真实数据库**。
* **Merchant/Brand**: 使用 ID=1 作为默认测试商户,ID=100 作为默认品牌,ID=101 作为子品牌。
* **Time**: 统一使用 "2025-01" 作为测试月份。
* **User**: defaultStaffPhone = "13800000000"。
### 关键 Mapper/Service Mock 列表
* `
StaffPerformanceSubOrderMapper.listStaffMonthSubOrders
` (Mock Orders)
* `
PerformanceConfigService.getEffectivePerformanceConfig
` (Mock Config)
* `
StaffPerformanceCalMapper.statPreSalesTouchCount
` (Mock Daily Data)
* `
EffectiveReferralReviewService.queryEffectiveReferralReview
` (Mock Referral)
* `
MerchantPerformanceProductDefineRemote.getProductDefine
` (Mock Product Definition)
* `
StaffBeisenBaseInfoService.getByStaffPhone
`
(Mock Entry Date for Newcomer)
rpc-dj-staff/src/main/resources/design/TEST_PLAN_COMPLETE.md
0 → 100644
View file @
61b2271
# 员工提成计算模块测试规划文档 (完整集成版)
> **文档说明**:本文档整合了初始测试规划与真实 DB 数据 SQL 版,旨在为测试开发提供从单元测试 (Mock) 到集成测试 (真实 DB) 的全方位指导。
> **特别说明**:
> 1. 部分核心用例提供基于真实数据库的数据准备 SQL,适用于集成测试。
> 2. 复杂逻辑用例建议通过 Mock 方式进行单元测试,以控制维护成本。
> 3. 所有测试数据 `created_by` 统一标识为 `caiym_test_staff_performance`,便于清理。
---
## 1. 测试策略 (Test Strategy)
### 1.1 测试目标
*
确保提成计算逻辑的准确性,覆盖所有商户规则配置。
*
验证数据依赖处理的正确性(订单、日报、引荐数)及考核因子计算准确性。
*
保障异常场景下的系统鲁棒性(数据缺失、格式错误)及接口幂等性。
### 1.2 测试范围
*
**代码入口**
:
`StaffPerformanceCalService.calStaffPerformance(String staffPhone, String month)`
*
**核心逻辑**
:
*
订单分组与数据聚合
*
考核因子依赖数据计算(含日报数据逻辑)
*
**考核因子实际值计算**
(12个核心因子)
*
提成配置匹配与阶梯计算
*
四大特殊条件处理(渗透率限制、扣减、奖励、剔除)
*
最终金额汇总、提成系数积计算及
**新人保护期**
处理
*
数据持久化逻辑及
**幂等性处理**
### 1.3 测试等级与方法
1.
**单元测试 (Unit Test)**
:
*
**方法**
: 使用 JUnit + Mockito。
*
**重点**
: 验证 TC-02 ~ TC-13 (复杂逻辑)、TC-15 ~ TC-19 (异常/边界)。Mock 所有 Mapper 和外部 Service,聚焦算法准确性。
2.
**集成测试 (Integration Test)**
:
*
**方法**
: 基于真实 MySQL 数据库环境。
*
**重点**
: 验证 TC-01 (主流程)、TC-20 (新人保护与系数)、TC-14 (幂等性/持久化)。确保 SQL 层面字段匹配、数据类型及事务/清理逻辑正确。
---
## 2. 测试用例总览 (Test Case Overview)
| ID | 用例名称 | 场景简述 | 测试方式 | 包含 SQL |
| :-------- | :---------------------- | :------------------------------------------ | :------- | :------- |
|
**TC-01**
| 单商户单订单基础计算 | 基础流程验证:单订单匹配固定配置。 | 集成测试 | 是 |
|
**TC-02**
| 12个考核因子计算覆盖 | 覆盖所有12个核心考核因子的计算逻辑。 | 单元测试 | 否 |
|
**TC-03**
| 配置区间匹配测试 | 验证 Start/End/Middle 及边界值的匹配逻辑。 | 单元测试 | 否 |
|
**TC-04**
| 多订单分组计算 | 验证多商户、多业务下的数据隔离与分组处理。 | 单元测试 | 否 |
|
**TC-05**
| 提成比例计算模式 | 验证基于比例 (BL) 的提成公式计算。 | 单元测试 | 否 |
|
**TC-20**
|
**系数与新人保护计算**
| 验证提成系数 (XS) 叠加及新人保护期逻辑。 | 集成测试 | 是 |
|
**TC-06**
| 渗透率限制-区间内 | 渗透率达标,不触发降档。 | 单元测试 | 否 |
|
**TC-07**
| 渗透率限制-触发降档 | 渗透率不足,降至低档位。 | 单元测试 | 否 |
|
**TC-08**
| 渗透率限制-降档归零 | 渗透率不足且无更低档位,提成归零。 | 单元测试 | 否 |
|
**TC-09**
| 订单数不足扣减 | 计算渗透率缺口并执行扣款。 | 单元测试 | 否 |
|
**TC-10**
| 整体指标达成奖励 | 满足额外指标,执行奖励增加。 | 单元测试 | 否 |
|
**TC-11**
| 订单剔除 (升级单量修正) | 排除特定订单,修正升级单量字段。 | 单元测试 | 否 |
|
**TC-12**
| 个人应触客数逻辑覆盖 | 验证 StoreRate =, >, < 1 三种场景下的公式。 | 单元测试 | 否 |
|
**TC-13**
| 套系商品匹配 (Package) | 验证仅统计套系内定义商品的产值逻辑。 | 单元测试 | 否 |
|
**TC-14**
| 幂等性验证 | 重复调用接口,验证数据一致性与旧数据清理。 | 集成测试 | 是 |
|
**TC-15**
| 月份格式错误 | 非法月份格式 ("2023/01") 校验。 | 单元测试 | 否 |
|
**TC-16**
| 参数缺失 (NPE防御) | 必填项缺失校验。 | 单元测试 | 否 |
|
**TC-17**
| 日报数据缺失 | 容错处理:日报触客数为空时的默认处理。 | 单元测试 | 否 |
|
**TC-18**
| 引荐数修正逻辑 | 数据回退:无修正引荐数时使用系统交车数。 | 单元测试 | 否 |
|
**TC-19**
| 边界值测试 | 验证区间临界点 (Start/End) 的判定。 | 单元测试 | 否 |
---
## 3. 用例详细设计 (Detailed Test Case Design)
### 3.1 P0 核心用例与集成设计 (包含 SQL)
#### TC-01: 单商户单订单基础计算
*
**测试目的**
: 验证最基础的单订单、单配置下的提成计算流程,确保链路通畅。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
,
`StaffPerformanceService.java`
*
**测试逻辑说明**
:
1.
**请求接收**
: 系统接收计算请求 (员工手机号
`13800138001`
+ 月份
`2025-01`
)。
2.
**订单获取**
: 查询该员工在 2025-01 月份的所有有效订单 (
`StaffPerformanceSubOrder`
)。
3.
**分组处理**
: 将订单按
`商户 + 业务类型 + 品牌 + 子品牌`
进行分组,本用例仅产生一组数据。
4.
**配置匹配**
: 根据分组 Key (
`Merchant1 + Business1 + Brand100 + Child101`
) 获取当月有效的提成配置 (
`PerformanceConfig`
)。
5.
**依赖数据计算**
:
*
聚合个人月度产值、单店产值。
*
获取并计算日报数据(个人触客、门店触客、有效引荐等)。
6.
**提成计算**
:
*
遍历 12 个考核因子,计算实际值 (此处重点关注
`GMV`
或
`GDJE`
)。
*
根据实际值匹配配置阶梯 (Start <= Actual <= End)。
*
应用特殊条件(如渗透率降档、扣减等,本用例不触发)。
7.
**结果持久化**
:
*
逻辑删除该员工该月旧的提成记录。
*
插入新的
`StaffPerformanceDetail`
(明细) 和
`StaffPerformance`
(汇总) 记录。
*
**前置条件**
:
1.
MySQL 中存在关联的商户、品牌基础数据。
2.
无历史提成数据干扰。
*
**真实环境数据准备 (SQL)**
:
```
sql
-- 1. 清理数据
DELETE
FROM
dj_car_life_staff_info
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_performance_config
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_performance_param_config
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_performance_config_merchant_brand_ref
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_goods_order
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_pay_order
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_goods_order_customer
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_goods_sub_order
WHERE
created_by
=
'caiym_test_staff_performance'
;
-- 2. 准备 Staff 数据
INSERT
INTO
dj_car_life_staff_info
(
staff_uuid
,
staff_name
,
phone_number
,
merchant_id
,
merchant_name
,
register_time
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'staff_uuid_tc01'
,
'TC01_Staff'
,
'13800138001'
,
1
,
'测试商户1'
,
NOW
(),
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 3. 准备 Config 数据 (单配置)
INSERT
INTO
dj_car_life_performance_config
(
scheme_name
,
scheme_type
,
business_type
,
effective_month
,
status
,
enable_flag
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'TC01_Scheme'
,
1
,
'1'
,
'2025-01'
,
2
,
'Y'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
SET
@
config_id_tc01
=
LAST_INSERT_ID
();
INSERT
INTO
dj_car_life_performance_config_merchant_brand_ref
(
performance_config_id
,
merchant_id
,
merchant_name
,
brand_id
,
brand_name
,
child_id
,
child_name
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
@
config_id_tc01
,
1
,
'测试商户1'
,
100
,
'测试品牌'
,
101
,
'测试子品牌'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 参数配置 (个人月度总产值, 固定金额 100)
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
end_value
,
commission_base
,
commission_type
,
goods_config_type
,
commission_type_value
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
@
config_id_tc01
,
1
,
1
,
0
,
NULL
,
'GMV'
,
'GDJE'
,
-
1
,
100
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 4. 准备 Order 数据
INSERT
INTO
dj_car_life_goods_order
(
order_code
,
user_id
,
merchant_id
,
merchant_name
,
seller_user_id
,
status
,
channel_type
,
order_type
,
business_type
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'user_001'
,
1
,
'测试商户1'
,
'staff_uuid_tc01'
,
4
,
2
,
1
,
1
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
INSERT
INTO
dj_car_life_pay_order
(
order_code
,
success_date
,
pay_status
,
order_money
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'2025-01-15 10:00:00'
,
1
,
1000
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
INSERT
INTO
dj_car_life_goods_order_customer
(
order_code
,
customer_name
,
customer_phone
,
car_brand_id
,
car_childs_brand_id
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'Cust_TC01'
,
'13900000001'
,
100
,
101
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_thumb_url
,
base_shop_price
,
number
,
final_price
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'SUB_TC01_001'
,
1000
,
'GOODS_001'
,
'测试商品'
,
'test_thumb'
,
1000
.
00
,
1
,
1000
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
```
*
**执行步骤**
:
1.
执行上述 SQL。
2.
调用接口:
`calStaffPerformance("13800138001", "2025-01")`
*
**期望结果**
:
1.
返回值 List size = 1。
2.
`performanceAmount`
== 100.00,
`gmvOutput`
== 1000.00。
3.
`staff_performance_detail`
及
`staff_performance`
表新增对应记录。
#### TC-20: 系数与新人保护计算
*
**测试目的**
: 验证提成系数 (XS) 叠加及新人保护期逻辑(总系数 < 1.0 则重置为 1.0)。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 750)
*
**测试逻辑说明**
:
1.
**新人判定**
:
*
查询员工入职日期 (
`StaffBeisenBaseInfo`
)。
*
计算保护期截止时间: 绩效月份上个月的 15 号 (例如 2025-01 绩效,界限为 2024-12-15)。
*
若
`入职日期 > 界限日期`
,标记为
**新人**
。
2.
**系数计算**
:
*
累乘所有
`commissionType=XS`
(系数) 类型的配置值。
*
例如:基础系数 0.8
*
额外系数 0.9 = 0.72。
3.
**保护逻辑应用**
:
*
若员工为
**新人**
且 totalCoefficient < 1.0,强制重置为
**1.0**
。
*
若非新人,保持计算出的系数 (0.9)。
4.
**金额计算**
:
`最终提成 = 基础提成 * 最终系数`
。
*
**真实环境数据准备 (SQL)**
:
```
sql
-- 1. Staff 信息
INSERT
INTO
dj_car_life_staff_info
(
staff_uuid
,
staff_name
,
phone_number
,
merchant_id
,
merchant_name
,
register_time
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'staff_uuid_tc20'
,
'TC20_Staff'
,
'13800138020'
,
1
,
'测试商户1'
,
NOW
(),
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 2. 北森入职信息 (关键:入职时间 > 2024-12-15)
INSERT
INTO
dj_car_life_staff_beisen_base_info
(
staff_name
,
staff_phone
,
trial_basic_salary
,
entry_date
,
merchant_id
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'TC20_Staff'
,
'13800138020'
,
5000
.
00
,
'2024-12-20'
,
1
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 3. Config (含基础提成 + 系数 0.8)
INSERT
INTO
dj_car_life_performance_config
(
scheme_name
,
scheme_type
,
business_type
,
effective_month
,
status
,
enable_flag
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'TC20_Scheme'
,
1
,
'1'
,
'2025-01'
,
2
,
'Y'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
SET
@
config_id_tc20
=
LAST_INSERT_ID
();
INSERT
INTO
dj_car_life_performance_config_merchant_brand_ref
(
performance_config_id
,
merchant_id
,
merchant_name
,
brand_id
,
brand_name
,
child_id
,
child_name
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
@
config_id_tc20
,
1
,
'测试商户1'
,
100
,
'测试品牌'
,
101
,
'测试子品牌'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 基础提成 GDJE 100
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
commission_base
,
commission_type
,
goods_config_type
,
commission_type_value
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
@
config_id_tc20
,
1
,
1
,
0
,
'GMV'
,
'GDJE'
,
-
1
,
100
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 系数 XS 0.8 (触发保护应变为 1.0)
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
commission_base
,
commission_type
,
goods_config_type
,
commission_type_value
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
@
config_id_tc20
,
1
,
2
,
0
,
'GMV'
,
'XS'
,
-
1
,
0
.
80
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 4. Order 数据 (略,参考 TC-01 构造一个有效订单)
```
*
**预期结果**
:
1.
**新人**
: 金额 = 100
*
1.0 = 100.00 (保护生效)。
2.
**非新人**
(入职改设为 '2024-12-01'): 金额 = 100
*
0.8 = 80.00。
#### TC-14: 幂等性验证
*
**测试目的**
: 验证重复计算不产生重复数据,确保数据一致性。
*
**涉及代码**
:
`StaffPerformanceService.java`
(Line 200)
*
**测试逻辑说明**
:
1.
**首次执行**
: 跟随标准流程计算并插入数据 (
`deleted_flag='N'`
)。
2.
**二次执行**
:
*
在插入前,执行
`updateDeletedFlag`
操作,将库中该员工该月的
`deleted_flag='N'`
记录更新为
`Y`
(逻辑删除)。
*
插入本次计算的新记录 (
`deleted_flag='N'`
)。
3.
**结果验证**
: 数据库中应仅存在
**一份**
有效的 (
`deleted_flag='N'`
) 结果数据,旧数据均被标记为删除。
*
**执行步骤**
:
1.
执行 TC-01 数据脚本。
2.
调用核心计算接口 (第 1 次)。
3.
再次调用核心计算接口 (第 2 次)。
*
**期望结果**
:
1.
`staff_performance`
表中该员工该月仅有
**1 条**
`deleted_flag = 'N'`
的记录。
2.
验证旧数据被正确软删除。
---
#### TC-02: 12个考核因子计算覆盖 (Mock 重点)
*
**测试目的**
: 验证所有 12 种考核因子的计算逻辑,特别是依赖日报和个人占比的指标。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 420,
`getActualValue`
)
*
**测试逻辑说明**
:
*
**核心公式验证**
:
1.
**个人月度总产值 (`PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE`)**
: ∑(该业务下所有订单产值)。
2.
**个人月度单店产值 (`PERSONAL_MONTHLY_SINGLE_STORE_OUTPUT_VALUE`)**
: ∑(该门店该业务下所有订单产值)。
3.
**个人客户渗透率 (`PERSONAL_CUSTOMER_PENETRATION_RATE`)**
: 主订单数 / 个人应触客数。
4.
**个人单品渗透率 (`PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE`)**
: 子订单数 / 个人应触客数。
5.
**高客单价 (`HIGH_CUSTOMER_UNIT_PRICE`)**
: ∑(符合条件的订单产值)。
6.
**总触客客单价-园区店 (`TOTAL_CUSTOMER_CONTACT_UNIT_PRICE`)**
: 个人总产值 / 个人总售前触客数。
7.
**触客客单价 (`CUSTOMER_CONTACT_UNIT_PRICE`)**
: 个人单店产值 / 门店个人售前触客数。
8.
**升级客单价 (`UPGRADE_UNIT_PRICE`)**
: 个人单店产值 / 主订单成交数。
9.
**交车客单价 (`DELIVERY_UNIT_PRICE`)**
: 个人单店产值 / 个人应触客数。
10.
**门店触客率-交车 (`STORE_CUSTOMER_CONTACT_RATE_DELIVERY`)**
: 门店总触客 / 门店交车数。
11.
**门店触客率-有效引荐 (`STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL`)**
: 门店总触客 / 门店有效引荐数。
12.
**升级订单数 (`UPGRADE_ORDER_QUANTITY`)**
: 主订单成交数。
*
**模拟数据 (Input)**
:
*
**Orders**
:
*
OrderA: Merch1, Brand1, Output=2000 (主单)
*
OrderB: Merch1, Brand1, Output=1000 (主单) ->
**Total=3000**
*
**DailyReport**
:
*
`personalTotalPreSalesTouchCount`
= 50 (个人总)
*
`storePersonalPreSalesTouchCount`
= 20 (门店个人)
*
`storeTotalTouchCount`
= 200 (门店总)
*
`storeDeliveryCount`
= 10 (门店交车)
*
`storeValidRecommendationCount`
= 20 (有效引荐)
*
**中间变量计算**
:
*
PersonalRatio (个人占比) = 50 / 200 = 0.25
*
PersonalTargetTouch (个人目标触客) = 20
* 0.25 = **5.00*
*
*
**期望 ActualValue 验证**
:
1.
`PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE`
:
**3000**
2.
`PERSONAL_MONTHLY_SINGLE_STORE_OUTPUT_VALUE`
:
**3000**
3.
`PERSONAL_CUSTOMER_PENETRATION_RATE`
: 2(主单) / 5.0 =
**40.00%**
4.
`PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE`
: 2(子单) / 5.0 =
**40.00%**
5.
`HIGH_CUSTOMER_UNIT_PRICE`
:
**3000**
(主流程金额)
6.
`TOTAL_CUSTOMER_CONTACT_UNIT_PRICE`
: 3000 / 50 =
**60.00**
7.
`CUSTOMER_CONTACT_UNIT_PRICE`
: 3000 / 20 =
**150.00**
8.
`UPGRADE_UNIT_PRICE`
: 3000 / 2 =
**1500.00**
9.
`DELIVERY_UNIT_PRICE`
: 3000 / 5.0 =
**600.00**
10.
`STORE_CUSTOMER_CONTACT_RATE_DELIVERY`
: 200 / 10 =
**2000.00%**
11.
`STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL`
: 200 / 20 =
**1000.00%**
12.
`UPGRADE_ORDER_QUANTITY`
:
**2**
#### TC-03: 配置区间匹配测试
*
**测试目的**
: 验证
`actualValue`
落在不同区间时的阶梯匹配逻辑。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 580,
`isConfigMatch`
)
*
**测试逻辑说明**
:
1.
系统遍历配置组中的所有阶梯配置 (
`PerformanceParamConfigDTO`
)。
2.
对于每个配置,检查条件:
`StartValue <= ActualValue <= EndValue`
。
3.
注意:
`EndValue`
为
`NULL`
时表示无穷大。
4.
验证四种场景:
*
区间内 (Inner): Match.
*
等于 Start (Left Boundary): Match.
*
等于 End (Right Boundary): Match.
*
区间外 (Outside): No Match.
*
**配置**
: Tier A
[
0, 99
]
(
Val=10
)
, Tier B
[
100, 200
]
(
Val=20
)
, Tier C
[
201, null
]
(
Val=30
)
。
*
**验证结果**
: 50 -> Tier A; 100 -> Tier B; 200 -> Tier B; 300 -> Tier C。
#### TC-04: 多订单分组计算
*
**测试目的**
: 验证
`Merchant + BusinessType + Brand + ChildBrand`
组合的分组隔离。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 150,
`processOrderGroup`
)
*
**测试逻辑说明**
:
1.
**分组键生成**
:
`GenerateGroupKey = merchantId + "_" + businessType + "_" + brandId + "_" + childBrandId`
。
2.
**隔离性验证**
:
*
Group A: 有对应
`PerformanceConfig`
-> 正常计算。
*
Group B: 无对应
`PerformanceConfig`
-> 记录 Warning 日志,跳过,不报错。
3.
**结果验证**
: 最终 List 中应包含 Group A 的结果,不包含 Group B 的结果。
*
**场景**
: Set 1 有配置,Set 2 无配置。
*
**结果**
: Set 1 生成 DTO,Set 2 提示 Warn 并不生成记录,系统不报错。
#### TC-05: 提成比例计算模式
*
**测试目的**
: 验证
`CommissionType=BL`
(比例) 的计算。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 800,
`calculateFinalCommission`
)
*
**测试逻辑说明**
:
1.
**基数确定**
: 根据
`valid.dj.order.type`
再次过滤订单,计算所有有效订单的总产值 (
`GMV`
)。
2.
**比例应用**
: 读取配置的比例值 (例如 0.05)。
3.
**计算**
:
`提成金额 = GMV * 比例`
。
4.
**对比**
: 区别于
`GDJE`
(固定金额) 直接返回配置值的逻辑。
*
**数据**
: 有效订单 3000, 比例 5%, 非法类型订单 5000。
*
**预期**
: 基数 3000, 提成金额 150.00。
---
### 3.2 P1 复杂业务场景设计 (Mock 测试)
#### TC-06: 渗透率限制-区间内 (Penetration Within Limit)
*
**测试目标**
: 验证
`processPenetrationRateCondition`
方法在渗透率达标时不触发降档。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 644)
*
**测试逻辑说明**
:
*
系统首先计算商品的实际渗透率。
*
检查该渗透率是否落在配置的
`[ConditionStartValue, ConditionEndValue]`
区间内。
*
如果
**在区间内**
,则认为达标,保持当前的提成配置不变,不修改
`commissionTypeValue`
,也不设置
`newParamConfigId`
。
*
**Mock 准备 (JUnit)**
:
1.
**Config 构造**
:
```java
PerformanceParamConfigDTO config = new PerformanceParamConfigDTO();
config.setAssessmentFactor(AssessmentFactorEnum.PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE.getCode());
config.setCommissionTypeValue(new BigDecimal("100")); // 原档位
PerformanceParamConfigConditionDTO condition = new PerformanceParamConfigConditionDTO();
condition.setConditionType(PerformanceConditionTypeEnum.PENETRATION_RATE_LIMIT.getCode());
condition.setConditionStartValue(new BigDecimal("0.1")); // 10%
condition.setConditionEndValue(new BigDecimal("0.4")); // 40%
config.setPerformanceParamConfigConditions(Collections.singletonList(condition));
```
2.
**Context 构造**
:
*
Mock
`dailyData.getPersonalTargetTouchCount()`
返回
`new BigDecimal("100")`
.
*
Mock
`calculateConditionProductPenetrationRate`
计算结果为
`new BigDecimal("0.25")`
(25%).
*
*(提示: 可通过构造包含25个目标商品子订单的 `groupedOrdersMap` 实现)*
*
**断言验证 (Verify)**
:
*
确认
`processPenetrationRateCondition`
返回
`false`
(代表不跳过/不降档)。
*
`Assert.assertEquals(new BigDecimal("100"), detailDTO.getCommissionTypeValue());`
*
`Assert.assertNull(detailDTO.getParamsJson().getString("newParamConfigId"));`
#### TC-07: 渗透率限制-触发降档 (Penetration Downgrade)
*
**测试目标**
: 验证
`handleDegradation`
逻辑,确保能找到并应用低档位配置。
*
**涉及代码**
:
`StaffPerformanceCalService.handleDegradation`
*
**测试逻辑说明**
:
*
**由于条件不满足导致降档**
。
*
**触发条件**
:
1.
Config 中配置了
`PENETRATION_RATE_LIMIT`
条件。
2.
系统计算该条件中指定的
**条件商品**
的渗透率 (
`calculateConditionProductPenetrationRate`
)。
3.
若
**条件商品渗透率**
不在配置区间
`[Start, End]`
内(且不为 null),则触发降档。
*
**降档动作**
:
*
针对
**主考核因子**
的配置组 (
`paramConfigs`
),寻找
`StartValue < 当前StartValue`
的配置。
*
取其中
`StartValue`
最大的一个作为新档位。
*
*注意*
: "条件商品"和"考核因子商品"可以是不同的(例如:考核整车提成,但限制条件是精品渗透率)。
*
**Mock 准备 (JUnit 代码示例)**
:
```java
// 1. 构造配置项
List<PerformanceParamConfigDTO> paramConfigs = new ArrayList<>();
// -- Config A (当前高档位): Start=0.2, Commission=200
// 包含渗透率限制条件: [0.2, 1.0]
PerformanceParamConfigDTO configA = new PerformanceParamConfigDTO();
configA.setId(101L);
configA.setStartValue(new BigDecimal("0.2"));
configA.setCommissionTypeValue(new BigDecimal("200"));
PerformanceParamConfigConditionDTO condition = new PerformanceParamConfigConditionDTO();
condition.setConditionType(PerformanceConditionTypeEnum.PENETRATION_RATE_LIMIT.getCode());
condition.setConditionStartValue(new BigDecimal("0.2"));
condition.setConditionEndValue(new BigDecimal("1.0"));
// 设置条件中指定的商品定义 (Condition Product)
MerchantPerformanceProductDefineDTO conditionProduct = new MerchantPerformanceProductDefineDTO();
conditionProduct.setId(888); // 假设这是限制商品ID
condition.setProductDefine(conditionProduct);
configA.setPerformanceParamConfigConditions(Collections.singletonList(condition));
paramConfigs.add(configA);
// -- Config B (降档目标位): Start=0.1, Commission=100
PerformanceParamConfigDTO configB = new PerformanceParamConfigDTO();
configB.setId(102L);
configB.setStartValue(new BigDecimal("0.1"));
configB.setCommissionTypeValue(new BigDecimal("100"));
paramConfigs.add(configB);
// -- Config C (最低档位): Start=0.0, Commission=50
PerformanceParamConfigDTO configC = new PerformanceParamConfigDTO();
configC.setId(103L);
configC.setStartValue(BigDecimal.ZERO);
configC.setCommissionTypeValue(new BigDecimal("50"));
paramConfigs.add(configC);
// 2. Mock 渗透率计算结果
// 假设实际计算出的条件商品渗透率为 0.05 (5%)
// 5% < 20% (条件下限),因此触发降档
StaffPerformanceCalService serviceSpy = spy(service);
doReturn(new BigDecimal("0.05"))
.when(serviceSpy).calculateConditionProductPenetrationRate(any(), any());
// 3. 构造提成明细 DTO (初始状态使用 Config A)
StaffPerformanceDetailDTO detailDTO = new StaffPerformanceDetailDTO();
detailDTO.setCommissionTypeValue(new BigDecimal("200"));
detailDTO.setParamConfigId(101L);
```
*
**断言验证 (Verify)**
:
*
`Assert.assertEquals(new BigDecimal("100"), detailDTO.getCommissionTypeValue());`
*
`Assert.assertEquals(102L, resultLog.getLong("newParamConfigId"));`
#### TC-08: 渗透率限制-降档归零 (Downgrade to Zero)
*
**测试目标**
: 验证
`handleDegradation`
在无低档位可用时的归零逻辑。
*
**涉及代码**
:
`StaffPerformanceCalService.handleDegradation`
*
**测试逻辑说明**
:
*
当触发降档查找时,如果在
`paramConfigs`
中
**找不到**
任何
`StartValue`
低于当前配置的项。
*
系统应将提成类型强制设为
`DDJE`
(固定金额),并将金额设为
`0`
。
*
这意味着员工不仅拿不到当前档位的提成,也没有保底档位可拿。
*
**Mock 准备 (JUnit)**
:
1.
**Config 构造**
:
```java
List<PerformanceParamConfigDTO> paramConfigs = new ArrayList<>();
// Only one config, Start 10%
PerformanceParamConfigDTO configA = new PerformanceParamConfigDTO();
configA.setStartValue(new BigDecimal("0.1"));
configA.setCommissionTypeValue(new BigDecimal("100"));
paramConfigs.add(configA);
```
2.
**Context 构造**
:
*
实际渗透率
`0.05`
(< 10%)。
*
**断言验证 (Verify)**
:
*
`Assert.assertEquals("DDJE", detailDTO.getCommissionType());`
*
`Assert.assertEquals(BigDecimal.ZERO, detailDTO.getCommissionTypeValue());`
*
日志验证:
`verify(log).info(contains("渗透率不达标且无更低档位"));`
#### TC-09: 订单数不足扣减 (Order Count Deduction)
*
**测试目标**
: 验证
`processOrderCountDeductionCondition`
的扣款公式计算。
*
**涉及代码**
:
`StaffPerformanceCalService.processOrderCountDeductionCondition`
*
**测试逻辑说明**
:
*
当实际渗透率低于目标渗透率 (
`ConditionEndValue`
) 时,计算差值。
*
差值转化为缺口单量:
`(目标率 - 实际率) * 个人应触客数`
。注意这里需要
**向上取整**
(
`ROUND_UP`
),即只要缺一点点也算缺一单。
*
最终扣款额 =
`缺口单量 * 单笔扣款标准`
。该金额会作为负数累加到
`ExtraPerformanceAmount`
中。
*
**Mock 准备 (JUnit)**
:
1.
**Config 构造**
:
```java
PerformanceParamConfigConditionDTO condition = new PerformanceParamConfigConditionDTO();
condition.setConditionType(PerformanceConditionTypeEnum.ORDER_COUNT_DEDUCTION.getCode());
condition.setConditionEndValue(new BigDecimal("0.1")); // Target Rate 10%
condition.setConditionCommissionTypeValue(new BigDecimal("50")); // Unit Deduction
```
2.
**Context 构造**
:
```java
// Mock Daily Data
AssessmentFactorDailyDataDTO dailyData = AssessmentFactorDailyDataDTO.builder()
.personalTargetTouchCount(new BigDecimal("100"))
.build();
when(context.getAssessmentFactorDependencyData().getDailyData()).thenReturn(dailyData);
// Prepare DetailDTO with actual rate
detailDTO.setPersonalPenetrationRate(new BigDecimal("0.05")); // 5%
```
*
**断言验证 (Verify)**
:
*
`Assert.assertEquals(new BigDecimal("-250"), detailDTO.getExtraPerformanceAmount());`
*
*Calculation: (0.10 - 0.05) *
100 = 5.0 orders; 5.0
* 50 *
-1 = -250.
*
#### TC-10: 整体指标达成奖励 (Target Achievement Reward)
*
**测试目标**
: 验证
`processTargetAchievementRewardCondition`
的奖励累加。
*
**涉及代码**
:
`StaffPerformanceCalService.processTargetAchievementRewardCondition`
*
**测试逻辑说明**
:
*
此条件用于给满足特定达标任务的员工发放固定金额奖励。
*
逻辑非常直接:读取配置中的奖励金额 (
`conditionCommissionTypeValue`
)。
*
将该金额
**累加**
到提成明细的额外奖金字段 (
`ExtraPerformanceAmount`
) 中。
*
注意是累加 (
`add`
) 而不是覆盖 (
`set`
),以支持多个奖励共存的情况。
*
**Mock 准备 (JUnit)**
:
1.
**Condition 构造**
:
```java
PerformanceParamConfigConditionDTO condition = new PerformanceParamConfigConditionDTO();
condition.setConditionType(PerformanceConditionTypeEnum.TARGET_ACHIEVEMENT_REWARD.getCode());
condition.setConditionCommissionTypeValue(new BigDecimal("500"));
```
2.
**DetailDTO 状态**
:
*
初始
`detailDTO.setExtraPerformanceAmount(BigDecimal.ZERO)`
(或非0值以验证累加)。
*
**断言验证 (Verify)**
:
*
`Assert.assertEquals(new BigDecimal("500"), detailDTO.getExtraPerformanceAmount());`
*
*注: 若初始为 100,则断言 600。*
#### TC-11: 订单剔除 (Order Exclusion)
*
**测试目标**
: 验证
`processOrderExclusionCondition`
正确调用工具类并更新
`UpgradeOrderNum`
。
*
**涉及代码**
:
`StaffPerformanceCalService.processOrderExclusionCondition`
*
**测试逻辑说明**
:
*
**区分逻辑**
:
*
若 Condition 指定的是
**套餐**
(
`DESIGNATED_PACKAGE`
): 需调用
`isOrderMatchPackage`
,判断整单逻辑。
*
若 Condition 指定的是
**单品/分类**
(
`DESIGNATED_PRODUCT`
等): 调用
`isOrderMatchCategory`
,逐个子订单判断。
*
**扣减动作**
:
`UpgradeOrderNum = Max(0, 原升级单量 - 匹配剔除的单量)`
。
*
**Mock 准备 (JUnit 代码示例)**
:
```java
// -- 场景: 剔除指定套餐 (Designated Package Exclusion) --
// 1. 构造剔除条件 (Condition)
PerformanceParamConfigConditionDTO condition = new PerformanceParamConfigConditionDTO();
condition.setConditionType(PerformanceConditionTypeEnum.ORDER_EXCLUSION_INCLUSION.getCode());
// 构造定义: 这是一个套餐 (Type=2),包含 ItemA(1001) 和 ItemB(1002)
MerchantPerformanceProductDefineDTO excludeDefine = new MerchantPerformanceProductDefineDTO();
excludeDefine.setId(999);
excludeDefine.setGoodsConfigType(GoodsConfigTypeEnum.DESIGNATED_PACKAGE.getCode());
// 套餐结构: Group1[ItemA] AND Group2[ItemB]
MerchantPerformanceProductDefineItemDTO itemA = new MerchantPerformanceProductDefineItemDTO().setUpgradeGoodsId(1001);
MerchantPerformanceProductDefineItemDTO itemB = new MerchantPerformanceProductDefineItemDTO().setUpgradeGoodsId(1002);
// 注意: PackageItemList 是 List<List<Item>>
List<List<MerchantPerformanceProductDefineItemDTO>> packageItems = new ArrayList<>();
packageItems.add(Collections.singletonList(itemA));
packageItems.add(Collections.singletonList(itemB));
excludeDefine.setPackageItemList(packageItems);
condition.setProductDefine(excludeDefine);
// 2. 构造上下文订单数据 (Context)
// 订单组包含2个主订单
List<StaffPerformanceSubOrderDTO> orders = new ArrayList<>();
// Order 1: 包含 1001 和 1002 -> 匹配套餐 -> 应被剔除
StaffPerformanceSubOrderDTO o1_1 = new StaffPerformanceSubOrderDTO(); o1_1.setOrderCode("ORDER_01"); o1_1.setUpgradeGoodsId(1001);
StaffPerformanceSubOrderDTO o1_2 = new StaffPerformanceSubOrderDTO(); o1_2.setOrderCode("ORDER_01"); o1_2.setUpgradeGoodsId(1002);
orders.add(o1_1);
orders.add(o1_2);
// Order 2: 仅包含 1001 -> 不匹配套餐 -> 保留
StaffPerformanceSubOrderDTO o2_1 = new StaffPerformanceSubOrderDTO(); o2_1.setOrderCode("ORDER_02"); o2_1.setUpgradeGoodsId(1001);
orders.add(o2_1);
// Mock Context 返回此订单列表
when(context.getGroupedOrdersMap().get(anyString())).thenReturn(orders);
// 3. 构造 DetailDTO
StaffPerformanceDetailDTO detailDTO = new StaffPerformanceDetailDTO();
detailDTO.setUpgradeOrderNum(2); // 初始单量为2
```
*
**断言验证 (Verify)**
:
*
`processOrderExclusionCondition(detailDTO, context, condition, log);`
*
`Assert.assertEquals(1, detailDTO.getUpgradeOrderNum());`
(2 - 1 = 1)
*
`verify(log).info(contains("excludedCount=1"));`
#### TC-12: 个人应触客数逻辑覆盖 (Target Touch Logic)
*
**测试目标**
: 单元测试
`computePersonalExpectedTouchCount`
方法的三个分支。
*
**涉及代码**
:
`StaffPerformanceCalService.computePersonalExpectedTouchCount`
*
**测试逻辑说明**
:
*
个人应触客数是计算渗透率的分母,逻辑旨在将个人的触客行为标准化。
*
核心公式:
`个人应触客数 = 个人实际触客数 * (门店有效引荐数 / 门店总触客数)`
。
*
即:用门店整体的“触客-引荐”转化效率,来折算个人的有效触客工作量。
*
**分支 1 (Rate=1)**
: 门店效率 100%,个人应触客数 = 个人实际触客数。
*
**分支 2 (Rate>1)**
: 门店效率低(需多次触客才由1引荐),个人应触客数 < 实际触客数(折算)。
*
**分支 3 (Rate<1)**
: 门店效率极高(数据异常或极佳),个人应触客数 > 实际触客数(放大)。
*
**测试策略**
: 使用 JUnit 5
`@ParameterizedTest`
.
*
**代码示例**
:
```java
@ParameterizedTest
@CsvSource({
"100, 100, 10, 10.00", // Rate=1: Return Personal
"200, 100, 20, 10.00", // Rate=2 (>1): 20 * (100/200) = 10
"50, 100, 5, 10.00" // Rate=0.5 (<1): 5 * (100/50) = 10
})
void testComputePersonalExpectedTouchCount(Integer storeTotal, Integer storeValid,
Integer personalTotal, BigDecimal expected) {
// 使用反射调用私有方法
Method method = StaffPerformanceCalService.class.getDeclaredMethod("computePersonalExpectedTouchCount", ...);
method.setAccessible(true);
BigDecimal result = (BigDecimal) method.invoke(service, personalTotal, storeTotal, storeValid);
Assert.assertEquals(expected, result);
}
```
#### TC-13: 套系商品匹配 (Package Matching)
*
**测试目标**
: 验证
`matchesPackage`
逻辑是否正确处理AND关系的商品组。
*
**涉及代码**
:
`StaffPerformanceOrderUtil.matchesPackage`
*
**测试逻辑说明**
:
*
**数据结构**
: 套餐定义 (
`ProductDefine`
) 包含一个
`PackageItemList`
(List
<List
<
Item
>
>)。
*
**外层 List (AND)**
: 代表商品
**组**
。订单必须包含所有组。
*
**内层 List (OR)**
: 代表组内
**可选项**
。组内任一商品命中即可。
*
**Mock 准备 (JUnit 代码示例)**
:
```java
// 1. 构造套餐定义 (ProductDefine)
MerchantPerformanceProductDefineDTO packageDefine = new MerchantPerformanceProductDefineDTO();
// List<List<Item>> 结构
List<List<MerchantPerformanceProductDefineItemDTO>> packageItems = new ArrayList<>();
// Group 1 (必须满足): 包含 Item 1001 或 1002
List<MerchantPerformanceProductDefineItemDTO> group1 = new ArrayList<>();
group1.add(new MerchantPerformanceProductDefineItemDTO().setItemId(1001));
group1.add(new MerchantPerformanceProductDefineItemDTO().setItemId(1002));
packageItems.add(group1);
// Group 2 (必须满足): 包含 Item 2001
List<MerchantPerformanceProductDefineItemDTO> group2 = new ArrayList<>();
group2.add(new MerchantPerformanceProductDefineItemDTO().setItemId(2001));
packageItems.add(group2);
packageDefine.setPackageItemList(packageItems);
// 2. 构造测试订单 (Orders)
// Case A: 完全匹配 (包含 1001 和 2001)
List<StaffPerformanceSubOrderDTO> orderCaseA = Arrays.asList(
new StaffPerformanceSubOrderDTO().setUpgradeGoodsId(1001),
new StaffPerformanceSubOrderDTO().setUpgradeGoodsId(2001)
);
// Case B: 变种匹配 (包含 1002 和 2001) -> 1002 也在 Group1 中,应匹配
List<StaffPerformanceSubOrderDTO> orderCaseB = Arrays.asList(
new StaffPerformanceSubOrderDTO().setUpgradeGoodsId(1002),
new StaffPerformanceSubOrderDTO().setUpgradeGoodsId(2001)
);
// Case C: 匹配失败 (缺 Group2)
List<StaffPerformanceSubOrderDTO> orderCaseC = Arrays.asList(
new StaffPerformanceSubOrderDTO().setUpgradeGoodsId(1001)
);
```
*
**断言验证 (Verify)**
:
*
`Assert.assertTrue("Case A Should Match", StaffPerformanceOrderUtil.matchesPackage(orderCaseA, packageDefine.getPackageItemList()));`
*
`Assert.assertTrue("Case B Should Match", StaffPerformanceOrderUtil.matchesPackage(orderCaseB, packageDefine.getPackageItemList()));`
*
`Assert.assertFalse("Case C Should Fail", StaffPerformanceOrderUtil.matchesPackage(orderCaseC, packageDefine.getPackageItemList()));`
---
### 3.3 P2 异常、边界与幂等性
#### TC-15: 月份格式错误 (Invalid Month Format)
*
**测试目标**
: 验证
`calStaffPerformance`
方法入口的正则校验。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 77)
*
**测试逻辑说明**
:
1.
**输入**
: 手机号正常,月份格式为
`2023/01`
(应为
`yyyy-MM`
)。
2.
**校验**
: 方法入口处检查
`month`
参数格式。
3.
**异常**
: 抛出
`RpcServiceException`
。
*
**执行逻辑**
:
*
调用
`calStaffPerformance("138...", "2023/01")`
.
*
**结果验证 (Expected Exception)**
:
*
捕获
`RpcServiceException`
.
*
验证
`e.getErrorCode()`
为
`DefaultErrorEnum.DATA_INVALID`
.
*
验证 Message 包含 "月份格式错误".
#### TC-16: 参数缺失 (NPE 防御)
*
**测试目标**
: 验证
`RpcAssert`
对必填参数的拦截。
*
**涉及代码**
:
`StaffPerformanceCalService.java`
(Line 75)
*
**测试逻辑说明**
:
1.
**输入**
: 手机号为
`null`
或月份为
`null`
。
2.
**校验**
:
`RpcAssert.notNull`
进行拦截。
3.
**异常**
: 抛出
`RpcServiceException`
(DATA_NULL)。
*
**执行逻辑**
:
*
调用
`calStaffPerformance(null, "2025-01")`
.
*
**结果验证**
:
*
捕获
`RpcServiceException`
.
*
验证
`e.getErrorCode()`
为
`DefaultErrorEnum.DATA_NULL`
.
*
验证 Message 包含 "员工手机号不能为空".
#### TC-17: 日报数据缺失 (Null Safety)
*
**测试目标**
: 验证
`calculateDailyDependencyData`
和
`DataCalUtil`
对空值的防御。
*
**涉及代码**
:
`calculateDailyDependencyData`
(Line 233)
*
**测试逻辑说明**
:
1.
**场景**
: Mapper 返回的触客数统计为
`null`
。
2.
**处理**
: DTO 字段被赋值为
`null`
。
3.
**计算**
: 在计算客单价时 (产值 / 触客数),调用
`DataCalUtil.divide`
。
4.
**安全机制**
: 工具类检测到除数为
`null`
或
`0`
,返回
`BigDecimal.ZERO`
,避免抛出
`ArithmeticException`
或
`NullPointerException`
。
*
**Mock 准备**
:
*
`staffPerformanceCalMapper.statPreSalesTouchCount`
均返回
`null`
.
*
**断言验证**
:
*
`dailyData.getPersonalTotalPreSalesTouchCount()`
应为
`null`
(或0,取决于Mapper实现,Service层似乎直接透传)。
*
**关键**
: 后续计算
`TOTAL_CUSTOMER_CONTACT_UNIT_PRICE`
时,调用
`DataCalUtil.divide(..., null)`
。
*
验证
`DataCalUtil.divide`
返回
`BigDecimal.ZERO`
且不抛出 NPE。
#### TC-18: 引荐数修正逻辑 (Referral Fallback)
*
**测试目标**
: 验证当有效引荐数为空时,自动回退使用系统交车数。
*
**涉及代码**
:
`calculateDailyDependencyData`
(Line 272)
*
**测试逻辑说明**
:
1.
**场景**
: 调用
`effectiveReferralReviewService`
获取修正数据。
2.
**分支**
:
*
若
`reviewedEffectiveCount`
(修正后引荐数) 不为
`null`
: 使用修正值。
*
若
`reviewedEffectiveCount`
为
`null`
: 回退使用
`totalDeliveryCount`
(系统统计交车数)。
3.
**目的**
: 确保在未进行人工修正时,计算仍有默认依据。
*
**Mock 准备**
:
*
`effectiveReferralReviewService.queryEffectiveReferralReview`
返回对象:
*
`reviewedEffectiveCount = null`
*
`totalDeliveryCount = 50`
*
**断言验证**
:
*
验证
`dailyData.getStoreValidRecommendationCount()`
等于
**50**
.
#### TC-19: 边界值测试 (Boundary Value)
*
**测试目标**
: 验证
`processPenetrationRateCondition`
区间判断的闭区间逻辑。
*
**涉及代码**
:
`processPenetrationRateCondition`
(Line 680)
*
**测试逻辑说明**
:
1.
**区间定义**
:
`[Start, End]`
(闭区间)。
2.
**判断逻辑**
:
`Start <= Rate <= End`
。
3.
**验证点**
:
*
Rate == Start: 应判断为 True (In Range).
*
Rate == End: 应判断为 True (In Range).
*
**Mock 准备**
:
*
**Config**
: Condition
`[10%, 20%]`
.
*
**Test 1**
: Mock rate =
`0.10`
.
*
**Test 2**
: Mock rate =
`0.20`
.
*
**断言验证**
:
*
两次测试均应通过区间判断 (
`inRange = true`
)。
*
`handleDegradation`
**不被调用**
。
---
## 4. 通用数据准备说明
### 基础数据 Mock 建议
*
**Mock Strategy**
: 所有外部依赖 (Mapper, RemoteService) 均采用 Mockito 模拟返回值,
**不依赖真实数据库**
。
*
**Merchant/Brand**
: 使用 ID=1 作为默认测试商户,ID=100 作为默认品牌,ID=101 作为子品牌。
*
**Time**
: 统一使用 "2025-01" 作为测试月份。
*
**User**
: defaultStaffPhone = "13800000000"。
### 关键 Mapper/Service Mock 列表
*
`StaffPerformanceSubOrderMapper.listStaffMonthSubOrders`
(Mock Orders)
*
`PerformanceConfigService.getEffectivePerformanceConfig`
(Mock Config)
*
`StaffPerformanceCalMapper.statPreSalesTouchCount`
(Mock Daily Data)
*
`EffectiveReferralReviewService.queryEffectiveReferralReview`
(Mock Referral)
*
`MerchantPerformanceProductDefineRemote.getProductDefine`
(Mock Product Definition)
*
`StaffBeisenBaseInfoService.getByStaffPhone`
(Mock Entry Date for Newcomer)
rpc-dj-staff/src/main/resources/design/TEST_PLAN_SQL.md
0 → 100644
View file @
61b2271
# 员工提成计算模块测试规划文档 (真实DB数据版)
> **文档说明**:本文档基于 `StaffPerformanceCalService.java` 及相关业务逻辑分析编写,旨在为测试开发提供详细的测试策略、用例设计及注意事项。
> **特别说明**:本版本包含详细的数据准备 SQL,适用于基于真实数据库的集成测试。所有测试数据 `created_by` 统一标识为 `caiym_test_staff_performance`,便于清理。
## 1. 测试策略 (Test Strategy)
### 1.1 测试目标
*
确保提成计算逻辑的准确性,覆盖所有商户规则配置。
*
验证数据依赖处理的正确性(订单、日报、引荐数)及考核因子计算准确性。
*
保障异常场景下的系统鲁棒性(数据缺失、格式错误)及接口幂等性。
### 1.2 测试范围
*
**代码入口**
:
`StaffPerformanceCalService.calStaffPerformance(String staffPhone, String month)`
*
**核心逻辑**
:
*
订单分组与数据聚合
*
考核因子依赖数据计算(含日报数据逻辑)
*
**考核因子实际值计算**
(12个核心因子)
*
提成配置匹配与阶梯计算
*
四大特殊条件处理(渗透率限制、扣减、奖励、剔除)
*
最终金额汇总及
**幂等性处理**
---
## 2. 测试用例总览 (Test Case Overview)
### 2.1 P0 - 核心主流程 (Happy Path)
| ID | 用例名称 | 场景简述 |
| :-------- | :--------------------- | :--------------------------------------- |
|
**TC-01**
| 单商户单订单基础计算 | 基础流程验证:单订单匹配固定配置。 |
|
**TC-20**
|
**系数与新人保护计算**
| 验证提成系数 (XS) 叠加及新人保护期逻辑。 |
### 2.2 P2 - 边界、异常与幂等性
| ID | 用例名称 | 场景简述 |
| :-------- | :--------- | :----------------------------------------- |
|
**TC-14**
| 幂等性验证 | 重复调用接口,验证数据一致性与旧数据清理。 |
### 2.3 补充说明
*
**注**
:原
`TEST_PLAN.md`
中包含的其他用例 (TC-02 ~ TC-13, TC-15 ~ TC-19) 暂时
**保留通过 Mock 方式测试**
,原因如下:
*
**TC-02 ~ TC-13 (复杂业务逻辑)**
:需要构造大量依赖数据(如 12 种考核因子、渗透率阶梯),使用真实 DB SQL 维护成本极高,建议继续沿用 Unit Test (Mock) 覆盖核心算法逻辑。
*
**TC-15 ~ TC-19 (异常处理)**
:主要验证代码层面的参数校验和 NPE 防御,不需要依赖复杂的真实数据库状态。
*
**本文档 (TEST_PLAN_SQL.md)**
仅聚焦于
**核心链路打通 (TC-01)**
、
**关键新增业务 (TC-20 系数与新人保护)**
以及
**数据持久化行为 (TC-14 幂等性)**
的真实 DB 集成验证。
---
## 3. 用例详细设计与数据准备 (Detailed Design & SQL)
### 3.1 TC-01: 单商户单订单基础计算
*
**测试目的**
: 验证最基础的单订单、单配置下的提成计算流程,确保链路通畅。
*
**前置条件**
:
1.
MySQL 中存在关联的商户、品牌基础数据。
2.
无历史提成数据干扰(或允许被逻辑删除)。
*
**数据准备 (SQL)**
:
```
sql
-- 1. 清理数据 (Cleanup)
DELETE
FROM
dj_car_life_staff_info
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_performance_config
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_performance_param_config
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_performance_config_merchant_brand_ref
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_goods_order
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_pay_order
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_goods_order_customer
WHERE
created_by
=
'caiym_test_staff_performance'
;
DELETE
FROM
dj_car_life_goods_sub_order
WHERE
created_by
=
'caiym_test_staff_performance'
;
-- 2. 准备 Staff 数据
INSERT
INTO
dj_car_life_staff_info
(
staff_uuid
,
staff_name
,
phone_number
,
merchant_id
,
merchant_name
,
register_time
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'staff_uuid_tc01'
,
'TC01_Staff'
,
'13800138001'
,
1
,
'测试商户1'
,
NOW
(),
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 3. 准备 Config 数据 (单配置)
-- 3.1 主配置
INSERT
INTO
dj_car_life_performance_config
(
scheme_name
,
scheme_type
,
business_type
,
effective_month
,
status
,
enable_flag
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'TC01_Scheme'
,
1
,
'1'
,
'2025-01'
,
2
,
'Y'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
SET
@
config_id_tc01
=
LAST_INSERT_ID
();
-- 3.2 商户品牌关联
INSERT
INTO
dj_car_life_performance_config_merchant_brand_ref
(
performance_config_id
,
merchant_id
,
merchant_name
,
brand_id
,
brand_name
,
child_id
,
child_name
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
@
config_id_tc01
,
1
,
'测试商户1'
,
100
,
'测试品牌'
,
101
,
'测试子品牌'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 3.3 参数配置 (个人月度总产值, 固定金额 100)
-- assessment_factor=1 (PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE)
-- goods_config_type=-1 (ALL_PRODUCT)
-- commission_type='GDJE'
-- commission_base='GMV' (枚举值必须为 GMV/SJDDS/DDTC 之一)
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
end_value
,
commission_base
,
commission_type
,
goods_config_type
,
commission_type_value
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
@
config_id_tc01
,
1
,
1
,
0
,
NULL
,
'GMV'
,
'GDJE'
,
-
1
,
100
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 4. 准备 Order 数据
-- 4.1 Goods Order (channel_type=2, status=4 为已支付)
INSERT
INTO
dj_car_life_goods_order
(
order_code
,
user_id
,
merchant_id
,
merchant_name
,
seller_user_id
,
status
,
channel_type
,
order_type
,
business_type
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'user_001'
,
1
,
'测试商户1'
,
'staff_uuid_tc01'
,
4
,
2
,
1
,
1
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 4.2 Pay Order (Success Date determines the month)
INSERT
INTO
dj_car_life_pay_order
(
order_code
,
success_date
,
pay_status
,
order_money
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'2025-01-15 10:00:00'
,
1
,
1000
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 4.3 Order Customer (Brand info)
INSERT
INTO
dj_car_life_goods_order_customer
(
order_code
,
customer_name
,
customer_phone
,
car_brand_id
,
car_childs_brand_id
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'Cust_TC01'
,
'13900000001'
,
100
,
101
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 4.4 Sub Order (Output Value)
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_thumb_url
,
base_shop_price
,
number
,
final_price
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC01_001'
,
'SUB_TC01_001'
,
1000
,
'GOODS_001'
,
'测试商品'
,
'test_thumb'
,
1000
.
00
,
1
,
1000
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
```
*
**执行步骤**
:
1.
执行上述 SQL 插入测试数据。
2.
调用核心计算接口:
`StaffPerformanceCalService.calStaffPerformance(staffPhone, month)`
*
入参
`staffPhone`
:
`"13800138001"`
*
入参
`month`
:
`"2025-01"`
*
**期望结果**
:
1.
返回 List size = 1。
2.
`performanceAmount`
== 100.00。
3.
`dj_car_life_staff_performance`
表新增一条记录。
### 3.2 TC-20: 系数与新人保护计算
*
**测试目的**
: 验证提成系数 (XS) 叠加及新人保护期逻辑(系数<1则重置为1)。
*
**前置条件**
: 需分别模拟“非新人”和“新人”两种场景。
*
**Case A: 非新人 (不在保护期)**
*
**Scenario**
: 入职日期 <= 绩效月份上个月的 15 号 (例如 2025-01 绩效,入职日期 <= 2024-12-15)。
*
**Expected**
: 系数正常叠加。
*
**Case B: 新人 (处于保护期)**
*
**Scenario**
: 入职日期 > 绩效月份上个月的 15 号 (例如 2025-01 绩效,入职日期 > 2024-12-15)。
*
**Expected**
: 若总系数 < 1.0,则强制重置为 1.0。
*
**数据准备 (SQL) - 以 Case B (新人) 为例**
:
```
sql
-- 1. 清理 (同上,略)
-- 2. 准备 Staff 数据 (新人 Case)
INSERT
INTO
dj_car_life_staff_info
(
staff_uuid
,
staff_name
,
phone_number
,
merchant_id
,
merchant_name
,
register_time
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'staff_uuid_tc20'
,
'TC20_Staff'
,
'13800138020'
,
1
,
'测试商户1'
,
NOW
(),
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 2.1 Beisen Base Info (关键:入职时间设置在保护期内,入职 > 2024-12-15,例如 2024-12-20)
-- 补充 trial_basic_salary = 5000.00
INSERT
INTO
dj_car_life_staff_beisen_base_info
(
staff_name
,
staff_phone
,
trial_basic_salary
,
entry_date
,
merchant_id
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'TC20_Staff'
,
'13800138020'
,
5000
.
00
,
'2024-12-20'
,
1
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 3. 准备 Config 数据 (含系数)
-- 3.1 主配置
INSERT
INTO
dj_car_life_performance_config
(
scheme_name
,
scheme_type
,
business_type
,
effective_month
,
status
,
enable_flag
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
'TC20_Scheme'
,
1
,
'1'
,
'2025-01'
,
2
,
'Y'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
SET
@
config_id_tc20
=
LAST_INSERT_ID
();
-- 3.2 商户品牌关联
INSERT
INTO
dj_car_life_performance_config_merchant_brand_ref
(
performance_config_id
,
merchant_id
,
merchant_name
,
brand_id
,
brand_name
,
child_id
,
child_name
,
created_by
,
updated_by
,
deleted_flag
)
VALUES
(
@
config_id_tc20
,
1
,
'测试商户1'
,
100
,
'测试品牌'
,
101
,
'测试子品牌'
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
'N'
);
-- 3.3 参数配置
-- 3.3.1 固定金额基数 (GDJE 100)
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
commission_base
,
commission_type
,
goods_config_type
,
commission_type_value
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
@
config_id_tc20
,
1
,
1
,
0
,
'GMV'
,
'GDJE'
,
-
1
,
100
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 3.3.2 系数 0.8 (XS 0.8) - 应该被保护机制覆盖
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
commission_base
,
commission_type
,
goods_config_type
,
commission_type_value
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
@
config_id_tc20
,
1
,
2
,
0
,
'GMV'
,
'XS'
,
-
1
,
0
.
80
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
-- 4. 准备 Order 数据 (确保产值能命中配置)
INSERT
INTO
dj_car_life_goods_order
(
order_code
,
user_id
,
merchant_id
,
merchant_name
,
seller_user_id
,
status
,
channel_type
,
order_type
,
business_type
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC20_001'
,
'user_020'
,
1
,
'测试商户1'
,
'staff_uuid_tc20'
,
4
,
2
,
1
,
1
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
INSERT
INTO
dj_car_life_pay_order
(
order_code
,
success_date
,
pay_status
,
order_money
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC20_001'
,
'2025-01-15 10:00:00'
,
1
,
1000
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
INSERT
INTO
dj_car_life_goods_order_customer
(
order_code
,
customer_name
,
customer_phone
,
car_brand_id
,
car_childs_brand_id
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC20_001'
,
'Cust_TC20'
,
'13900000020'
,
100
,
101
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_thumb_url
,
base_shop_price
,
number
,
final_price
,
created_by
,
updated_by
,
created_date
,
updated_date
,
deleted_flag
)
VALUES
(
'ORDER_TC20_001'
,
'SUB_TC20_001'
,
1000
,
'GOODS_020'
,
'测试商品20'
,
'test_thumb'
,
1000
.
00
,
1
,
1000
.
00
,
'caiym_test_staff_performance'
,
'caiym_test_staff_performance'
,
NOW
(),
NOW
(),
'N'
);
```
*
**执行步骤**
:
1.
执行上述 SQL (Case B) 插入数据。
2.
调用核心计算接口:
`StaffPerformanceCalService.calStaffPerformance(staffPhone, month)`
*
入参
`staffPhone`
:
`"13800138020"`
*
入参
`month`
:
`"2025-01"`
*
**期望结果**
:
1.
提成金额 = 100
*
1.0 (保护生效) = 100.00。
2.
若
`entry_date`
改为 '2024-12-01' (Case A,符合 <= 2024-12-15),则提成金额 = 100
*
0.8 = 80.00。
### 3.3 TC-14: 幂等性验证
*
**测试目的**
: 验证重复计算不会导致数据重复。
*
**数据准备**
: 复用 TC-01 的数据即可。
*
**执行步骤**
:
1.
执行 TC-01 的 SQL 脚本。
2.
**第 1 次调用**
核心计算接口:
*
方法:
`StaffPerformanceCalService.calStaffPerformance("13800138001", "2025-01")`
3.
查询数据库,记录
`dj_car_life_staff_performance`
表中产生的记录 ID。
4.
**第 2 次调用**
核心计算接口(参数完全一致):
*
方法:
`StaffPerformanceCalService.calStaffPerformance("13800138001", "2025-01")`
*
**期望结果**
:
1.
第2次调用成功,无报错。
2.
查询
`staff_performance`
表,该员工该月
**仍然只有1条有效记录**
(deleted_flag='N')。
3.
(可选) 检查旧记录是否被软删除 (deleted_flag='Y'),或者新记录是否覆盖了旧记录(取决于实现逻辑,通常是先删后插)。
rpc-dj-staff/src/main/resources/design/generate_conditions.py
0 → 100644
View file @
61b2271
import
random
import
datetime
# Configuration
config_ids
=
[
13
,
14
,
15
,
49
,
50
,
51
]
# 4 to 75 inclusive
created_by
=
'caiym_test_260123'
updated_by
=
'caiym_test_260123'
created_date
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
updated_date
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
# Goods Configurations
goods_combinations
=
{
-
1
:
[{
'type'
:
-
1
,
'name'
:
''
,
'sec_type'
:
-
1
,
'sec_name'
:
''
,
'third_type'
:
-
1
,
'third_name'
:
''
,
'prod_id'
:
None
,
'prod_name'
:
''
}],
0
:
[
{
'type'
:
146
,
'name'
:
'权益一级类目'
,
'sec_type'
:
-
1
,
'sec_name'
:
''
,
'third_type'
:
-
1
,
'third_name'
:
''
,
'prod_id'
:
None
,
'prod_name'
:
''
},
{
'type'
:
146
,
'name'
:
'权益一级类目'
,
'sec_type'
:
147
,
'sec_name'
:
'权益二级类目'
,
'third_type'
:
148
,
'third_name'
:
'权益三级类目'
,
'prod_id'
:
None
,
'prod_name'
:
''
},
{
'type'
:
146
,
'name'
:
'权益一级类目'
,
'sec_type'
:
147
,
'sec_name'
:
'权益二级类目'
,
'third_type'
:
-
1
,
'third_name'
:
''
,
'prod_id'
:
None
,
'prod_name'
:
''
},
{
'type'
:
102
,
'name'
:
'11122'
,
'sec_type'
:
-
1
,
'sec_name'
:
''
,
'third_type'
:
-
1
,
'third_name'
:
''
,
'prod_id'
:
None
,
'prod_name'
:
''
},
{
'type'
:
114
,
'name'
:
'延保类'
,
'sec_type'
:
149
,
'sec_name'
:
'延保类二级'
,
'third_type'
:
150
,
'third_name'
:
'延保类三级'
,
'prod_id'
:
None
,
'prod_name'
:
''
}
],
1
:
[
{
'type'
:
None
,
'name'
:
''
,
'sec_type'
:
None
,
'sec_name'
:
''
,
'third_type'
:
None
,
'third_name'
:
''
,
'prod_id'
:
32
,
'prod_name'
:
'圈定产品1'
},
{
'type'
:
None
,
'name'
:
''
,
'sec_type'
:
None
,
'sec_name'
:
''
,
'third_type'
:
None
,
'third_name'
:
''
,
'prod_id'
:
33
,
'prod_name'
:
'圈定产品2'
}
],
2
:
[
{
'type'
:
None
,
'name'
:
''
,
'sec_type'
:
None
,
'sec_name'
:
''
,
'third_type'
:
None
,
'third_name'
:
''
,
'prod_id'
:
34
,
'prod_name'
:
'圈定套餐3'
}
]
}
values_list
=
[]
for
config_id
in
config_ids
:
condition_type
=
random
.
choice
([
1
,
2
,
3
,
4
])
# Defaults
goods_config_type
=
None
goods_info
=
{
'type'
:
None
,
'name'
:
None
,
'sec_type'
:
None
,
'sec_name'
:
None
,
'third_type'
:
None
,
'third_name'
:
None
,
'prod_id'
:
None
,
'prod_name'
:
None
}
assessment_factors
=
'0'
start_value
=
0.00
end_value
=
0.00
commission_base
=
'GMV'
commission_type
=
''
commission_type_value
=
0.00
# Logic per condition type
if
condition_type
==
1
:
# 渗透率限制
# Needs goods info
goods_config_type
=
random
.
choice
([
-
1
,
0
,
1
,
2
])
goods_info
=
random
.
choice
(
goods_combinations
[
goods_config_type
])
assessment_factors
=
'3'
end_value
=
round
(
random
.
uniform
(
1
,
10
),
2
)
elif
condition_type
==
2
:
# 订单数不足扣减
# No goods info
end_value
=
round
(
random
.
uniform
(
1
,
10
),
2
)
elif
condition_type
==
3
:
# 整体指标达成奖励
# No goods info
commission_type
=
'DDJE'
commission_type_value
=
round
(
random
.
uniform
(
100
,
1000
),
2
)
elif
condition_type
==
4
:
# 订单数剔除/包含
# Needs goods info
goods_config_type
=
random
.
choice
([
-
1
,
0
,
1
,
2
])
goods_info
=
random
.
choice
(
goods_combinations
[
goods_config_type
])
# SQL Generation
# Handling None values for SQL
def
sql_val
(
val
):
return
f
"'{val}'"
if
val
is
not
None
else
"NULL"
def
sql_num
(
val
):
return
str
(
val
)
if
val
is
not
None
else
"NULL"
value_tuple
=
f
"({config_id}, {condition_type}, {sql_num(goods_config_type)}, "
\
f
"{sql_num(goods_info['type'])}, {sql_val(goods_info['name'])}, {sql_num(goods_info['sec_type'])}, {sql_val(goods_info['sec_name'])}, "
\
f
"{sql_num(goods_info['third_type'])}, {sql_val(goods_info['third_name'])}, {sql_num(goods_info['prod_id'])}, "
\
f
"{sql_val(goods_info['prod_name'])}, '{assessment_factors}', {start_value}, {end_value}, "
\
f
"'{commission_base}', '{commission_type}', {commission_type_value}, "
\
f
"'{created_by}', '{created_date}', '{updated_by}', '{updated_date}', 'N')"
values_list
.
append
(
value_tuple
)
# Generate final SQL
insert_prefix
=
"INSERT INTO dj_car_life_performance_param_config_condition "
\
"(performance_param_config_id, condition_type, condition_goods_config_type, "
\
"condition_goods_type, condition_goods_type_name, condition_secondary_goods_type, condition_secondary_goods_type_name, "
\
"condition_third_level_goods_type, condition_third_level_goods_type_name, condition_product_define_id, "
\
"condition_product_define_name, condition_assessment_factors, condition_start_value, condition_end_value, "
\
"condition_commission_base, condition_commission_type, condition_commission_type_value, "
\
"created_by, created_date, updated_by, updated_date, deleted_flag) VALUES
\n
"
full_sql
=
insert_prefix
+
",
\n
"
.
join
(
values_list
)
+
";"
# Output to file
output_file
=
r'e:\code\260210工资绩效\rpc-staff\rpc-dj-staff\src\main\resources\design\260210_insert_conditions.sql'
with
open
(
output_file
,
'w'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
full_sql
)
print
(
f
"Generated multi-row INSERT SQL to {output_file}"
)
rpc-dj-staff/src/main/resources/design/init_test_data_202512.sql
0 → 100644
View file @
61b2271
-- 1.3 Insert Beisen Info
INSERT
INTO
dj_car_life_staff_beisen_base_info
(
staff_name
,
staff_phone
,
entry_date
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
'天明哥哥'
,
'15626599735'
,
'2025-12-10'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
'明明崇文园区店员工01'
,
'15626599738'
,
'2025-12-20'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- 1.4 Insert Product Definitions & Items
-- Define 1: Product (Goods A + B)
INSERT
INTO
dj_car_life_merchant_performance_product_define
(
define_type
,
define_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
1
,
'圈定产品1'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
SET
@
def_id_1
=
LAST_INSERT_ID
();
INSERT
INTO
dj_car_life_merchant_performance_product_define_item
(
product_define_id
,
item_id
,
item_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
@
def_id_1
,
102031
,
'权益一级260123'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Goods A
(
@
def_id_1
,
102018
,
'权益三级至臻多规格'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- Goods B
-- Define 2: Product (Goods C + D)
INSERT
INTO
dj_car_life_merchant_performance_product_define
(
define_type
,
define_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
1
,
'圈定产品2'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
SET
@
def_id_2
=
LAST_INSERT_ID
();
INSERT
INTO
dj_car_life_merchant_performance_product_define_item
(
product_define_id
,
item_id
,
item_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
@
def_id_2
,
101673
,
'权益二级25011301c'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Goods C
(
@
def_id_2
,
101956
,
'20250514权益第三方商品'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- Goods D
-- Define 3: Package (Def 1 + Def 2)
INSERT
INTO
dj_car_life_merchant_performance_product_define
(
define_type
,
define_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
2
,
'圈定套餐3'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
SET
@
def_id_3
=
LAST_INSERT_ID
();
INSERT
INTO
dj_car_life_merchant_performance_product_define_item
(
product_define_id
,
item_id
,
item_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
@
def_id_3
,
@
def_id_1
,
'圈定产品1'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
def_id_3
,
@
def_id_2
,
'圈定产品2'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- =================================================================================================
-- Step 2: Main Configuration Generation
-- =================================================================================================
-- 2.1 Performance Config A (New Car - Business Type 1)
INSERT
INTO
dj_car_life_performance_config
(
scheme_name
,
scheme_type
,
business_type
,
effective_month
,
status
,
enable_flag
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
'权益方案_cymtest_202512'
,
1
,
'1'
,
'2025-12'
,
2
,
'Y'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
SET
@
config_id_A
=
LAST_INSERT_ID
();
-- 2.2 Performance Config B (Used Car - Business Type 2)
INSERT
INTO
dj_car_life_performance_config
(
scheme_name
,
scheme_type
,
business_type
,
effective_month
,
status
,
enable_flag
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
'延保方案_cymtest_202512'
,
1
,
'2'
,
'2025-12'
,
2
,
'Y'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
SET
@
config_id_B
=
LAST_INSERT_ID
();
-- 2.3 Merchant & Brand Bindings (Refs)
-- We need to bind BOTH configs (A & B) to ALL 4 Brands and BOTH Merchants (AG, AF)
-- Helper to insert bindings for a specific config
-- Merchants: 44217734 (AG), 44217732 (AF)
-- Brands:
-- 1. AITO: 2978 / 3454
-- 2. STEL: 2978 / 3547
-- 3. AUDI: 2125 / 2127
-- 4. BYD: 2365 / 2695
INSERT
INTO
dj_car_life_performance_config_merchant_brand_ref
(
performance_config_id
,
merchant_id
,
merchant_name
,
brand_id
,
brand_name
,
child_id
,
child_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
-- Config A (New Car)
(
@
config_id_A
,
44217734
,
'明天集团4s店AG'
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_A
,
44217734
,
'明天集团4s店AG'
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_A
,
44217734
,
'明天集团4s店AG'
,
2125
,
'奥迪'
,
2127
,
'Audi Sport'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_A
,
44217734
,
'明天集团4s店AG'
,
2365
,
'比亚迪'
,
2695
,
'比亚迪'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_A
,
44217732
,
'明天集团4s店AF'
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_A
,
44217732
,
'明天集团4s店AF'
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_A
,
44217732
,
'明天集团4s店AF'
,
2125
,
'奥迪'
,
2127
,
'Audi Sport'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_A
,
44217732
,
'明天集团4s店AF'
,
2365
,
'比亚迪'
,
2695
,
'比亚迪'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Config B (Used Car)
(
@
config_id_B
,
44217734
,
'明天集团4s店AG'
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_B
,
44217734
,
'明天集团4s店AG'
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_B
,
44217734
,
'明天集团4s店AG'
,
2125
,
'奥迪'
,
2127
,
'Audi Sport'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_B
,
44217734
,
'明天集团4s店AG'
,
2365
,
'比亚迪'
,
2695
,
'比亚迪'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_B
,
44217732
,
'明天集团4s店AF'
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_B
,
44217732
,
'明天集团4s店AF'
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_B
,
44217732
,
'明天集团4s店AF'
,
2125
,
'奥迪'
,
2127
,
'Audi Sport'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_id_B
,
44217732
,
'明天集团4s店AF'
,
2365
,
'比亚迪'
,
2695
,
'比亚迪'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- =================================================================================================
-- Step 3: Parameter Configuration Generation
-- =================================================================================================
-- 3.1 Function/Procedure to insert params (Simulated by repeating blocks or just long values)
-- We will insert for Config A (@config_id_A) and Config B (@config_id_B)
-- Factors 1-12 (Assumed Codes based on Enum)
-- ASSESSMENT_FACTOR codes:
-- 1: PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE
-- 2: PERSONAL_MONTHLY_SINGLE_STORE_OUTPUT_VALUE
-- 3: PERSONAL_CUSTOMER_PENETRATION_RATE
-- 4: PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE
-- 5: HIGH_CUSTOMER_UNIT_PRICE
-- 6: TOTAL_CUSTOMER_CONTACT_UNIT_PRICE
-- 7: CUSTOMER_CONTACT_UNIT_PRICE
-- 8: UPGRADE_UNIT_PRICE
-- 9: DELIVERY_UNIT_PRICE
-- 10: STORE_CUSTOMER_CONTACT_RATE_DELIVERY
-- 11: STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL
-- 12: UPGRADE_ORDER_QUANTITY
-- Prepare variables for reuse
SET
@
config_A
=
@
config_id_A
;
SET
@
config_B
=
@
config_id_B
;
-- Loop logic is hard in plain SQL script without procedures, so we generate rows.
-- We will use a huge INSERT statement for efficiency.
-- Config A (New Car) - 12 Factors * 3 Tiers = 36 rows
delete
from
dj_car_life_performance_param_config
where
created_by
=
'caiym_test_260123'
;
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
end_value
,
commission_base
,
commission_type
,
commission_type_value
,
goods_config_type
,
goods_type
,
goods_type_name
,
secondary_goods_type
,
secondary_goods_type_name
,
third_level_goods_type
,
third_level_goods_type_name
,
product_define_id
,
product_define_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
-- Factor 1: PERSONAL_MONTHLY_TOTAL_OUTPUT_VALUE (Tier 1: 0-10000, Type BL 1%)
(
@
config_A
,
1
,
1
,
0
,
10000
,
'GMV'
,
'BL'
,
0
.
01
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 1 (Tier 2: 10000-50000, Type BL 2%)
(
@
config_A
,
1
,
1
,
10000
,
50000
,
'GMV'
,
'BL'
,
0
.
02
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 1 (Tier 3: 50000+, Type BL 3%)
(
@
config_A
,
1
,
1
,
50000
,
9999999
,
'GMV'
,
'BL'
,
0
.
03
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 2: PERSONAL_MONTHLY_SINGLE_STORE_OUTPUT_VALUE (Fixed Reward)
(
@
config_A
,
1
,
1
,
0
,
10000
,
'GMV'
,
'GDJE'
,
100
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
1
,
10000
,
50000
,
'GMV'
,
'GDJE'
,
500
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
1
,
50000
,
9999999
,
'GMV'
,
'GDJE'
,
1000
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 3: PERSONAL_CUSTOMER_PENETRATION_RATE (Rate Tiers: 0-10%, 10-20%, 20%+)
(
@
config_A
,
1
,
3
,
0
,
10
,
'ORDER_COUNT'
,
'GDJE'
,
50
,
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_1
,
'圈定产品1'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
3
,
10
,
20
,
'ORDER_COUNT'
,
'GDJE'
,
150
,
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_1
,
'圈定产品1'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
3
,
20
,
100
,
'ORDER_COUNT'
,
'GDJE'
,
300
,
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_1
,
'圈定产品1'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 4: PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE (Using Define 1)
(
@
config_A
,
1
,
4
,
0
,
10
,
'ORDER_COUNT'
,
'GDJE'
,
60
,
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_2
,
'圈定产品2'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
4
,
10
,
20
,
'ORDER_COUNT'
,
'GDJE'
,
160
,
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_2
,
'圈定产品2'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
4
,
20
,
100
,
'ORDER_COUNT'
,
'GDJE'
,
360
,
1
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_2
,
'圈定产品2'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 5 (High Unit Price)
(
@
config_A
,
1
,
5
,
0
,
1000
,
'GMV'
,
'GDJE'
,
10
,
2
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_3
,
'圈定套餐3'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
5
,
1000
,
2000
,
'GMV'
,
'GDJE'
,
20
,
2
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_3
,
'圈定套餐3'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
5
,
2000
,
999999
,
'GMV'
,
'GDJE'
,
30
,
2
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
@
def_id_3
,
'圈定套餐3'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factors 6-12 (Simplified loop for variety, using GOODS_TYPE 146 default)
-- Factor 6
(
@
config_A
,
1
,
6
,
0
,
100
,
'GMV'
,
'GDJE'
,
5
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
6
,
100
,
500
,
'GMV'
,
'GDJE'
,
15
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
6
,
500
,
999999
,
'GMV'
,
'GDJE'
,
25
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 7
(
@
config_A
,
1
,
7
,
0
,
100
,
'GMV'
,
'GDJE'
,
6
,
0
,
146
,
'权益一级类目'
,
147
,
'权益二级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
7
,
100
,
500
,
'GMV'
,
'GDJE'
,
16
,
0
,
146
,
'权益一级类目'
,
147
,
'权益二级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
7
,
500
,
999999
,
'GMV'
,
'GDJE'
,
26
,
0
,
146
,
'权益一级类目'
,
147
,
'权益二级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 8
(
@
config_A
,
1
,
8
,
0
,
100
,
'GMV'
,
'GDJE'
,
8
,
0
,
146
,
'权益一级类目'
,
148
,
'权益二级类目'
,
148
,
'权益三级类目'
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
8
,
100
,
500
,
'GMV'
,
'GDJE'
,
18
,
0
,
146
,
'权益一级类目'
,
148
,
'权益二级类目'
,
148
,
'权益三级类目'
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
8
,
500
,
999999
,
'GMV'
,
'GDJE'
,
28
,
0
,
146
,
'权益一级类目'
,
148
,
'权益二级类目'
,
148
,
'权益三级类目'
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 9
(
@
config_A
,
1
,
9
,
0
,
100
,
'GMV'
,
'GDJE'
,
9
,
0
,
114
,
'延保类'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
9
,
100
,
500
,
'GMV'
,
'GDJE'
,
19
,
0
,
114
,
'延保类'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
9
,
500
,
999999
,
'GMV'
,
'GDJE'
,
29
,
0
,
114
,
'延保类'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 10
(
@
config_A
,
1
,
10
,
0
,
100
,
'GMV'
,
'GDJE'
,
10
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
10
,
100
,
500
,
'GMV'
,
'GDJE'
,
20
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
10
,
500
,
999999
,
'GMV'
,
'GDJE'
,
30
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 11
(
@
config_A
,
1
,
11
,
0
,
100
,
'GMV'
,
'GDJE'
,
11
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
11
,
100
,
500
,
'GMV'
,
'GDJE'
,
21
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
11
,
500
,
999999
,
'GMV'
,
'GDJE'
,
31
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Factor 12
(
@
config_A
,
1
,
12
,
0
,
100
,
'GMV'
,
'GDJE'
,
12
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
12
,
100
,
500
,
'GMV'
,
'GDJE'
,
22
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
@
config_A
,
1
,
12
,
500
,
999999
,
'GMV'
,
'GDJE'
,
32
,
0
,
146
,
'权益一级类目'
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
NULL
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- Config B (Used Car) - Cloning structure of A but pointing to Config B
INSERT
INTO
dj_car_life_performance_param_config
(
performance_config_id
,
template_type
,
assessment_factor
,
start_value
,
end_value
,
commission_base
,
commission_type
,
commission_type_value
,
goods_config_type
,
goods_type
,
goods_type_name
,
product_define_id
,
product_define_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
SELECT
@
config_B
,
1
,
assessment_factor
,
start_value
,
end_value
,
commission_base
,
commission_type
,
commission_type_value
,
goods_config_type
,
goods_type
,
goods_type_name
,
product_define_id
,
product_define_name
,
created_by
,
NOW
(),
updated_by
,
NOW
(),
deleted_flag
FROM
dj_car_life_performance_param_config
WHERE
performance_config_id
=
@
config_A
;
-- Copy properties from A to B for simplicity and coverage
-- =================================================================================================
-- Step 4: Order Data Generation (Stored Procedure for 124 Orders)
-- =================================================================================================
DROP
PROCEDURE
IF
EXISTS
sp_generate_test_orders_202512
;
DELIMITER
$$
CREATE
PROCEDURE
sp_generate_test_orders_202512
()
BEGIN
DECLARE
v_staff_idx
INT
DEFAULT
0
;
DECLARE
v_merch_idx
INT
DEFAULT
0
;
DECLARE
v_combo
INT
DEFAULT
1
;
DECLARE
v_staff_uuid
VARCHAR
(
32
);
DECLARE
v_staff_name
VARCHAR
(
100
);
DECLARE
v_merchant_id
INT
;
DECLARE
v_merchant_name
VARCHAR
(
100
);
DECLARE
v_order_code
VARCHAR
(
32
);
DECLARE
v_bus_type
INT
;
DECLARE
v_brand_rand
INT
;
DECLARE
v_car_brand_id
INT
;
DECLARE
v_car_brand_name
VARCHAR
(
100
);
DECLARE
v_child_brand_id
INT
;
DECLARE
v_child_brand_name
VARCHAR
(
100
);
DECLARE
v_oid
INT
;
-- Staff Loop (0: Tianming, 1: Mingming)
WHILE
v_staff_idx
<
2
DO
IF
v_staff_idx
=
0
THEN
SET
v_staff_uuid
=
'304c01b8abf14db581606ce42e35ede5'
;
-- Tianming
SET
v_staff_name
=
'天明哥哥'
;
ELSE
SET
v_staff_uuid
=
'8d3f61299d024a3dbe685687c756866d'
;
-- Mingming
SET
v_staff_name
=
'明明崇文园区店员工01'
;
END
IF
;
-- Merchant Loop (0: AG, 1: AF)
SET
v_merch_idx
=
0
;
WHILE
v_merch_idx
<
2
DO
IF
v_merch_idx
=
0
THEN
SET
v_merchant_id
=
44217734
;
-- AG
SET
v_merchant_name
=
'明天集团4s店AG'
;
ELSE
SET
v_merchant_id
=
44217732
;
-- AF
SET
v_merchant_name
=
'明天集团4s店AF'
;
END
IF
;
-- Combination Loop (1 to 31)
SET
v_combo
=
1
;
WHILE
v_combo
<=
31
DO
-- Generate basic order info
SET
v_order_code
=
CONCAT
(
'ORD_T_'
,
v_staff_idx
,
'_'
,
v_merch_idx
,
'_'
,
v_combo
,
'_'
,
FLOOR
(
RAND
()
*
10000
));
SET
v_bus_type
=
FLOOR
(
1
+
RAND
()
*
2
);
-- 1 or 2
-- Random Brand (0-3)
SET
v_brand_rand
=
FLOOR
(
RAND
()
*
4
);
IF
v_brand_rand
=
0
THEN
SET
v_car_brand_id
=
2978
;
SET
v_car_brand_name
=
'鸿蒙智行'
;
SET
v_child_brand_id
=
3454
;
SET
v_child_brand_name
=
'AITO 问界'
;
ELSEIF
v_brand_rand
=
1
THEN
SET
v_car_brand_id
=
2978
;
SET
v_car_brand_name
=
'鸿蒙智行'
;
SET
v_child_brand_id
=
3547
;
SET
v_child_brand_name
=
'尚界'
;
ELSEIF
v_brand_rand
=
2
THEN
SET
v_car_brand_id
=
2125
;
SET
v_car_brand_name
=
'奥迪'
;
SET
v_child_brand_id
=
2127
;
SET
v_child_brand_name
=
'Audi Sport'
;
ELSE
SET
v_car_brand_id
=
2365
;
SET
v_car_brand_name
=
'比亚迪'
;
SET
v_child_brand_id
=
2695
;
SET
v_child_brand_name
=
'比亚迪'
;
END
IF
;
-- 4.1 Insert Main Order
INSERT
INTO
dj_car_life_goods_order
(
order_code
,
channel_type
,
merchant_id
,
merchant_name
,
seller_user_id
,
seller_name
,
scene_type
,
business_type
,
order_time
,
final_price
,
total_price
,
status
,
upgrade_flag
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
v_order_code
,
1
,
v_merchant_id
,
v_merchant_name
,
v_staff_uuid
,
v_staff_name
,
0
,
v_bus_type
,
'2025-12-15 10:00:00'
,
1000
.
00
,
1000
.
00
,
4
,
'Y'
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- 4.2 Insert Pay Order
INSERT
INTO
dj_car_life_pay_order
(
order_code
,
order_money
,
out_trade_no
,
trade_no
,
pay_type
,
success_date
,
pay_status
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
v_order_code
,
1000
,
DATE_FORMAT
(
now
(),
'%Y%m%d%H%i%s'
),
DATE_FORMAT
(
now
(),
'%Y%m%d%H%i%s'
),
2
,
'2025-12-15 10:00:00'
,
2
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- 4.3 Insert Order Customer
INSERT
INTO
dj_car_life_goods_order_customer
(
order_code
,
customer_phone
,
customer_name
,
customer_id
,
car_brand_id
,
car_brand
,
car_childs_brand_id
,
car_childs_brand_name
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
(
v_order_code
,
'13800138000'
,
'张三'
,
11111
,
v_car_brand_id
,
v_car_brand_name
,
v_child_brand_id
,
v_child_brand_name
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- 4.4 Insert Sub Orders based on Combination bits
-- Bit 1 (1): Goods A (102031)
IF
(
v_combo
&
1
)
>
0
THEN
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
upgrade_goods_id
,
upgrade_goods_name
,
upgrade_goods_type
,
upgrade_goods_type_name
,
upgrade_secondary_goods_type
,
upgrade_secondary_goods_type_name
,
upgrade_third_level_goods_type
,
upgrade_third_level_goods_type_name
,
total_price
,
final_price
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_shop_price
,
base_thumb_url
)
VALUES
(
v_order_code
,
CONCAT
(
v_order_code
,
'_A'
),
102031
,
'权益一级260123'
,
146
,
'权益一级类目'
,
-
1
,
''
,
-
1
,
''
,
100
.
00
,
100
.
00
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
,
111
,
'111'
,
'111'
,
100
,
'111'
);
END
IF
;
-- Bit 2 (2): Goods B (102018)
IF
(
v_combo
&
2
)
>
0
THEN
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
upgrade_goods_id
,
upgrade_goods_name
,
upgrade_goods_type
,
upgrade_goods_type_name
,
upgrade_secondary_goods_type
,
upgrade_secondary_goods_type_name
,
upgrade_third_level_goods_type
,
upgrade_third_level_goods_type_name
,
total_price
,
final_price
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_shop_price
,
base_thumb_url
)
VALUES
(
v_order_code
,
CONCAT
(
v_order_code
,
'_B'
),
102018
,
'权益三级至臻多规格'
,
146
,
'权益一级类目'
,
147
,
'权益二级类目'
,
148
,
'权益三级类目'
,
200
.
00
,
200
.
00
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
,
111
,
'111'
,
'111'
,
100
,
'111'
);
END
IF
;
-- Bit 3 (4): Goods C (101673)
IF
(
v_combo
&
4
)
>
0
THEN
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
upgrade_goods_id
,
upgrade_goods_name
,
upgrade_goods_type
,
upgrade_goods_type_name
,
upgrade_secondary_goods_type
,
upgrade_secondary_goods_type_name
,
upgrade_third_level_goods_type
,
upgrade_third_level_goods_type_name
,
total_price
,
final_price
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_shop_price
,
base_thumb_url
)
VALUES
(
v_order_code
,
CONCAT
(
v_order_code
,
'_C'
),
101673
,
'权益二级25011301c'
,
146
,
'权益一级类目'
,
147
,
'权益二级类目'
,
-
1
,
''
,
300
.
00
,
300
.
00
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
,
111
,
'111'
,
'111'
,
100
,
'111'
);
END
IF
;
-- Bit 4 (8): Goods D (101956)
IF
(
v_combo
&
8
)
>
0
THEN
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
upgrade_goods_id
,
upgrade_goods_name
,
upgrade_goods_type
,
upgrade_goods_type_name
,
upgrade_secondary_goods_type
,
upgrade_secondary_goods_type_name
,
upgrade_third_level_goods_type
,
upgrade_third_level_goods_type_name
,
total_price
,
final_price
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_shop_price
,
base_thumb_url
)
VALUES
(
v_order_code
,
CONCAT
(
v_order_code
,
'_D'
),
101956
,
'20250514权益第三方商品'
,
102
,
'11122'
,
-
1
,
''
,
-
1
,
''
,
400
.
00
,
400
.
00
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
,
111
,
'111'
,
'111'
,
100
,
'111'
);
END
IF
;
-- Bit 5 (16): Goods E (101669)
IF
(
v_combo
&
16
)
>
0
THEN
INSERT
INTO
dj_car_life_goods_sub_order
(
order_code
,
sub_order_code
,
upgrade_goods_id
,
upgrade_goods_name
,
upgrade_goods_type
,
upgrade_goods_type_name
,
upgrade_secondary_goods_type
,
upgrade_secondary_goods_type_name
,
upgrade_third_level_goods_type
,
upgrade_third_level_goods_type_name
,
total_price
,
final_price
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
,
base_goods_id
,
base_goods_code
,
base_goods_name
,
base_shop_price
,
base_thumb_url
)
VALUES
(
v_order_code
,
CONCAT
(
v_order_code
,
'_E'
),
101669
,
'延保三级25011301a'
,
114
,
'延保类'
,
149
,
'延保类二级'
,
150
,
'延保类三级'
,
500
.
00
,
500
.
00
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
,
111
,
'111'
,
'111'
,
100
,
'111'
);
END
IF
;
SET
v_combo
=
v_combo
+
1
;
END
WHILE
;
SET
v_merch_idx
=
v_merch_idx
+
1
;
END
WHILE
;
SET
v_staff_idx
=
v_staff_idx
+
1
;
END
WHILE
;
END
$$
DELIMITER
;
-- Execute the procedure
CALL
sp_generate_test_orders_202512
();
-- Cleanup
DROP
PROCEDURE
sp_generate_test_orders_202512
;
-- =================================================================================================
-- Step 5: Supporting Data Generation
-- =================================================================================================
-- 5.1 Daily Reports (Huawei)
-- Generating entries for mid-month to ensure data coverage
-- Staff: Tianming (AG, AF), Mingming (AG, AF)
-- Dates: 2025-12-01, 2025-12-15, 2025-12-30
delete
from
dj_car_life_staff_daily_report_huawei
where
created_by
=
'caiym_test_260123'
;
INSERT
INTO
dj_car_life_staff_daily_report_huawei
(
report_id
,
merchant_id
,
merchant_name
,
yq_merchant_id
,
yq_merchant_name
,
staff_uuid
,
staff_name
,
report_date
,
scene_type
,
first_brand_id
,
first_brand_name
,
brand_id
,
brand_name
,
staff_count
,
equity_to_shop_count
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
-- Tianming - AG - 2978 -鸿蒙智行 - 3454 - AITO 问界
(
1001
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1002
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1003
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Tianming - AG - 2978 -鸿蒙智行 - 3547 - 尚界
(
1001
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1002
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1003
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Tianming - AG - -1 -其他品牌 - -1 - 其他品牌
(
1001
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-01'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1002
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-15'
,
0
,
2125
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1003
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-30'
,
0
,
2125
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Tianming - AF - 2978 -鸿蒙智行 - 3454 - AITO 问界
(
1004
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1005
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1006
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Tianming - AF - 2978 -鸿蒙智行 - 3547 - 尚界
(
1007
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1008
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1009
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Tianming - AF - -1 -其他品牌 - -1 - 其他品牌
(
1010
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-01'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1011
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-15'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
1012
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'304c01b8abf14db581606ce42e35ede5'
,
'天明哥哥'
,
'2025-12-30'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Mingming - AG - 2978 -鸿蒙智行 - 3454 - AITO 问界
(
2001
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2002
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2003
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Mingming - AG - 2978 -鸿蒙智行 - 3547 - 尚界
(
2004
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2005
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2006
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Mingming - AG - -1 -其他品牌 - -1 - 其他品牌
(
2007
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-01'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2008
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-15'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2009
,
44217734
,
'明天集团4s店AG'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-30'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Mingming - AF - 2978 -鸿蒙智行 - 3454 - AITO 问界
(
2004
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2005
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2006
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3454
,
'AITO 问界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Mingming - AF - 2978 -鸿蒙智行 - 3547 - 尚界
(
2004
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-01'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2005
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-15'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2006
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-30'
,
0
,
2978
,
'鸿蒙智行'
,
3547
,
'尚界'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- Mingming - AF - -1 -其他品牌 - -1 - 其他品牌
(
2007
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-01'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2008
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-15'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
2009
,
44217732
,
'明天集团4s店AF'
,
0
,
''
,
'8d3f61299d024a3dbe685687c756866d'
,
'明明崇文园区店员工01'
,
'2025-12-30'
,
0
,
-
1
,
'其他品牌'
,
-
1
,
'其他品牌'
,
10
,
5
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- 5.2 Effective Referrals
-- 2 Merchants * 4 Brands = 8 rows
delete
from
sal_effective_referral_review
where
created_by
=
'caiym_test_260123'
;
INSERT
INTO
sal_effective_referral_review
(
merchant_id
,
review_month
,
total_delivery_count
,
area_effective_count
,
reviewed_effective_count
,
status
,
brand_id
,
brand_name
,
scene_type
,
is_need_reviewed
,
is_reviewed
,
created_by
,
created_date
,
updated_by
,
updated_date
,
deleted_flag
)
VALUES
-- AG (44217734)
(
44217734
,
'2025-12'
,
10
,
10
,
8
,
1
,
2978
,
'鸿蒙智行'
,
0
,
1
,
1
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
44217734
,
'2025-12'
,
10
,
10
,
null
,
1
,
3547
,
'尚界'
,
0
,
1
,
1
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- assuming brand_id for Shangjie
(
44217734
,
'2025-12'
,
10
,
10
,
6
,
1
,
-
1
,
'其他品牌'
,
0
,
1
,
1
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
-- AF (44217732)
(
44217732
,
'2025-12'
,
10
,
10
,
7
,
1
,
3454
,
'AITO 问界'
,
0
,
1
,
1
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
44217732
,
'2025-12'
,
10
,
10
,
6
,
1
,
3547
,
'尚界'
,
0
,
1
,
1
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
),
(
44217732
,
'2025-12'
,
10
,
10
,
null
,
1
,
-
1
,
'其他品牌'
,
0
,
1
,
1
,
'caiym_test_260123'
,
NOW
(),
'caiym_test_260123'
,
NOW
(),
'N'
);
-- End of Script
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment