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 bbe05248
authored
Jan 20, 2026
by
张富康
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/v5.6.0' into v5.6.0
2 parents
33f38c47
c28b0310
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
372 additions
and
202 deletions
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/CommissionMethodEnum.java → rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/CommissionTypeEnum.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/ProductConfigTypeEnum.java → rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/GoodsConfigTypeEnum.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/PerformanceConditionTypeEnum.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/PerformanceParamConfigCondition.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffProductPerformanceMapper.java
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/StaffPerformanceService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffProductPerformanceService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/util/StaffPerformanceOrderUtil.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/util/DataCalUtil.java
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceDetailMapper.xml
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/Commission
Method
Enum.java
→
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/Commission
Type
Enum.java
View file @
bbe0524
...
@@ -10,7 +10,7 @@ import java.math.BigDecimal;
...
@@ -10,7 +10,7 @@ import java.math.BigDecimal;
*/
*/
@AllArgsConstructor
@AllArgsConstructor
@Getter
@Getter
public
enum
Commission
Method
Enum
{
public
enum
Commission
Type
Enum
{
BL
(
"BL"
,
"比例"
,
BigDecimal
.
ZERO
,
BigDecimal
.
valueOf
(
100
)),
BL
(
"BL"
,
"比例"
,
BigDecimal
.
ZERO
,
BigDecimal
.
valueOf
(
100
)),
XS
(
"XS"
,
"系数"
,
BigDecimal
.
ONE
,
BigDecimal
.
valueOf
(
10
)),
XS
(
"XS"
,
"系数"
,
BigDecimal
.
ONE
,
BigDecimal
.
valueOf
(
10
)),
GDJE
(
"GDJE"
,
"固定金额"
,
BigDecimal
.
ZERO
,
BigDecimal
.
valueOf
(
9999999
));
GDJE
(
"GDJE"
,
"固定金额"
,
BigDecimal
.
ZERO
,
BigDecimal
.
valueOf
(
9999999
));
...
@@ -20,8 +20,8 @@ public enum CommissionMethodEnum {
...
@@ -20,8 +20,8 @@ public enum CommissionMethodEnum {
private
final
BigDecimal
min
;
private
final
BigDecimal
min
;
private
final
BigDecimal
max
;
private
final
BigDecimal
max
;
public
static
Commission
Method
Enum
getByCode
(
String
code
)
{
public
static
Commission
Type
Enum
getByCode
(
String
code
)
{
for
(
Commission
Method
Enum
value
:
values
())
{
for
(
Commission
Type
Enum
value
:
values
())
{
if
(
value
.
getCode
().
equals
(
code
))
{
if
(
value
.
getCode
().
equals
(
code
))
{
return
value
;
return
value
;
}
}
...
@@ -31,10 +31,10 @@ public enum CommissionMethodEnum {
...
@@ -31,10 +31,10 @@ public enum CommissionMethodEnum {
// 检测区间
// 检测区间
public
static
boolean
check
(
String
code
,
BigDecimal
value
)
{
public
static
boolean
check
(
String
code
,
BigDecimal
value
)
{
Commission
MethodEnum
commissionMethod
Enum
=
getByCode
(
code
);
Commission
TypeEnum
commissionType
Enum
=
getByCode
(
code
);
if
(
commission
Method
Enum
==
null
)
{
if
(
commission
Type
Enum
==
null
)
{
return
false
;
return
false
;
}
}
return
value
.
doubleValue
()
>=
commission
MethodEnum
.
getMin
().
doubleValue
()
&&
value
.
doubleValue
()
<=
commissionMethod
Enum
.
getMax
().
doubleValue
();
return
value
.
doubleValue
()
>=
commission
TypeEnum
.
getMin
().
doubleValue
()
&&
value
.
doubleValue
()
<=
commissionType
Enum
.
getMax
().
doubleValue
();
}
}
}
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/
Product
ConfigTypeEnum.java
→
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/
Goods
ConfigTypeEnum.java
View file @
bbe0524
...
@@ -3,22 +3,31 @@ package cn.com.glsx.dj.staff.enums;
...
@@ -3,22 +3,31 @@ package cn.com.glsx.dj.staff.enums;
/**
/**
* 商品配置类型枚举
* 商品配置类型枚举
*/
*/
public
enum
ProductConfigTypeEnum
implements
BaseEnum
<
Integer
,
String
>
{
public
enum
GoodsConfigTypeEnum
implements
BaseEnum
<
Byte
,
String
>
{
ALL_PRODUCT
(-
1
,
"全部商品"
),
ALL_PRODUCT
(
(
byte
)
-
1
,
"全部商品"
),
PRODUCT_CATEGORY
(
0
,
"商品分类"
),
PRODUCT_CATEGORY
(
(
byte
)
0
,
"商品分类"
),
DESIGNATED_PRODUCT
(
1
,
"圈定产品"
),
DESIGNATED_PRODUCT
(
(
byte
)
1
,
"圈定产品"
),
DESIGNATED_PACKAGE
(
2
,
"圈定套餐"
);
DESIGNATED_PACKAGE
(
(
byte
)
2
,
"圈定套餐"
);
private
final
Integer
code
;
private
final
Byte
code
;
private
final
String
desc
;
private
final
String
desc
;
ProductConfigTypeEnum
(
Integer
code
,
String
desc
)
{
GoodsConfigTypeEnum
(
Byte
code
,
String
desc
)
{
this
.
code
=
code
;
this
.
code
=
code
;
this
.
desc
=
desc
;
this
.
desc
=
desc
;
}
}
public
static
GoodsConfigTypeEnum
getByCode
(
Byte
goodsConfigType
)
{
for
(
GoodsConfigTypeEnum
type
:
GoodsConfigTypeEnum
.
values
())
{
if
(
type
.
getCode
().
equals
(
goodsConfigType
))
{
return
type
;
}
}
return
null
;
}
@Override
@Override
public
Integer
getCode
()
{
public
Byte
getCode
()
{
return
code
;
return
code
;
}
}
...
...
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/PerformanceConditionTypeEnum.java
0 → 100644
View file @
bbe0524
package
cn
.
com
.
glsx
.
dj
.
staff
.
enums
;
/**
* 绩效参数配置条件类型枚举
*/
public
enum
PerformanceConditionTypeEnum
implements
BaseEnum
<
Byte
,
String
>
{
PENETRATION_RATE_LIMIT
((
byte
)
1
,
"渗透率限制"
),
ORDER_COUNT_DEDUCTION
((
byte
)
2
,
"订单数不足扣减"
),
TARGET_ACHIEVEMENT_REWARD
((
byte
)
3
,
"整体指标达成奖励"
),
ORDER_EXCLUSION_INCLUSION
((
byte
)
4
,
"订单数剔除/包含"
);
private
final
Byte
code
;
private
final
String
desc
;
PerformanceConditionTypeEnum
(
Byte
code
,
String
desc
)
{
this
.
code
=
code
;
this
.
desc
=
desc
;
}
public
static
PerformanceConditionTypeEnum
getByCode
(
Number
code
)
{
if
(
code
==
null
)
{
return
null
;
}
for
(
PerformanceConditionTypeEnum
type
:
PerformanceConditionTypeEnum
.
values
())
{
if
(
type
.
getCode
().
equals
(
code
.
intValue
()))
{
return
type
;
}
}
return
null
;
}
@Override
public
Byte
getCode
()
{
return
code
;
}
@Override
public
String
getDesc
()
{
return
desc
;
}
}
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/PerformanceParamConfigCondition.java
View file @
bbe0524
...
@@ -34,13 +34,13 @@ public class PerformanceParamConfigCondition implements Serializable {
...
@@ -34,13 +34,13 @@ public class PerformanceParamConfigCondition implements Serializable {
@Column
(
name
=
"performance_param_config_id"
)
@Column
(
name
=
"performance_param_config_id"
)
private
Integer
performanceParamConfigId
;
private
Integer
performanceParamConfigId
;
@ApiModelProperty
(
notes
=
"条件类型(1:渗透率限制,2.订单数不足扣减,3.整体指标达成奖励,4.订单数剔除/包含)"
)
@ApiModelProperty
(
notes
=
"条件类型(1:渗透率限制,2.订单数不足扣减,3.整体指标达成奖励,4.订单数剔除/包含)
, 详见PerformanceConditionTypeEnum
"
)
@Column
(
name
=
"condition_type"
)
@Column
(
name
=
"condition_type"
)
private
Integer
conditionType
;
private
Byte
conditionType
;
@ApiModelProperty
(
notes
=
"条件商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐)"
)
@ApiModelProperty
(
notes
=
"条件商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐)
, 详见ProductConfigTypeEnum
"
)
@Column
(
name
=
"condition_goods_config_type"
)
@Column
(
name
=
"condition_goods_config_type"
)
private
Integer
conditionGoodsConfigType
;
private
Byte
conditionGoodsConfigType
;
@ApiModelProperty
(
notes
=
"条件商品分类(一级)"
)
@ApiModelProperty
(
notes
=
"条件商品分类(一级)"
)
@Column
(
name
=
"condition_goods_type"
)
@Column
(
name
=
"condition_goods_type"
)
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffProductPerformanceMapper.java
View file @
bbe0524
...
@@ -19,5 +19,5 @@ public interface StaffProductPerformanceMapper extends OreMapper<StaffProductPer
...
@@ -19,5 +19,5 @@ public interface StaffProductPerformanceMapper extends OreMapper<StaffProductPer
@Param
(
"staffPhone"
)
String
staffPhone
,
@Param
(
"staffPhone"
)
String
staffPhone
,
@Param
(
"updatedBy"
)
String
updatedBy
);
@Param
(
"updatedBy"
)
String
updatedBy
);
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
@Param
(
"dto"
)
StaffProductPerformanceDTO
dto
);
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
StaffProductPerformanceDTO
dto
);
}
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceCalService.java
View file @
bbe0524
...
@@ -9,8 +9,9 @@ import cn.com.glsx.dj.staff.dto.*;
...
@@ -9,8 +9,9 @@ import cn.com.glsx.dj.staff.dto.*;
import
cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewDTO
;
import
cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewDTO
;
import
cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.enums.AssessmentFactorEnum
;
import
cn.com.glsx.dj.staff.enums.AssessmentFactorEnum
;
import
cn.com.glsx.dj.staff.enums.CommissionMethodEnum
;
import
cn.com.glsx.dj.staff.enums.CommissionTypeEnum
;
import
cn.com.glsx.dj.staff.enums.ProductConfigTypeEnum
;
import
cn.com.glsx.dj.staff.enums.PerformanceConditionTypeEnum
;
import
cn.com.glsx.dj.staff.enums.GoodsConfigTypeEnum
;
import
cn.com.glsx.dj.staff.mapper.StaffPerformanceCalMapper
;
import
cn.com.glsx.dj.staff.mapper.StaffPerformanceCalMapper
;
import
cn.com.glsx.dj.staff.service.perfSalary.EffectiveReferralReviewService
;
import
cn.com.glsx.dj.staff.service.perfSalary.EffectiveReferralReviewService
;
import
cn.com.glsx.dj.staff.service.staffPerformance.util.StaffPerformanceOrderUtil
;
import
cn.com.glsx.dj.staff.service.staffPerformance.util.StaffPerformanceOrderUtil
;
...
@@ -477,13 +478,13 @@ public class StaffPerformanceCalService {
...
@@ -477,13 +478,13 @@ public class StaffPerformanceCalService {
}
}
/**
/**
* 创建
绩效
明细DTO
* 创建
提成
明细DTO
*
*
* @param context 计算上下文
* @param context 计算上下文
* @param paramConfig
绩效
参数配置
* @param paramConfig
提成
参数配置
* @param actualValue 考核因子实际值
* @param actualValue 考核因子实际值
* @param paramConfigs 该组所有
绩效
参数配置
* @param paramConfigs 该组所有
提成
参数配置
* @return
绩效
明细DTO
* @return
提成
明细DTO
*/
*/
private
StaffPerformanceDetailDTO
createPerformanceDetailDTO
(
StaffPerformanceCalContextDTO
context
,
private
StaffPerformanceDetailDTO
createPerformanceDetailDTO
(
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigDTO
paramConfig
,
PerformanceParamConfigDTO
paramConfig
,
...
@@ -531,15 +532,14 @@ public class StaffPerformanceCalService {
...
@@ -531,15 +532,14 @@ public class StaffPerformanceCalService {
/**
/**
* 计算最终提成金额
* 计算最终提成金额
*
*
* @param detailDTO
绩效
明细DTO
* @param detailDTO
提成
明细DTO
*/
*/
private
void
calculateFinalCommission
(
StaffPerformanceDetailDTO
detailDTO
)
{
private
void
calculateFinalCommission
(
StaffPerformanceDetailDTO
detailDTO
)
{
// 非系数的计算提成金额
// 非系数的计算提成金额
BigDecimal
commission
=
null
;
BigDecimal
commission
=
null
;
// TODO 换成枚举
if
(
Objects
.
equals
(
detailDTO
.
getCommissionType
(),
CommissionTypeEnum
.
GDJE
.
getCode
()))
{
if
(
"DDJE"
.
equals
(
detailDTO
.
getCommissionType
()))
{
commission
=
detailDTO
.
getCommissionTypeValue
();
commission
=
detailDTO
.
getCommissionTypeValue
();
}
else
if
(
"BL"
.
equals
(
detailDTO
.
getCommissionTyp
e
()))
{
}
else
if
(
Objects
.
equals
(
detailDTO
.
getCommissionType
(),
CommissionTypeEnum
.
BL
.
getCod
e
()))
{
// 比例:基数 * 比例
// 比例:基数 * 比例
if
(
detailDTO
.
getCommissionTypeValue
()
!=
null
)
{
if
(
detailDTO
.
getCommissionTypeValue
()
!=
null
)
{
commission
=
detailDTO
.
getGmvOutput
()
commission
=
detailDTO
.
getGmvOutput
()
...
@@ -554,11 +554,11 @@ public class StaffPerformanceCalService {
...
@@ -554,11 +554,11 @@ public class StaffPerformanceCalService {
}
}
/**
/**
* 根据条件计算额外的
绩效
参数(如扣减、奖励、降档等)
* 根据条件计算额外的
提成
参数(如扣减、奖励、降档等)
*
*
* @param detailDTO
绩效
明细DTO
* @param detailDTO
提成
明细DTO
* @param paramConfig 当前
绩效
参数配置
* @param paramConfig 当前
提成
参数配置
* @param paramConfigs 该组所有
绩效
参数配置
* @param paramConfigs 该组所有
提成
参数配置
* @param context 计算上下文
* @param context 计算上下文
*/
*/
private
void
calculateByConditions
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
private
void
calculateByConditions
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
...
@@ -581,16 +581,33 @@ public class StaffPerformanceCalService {
...
@@ -581,16 +581,33 @@ public class StaffPerformanceCalService {
JSONObject
resultLog
=
new
JSONObject
();
JSONObject
resultLog
=
new
JSONObject
();
try
{
try
{
if
(
condition
.
getConditionType
()
==
1
)
{
PerformanceConditionTypeEnum
conditionTypeEnum
=
PerformanceConditionTypeEnum
skipPenetrationRateCondition
=
processPenetrationRateCondition
(
detailDTO
,
.
getByCode
(
condition
.
getConditionType
());
paramConfig
,
paramConfigs
,
if
(
conditionTypeEnum
==
null
)
{
context
,
condition
,
resultLog
,
skipPenetrationRateCondition
);
throw
new
RpcServiceException
(
"未知的条件类型: "
+
condition
.
getConditionType
());
}
else
if
(
condition
.
getConditionType
()
==
2
)
{
}
processOrderCountDeductionCondition
(
detailDTO
,
context
,
condition
,
resultLog
);
switch
(
conditionTypeEnum
)
{
}
else
if
(
condition
.
getConditionType
()
==
3
)
{
case
PENETRATION_RATE_LIMIT:
processTargetAchievementRewardCondition
(
detailDTO
,
condition
,
resultLog
);
skipPenetrationRateCondition
=
processPenetrationRateCondition
(
}
else
if
(
condition
.
getConditionType
()
==
4
)
{
detailDTO
,
processOrderExclusionCondition
(
detailDTO
,
context
,
condition
,
resultLog
);
paramConfig
,
paramConfigs
,
context
,
condition
,
resultLog
,
skipPenetrationRateCondition
);
break
;
case
ORDER_COUNT_DEDUCTION:
processOrderCountDeductionCondition
(
detailDTO
,
context
,
condition
,
resultLog
);
break
;
case
TARGET_ACHIEVEMENT_REWARD:
processTargetAchievementRewardCondition
(
detailDTO
,
condition
,
resultLog
);
break
;
case
ORDER_EXCLUSION_INCLUSION:
processOrderExclusionCondition
(
detailDTO
,
context
,
condition
,
resultLog
);
break
;
default
:
throw
new
RpcServiceException
(
"未处理的条件类型: "
+
conditionTypeEnum
);
}
}
}
catch
(
RpcServiceException
e
)
{
}
catch
(
RpcServiceException
e
)
{
// 业务异常主要针对渗透率限制的校验,需要抛出
// 业务异常主要针对渗透率限制的校验,需要抛出
...
@@ -610,15 +627,15 @@ public class StaffPerformanceCalService {
...
@@ -610,15 +627,15 @@ public class StaffPerformanceCalService {
paramsJson
.
put
(
"conditionExecutions"
,
conditionExecutions
);
paramsJson
.
put
(
"conditionExecutions"
,
conditionExecutions
);
detailDTO
.
setParamsJson
(
paramsJson
.
toJSONString
());
detailDTO
.
setParamsJson
(
paramsJson
.
toJSONString
());
log
.
info
(
"条件计算完成: staffPhone={}, paramsJson={}"
,
detailDTO
.
getStaffPhone
(),
paramsJson
.
toJSONString
());
log
.
debug
(
"条件计算完成: staffPhone={}, paramsJson={}"
,
detailDTO
.
getStaffPhone
(),
paramsJson
.
toJSONString
());
}
}
/**
/**
* 处理渗透率限制条件
* 处理渗透率限制条件
*
*
* @param detailDTO
绩效
明细DTO
* @param detailDTO
提成
明细DTO
* @param paramConfig 当前
绩效
参数配置
* @param paramConfig 当前
提成
参数配置
* @param paramConfigs 该组所有
绩效
参数配置
* @param paramConfigs 该组所有
提成
参数配置
* @param context 计算上下文
* @param context 计算上下文
* @param condition 当前条件
* @param condition 当前条件
* @param resultLog 结果日志
* @param resultLog 结果日志
...
@@ -646,18 +663,19 @@ public class StaffPerformanceCalService {
...
@@ -646,18 +663,19 @@ public class StaffPerformanceCalService {
resultLog
.
put
(
"limitStart"
,
condition
.
getConditionStartValue
());
resultLog
.
put
(
"limitStart"
,
condition
.
getConditionStartValue
());
resultLog
.
put
(
"limitEnd"
,
condition
.
getConditionEndValue
());
resultLog
.
put
(
"limitEnd"
,
condition
.
getConditionEndValue
());
// 判断是否在区间内 [start, end)
// 判断是否在区间内 [start, end]
boolean
inRange
=
false
;
BigDecimal
start
=
condition
.
getConditionStartValue
()
==
null
?
BigDecimal
.
ZERO
BigDecimal
start
=
condition
.
getConditionStartValue
()
==
null
?
BigDecimal
.
ZERO
:
condition
.
getConditionStartValue
();
:
condition
.
getConditionStartValue
();
BigDecimal
end
=
condition
.
getConditionEndValue
();
BigDecimal
end
=
condition
.
getConditionEndValue
();
boolean
inRange
;
if
(
conditionProductPenetrationRate
!=
null
)
{
if
(
end
==
null
)
{
if
(
end
==
null
)
{
inRange
=
conditionProductPenetrationRate
.
compareTo
(
start
)
>=
0
;
inRange
=
conditionProductPenetrationRate
.
compareTo
(
start
)
>=
0
;
}
else
{
}
else
{
inRange
=
conditionProductPenetrationRate
.
compareTo
(
start
)
>=
0
inRange
=
conditionProductPenetrationRate
.
compareTo
(
start
)
>=
0
&&
conditionProductPenetrationRate
.
compareTo
(
end
)
<=
0
;
&&
conditionProductPenetrationRate
.
compareTo
(
end
)
<=
0
;
}
}
}
log
.
info
(
"渗透率限制检查: rate={}, range=[{}, {}], pass={}"
,
conditionProductPenetrationRate
,
start
,
end
,
log
.
info
(
"渗透率限制检查: rate={}, range=[{}, {}], pass={}"
,
conditionProductPenetrationRate
,
start
,
end
,
inRange
);
inRange
);
...
@@ -671,9 +689,9 @@ public class StaffPerformanceCalService {
...
@@ -671,9 +689,9 @@ public class StaffPerformanceCalService {
/**
/**
* 处理降档逻辑
* 处理降档逻辑
*
*
* @param detailDTO
绩效
明细DTO
* @param detailDTO
提成
明细DTO
* @param paramConfig 当前
绩效
参数配置
* @param paramConfig 当前
提成
参数配置
* @param paramConfigs 该组所有
绩效
参数配置
* @param paramConfigs 该组所有
提成
参数配置
* @param resultLog 结果日志
* @param resultLog 结果日志
*/
*/
private
void
handleDegradation
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
private
void
handleDegradation
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
...
@@ -725,7 +743,7 @@ public class StaffPerformanceCalService {
...
@@ -725,7 +743,7 @@ public class StaffPerformanceCalService {
/**
/**
* 处理订单数不足扣减条件
* 处理订单数不足扣减条件
*
*
* @param detailDTO
绩效
明细DTO
* @param detailDTO
提成
明细DTO
* @param context 计算上下文
* @param context 计算上下文
* @param condition 当前条件
* @param condition 当前条件
* @param resultLog 结果日志
* @param resultLog 结果日志
...
@@ -783,7 +801,7 @@ public class StaffPerformanceCalService {
...
@@ -783,7 +801,7 @@ public class StaffPerformanceCalService {
/**
/**
* 处理整体指标达成奖励条件
* 处理整体指标达成奖励条件
*
*
* @param detailDTO
绩效
明细DTO
* @param detailDTO
提成
明细DTO
* @param condition 当前条件
* @param condition 当前条件
* @param resultLog 结果日志
* @param resultLog 结果日志
*/
*/
...
@@ -803,7 +821,7 @@ public class StaffPerformanceCalService {
...
@@ -803,7 +821,7 @@ public class StaffPerformanceCalService {
/**
/**
* 处理订单数剔除条件
* 处理订单数剔除条件
*
*
* @param detailDTO
绩效
明细DTO
* @param detailDTO
提成
明细DTO
* @param context 计算上下文
* @param context 计算上下文
* @param condition 当前条件
* @param condition 当前条件
* @param resultLog 结果日志
* @param resultLog 结果日志
...
@@ -816,7 +834,7 @@ public class StaffPerformanceCalService {
...
@@ -816,7 +834,7 @@ public class StaffPerformanceCalService {
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getChildBrandId
());
context
.
getChildBrandId
());
List
<
StaffPerformanceSubOrderDTO
>
orders
=
context
.
getGroupedOrdersMap
().
get
(
groupKey
);
List
<
StaffPerformanceSubOrderDTO
>
orders
=
context
.
getGroupedOrdersMap
().
get
(
groupKey
);
int
excludedOrderCount
=
(
int
)
StaffPerformanceOrderUtil
.
countMatchingOrders
(
orders
,
Integer
excludedOrderCount
=
StaffPerformanceOrderUtil
.
countMatchingOrders
(
orders
,
condition
.
getConditionGoodsConfigType
(),
condition
.
getConditionGoodsConfigType
(),
condition
.
getConditionGoodsType
(),
condition
.
getConditionGoodsType
(),
condition
.
getConditionSecondaryGoodsType
(),
condition
.
getConditionSecondaryGoodsType
(),
...
@@ -1006,7 +1024,7 @@ public class StaffPerformanceCalService {
...
@@ -1006,7 +1024,7 @@ public class StaffPerformanceCalService {
childBrandId
,
childBrandId
,
context
.
getPerformanceMonth
());
context
.
getPerformanceMonth
());
if
(
config
==
null
)
{
if
(
config
==
null
)
{
log
.
error
(
"未找到有效的
绩效
配置,不计算提成: merchantId={}, brandId={}, month={}"
,
log
.
error
(
"未找到有效的
提成
配置,不计算提成: merchantId={}, brandId={}, month={}"
,
merchantId
,
brandId
,
context
.
getPerformanceMonth
());
merchantId
,
brandId
,
context
.
getPerformanceMonth
());
return
;
return
;
}
}
...
@@ -1014,7 +1032,7 @@ public class StaffPerformanceCalService {
...
@@ -1014,7 +1032,7 @@ public class StaffPerformanceCalService {
context
.
setPerformanceConfig
(
config
);
context
.
setPerformanceConfig
(
config
);
if
(
CollectionUtils
.
isEmpty
(
config
.
getPerformanceParamConfigs
()))
{
if
(
CollectionUtils
.
isEmpty
(
config
.
getPerformanceParamConfigs
()))
{
log
.
error
(
"未找到
绩效
参数配置,不计算提成: configId:{}"
,
config
.
getId
());
log
.
error
(
"未找到
提成
参数配置,不计算提成: configId:{}"
,
config
.
getId
());
return
;
return
;
}
}
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
=
thiz
.
evaluatePerformanceConfigs
(
context
);
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
=
thiz
.
evaluatePerformanceConfigs
(
context
);
...
@@ -1028,14 +1046,14 @@ public class StaffPerformanceCalService {
...
@@ -1028,14 +1046,14 @@ public class StaffPerformanceCalService {
}
}
/**
/**
* 获取有效的
绩效
配置
* 获取有效的
提成
配置
*
*
* @param merchantId 商户ID
* @param merchantId 商户ID
* @param businessType 业务类型
* @param businessType 业务类型
* @param brandId 品牌ID
* @param brandId 品牌ID
* @param childBrandId 子品牌ID
* @param childBrandId 子品牌ID
* @param month 月份
* @param month 月份
* @return
绩效
配置DTO
* @return
提成
配置DTO
*/
*/
private
PerformanceConfigDTO
getEffectivePerformanceConfig
(
Integer
merchantId
,
Byte
businessType
,
private
PerformanceConfigDTO
getEffectivePerformanceConfig
(
Integer
merchantId
,
Byte
businessType
,
Integer
brandId
,
Integer
brandId
,
...
@@ -1054,7 +1072,7 @@ public class StaffPerformanceCalService {
...
@@ -1054,7 +1072,7 @@ public class StaffPerformanceCalService {
.
build
();
.
build
();
PerformanceConfigDTO
config
=
performanceConfigService
.
selectEffectiveConfig
(
queryConfig
);
PerformanceConfigDTO
config
=
performanceConfigService
.
selectEffectiveConfig
(
queryConfig
);
if
(
config
==
null
)
{
if
(
config
==
null
)
{
log
.
warn
(
"未找到有效的
绩效
配置: merchantId={}, businessType={}, brandId={}, childBrandId={}, month={}"
,
log
.
warn
(
"未找到有效的
提成
配置: merchantId={}, businessType={}, brandId={}, childBrandId={}, month={}"
,
merchantId
,
businessType
,
brandId
,
childBrandId
,
month
);
merchantId
,
businessType
,
brandId
,
childBrandId
,
month
);
}
}
return
config
;
return
config
;
...
@@ -1088,9 +1106,9 @@ public class StaffPerformanceCalService {
...
@@ -1088,9 +1106,9 @@ public class StaffPerformanceCalService {
assessmentFactor
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
assessmentFactor
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefineId
);
thirdLevelGoodsType
,
productDefineId
);
if
(
Objects
.
equals
(
firstConfig
.
getCommissionType
(),
Commission
Method
Enum
.
XS
.
getCode
())
if
(
Objects
.
equals
(
firstConfig
.
getCommissionType
(),
Commission
Type
Enum
.
XS
.
getCode
())
&&
!
Objects
.
equals
(
goodsConfigType
,
&&
!
Objects
.
equals
(
goodsConfigType
,
Product
ConfigTypeEnum
.
ALL_PRODUCT
.
getCode
()))
{
Goods
ConfigTypeEnum
.
ALL_PRODUCT
.
getCode
()))
{
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"系数计算方式必须指定为全部品类"
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"系数计算方式必须指定为全部品类"
);
}
}
BigDecimal
actualValue
=
getActualValue
(
assessmentFactor
,
context
,
BigDecimal
actualValue
=
getActualValue
(
assessmentFactor
,
context
,
...
@@ -1104,10 +1122,14 @@ public class StaffPerformanceCalService {
...
@@ -1104,10 +1122,14 @@ public class StaffPerformanceCalService {
goodsConfigType
,
goodsType
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefineId
,
assessmentFactor
,
actualValue
);
productDefineId
,
assessmentFactor
,
actualValue
);
if
(
actualValue
==
null
)
{
log
.
warn
(
"实际值为空,跳过计算"
);
continue
;
}
for
(
PerformanceParamConfigDTO
paramConfig
:
paramConfigs
)
{
for
(
PerformanceParamConfigDTO
paramConfig
:
paramConfigs
)
{
if
(
isConfigMatch
(
paramConfig
,
actualValue
))
{
if
(
isConfigMatch
(
paramConfig
,
actualValue
))
{
log
.
info
(
"匹配到
绩效
配置ID: {}"
,
paramConfig
.
getId
());
log
.
info
(
"匹配到
提成
配置ID: {}"
,
paramConfig
.
getId
());
StaffPerformanceDetailDTO
performanceDTO
=
createPerformanceDetailDTO
(
context
,
StaffPerformanceDetailDTO
performanceDTO
=
createPerformanceDetailDTO
(
context
,
paramConfig
,
actualValue
,
paramConfigs
);
paramConfig
,
actualValue
,
paramConfigs
);
groupResults
.
add
(
performanceDTO
);
groupResults
.
add
(
performanceDTO
);
...
@@ -1158,15 +1180,25 @@ public class StaffPerformanceCalService {
...
@@ -1158,15 +1180,25 @@ public class StaffPerformanceCalService {
final
List
<
Byte
>
validOrderTypes
=
getValidDjOrderTypesForCommissionBasic
();
final
List
<
Byte
>
validOrderTypes
=
getValidDjOrderTypesForCommissionBasic
();
// 3. 根据配置类型分别处理
// 3. 根据配置类型分别处理
if
(
Objects
.
equals
(
ProductConfigTypeEnum
.
PRODUCT_CATEGORY
.
getCode
(),
goodsConfigType
)
GoodsConfigTypeEnum
configType
=
GoodsConfigTypeEnum
.
getByCode
(
goodsConfigType
);
||
Objects
.
equals
(
ProductConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
if
(
configType
==
null
)
{
goodsConfigType
))
{
processCategoryOrProductData
(
context
,
orders
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefine
,
validOrderTypes
);
}
else
if
(
Objects
.
equals
(
ProductConfigTypeEnum
.
DESIGNATED_PACKAGE
.
getCode
(),
goodsConfigType
))
{
processPackageData
(
context
,
orders
,
productDefine
,
validOrderTypes
);
}
else
{
log
.
warn
(
"未知的商品配置类型: {}"
,
goodsConfigType
);
log
.
warn
(
"未知的商品配置类型: {}"
,
goodsConfigType
);
return
;
}
switch
(
configType
)
{
case
DESIGNATED_PACKAGE:
processPackageData
(
context
,
orders
,
productDefine
,
validOrderTypes
);
break
;
case
ALL_PRODUCT:
case
PRODUCT_CATEGORY:
case
DESIGNATED_PRODUCT:
processCategoryOrProductData
(
context
,
orders
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefine
,
validOrderTypes
);
break
;
default
:
log
.
warn
(
"未知的商品配置类型: {}"
,
goodsConfigType
);
break
;
}
}
}
}
...
@@ -1179,8 +1211,8 @@ public class StaffPerformanceCalService {
...
@@ -1179,8 +1211,8 @@ public class StaffPerformanceCalService {
*/
*/
private
MerchantPerformanceProductDefineDTO
getMerchantPerformanceProductDefine
(
Byte
goodsConfigType
,
private
MerchantPerformanceProductDefineDTO
getMerchantPerformanceProductDefine
(
Byte
goodsConfigType
,
Integer
productDefineId
)
{
Integer
productDefineId
)
{
if
(
Objects
.
equals
(
Product
ConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
goodsConfigType
)
if
(
Objects
.
equals
(
Goods
ConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
goodsConfigType
)
||
Objects
.
equals
(
Product
ConfigTypeEnum
.
DESIGNATED_PACKAGE
.
getCode
(),
||
Objects
.
equals
(
Goods
ConfigTypeEnum
.
DESIGNATED_PACKAGE
.
getCode
(),
goodsConfigType
))
{
goodsConfigType
))
{
RpcAssert
.
assertNotNull
(
productDefineId
,
DefaultErrorEnum
.
DATA_NULL
,
"圈定商品ID不能为空"
);
RpcAssert
.
assertNotNull
(
productDefineId
,
DefaultErrorEnum
.
DATA_NULL
,
"圈定商品ID不能为空"
);
MerchantPerformanceProductDefineDTO
productDefine
=
merchantPerformanceProductDefineRemote
MerchantPerformanceProductDefineDTO
productDefine
=
merchantPerformanceProductDefineRemote
...
@@ -1238,7 +1270,7 @@ public class StaffPerformanceCalService {
...
@@ -1238,7 +1270,7 @@ public class StaffPerformanceCalService {
orderData
.
setSubOrderCountByBrandAndCategory
(
subOrderCount
);
orderData
.
setSubOrderCountByBrandAndCategory
(
subOrderCount
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
log
.
info
(
"品类/单品基础数据: mainOrderCount={}, subOrderCount={}, outputTotal={}"
,
mainOrderCount
,
log
.
debug
(
"品类/单品基础数据: mainOrderCount={}, subOrderCount={}, outputTotal={}"
,
mainOrderCount
,
subOrderCount
,
subOrderCount
,
outputTotal
);
outputTotal
);
...
@@ -1255,7 +1287,7 @@ public class StaffPerformanceCalService {
...
@@ -1255,7 +1287,7 @@ public class StaffPerformanceCalService {
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
commissionBaseSubOrderCount
);
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
commissionBaseSubOrderCount
);
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
commissionBaseOutputTotal
);
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
commissionBaseOutputTotal
);
log
.
info
(
"品类/单品提成基数数据: baseSubOrderCount={}, baseOutputTotal={}"
,
commissionBaseSubOrderCount
,
log
.
debug
(
"品类/单品提成基数数据: baseSubOrderCount={}, baseOutputTotal={}"
,
commissionBaseSubOrderCount
,
commissionBaseOutputTotal
);
commissionBaseOutputTotal
);
}
}
...
@@ -1299,7 +1331,7 @@ public class StaffPerformanceCalService {
...
@@ -1299,7 +1331,7 @@ public class StaffPerformanceCalService {
orderData
.
setSubOrderCountByBrandAndCategory
(
subOrderCount
);
orderData
.
setSubOrderCountByBrandAndCategory
(
subOrderCount
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
log
.
info
(
"套系基础数据: mainOrderCount={}, outputTotal={}"
,
mainOrderCount
,
outputTotal
);
log
.
debug
(
"套系基础数据: mainOrderCount={}, outputTotal={}"
,
mainOrderCount
,
outputTotal
);
// 计算提成基数相关数据 (过滤特定订单类型)
// 计算提成基数相关数据 (过滤特定订单类型)
// 注意:这里原文是 filter groupedOrders.values() 再 filter matchPackage,这里直接复用
// 注意:这里原文是 filter groupedOrders.values() 再 filter matchPackage,这里直接复用
...
@@ -1319,7 +1351,7 @@ public class StaffPerformanceCalService {
...
@@ -1319,7 +1351,7 @@ public class StaffPerformanceCalService {
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
commissionBaseMainOrderCount
);
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
commissionBaseMainOrderCount
);
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
commissionBaseOutputTotal
);
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
commissionBaseOutputTotal
);
log
.
info
(
"套系提成基数数据: baseMainOrderCount={}, baseOutputTotal={}"
,
commissionBaseMainOrderCount
,
log
.
debug
(
"套系提成基数数据: baseMainOrderCount={}, baseOutputTotal={}"
,
commissionBaseMainOrderCount
,
commissionBaseOutputTotal
);
commissionBaseOutputTotal
);
}
}
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceDetailService.java
View file @
bbe0524
...
@@ -50,9 +50,9 @@ public class StaffPerformanceDetailService {
...
@@ -50,9 +50,9 @@ public class StaffPerformanceDetailService {
return
;
return
;
}
}
// 1. 调用mapper,通过update更新相同merchantId businessType brandId childBrandId
// 1. 逻辑删除旧数据
// performanceMonth的记录的deletedFlag = 'D'
StaffPerformanceDetail
query
=
StaffPerformanceDetail
.
builder
()
StaffPerformanceDetail
query
=
StaffPerformanceDetail
.
builder
()
.
staffPhone
(
performanceDetailDTOS
.
get
(
0
).
getStaffPhone
())
.
merchantId
(
config
.
getMerchantId
())
.
merchantId
(
config
.
getMerchantId
())
.
businessType
(
config
.
getBusinessType
())
.
businessType
(
config
.
getBusinessType
())
.
brandId
(
config
.
getBrandId
())
.
brandId
(
config
.
getBrandId
())
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceService.java
View file @
bbe0524
...
@@ -5,7 +5,7 @@ import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
...
@@ -5,7 +5,7 @@ import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.enums.Commission
Method
Enum
;
import
cn.com.glsx.dj.staff.enums.Commission
Type
Enum
;
import
cn.com.glsx.dj.staff.mapper.StaffPerformanceMapper
;
import
cn.com.glsx.dj.staff.mapper.StaffPerformanceMapper
;
import
cn.com.glsx.dj.staff.model.StaffBeisenBaseInfo
;
import
cn.com.glsx.dj.staff.model.StaffBeisenBaseInfo
;
import
cn.com.glsx.dj.staff.model.StaffPerformance
;
import
cn.com.glsx.dj.staff.model.StaffPerformance
;
...
@@ -52,43 +52,31 @@ public class StaffPerformanceService {
...
@@ -52,43 +52,31 @@ public class StaffPerformanceService {
log
.
error
(
"输入数据无效: context 为空或 performanceDetailDTOS 为空"
);
log
.
error
(
"输入数据无效: context 为空或 performanceDetailDTOS 为空"
);
return
;
return
;
}
}
String
staffPhone
=
context
.
getStaffPhone
();
// 1. 根据 merchantId, businessType, brandId, childBrandId 分组
Integer
merchantId
=
context
.
getMerchantId
();
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupedMap
=
groupPerformanceDetails
(
performanceDetailDTOS
);
Byte
businessType
=
context
.
getBusinessType
();
Integer
brandId
=
context
.
getBrandId
();
Integer
childBrandId
=
context
.
getChildBrandId
();
String
performanceMonth
=
context
.
getPerformanceMonth
();
if
(
merchantId
==
null
||
businessType
==
null
||
brandId
==
null
||
childBrandId
==
null
||
StringUtils
.
isBlank
(
performanceMonth
)
||
StringUtils
.
isBlank
(
staffPhone
))
{
log
.
error
(
"输入数据无效: merchantId={}, businessType={}, brandId={}, childBrandId={}, performanceMonth={}, staffPhone={}"
,
merchantId
,
businessType
,
brandId
,
childBrandId
,
performanceMonth
,
staffPhone
);
return
;
}
// 2. 检查是否处于新人保护期
// 2. 检查是否处于新人保护期
boolean
isNewcomerProtection
=
checkNewcomerProtection
(
context
.
getStaffPhone
(),
context
.
getPerformanceMonth
());
boolean
isNewcomerProtection
=
checkNewcomerProtection
(
context
.
getStaffPhone
(),
context
.
getPerformanceMonth
());
List
<
StaffPerformance
>
insertList
=
new
ArrayList
<>();
// 3. 构建 StaffPerformance
Date
now
=
new
Date
();
StaffPerformance
staffPerformance
=
buildStaffPerformance
(
performanceDetailDTOS
,
context
,
isNewcomerProtection
);
for
(
List
<
StaffPerformanceDetailDTO
>
groupList
:
groupedMap
.
values
())
{
if
(
CollectionUtils
.
isEmpty
(
groupList
))
{
continue
;
}
// 3. 构建 StaffPerformance
StaffPerformance
staffPerformance
=
buildStaffPerformance
(
groupList
,
context
,
isNewcomerProtection
,
now
);
insertList
.
add
(
staffPerformance
);
// 4. 逻辑删除旧数据
// 4. 逻辑删除旧数据
staffPerformanceMapper
.
removeStaffPerformance
(
staffPerformance
);
staffPerformanceMapper
.
removeStaffPerformance
(
staffPerformance
);
}
// 5. 批量插入新数据
if
(
CollectionUtils
.
isNotEmpty
(
insertList
))
{
staffPerformanceMapper
.
insertList
(
insertList
);
}
}
/**
// 5. 插入新数据
* 对详情数据进行分组
staffPerformanceMapper
.
insertSelective
(
staffPerformance
);
*/
private
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupPerformanceDetails
(
List
<
StaffPerformanceDetailDTO
>
details
)
{
return
details
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
dto
->
dto
.
getMerchantId
()
+
"_"
+
dto
.
getBusinessType
()
+
"_"
+
dto
.
getBrandId
()
+
"_"
+
dto
.
getChildBrandId
()));
}
}
/**
/**
...
@@ -136,8 +124,7 @@ public class StaffPerformanceService {
...
@@ -136,8 +124,7 @@ public class StaffPerformanceService {
*/
*/
private
StaffPerformance
buildStaffPerformance
(
List
<
StaffPerformanceDetailDTO
>
groupList
,
private
StaffPerformance
buildStaffPerformance
(
List
<
StaffPerformanceDetailDTO
>
groupList
,
StaffPerformanceCalContextDTO
context
,
StaffPerformanceCalContextDTO
context
,
boolean
isNewcomerProtection
,
boolean
isNewcomerProtection
)
{
Date
now
)
{
StaffPerformanceDetailDTO
first
=
groupList
.
get
(
0
);
StaffPerformanceDetailDTO
first
=
groupList
.
get
(
0
);
StaffPerformance
staffPerformance
=
new
StaffPerformance
();
StaffPerformance
staffPerformance
=
new
StaffPerformance
();
...
@@ -153,6 +140,7 @@ public class StaffPerformanceService {
...
@@ -153,6 +140,7 @@ public class StaffPerformanceService {
staffPerformance
.
setChildBrandName
(
first
.
getChildBrandName
());
staffPerformance
.
setChildBrandName
(
first
.
getChildBrandName
());
staffPerformance
.
setMonth
(
first
.
getMonth
());
staffPerformance
.
setMonth
(
first
.
getMonth
());
Date
now
=
new
Date
();
staffPerformance
.
setCreatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
staffPerformance
.
setCreatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
staffPerformance
.
setUpdatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
staffPerformance
.
setUpdatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
staffPerformance
.
setCreatedDate
(
now
);
staffPerformance
.
setCreatedDate
(
now
);
...
@@ -193,7 +181,7 @@ public class StaffPerformanceService {
...
@@ -193,7 +181,7 @@ public class StaffPerformanceService {
// 遍历详情计算
// 遍历详情计算
for
(
StaffPerformanceDetailDTO
detail
:
groupList
)
{
for
(
StaffPerformanceDetailDTO
detail
:
groupList
)
{
// 判断是否为系数类型 (假设 'XS' 为系数代码)
// 判断是否为系数类型 (假设 'XS' 为系数代码)
if
(
Commission
Method
Enum
.
XS
.
getCode
().
equals
(
detail
.
getCommissionType
()))
{
if
(
Commission
Type
Enum
.
XS
.
getCode
().
equals
(
detail
.
getCommissionType
()))
{
if
(
detail
.
getCommissionTypeValue
()
!=
null
)
{
if
(
detail
.
getCommissionTypeValue
()
!=
null
)
{
multiplyCoeff
=
multiplyCoeff
.
multiply
(
detail
.
getCommissionTypeValue
());
multiplyCoeff
=
multiplyCoeff
.
multiply
(
detail
.
getCommissionTypeValue
());
}
}
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffProductPerformanceService.java
View file @
bbe0524
...
@@ -7,15 +7,20 @@ import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
...
@@ -7,15 +7,20 @@ import cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.enums.CommissionTypeEnum
;
import
cn.com.glsx.dj.staff.enums.GoodsConfigTypeEnum
;
import
cn.com.glsx.dj.staff.mapper.StaffProductPerformanceMapper
;
import
cn.com.glsx.dj.staff.mapper.StaffProductPerformanceMapper
;
import
cn.com.glsx.dj.staff.model.StaffProductPerformance
;
import
cn.com.glsx.dj.staff.model.StaffProductPerformance
;
import
cn.com.glsx.dj.staff.service.perfSalary.AutoPerformRuleService
;
import
cn.com.glsx.dj.staff.service.staffPerformance.util.StaffPerformanceOrderUtil
;
import
cn.com.glsx.dj.staff.service.staffPerformance.util.StaffPerformanceOrderUtil
;
import
cn.com.glsx.dj.staff.util.DataCalUtil
;
import
cn.com.glsx.dj.staff.util.DataCalUtil
;
import
cn.com.glsx.framework.core.beans.BaseModel.DeletedFlagEnum
;
import
cn.com.glsx.framework.core.beans.BaseModel.DeletedFlagEnum
;
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.framework.core.util.RpcAssert
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.dubbo.common.utils.StringUtils
;
import
org.oreframework.boot.env.OrePropertyConfigurer
;
import
org.oreframework.boot.env.OrePropertyConfigurer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.context.annotation.Lazy
;
...
@@ -23,6 +28,8 @@ import org.springframework.stereotype.Service;
...
@@ -23,6 +28,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.ctc.wstx.util.StringUtil
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -32,6 +39,8 @@ import java.util.stream.Collectors;
...
@@ -32,6 +39,8 @@ import java.util.stream.Collectors;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
RpcServiceException
.
class
)
public
class
StaffProductPerformanceService
{
public
class
StaffProductPerformanceService
{
private
final
AutoPerformRuleService
autoPerformRuleService
;
@Lazy
@Lazy
@Autowired
@Autowired
private
StaffProductPerformanceService
thiz
;
private
StaffProductPerformanceService
thiz
;
...
@@ -40,6 +49,10 @@ public class StaffProductPerformanceService {
...
@@ -40,6 +49,10 @@ public class StaffProductPerformanceService {
@Autowired
@Autowired
private
MerchantPerformanceProductDefineRemote
merchantPerformanceProductDefineRemote
;
private
MerchantPerformanceProductDefineRemote
merchantPerformanceProductDefineRemote
;
StaffProductPerformanceService
(
AutoPerformRuleService
autoPerformRuleService
)
{
this
.
autoPerformRuleService
=
autoPerformRuleService
;
}
public
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
StaffProductPerformanceDTO
dto
)
{
public
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
StaffProductPerformanceDTO
dto
)
{
try
{
try
{
return
staffProductPerformanceMapper
.
listStaffPerformance
(
dto
);
return
staffProductPerformanceMapper
.
listStaffPerformance
(
dto
);
...
@@ -57,18 +70,26 @@ public class StaffProductPerformanceService {
...
@@ -57,18 +70,26 @@ public class StaffProductPerformanceService {
log
.
error
(
"saveStaffProductPerformance param error 1"
);
log
.
error
(
"saveStaffProductPerformance param error 1"
);
return
;
return
;
}
}
if
(
context
.
getMerchantId
()
==
null
||
context
.
getBusinessType
()
==
null
||
context
.
getBrandId
()
==
null
Integer
merchantId
=
context
.
getMerchantId
();
||
context
.
getChildBrandId
()
==
null
||
context
.
getPerformanceMonth
()
==
null
Byte
businessType
=
context
.
getBusinessType
();
||
context
.
getStaffPhone
()
==
null
)
{
Integer
brandId
=
context
.
getBrandId
();
Integer
childBrandId
=
context
.
getChildBrandId
();
String
performanceMonth
=
context
.
getPerformanceMonth
();
String
staffPhone
=
context
.
getStaffPhone
();
if
(
merchantId
==
null
||
businessType
==
null
||
brandId
==
null
||
childBrandId
==
null
||
StringUtils
.
isBlank
(
performanceMonth
)
||
StringUtils
.
isBlank
(
staffPhone
))
{
log
.
error
(
"saveStaffProductPerformance param error 2"
);
log
.
error
(
"saveStaffProductPerformance param error 2"
);
return
;
return
;
}
}
log
.
info
(
"saveStaffProductPerformance, staffPhone:{}, performanceMonth:{}, merchantId:{}, businessType:{}, brandId:{}, childBrandId:{}, "
,
staffPhone
,
performanceMonth
,
merchantId
,
businessType
,
brandId
,
childBrandId
);
// 2. 构建StaffProductPerformance列表
// 2. 构建StaffProductPerformance列表
List
<
StaffProductPerformance
>
insertList
=
buildStaffProductPerformances
(
context
,
performanceDetailDTOS
);
List
<
StaffProductPerformance
>
insertList
=
buildStaffProductPerformances
(
context
,
performanceDetailDTOS
);
// 3. 逻辑删除之前的数据
// 3. 逻辑删除之前的数据
staffProductPerformanceMapper
.
removeStaffProductPerformance
(
int
removeStaffProductPerformance
=
staffProductPerformanceMapper
.
removeStaffProductPerformance
(
context
.
getMerchantId
(),
context
.
getMerchantId
(),
context
.
getBusinessType
(),
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getBrandId
(),
...
@@ -76,15 +97,22 @@ public class StaffProductPerformanceService {
...
@@ -76,15 +97,22 @@ public class StaffProductPerformanceService {
context
.
getPerformanceMonth
(),
context
.
getPerformanceMonth
(),
context
.
getStaffPhone
(),
context
.
getStaffPhone
(),
CommonConstants
.
DEFAULT_UPDATE_BY
);
CommonConstants
.
DEFAULT_UPDATE_BY
);
log
.
debug
(
"removeStaffProductPerformance, removeStaffProductPerformance count:{}, "
,
removeStaffProductPerformance
);
// 4.入库
// 4.入库
if
(
CollectionUtils
.
isNotEmpty
(
insertList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
insertList
))
{
staffProductPerformanceMapper
.
insertList
(
insertList
);
staffProductPerformanceMapper
.
insertList
(
insertList
);
log
.
debug
(
"insertStaffProductPerformance, insertStaffProductPerformance count:{}, "
,
insertList
.
size
());
}
}
}
}
private
List
<
StaffProductPerformance
>
buildStaffProductPerformances
(
StaffPerformanceCalContextDTO
context
,
private
List
<
StaffProductPerformance
>
buildStaffProductPerformances
(
StaffPerformanceCalContextDTO
context
,
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
)
{
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
)
{
if
(
CollectionUtils
.
isEmpty
(
performanceDetailDTOS
))
{
return
new
ArrayList
<>();
}
// 品类分组
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupedMap
=
performanceDetailDTOS
.
stream
()
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupedMap
=
performanceDetailDTOS
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
this
::
generateGroupKey
));
.
collect
(
Collectors
.
groupingBy
(
this
::
generateGroupKey
));
List
<
StaffProductPerformance
>
insertList
=
new
ArrayList
<>();
List
<
StaffProductPerformance
>
insertList
=
new
ArrayList
<>();
...
@@ -98,7 +126,7 @@ public class StaffProductPerformanceService {
...
@@ -98,7 +126,7 @@ public class StaffProductPerformanceService {
// 2.2 累计得到提成金额
// 2.2 累计得到提成金额
BigDecimal
totalAmount
=
dtoList
.
stream
()
BigDecimal
totalAmount
=
dtoList
.
stream
()
.
filter
(
d
->
!
"XS"
.
equals
(
d
.
getCommissionType
()))
.
filter
(
d
->
!
CommissionTypeEnum
.
XS
.
getCode
()
.
equals
(
d
.
getCommissionType
()))
.
map
(
d
->
Optional
.
ofNullable
(
d
.
getPerformanceAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
map
(
d
->
Optional
.
ofNullable
(
d
.
getPerformanceAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
productPerformance
.
setPerformanceAmount
(
totalAmount
);
productPerformance
.
setPerformanceAmount
(
totalAmount
);
...
@@ -153,22 +181,13 @@ public class StaffProductPerformanceService {
...
@@ -153,22 +181,13 @@ public class StaffProductPerformanceService {
private
void
calculateAndFillMetrics
(
StaffProductPerformance
productPerformance
,
private
void
calculateAndFillMetrics
(
StaffProductPerformance
productPerformance
,
StaffPerformanceDetailDTO
detailDTO
,
StaffPerformanceCalContextDTO
context
)
{
StaffPerformanceDetailDTO
detailDTO
,
StaffPerformanceCalContextDTO
context
)
{
Byte
goodsConfigType
=
detailDTO
.
getGoodsConfigType
();
Byte
goodsConfigType
=
detailDTO
.
getGoodsConfigType
();
Integer
goodsType
=
detailDTO
.
getGoodsType
();
Integer
secondaryGoodsType
=
detailDTO
.
getSecondaryGoodsType
();
Integer
thirdLevelGoodsType
=
detailDTO
.
getThirdLevelGoodsType
();
Integer
productDefineId
=
detailDTO
.
getProductDefineId
();
Integer
productDefineId
=
detailDTO
.
getProductDefineId
();
MerchantPerformanceProductDefineDTO
productDefine
=
null
;
// 1. 获取产品定义配置
if
(
goodsConfigType
!=
null
&&
(
goodsConfigType
==
1
||
goodsConfigType
==
2
))
{
MerchantPerformanceProductDefineDTO
productDefine
=
fetchProductDefine
(
goodsConfigType
,
productDefineId
);
if
(
productDefineId
!=
null
)
{
productDefine
=
merchantPerformanceProductDefineRemote
.
getByIdWithRadicalUpgradeGoodsItem
(
productDefineId
).
getResult
();
}
}
String
groupKey
=
StaffPerformanceCalService
.
generateGroupOrderMapKey
(
context
.
getMerchantId
(),
// 2. 获取当前层级关联的所有原始订单
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getChildBrandId
());
List
<
StaffPerformanceSubOrderDTO
>
orders
=
getRelevantOrders
(
context
);
List
<
StaffPerformanceSubOrderDTO
>
orders
=
context
.
getGroupedOrdersMap
().
get
(
groupKey
);
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
productPerformance
.
setUpgradeOrderNum
(
0
);
productPerformance
.
setUpgradeOrderNum
(
0
);
productPerformance
.
setPersonalPenetrationRate
(
BigDecimal
.
ZERO
);
productPerformance
.
setPersonalPenetrationRate
(
BigDecimal
.
ZERO
);
...
@@ -176,62 +195,126 @@ public class StaffProductPerformanceService {
...
@@ -176,62 +195,126 @@ public class StaffProductPerformanceService {
return
;
return
;
}
}
// 过滤订单
// 3. 根据配置类型计算指标(升级订单数、产值)
final
MerchantPerformanceProductDefineDTO
finalProductDefine
=
productDefine
;
MetricsResult
metrics
=
calculateMetricsByConfigType
(
orders
,
detailDTO
,
productDefine
);
final
List
<
Byte
>
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
=
Arrays
.
stream
(
OrePropertyConfigurer
productPerformance
.
setUpgradeOrderNum
(
metrics
.
getUpgradeOrderNum
());
productPerformance
.
setGmvOutput
(
metrics
.
getGmvOutput
());
// 4. 计算并填充个人渗透率
BigDecimal
penetrationRate
=
calculatePersonalPenetrationRate
(
context
,
metrics
.
getUpgradeOrderNum
());
productPerformance
.
setPersonalPenetrationRate
(
penetrationRate
);
}
private
MerchantPerformanceProductDefineDTO
fetchProductDefine
(
Byte
goodsConfigType
,
Integer
productDefineId
)
{
if
(
goodsConfigType
==
null
||
productDefineId
==
null
)
{
return
null
;
}
GoodsConfigTypeEnum
configTypeEnum
=
GoodsConfigTypeEnum
.
getByCode
(
goodsConfigType
);
if
(
configTypeEnum
==
GoodsConfigTypeEnum
.
DESIGNATED_PRODUCT
||
configTypeEnum
==
GoodsConfigTypeEnum
.
DESIGNATED_PACKAGE
)
{
return
merchantPerformanceProductDefineRemote
.
getByIdWithRadicalUpgradeGoodsItem
(
productDefineId
).
getResult
();
}
return
null
;
}
private
List
<
StaffPerformanceSubOrderDTO
>
getRelevantOrders
(
StaffPerformanceCalContextDTO
context
)
{
String
groupKey
=
StaffPerformanceCalService
.
generateGroupOrderMapKey
(
context
.
getMerchantId
(),
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getChildBrandId
());
return
context
.
getGroupedOrdersMap
().
get
(
groupKey
);
}
private
MetricsResult
calculateMetricsByConfigType
(
List
<
StaffPerformanceSubOrderDTO
>
orders
,
StaffPerformanceDetailDTO
detailDTO
,
MerchantPerformanceProductDefineDTO
productDefine
)
{
final
List
<
Byte
>
validDjOrderTypes
=
Arrays
.
stream
(
OrePropertyConfigurer
.
getString
(
"valid.dj.order.type.for.commission.basic"
,
"1,5"
).
split
(
","
))
.
getString
(
"valid.dj.order.type.for.commission.basic"
,
"1,5"
).
split
(
","
))
.
map
(
Byte:
:
parseByte
).
collect
(
Collectors
.
toList
());
.
map
(
Byte:
:
parseByte
).
collect
(
Collectors
.
toList
());
long
upgradeOrderNum
=
0
;
long
upgradeOrderNum
=
0
;
BigDecimal
gmvOutput
=
BigDecimal
.
ZERO
;
BigDecimal
gmvOutput
=
BigDecimal
.
ZERO
;
if
(
goodsConfigType
!=
null
&&
goodsConfigType
==
2
)
{
GoodsConfigTypeEnum
configTypeEnum
=
GoodsConfigTypeEnum
.
getByCode
(
detailDTO
.
getGoodsConfigType
());
// 套餐逻辑
if
(
configTypeEnum
==
null
)
{
if
(
finalProductDefine
!=
null
&&
CollectionUtils
.
isNotEmpty
(
finalProductDefine
.
getPackageItemList
()))
{
return
new
MetricsResult
(
0
,
BigDecimal
.
ZERO
);
}
switch
(
configTypeEnum
)
{
case
DESIGNATED_PACKAGE:
// 套餐逻辑
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NOT_EXIST
,
"productDefine is null"
);
RpcAssert
.
assertNotEmpty
(
productDefine
.
getPackageItemList
(),
DefaultErrorEnum
.
DATA_NOT_EXIST
,
"productDefine.getPackageItemList() is empty"
);
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrders
=
orders
.
stream
()
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrders
=
orders
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
));
.
collect
(
Collectors
.
groupingBy
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
));
// 计算产值 (所有匹配的子订单)
// 计算产值 (所有匹配的子订单)
gmvOutput
=
groupedOrders
.
values
().
stream
()
gmvOutput
=
groupedOrders
.
values
().
stream
()
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.
filter
(
o
->
validDjOrderTypes
.
contains
(
o
.
get
(
0
).
getDjOrderType
()))
.
contains
(
o
.
get
(
0
).
getDjOrderType
()))
.
flatMap
(
o
->
StaffPerformanceOrderUtil
.
flatMap
(
o
->
StaffPerformanceOrderUtil
.
matchPackageSubOrders
(
o
,
finalP
roductDefine
.
getPackageItemList
()).
stream
())
.
matchPackageSubOrders
(
o
,
p
roductDefine
.
getPackageItemList
()).
stream
())
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
// 计算升级订单数
(满足 commission basic 类型的)
// 计算升级订单数
upgradeOrderNum
=
groupedOrders
.
values
().
stream
()
upgradeOrderNum
=
groupedOrders
.
values
().
stream
()
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.
contains
(
o
.
get
(
0
).
getDjOrderType
())
.
filter
(
o
->
validDjOrderTypes
.
contains
(
o
.
get
(
0
).
getDjOrderType
())
&&
StaffPerformanceOrderUtil
.
isOrderMatchPackage
(
o
,
&&
StaffPerformanceOrderUtil
.
isOrderMatchPackage
(
o
,
finalP
roductDefine
.
getPackageItemList
()))
p
roductDefine
.
getPackageItemList
()))
.
count
();
.
count
();
}
break
;
}
else
{
case
ALL_PRODUCT:
// 单品逻辑
case
PRODUCT_CATEGORY:
List
<
StaffPerformanceSubOrderDTO
>
matchedOrders
=
orders
.
stream
()
case
DESIGNATED_PRODUCT:
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.
contains
(
o
.
getDjOrderType
())
// 单品或品类逻辑
&&
StaffPerformanceOrderUtil
.
isOrderMatchCategory
(
o
,
goodsConfigType
,
goodsType
,
List
<
StaffPerformanceSubOrderDTO
>
matchedOrders
=
orders
.
stream
()
secondaryGoodsType
,
.
filter
(
o
->
validDjOrderTypes
.
contains
(
o
.
getDjOrderType
())
thirdLevelGoodsType
,
finalProductDefine
))
&&
StaffPerformanceOrderUtil
.
isOrderMatchCategory
(
o
,
detailDTO
.
getGoodsConfigType
(),
.
collect
(
Collectors
.
toList
());
detailDTO
.
getGoodsType
(),
detailDTO
.
getSecondaryGoodsType
(),
detailDTO
.
getThirdLevelGoodsType
(),
productDefine
))
gmvOutput
=
matchedOrders
.
stream
()
.
collect
(
Collectors
.
toList
());
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
upgradeOrderNum
=
matchedOrders
.
size
();
gmvOutput
=
matchedOrders
.
stream
()
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
upgradeOrderNum
=
matchedOrders
.
size
();
break
;
default
:
log
.
error
(
"Unsupported goodsConfigType: {}"
,
detailDTO
.
getGoodsConfigType
());
break
;
}
}
productPerformance
.
setUpgradeOrderNum
((
int
)
upgradeOrderNum
);
return
new
MetricsResult
((
int
)
upgradeOrderNum
,
gmvOutput
);
productPerformance
.
setGmvOutput
(
gmvOutput
);
}
// 计算个人渗透率
private
BigDecimal
calculatePersonalPenetrationRate
(
StaffPerformanceCalContextDTO
context
,
int
upgradeOrderNum
)
{
// 个人渗透率 = 升级订单数 / 个人应触客数
BigDecimal
personalTargetTouchCount
=
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
BigDecimal
personalTargetTouchCount
=
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
.
getPersonalTargetTouchCount
();
.
getPersonalTargetTouchCount
();
BigDecimal
targetTouch
=
Optional
.
ofNullable
(
personalTargetTouchCount
).
orElse
(
BigDecimal
.
ZERO
);
if
(
personalTargetTouchCount
==
null
)
{
BigDecimal
penetrationRate
=
DataCalUtil
.
divideToPercent
(
new
BigDecimal
(
upgradeOrderNum
),
targetTouch
);
log
.
error
(
"personalTargetTouchCount is null"
);
productPerformance
.
setPersonalPenetrationRate
(
penetrationRate
);
return
BigDecimal
.
ZERO
;
}
return
DataCalUtil
.
divideToPercent
(
new
BigDecimal
(
upgradeOrderNum
),
personalTargetTouchCount
);
}
private
static
class
MetricsResult
{
private
final
int
upgradeOrderNum
;
private
final
BigDecimal
gmvOutput
;
public
MetricsResult
(
int
upgradeOrderNum
,
BigDecimal
gmvOutput
)
{
this
.
upgradeOrderNum
=
upgradeOrderNum
;
this
.
gmvOutput
=
gmvOutput
;
}
public
int
getUpgradeOrderNum
()
{
return
upgradeOrderNum
;
}
public
BigDecimal
getGmvOutput
()
{
return
gmvOutput
;
}
}
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/util/StaffPerformanceOrderUtil.java
View file @
bbe0524
...
@@ -3,8 +3,9 @@ package cn.com.glsx.dj.staff.service.staffPerformance.util;
...
@@ -3,8 +3,9 @@ package cn.com.glsx.dj.staff.service.staffPerformance.util;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO
;
import
cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem
;
import
cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
import
cn.com.glsx.dj.staff.enums.
Product
ConfigTypeEnum
;
import
cn.com.glsx.dj.staff.enums.
Goods
ConfigTypeEnum
;
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.util.RpcAssert
;
import
cn.com.glsx.framework.core.util.RpcAssert
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.CollectionUtils
;
...
@@ -81,37 +82,47 @@ public class StaffPerformanceOrderUtil {
...
@@ -81,37 +82,47 @@ public class StaffPerformanceOrderUtil {
* @param productDefine 圈定商品定义(含套餐)
* @param productDefine 圈定商品定义(含套餐)
* @return 匹配数量
* @return 匹配数量
*/
*/
public
static
long
countMatchingOrders
(
List
<
StaffPerformanceSubOrderDTO
>
orders
,
public
static
Integer
countMatchingOrders
(
List
<
StaffPerformanceSubOrderDTO
>
orders
,
Integer
goodsConfigType
,
Byte
goodsConfigType
,
Integer
goodsType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
Integer
thirdLevelGoodsType
,
MerchantPerformanceProductDefineDTO
productDefine
)
{
MerchantPerformanceProductDefineDTO
productDefine
)
{
if
(
CollectionUtils
.
isEmpty
(
orders
)
||
goodsConfigType
==
null
)
{
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
return
0
;
return
0
;
}
}
// 3. 根据配置类型分别处理
GoodsConfigTypeEnum
configType
=
GoodsConfigTypeEnum
.
getByCode
(
goodsConfigType
);
if
(
configType
==
null
)
{
throw
new
RpcServiceException
(
"不支持的商品配置类型: "
+
goodsConfigType
);
}
switch
(
configType
)
{
case
DESIGNATED_PACKAGE:
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
"conditionProductDefine be null"
);
RpcAssert
.
assertNotEmpty
(
productDefine
.
getPackageItemList
(),
DefaultErrorEnum
.
DATA_NULL
,
"conditionProductDefine.getPackageItemList() is empty"
);
if
(
goodsConfigType
==
2
)
{
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrders
=
orders
.
stream
()
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
.
collect
(
Collectors
.
groupingBy
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
));
"conditionProductDefine be null"
);
return
(
int
)
groupedOrders
.
values
().
stream
()
RpcAssert
.
assertNotEmpty
(
productDefine
.
getPackageItemList
(),
DefaultErrorEnum
.
DATA_NULL
,
.
filter
(
o
->
isOrderMatchPackage
(
o
,
productDefine
.
getPackageItemList
()))
"conditionProductDefine.getPackageItemList() is empty"
);
.
count
();
case
ALL_PRODUCT:
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrders
=
orders
.
stream
()
case
PRODUCT_CATEGORY:
.
collect
(
Collectors
.
groupingBy
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
));
case
DESIGNATED_PRODUCT:
return
groupedOrders
.
values
().
stream
()
return
(
int
)
orders
.
stream
()
.
filter
(
o
->
isOrderMatchPackage
(
o
,
productDefine
.
getPackageItemList
()))
.
filter
(
o
->
isOrderMatchCategory
(
o
,
.
count
();
goodsConfigType
,
}
else
{
goodsType
,
return
orders
.
stream
()
secondaryGoodsType
,
.
filter
(
o
->
isOrderMatchCategory
(
o
,
thirdLevelGoodsType
,
goodsConfigType
.
byteValue
(),
productDefine
))
goodsType
,
.
count
();
secondaryGoodsType
,
default
:
thirdLevelGoodsType
,
throw
new
RpcServiceException
(
"不支持的商品配置类型: "
+
goodsConfigType
);
productDefine
))
.
count
();
}
}
}
}
/**
/**
...
@@ -134,12 +145,12 @@ public class StaffPerformanceOrderUtil {
...
@@ -134,12 +145,12 @@ public class StaffPerformanceOrderUtil {
RpcAssert
.
assertNotNull
(
goodsConfigType
,
DefaultErrorEnum
.
DATA_NULL
,
"goodsConfigType不能为空"
);
RpcAssert
.
assertNotNull
(
goodsConfigType
,
DefaultErrorEnum
.
DATA_NULL
,
"goodsConfigType不能为空"
);
// TODO 改用枚举
// TODO 改用枚举
// -1:全部商品
// -1:全部商品
if
(
Objects
.
equals
(
Product
ConfigTypeEnum
.
ALL_PRODUCT
.
getCode
(),
goodsConfigType
))
{
if
(
Objects
.
equals
(
Goods
ConfigTypeEnum
.
ALL_PRODUCT
.
getCode
(),
goodsConfigType
))
{
return
true
;
return
true
;
}
}
// 0:商品分类
// 0:商品分类
if
(
Objects
.
equals
(
Product
ConfigTypeEnum
.
PRODUCT_CATEGORY
.
getCode
(),
goodsConfigType
))
{
if
(
Objects
.
equals
(
Goods
ConfigTypeEnum
.
PRODUCT_CATEGORY
.
getCode
(),
goodsConfigType
))
{
boolean
match
=
true
;
boolean
match
=
true
;
if
(
goodsType
!=
null
)
{
if
(
goodsType
!=
null
)
{
match
=
match
&&
Objects
.
equals
(
goodsType
,
order
.
getGoodsType
());
match
=
match
&&
Objects
.
equals
(
goodsType
,
order
.
getGoodsType
());
...
@@ -154,7 +165,7 @@ public class StaffPerformanceOrderUtil {
...
@@ -154,7 +165,7 @@ public class StaffPerformanceOrderUtil {
}
}
// 1:圈定产品
// 1:圈定产品
if
(
Objects
.
equals
(
Product
ConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
goodsConfigType
))
{
if
(
Objects
.
equals
(
Goods
ConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
goodsConfigType
))
{
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
"productDefine不能为空"
);
"productDefine不能为空"
);
return
productDefine
.
getItemList
().
stream
()
return
productDefine
.
getItemList
().
stream
()
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/util/DataCalUtil.java
View file @
bbe0524
...
@@ -6,6 +6,9 @@ import java.math.BigDecimal;
...
@@ -6,6 +6,9 @@ import java.math.BigDecimal;
public
class
DataCalUtil
{
public
class
DataCalUtil
{
public
static
BigDecimal
divideToPercent
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
public
static
BigDecimal
divideToPercent
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
if
(
dividend
==
null
||
divisor
==
null
)
{
return
null
;
}
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
null
;
return
null
;
}
}
...
@@ -14,8 +17,10 @@ public class DataCalUtil {
...
@@ -14,8 +17,10 @@ public class DataCalUtil {
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
.
ROUND_HALF_UP
);
}
}
public
static
BigDecimal
divide
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
public
static
BigDecimal
divide
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
if
(
dividend
==
null
||
divisor
==
null
)
{
return
null
;
}
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
BigDecimal
.
ZERO
;
return
BigDecimal
.
ZERO
;
}
}
...
...
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceDetailMapper.xml
View file @
bbe0524
...
@@ -71,7 +71,8 @@
...
@@ -71,7 +71,8 @@
updated_by = #{updatedBy},
updated_by = #{updatedBy},
updated_date = now()
updated_date = now()
WHERE
WHERE
merchant_id = #{merchantId,jdbcType=INTEGER}
staff_phone = #{staffPhone,jdbcType=VARCHAR}
AND merchant_id = #{merchantId,jdbcType=INTEGER}
AND business_type = #{businessType,jdbcType=TINYINT}
AND business_type = #{businessType,jdbcType=TINYINT}
AND brand_id = #{brandId,jdbcType=INTEGER}
AND brand_id = #{brandId,jdbcType=INTEGER}
AND child_brand_id = #{childBrandId,jdbcType=INTEGER}
AND child_brand_id = #{childBrandId,jdbcType=INTEGER}
...
...
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