Commit c8433977 by 章家宝

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

2 parents f59990af 458090c4
Showing 17 changed files with 118 additions and 47 deletions
...@@ -44,4 +44,8 @@ public class PerformanceConfigDTO extends PerformanceConfig { ...@@ -44,4 +44,8 @@ public class PerformanceConfigDTO extends PerformanceConfig {
*/ */
private String merchantName; private String merchantName;
private String brandName;
private String childBrandName;
} }
...@@ -6,12 +6,11 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -6,12 +6,11 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.*; import lombok.*;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder @SuperBuilder
@ToString(callSuper = true) @ToString(callSuper = true)
@Data @Data
@EqualsAndHashCode(callSuper=false)
@AllArgsConstructor
@NoArgsConstructor
public class PerformanceParamConfigConditionDTO extends PerformanceParamConfigCondition { public class PerformanceParamConfigConditionDTO extends PerformanceParamConfigCondition {
private MerchantPerformanceProductDefineDTO productDefine; private MerchantPerformanceProductDefineDTO productDefine;
@ApiModelProperty(notes = "提成方案置ID") @ApiModelProperty(notes = "提成方案置ID")
......
...@@ -64,11 +64,21 @@ public class StaffPerformanceCalContextDTO implements Serializable { ...@@ -64,11 +64,21 @@ public class StaffPerformanceCalContextDTO implements Serializable {
private Integer brandId; private Integer brandId;
/** /**
* 品牌名称
*/
private String brandName;
/**
* 子品牌ID * 子品牌ID
*/ */
private Integer childBrandId; private Integer childBrandId;
/** /**
* 子品牌名称
*/
private String childBrandName;
/**
* 当前计算的门店提成方案 * 当前计算的门店提成方案
*/ */
private PerformanceConfigDTO performanceConfig; private PerformanceConfigDTO performanceConfig;
......
...@@ -2,9 +2,9 @@ package cn.com.glsx.dj.staff.dto; ...@@ -2,9 +2,9 @@ package cn.com.glsx.dj.staff.dto;
import cn.com.glsx.dj.staff.model.StaffPerformanceDetail; import cn.com.glsx.dj.staff.model.StaffPerformanceDetail;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -12,13 +12,16 @@ import java.math.BigDecimal; ...@@ -12,13 +12,16 @@ import java.math.BigDecimal;
/** /**
* 提成结果明细DTO * 提成结果明细DTO
*/ */
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder @SuperBuilder
@ToString(callSuper = true)
@Data @Data
@EqualsAndHashCode(callSuper=false)
public class StaffPerformanceDetailDTO extends StaffPerformanceDetail { public class StaffPerformanceDetailDTO extends StaffPerformanceDetail {
private static final long serialVersionUID = 833236627080089143L; private static final long serialVersionUID = 833236627080089143L;
@ApiModelProperty(notes = "额外提成金额") @ApiModelProperty(notes = "额外提成金额")
private BigDecimal extraPerformanceAmount; private BigDecimal extraPerformanceAmount;
@ApiModelProperty(notes = "个人渗透率")
private BigDecimal personalPenetrationRate;
} }
package cn.com.glsx.dj.staff.dto.perfSalary; package cn.com.glsx.dj.staff.dto.perfSalary;
import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview; import cn.com.glsx.dj.staff.model.perfSalary.EffectiveReferralReview;
import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor;
import lombok.*; import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import java.util.List;
/** /**
* 有效引荐数表 * 有效引荐数表
*/ */
//@AllArgsConstructor // @AllArgsConstructor
//@NoArgsConstructor // @NoArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder @SuperBuilder
@ToString(callSuper = true) @ToString(callSuper = true)
@Data @Data
@EqualsAndHashCode(callSuper=false)
public class EffectiveReferralReviewDTO extends EffectiveReferralReview { public class EffectiveReferralReviewDTO extends EffectiveReferralReview {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List<Integer> ids;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.staff.enums; package cn.com.glsx.dj.staff.enums;
import java.util.Objects;
/** /**
* 绩效参数配置条件类型枚举 * 绩效参数配置条件类型枚举
*/ */
...@@ -17,12 +19,12 @@ public enum PerformanceConditionTypeEnum implements BaseEnum<Byte, String> { ...@@ -17,12 +19,12 @@ public enum PerformanceConditionTypeEnum implements BaseEnum<Byte, String> {
this.desc = desc; this.desc = desc;
} }
public static PerformanceConditionTypeEnum getByCode(Number code) { public static PerformanceConditionTypeEnum getByCode(Byte code) {
if (code == null) { if (code == null) {
return null; return null;
} }
for (PerformanceConditionTypeEnum type : PerformanceConditionTypeEnum.values()) { for (PerformanceConditionTypeEnum type : PerformanceConditionTypeEnum.values()) {
if (type.getCode().equals(code.intValue())) { if (Objects.equals(type.getCode(), code)) {
return type; return type;
} }
} }
......
...@@ -134,10 +134,6 @@ public class StaffPerformanceDetail implements Serializable { ...@@ -134,10 +134,6 @@ public class StaffPerformanceDetail implements Serializable {
@Column(name = "upgrade_order_num") @Column(name = "upgrade_order_num")
private Integer upgradeOrderNum; private Integer upgradeOrderNum;
@ApiModelProperty(notes = "个人渗透率")
@Column(name = "personal_penetration_rate")
private BigDecimal personalPenetrationRate;
@ApiModelProperty(notes = "提成方式(比例-BL,系数-XS,固定金额-DDJE)") @ApiModelProperty(notes = "提成方式(比例-BL,系数-XS,固定金额-DDJE)")
@Column(name = "commission_type") @Column(name = "commission_type")
private String commissionType; private String commissionType;
...@@ -151,6 +147,26 @@ public class StaffPerformanceDetail implements Serializable { ...@@ -151,6 +147,26 @@ public class StaffPerformanceDetail implements Serializable {
/** /**
* <pre> * <pre>
* { * {
* "assessmentFactorDependencyData": {
* "orderData": { // 订单依赖数据
* "personalMonthlyTotalOutput": 1000.00, // 个人月度总产值(业务)
* "personalMonthlyStoreOutput": 800.00, // 个人月度单店产值(门店+业务)
* "mainOrderCountByBrand": 5, // 主订单成交数(门店+业务+品牌)
* "mainOrderCountByBrandAndCategory": 3, // 主订单成交数(门店+业务+品牌+品类)
* "subOrderCountByBrandAndCategory": 10, // 子订单成交数(门店+业务+品牌+品类)
* "categoryOrderOutputTotalByBrandAndCategory": 500.00, // 品类订单产值合计(门店+业务+品牌+品类)
* "commissionBaseSubOrderCountByBrandAndCategory": 8, // 提成基数-子订单成交数(门店+业务+品牌+品类)
* "commissionBaseCategoryOrderOutputTotalByBrandAndCategory": 400.00 // 提成基数-品类订单产值合计(门店+业务+品牌+品类)
* },
* "dailyData": { // 日报/触客依赖数据
* "personalTotalPreSalesTouchCount": 100, // 该个人在所有门店的实际售前触客数总和
* "storePersonalPreSalesTouchCount": 50, // 该门店的该个人实际售前触客数
* "storeTotalTouchCount": 500, // 门店总触客数(该门店的所有个人实际售前触客数之和)
* "storeDeliveryCount": 40, // 门店交车数
* "storeValidRecommendationCount": 45, // 门店有效引荐数
* "personalTargetTouchCount": 10.50 // 个人应触客数
* }
* },
* "conditionExecutions": [ * "conditionExecutions": [
* { * {
* "conditionType": 1, * "conditionType": 1,
......
...@@ -311,7 +311,7 @@ public class AttendanceDataCleansingService { ...@@ -311,7 +311,7 @@ public class AttendanceDataCleansingService {
// 2. 处理每条考勤记录 // 2. 处理每条考勤记录
// 判断该打卡日期是否在离职直接之后,如果在离职日期之后则不计算 // 判断该打卡日期是否在离职直接之后,如果在离职日期之后则不计算
if (StrUtil.isNotBlank(employee.getLastWorkDate())) { if (StrUtil.isNotBlank(employee.getLastWorkDate())) {
if(DateUtil.compare(DateUtil.parse(clockInfo.getClockInDate(), "yyyy-MM-dd"), DateUtil.parse(employee.getLastWorkDate(), "yyyy-MM-dd")) > 0){ if (DateUtil.compare(DateUtil.parse(clockInfo.getClockInDate(), "yyyy-MM-dd"), DateUtil.parse(employee.getLastWorkDate(), "yyyy-MM-dd")) > 0) {
log.info("{} 打卡日期:{},离职日期:{} 打卡日期在离职日期之后,不处理", employee.getStaffName(), clockInfo.getClockInDate(), employee.getLastWorkDate()); log.info("{} 打卡日期:{},离职日期:{} 打卡日期在离职日期之后,不处理", employee.getStaffName(), clockInfo.getClockInDate(), employee.getLastWorkDate());
continue; continue;
} }
...@@ -416,24 +416,23 @@ public class AttendanceDataCleansingService { ...@@ -416,24 +416,23 @@ public class AttendanceDataCleansingService {
// 处理每个批次 // 处理每个批次
for (List<AttendanceSummary> batch : batches) { for (List<AttendanceSummary> batch : batches) {
try { try {
// 1. 开启事务 for (AttendanceSummary summary : batch) {
TransactionDefinition def = new DefaultTransactionDefinition();
TransactionStatus status = transactionManager.getTransaction(def);
try { try {
// 2. 执行批量插入 // 尝试单条插入
attendanceSummaryMapper.insertOrUpdateBatch(batch); insertAttendanceData(summary);
transactionManager.commit(status); } catch (Exception ex) {
log.info("成功插入 {} 条考勤数据", batch.size()); // 记录详细失败信息
} catch (Exception e) { recordFailure(summary.getMobilePhone(), summary.getAttendanceMonth(),
// 3. 批量插入失败,回滚事务 "单条插入失败: " + ex.getMessage());
transactionManager.rollback(status);
throw e; // 记录关键日志
log.error("单条插入失败 [phone: {}, month: {}] - {}",
summary.getMobilePhone(),
summary.getAttendanceMonth(),
ex.getMessage()
);
}
} }
} catch (Exception e) {
// 4. 批量插入失败,重试单条插入
log.error("批量插入失败,开始单条重试 [batchSize: {}]", batch.size());
processSingleInsertBatch(batch);
} finally { } finally {
// 5. 释放内存 // 5. 释放内存
batch.clear(); batch.clear();
...@@ -773,7 +772,6 @@ public class AttendanceDataCleansingService { ...@@ -773,7 +772,6 @@ public class AttendanceDataCleansingService {
} }
private ClockInResult processWithMerchant(StaffQwClockClean clockInfo, MerchantAttendanceList merchant, StaffBeisenBaseInfo employee) { private ClockInResult processWithMerchant(StaffQwClockClean clockInfo, MerchantAttendanceList merchant, StaffBeisenBaseInfo employee) {
log.info("策略一:处理打卡时间:{}-{},经纬度:{},{}", clockInfo.getClockInTimeStart(), clockInfo.getClockOutTimeEnd(), log.info("策略一:处理打卡时间:{}-{},经纬度:{},{}", clockInfo.getClockInTimeStart(), clockInfo.getClockOutTimeEnd(),
merchant.getAddressLng(), merchant.getAddressLat()); merchant.getAddressLng(), merchant.getAddressLat());
......
...@@ -41,8 +41,10 @@ public class StaffPerformanceDetailService { ...@@ -41,8 +41,10 @@ public class StaffPerformanceDetailService {
return; return;
} }
log.info("Saving staff performance details. merchantId={}, businessType={}, month={}, count={}", log.info(
config.getMerchantId(), config.getBusinessType(), config.getEffectiveMonth(), "Saving staff performance details. merchantId={}, businessType={}, brandId={}, childBrandId={}, month={}, count={}",
config.getMerchantId(), config.getBusinessType(), config.getBrandId(), config.getChildBrandId(),
config.getEffectiveMonth(),
performanceDetailDTOS == null ? 0 : performanceDetailDTOS.size()); performanceDetailDTOS == null ? 0 : performanceDetailDTOS.size());
if (CollectionUtils.isEmpty(performanceDetailDTOS)) { if (CollectionUtils.isEmpty(performanceDetailDTOS)) {
......
...@@ -61,16 +61,22 @@ public class StaffPerformanceService { ...@@ -61,16 +61,22 @@ public class StaffPerformanceService {
merchantId, businessType, brandId, childBrandId, performanceMonth, staffPhone); merchantId, businessType, brandId, childBrandId, performanceMonth, staffPhone);
return; return;
} }
log.info(
"保存员工绩效数据: merchantId={}, businessType={}, brandId={}, childBrandId={}, performanceMonth={}, staffPhone={}",
merchantId, businessType, brandId, childBrandId, performanceMonth, staffPhone);
// 2. 检查是否处于新人保护期 // 2. 检查是否处于新人保护期
boolean isNewcomerProtection = checkNewcomerProtection(context.getStaffPhone(), context.getPerformanceMonth()); boolean isNewcomerProtection = checkNewcomerProtection(context.getStaffPhone(), context.getPerformanceMonth());
log.info("是否处于新人保护期: isNewcomerProtection={}", isNewcomerProtection);
// 3. 构建 StaffPerformance // 3. 构建 StaffPerformance
StaffPerformance staffPerformance = buildStaffPerformance(performanceDetailDTOS, context, isNewcomerProtection); StaffPerformance staffPerformance = buildStaffPerformance(performanceDetailDTOS, context, isNewcomerProtection);
// 4. 逻辑删除旧数据 // 4. 逻辑删除旧数据
log.debug("逻辑删除旧数据: staffPerformance={}", staffPerformance);
staffPerformanceMapper.removeStaffPerformance(staffPerformance); staffPerformanceMapper.removeStaffPerformance(staffPerformance);
// 5. 插入新数据 // 5. 插入新数据
log.debug("插入新数据: staffPerformance={}", staffPerformance);
staffPerformanceMapper.insertSelective(staffPerformance); staffPerformanceMapper.insertSelective(staffPerformance);
} }
......
...@@ -24,7 +24,7 @@ public class DataCalUtil { ...@@ -24,7 +24,7 @@ public class DataCalUtil {
if (divisor.compareTo(BigDecimal.ZERO) == 0) { if (divisor.compareTo(BigDecimal.ZERO) == 0) {
return null; return null;
} }
return dividend.divide(divisor, 4, BigDecimal.ROUND_HALF_UP); return dividend.divide(divisor, 2, BigDecimal.ROUND_HALF_UP);
} }
} }
...@@ -101,6 +101,31 @@ ...@@ -101,6 +101,31 @@
LEFT JOIN dj_car_life_service_merchant dclsm ON serr.merchant_id = dclsm.merchant_id LEFT JOIN dj_car_life_service_merchant dclsm ON serr.merchant_id = dclsm.merchant_id
AND dclsm.deleted_flag = 'N' AND dclsm.deleted_flag = 'N'
WHERE serr.deleted_flag = 'N' WHERE serr.deleted_flag = 'N'
<if test="isReviewed != null and isReviewed == 0">
AND serr.is_reviewed = #{isReviewed}
AND now() BETWEEN
STR_TO_DATE(CONCAT(DATE_FORMAT(now(), '%Y-%m-'),
(SELECT start_day_of_month FROM dj_car_life_performance_time_cycle ORDER BY id LIMIT 1)),
'%Y-%m-%d %H:%i:%s')
AND
STR_TO_DATE(CONCAT(DATE_FORMAT(now(), '%Y-%m-'),
(SELECT end_day_of_month FROM dj_car_life_performance_time_cycle ORDER BY id LIMIT 1)),
'%Y-%m-%d %H:%i:%s')
</if>
<if test="isReviewed != null and isReviewed == 1">
AND serr.is_reviewed = #{isReviewed}
</if>
<if test="isReviewed != null and isReviewed == 2">
AND serr.is_reviewed = #{isReviewed}
AND now() NOT BETWEEN
STR_TO_DATE(CONCAT(DATE_FORMAT(now(), '%Y-%m-'),
(SELECT start_day_of_month FROM dj_car_life_performance_time_cycle ORDER BY id LIMIT 1)),
'%Y-%m-%d %H:%i:%s')
AND
STR_TO_DATE(CONCAT(DATE_FORMAT(now(), '%Y-%m-'),
(SELECT end_day_of_month FROM dj_car_life_performance_time_cycle ORDER BY id LIMIT 1)),
'%Y-%m-%d %H:%i:%s')
</if>
<if test="merchantId != null"> <if test="merchantId != null">
AND serr.merchant_id = #{merchantId} AND serr.merchant_id = #{merchantId}
</if> </if>
...@@ -116,9 +141,6 @@ ...@@ -116,9 +141,6 @@
<if test="isNeedReviewed != null and isNeedReviewed != '' "> <if test="isNeedReviewed != null and isNeedReviewed != '' ">
AND serr.is_need_reviewed = #{isNeedReviewed} AND serr.is_need_reviewed = #{isNeedReviewed}
</if> </if>
<if test="isReviewed != null ">
AND serr.is_reviewed = #{isReviewed}
</if>
<if test="brandName != null and brandName != '' "> <if test="brandName != null and brandName != '' ">
AND serr.brand_name = #{brandName} AND serr.brand_name = #{brandName}
</if> </if>
......
...@@ -20,7 +20,10 @@ ...@@ -20,7 +20,10 @@
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" /> <result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap> </resultMap>
<resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.PerformanceConfigDTO" extends="BaseResultMap"> <resultMap id="DTOResultMap" type="cn.com.glsx.dj.staff.dto.PerformanceConfigDTO" extends="BaseResultMap">
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
<result column="merchant_name" property="merchantName" jdbcType="VARCHAR" /> <result column="merchant_name" property="merchantName" jdbcType="VARCHAR" />
<result column="brand_name" property="brandName" jdbcType="VARCHAR" />
<result column="child_name" property="childBrandName" jdbcType="VARCHAR" />
</resultMap> </resultMap>
<sql id="Base_Column_List" > <sql id="Base_Column_List" >
<!-- <!--
...@@ -32,7 +35,10 @@ ...@@ -32,7 +35,10 @@
<select id="selectEffectiveConfig" parameterType="cn.com.glsx.dj.staff.dto.PerformanceConfigDTO" resultMap="DTOResultMap"> <select id="selectEffectiveConfig" parameterType="cn.com.glsx.dj.staff.dto.PerformanceConfigDTO" resultMap="DTOResultMap">
SELECT c.*, SELECT c.*,
dclsm.merchant_name r.merchant_id,
r.brand_name,
r.child_name,
ifnull(dclsm.merchant_name, r.merchant_name) merchant_name
FROM dj_car_life_performance_config c FROM dj_car_life_performance_config c
LEFT JOIN dj_car_life_performance_config_merchant_brand_ref r ON c.id = r.performance_config_id LEFT JOIN dj_car_life_performance_config_merchant_brand_ref r ON c.id = r.performance_config_id
LEFT JOIN dj_car_life_service_merchant dclsm ON dclsm.merchant_id = r.merchant_id LEFT JOIN dj_car_life_service_merchant dclsm ON dclsm.merchant_id = r.merchant_id
......
...@@ -91,10 +91,8 @@ ...@@ -91,10 +91,8 @@
AND dclsdrh.brand_id = #{childBrandId} AND dclsdrh.brand_id = #{childBrandId}
</if> </if>
<if test="month != null and month != ''"> <if test="month != null and month != ''">
AND dclsdrh.report_date &gt;= concat( #{month}, AND dclsdrh.report_date &gt;= concat( #{month}, '-01')
'-01') AND dclsdrh.report_date &lt; DATE_ADD(concat( #{month}, '-01'), INTERVAL 1 MONTH)
AND dclsdrh.report_date &lt; DATE_ADD(concat( #{month},
'-01'), INTERVAL 1 MONTH)
</if> </if>
</where> </where>
</select> </select>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!