Commit 1f8fc87f by 张富康

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

2 parents 699f7958 f1eb9927
Showing 19 changed files with 592 additions and 17 deletions
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
...@@ -9,7 +9,6 @@ import cn.com.glsx.dj.staff.model.StaffMonthSalarySlip; ...@@ -9,7 +9,6 @@ import cn.com.glsx.dj.staff.model.StaffMonthSalarySlip;
import cn.com.glsx.dj.staff.model.StaffMonthSalarySlipSend; import cn.com.glsx.dj.staff.model.StaffMonthSalarySlipSend;
import cn.com.glsx.dj.staff.service.common.QWManager; import cn.com.glsx.dj.staff.service.common.QWManager;
import cn.com.glsx.dj.staff.service.salary.StaffMonthSalarySlipService; import cn.com.glsx.dj.staff.service.salary.StaffMonthSalarySlipService;
import cn.com.glsx.dj.staff.util.DateUtils;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.WorkWechatTextCardMessageDTO; import cn.com.glsx.scrm.wechat.dto.workwechat.message.WorkWechatTextCardMessageDTO;
...@@ -28,7 +27,6 @@ import org.springframework.core.task.TaskExecutor; ...@@ -28,7 +27,6 @@ import org.springframework.core.task.TaskExecutor;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
...@@ -84,6 +82,9 @@ public class StaffMonthSalaryJob implements SimpleJob { ...@@ -84,6 +82,9 @@ public class StaffMonthSalaryJob implements SimpleJob {
// 保存发送信息 // 保存发送信息
try { try {
StaffMonthSalarySlipSend slipSend = saveSendMsg(monthSalary); StaffMonthSalarySlipSend slipSend = saveSendMsg(monthSalary);
if (slipSend == null) {
return;
}
sendMessage(monthSalary, slipSend); sendMessage(monthSalary, slipSend);
} catch (Exception e) { } catch (Exception e) {
log.error("员工:{},手机号:{} 发送企微消息异常:{}", staffBaseInfo.getStaffName(), staffBaseInfo.getStaffPhone(), e.getMessage(), e); log.error("员工:{},手机号:{} 发送企微消息异常:{}", staffBaseInfo.getStaffName(), staffBaseInfo.getStaffPhone(), e.getMessage(), e);
...@@ -103,6 +104,15 @@ public class StaffMonthSalaryJob implements SimpleJob { ...@@ -103,6 +104,15 @@ public class StaffMonthSalaryJob implements SimpleJob {
} }
private StaffMonthSalarySlipSend saveSendMsg(StaffMonthSalarySlip monthSalary) { private StaffMonthSalarySlipSend saveSendMsg(StaffMonthSalarySlip monthSalary) {
// 先判断是否已经发送过,如果存在,则不再发送
StaffMonthSalarySlipSend query = new StaffMonthSalarySlipSend();
query.setSalaryMonth(monthSalary.getSalaryMonth());
query.setStaffPhone(monthSalary.getStaffPhone());
query.setDeletedFlag("N");
List<StaffMonthSalarySlipSend> list = staffMonthSalarySlipSendMapper.select(query);
if (list != null && !list.isEmpty()) {
return null;
}
StaffMonthSalarySlipSend staffMonthSalarySlipSend = new StaffMonthSalarySlipSend(); StaffMonthSalarySlipSend staffMonthSalarySlipSend = new StaffMonthSalarySlipSend();
staffMonthSalarySlipSend.setStaffName(monthSalary.getStaffName()); staffMonthSalarySlipSend.setStaffName(monthSalary.getStaffName());
staffMonthSalarySlipSend.setStaffPhone(monthSalary.getStaffPhone()); staffMonthSalarySlipSend.setStaffPhone(monthSalary.getStaffPhone());
...@@ -136,7 +146,6 @@ public class StaffMonthSalaryJob implements SimpleJob { ...@@ -136,7 +146,6 @@ public class StaffMonthSalaryJob implements SimpleJob {
} }
private String buildEntryDate(StaffMonthSalarySlip monthSalary) { private String buildEntryDate(StaffMonthSalarySlip monthSalary) {
StaffMonthSalaryBaseInfo staffMonthSalaryBaseInfo = new StaffMonthSalaryBaseInfo(); StaffMonthSalaryBaseInfo staffMonthSalaryBaseInfo = new StaffMonthSalaryBaseInfo();
staffMonthSalaryBaseInfo.setStaffPhone(monthSalary.getStaffPhone()); staffMonthSalaryBaseInfo.setStaffPhone(monthSalary.getStaffPhone());
......
...@@ -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());
} }
} }
......
...@@ -239,6 +239,8 @@ public class StaffMonthSalarySlipService { ...@@ -239,6 +239,8 @@ public class StaffMonthSalarySlipService {
dailyDeductCount += deduct.getBehaviorCount(); dailyDeductCount += deduct.getBehaviorCount();
} }
} }
}else {
log.error("获取员工日常扣除记录失败:{}", JSON.toJSONString(resp));
} }
// 获取工资绩效数据 // 获取工资绩效数据
StaffMonthSalaryDTO salary1 = performanceEvaluationMapper.queryStaffMonthSalary(info.getSalaryMonth(), info.getStaffPhone()); StaffMonthSalaryDTO salary1 = performanceEvaluationMapper.queryStaffMonthSalary(info.getSalaryMonth(), info.getStaffPhone());
......
...@@ -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();
......
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
phone_number, phone_number,
MAX(updated_date) AS latest_time MAX(updated_date) AS latest_time
FROM `dj_car_life_staff_info` FROM `dj_car_life_staff_info`
WHERE deleted_flag = 'N' WHERE deleted_flag IN ('N','I')
GROUP BY phone_number GROUP BY phone_number
) latest ON dsi.phone_number = latest.phone_number AND dsi.updated_date = latest.latest_time ) latest ON dsi.phone_number = latest.phone_number AND dsi.updated_date = latest.latest_time
WHERE EXISTS ( WHERE EXISTS (
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
</if> </if>
AND dss.staff_phone = dsi.phone_number AND dss.staff_phone = dsi.phone_number
) )
AND dsi.deleted_flag = 'N' AND dsi.deleted_flag IN ('N','I')
</select> </select>
<select id="getStaffMonthSalaryDetailData" resultMap="detailResultMap"> <select id="getStaffMonthSalaryDetailData" resultMap="detailResultMap">
SELECT ss.*,sbi.area_operation,sbi.area,sbi.entry_date,sbi.leave_date,sbi.post,sbi. SELECT ss.*,sbi.area_operation,sbi.area,sbi.entry_date,sbi.leave_date,sbi.post,sbi.
......
...@@ -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}")
...@@ -4,7 +4,9 @@ import cn.com.glsx.dj.sale.service.BaseServiceTest; ...@@ -4,7 +4,9 @@ import cn.com.glsx.dj.sale.service.BaseServiceTest;
import cn.com.glsx.dj.staff.dto.salary.StaffMonthSalarySlipSendDTO; import cn.com.glsx.dj.staff.dto.salary.StaffMonthSalarySlipSendDTO;
import cn.com.glsx.dj.staff.dto.salary.StaffSalaryDetailDTO; import cn.com.glsx.dj.staff.dto.salary.StaffSalaryDetailDTO;
import cn.com.glsx.dj.staff.dto.salary.StaffSalaryDetailRequestDTO; import cn.com.glsx.dj.staff.dto.salary.StaffSalaryDetailRequestDTO;
import cn.com.glsx.dj.staff.mapper.StaffMonthSalarySlipSendMapper;
import cn.com.glsx.dj.staff.model.StaffMonthSalarySlip; import cn.com.glsx.dj.staff.model.StaffMonthSalarySlip;
import cn.com.glsx.dj.staff.model.StaffMonthSalarySlipSend;
import cn.com.glsx.dj.staff.service.common.QWManager; import cn.com.glsx.dj.staff.service.common.QWManager;
import cn.com.glsx.dj.staff.service.salary.StaffMonthSalarySlipService; import cn.com.glsx.dj.staff.service.salary.StaffMonthSalarySlipService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
...@@ -19,6 +21,8 @@ import org.junit.Test; ...@@ -19,6 +21,8 @@ import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
import java.util.List;
@Slf4j @Slf4j
public class StaffMonthSalaryServiceTest extends BaseServiceTest { public class StaffMonthSalaryServiceTest extends BaseServiceTest {
...@@ -28,6 +32,9 @@ public class StaffMonthSalaryServiceTest extends BaseServiceTest { ...@@ -28,6 +32,9 @@ public class StaffMonthSalaryServiceTest extends BaseServiceTest {
private Environment env; private Environment env;
@Autowired @Autowired
private QWManager qwManager; private QWManager qwManager;
@Autowired
private StaffMonthSalarySlipSendMapper staffMonthSalarySlipSendMapper;
@Test @Test
public void testStatStaffMonthSalary() { public void testStatStaffMonthSalary() {
...@@ -40,6 +47,16 @@ public class StaffMonthSalaryServiceTest extends BaseServiceTest { ...@@ -40,6 +47,16 @@ public class StaffMonthSalaryServiceTest extends BaseServiceTest {
@Test @Test
public void testSendMessage() { public void testSendMessage() {
// 先判断是否已经发送过,如果存在,则不再发送
StaffMonthSalarySlipSend query = new StaffMonthSalarySlipSend();
query.setSalaryMonth("2025-12");
query.setStaffPhone("18925261040");
query.setDeletedFlag("N");
List<StaffMonthSalarySlipSend> list = staffMonthSalarySlipSendMapper.select(query);
if (list != null && !list.isEmpty()){
log.info("员工:{},手机号:{} 已经发送过,请勿重复发送", "张三", "18925261040");
return;
}
Integer merchantId = 44210895; Integer merchantId = 44210895;
// 发送自建应用消息对应(wechat-build-server)配置门店号 // 发送自建应用消息对应(wechat-build-server)配置门店号
Integer sendConfigMerchantId = 442108951; Integer sendConfigMerchantId = 442108951;
......
  • @wangxw1
    commented
    Master

    你好,我是负责此次代码审查的资深软件开发工程师。

    你提交的代码旨在限制绩效数据的提交时间窗口,这是一个对于数据一致性非常重要的业务逻辑。从提交信息来看,意图清晰,代码改动也较为直观。但在时区处理的严谨性、代码复用性以及异常提示的准确性方面,还有优化的空间。

    以下是针对本次提交的 Top 3 关键问题与优化建议:

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

    1. 严重隐患:依赖服务器本地时区可能导致“跨月”边界判定错误

    • 问题描述:DateUtil.lastMonth() 和 DateUtil.format() 默认使用服务器的系统时区(System Default TimeZone)。如果生产环境(如 Docker 容器)默认为 UTC 时间,而业务场景在中国(GMT+8),在每月的 1 号 00:00 到 08:00 期间,服务器时间仍处于“上个月的最后一天”,导致 lastMonth() 计算出的结果是“上上个月”,从而错误地拦截合法的提交请求,或允许非法的提交。
    • 影响分析:导致每月初特定时间段内业务功能瘫痪,引发用户投诉(特别是绩效提交通常有严格的截止时间)。
    • 优化建议:显式指定业务时区(如 GMT+8)进行日期计算。

      // 建议封装一个获取当前业务日期的方法,或在 format 时指定时区
      // 示例:假设业务为中国时间
      DateTime lastMonthDate = DateUtil.offsetMonth(DateUtil.date(), -1);
      // 务必确保 format 使用的是业务时区,Hutool 的 DateUtil 某些版本 format 可能不带时区参数,建议转为 LocalDate 或 Calendar 处理更稳健
      // 或者简单修复(依赖环境配置):
      // String targetMonth = DateUtil.format(lastMonthDate, "yyyy-MM"); 
      
      // 推荐做法 (Java 8+ API):
      YearMonth lastMonth = YearMonth.now(ZoneId.of("Asia/Shanghai")).minusMonths(1);
      if (!lastMonth.toString().equals(perfAppraisalSubmitReqDTO.getEvaluationMonth())) { ... }
      

    2. 代码质量:重复代码(Copy-Paste)违反 DRY 原则

    • 问题描述:相同的逻辑判断代码块(包括注释、if 判断、异常抛出)在 submit 和 batchSubmit 两个方法中完全复制粘贴。
    • 影响分析:增加了维护成本。如果未来需要调整逻辑(例如:允许修改当月数据,或者修改提示文案),开发人员很容易漏改其中一处,导致接口行为不一致。
    • 优化建议:提取私有方法进行复用。 java private void validateEvaluationMonth(String evaluationMonth) { // 建议使用常量定义 "yyyy-MM" String lastMonthStr = DateUtil.format(DateUtil.lastMonth(), "yyyy-MM"); if (ObjectUtil.notEqual(evaluationMonth, lastMonthStr)) { // 提示语建议更具体,见问题 3 throw new RpcServiceException("亲,只能提交/修改上个月(" + lastMonthStr + ")的绩效数据"); } }

    3. 用户体验:异常提示文案产生歧义

    • 问题描述:代码逻辑是 notEqual(不等于上月),即包含了“更早的历史月份”和“当前/未来月份”。但异常抛出的文案是“不能修改历史的数据”。如果用户尝试提交本月数据(这也是常理上可能发生的操作),报错却说“不能修改历史”,会让用户感到困惑。
    • 影响分析:错误信息误导用户,增加排查沟通成本。
    • 优化建议:根据实际情况精准提示,或者统一提示“只能提交上个月份的数据”。 java throw new RpcServiceException("亲,当前仅允许提交上个月份的绩效数据");

    二、评分明细

    1. 功能实现的正确性与健壮性(30/40分)
      • 扣分点:严重依赖服务器本地时区,存在边界时间 Bug 风险;逻辑上完全禁止了“本月”数据的提交(假设这是业务意图,但代码实现较“硬”)。
    2. 安全性与潜在风险(30/30分)
      • 得分点:增加了数据修改的时间窗口限制,有效防止了对已归档历史数据的篡改,符合安全预期。
    3. 最佳实践与可维护性(10/20分)
      • 扣分点:存在明显的代码复制粘贴;使用了硬编码的日期格式字符串;异常信息不够准确。
    4. 性能与资源利用(5/5分)
      • 得分点:简单的日期格式化与字符串比对,无性能问题。
    5. 提交信息质量(5/5分)
      • 得分点:Commit message 格式规范(Type: Subject),Body 描述清晰,关联了 issue 或变更点。

    三、总分

    总分:80分

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