Commit f1eb9927 by 叶立庆

Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0

2 parents 47d53f05 a87fddaf
package cn.com.glsx.dj.staff.enums.perfSalary;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;
/**
* 有效转介绍审核状态枚举
*/
@Getter
@AllArgsConstructor
public enum EffectiveReferralReviewStatusEnum {
NOT_SUBMITTED(0, "未提交"),
DRAFT(1, "草稿"),
SUBMITTED(2, "已提交");
/**
* 状态编码
*/
private final Integer code;
/**
* 状态描述
*/
private final String description;
/**
* 根据编码获取枚举
*
* @param code 编码
* @return 对应的枚举,找不到时返回null
*/
public static EffectiveReferralReviewStatusEnum getByCode(Integer code) {
if (code == null) {
return null;
}
for (EffectiveReferralReviewStatusEnum status : EffectiveReferralReviewStatusEnum.values()) {
if (status.getCode().equals(code)) {
return status;
}
}
return null;
}
/**
* 根据编码获取描述
*
* @param code 编码
* @return 描述,找不到时返回null
*/
public static String getDescriptionByCode(Integer code) {
EffectiveReferralReviewStatusEnum status = getByCode(code);
return status != null ? status.getDescription() : null;
}
/**
* 根据描述获取枚举
*
* @param description 描述
* @return 对应的枚举,找不到时返回null
*/
public static EffectiveReferralReviewStatusEnum getByDescription(String description) {
if (StringUtils.isBlank(description)) {
return null;
}
for (EffectiveReferralReviewStatusEnum status : EffectiveReferralReviewStatusEnum.values()) {
if (status.getDescription().equals(description)) {
return status;
}
}
return null;
}
/**
* 根据描述获取编码
*
* @param description 描述
* @return 编码,找不到时返回null
*/
public static Integer getCodeByDescription(String description) {
EffectiveReferralReviewStatusEnum status = getByDescription(description);
return status != null ? status.getCode() : null;
}
/**
* 检查编码是否有效
*
* @param code 编码
* @return 是否有效
*/
public static boolean isValid(Integer code) {
return getByCode(code) != null;
}
}
\ No newline at end of file \ No newline at end of file
...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.staff.dto.perfSalary.*; ...@@ -6,6 +6,7 @@ import cn.com.glsx.dj.staff.dto.perfSalary.*;
import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO; import cn.com.glsx.dj.staff.dto.performance.PerformanceTimeCycleDTO;
import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum; import cn.com.glsx.dj.staff.enums.PerformanceTimeCycleCodeEnum;
import cn.com.glsx.dj.staff.enums.perfSalary.EffectiveReferralBrandTypeEnum; import cn.com.glsx.dj.staff.enums.perfSalary.EffectiveReferralBrandTypeEnum;
import cn.com.glsx.dj.staff.enums.perfSalary.EffectiveReferralReviewStatusEnum;
import cn.com.glsx.dj.staff.enums.perfSalary.EffectiveReferralSceneEnum; import cn.com.glsx.dj.staff.enums.perfSalary.EffectiveReferralSceneEnum;
import cn.com.glsx.dj.staff.mapper.perfSalary.EffectiveReferralReviewMapper; import cn.com.glsx.dj.staff.mapper.perfSalary.EffectiveReferralReviewMapper;
import cn.com.glsx.dj.staff.model.Dict; import cn.com.glsx.dj.staff.model.Dict;
...@@ -323,8 +324,10 @@ public class EffectiveReferralReviewMiniProgramService { ...@@ -323,8 +324,10 @@ public class EffectiveReferralReviewMiniProgramService {
&& !item.getEffectiveReferralCount().equals(referralReviewCommonDTOSMap.get(item.getId()).getTotalDeliveryCount())) { && !item.getEffectiveReferralCount().equals(referralReviewCommonDTOSMap.get(item.getId()).getTotalDeliveryCount())) {
review.setIsNeedReviewed(1); review.setIsNeedReviewed(1);
review.setIsReviewed(0); review.setIsReviewed(0);
if (Objects.equals(EffectiveReferralReviewStatusEnum.SUBMITTED.getCode(),dto.getStatus())) {
sendMessageFlag.set(true); sendMessageFlag.set(true);
} }
}
else { else {
review.setIsNeedReviewed(0); review.setIsNeedReviewed(0);
} }
...@@ -348,6 +351,7 @@ public class EffectiveReferralReviewMiniProgramService { ...@@ -348,6 +351,7 @@ public class EffectiveReferralReviewMiniProgramService {
private void sendMessageAsync(AtomicReference<Boolean> sendMessageFlag, EffectiveReferralReviewCommonDTO reviewCommonDTO) { private void sendMessageAsync(AtomicReference<Boolean> sendMessageFlag, EffectiveReferralReviewCommonDTO reviewCommonDTO) {
taskExecutor.execute(() -> { taskExecutor.execute(() -> {
if (sendMessageFlag.get()) { if (sendMessageFlag.get()) {
log.info("effectiveReferralStoreSubmit-sendMessageFlag:{},referralReviewCommonDTO:{}", sendMessageFlag,JSON.toJSONString(reviewCommonDTO));
effectiveReferralReviewQwService.qwOnlineNotification(reviewCommonDTO.getReviewMonth(), reviewCommonDTO.getMerchantId(), reviewCommonDTO.getSceneType()); effectiveReferralReviewQwService.qwOnlineNotification(reviewCommonDTO.getReviewMonth(), reviewCommonDTO.getMerchantId(), reviewCommonDTO.getSceneType());
} }
} }
......
...@@ -65,6 +65,7 @@ public class StaffPerformanceCalService { ...@@ -65,6 +65,7 @@ public class StaffPerformanceCalService {
@Autowired @Autowired
private MerchantPerformanceProductDefineService merchantPerformanceProductDefineService; private MerchantPerformanceProductDefineService merchantPerformanceProductDefineService;
/** /**
* 计算员工提成 * 计算员工提成
* *
...@@ -536,11 +537,9 @@ public class StaffPerformanceCalService { ...@@ -536,11 +537,9 @@ 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) {
commission = commission.add(detailDTO.getExtraPerformanceAmount()); commission = commission.add(detailDTO.getExtraPerformanceAmount());
...@@ -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();
...@@ -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:跳过渗透率限制条件
......
...@@ -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.getEffectiveMonth()) .month(firstDTO.getMonth())
.updatedBy(CommonConstants.DEFAULT_UPDATE_BY) .updatedBy(CommonConstants.DEFAULT_UPDATE_BY)
.build(); .build();
int updatedRecord = staffPerformanceDetailMapper.removePerformanceDetail(query); int updatedRecord = staffPerformanceDetailMapper.removePerformanceDetail(query);
......
...@@ -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();
......
...@@ -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>
......
# 数据生成方案:门店工资绩效参数配置条件数据
## 目标
为 `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`。
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
## 数据要求
我需要开始集成测试的测试数据准备,数据应该满足如下要求:
- 员工
- 天明哥哥
- 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
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}")
  • @wangxw1
    commented
    Master

    你好,我是负责本次代码审查的资深软件开发工程师。你提交的代码旨在让“已禁用”状态的员工也能查询工资明细,业务意图清晰。

    以下是基于功能正确性、安全性、工程最佳实践等维度的审查意见。

    一、关键问题与优化建议(Top 3)

    1. 代码可维护性:存在硬编码(Magic Strings)与逻辑重复

    • 问题描述:在 SQL 中直接硬编码使用 'N' 和 'I' 且重复出现了两次(子查询内与主查询 WHERE 子句中)。
    • 影响分析:
      • 维护困难:未来如果增加了新的状态(如 'S' 挂起),需要同时修改多处 SQL,容易遗漏导致数据不一致。
      • 逻辑分散:业务状态的定义散落在 SQL 字符串中,而非在 Java 常量或枚举中统一管理。
    • 优化建议:
      • 推荐:在 Java 层定义枚举或常量列表,通过 MyBatis 的 <foreach> 标签传入状态列表。
      • 示例: xml <!-- 传入 statusList = ["N", "I"] --> WHERE deleted_flag IN <foreach item="status" collection="statusList" open="(" separator="," close=")"> #{status} </foreach>

    2. 性能隐患:子查询全表聚合风险

    • 问题描述:子查询 SELECT ... MAX(updated_date) ... GROUP BY phone_number 会对 dj_car_life_staff_info 表进行全量(或基于索引的)扫描和分组聚合。
    • 影响分析:随着员工历史数据(包括 'I' 状态的历史记录)的累积,该子查询的开销会线性增长。如果外层查询(getStaffMonthSalarySlipData)本身是带有特定筛选条件(如查询特定月份或特定人),该子查询却依然计算了全员的最新状态,造成资源浪费。
    • 优化建议:
      • 如果外层查询包含针对 phone_number 或其他字段的过滤条件,应尽可能将这些条件下推到子查询内部,减少聚合的数据量。
      • 检查 (phone_number, deleted_flag, updated_date) 是否存在联合索引以优化聚合效率。

    3. Git 提交规范:包含无意义的 Merge 节点

    • 问题描述:提交历史中包含 Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0。
    • 影响分析:这表明在提交代码前未进行 git rebase,导致 Git 历史线出现不必要的分叉和“Merge 气泡”,污染了项目历史,增加了代码回溯的难度。
    • 优化建议:建议在 push 代码前使用 git pull --rebase 或 git rebase 来保持提交历史的线性整洁。

    二、评分明细

    1. 功能实现的正确性与健壮性(38/40分)
      • 逻辑符合业务需求,正确处理了 'N' 和 'I' 的状态包含。扣分点在于逻辑重复可能导致的潜在不一致风险。
    2. 安全性与潜在风险(30/30分)
      • 未引入明显的 SQL 注入风险(假设外层调用正确),未引入越权风险(假设业务允许禁用员工查看)。
    3. 最佳实践与可维护性(12/20分)
      • 存在硬编码(Magic Strings)且逻辑分散,严重影响可维护性,扣分较多。
    4. 性能与资源利用(3/5分)
      • GROUP BY 子查询在数据量大时存在性能瓶颈,且修改将扫描范围扩大到了 'I' 状态数据,增加了负载。
    5. 提交信息质量(4/5分)
      • 业务描述清晰("已禁用员工也需要..."),但包含 Merge 节点导致历史不洁,扣 1 分。

    三、总分

    总分:87分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!