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 aef7c282
authored
Jan 20, 2026
by
DESKTOP-3F024UL\tianming
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
提成计算相关
1 parent
9dcc24b3
Show whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
1558 additions
and
522 deletions
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/AssessmentFactorDailyDataDTO.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/AssessmentFactorOrderDataDTO.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/PerformanceConfigDTO.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffPerformanceCalContextDTO.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffPerformanceSubOrderDTO.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffPerformanceDTO.java → rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffProductPerformanceDTO.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/performance/StaffPerformanceDTO.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/performance/StaffPerformanceGetDTO.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/model/StaffPerformance.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/StaffPerformanceDetail.java
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/StaffPerformanceBase.java → rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/StaffProductPerformance.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/config/dubbo/ProxyDubboConfig.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceBaseMapper.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceCalMapper.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceDetailMapper.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceMapper.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/mapper/perfSalary/EffectiveReferralReviewMapper.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/StaffBeisenBaseInfoService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/perfSalary/EffectiveReferralReviewService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/salary/StaffMonthBusinessDataService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/PerformanceConfigService.java
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/PerformanceParamConfigService.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/EffectiveReferralReviewMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/PerformanceConfigMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/PerformanceParamConfigConditionMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/PerformanceParamConfigMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceBaseMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceCalMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceDetailMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceMapper.xml
rpc-dj-staff/src/main/resources/META-INF/orm/StaffProductPerformanceMapper.xml
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/AssessmentFactorDailyDataDTO.java
View file @
aef7c28
...
@@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
...
@@ -6,6 +6,7 @@ import lombok.NoArgsConstructor;
import
lombok.experimental.SuperBuilder
;
import
lombok.experimental.SuperBuilder
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
/**
/**
* 考核因子依赖的基础数据-日报数据
* 考核因子依赖的基础数据-日报数据
...
@@ -44,5 +45,5 @@ public class AssessmentFactorDailyDataDTO implements Serializable {
...
@@ -44,5 +45,5 @@ public class AssessmentFactorDailyDataDTO implements Serializable {
/**
/**
* 个人应触客数
* 个人应触客数
*/
*/
private
Integer
personalTargetTouchCount
;
private
BigDecimal
personalTargetTouchCount
;
}
}
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/AssessmentFactorOrderDataDTO.java
View file @
aef7c28
...
@@ -63,11 +63,6 @@ public class AssessmentFactorOrderDataDTO implements Serializable {
...
@@ -63,11 +63,6 @@ public class AssessmentFactorOrderDataDTO implements Serializable {
private
BigDecimal
categoryOrderOutputTotalByBrandAndCategory
;
private
BigDecimal
categoryOrderOutputTotalByBrandAndCategory
;
/**
/**
* 提成基数-主订单成交数(门店+业务+品牌+品类)
*/
private
Integer
commissionBaseMainOrderCountByBrandAndCategory
;
/**
* 提成基数-子订单成交数(门店+业务+品牌+品类)
* 提成基数-子订单成交数(门店+业务+品牌+品类)
*/
*/
private
Integer
commissionBaseSubOrderCountByBrandAndCategory
;
private
Integer
commissionBaseSubOrderCountByBrandAndCategory
;
...
...
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/PerformanceConfigDTO.java
View file @
aef7c28
...
@@ -14,7 +14,7 @@ import java.util.List;
...
@@ -14,7 +14,7 @@ import java.util.List;
@SuperBuilder
@SuperBuilder
@ToString
(
callSuper
=
true
)
@ToString
(
callSuper
=
true
)
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
PerformanceConfigDTO
extends
PerformanceConfig
{
public
class
PerformanceConfigDTO
extends
PerformanceConfig
{
private
static
final
long
serialVersionUID
=
-
2645954117282535336L
;
private
static
final
long
serialVersionUID
=
-
2645954117282535336L
;
...
@@ -39,4 +39,9 @@ public class PerformanceConfigDTO extends PerformanceConfig {
...
@@ -39,4 +39,9 @@ public class PerformanceConfigDTO extends PerformanceConfig {
*/
*/
private
Integer
childBrandId
;
private
Integer
childBrandId
;
/**
* 商户名称
*/
private
String
merchantName
;
}
}
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffPerformanceCalContextDTO.java
View file @
aef7c28
...
@@ -49,6 +49,11 @@ public class StaffPerformanceCalContextDTO implements Serializable {
...
@@ -49,6 +49,11 @@ public class StaffPerformanceCalContextDTO implements Serializable {
private
Integer
merchantId
;
private
Integer
merchantId
;
/**
/**
* 商户名称
*/
private
String
merchantName
;
/**
* 业务类型
* 业务类型
*/
*/
private
Byte
businessType
;
private
Byte
businessType
;
...
...
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffPerformanceSubOrderDTO.java
View file @
aef7c28
...
@@ -39,6 +39,11 @@ public class StaffPerformanceSubOrderDTO implements Serializable {
...
@@ -39,6 +39,11 @@ public class StaffPerformanceSubOrderDTO implements Serializable {
private
String
staffPhone
;
private
String
staffPhone
;
/**
/**
* 员工姓名
*/
private
String
staffName
;
/**
* 业务类型
* 业务类型
*/
*/
private
Byte
businessType
;
private
Byte
businessType
;
...
...
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffPerformanceDTO.java
→
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/StaffP
roductP
erformanceDTO.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
dto
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
dto
;
import
cn.com.glsx.dj.staff.model.StaffPerformance
;
import
cn.com.glsx.dj.staff.model.StaffP
roductP
erformance
;
import
lombok.*
;
import
lombok.*
;
import
lombok.experimental.SuperBuilder
;
import
lombok.experimental.SuperBuilder
;
/**
/**
* 员工绩效计算结果DTO
* 员工绩效计算结果DTO
*/
*/
//@AllArgsConstructor
//
@AllArgsConstructor
//@NoArgsConstructor
//
@NoArgsConstructor
@SuperBuilder
@SuperBuilder
@ToString
(
callSuper
=
true
)
@ToString
(
callSuper
=
true
)
@Data
@Data
@EqualsAndHashCode
(
callSuper
=
false
)
@EqualsAndHashCode
(
callSuper
=
false
)
public
class
StaffP
erformanceDTO
extends
Staff
Performance
{
public
class
StaffP
roductPerformanceDTO
extends
StaffProduct
Performance
{
private
static
final
long
serialVersionUID
=
-
6357597727215841459L
;
private
static
final
long
serialVersionUID
=
-
6357597727215841459L
;
}
}
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/performance/StaffPerformanceDTO.java
0 → 100644
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
dto
.
performance
;
import
cn.com.glsx.dj.staff.model.StaffPerformance
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.ToString
;
import
lombok.experimental.SuperBuilder
;
import
java.util.List
;
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
@ToString
(
callSuper
=
true
)
@Data
public
class
StaffPerformanceDTO
extends
StaffPerformance
{
private
static
final
long
serialVersionUID
=
-
1889194971763049271L
;
private
List
<
String
>
staffPhones
;
}
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/dto/performance/StaffPerformanceGetDTO.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
dto
.
performance
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
dto
.
performance
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.StaffP
roductP
erformanceDTO
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -10,5 +10,5 @@ import java.util.List;
...
@@ -10,5 +10,5 @@ import java.util.List;
public
class
StaffPerformanceGetDTO
{
public
class
StaffPerformanceGetDTO
{
@ApiModelProperty
(
name
=
"staffPerformanceList"
,
notes
=
"工资提成列表获取"
)
@ApiModelProperty
(
name
=
"staffPerformanceList"
,
notes
=
"工资提成列表获取"
)
private
List
<
StaffPerformanceDTO
>
staffPerformanceList
;
private
List
<
StaffP
roductP
erformanceDTO
>
staffPerformanceList
;
}
}
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/enums/ProductConfigTypeEnum.java
View file @
aef7c28
...
@@ -4,6 +4,7 @@ package cn.com.glsx.dj.staff.enums;
...
@@ -4,6 +4,7 @@ package cn.com.glsx.dj.staff.enums;
* 商品配置类型枚举
* 商品配置类型枚举
*/
*/
public
enum
ProductConfigTypeEnum
implements
BaseEnum
<
Integer
,
String
>
{
public
enum
ProductConfigTypeEnum
implements
BaseEnum
<
Integer
,
String
>
{
ALL_PRODUCT
(-
1
,
"全部商品"
),
PRODUCT_CATEGORY
(
0
,
"商品分类"
),
PRODUCT_CATEGORY
(
0
,
"商品分类"
),
DESIGNATED_PRODUCT
(
1
,
"圈定产品"
),
DESIGNATED_PRODUCT
(
1
,
"圈定产品"
),
DESIGNATED_PACKAGE
(
2
,
"圈定套餐"
);
DESIGNATED_PACKAGE
(
2
,
"圈定套餐"
);
...
...
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/StaffPerformance.java
View file @
aef7c28
...
@@ -13,7 +13,7 @@ import java.math.BigDecimal;
...
@@ -13,7 +13,7 @@ import java.math.BigDecimal;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
* 员工提成
* 员工提成
基础数据
*/
*/
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
...
@@ -21,7 +21,7 @@ import java.util.Date;
...
@@ -21,7 +21,7 @@ import java.util.Date;
@Data
@Data
@Table
(
name
=
"dj_car_life_staff_performance"
)
@Table
(
name
=
"dj_car_life_staff_performance"
)
public
class
StaffPerformance
implements
Serializable
{
public
class
StaffPerformance
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1
L
;
private
static
final
long
serialVersionUID
=
-
1513132045260423746
L
;
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
@@ -68,53 +68,13 @@ public class StaffPerformance implements Serializable {
...
@@ -68,53 +68,13 @@ public class StaffPerformance implements Serializable {
@Column
(
name
=
"month"
)
@Column
(
name
=
"month"
)
private
String
month
;
private
String
month
;
@ApiModelProperty
(
notes
=
"
商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐)
"
)
@ApiModelProperty
(
notes
=
"
有效引荐量
"
)
@Column
(
name
=
"
goods_config_type
"
)
@Column
(
name
=
"
effective_referral_quantity
"
)
private
Byte
goodsConfigType
;
private
Integer
effectiveReferralQuantity
;
@ApiModelProperty
(
notes
=
"商品分类(一级)"
)
@ApiModelProperty
(
notes
=
"实际售前触客数总数"
)
@Column
(
name
=
"goods_type"
)
@Column
(
name
=
"touch_number"
)
private
Integer
goodsType
;
private
Integer
touchNumber
;
@ApiModelProperty
(
notes
=
"商品分类名(一级)"
)
@Column
(
name
=
"goods_type_name"
)
private
String
goodsTypeName
;
@ApiModelProperty
(
notes
=
"商品分类(二级)"
)
@Column
(
name
=
"secondary_goods_type"
)
private
Integer
secondaryGoodsType
;
@ApiModelProperty
(
notes
=
"商品分类名(二级)"
)
@Column
(
name
=
"secondary_goods_type_name"
)
private
String
secondaryGoodsTypeName
;
@ApiModelProperty
(
notes
=
"商品分类(三级)"
)
@Column
(
name
=
"third_level_goods_type"
)
private
Integer
thirdLevelGoodsType
;
@ApiModelProperty
(
notes
=
"商品分类名(三级)"
)
@Column
(
name
=
"third_level_goods_type_name"
)
private
String
thirdLevelGoodsTypeName
;
@ApiModelProperty
(
notes
=
"关联圈定ID"
)
@Column
(
name
=
"product_define_id"
)
private
Integer
productDefineId
;
@ApiModelProperty
(
notes
=
"关联圈定产品/套餐名称"
)
@Column
(
name
=
"product_define_name"
)
private
String
productDefineName
;
@ApiModelProperty
(
notes
=
"产值"
)
@Column
(
name
=
"gmv_output"
)
private
BigDecimal
gmvOutput
;
@ApiModelProperty
(
notes
=
"升级订单数"
)
@Column
(
name
=
"upgrade_order_num"
)
private
Integer
upgradeOrderNum
;
@ApiModelProperty
(
notes
=
"个人渗透率"
)
@Column
(
name
=
"personal_penetration_rate"
)
private
BigDecimal
personalPenetrationRate
;
@ApiModelProperty
(
notes
=
"提成金额"
)
@ApiModelProperty
(
notes
=
"提成金额"
)
@Column
(
name
=
"performance_amount"
)
@Column
(
name
=
"performance_amount"
)
...
@@ -141,4 +101,19 @@ public class StaffPerformance implements Serializable {
...
@@ -141,4 +101,19 @@ public class StaffPerformance implements Serializable {
@ApiModelProperty
(
notes
=
"删除标识(D:已删除;N:未删除)"
)
@ApiModelProperty
(
notes
=
"删除标识(D:已删除;N:未删除)"
)
@Column
(
name
=
"deleted_flag"
)
@Column
(
name
=
"deleted_flag"
)
private
String
deletedFlag
;
private
String
deletedFlag
;
@ApiModelProperty
(
notes
=
"参数json"
)
@Column
(
name
=
"params_json"
)
/**
* <pre>
* {
* "sumNonCoeff": 100.00, // 非系数部分总额
* "multiplyCoeff": 1.2, // 原始总系数
* "isNewcomerProtection": true, // 是否处于新人保护期
* "finalMultiplyCoeff": 1.2, // 最终使用的系数(考虑新人保护)
* "finalAmount": 120.00 // 最终提成金额(sumNonCoeff * finalMultiplyCoeff)
* }
* </pre>
*/
private
String
paramsJson
;
}
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/StaffPerformanceDetail.java
View file @
aef7c28
...
@@ -42,7 +42,7 @@ public class StaffPerformanceDetail implements Serializable {
...
@@ -42,7 +42,7 @@ public class StaffPerformanceDetail implements Serializable {
@Column
(
name
=
"merchant_id"
)
@Column
(
name
=
"merchant_id"
)
private
Integer
merchantId
;
private
Integer
merchantId
;
@ApiModelProperty
(
notes
=
"商户名"
)
@ApiModelProperty
(
notes
=
"商户名
称
"
)
@Column
(
name
=
"merchant_name"
)
@Column
(
name
=
"merchant_name"
)
private
String
merchantName
;
private
String
merchantName
;
...
@@ -76,7 +76,7 @@ public class StaffPerformanceDetail implements Serializable {
...
@@ -76,7 +76,7 @@ public class StaffPerformanceDetail implements Serializable {
@ApiModelProperty
(
notes
=
"考核因子"
)
@ApiModelProperty
(
notes
=
"考核因子"
)
@Column
(
name
=
"assessment_factor"
)
@Column
(
name
=
"assessment_factor"
)
private
String
assessmentFactor
;
private
Byte
assessmentFactor
;
@ApiModelProperty
(
notes
=
"商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐)"
)
@ApiModelProperty
(
notes
=
"商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐)"
)
@Column
(
name
=
"goods_config_type"
)
@Column
(
name
=
"goods_config_type"
)
...
...
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/StaffP
erformanceBas
e.java
→
rpc-dj-staff-api/src/main/java/cn/com/glsx/dj/staff/model/StaffP
roductPerformanc
e.java
View file @
aef7c28
...
@@ -5,21 +5,22 @@ import io.swagger.annotations.ApiModelProperty;
...
@@ -5,21 +5,22 @@ import io.swagger.annotations.ApiModelProperty;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
import
lombok.experimental.
Accessors
;
import
lombok.experimental.
SuperBuilder
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.Date
;
/**
/**
* 员工提成
基础数据
* 员工提成
*/
*/
@Data
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@Accessors
(
chain
=
true
)
@SuperBuilder
@Table
(
name
=
"dj_car_life_staff_performance_base"
)
@Data
public
class
StaffPerformanceBase
implements
Serializable
{
@Table
(
name
=
"dj_car_life_staff_product_performance"
)
public
class
StaffProductPerformance
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
@Id
@Id
...
@@ -45,7 +46,7 @@ public class StaffPerformanceBase implements Serializable {
...
@@ -45,7 +46,7 @@ public class StaffPerformanceBase implements Serializable {
@ApiModelProperty
(
notes
=
"业务类型(0:轻改,1:权益;2:延保)"
)
@ApiModelProperty
(
notes
=
"业务类型(0:轻改,1:权益;2:延保)"
)
@Column
(
name
=
"business_type"
)
@Column
(
name
=
"business_type"
)
private
Integer
businessType
;
private
Byte
businessType
;
@ApiModelProperty
(
notes
=
"主品牌id"
)
@ApiModelProperty
(
notes
=
"主品牌id"
)
@Column
(
name
=
"brand_id"
)
@Column
(
name
=
"brand_id"
)
...
@@ -67,13 +68,57 @@ public class StaffPerformanceBase implements Serializable {
...
@@ -67,13 +68,57 @@ public class StaffPerformanceBase implements Serializable {
@Column
(
name
=
"month"
)
@Column
(
name
=
"month"
)
private
String
month
;
private
String
month
;
@ApiModelProperty
(
notes
=
"有效引荐量"
)
@ApiModelProperty
(
notes
=
"商品配置类型(-1:全部商品,0:商品分类,1:圈定产品,2圈定套餐)"
)
@Column
(
name
=
"effective_referral_quantity"
)
@Column
(
name
=
"goods_config_type"
)
private
Integer
effectiveReferralQuantity
;
private
Byte
goodsConfigType
;
@ApiModelProperty
(
notes
=
"商品分类(一级)"
)
@Column
(
name
=
"goods_type"
)
private
Integer
goodsType
;
@ApiModelProperty
(
notes
=
"商品分类名(一级)"
)
@Column
(
name
=
"goods_type_name"
)
private
String
goodsTypeName
;
@ApiModelProperty
(
notes
=
"商品分类(二级)"
)
@Column
(
name
=
"secondary_goods_type"
)
private
Integer
secondaryGoodsType
;
@ApiModelProperty
(
notes
=
"商品分类名(二级)"
)
@Column
(
name
=
"secondary_goods_type_name"
)
private
String
secondaryGoodsTypeName
;
@ApiModelProperty
(
notes
=
"商品分类(三级)"
)
@Column
(
name
=
"third_level_goods_type"
)
private
Integer
thirdLevelGoodsType
;
@ApiModelProperty
(
notes
=
"商品分类名(三级)"
)
@Column
(
name
=
"third_level_goods_type_name"
)
private
String
thirdLevelGoodsTypeName
;
@ApiModelProperty
(
notes
=
"关联圈定ID"
)
@Column
(
name
=
"product_define_id"
)
private
Integer
productDefineId
;
@ApiModelProperty
(
notes
=
"关联圈定产品/套餐名称"
)
@Column
(
name
=
"product_define_name"
)
private
String
productDefineName
;
@ApiModelProperty
(
notes
=
"产值"
)
@Column
(
name
=
"gmv_output"
)
private
BigDecimal
gmvOutput
;
@ApiModelProperty
(
notes
=
"升级订单数"
)
@Column
(
name
=
"upgrade_order_num"
)
private
Integer
upgradeOrderNum
;
@ApiModelProperty
(
notes
=
"个人渗透率"
)
@Column
(
name
=
"personal_penetration_rate"
)
private
BigDecimal
personalPenetrationRate
;
@ApiModelProperty
(
notes
=
"
触客数
"
)
@ApiModelProperty
(
notes
=
"
提成金额
"
)
@Column
(
name
=
"
touch_number
"
)
@Column
(
name
=
"
performance_amount
"
)
private
Integer
touchNumber
;
private
BigDecimal
performanceAmount
;
@ApiModelProperty
(
notes
=
"创建人"
)
@ApiModelProperty
(
notes
=
"创建人"
)
@Column
(
name
=
"created_by"
)
@Column
(
name
=
"created_by"
)
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/config/dubbo/ProxyDubboConfig.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
config
.
dubbo
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
config
.
dubbo
;
import
cn.com.glsx.dj.staff.config.DubboConfig
;
import
cn.com.glsx.dj.staff.config.DubboConfig
;
import
cn.com.glsx.scrm.proxy.remote.CommonProxyRemote
;
import
cn.com.glsx.scrm.proxy.remote.merchant.MerchantRemote
;
import
cn.com.glsx.scrm.proxy.remote.merchant.MerchantRemote
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -13,4 +14,9 @@ public class ProxyDubboConfig extends DubboConfig {
...
@@ -13,4 +14,9 @@ public class ProxyDubboConfig extends DubboConfig {
return
factory
.
builder
(
MerchantRemote
.
class
).
check
(
check
).
timeout
(
timeout
).
build
();
return
factory
.
builder
(
MerchantRemote
.
class
).
check
(
check
).
timeout
(
timeout
).
build
();
}
}
@Bean
public
CommonProxyRemote
commonProxyRemote
(){
return
factory
.
builder
(
CommonProxyRemote
.
class
).
check
(
check
).
timeout
(
timeout
).
build
();
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceBaseMapper.java
deleted
100644 → 0
View file @
9dcc24b
package
cn
.
com
.
glsx
.
dj
.
staff
.
mapper
;
import
cn.com.glsx.dj.staff.model.StaffPerformanceBase
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
@Mapper
public
interface
StaffPerformanceBaseMapper
extends
OreMapper
<
StaffPerformanceBase
>
{
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceCalMapper.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
mapper
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
mapper
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.StaffP
roductP
erformanceDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDailyReportQueryDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDailyReportQueryDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceOrderQueryDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceOrderQueryDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
...
@@ -13,7 +13,7 @@ import java.util.List;
...
@@ -13,7 +13,7 @@ import java.util.List;
* 员工绩效计算Mapper
* 员工绩效计算Mapper
*/
*/
@Mapper
@Mapper
public
interface
StaffPerformanceCalMapper
extends
OreMapper
<
StaffPerformanceDTO
>
{
public
interface
StaffPerformanceCalMapper
extends
OreMapper
<
StaffP
roductP
erformanceDTO
>
{
/**
/**
* 查找员工指定时间范围的订单
* 查找员工指定时间范围的订单
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceDetailMapper.java
View file @
aef7c28
...
@@ -4,6 +4,10 @@ import cn.com.glsx.dj.staff.model.StaffPerformanceDetail;
...
@@ -4,6 +4,10 @@ import cn.com.glsx.dj.staff.model.StaffPerformanceDetail;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.List
;
@Mapper
@Mapper
public
interface
StaffPerformanceDetailMapper
extends
OreMapper
<
StaffPerformanceDetail
>
{
public
interface
StaffPerformanceDetailMapper
extends
OreMapper
<
StaffPerformanceDetail
>
{
int
removePerformanceDetail
(
StaffPerformanceDetail
query
);
}
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffPerformanceMapper.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
mapper
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
mapper
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.model.StaffPerformance
;
import
cn.com.glsx.dj.staff.model.StaffPerformance
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
...
@@ -9,5 +10,13 @@ import java.util.List;
...
@@ -9,5 +10,13 @@ import java.util.List;
@Mapper
@Mapper
public
interface
StaffPerformanceMapper
extends
OreMapper
<
StaffPerformance
>
{
public
interface
StaffPerformanceMapper
extends
OreMapper
<
StaffPerformance
>
{
List
<
StaffPerformanceDTO
>
listStaffPerformance
(
StaffPerformanceDTO
dto
);
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
StaffPerformanceDTO
dto
);
/**
* 逻辑删除
*
* @param staffPerformance
* @return
*/
int
removeStaffPerformance
(
StaffPerformance
staffPerformance
);
}
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/mapper/StaffProductPerformanceMapper.java
0 → 100644
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
mapper
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.model.StaffProductPerformance
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
org.oreframework.datasource.mybatis.mapper.OreMapper
;
import
java.util.List
;
@Mapper
public
interface
StaffProductPerformanceMapper
extends
OreMapper
<
StaffProductPerformance
>
{
int
removeStaffProductPerformance
(
@Param
(
"merchantId"
)
Integer
merchantId
,
@Param
(
"businessType"
)
Byte
businessType
,
@Param
(
"brandId"
)
Integer
brandId
,
@Param
(
"childBrandId"
)
Integer
childBrandId
,
@Param
(
"performanceMonth"
)
String
performanceMonth
,
@Param
(
"staffPhone"
)
String
staffPhone
,
@Param
(
"updatedBy"
)
String
updatedBy
);
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
@Param
(
"dto"
)
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/mapper/perfSalary/EffectiveReferralReviewMapper.java
View file @
aef7c28
...
@@ -17,7 +17,7 @@ public interface EffectiveReferralReviewMapper extends OreMapper<EffectiveReferr
...
@@ -17,7 +17,7 @@ public interface EffectiveReferralReviewMapper extends OreMapper<EffectiveReferr
* @param query 查询条件
* @param query 查询条件
* @return 记录
* @return 记录
*/
*/
EffectiveReferralReviewDTO
select
OneByQuery
(
EffectiveReferralReviewDTO
query
);
EffectiveReferralReviewDTO
select
EffectiveReferralReview
(
EffectiveReferralReviewDTO
query
);
/**
/**
* 查询门店列表
* 查询门店列表
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/StaffBeisenBaseInfoService.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
;
import
cn.com.glsx.dj.staff.mapper.StaffBeisenBaseInfoMapper
;
import
cn.com.glsx.dj.staff.mapper.StaffBeisenBaseInfoMapper
;
import
cn.com.glsx.dj.staff.model.StaffBeisenBaseInfo
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -9,7 +10,6 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -9,7 +10,6 @@ import org.springframework.transaction.annotation.Transactional;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
@Slf4j
@Slf4j
@Service
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
RpcServiceException
.
class
)
...
@@ -18,9 +18,16 @@ public class StaffBeisenBaseInfoService {
...
@@ -18,9 +18,16 @@ public class StaffBeisenBaseInfoService {
@Resource
@Resource
private
StaffBeisenBaseInfoMapper
staffBeisenBaseInfoMapper
;
private
StaffBeisenBaseInfoMapper
staffBeisenBaseInfoMapper
;
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
RpcServiceException
.
class
)
public
StaffBeisenBaseInfo
getByStaffPhone
(
String
staffPhone
)
{
StaffBeisenBaseInfo
query
=
new
StaffBeisenBaseInfo
();
query
.
setStaffPhone
(
staffPhone
);
query
.
setDeletedFlag
(
"N"
);
return
staffBeisenBaseInfoMapper
.
selectOne
(
query
);
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
void
test
(
String
test
)
{
public
void
test
(
String
test
)
{
}
}
}
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/perfSalary/EffectiveReferralReviewService.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
perfSalary
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
perfSalary
;
import
cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewCommonDTO
;
import
cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewCommonDTO
;
import
cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReview
Common
DTO
;
import
cn.com.glsx.dj.staff.dto.perfSalary.EffectiveReferralReviewDTO
;
import
cn.com.glsx.dj.staff.mapper.perfSalary.EffectiveReferralReviewMapper
;
import
cn.com.glsx.dj.staff.mapper.perfSalary.EffectiveReferralReviewMapper
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
...
@@ -13,7 +13,6 @@ import org.springframework.transaction.annotation.Propagation;
...
@@ -13,7 +13,6 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
@Slf4j
@Slf4j
...
@@ -59,4 +58,14 @@ public class EffectiveReferralReviewService {
...
@@ -59,4 +58,14 @@ public class EffectiveReferralReviewService {
public
String
effectiveReferralAuditExportData
(
RpcPagination
<
EffectiveReferralReviewCommonDTO
>
pagination
)
{
public
String
effectiveReferralAuditExportData
(
RpcPagination
<
EffectiveReferralReviewCommonDTO
>
pagination
)
{
return
null
;
return
null
;
}
}
/**
* 根据条件查询单条有效引荐数记录
*
* @param query 查询参数
* @return 记录
*/
public
EffectiveReferralReviewDTO
queryEffectiveReferralReview
(
EffectiveReferralReviewDTO
query
)
{
return
effectiveReferralReviewMapper
.
selectEffectiveReferralReview
(
query
);
}
}
}
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/salary/StaffMonthBusinessDataService.java
View file @
aef7c28
...
@@ -8,7 +8,7 @@ import cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum;
...
@@ -8,7 +8,7 @@ import cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum;
import
cn.com.glsx.dj.smartcarlife.remote.GoodsOrderRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.GoodsOrderRemote
;
import
cn.com.glsx.dj.smartcarlife.util.DateUtils
;
import
cn.com.glsx.dj.smartcarlife.util.DateUtils
;
import
cn.com.glsx.dj.staff.constant.CommonConstants
;
import
cn.com.glsx.dj.staff.constant.CommonConstants
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.StaffP
roductP
erformanceDTO
;
import
cn.com.glsx.dj.staff.dto.salary.SalaryMonthBusinessDataDTO
;
import
cn.com.glsx.dj.staff.dto.salary.SalaryMonthBusinessDataDTO
;
import
cn.com.glsx.dj.staff.mapper.StaffMonthBusinessDataMapper
;
import
cn.com.glsx.dj.staff.mapper.StaffMonthBusinessDataMapper
;
import
cn.com.glsx.dj.staff.model.StaffMonthBusinessData
;
import
cn.com.glsx.dj.staff.model.StaffMonthBusinessData
;
...
@@ -84,13 +84,13 @@ public class StaffMonthBusinessDataService {
...
@@ -84,13 +84,13 @@ public class StaffMonthBusinessDataService {
return
;
return
;
}
}
StaffMonthBusinessData
data
=
list
.
get
(
0
);
StaffMonthBusinessData
data
=
list
.
get
(
0
);
List
<
StaffPerformanceDTO
>
performanceDTOList
=
staffPerformanceCalService
.
calStaffPerformance
(
data
.
getStaffPhone
(),
data
.
getSalaryMonth
());
List
<
StaffP
roductP
erformanceDTO
>
performanceDTOList
=
staffPerformanceCalService
.
calStaffPerformance
(
data
.
getStaffPhone
(),
data
.
getSalaryMonth
());
if
(
performanceDTOList
==
null
||
performanceDTOList
.
isEmpty
())
{
if
(
performanceDTOList
==
null
||
performanceDTOList
.
isEmpty
())
{
return
;
return
;
}
}
//performanceDTOList列表按businessType分组,然后累加performanceAmount值,返回map
//performanceDTOList列表按businessType分组,然后累加performanceAmount值,返回map
Map
<
Byte
,
BigDecimal
>
map
=
performanceDTOList
.
stream
().
collect
(
Collectors
.
groupingBy
(
StaffPerformanceDTO:
:
getBusinessType
,
Map
<
Byte
,
BigDecimal
>
map
=
performanceDTOList
.
stream
().
collect
(
Collectors
.
groupingBy
(
StaffP
roductP
erformanceDTO:
:
getBusinessType
,
Collectors
.
mapping
(
StaffPerformanceDTO:
:
getPerformanceAmount
,
Collectors
.
reducing
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
))));
Collectors
.
mapping
(
StaffP
roductP
erformanceDTO:
:
getPerformanceAmount
,
Collectors
.
reducing
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
))));
for
(
StaffMonthBusinessData
staffMonthBusinessData
:
list
)
{
for
(
StaffMonthBusinessData
staffMonthBusinessData
:
list
)
{
if
(
staffMonthBusinessData
.
getBusinessType
()
==
null
)
{
if
(
staffMonthBusinessData
.
getBusinessType
()
==
null
)
{
log
.
warn
(
"StaffMonthBusinessData.businessType is null"
);
log
.
warn
(
"StaffMonthBusinessData.businessType is null"
);
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/PerformanceConfigService.java
View file @
aef7c28
...
@@ -7,6 +7,8 @@ import cn.com.glsx.dj.staff.model.PerformanceConfig;
...
@@ -7,6 +7,8 @@ import cn.com.glsx.dj.staff.model.PerformanceConfig;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
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
com.github.pagehelper.Page
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageHelper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -34,16 +36,20 @@ public class PerformanceConfigService {
...
@@ -34,16 +36,20 @@ public class PerformanceConfigService {
@Autowired
@Autowired
private
PerformanceConfigMerchantBrandRefService
performanceConfigMerchantBrandRefService
;
private
PerformanceConfigMerchantBrandRefService
performanceConfigMerchantBrandRefService
;
/**
/**
* 查找门店 业务场景 品牌生效的提成配置
* 查找门店 业务场景 品牌
子品牌 月份
生效的提成配置
*
*
* @param dto 查询条件DTO
* @param dto 查询条件DTO
* @return 提成配置
* @return 提成配置
*/
*/
public
PerformanceConfigDTO
selectEffectiveConfig
(
PerformanceConfigDTO
dto
)
{
public
PerformanceConfigDTO
selectEffectiveConfig
(
PerformanceConfigDTO
dto
)
{
log
.
info
(
"Querying performance config by dto: {}"
,
dto
);
log
.
info
(
"selectEffectiveConfig dto: {}"
,
dto
);
RpcAssert
.
assertNotNull
(
dto
,
DefaultErrorEnum
.
DATA_NULL
,
"dto不能为空"
);
RpcAssert
.
assertNotNull
(
dto
.
getMerchantId
(),
DefaultErrorEnum
.
DATA_NULL
,
"merchantId不能为空"
);
RpcAssert
.
assertNotNull
(
dto
.
getBusinessType
(),
DefaultErrorEnum
.
DATA_NULL
,
"businessType不能为空"
);
RpcAssert
.
assertNotNull
(
dto
.
getBrandId
(),
DefaultErrorEnum
.
DATA_NULL
,
"brandId不能为空"
);
RpcAssert
.
assertNotNull
(
dto
.
getChildBrandId
(),
DefaultErrorEnum
.
DATA_NULL
,
"childBrandId不能为空"
);
RpcAssert
.
assertNotNull
(
dto
.
getEffectiveMonth
(),
DefaultErrorEnum
.
DATA_NULL
,
"month不能为空"
);
// 1. 根据入参的dto调用mapper方法查询基础数据的PerformanceConfigDTO result
// 1. 根据入参的dto调用mapper方法查询基础数据的PerformanceConfigDTO result
PerformanceConfigDTO
result
=
performanceConfigMapper
.
selectEffectiveConfig
(
dto
);
PerformanceConfigDTO
result
=
performanceConfigMapper
.
selectEffectiveConfig
(
dto
);
...
@@ -53,13 +59,10 @@ public class PerformanceConfigService {
...
@@ -53,13 +59,10 @@ public class PerformanceConfigService {
return
null
;
return
null
;
}
}
// 2.
// 2. 查找并设置performanceParamConfigs
// 调用PerformanceParamConfigService的方法,根据performanceConfigId,调用对应的mapper查询List<PerformanceParamConfigDTO>
List
<
PerformanceParamConfigDTO
>
performanceParamConfigs
=
performanceParamConfigService
// List<PerformanceParamConfigDTO> performanceParamConfigs = performanceParamConfigService
.
listByConfigId
(
result
.
getId
());
// .listByConfigId(result.getId());
result
.
setPerformanceParamConfigs
(
performanceParamConfigs
);
//
// // 设置到result
// result.setPerformanceParamConfigs(performanceParamConfigs);
// 3. 返回PerformanceConfigDTO
// 3. 返回PerformanceConfigDTO
return
result
;
return
result
;
...
@@ -68,9 +71,11 @@ public class PerformanceConfigService {
...
@@ -68,9 +71,11 @@ public class PerformanceConfigService {
public
PerformanceConfigDTO
selectByName
(
PerformanceConfigDTO
dto
)
{
public
PerformanceConfigDTO
selectByName
(
PerformanceConfigDTO
dto
)
{
return
performanceConfigMapper
.
selectByName
(
dto
);
return
performanceConfigMapper
.
selectByName
(
dto
);
}
}
public
Page
<
PerformanceConfigPageDTO
>
pagePerformanceConfig
(
RpcPagination
<
PerformanceConfigPageDTO
>
pagination
)
{
public
Page
<
PerformanceConfigPageDTO
>
pagePerformanceConfig
(
RpcPagination
<
PerformanceConfigPageDTO
>
pagination
)
{
try
{
try
{
Page
<
PerformanceConfigPageDTO
>
page
=
PageHelper
.
startPage
(
pagination
.
getPageNum
(),
pagination
.
getPageSize
(),
pagination
.
isNeedCount
());
Page
<
PerformanceConfigPageDTO
>
page
=
PageHelper
.
startPage
(
pagination
.
getPageNum
(),
pagination
.
getPageSize
(),
pagination
.
isNeedCount
());
performanceConfigMapper
.
listPerformanceConfig
(
pagination
.
getCondition
());
performanceConfigMapper
.
listPerformanceConfig
(
pagination
.
getCondition
());
return
page
;
return
page
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/PerformanceParamConfigService.java
View file @
aef7c28
...
@@ -2,11 +2,12 @@ package cn.com.glsx.dj.staff.service.staffPerformance;
...
@@ -2,11 +2,12 @@ package cn.com.glsx.dj.staff.service.staffPerformance;
import
cn.com.glsx.dj.staff.dto.PerformanceParamConfigDTO
;
import
cn.com.glsx.dj.staff.dto.PerformanceParamConfigDTO
;
import
cn.com.glsx.dj.staff.mapper.PerformanceParamConfigMapper
;
import
cn.com.glsx.dj.staff.mapper.PerformanceParamConfigMapper
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.util.RpcAssert
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -26,9 +27,8 @@ public class PerformanceParamConfigService {
...
@@ -26,9 +27,8 @@ public class PerformanceParamConfigService {
* @return List<PerformanceParamConfigDTO>
* @return List<PerformanceParamConfigDTO>
*/
*/
public
List
<
PerformanceParamConfigDTO
>
listByConfigId
(
Integer
configId
)
{
public
List
<
PerformanceParamConfigDTO
>
listByConfigId
(
Integer
configId
)
{
if
(
configId
==
null
)
{
log
.
info
(
"根据配置ID查询参数列表: configId={}"
,
configId
);
return
new
ArrayList
<>();
RpcAssert
.
assertNotNull
(
configId
,
DefaultErrorEnum
.
DATA_NULL
,
"configId不能为空"
);
}
PerformanceParamConfigDTO
dto
=
PerformanceParamConfigDTO
.
builder
().
performanceConfigId
(
configId
).
build
();
PerformanceParamConfigDTO
dto
=
PerformanceParamConfigDTO
.
builder
().
performanceConfigId
(
configId
).
build
();
return
performanceParamConfigMapper
.
listByConfigId
(
dto
);
return
performanceParamConfigMapper
.
listByConfigId
(
dto
);
}
}
...
...
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceCalService.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
staffPerformance
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
staffPerformance
;
import
cn.com.glsx.dj.smartcarlife.constant.CommonConstants
;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO
;
import
cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.OrderBusinessTypeEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.OrderBusinessTypeEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum
;
import
cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem
;
import
cn.com.glsx.dj.smartcarlife.remote.MerchantPerformanceProductDefineRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.MerchantPerformanceProductDefineRemote
;
import
cn.com.glsx.dj.staff.dto.*
;
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.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.ProductConfigTypeEnum
;
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.util.DataCalUtil
;
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
cn.com.glsx.framework.core.util.RpcAssert
;
...
@@ -48,31 +51,44 @@ public class StaffPerformanceCalService {
...
@@ -48,31 +51,44 @@ public class StaffPerformanceCalService {
private
EffectiveReferralReviewService
effectiveReferralReviewService
;
private
EffectiveReferralReviewService
effectiveReferralReviewService
;
@Autowired
@Autowired
private
StaffP
erformanceService
staff
PerformanceService
;
private
StaffP
roductPerformanceService
staffProduct
PerformanceService
;
@Autowired
@Autowired
private
MerchantPerformanceProductDefineRemote
merchantPerformanceProductDefineRemote
;
private
MerchantPerformanceProductDefineRemote
merchantPerformanceProductDefineRemote
;
@Autowired
private
StaffPerformanceService
staffPerformanceService
;
@Autowired
private
StaffPerformanceDetailService
staffPerformanceDetailService
;
/**
/**
* 计算员工提成
* 计算员工提成
*
*
* @param staffPhone 员工手机号
* @param staffPhone 员工手机号
* @param month 月份 (yyyy-
mm
)
* @param month 月份 (yyyy-
MM
)
* @return 提成结果列表
* @return 提成结果列表
*/
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
List
<
StaffPerformanceDTO
>
calStaffPerformance
(
String
staffPhone
,
String
month
)
{
public
List
<
StaffProductPerformanceDTO
>
calStaffPerformance
(
String
staffPhone
,
String
month
)
{
log
.
info
(
"Start calculating performance for staff: {}, month: {}"
,
staffPhone
,
month
);
RpcAssert
.
assertNotEmpty
(
staffPhone
,
DefaultErrorEnum
.
DATA_NULL
,
"员工手机号不能为空"
);
RpcAssert
.
assertNotEmpty
(
month
,
DefaultErrorEnum
.
DATA_NULL
,
"月份不能为空"
);
if
(!
month
.
matches
(
"^\\d{4}-\\d{2}$"
))
{
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"月份格式错误,应为yyyy-MM"
);
}
log
.
info
(
"开始计算员工提成: staffPhone={}, month={}"
,
staffPhone
,
month
);
List
<
StaffPerformanceSubOrderDTO
>
orders
=
listStaffMonthSubOrders
(
staffPhone
,
month
);
List
<
StaffPerformanceSubOrderDTO
>
orders
=
listStaffMonthSubOrders
(
staffPhone
,
month
);
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
log
.
warn
(
"
Found 0 orders for staff
: {}"
,
staffPhone
);
log
.
warn
(
"
未找到员工订单,不计算提成,staffPhone
: {}"
,
staffPhone
);
return
new
ArrayList
<>();
return
new
ArrayList
<>();
}
}
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrdersMap
=
groupOrders
(
orders
);
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrdersMap
=
groupOrders
(
orders
);
StaffPerformanceCalContextDTO
context
=
StaffPerformanceCalContextDTO
.
builder
()
StaffPerformanceCalContextDTO
context
=
StaffPerformanceCalContextDTO
.
builder
()
.
staffPhone
(
staffPhone
)
.
staffPhone
(
staffPhone
)
.
staffName
(
orders
.
get
(
0
).
getStaffName
())
.
performanceMonth
(
month
)
.
performanceMonth
(
month
)
.
orders
(
orders
)
.
orders
(
orders
)
.
groupedOrdersMap
(
groupedOrdersMap
)
.
groupedOrdersMap
(
groupedOrdersMap
)
...
@@ -82,12 +98,15 @@ public class StaffPerformanceCalService {
...
@@ -82,12 +98,15 @@ public class StaffPerformanceCalService {
for
(
Map
.
Entry
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
entry
:
groupedOrdersMap
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
entry
:
groupedOrdersMap
.
entrySet
())
{
try
{
try
{
thiz
.
processOrderGroup
(
entry
.
getKey
(),
context
);
thiz
.
processOrderGroup
(
entry
.
getKey
(),
context
);
}
catch
(
RpcServiceException
e
)
{
log
.
error
(
"处理订单组业务异常: groupKey={}"
,
entry
.
getKey
(),
e
);
// 业务异常可以选择抛出或记录,此处记录后继续处理其他组
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"
Error processing order group:
{}"
,
entry
.
getKey
(),
e
);
log
.
error
(
"
处理订单组未知异常: groupKey=
{}"
,
entry
.
getKey
(),
e
);
}
}
}
}
log
.
info
(
"
Calculation finished."
);
log
.
info
(
"
员工提成计算完成: staffPhone={}"
,
staffPhone
);
StaffPerformanceDTO
dto
=
StaffPerformanceDTO
.
builder
()
StaffPerformanceDTO
dto
=
StaffPerformanceDTO
.
builder
()
.
staffPhone
(
staffPhone
)
.
staffPhone
(
staffPhone
)
.
month
(
month
)
.
month
(
month
)
...
@@ -96,19 +115,17 @@ public class StaffPerformanceCalService {
...
@@ -96,19 +115,17 @@ public class StaffPerformanceCalService {
}
}
/**
/**
* 查找员工指定月份的订单
* 查找员工指定月份的订单
,brandId非鸿蒙智行的,品牌信息处理为其他品牌
*
*
* @param staffPhone
* @param staffPhone 员工手机号
* @param month
* @param month 月份 (yyyy-MM)
* @return java.util.List<cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO>
* @return 订单列表
* @author caiym
* @date 2026年01月14日 17:14:27
*/
*/
public
List
<
StaffPerformanceSubOrderDTO
>
listStaffMonthSubOrders
(
String
staffPhone
,
String
month
)
{
public
List
<
StaffPerformanceSubOrderDTO
>
listStaffMonthSubOrders
(
String
staffPhone
,
String
month
)
{
//
假设 month 格式为 yyyy-mm, 需要构造 startDate 和 endDate
//
构造查询时间范围
String
startDate
=
month
+
"-01 00:00:00"
;
String
startDate
=
month
+
"-01 00:00:00"
;
// 简单处理,结束时间为
下个月1号前,或者当前月最后一天。
// 简单处理,结束时间为
当前月最后一天(此处简化为31号,建议后续优化为准确的月末时间)
String
endDate
=
month
+
"-31 23:59:59"
;
// 简化处理,实际应计算月末
String
endDate
=
month
+
"-31 23:59:59"
;
StaffPerformanceOrderQueryDTO
query
=
StaffPerformanceOrderQueryDTO
.
builder
()
StaffPerformanceOrderQueryDTO
query
=
StaffPerformanceOrderQueryDTO
.
builder
()
.
staffPhone
(
staffPhone
)
.
staffPhone
(
staffPhone
)
...
@@ -135,10 +152,30 @@ public class StaffPerformanceCalService {
...
@@ -135,10 +152,30 @@ public class StaffPerformanceCalService {
return
subOrderDTOS
;
return
subOrderDTOS
;
}
}
private
AssessmentFactorDependencyDataDTO
calculateDependencyData
(
/**
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrdersMap
,
Integer
merchantId
,
* 计算考核因子依赖的基础数据
Byte
businessType
,
* 包括订单相关数据和日报相关数据
Integer
brandId
,
Integer
childBrandId
,
String
staffPhone
,
String
month
)
{
*
* @param context 上下文
* @return 依赖数据DTO
*/
private
AssessmentFactorDependencyDataDTO
calculateDependencyData
(
StaffPerformanceCalContextDTO
context
)
{
RpcAssert
.
assertNotNull
(
context
,
DefaultErrorEnum
.
DATA_NULL
,
"上下文不能为空"
);
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrdersMap
=
context
.
getGroupedOrdersMap
();
Integer
merchantId
=
context
.
getMerchantId
();
Byte
businessType
=
context
.
getBusinessType
();
Integer
brandId
=
context
.
getBrandId
();
Integer
childBrandId
=
context
.
getChildBrandId
();
String
staffPhone
=
context
.
getStaffPhone
();
String
month
=
context
.
getPerformanceMonth
();
log
.
info
(
"计算考核因子依赖的基础数据: staffPhone={}, month={}, businessType={}, brandId={}, childBrandId={}"
,
staffPhone
,
month
,
businessType
,
brandId
,
childBrandId
);
RpcAssert
.
assertNotEmpty
(
staffPhone
,
DefaultErrorEnum
.
DATA_NULL
,
"员工手机号不能为空"
);
RpcAssert
.
assertNotNull
(
businessType
,
DefaultErrorEnum
.
DATA_NULL
,
"业务类型不能为空"
);
RpcAssert
.
assertNotEmpty
(
month
,
DefaultErrorEnum
.
DATA_NULL
,
"月份不能为空"
);
RpcAssert
.
assertNotNull
(
merchantId
,
DefaultErrorEnum
.
DATA_NULL
,
"商户ID不能为空"
);
RpcAssert
.
assertNotNull
(
brandId
,
DefaultErrorEnum
.
DATA_NULL
,
"品牌ID不能为空"
);
RpcAssert
.
assertNotNull
(
childBrandId
,
DefaultErrorEnum
.
DATA_NULL
,
"子品牌ID不能为空"
);
Byte
sceneType
=
getSceneTypeFromBusinessType
(
businessType
);
Byte
sceneType
=
getSceneTypeFromBusinessType
(
businessType
);
AssessmentFactorOrderDataDTO
orderData
=
calculateOrderDependencyData
(
groupedOrdersMap
,
merchantId
,
AssessmentFactorOrderDataDTO
orderData
=
calculateOrderDependencyData
(
groupedOrdersMap
,
merchantId
,
...
@@ -170,6 +207,8 @@ public class StaffPerformanceCalService {
...
@@ -170,6 +207,8 @@ public class StaffPerformanceCalService {
private
AssessmentFactorOrderDataDTO
calculateOrderDependencyData
(
private
AssessmentFactorOrderDataDTO
calculateOrderDependencyData
(
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrdersMap
,
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrdersMap
,
Integer
merchantId
,
Byte
businessType
,
Integer
brandId
,
Integer
childBrandId
)
{
Integer
merchantId
,
Byte
businessType
,
Integer
brandId
,
Integer
childBrandId
)
{
log
.
info
(
"计算订单依赖数据: merchantId={}, businessType={}, brandId={}, childBrandId={}"
,
merchantId
,
businessType
,
brandId
,
childBrandId
);
return
AssessmentFactorOrderDataDTO
.
builder
()
return
AssessmentFactorOrderDataDTO
.
builder
()
.
personalMonthlyTotalOutput
(
.
personalMonthlyTotalOutput
(
computePersonalMonthlyTotalOutput
(
groupedOrdersMap
,
businessType
))
computePersonalMonthlyTotalOutput
(
groupedOrdersMap
,
businessType
))
...
@@ -185,6 +224,8 @@ public class StaffPerformanceCalService {
...
@@ -185,6 +224,8 @@ public class StaffPerformanceCalService {
private
AssessmentFactorDailyDataDTO
calculateDailyDependencyData
(
Integer
merchantId
,
Integer
brandId
,
private
AssessmentFactorDailyDataDTO
calculateDailyDependencyData
(
Integer
merchantId
,
Integer
brandId
,
Integer
childBrandId
,
String
staffPhone
,
Integer
childBrandId
,
String
staffPhone
,
String
month
,
Byte
sceneType
)
{
String
month
,
Byte
sceneType
)
{
log
.
info
(
"计算日报依赖数据: merchantId={}, brandId={}, childBrandId={}, staffPhone={}, month={}, sceneType={}"
,
merchantId
,
brandId
,
childBrandId
,
staffPhone
,
month
,
sceneType
);
// 计算依赖数据-日报
// 计算依赖数据-日报
// 查询个人总实际售前触客数
// 查询个人总实际售前触客数
StaffPerformanceDailyReportQueryDTO
personalQuery
=
StaffPerformanceDailyReportQueryDTO
.
builder
()
StaffPerformanceDailyReportQueryDTO
personalQuery
=
StaffPerformanceDailyReportQueryDTO
.
builder
()
...
@@ -237,7 +278,7 @@ public class StaffPerformanceCalService {
...
@@ -237,7 +278,7 @@ public class StaffPerformanceCalService {
storeValidRecommendationCount
=
storeDeliveryCount
;
storeValidRecommendationCount
=
storeDeliveryCount
;
}
}
// 计算个人应触客数
// 计算个人应触客数
Integer
personalTargetTouchCount
=
computePersonalExpectedTouchCount
(
personalTotalPreSalesTouchCount
,
BigDecimal
personalTargetTouchCount
=
computePersonalExpectedTouchCount
(
personalTotalPreSalesTouchCount
,
storeTotalTouchCount
,
storeValidRecommendationCount
);
storeTotalTouchCount
,
storeValidRecommendationCount
);
AssessmentFactorDailyDataDTO
dailyData
=
AssessmentFactorDailyDataDTO
.
builder
()
AssessmentFactorDailyDataDTO
dailyData
=
AssessmentFactorDailyDataDTO
.
builder
()
...
@@ -311,10 +352,25 @@ public class StaffPerformanceCalService {
...
@@ -311,10 +352,25 @@ public class StaffPerformanceCalService {
.
toString
();
.
toString
();
}
}
/**
* 计算考核因子实际值
*
* @param assessmentFactor 考核因子
* @param context 上下文
* @param goodsConfigType 商品配置类型
* @param goodsType 商品类型
* @param secondaryGoodsType 二级商品类型
* @param thirdLevelGoodsType 三级商品类型
* @param productDefineId 圈定商品定义ID
* @return 实际值
*/
private
BigDecimal
getActualValue
(
Byte
assessmentFactor
,
StaffPerformanceCalContextDTO
context
,
private
BigDecimal
getActualValue
(
Byte
assessmentFactor
,
StaffPerformanceCalContextDTO
context
,
Byte
goodsConfigType
,
Byte
goodsConfigType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
Integer
productDefineId
)
{
Integer
productDefineId
)
{
log
.
info
(
"开始计算考核因子实际值: assessmentFactor={}, goodsConfigType={}, goodsType={}, secondaryGoodsType={}, thirdLevelGoodsType={}, productDefineId={}"
,
assessmentFactor
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefineId
);
if
(
context
.
getAssessmentFactorDependencyData
()
==
null
)
{
if
(
context
.
getAssessmentFactorDependencyData
()
==
null
)
{
throw
new
RpcServiceException
(
"考核因子依赖的基础数据为空,无法计算考核因子的实际值"
);
throw
new
RpcServiceException
(
"考核因子依赖的基础数据为空,无法计算考核因子的实际值"
);
}
}
...
@@ -343,18 +399,18 @@ public class StaffPerformanceCalService {
...
@@ -343,18 +399,18 @@ public class StaffPerformanceCalService {
BigDecimal
mainCount
=
new
BigDecimal
(
BigDecimal
mainCount
=
new
BigDecimal
(
Optional
.
ofNullable
(
orderData
.
getMainOrderCountByBrandAndCategory
())
Optional
.
ofNullable
(
orderData
.
getMainOrderCountByBrandAndCategory
())
.
orElse
(
0
));
.
orElse
(
0
));
BigDecimal
targetTouch
=
new
BigDecimal
(
BigDecimal
targetTouch
=
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
())
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
()).
orElse
(
0
)
);
.
orElse
(
BigDecimal
.
ZERO
);
return
divideToPercent
(
mainCount
,
targetTouch
);
return
DataCalUtil
.
divideToPercent
(
mainCount
,
targetTouch
);
}
}
case
PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE:
{
case
PERSONAL_SINGLE_PRODUCT_PENETRATION_RATE:
{
// 个人单品渗透率 = 子订单成交数(门店+业务+品牌+品类)/ 个人应触客数
// 个人单品渗透率 = 子订单成交数(门店+业务+品牌+品类)/ 个人应触客数
BigDecimal
subCount
=
new
BigDecimal
(
BigDecimal
subCount
=
new
BigDecimal
(
Optional
.
ofNullable
(
orderData
.
getSubOrderCountByBrandAndCategory
())
Optional
.
ofNullable
(
orderData
.
getSubOrderCountByBrandAndCategory
())
.
orElse
(
0
));
.
orElse
(
0
));
BigDecimal
targetTouch
=
new
BigDecimal
(
BigDecimal
targetTouch
=
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
())
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
()).
orElse
(
0
)
);
.
orElse
(
BigDecimal
.
ZERO
);
return
divideToPercent
(
subCount
,
targetTouch
);
return
DataCalUtil
.
divideToPercent
(
subCount
,
targetTouch
);
}
}
case
HIGH_CUSTOMER_UNIT_PRICE:
case
HIGH_CUSTOMER_UNIT_PRICE:
// 高客单价 = 品类订单产值合计(门店+业务+品牌+品类)
// 高客单价 = 品类订单产值合计(门店+业务+品牌+品类)
...
@@ -367,7 +423,7 @@ public class StaffPerformanceCalService {
...
@@ -367,7 +423,7 @@ public class StaffPerformanceCalService {
BigDecimal
totalTouch
=
new
BigDecimal
(
BigDecimal
totalTouch
=
new
BigDecimal
(
Optional
.
ofNullable
(
dailyData
.
getPersonalTotalPreSalesTouchCount
())
Optional
.
ofNullable
(
dailyData
.
getPersonalTotalPreSalesTouchCount
())
.
orElse
(
0
));
.
orElse
(
0
));
return
divide
(
totalOutput
,
totalTouch
);
return
DataCalUtil
.
divide
(
totalOutput
,
totalTouch
);
}
}
case
CUSTOMER_CONTACT_UNIT_PRICE:
{
case
CUSTOMER_CONTACT_UNIT_PRICE:
{
// 触客客单价 = 个人月度单店产值(门店+业务)/ 该门店的该个人实际售前触客数
// 触客客单价 = 个人月度单店产值(门店+业务)/ 该门店的该个人实际售前触客数
...
@@ -376,7 +432,7 @@ public class StaffPerformanceCalService {
...
@@ -376,7 +432,7 @@ public class StaffPerformanceCalService {
BigDecimal
storePersonalTouch
=
new
BigDecimal
(
BigDecimal
storePersonalTouch
=
new
BigDecimal
(
Optional
.
ofNullable
(
dailyData
.
getStorePersonalPreSalesTouchCount
())
Optional
.
ofNullable
(
dailyData
.
getStorePersonalPreSalesTouchCount
())
.
orElse
(
0
));
.
orElse
(
0
));
return
divide
(
storeOutput
,
storePersonalTouch
);
return
DataCalUtil
.
divide
(
storeOutput
,
storePersonalTouch
);
}
}
case
UPGRADE_UNIT_PRICE:
{
case
UPGRADE_UNIT_PRICE:
{
// 升级客单价 = 个人月度单店产值(门店+业务)/ 主订单成交数(门店+业务+品牌)
// 升级客单价 = 个人月度单店产值(门店+业务)/ 主订单成交数(门店+业务+品牌)
...
@@ -384,15 +440,15 @@ public class StaffPerformanceCalService {
...
@@ -384,15 +440,15 @@ public class StaffPerformanceCalService {
.
orElse
(
BigDecimal
.
ZERO
);
.
orElse
(
BigDecimal
.
ZERO
);
BigDecimal
mainOrderCount
=
new
BigDecimal
(
BigDecimal
mainOrderCount
=
new
BigDecimal
(
Optional
.
ofNullable
(
orderData
.
getMainOrderCountByBrand
()).
orElse
(
0
));
Optional
.
ofNullable
(
orderData
.
getMainOrderCountByBrand
()).
orElse
(
0
));
return
divide
(
storeOutput
,
mainOrderCount
);
return
DataCalUtil
.
divide
(
storeOutput
,
mainOrderCount
);
}
}
case
DELIVERY_UNIT_PRICE:
{
case
DELIVERY_UNIT_PRICE:
{
// 交车客单价 = 个人月度单店产值(门店+业务)/ 个人应触客数
// 交车客单价 = 个人月度单店产值(门店+业务)/ 个人应触客数
BigDecimal
storeOutput
=
Optional
.
ofNullable
(
orderData
.
getPersonalMonthlyStoreOutput
())
BigDecimal
storeOutput
=
Optional
.
ofNullable
(
orderData
.
getPersonalMonthlyStoreOutput
())
.
orElse
(
BigDecimal
.
ZERO
);
.
orElse
(
BigDecimal
.
ZERO
);
BigDecimal
targetTouch
=
new
BigDecimal
(
BigDecimal
targetTouch
=
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
())
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
()).
orElse
(
0
)
);
.
orElse
(
BigDecimal
.
ZERO
);
return
divide
(
storeOutput
,
targetTouch
);
return
DataCalUtil
.
divide
(
storeOutput
,
targetTouch
);
}
}
case
STORE_CUSTOMER_CONTACT_RATE_DELIVERY:
{
case
STORE_CUSTOMER_CONTACT_RATE_DELIVERY:
{
// 门店触客率(交车) = 门店总触客数(该门店的所有个人实际售前触客数之和) / 门店交车数
// 门店触客率(交车) = 门店总触客数(该门店的所有个人实际售前触客数之和) / 门店交车数
...
@@ -400,7 +456,7 @@ public class StaffPerformanceCalService {
...
@@ -400,7 +456,7 @@ public class StaffPerformanceCalService {
Optional
.
ofNullable
(
dailyData
.
getStoreTotalTouchCount
()).
orElse
(
0
));
Optional
.
ofNullable
(
dailyData
.
getStoreTotalTouchCount
()).
orElse
(
0
));
BigDecimal
storeDelivery
=
new
BigDecimal
(
BigDecimal
storeDelivery
=
new
BigDecimal
(
Optional
.
ofNullable
(
dailyData
.
getStoreDeliveryCount
()).
orElse
(
0
));
Optional
.
ofNullable
(
dailyData
.
getStoreDeliveryCount
()).
orElse
(
0
));
return
divideToPercent
(
storeTotalTouch
,
storeDelivery
);
return
DataCalUtil
.
divideToPercent
(
storeTotalTouch
,
storeDelivery
);
}
}
case
STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL:
{
case
STORE_CUSTOMER_CONTACT_RATE_EFFECTIVE_REFERRAL:
{
// 门店触客率(有效引荐) = 门店总触客数(该门店的所有个人实际售前触客数之和) / 门店有效引荐数
// 门店触客率(有效引荐) = 门店总触客数(该门店的所有个人实际售前触客数之和) / 门店有效引荐数
...
@@ -409,7 +465,7 @@ public class StaffPerformanceCalService {
...
@@ -409,7 +465,7 @@ public class StaffPerformanceCalService {
BigDecimal
storeValidReferral
=
new
BigDecimal
(
BigDecimal
storeValidReferral
=
new
BigDecimal
(
Optional
.
ofNullable
(
dailyData
.
getStoreValidRecommendationCount
())
Optional
.
ofNullable
(
dailyData
.
getStoreValidRecommendationCount
())
.
orElse
(
0
));
.
orElse
(
0
));
return
divideToPercent
(
storeTotalTouch
,
storeValidReferral
);
return
DataCalUtil
.
divideToPercent
(
storeTotalTouch
,
storeValidReferral
);
}
}
case
UPGRADE_ORDER_QUANTITY:
case
UPGRADE_ORDER_QUANTITY:
// 升级订单数 = 主订单成交数(门店+业务+品牌)
// 升级订单数 = 主订单成交数(门店+业务+品牌)
...
@@ -420,22 +476,15 @@ public class StaffPerformanceCalService {
...
@@ -420,22 +476,15 @@ public class StaffPerformanceCalService {
}
}
}
}
private
BigDecimal
divide
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
/**
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
* 创建绩效明细DTO
return
BigDecimal
.
ZERO
;
*
}
* @param context 计算上下文
return
dividend
.
divide
(
divisor
,
4
,
BigDecimal
.
ROUND_HALF_UP
);
* @param paramConfig 绩效参数配置
}
* @param actualValue 考核因子实际值
* @param paramConfigs 该组所有绩效参数配置
private
BigDecimal
divideToPercent
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
* @return 绩效明细DTO
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
*/
return
BigDecimal
.
ZERO
;
}
return
dividend
.
divide
(
divisor
,
4
,
BigDecimal
.
ROUND_HALF_UP
)
.
multiply
(
CommonConstants
.
ONEHUNDRED_BIGDECIMAL
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
private
StaffPerformanceDetailDTO
createPerformanceDetailDTO
(
StaffPerformanceCalContextDTO
context
,
private
StaffPerformanceDetailDTO
createPerformanceDetailDTO
(
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigDTO
paramConfig
,
PerformanceParamConfigDTO
paramConfig
,
BigDecimal
actualValue
,
List
<
PerformanceParamConfigDTO
>
paramConfigs
)
{
BigDecimal
actualValue
,
List
<
PerformanceParamConfigDTO
>
paramConfigs
)
{
...
@@ -444,48 +493,74 @@ public class StaffPerformanceCalService {
...
@@ -444,48 +493,74 @@ public class StaffPerformanceCalService {
.
staffName
(
context
.
getStaffName
())
.
staffName
(
context
.
getStaffName
())
.
month
(
context
.
getPerformanceMonth
())
.
month
(
context
.
getPerformanceMonth
())
.
merchantId
(
context
.
getMerchantId
())
.
merchantId
(
context
.
getMerchantId
())
.
merchantName
(
context
.
getMerchantName
())
.
businessType
(
context
.
getBusinessType
())
.
businessType
(
context
.
getBusinessType
())
.
brandId
(
context
.
getBrandId
())
.
brandId
(
context
.
getBrandId
())
.
childBrandId
(
context
.
getChildBrandId
())
.
childBrandId
(
context
.
getChildBrandId
())
.
performanceConfigId
(
paramConfig
.
getId
())
.
assessmentFactor
(
paramConfig
.
getAssessmentFactor
())
.
goodsConfigType
(
paramConfig
.
getGoodsConfigType
())
.
goodsConfigType
(
paramConfig
.
getGoodsConfigType
())
.
goodsType
(
paramConfig
.
getGoodsType
())
.
goodsType
(
paramConfig
.
getGoodsType
())
.
goodsTypeName
(
paramConfig
.
getGoodsTypeName
())
.
secondaryGoodsType
(
paramConfig
.
getSecondaryGoodsType
())
.
secondaryGoodsType
(
paramConfig
.
getSecondaryGoodsType
())
.
secondaryGoodsTypeName
(
paramConfig
.
getSecondaryGoodsTypeName
())
.
thirdLevelGoodsType
(
paramConfig
.
getThirdLevelGoodsType
())
.
thirdLevelGoodsType
(
paramConfig
.
getThirdLevelGoodsType
())
.
thirdLevelGoodsTypeName
(
paramConfig
.
getThirdLevelGoodsTypeName
())
.
productDefineId
(
paramConfig
.
getProductDefineId
())
.
productDefineId
(
paramConfig
.
getProductDefineId
())
.
productDefineName
(
paramConfig
.
getProductDefineName
())
.
assessmentFactorValue
(
actualValue
)
.
commissionBase
(
paramConfig
.
getCommissionBase
())
.
gmvOutput
(
context
.
getAssessmentFactorDependencyData
().
getOrderData
()
.
gmvOutput
(
context
.
getAssessmentFactorDependencyData
().
getOrderData
()
.
getCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
())
.
getCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
())
.
upgradeOrderNum
(
context
.
getAssessmentFactorDependencyData
().
getOrderData
()
.
upgradeOrderNum
(
context
.
getAssessmentFactorDependencyData
().
getOrderData
()
.
getCommissionBase
Main
OrderCountByBrandAndCategory
())
.
getCommissionBase
Sub
OrderCountByBrandAndCategory
())
.
personalPenetrationRate
(
computePersonalPenetrationRateForCommission
(
context
))
.
personalPenetrationRate
(
computePersonalPenetrationRateForCommission
(
context
))
.
commissionBase
(
paramConfig
.
getCommissionBase
())
.
commissionType
(
paramConfig
.
getCommissionType
())
.
commissionType
(
paramConfig
.
getCommissionType
())
.
commissionTypeValue
(
paramConfig
.
getCommissionTypeValue
())
.
commissionTypeValue
(
paramConfig
.
getCommissionTypeValue
())
.
performanceConfigId
(
paramConfig
.
getId
())
.
build
();
.
build
();
// 结合config.performanceParamConfigConditions(多个条件,遍历处理),确认最终的计算参数
// 结合config.performanceParamConfigConditions(多个条件,遍历处理),确认最终的计算参数
calculateByConditions
(
staffPerformanceDetailDTO
,
paramConfig
,
paramConfigs
,
context
);
calculateByConditions
(
staffPerformanceDetailDTO
,
paramConfig
,
paramConfigs
,
context
);
// 计算提成金额
// 计算最终提成金额
BigDecimal
commission
=
BigDecimal
.
ZERO
;
calculateFinalCommission
(
staffPerformanceDetailDTO
);
// 简单示例:如果是 固定金额
if
(
"DDJE"
.
equals
(
staffPerformanceDetailDTO
.
getCommissionType
()))
{
return
staffPerformanceDetailDTO
;
commission
=
staffPerformanceDetailDTO
.
getCommissionTypeValue
();
}
}
else
if
(
"BL"
.
equals
(
staffPerformanceDetailDTO
.
getCommissionType
()))
{
/**
* 计算最终提成金额
*
* @param detailDTO 绩效明细DTO
*/
private
void
calculateFinalCommission
(
StaffPerformanceDetailDTO
detailDTO
)
{
// 非系数的计算提成金额
BigDecimal
commission
=
null
;
// TODO 换成枚举
if
(
"DDJE"
.
equals
(
detailDTO
.
getCommissionType
()))
{
commission
=
detailDTO
.
getCommissionTypeValue
();
}
else
if
(
"BL"
.
equals
(
detailDTO
.
getCommissionType
()))
{
// 比例:基数 * 比例
// 比例:基数 * 比例
if
(
staffPerformanceD
etailDTO
.
getCommissionTypeValue
()
!=
null
)
{
if
(
d
etailDTO
.
getCommissionTypeValue
()
!=
null
)
{
commission
=
staffPerformanceD
etailDTO
.
getGmvOutput
()
commission
=
d
etailDTO
.
getGmvOutput
()
.
multiply
(
staffPerformanceD
etailDTO
.
getCommissionTypeValue
());
.
multiply
(
d
etailDTO
.
getCommissionTypeValue
());
}
}
}
}
// 加上额外奖惩金额(扣减或奖励)
// 加上额外奖惩金额(扣减或奖励)
if
(
staffPerformanceD
etailDTO
.
getExtraPerformanceAmount
()
!=
null
)
{
if
(
commission
!=
null
&&
d
etailDTO
.
getExtraPerformanceAmount
()
!=
null
)
{
commission
=
commission
.
add
(
staffPerformanceD
etailDTO
.
getExtraPerformanceAmount
());
commission
=
commission
.
add
(
d
etailDTO
.
getExtraPerformanceAmount
());
}
}
staffPerformanceDetailDTO
.
setPerformanceAmount
(
commission
);
detailDTO
.
setPerformanceAmount
(
commission
);
return
staffPerformanceDetailDTO
;
}
}
/**
* 根据条件计算额外的绩效参数(如扣减、奖励、降档等)
*
* @param detailDTO 绩效明细DTO
* @param paramConfig 当前绩效参数配置
* @param paramConfigs 该组所有绩效参数配置
* @param context 计算上下文
*/
private
void
calculateByConditions
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
private
void
calculateByConditions
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
List
<
PerformanceParamConfigDTO
>
paramConfigs
,
StaffPerformanceCalContextDTO
context
)
{
List
<
PerformanceParamConfigDTO
>
paramConfigs
,
StaffPerformanceCalContextDTO
context
)
{
if
(
CollectionUtils
.
isEmpty
(
paramConfig
.
getPerformanceParamConfigConditions
()))
{
if
(
CollectionUtils
.
isEmpty
(
paramConfig
.
getPerformanceParamConfigConditions
()))
{
...
@@ -499,7 +574,7 @@ public class StaffPerformanceCalService {
...
@@ -499,7 +574,7 @@ public class StaffPerformanceCalService {
log
.
info
(
"= 开始计算条件: configId={}"
,
paramConfig
.
getId
());
log
.
info
(
"= 开始计算条件: configId={}"
,
paramConfig
.
getId
());
for
(
PerformanceParamConfigConditionDTO
condition
:
paramConfig
.
getPerformanceParamConfigConditions
())
{
for
(
PerformanceParamConfigConditionDTO
condition
:
paramConfig
.
getPerformanceParamConfigConditions
())
{
log
.
info
(
"==
开始计算
条件: conditionId={}"
,
condition
.
getId
());
log
.
info
(
"==
处理
条件: conditionId={}"
,
condition
.
getId
());
JSONObject
executionLog
=
new
JSONObject
();
JSONObject
executionLog
=
new
JSONObject
();
executionLog
.
put
(
"conditionType"
,
condition
.
getConditionType
());
executionLog
.
put
(
"conditionType"
,
condition
.
getConditionType
());
executionLog
.
put
(
"conditionId"
,
condition
.
getId
());
executionLog
.
put
(
"conditionId"
,
condition
.
getId
());
...
@@ -538,6 +613,18 @@ public class StaffPerformanceCalService {
...
@@ -538,6 +613,18 @@ public class StaffPerformanceCalService {
log
.
info
(
"条件计算完成: staffPhone={}, paramsJson={}"
,
detailDTO
.
getStaffPhone
(),
paramsJson
.
toJSONString
());
log
.
info
(
"条件计算完成: staffPhone={}, paramsJson={}"
,
detailDTO
.
getStaffPhone
(),
paramsJson
.
toJSONString
());
}
}
/**
* 处理渗透率限制条件
*
* @param detailDTO 绩效明细DTO
* @param paramConfig 当前绩效参数配置
* @param paramConfigs 该组所有绩效参数配置
* @param context 计算上下文
* @param condition 当前条件
* @param resultLog 结果日志
* @param skipPenetrationRateCondition 是否跳过渗透率条件
* @return 是否跳过后续渗透率条件
*/
private
boolean
processPenetrationRateCondition
(
StaffPerformanceDetailDTO
detailDTO
,
private
boolean
processPenetrationRateCondition
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
List
<
PerformanceParamConfigDTO
>
paramConfigs
,
PerformanceParamConfigDTO
paramConfig
,
List
<
PerformanceParamConfigDTO
>
paramConfigs
,
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigConditionDTO
condition
,
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigConditionDTO
condition
,
...
@@ -568,10 +655,10 @@ public class StaffPerformanceCalService {
...
@@ -568,10 +655,10 @@ public class StaffPerformanceCalService {
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
);
if
(!
inRange
)
{
if
(!
inRange
)
{
...
@@ -581,6 +668,14 @@ public class StaffPerformanceCalService {
...
@@ -581,6 +668,14 @@ public class StaffPerformanceCalService {
return
false
;
return
false
;
}
}
/**
* 处理降档逻辑
*
* @param detailDTO 绩效明细DTO
* @param paramConfig 当前绩效参数配置
* @param paramConfigs 该组所有绩效参数配置
* @param resultLog 结果日志
*/
private
void
handleDegradation
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
private
void
handleDegradation
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigDTO
paramConfig
,
List
<
PerformanceParamConfigDTO
>
paramConfigs
,
JSONObject
resultLog
)
{
List
<
PerformanceParamConfigDTO
>
paramConfigs
,
JSONObject
resultLog
)
{
// 寻找降档配置:在 paramConfigs 中找 startValue < 当前 paramConfig.startValue 的最大值
// 寻找降档配置:在 paramConfigs 中找 startValue < 当前 paramConfig.startValue 的最大值
...
@@ -627,6 +722,14 @@ public class StaffPerformanceCalService {
...
@@ -627,6 +722,14 @@ public class StaffPerformanceCalService {
}
}
}
}
/**
* 处理订单数不足扣减条件
*
* @param detailDTO 绩效明细DTO
* @param context 计算上下文
* @param condition 当前条件
* @param resultLog 结果日志
*/
private
void
processOrderCountDeductionCondition
(
StaffPerformanceDetailDTO
detailDTO
,
private
void
processOrderCountDeductionCondition
(
StaffPerformanceDetailDTO
detailDTO
,
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigConditionDTO
condition
,
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigConditionDTO
condition
,
JSONObject
resultLog
)
{
JSONObject
resultLog
)
{
...
@@ -642,16 +745,15 @@ public class StaffPerformanceCalService {
...
@@ -642,16 +745,15 @@ public class StaffPerformanceCalService {
conditionEndValue
,
deduct
);
conditionEndValue
,
deduct
);
if
(
deduct
)
{
if
(
deduct
)
{
Integer
personalTargetTouchCount
=
context
.
getAssessmentFactorDependencyData
()
BigDecimal
personalTargetTouchCount
=
context
.
getAssessmentFactorDependencyData
()
.
getDailyData
().
getPersonalTargetTouchCount
();
.
getDailyData
().
getPersonalTargetTouchCount
();
if
(
personalTargetTouchCount
==
null
)
{
if
(
personalTargetTouchCount
==
null
)
{
personalTargetTouchCount
=
0
;
personalTargetTouchCount
=
BigDecimal
.
ZERO
;
}
}
BigDecimal
targetTouchBD
=
new
BigDecimal
(
personalTargetTouchCount
);
// 不足订单数 = (目标渗透率 - 实际渗透率) * 个人应触客数
// 不足订单数 = (目标渗透率 - 实际渗透率) * 个人应触客数
BigDecimal
shortfallRate
=
conditionEndValue
.
subtract
(
personalPenetrationRate
);
BigDecimal
shortfallRate
=
conditionEndValue
.
subtract
(
personalPenetrationRate
);
BigDecimal
shortfallOrdersBD
=
shortfallRate
.
multiply
(
targetTouchBD
).
setScale
(
0
,
BigDecimal
shortfallOrdersBD
=
shortfallRate
.
multiply
(
personalTargetTouchCount
).
setScale
(
0
,
BigDecimal
.
ROUND_UP
);
// 向上取整
BigDecimal
.
ROUND_UP
);
// 向上取整
// 扣减金额 = 不足订单数 * 单价 * -1
// 扣减金额 = 不足订单数 * 单价 * -1
...
@@ -678,6 +780,13 @@ public class StaffPerformanceCalService {
...
@@ -678,6 +780,13 @@ public class StaffPerformanceCalService {
}
}
}
}
/**
* 处理整体指标达成奖励条件
*
* @param detailDTO 绩效明细DTO
* @param condition 当前条件
* @param resultLog 结果日志
*/
private
void
processTargetAchievementRewardCondition
(
StaffPerformanceDetailDTO
detailDTO
,
private
void
processTargetAchievementRewardCondition
(
StaffPerformanceDetailDTO
detailDTO
,
PerformanceParamConfigConditionDTO
condition
,
JSONObject
resultLog
)
{
PerformanceParamConfigConditionDTO
condition
,
JSONObject
resultLog
)
{
// 3.整体指标达成奖励
// 3.整体指标达成奖励
...
@@ -691,6 +800,14 @@ public class StaffPerformanceCalService {
...
@@ -691,6 +800,14 @@ public class StaffPerformanceCalService {
log
.
info
(
"执行指标达成奖励: amount={}"
,
reward
);
log
.
info
(
"执行指标达成奖励: amount={}"
,
reward
);
}
}
/**
* 处理订单数剔除条件
*
* @param detailDTO 绩效明细DTO
* @param context 计算上下文
* @param condition 当前条件
* @param resultLog 结果日志
*/
private
void
processOrderExclusionCondition
(
StaffPerformanceDetailDTO
detailDTO
,
private
void
processOrderExclusionCondition
(
StaffPerformanceDetailDTO
detailDTO
,
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigConditionDTO
condition
,
StaffPerformanceCalContextDTO
context
,
PerformanceParamConfigConditionDTO
condition
,
JSONObject
resultLog
)
{
JSONObject
resultLog
)
{
...
@@ -699,7 +816,7 @@ public class StaffPerformanceCalService {
...
@@ -699,7 +816,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
)
countMatchingOrders
(
orders
,
int
excludedOrderCount
=
(
int
)
StaffPerformanceOrderUtil
.
countMatchingOrders
(
orders
,
condition
.
getConditionGoodsConfigType
(),
condition
.
getConditionGoodsConfigType
(),
condition
.
getConditionGoodsType
(),
condition
.
getConditionGoodsType
(),
condition
.
getConditionSecondaryGoodsType
(),
condition
.
getConditionSecondaryGoodsType
(),
...
@@ -721,6 +838,13 @@ public class StaffPerformanceCalService {
...
@@ -721,6 +838,13 @@ public class StaffPerformanceCalService {
}
}
}
}
/**
* 计算条件商品的渗透率
*
* @param condition 条件DTO
* @param context 计算上下文
* @return 渗透率
*/
private
BigDecimal
calculateConditionProductPenetrationRate
(
PerformanceParamConfigConditionDTO
condition
,
private
BigDecimal
calculateConditionProductPenetrationRate
(
PerformanceParamConfigConditionDTO
condition
,
StaffPerformanceCalContextDTO
context
)
{
StaffPerformanceCalContextDTO
context
)
{
// 计算条件定义的商品生成的子订单数
// 计算条件定义的商品生成的子订单数
...
@@ -731,30 +855,36 @@ public class StaffPerformanceCalService {
...
@@ -731,30 +855,36 @@ public class StaffPerformanceCalService {
return
BigDecimal
.
ZERO
;
return
BigDecimal
.
ZERO
;
}
}
long
matchedCount
=
countMatchingOrders
(
orders
,
long
matchedCount
=
StaffPerformanceOrderUtil
.
countMatchingOrders
(
orders
,
condition
.
getConditionGoodsConfigType
(),
condition
.
getConditionGoodsConfigType
(),
condition
.
getConditionGoodsType
(),
condition
.
getConditionGoodsType
(),
condition
.
getConditionSecondaryGoodsType
(),
condition
.
getConditionSecondaryGoodsType
(),
condition
.
getConditionThirdLevelGoodsType
(),
condition
.
getConditionThirdLevelGoodsType
(),
condition
.
getProductDefine
());
condition
.
getProductDefine
());
Integer
targetTouchCount
=
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
BigDecimal
targetTouchCount
=
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
.
getPersonalTargetTouchCount
();
.
getPersonalTargetTouchCount
();
BigDecimal
target
=
new
BigDecimal
(
Optional
.
ofNullable
(
targetTouchCount
).
orElse
(
0
)
);
BigDecimal
target
=
Optional
.
ofNullable
(
targetTouchCount
).
orElse
(
BigDecimal
.
ZERO
);
return
divideToPercent
(
new
BigDecimal
(
matchedCount
),
target
);
return
DataCalUtil
.
divideToPercent
(
new
BigDecimal
(
matchedCount
),
target
);
}
}
/**
* 计算个人渗透率(用于提成计算)
* 个人渗透率 = 主订单成交数 / 个人应触客数
*
* @param context 计算上下文
* @return 个人渗透率
*/
private
BigDecimal
computePersonalPenetrationRateForCommission
(
StaffPerformanceCalContextDTO
context
)
{
private
BigDecimal
computePersonalPenetrationRateForCommission
(
StaffPerformanceCalContextDTO
context
)
{
AssessmentFactorOrderDataDTO
orderData
=
context
.
getAssessmentFactorDependencyData
().
getOrderData
();
AssessmentFactorOrderDataDTO
orderData
=
context
.
getAssessmentFactorDependencyData
().
getOrderData
();
AssessmentFactorDailyDataDTO
dailyData
=
context
.
getAssessmentFactorDependencyData
().
getDailyData
();
AssessmentFactorDailyDataDTO
dailyData
=
context
.
getAssessmentFactorDependencyData
().
getDailyData
();
// 个人渗透率 = 主订单成交数 / 个人应触客数
BigDecimal
subOrderCount
=
new
BigDecimal
(
Optional
BigDecimal
mainOrderCount
=
new
BigDecimal
(
Optional
.
ofNullable
(
orderData
.
getCommissionBaseSubOrderCountByBrandAndCategory
()).
orElse
(
0
));
.
ofNullable
(
orderData
.
getCommissionBaseMainOrderCountByBrandAndCategory
()).
orElse
(
0
));
BigDecimal
targetTouchCount
=
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
())
BigDecimal
targetTouchCount
=
new
BigDecimal
(
.
orElse
(
BigDecimal
.
ZERO
);
Optional
.
ofNullable
(
dailyData
.
getPersonalTargetTouchCount
()).
orElse
(
0
));
return
DataCalUtil
.
divideToPercent
(
subOrderCount
,
targetTouchCount
);
return
divideToPercent
(
mainOrderCount
,
targetTouchCount
);
}
}
/**
/**
...
@@ -765,14 +895,15 @@ public class StaffPerformanceCalService {
...
@@ -765,14 +895,15 @@ public class StaffPerformanceCalService {
* @param validReferral 门店有效引荐数
* @param validReferral 门店有效引荐数
* @return 个人应触客数
* @return 个人应触客数
*/
*/
private
Integer
computePersonalExpectedTouchCount
(
Integer
actualPersonal
,
Integer
totalStore
,
private
BigDecimal
computePersonalExpectedTouchCount
(
Integer
actualPersonal
,
Integer
totalStore
,
Integer
validReferral
)
{
Integer
validReferral
)
{
int
actual
=
actualPersonal
==
null
?
0
:
actualPersonal
;
int
actual
=
actualPersonal
==
null
?
0
:
actualPersonal
;
int
total
=
totalStore
==
null
?
0
:
totalStore
;
int
total
=
totalStore
==
null
?
0
:
totalStore
;
int
referral
=
validReferral
==
null
?
0
:
validReferral
;
int
referral
=
validReferral
==
null
?
0
:
validReferral
;
if
(
referral
==
0
)
{
if
(
referral
==
0
)
{
return
0
;
log
.
warn
(
"门店有效引荐数为0,无法计算个人应触客数"
);
return
null
;
}
}
BigDecimal
bdActual
=
new
BigDecimal
(
actual
);
BigDecimal
bdActual
=
new
BigDecimal
(
actual
);
...
@@ -803,9 +934,15 @@ public class StaffPerformanceCalService {
...
@@ -803,9 +934,15 @@ public class StaffPerformanceCalService {
BigDecimal
.
ROUND_HALF_UP
);
BigDecimal
.
ROUND_HALF_UP
);
}
}
return
expected
.
setScale
(
0
,
BigDecimal
.
ROUND_HALF_UP
).
intValue
(
);
return
expected
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
}
/**
* 按照商户、业务类型、品牌、子品牌对订单进行分组
*
* @param orders 原始订单列表
* @return 分组后的订单Map
*/
private
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupOrders
(
List
<
StaffPerformanceSubOrderDTO
>
orders
)
{
private
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupOrders
(
List
<
StaffPerformanceSubOrderDTO
>
orders
)
{
return
orders
.
stream
()
return
orders
.
stream
()
.
filter
(
o
->
o
.
getMerchantId
()
!=
null
&&
o
.
getBusinessType
()
!=
null
.
filter
(
o
->
o
.
getMerchantId
()
!=
null
&&
o
.
getBusinessType
()
!=
null
...
@@ -817,15 +954,33 @@ public class StaffPerformanceCalService {
...
@@ -817,15 +954,33 @@ public class StaffPerformanceCalService {
o
.
getChildBrandId
())));
o
.
getChildBrandId
())));
}
}
private
String
generateGroupOrderMapKey
(
Integer
merchantId
,
Byte
businessType
,
Integer
brandId
,
/**
* 生成订单分组的Key
*
* @param merchantId 商户ID
* @param businessType 业务类型
* @param brandId 品牌ID
* @param childBrandId 子品牌ID
* @return 分组Key (merchantId_businessType_brandId_childBrandId)
*/
public
static
String
generateGroupOrderMapKey
(
Integer
merchantId
,
Byte
businessType
,
Integer
brandId
,
Integer
childBrandId
)
{
Integer
childBrandId
)
{
return
merchantId
+
"_"
+
businessType
+
"_"
+
brandId
+
"_"
+
childBrandId
;
return
merchantId
+
"_"
+
businessType
+
"_"
+
brandId
+
"_"
+
childBrandId
;
}
}
/**
* 处理单个订单分组
*
* @param groupKey 订单分组Key
* @param context 计算上下文
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRES_NEW
,
rollbackFor
=
RpcServiceException
.
class
)
public
List
<
StaffPerformanceDetailDTO
>
processOrderGroup
(
String
groupKey
,
public
void
processOrderGroup
(
String
groupKey
,
StaffPerformanceCalContextDTO
context
)
{
StaffPerformanceCalContextDTO
context
)
{
String
[]
keys
=
groupKey
.
split
(
"_"
);
String
[]
keys
=
groupKey
.
split
(
"_"
);
if
(
keys
.
length
!=
4
)
{
log
.
error
(
"无效的分组Key: {}"
,
groupKey
);
return
;
}
Integer
merchantId
=
Integer
.
parseInt
(
keys
[
0
]);
Integer
merchantId
=
Integer
.
parseInt
(
keys
[
0
]);
Byte
businessType
=
Byte
.
parseByte
(
keys
[
1
]);
Byte
businessType
=
Byte
.
parseByte
(
keys
[
1
]);
Integer
brandId
=
Integer
.
parseInt
(
keys
[
2
]);
Integer
brandId
=
Integer
.
parseInt
(
keys
[
2
]);
...
@@ -837,79 +992,122 @@ public class StaffPerformanceCalService {
...
@@ -837,79 +992,122 @@ public class StaffPerformanceCalService {
OrderBusinessTypeEnum
businessTypeEnum
=
OrderBusinessTypeEnum
.
getByValue
(
businessType
);
OrderBusinessTypeEnum
businessTypeEnum
=
OrderBusinessTypeEnum
.
getByValue
(
businessType
);
if
(
businessTypeEnum
==
null
)
{
if
(
businessTypeEnum
==
null
)
{
log
.
error
(
"
Invalid business type
: {}"
,
businessType
);
log
.
error
(
"
无效的业务类型
: {}"
,
businessType
);
return
Collections
.
emptyList
()
;
return
;
}
}
log
.
info
(
"
Processing group
: merchantId={}, businessType={}, brandId={}, childBrandId={}"
,
log
.
info
(
"
开始处理订单组
: merchantId={}, businessType={}, brandId={}, childBrandId={}"
,
merchantId
,
businessType
,
brandId
,
childBrandId
);
merchantId
,
businessType
,
brandId
,
childBrandId
);
AssessmentFactorDependencyDataDTO
dependencyData
=
calculateDependencyData
(
AssessmentFactorDependencyDataDTO
dependencyData
=
calculateDependencyData
(
context
);
context
.
getGroupedOrdersMap
(),
merchantId
,
businessType
,
brandId
,
childBrandId
,
context
.
getStaffPhone
(),
context
.
getPerformanceMonth
());
context
.
setAssessmentFactorDependencyData
(
dependencyData
);
context
.
setAssessmentFactorDependencyData
(
dependencyData
);
PerformanceConfigDTO
config
=
getEffectivePerformanceConfig
(
merchantId
,
brandId
,
childBrandId
,
PerformanceConfigDTO
config
=
getEffectivePerformanceConfig
(
merchantId
,
businessType
,
brandId
,
childBrandId
,
context
.
getPerformanceMonth
());
context
.
getPerformanceMonth
());
if
(
config
==
null
)
{
if
(
config
==
null
)
{
return
Collections
.
emptyList
();
log
.
error
(
"未找到有效的绩效配置,不计算提成: merchantId={}, brandId={}, month={}"
,
merchantId
,
brandId
,
context
.
getPerformanceMonth
());
return
;
}
}
context
.
setMerchantName
(
config
.
getMerchantName
());
context
.
setPerformanceConfig
(
config
);
context
.
setPerformanceConfig
(
config
);
if
(
CollectionUtils
.
isEmpty
(
config
.
getPerformanceParamConfigs
()))
{
if
(
CollectionUtils
.
isEmpty
(
config
.
getPerformanceParamConfigs
()))
{
log
.
warn
(
"No performance param configs found for merchantId={}, businessType={}, brandId={}, month={}"
,
log
.
error
(
"未找到绩效参数配置,不计算提成: configId:{}"
,
config
.
getId
());
merchantId
,
businessType
,
brandId
,
context
.
getPerformanceMonth
());
return
;
return
Collections
.
emptyList
();
}
}
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
=
thiz
.
evaluatePerformanceConfigs
(
context
);
return
thiz
.
evaluatePerformanceConfigs
(
context
);
// 保存StaffPerformanceDetailDTO
staffPerformanceDetailService
.
saveStaffPerformanceDetails
(
config
,
performanceDetailDTOS
);
// 汇总计算保存StaffProductPerformance
staffProductPerformanceService
.
saveStaffProductPerformance
(
context
,
performanceDetailDTOS
);
// 汇总计算保存StaffPerformance
staffPerformanceService
.
saveStaffPerformance
(
context
,
performanceDetailDTOS
);
}
}
private
PerformanceConfigDTO
getEffectivePerformanceConfig
(
Integer
merchantId
,
Integer
brandId
,
/**
* 获取有效的绩效配置
*
* @param merchantId 商户ID
* @param businessType 业务类型
* @param brandId 品牌ID
* @param childBrandId 子品牌ID
* @param month 月份
* @return 绩效配置DTO
*/
private
PerformanceConfigDTO
getEffectivePerformanceConfig
(
Integer
merchantId
,
Byte
businessType
,
Integer
brandId
,
Integer
childBrandId
,
String
month
)
{
Integer
childBrandId
,
String
month
)
{
RpcAssert
.
assertNotNull
(
merchantId
,
DefaultErrorEnum
.
DATA_NULL
,
"merchantId不能为空"
);
RpcAssert
.
assertNotNull
(
businessType
,
DefaultErrorEnum
.
DATA_NULL
,
"businessType不能为空"
);
RpcAssert
.
assertNotNull
(
brandId
,
DefaultErrorEnum
.
DATA_NULL
,
"brandId不能为空"
);
RpcAssert
.
assertNotNull
(
childBrandId
,
DefaultErrorEnum
.
DATA_NULL
,
"childBrandId不能为空"
);
RpcAssert
.
assertNotNull
(
month
,
DefaultErrorEnum
.
DATA_NULL
,
"month不能为空"
);
PerformanceConfigDTO
queryConfig
=
PerformanceConfigDTO
.
builder
()
PerformanceConfigDTO
queryConfig
=
PerformanceConfigDTO
.
builder
()
.
merchantId
(
merchantId
)
.
merchantId
(
merchantId
)
.
businessType
(
businessType
)
.
brandId
(
brandId
)
.
brandId
(
brandId
)
.
childBrandId
(
childBrandId
)
.
childBrandId
(
childBrandId
)
.
effectiveMonth
(
month
)
.
effectiveMonth
(
month
)
.
build
();
.
build
();
PerformanceConfigDTO
config
=
performanceConfigService
.
selectEffectiveConfig
(
queryConfig
);
PerformanceConfigDTO
config
=
performanceConfigService
.
selectEffectiveConfig
(
queryConfig
);
if
(
config
==
null
)
{
if
(
config
==
null
)
{
log
.
warn
(
"
No effective performance config found for merchantId={}, b
randId={}, month={}"
,
log
.
warn
(
"
未找到有效的绩效配置: merchantId={}, businessType={}, brandId={}, childB
randId={}, month={}"
,
merchantId
,
brandId
,
month
);
merchantId
,
b
usinessType
,
brandId
,
childB
randId
,
month
);
}
}
return
config
;
return
config
;
}
}
/**
* 提成配置计算
*
* @param context 计算上下文
* @return 提成明细列表
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
List
<
StaffPerformanceDetailDTO
>
evaluatePerformanceConfigs
(
StaffPerformanceCalContextDTO
context
)
{
public
List
<
StaffPerformanceDetailDTO
>
evaluatePerformanceConfigs
(
StaffPerformanceCalContextDTO
context
)
{
log
.
info
(
"开始提成配置计算: staffPhone={}, merchantId={}"
,
context
.
getStaffPhone
(),
context
.
getMerchantId
());
// 配置按照考核因子+品类信息分组
List
<
StaffPerformanceDetailDTO
>
groupResults
=
new
ArrayList
<>();
List
<
StaffPerformanceDetailDTO
>
groupResults
=
new
ArrayList
<>();
Map
<
String
,
List
<
PerformanceParamConfigDTO
>>
paramConfigGroupMap
=
context
.
getPerformanceConfig
()
Map
<
String
,
List
<
PerformanceParamConfigDTO
>>
paramConfigGroupMap
=
context
.
getPerformanceConfig
()
.
getPerformanceParamConfigs
().
stream
()
.
getPerformanceParamConfigs
().
stream
()
.
collect
(
Collectors
.
groupingBy
(
this
::
generateParamConfigGroupKey
));
.
collect
(
Collectors
.
groupingBy
(
this
::
generateParamConfigGroupKey
));
for
(
List
<
PerformanceParamConfigDTO
>
paramConfigs
:
paramConfigGroupMap
.
values
())
{
for
(
List
<
PerformanceParamConfigDTO
>
paramConfigs
:
paramConfigGroupMap
.
values
())
{
// Sort by startValue desc
paramConfigs
.
sort
((
a
,
b
)
->
{
BigDecimal
valA
=
a
.
getStartValue
()
==
null
?
BigDecimal
.
ZERO
:
a
.
getStartValue
();
BigDecimal
valB
=
b
.
getStartValue
()
==
null
?
BigDecimal
.
ZERO
:
b
.
getStartValue
();
return
valB
.
compareTo
(
valA
);
});
PerformanceParamConfigDTO
firstConfig
=
paramConfigs
.
get
(
0
);
PerformanceParamConfigDTO
firstConfig
=
paramConfigs
.
get
(
0
);
Byte
assessmentFactor
=
firstConfig
.
getAssessmentFactor
();
Byte
assessmentFactor
=
firstConfig
.
getAssessmentFactor
();
Byte
goodsConfigType
=
firstConfig
.
getGoodsConfigType
();
Integer
goodsType
=
firstConfig
.
getGoodsType
();
Integer
secondaryGoodsType
=
firstConfig
.
getSecondaryGoodsType
();
Integer
thirdLevelGoodsType
=
firstConfig
.
getThirdLevelGoodsType
();
Integer
productDefineId
=
firstConfig
.
getProductDefineId
();
log
.
info
(
"开始提成配置计算: configId={}, assessmentFactor={}, goodsConfigType={}, goodsType={}, secondaryGoodsType={}, thirdLevelGoodsType={}, productDefineId={}"
,
firstConfig
.
getId
(),
assessmentFactor
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefineId
);
if
(
Objects
.
equals
(
firstConfig
.
getCommissionType
(),
CommissionMethodEnum
.
XS
.
getCode
())
&&
!
Objects
.
equals
(
goodsConfigType
,
ProductConfigTypeEnum
.
ALL_PRODUCT
.
getCode
()))
{
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"系数计算方式必须指定为全部品类"
);
}
BigDecimal
actualValue
=
getActualValue
(
assessmentFactor
,
context
,
BigDecimal
actualValue
=
getActualValue
(
assessmentFactor
,
context
,
firstConfig
.
getGoodsConfigType
(),
goodsConfigType
,
firstConfig
.
getGoodsType
(),
firstConfig
.
getSecondaryGoodsType
(),
goodsType
,
firstConfig
.
getThirdLevelGoodsType
(),
secondaryGoodsType
,
firstConfig
.
getProductDefineId
());
thirdLevelGoodsType
,
productDefineId
);
log
.
debug
(
"AssessmentFactor: {}, ActualValue: {}"
,
assessmentFactor
,
actualValue
);
log
.
debug
(
"goodsConfigType:{}, goodsType:{},secondaryGoodsType:{},thirdLevelGoodsType:{},productDefineId:{},考核因子: {},实际值: {}"
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefineId
,
assessmentFactor
,
actualValue
);
for
(
PerformanceParamConfigDTO
paramConfig
:
paramConfigs
)
{
for
(
PerformanceParamConfigDTO
paramConfig
:
paramConfigs
)
{
if
(
isConfigMatch
(
paramConfig
,
actualValue
))
{
if
(
isConfigMatch
(
paramConfig
,
actualValue
))
{
log
.
info
(
"
Matched param config 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
);
...
@@ -921,13 +1119,17 @@ public class StaffPerformanceCalService {
...
@@ -921,13 +1119,17 @@ public class StaffPerformanceCalService {
}
}
private
boolean
isConfigMatch
(
PerformanceParamConfigDTO
paramConfig
,
BigDecimal
actualValue
)
{
private
boolean
isConfigMatch
(
PerformanceParamConfigDTO
paramConfig
,
BigDecimal
actualValue
)
{
if
(
actualValue
==
null
)
{
log
.
error
(
"Actual value is null, paramConfig: {}"
,
paramConfig
);
return
false
;
}
BigDecimal
start
=
paramConfig
.
getStartValue
()
==
null
?
BigDecimal
.
ZERO
:
paramConfig
.
getStartValue
();
BigDecimal
start
=
paramConfig
.
getStartValue
()
==
null
?
BigDecimal
.
ZERO
:
paramConfig
.
getStartValue
();
BigDecimal
end
=
paramConfig
.
getEndValue
();
BigDecimal
end
=
paramConfig
.
getEndValue
();
if
(
end
==
null
)
{
if
(
end
==
null
)
{
return
actualValue
.
compareTo
(
start
)
>=
0
;
return
actualValue
.
compareTo
(
start
)
>=
0
;
}
else
{
}
else
{
return
actualValue
.
compareTo
(
start
)
>=
0
&&
actualValue
.
compareTo
(
end
)
<
0
;
return
actualValue
.
compareTo
(
start
)
>=
0
&&
actualValue
.
compareTo
(
end
)
<
=
0
;
}
}
}
}
...
@@ -935,34 +1137,92 @@ public class StaffPerformanceCalService {
...
@@ -935,34 +1137,92 @@ public class StaffPerformanceCalService {
Byte
goodsConfigType
,
Byte
goodsConfigType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
Integer
productDefineId
)
{
Integer
productDefineId
)
{
String
groupKey
=
context
.
getMerchantId
()
+
"_"
+
context
.
getBusinessType
()
+
"_"
+
context
.
getBrandId
()
log
.
info
(
"开始计算品类依赖数据: goodsConfigType={}, goodsType={}, secondaryGoodsType={}, thirdLevelGoodsType={}, productDefineId={}"
,
+
"_"
+
context
.
getChildBrandId
();
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefineId
);
String
groupKey
=
generateGroupOrderMapKey
(
context
.
getMerchantId
(),
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getChildBrandId
());
List
<
StaffPerformanceSubOrderDTO
>
orders
=
context
.
getGroupedOrdersMap
().
get
(
groupKey
);
List
<
StaffPerformanceSubOrderDTO
>
orders
=
context
.
getGroupedOrdersMap
().
get
(
groupKey
);
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
log
.
info
(
"该分组下无订单数据,重置依赖数据"
);
resetCategoryData
(
context
);
resetCategoryData
(
context
);
return
;
return
;
}
}
MerchantPerformanceProductDefineDTO
productDefine
=
null
;
if
(
goodsConfigType
==
1
||
goodsConfigType
==
2
)
{
// 1. 获取圈定商品定义(如果有)
RpcAssert
.
assertNotNull
(
productDefineId
,
DefaultErrorEnum
.
DATA_NULL
,
MerchantPerformanceProductDefineDTO
productDefine
=
getMerchantPerformanceProductDefine
(
goodsConfigType
,
"productDefineId not be null"
);
productDefineId
);
productDefine
=
merchantPerformanceProductDefineRemote
// 2. 获取有效订单类型配置
final
List
<
Byte
>
validOrderTypes
=
getValidDjOrderTypesForCommissionBasic
();
// 3. 根据配置类型分别处理
if
(
Objects
.
equals
(
ProductConfigTypeEnum
.
PRODUCT_CATEGORY
.
getCode
(),
goodsConfigType
)
||
Objects
.
equals
(
ProductConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
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
);
}
}
/**
* 获取圈定商品定义
*
* @param goodsConfigType 商品配置类型
* @param productDefineId 圈定商品ID
* @return 商品定义DTO
*/
private
MerchantPerformanceProductDefineDTO
getMerchantPerformanceProductDefine
(
Byte
goodsConfigType
,
Integer
productDefineId
)
{
if
(
Objects
.
equals
(
ProductConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
goodsConfigType
)
||
Objects
.
equals
(
ProductConfigTypeEnum
.
DESIGNATED_PACKAGE
.
getCode
(),
goodsConfigType
))
{
RpcAssert
.
assertNotNull
(
productDefineId
,
DefaultErrorEnum
.
DATA_NULL
,
"圈定商品ID不能为空"
);
MerchantPerformanceProductDefineDTO
productDefine
=
merchantPerformanceProductDefineRemote
.
getByIdWithRadicalUpgradeGoodsItem
(
productDefineId
).
getResult
();
.
getByIdWithRadicalUpgradeGoodsItem
(
productDefineId
).
getResult
();
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
"获取不到对应圈定商品,圈定商品ID:{}"
,
"productDefineDTO not be null"
);
productDefineId
);
return
productDefine
;
}
return
null
;
}
}
final
List
<
Byte
>
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
=
Arrays
.
stream
(
OrePropertyConfigurer
/**
* 获取用于计算提成基数的有效电家订单类型
*
* @return 订单类型列表
*/
private
List
<
Byte
>
getValidDjOrderTypesForCommissionBasic
()
{
return
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
());
if
(
goodsConfigType
==
0
||
goodsConfigType
==
1
)
{
}
final
MerchantPerformanceProductDefineDTO
finalProductDefine
=
productDefine
;
/**
* 处理品类或指定商品的数据计算
*/
private
void
processCategoryOrProductData
(
StaffPerformanceCalContextDTO
context
,
List
<
StaffPerformanceSubOrderDTO
>
orders
,
Byte
goodsConfigType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
MerchantPerformanceProductDefineDTO
productDefine
,
List
<
Byte
>
validOrderTypes
)
{
log
.
info
(
"处理品类/单品数据: orders.size={}"
,
orders
.
size
());
// 筛选符合条件的订单
List
<
StaffPerformanceSubOrderDTO
>
filteredOrders
=
orders
.
stream
()
List
<
StaffPerformanceSubOrderDTO
>
filteredOrders
=
orders
.
stream
()
.
filter
(
o
->
isOrderMatchCategory
(
o
,
goodsConfigType
,
goodsType
,
.
filter
(
o
->
StaffPerformanceOrderUtil
.
isOrderMatchCategory
(
o
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
finalP
roductDefine
))
thirdLevelGoodsType
,
p
roductDefine
))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
// 计算基础数据
Integer
mainOrderCount
=
Math
.
toIntExact
(
Integer
mainOrderCount
=
Math
.
toIntExact
(
filteredOrders
.
stream
().
map
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
)
filteredOrders
.
stream
().
map
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
)
.
distinct
()
.
distinct
()
...
@@ -972,129 +1232,95 @@ public class StaffPerformanceCalService {
...
@@ -972,129 +1232,95 @@ public class StaffPerformanceCalService {
.
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
);
AssessmentFactorOrderDataDTO
orderData
=
context
.
getAssessmentFactorDependencyData
()
// 更新上下文数据
.
getOrderData
();
AssessmentFactorOrderDataDTO
orderData
=
context
.
getAssessmentFactorDependencyData
()
.
getOrderData
();
orderData
.
setMainOrderCountByBrandAndCategory
(
mainOrderCount
);
orderData
.
setMainOrderCountByBrandAndCategory
(
mainOrderCount
);
orderData
.
setSubOrderCountByBrandAndCategory
(
subOrderCount
);
orderData
.
setSubOrderCountByBrandAndCategory
(
subOrderCount
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
List
<
StaffPerformanceSubOrderDTO
>
filteredOrdersForCommissionBase
=
orders
.
stream
()
log
.
info
(
"品类/单品基础数据: mainOrderCount={}, subOrderCount={}, outputTotal={}"
,
mainOrderCount
,
.
filter
(
o
->
isOrderMatchCategory
(
o
,
goodsConfigType
,
goodsType
,
subOrderCount
,
secondaryGoodsType
,
outputTotal
);
thirdLevelGoodsType
,
finalProductDefine
))
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
// 计算提成基数相关数据 (过滤特定订单类型)
.
contains
(
o
.
getDjOrderType
()))
List
<
StaffPerformanceSubOrderDTO
>
filteredOrdersForCommissionBase
=
filteredOrders
.
stream
()
.
filter
(
o
->
validOrderTypes
.
contains
(
o
.
getDjOrderType
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
Integer
commissionBaseMainOrderCountByBrandAndCategory
=
Math
.
toIntExact
(
filteredOrdersForCommissionBase
.
stream
()
Integer
commissionBaseSubOrderCount
=
filteredOrdersForCommissionBase
.
size
();
.
map
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
)
BigDecimal
commissionBaseOutputTotal
=
filteredOrdersForCommissionBase
.
stream
()
.
distinct
()
.
count
());
Integer
commissionBaseSubOrderCountByBrandAndCategory
=
filteredOrdersForCommissionBase
.
size
();
BigDecimal
commissionBaseCategoryOrderOutputTotalByBrandAndCategory
=
filteredOrdersForCommissionBase
.
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
);
orderData
.
setCommissionBaseMainOrderCountByBrandAndCategory
(
commissionBaseMainOrderCountByBrandAndCategory
);
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
commissionBaseSubOrderCount
);
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
commissionBaseOutputTotal
);
commissionBaseSubOrderCountByBrandAndCategory
);
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
log
.
info
(
"品类/单品提成基数数据: baseSubOrderCount={}, baseOutputTotal={}"
,
commissionBaseSubOrderCount
,
commissionBaseCategoryOrderOutputTotalByBrandAndCategory
);
commissionBaseOutputTotal
);
}
else
if
(
goodsConfigType
==
2
)
{
}
final
MerchantPerformanceProductDefineDTO
finalProductDefine
=
productDefine
;
/**
* 处理指定套系的数据计算
*/
private
void
processPackageData
(
StaffPerformanceCalContextDTO
context
,
List
<
StaffPerformanceSubOrderDTO
>
orders
,
MerchantPerformanceProductDefineDTO
productDefine
,
List
<
Byte
>
validOrderTypes
)
{
log
.
info
(
"处理套系数据: orders.size={}, productDefineId={}"
,
orders
.
size
(),
productDefine
.
getId
());
RpcAssert
.
assertNotEmpty
(
productDefine
.
getPackageItemList
(),
DefaultErrorEnum
.
DATA_NULL
,
RpcAssert
.
assertNotEmpty
(
productDefine
.
getPackageItemList
(),
DefaultErrorEnum
.
DATA_NULL
,
"productDefine.getPackageItemList() is empty"
);
"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
));
// 筛选符合套系定义的订单组
List
<
List
<
StaffPerformanceSubOrderDTO
>>
matchedPackageOrders
=
groupedOrders
.
values
().
stream
()
List
<
List
<
StaffPerformanceSubOrderDTO
>>
matchedPackageOrders
=
groupedOrders
.
values
().
stream
()
.
filter
(
o
->
isOrderMatchPackage
(
o
,
finalProductDefine
.
getPackageItemList
()))
.
filter
(
o
->
StaffPerformanceOrderUtil
.
isOrderMatchPackage
(
o
,
productDefine
.
getPackageItemList
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
// 计算基础数据
Integer
mainOrderCount
=
matchedPackageOrders
.
size
();
Integer
mainOrderCount
=
matchedPackageOrders
.
size
();
BigDecimal
outputTotal
=
matchedPackageOrders
.
stream
()
// 套系逻辑下,子订单数暂取主订单数(或根据实际需求调整,原文逻辑如此)
.
flatMap
(
List:
:
stream
)
Integer
subOrderCount
=
mainOrderCount
;
BigDecimal
outputTotal
=
matchedPackageOrders
.
stream
()
// 使用筛选后的matchedPackageOrders更准确
.
flatMap
(
o
->
StaffPerformanceOrderUtil
.
matchPackageSubOrders
(
o
,
productDefine
.
getPackageItemList
())
.
stream
())
// 这里matchPackageSubOrders可能会再次过滤,确保只计算套系内的子订单产值
.
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
);
AssessmentFactorOrderDataDTO
orderData
=
context
.
getAssessmentFactorDependencyData
()
.
getOrderData
();
// 更新上下文数据
AssessmentFactorOrderDataDTO
orderData
=
context
.
getAssessmentFactorDependencyData
().
getOrderData
();
orderData
.
setMainOrderCountByBrandAndCategory
(
mainOrderCount
);
orderData
.
setMainOrderCountByBrandAndCategory
(
mainOrderCount
);
orderData
.
setSubOrderCountByBrandAndCategory
(
main
OrderCount
);
orderData
.
setSubOrderCountByBrandAndCategory
(
sub
OrderCount
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
outputTotal
);
List
<
List
<
StaffPerformanceSubOrderDTO
>>
matchedPackageOrdersForCommissionBase
=
groupedOrders
log
.
info
(
"套系基础数据: mainOrderCount={}, outputTotal={}"
,
mainOrderCount
,
outputTotal
);
.
values
().
stream
()
.
filter
(
o
->
isOrderMatchPackage
(
o
,
finalProductDefine
.
getPackageItemList
()))
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.
contains
(
o
.
get
(
0
).
getDjOrderType
()))
.
collect
(
Collectors
.
toList
());
Integer
commissionBaseMainOrderCountByBrandAndCategory
=
matchedPackageOrdersForCommissionBase
.
size
();
BigDecimal
commissionBaseCategoryOrderOutputTotalByBrandAndCategory
=
matchedPackageOrdersForCommissionBase
.
stream
()
.
flatMap
(
List:
:
stream
)
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
orderData
.
setCommissionBaseMainOrderCountByBrandAndCategory
(
commissionBaseMainOrderCountByBrandAndCategory
);
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
commissionBaseMainOrderCountByBrandAndCategory
);
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
commissionBaseCategoryOrderOutputTotalByBrandAndCategory
);
}
}
private
boolean
isOrderMatchPackage
(
List
<
StaffPerformanceSubOrderDTO
>
o
,
// 计算提成基数相关数据 (过滤特定订单类型)
List
<
List
<
MerchantPerformanceProductDefineItem
>>
packageItemList
)
{
// 注意:这里原文是 filter groupedOrders.values() 再 filter matchPackage,这里直接复用
if
(
CollectionUtils
.
isEmpty
(
o
)
||
CollectionUtils
.
isEmpty
(
packageItemList
))
{
// matchedPackageOrders 效率更高
return
false
;
List
<
List
<
StaffPerformanceSubOrderDTO
>>
matchedOrdersForCommissionBase
=
matchedPackageOrders
.
stream
()
}
.
filter
(
o
->
!
o
.
isEmpty
()
&&
validOrderTypes
.
contains
(
o
.
get
(
0
).
getDjOrderType
()))
// 假设同一单下的子订单类型一致,或取出任一判断
List
<
Integer
>
upgradeGoodsIds
=
o
.
stream
().
map
(
StaffPerformanceSubOrderDTO:
:
getUpgradeGoodsId
)
.
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
// 匹配逻辑:packageItemList 定义了多个必选商品组。
// 订单必须包含每一个商品组中的至少一个商品,才被视为匹配该组合套餐。
boolean
isMatch
=
true
;
if
(
packageItemList
.
stream
().
anyMatch
(
packageItem
->
{
List
<
Integer
>
itemIds
=
packageItem
.
stream
()
.
map
(
MerchantPerformanceProductDefineItem:
:
getItemId
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
return
!
CollectionUtils
.
containsAny
(
upgradeGoodsIds
,
itemIds
);
}))
{
isMatch
=
false
;
}
return
isMatch
;
}
private
long
countMatchingOrders
(
List
<
StaffPerformanceSubOrderDTO
>
orders
,
Integer
commissionBaseMainOrderCount
=
matchedOrdersForCommissionBase
.
size
();
Integer
goodsConfigType
,
BigDecimal
commissionBaseOutputTotal
=
matchedOrdersForCommissionBase
.
stream
()
Integer
goodsType
,
.
flatMap
(
o
->
StaffPerformanceOrderUtil
Integer
secondaryGoodsType
,
.
matchPackageSubOrders
(
o
,
productDefine
.
getPackageItemList
())
Integer
thirdLevelGoodsType
,
.
stream
())
MerchantPerformanceProductDefineDTO
productDefine
)
{
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
if
(
CollectionUtils
.
isEmpty
(
orders
)
||
goodsConfigType
==
null
)
{
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
return
0
;
}
if
(
goodsConfigType
==
2
)
{
orderData
.
setCommissionBaseSubOrderCountByBrandAndCategory
(
commissionBaseMainOrderCount
);
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
orderData
.
setCommissionBaseCategoryOrderOutputTotalByBrandAndCategory
(
commissionBaseOutputTotal
);
"conditionProductDefine is null"
);
RpcAssert
.
assertNotEmpty
(
productDefine
.
getPackageItemList
(),
DefaultErrorEnum
.
DATA_NULL
,
"conditionProductDefine.getPackageItemList() is empty"
);
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrders
=
orders
.
stream
()
log
.
info
(
"套系提成基数数据: baseMainOrderCount={}, baseOutputTotal={}"
,
commissionBaseMainOrderCount
,
.
collect
(
Collectors
.
groupingBy
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
));
commissionBaseOutputTotal
);
return
groupedOrders
.
values
().
stream
()
.
filter
(
o
->
isOrderMatchPackage
(
o
,
productDefine
.
getPackageItemList
()))
.
count
();
}
else
{
return
orders
.
stream
()
.
filter
(
o
->
isOrderMatchCategory
(
o
,
goodsConfigType
.
byteValue
(),
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefine
))
.
count
();
}
}
}
private
void
resetCategoryData
(
StaffPerformanceCalContextDTO
context
)
{
private
void
resetCategoryData
(
StaffPerformanceCalContextDTO
context
)
{
...
@@ -1104,40 +1330,4 @@ public class StaffPerformanceCalService {
...
@@ -1104,40 +1330,4 @@ public class StaffPerformanceCalService {
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
BigDecimal
.
ZERO
);
orderData
.
setCategoryOrderOutputTotalByBrandAndCategory
(
BigDecimal
.
ZERO
);
}
}
private
boolean
isOrderMatchCategory
(
StaffPerformanceSubOrderDTO
order
,
Byte
goodsConfigType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
MerchantPerformanceProductDefineDTO
productDefine
)
{
RpcAssert
.
assertNotNull
(
goodsConfigType
,
DefaultErrorEnum
.
DATA_NULL
,
"goodsConfigType not be null"
);
// TODO 改用枚举
// -1:全部商品
if
(
goodsConfigType
==
-
1
)
{
return
true
;
}
// 0:商品分类
if
(
goodsConfigType
==
0
)
{
boolean
match
=
true
;
if
(
goodsType
!=
null
)
{
match
=
match
&&
Objects
.
equals
(
goodsType
,
order
.
getGoodsType
());
}
if
(
secondaryGoodsType
!=
null
)
{
match
=
match
&&
Objects
.
equals
(
secondaryGoodsType
,
order
.
getSecondaryGoodsType
());
}
if
(
thirdLevelGoodsType
!=
null
)
{
match
=
match
&&
Objects
.
equals
(
thirdLevelGoodsType
,
order
.
getThirdLevelGoodsType
());
}
return
match
;
}
// 1:圈定产品
if
(
goodsConfigType
==
1
)
{
return
productDefine
.
getItemList
().
stream
()
.
anyMatch
(
item
->
Objects
.
equals
(
item
.
getItemId
(),
order
.
getUpgradeGoodsId
()));
}
return
false
;
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceDetailService.java
0 → 100644
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
staffPerformance
;
import
cn.com.glsx.dj.staff.constant.CommonConstants
;
import
cn.com.glsx.dj.staff.dto.PerformanceConfigDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO
;
import
cn.com.glsx.dj.staff.mapper.StaffPerformanceDetailMapper
;
import
cn.com.glsx.dj.staff.model.StaffPerformanceDetail
;
import
cn.com.glsx.framework.core.beans.BaseModel
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* 员工绩效明细服务
*/
@Slf4j
@Service
public
class
StaffPerformanceDetailService
{
@Autowired
private
StaffPerformanceDetailMapper
staffPerformanceDetailMapper
;
/**
* 保存员工绩效明细
*
* @param config 绩效配置DTO
* @param performanceDetailDTOS 明细列表
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
saveStaffPerformanceDetails
(
PerformanceConfigDTO
config
,
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
)
{
if
(
config
==
null
||
config
.
getMerchantId
()
==
null
||
config
.
getBusinessType
()
==
null
||
config
.
getEffectiveMonth
()
==
null
)
{
log
.
error
(
"保存员工绩效明细失败:必填参数缺失, config={}"
,
config
);
return
;
}
log
.
info
(
"Saving staff performance details. merchantId={}, businessType={}, month={}, count={}"
,
config
.
getMerchantId
(),
config
.
getBusinessType
(),
config
.
getEffectiveMonth
(),
performanceDetailDTOS
==
null
?
0
:
performanceDetailDTOS
.
size
());
if
(
CollectionUtils
.
isEmpty
(
performanceDetailDTOS
))
{
log
.
error
(
"员工绩效明细列表为空,无需保存"
);
return
;
}
// 1. 调用mapper,通过update更新相同merchantId businessType brandId childBrandId
// performanceMonth的记录的deletedFlag = 'D'
StaffPerformanceDetail
query
=
StaffPerformanceDetail
.
builder
()
.
merchantId
(
config
.
getMerchantId
())
.
businessType
(
config
.
getBusinessType
())
.
brandId
(
config
.
getBrandId
())
.
childBrandId
(
config
.
getChildBrandId
())
.
month
(
config
.
getEffectiveMonth
())
.
updatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
)
.
build
();
int
updatedRecord
=
staffPerformanceDetailMapper
.
removePerformanceDetail
(
query
);
log
.
info
(
"Logically deleted {} old records."
,
updatedRecord
);
// 2. stream处理,设置createdBy、updatedBy='system',createdDate、updatedDate = now (new
// date)
Date
now
=
new
Date
();
List
<
StaffPerformanceDetailDTO
>
insertList
=
performanceDetailDTOS
.
stream
().
map
(
dto
->
{
// Ensure ID is null for insert to avoid conflicts if ID was somehow set
dto
.
setId
(
null
);
dto
.
setCreatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
dto
.
setUpdatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
dto
.
setCreatedDate
(
now
);
dto
.
setUpdatedDate
(
now
);
dto
.
setDeletedFlag
(
BaseModel
.
DeletedFlagEnum
.
N
.
name
());
return
dto
;
}).
collect
(
Collectors
.
toList
());
// 3. 调用mapper.insertList方法将记录入库
// MyBatis batch insert usually has a limit, but assuming list size is
// reasonable for now.
// If list is very large, consider partitioning.
if
(
CollectionUtils
.
isNotEmpty
(
insertList
))
{
int
insertedCount
=
staffPerformanceDetailMapper
.
insertList
(
insertList
);
log
.
info
(
"Inserted {} new records."
,
insertedCount
);
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffPerformanceService.java
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
staffPerformance
;
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
staffPerformance
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.constant.CommonConstants
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.dto.performance.StaffPerformanceDTO
;
import
cn.com.glsx.dj.staff.enums.CommissionMethodEnum
;
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.StaffPerformance
;
import
cn.com.glsx.dj.staff.service.StaffBeisenBaseInfoService
;
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
com.alibaba.fastjson.JSONObject
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
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
;
import
org.springframework.stereotype.Service
;
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
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.YearMonth
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Slf4j
@Slf4j
@Service
@Service
...
@@ -22,13 +42,198 @@ public class StaffPerformanceService {
...
@@ -22,13 +42,198 @@ public class StaffPerformanceService {
private
StaffPerformanceService
thiz
;
private
StaffPerformanceService
thiz
;
@Autowired
@Autowired
private
StaffPerformanceMapper
staffPerformanceMapper
;
private
StaffPerformanceMapper
staffPerformanceMapper
;
@Autowired
private
StaffBeisenBaseInfoService
staffBeisenBaseInfoService
;
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
void
saveStaffPerformance
(
StaffPerformanceCalContextDTO
context
,
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
)
{
if
(
context
==
null
||
CollectionUtils
.
isEmpty
(
performanceDetailDTOS
))
{
log
.
error
(
"输入数据无效: context 为空或 performanceDetailDTOS 为空"
);
return
;
}
// 1. 根据 merchantId, businessType, brandId, childBrandId 分组
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupedMap
=
groupPerformanceDetails
(
performanceDetailDTOS
);
// 2. 检查是否处于新人保护期
boolean
isNewcomerProtection
=
checkNewcomerProtection
(
context
.
getStaffPhone
(),
context
.
getPerformanceMonth
());
List
<
StaffPerformance
>
insertList
=
new
ArrayList
<>();
Date
now
=
new
Date
();
for
(
List
<
StaffPerformanceDetailDTO
>
groupList
:
groupedMap
.
values
())
{
if
(
CollectionUtils
.
isEmpty
(
groupList
))
{
continue
;
}
// 3. 构建 StaffPerformance
StaffPerformance
staffPerformance
=
buildStaffPerformance
(
groupList
,
context
,
isNewcomerProtection
,
now
);
insertList
.
add
(
staffPerformance
);
// 4. 逻辑删除旧数据
staffPerformanceMapper
.
removeStaffPerformance
(
staffPerformance
);
}
// 5. 批量插入新数据
if
(
CollectionUtils
.
isNotEmpty
(
insertList
))
{
staffPerformanceMapper
.
insertList
(
insertList
);
}
}
/**
* 对详情数据进行分组
*/
private
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupPerformanceDetails
(
List
<
StaffPerformanceDetailDTO
>
details
)
{
return
details
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
dto
->
dto
.
getMerchantId
()
+
"_"
+
dto
.
getBusinessType
()
+
"_"
+
dto
.
getBrandId
()
+
"_"
+
dto
.
getChildBrandId
()));
}
/**
* 检查员工是否处于新人保护期
*
* @param staffPhone 员工手机号
* @param performanceMonth 绩效月份 (yyyy-MM)
* @return true - 处于保护期
*/
private
boolean
checkNewcomerProtection
(
String
staffPhone
,
String
performanceMonth
)
{
RpcAssert
.
assertNotEmpty
(
staffPhone
,
DefaultErrorEnum
.
DATA_NULL
,
"员工手机号不能为空"
);
RpcAssert
.
assertNotEmpty
(
performanceMonth
,
DefaultErrorEnum
.
DATA_NULL
,
"绩效月份不能为空"
);
if
(!
performanceMonth
.
matches
(
"^\\d{4}-\\d{2}$"
))
{
log
.
error
(
"绩效月份格式错误: staffPhone={}, performanceMonth={}"
,
staffPhone
,
performanceMonth
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"绩效月份格式错误"
);
}
log
.
info
(
"检查员工{}在{}是否处于新人保护期"
,
staffPhone
,
performanceMonth
);
// 查询员工入职信息
StaffBeisenBaseInfo
staffInfo
=
staffBeisenBaseInfoService
.
getByStaffPhone
(
staffPhone
);
if
(
staffInfo
==
null
||
StringUtils
.
isBlank
(
staffInfo
.
getEntryDate
()))
{
log
.
warn
(
"员工入职信息不存在或入职日期为空: staffPhone={}"
,
staffPhone
);
return
false
;
}
if
(!
staffInfo
.
getEntryDate
().
matches
(
"^\\d{4}-\\d{2}-\\d{2}$"
))
{
log
.
warn
(
"员工入职日期格式错误: staffPhone={}, entryDate={}"
,
staffPhone
,
staffInfo
.
getEntryDate
());
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"员工入职日期格式错误,entryDate="
+
staffInfo
.
getEntryDate
());
}
try
{
// 判断逻辑: 入职日期 <= 绩效月份上个月的15号 -> 不在保护期 (false)
// 否则 -> 处于保护期 (true)
LocalDate
entryDate
=
LocalDate
.
parse
(
staffInfo
.
getEntryDate
());
LocalDate
month15th
=
YearMonth
.
parse
(
performanceMonth
).
minusMonths
(
1
).
atDay
(
15
);
return
entryDate
.
isAfter
(
month15th
);
}
catch
(
Exception
e
)
{
log
.
error
(
"解析日期出错: staffPhone={}, e={}"
,
staffPhone
,
e
.
getMessage
());
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATA_INVALID
,
"解析日期出错,entryDate="
+
staffInfo
.
getEntryDate
());
}
}
/**
* 构建 StaffPerformance 对象
*/
private
StaffPerformance
buildStaffPerformance
(
List
<
StaffPerformanceDetailDTO
>
groupList
,
StaffPerformanceCalContextDTO
context
,
boolean
isNewcomerProtection
,
Date
now
)
{
StaffPerformanceDetailDTO
first
=
groupList
.
get
(
0
);
StaffPerformance
staffPerformance
=
new
StaffPerformance
();
// 基础信息赋值
staffPerformance
.
setStaffName
(
first
.
getStaffName
());
staffPerformance
.
setStaffPhone
(
first
.
getStaffPhone
());
staffPerformance
.
setMerchantId
(
first
.
getMerchantId
());
staffPerformance
.
setMerchantName
(
first
.
getMerchantName
());
staffPerformance
.
setBusinessType
(
first
.
getBusinessType
());
staffPerformance
.
setBrandId
(
first
.
getBrandId
());
staffPerformance
.
setBrandName
(
first
.
getBrandName
());
staffPerformance
.
setChildBrandId
(
first
.
getChildBrandId
());
staffPerformance
.
setChildBrandName
(
first
.
getChildBrandName
());
staffPerformance
.
setMonth
(
first
.
getMonth
());
staffPerformance
.
setCreatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
staffPerformance
.
setUpdatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
staffPerformance
.
setCreatedDate
(
now
);
staffPerformance
.
setUpdatedDate
(
now
);
staffPerformance
.
setDeletedFlag
(
DeletedFlagEnum
.
N
.
name
());
// 填充触达数、有效引荐数
if
(
context
.
getAssessmentFactorDependencyData
()
!=
null
&&
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
!=
null
)
{
staffPerformance
.
setTouchNumber
(
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
.
getStorePersonalPreSalesTouchCount
());
staffPerformance
.
setEffectiveReferralQuantity
(
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
.
getStoreValidRecommendationCount
());
}
// 计算总提成金额
JSONObject
calculationResult
=
calculatePerformanceAmount
(
groupList
,
isNewcomerProtection
);
BigDecimal
finalAmount
=
calculationResult
.
getBigDecimal
(
"finalAmount"
);
staffPerformance
.
setPerformanceAmount
(
finalAmount
);
// 移除 finalAmount,保留其他详情存入 paramsJson
calculationResult
.
remove
(
"finalAmount"
);
staffPerformance
.
setParamsJson
(
calculationResult
.
toJSONString
());
return
staffPerformance
;
}
/**
* 计算绩效金额
*/
private
JSONObject
calculatePerformanceAmount
(
List
<
StaffPerformanceDetailDTO
>
groupList
,
boolean
isNewcomerProtection
)
{
BigDecimal
sumNonCoeff
=
BigDecimal
.
ZERO
;
BigDecimal
multiplyCoeff
=
BigDecimal
.
ONE
;
// 遍历详情计算
for
(
StaffPerformanceDetailDTO
detail
:
groupList
)
{
// 判断是否为系数类型 (假设 'XS' 为系数代码)
if
(
CommissionMethodEnum
.
XS
.
getCode
().
equals
(
detail
.
getCommissionType
()))
{
if
(
detail
.
getCommissionTypeValue
()
!=
null
)
{
multiplyCoeff
=
multiplyCoeff
.
multiply
(
detail
.
getCommissionTypeValue
());
}
}
else
{
// 非系数类型累加金额
if
(
detail
.
getPerformanceAmount
()
!=
null
)
{
sumNonCoeff
=
sumNonCoeff
.
add
(
detail
.
getPerformanceAmount
());
}
}
}
BigDecimal
finalMultiplyCoeff
=
multiplyCoeff
;
// 新人保护逻辑: 如果处于保护期且系数小于1,则强制设为1
if
(
isNewcomerProtection
)
{
if
(
multiplyCoeff
.
compareTo
(
BigDecimal
.
ONE
)
<
0
)
{
finalMultiplyCoeff
=
BigDecimal
.
ONE
;
}
}
// 最终金额 = 非系数总额 * 总系数
BigDecimal
finalAmount
=
sumNonCoeff
.
multiply
(
finalMultiplyCoeff
);
JSONObject
result
=
new
JSONObject
();
result
.
put
(
"sumNonCoeff"
,
sumNonCoeff
);
result
.
put
(
"multiplyCoeff"
,
multiplyCoeff
);
result
.
put
(
"isNewcomerProtection"
,
isNewcomerProtection
);
result
.
put
(
"finalMultiplyCoeff"
,
finalMultiplyCoeff
);
result
.
put
(
"finalAmount"
,
finalAmount
);
return
result
;
}
public
List
<
StaffPerformanceDTO
>
listStaffPerformance
(
StaffPerformanceDTO
dto
)
{
public
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
try
{
StaffPerformanceDTO
dto
)
{
try
{
return
staffPerformanceMapper
.
listStaffPerformance
(
dto
);
return
staffPerformanceMapper
.
listStaffPerformance
(
dto
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATABASE_ERROR
);
throw
new
cn
.
com
.
glsx
.
framework
.
core
.
exception
.
RpcServiceException
(
cn
.
com
.
glsx
.
framework
.
core
.
enums
.
DefaultErrorEnum
.
DATABASE_ERROR
);
}
}
}
}
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/StaffProductPerformanceService.java
0 → 100644
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
staffPerformance
;
import
cn.com.glsx.dj.smartcarlife.constant.CommonConstants
;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO
;
import
cn.com.glsx.dj.smartcarlife.remote.MerchantPerformanceProductDefineRemote
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceCalContextDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceDetailDTO
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
import
cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO
;
import
cn.com.glsx.dj.staff.mapper.StaffProductPerformanceMapper
;
import
cn.com.glsx.dj.staff.model.StaffProductPerformance
;
import
cn.com.glsx.dj.staff.service.staffPerformance.util.StaffPerformanceOrderUtil
;
import
cn.com.glsx.dj.staff.util.DataCalUtil
;
import
cn.com.glsx.framework.core.beans.BaseModel.DeletedFlagEnum
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.oreframework.boot.env.OrePropertyConfigurer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.math.BigDecimal
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
@Transactional
(
propagation
=
Propagation
.
SUPPORTS
,
rollbackFor
=
RpcServiceException
.
class
)
public
class
StaffProductPerformanceService
{
@Lazy
@Autowired
private
StaffProductPerformanceService
thiz
;
@Autowired
private
StaffProductPerformanceMapper
staffProductPerformanceMapper
;
@Autowired
private
MerchantPerformanceProductDefineRemote
merchantPerformanceProductDefineRemote
;
public
List
<
StaffProductPerformanceDTO
>
listStaffPerformance
(
StaffProductPerformanceDTO
dto
)
{
try
{
return
staffProductPerformanceMapper
.
listStaffPerformance
(
dto
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
DATABASE_ERROR
);
}
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
rollbackFor
=
RpcServiceException
.
class
)
public
void
saveStaffProductPerformance
(
StaffPerformanceCalContextDTO
context
,
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
)
{
// 1. 参数有效性校验
if
(
context
==
null
||
CollectionUtils
.
isEmpty
(
performanceDetailDTOS
))
{
log
.
error
(
"saveStaffProductPerformance param error 1"
);
return
;
}
if
(
context
.
getMerchantId
()
==
null
||
context
.
getBusinessType
()
==
null
||
context
.
getBrandId
()
==
null
||
context
.
getChildBrandId
()
==
null
||
context
.
getPerformanceMonth
()
==
null
||
context
.
getStaffPhone
()
==
null
)
{
log
.
error
(
"saveStaffProductPerformance param error 2"
);
return
;
}
// 2. 构建StaffProductPerformance列表
List
<
StaffProductPerformance
>
insertList
=
buildStaffProductPerformances
(
context
,
performanceDetailDTOS
);
// 3. 逻辑删除之前的数据
staffProductPerformanceMapper
.
removeStaffProductPerformance
(
context
.
getMerchantId
(),
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getChildBrandId
(),
context
.
getPerformanceMonth
(),
context
.
getStaffPhone
(),
CommonConstants
.
DEFAULT_UPDATE_BY
);
// 4.入库
if
(
CollectionUtils
.
isNotEmpty
(
insertList
))
{
staffProductPerformanceMapper
.
insertList
(
insertList
);
}
}
private
List
<
StaffProductPerformance
>
buildStaffProductPerformances
(
StaffPerformanceCalContextDTO
context
,
List
<
StaffPerformanceDetailDTO
>
performanceDetailDTOS
)
{
Map
<
String
,
List
<
StaffPerformanceDetailDTO
>>
groupedMap
=
performanceDetailDTOS
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
this
::
generateGroupKey
));
List
<
StaffProductPerformance
>
insertList
=
new
ArrayList
<>();
Date
now
=
new
Date
();
for
(
List
<
StaffPerformanceDetailDTO
>
dtoList
:
groupedMap
.
values
())
{
if
(
CollectionUtils
.
isEmpty
(
dtoList
))
continue
;
// 2.1 初始化StaffProductPerformance
StaffPerformanceDetailDTO
first
=
dtoList
.
get
(
0
);
StaffProductPerformance
productPerformance
=
buildStaffProductPerformance
(
first
,
now
);
// 2.2 累计得到提成金额
BigDecimal
totalAmount
=
dtoList
.
stream
()
.
filter
(
d
->
!
"XS"
.
equals
(
d
.
getCommissionType
()))
.
map
(
d
->
Optional
.
ofNullable
(
d
.
getPerformanceAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
productPerformance
.
setPerformanceAmount
(
totalAmount
);
// 2.3 根据context,计算当前品类的升级订单数、个人渗透率
// 这里需要根据品类信息重新过滤Context中的订单
calculateAndFillMetrics
(
productPerformance
,
first
,
context
);
insertList
.
add
(
productPerformance
);
}
return
insertList
;
}
private
static
StaffProductPerformance
buildStaffProductPerformance
(
StaffPerformanceDetailDTO
first
,
Date
now
)
{
StaffProductPerformance
productPerformance
=
new
StaffProductPerformance
();
productPerformance
.
setStaffName
(
first
.
getStaffName
());
productPerformance
.
setStaffPhone
(
first
.
getStaffPhone
());
productPerformance
.
setMerchantId
(
first
.
getMerchantId
());
productPerformance
.
setMerchantName
(
first
.
getMerchantName
());
productPerformance
.
setBusinessType
(
first
.
getBusinessType
());
productPerformance
.
setBrandId
(
first
.
getBrandId
());
productPerformance
.
setBrandName
(
first
.
getBrandName
());
productPerformance
.
setChildBrandId
(
first
.
getChildBrandId
());
productPerformance
.
setChildBrandName
(
first
.
getChildBrandName
());
productPerformance
.
setMonth
(
first
.
getMonth
());
productPerformance
.
setGoodsConfigType
(
first
.
getGoodsConfigType
());
productPerformance
.
setGoodsType
(
first
.
getGoodsType
());
productPerformance
.
setGoodsTypeName
(
first
.
getGoodsTypeName
());
productPerformance
.
setSecondaryGoodsType
(
first
.
getSecondaryGoodsType
());
productPerformance
.
setSecondaryGoodsTypeName
(
first
.
getSecondaryGoodsTypeName
());
productPerformance
.
setThirdLevelGoodsType
(
first
.
getThirdLevelGoodsType
());
productPerformance
.
setThirdLevelGoodsTypeName
(
first
.
getThirdLevelGoodsTypeName
());
productPerformance
.
setProductDefineId
(
first
.
getProductDefineId
());
productPerformance
.
setProductDefineName
(
first
.
getProductDefineName
());
productPerformance
.
setDeletedFlag
(
DeletedFlagEnum
.
N
.
name
());
productPerformance
.
setCreatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
productPerformance
.
setUpdatedBy
(
CommonConstants
.
DEFAULT_UPDATE_BY
);
productPerformance
.
setCreatedDate
(
now
);
productPerformance
.
setUpdatedDate
(
now
);
return
productPerformance
;
}
private
String
generateGroupKey
(
StaffPerformanceDetailDTO
dto
)
{
return
dto
.
getGoodsConfigType
()
+
"_"
+
dto
.
getGoodsType
()
+
"_"
+
dto
.
getSecondaryGoodsType
()
+
"_"
+
dto
.
getThirdLevelGoodsType
()
+
"_"
+
dto
.
getProductDefineId
();
}
private
void
calculateAndFillMetrics
(
StaffProductPerformance
productPerformance
,
StaffPerformanceDetailDTO
detailDTO
,
StaffPerformanceCalContextDTO
context
)
{
Byte
goodsConfigType
=
detailDTO
.
getGoodsConfigType
();
Integer
goodsType
=
detailDTO
.
getGoodsType
();
Integer
secondaryGoodsType
=
detailDTO
.
getSecondaryGoodsType
();
Integer
thirdLevelGoodsType
=
detailDTO
.
getThirdLevelGoodsType
();
Integer
productDefineId
=
detailDTO
.
getProductDefineId
();
MerchantPerformanceProductDefineDTO
productDefine
=
null
;
if
(
goodsConfigType
!=
null
&&
(
goodsConfigType
==
1
||
goodsConfigType
==
2
))
{
if
(
productDefineId
!=
null
)
{
productDefine
=
merchantPerformanceProductDefineRemote
.
getByIdWithRadicalUpgradeGoodsItem
(
productDefineId
).
getResult
();
}
}
String
groupKey
=
StaffPerformanceCalService
.
generateGroupOrderMapKey
(
context
.
getMerchantId
(),
context
.
getBusinessType
(),
context
.
getBrandId
(),
context
.
getChildBrandId
());
List
<
StaffPerformanceSubOrderDTO
>
orders
=
context
.
getGroupedOrdersMap
().
get
(
groupKey
);
if
(
CollectionUtils
.
isEmpty
(
orders
))
{
productPerformance
.
setUpgradeOrderNum
(
0
);
productPerformance
.
setPersonalPenetrationRate
(
BigDecimal
.
ZERO
);
productPerformance
.
setGmvOutput
(
BigDecimal
.
ZERO
);
return
;
}
// 过滤订单
final
MerchantPerformanceProductDefineDTO
finalProductDefine
=
productDefine
;
final
List
<
Byte
>
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
=
Arrays
.
stream
(
OrePropertyConfigurer
.
getString
(
"valid.dj.order.type.for.commission.basic"
,
"1,5"
).
split
(
","
))
.
map
(
Byte:
:
parseByte
).
collect
(
Collectors
.
toList
());
long
upgradeOrderNum
=
0
;
BigDecimal
gmvOutput
=
BigDecimal
.
ZERO
;
if
(
goodsConfigType
!=
null
&&
goodsConfigType
==
2
)
{
// 套餐逻辑
if
(
finalProductDefine
!=
null
&&
CollectionUtils
.
isNotEmpty
(
finalProductDefine
.
getPackageItemList
()))
{
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrders
=
orders
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
));
// 计算产值 (所有匹配的子订单)
gmvOutput
=
groupedOrders
.
values
().
stream
()
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.
contains
(
o
.
get
(
0
).
getDjOrderType
()))
.
flatMap
(
o
->
StaffPerformanceOrderUtil
.
matchPackageSubOrders
(
o
,
finalProductDefine
.
getPackageItemList
()).
stream
())
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
// 计算升级订单数 (满足 commission basic 类型的)
upgradeOrderNum
=
groupedOrders
.
values
().
stream
()
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.
contains
(
o
.
get
(
0
).
getDjOrderType
())
&&
StaffPerformanceOrderUtil
.
isOrderMatchPackage
(
o
,
finalProductDefine
.
getPackageItemList
()))
.
count
();
}
}
else
{
// 单品逻辑
List
<
StaffPerformanceSubOrderDTO
>
matchedOrders
=
orders
.
stream
()
.
filter
(
o
->
VALID_DJ_ORDER_TYPE_FOR_COMMISSION_BASIC
.
contains
(
o
.
getDjOrderType
())
&&
StaffPerformanceOrderUtil
.
isOrderMatchCategory
(
o
,
goodsConfigType
,
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
finalProductDefine
))
.
collect
(
Collectors
.
toList
());
gmvOutput
=
matchedOrders
.
stream
()
.
map
(
o
->
Optional
.
ofNullable
(
o
.
getOutputAmount
()).
orElse
(
BigDecimal
.
ZERO
))
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
upgradeOrderNum
=
matchedOrders
.
size
();
}
productPerformance
.
setUpgradeOrderNum
((
int
)
upgradeOrderNum
);
productPerformance
.
setGmvOutput
(
gmvOutput
);
// 计算个人渗透率
// 个人渗透率 = 升级订单数 / 个人应触客数
BigDecimal
personalTargetTouchCount
=
context
.
getAssessmentFactorDependencyData
().
getDailyData
()
.
getPersonalTargetTouchCount
();
BigDecimal
targetTouch
=
Optional
.
ofNullable
(
personalTargetTouchCount
).
orElse
(
BigDecimal
.
ZERO
);
BigDecimal
penetrationRate
=
DataCalUtil
.
divideToPercent
(
new
BigDecimal
(
upgradeOrderNum
),
targetTouch
);
productPerformance
.
setPersonalPenetrationRate
(
penetrationRate
);
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/service/staffPerformance/util/StaffPerformanceOrderUtil.java
0 → 100644
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
service
.
staffPerformance
.
util
;
import
cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO
;
import
cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem
;
import
cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO
;
import
cn.com.glsx.dj.staff.enums.ProductConfigTypeEnum
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.util.RpcAssert
;
import
org.apache.commons.collections.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
/**
* 员工绩效订单匹配工具类
* 提供订单与配置的匹配逻辑
*/
public
class
StaffPerformanceOrderUtil
{
/**
* 判断订单列表是否匹配组合套餐
*
* @param o 订单列表(通常指同一主订单下的子订单列表)
* @param packageItemList 套餐包含的商品组列表(每个商品组内必须至少命中一个)
* @return 是否匹配
*/
public
static
boolean
isOrderMatchPackage
(
List
<
StaffPerformanceSubOrderDTO
>
o
,
List
<
List
<
MerchantPerformanceProductDefineItem
>>
packageItemList
)
{
if
(
CollectionUtils
.
isEmpty
(
o
)
||
CollectionUtils
.
isEmpty
(
packageItemList
))
{
return
false
;
}
List
<
Integer
>
upgradeGoodsIds
=
o
.
stream
().
map
(
StaffPerformanceSubOrderDTO:
:
getUpgradeGoodsId
)
.
filter
(
Objects:
:
nonNull
).
collect
(
Collectors
.
toList
());
// 匹配逻辑:packageItemList 定义了多个必选商品组。
// 订单必须包含每一个商品组中的至少一个商品,才被视为匹配该组合套餐。
boolean
isMatch
=
true
;
if
(
packageItemList
.
stream
().
anyMatch
(
packageItem
->
{
List
<
Integer
>
itemIds
=
packageItem
.
stream
()
.
map
(
MerchantPerformanceProductDefineItem:
:
getItemId
)
.
collect
(
Collectors
.
toList
());
return
!
CollectionUtils
.
containsAny
(
upgradeGoodsIds
,
itemIds
);
}))
{
isMatch
=
false
;
}
return
isMatch
;
}
/**
* 筛选出匹配套餐的子订单
*
* @param o 订单列表
* @param packageItemList 套餐包含的商品组列表
* @return 匹配的子订单列表
*/
public
static
List
<
StaffPerformanceSubOrderDTO
>
matchPackageSubOrders
(
List
<
StaffPerformanceSubOrderDTO
>
o
,
List
<
List
<
MerchantPerformanceProductDefineItem
>>
packageItemList
)
{
if
(
CollectionUtils
.
isEmpty
(
o
)
||
CollectionUtils
.
isEmpty
(
packageItemList
))
{
return
new
ArrayList
<>();
}
List
<
Integer
>
upgradeGoodsIds
=
packageItemList
.
stream
().
flatMap
(
List:
:
stream
)
.
map
(
MerchantPerformanceProductDefineItem:
:
getItemId
)
.
collect
(
Collectors
.
toList
());
if
(!
isOrderMatchPackage
(
o
,
packageItemList
))
{
return
new
ArrayList
<>();
}
return
o
.
stream
().
filter
(
p
->
upgradeGoodsIds
.
contains
(
p
.
getUpgradeGoodsId
()))
.
collect
(
Collectors
.
toList
());
}
/**
* 统计匹配条件的订单数量
*
* @param orders 订单列表
* @param goodsConfigType 商品配置类型
* @param goodsType 商品类型
* @param secondaryGoodsType 二级商品类型
* @param thirdLevelGoodsType 三级商品类型
* @param productDefine 圈定商品定义(含套餐)
* @return 匹配数量
*/
public
static
long
countMatchingOrders
(
List
<
StaffPerformanceSubOrderDTO
>
orders
,
Integer
goodsConfigType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
MerchantPerformanceProductDefineDTO
productDefine
)
{
if
(
CollectionUtils
.
isEmpty
(
orders
)
||
goodsConfigType
==
null
)
{
return
0
;
}
if
(
goodsConfigType
==
2
)
{
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
"conditionProductDefine be null"
);
RpcAssert
.
assertNotEmpty
(
productDefine
.
getPackageItemList
(),
DefaultErrorEnum
.
DATA_NULL
,
"conditionProductDefine.getPackageItemList() is empty"
);
Map
<
String
,
List
<
StaffPerformanceSubOrderDTO
>>
groupedOrders
=
orders
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
StaffPerformanceSubOrderDTO:
:
getOrderCode
));
return
groupedOrders
.
values
().
stream
()
.
filter
(
o
->
isOrderMatchPackage
(
o
,
productDefine
.
getPackageItemList
()))
.
count
();
}
else
{
return
orders
.
stream
()
.
filter
(
o
->
isOrderMatchCategory
(
o
,
goodsConfigType
.
byteValue
(),
goodsType
,
secondaryGoodsType
,
thirdLevelGoodsType
,
productDefine
))
.
count
();
}
}
/**
* 判断单个订单是否匹配各类条件
*
* @param order 订单
* @param goodsConfigType 商品配置类型
* @param goodsType 商品类型
* @param secondaryGoodsType 二级商品类型
* @param thirdLevelGoodsType 三级商品类型
* @param productDefine 圈定商品定义
* @return 是否匹配
*/
public
static
boolean
isOrderMatchCategory
(
StaffPerformanceSubOrderDTO
order
,
Byte
goodsConfigType
,
Integer
goodsType
,
Integer
secondaryGoodsType
,
Integer
thirdLevelGoodsType
,
MerchantPerformanceProductDefineDTO
productDefine
)
{
RpcAssert
.
assertNotNull
(
goodsConfigType
,
DefaultErrorEnum
.
DATA_NULL
,
"goodsConfigType不能为空"
);
// TODO 改用枚举
// -1:全部商品
if
(
Objects
.
equals
(
ProductConfigTypeEnum
.
ALL_PRODUCT
.
getCode
(),
goodsConfigType
))
{
return
true
;
}
// 0:商品分类
if
(
Objects
.
equals
(
ProductConfigTypeEnum
.
PRODUCT_CATEGORY
.
getCode
(),
goodsConfigType
))
{
boolean
match
=
true
;
if
(
goodsType
!=
null
)
{
match
=
match
&&
Objects
.
equals
(
goodsType
,
order
.
getGoodsType
());
}
if
(
secondaryGoodsType
!=
null
)
{
match
=
match
&&
Objects
.
equals
(
secondaryGoodsType
,
order
.
getSecondaryGoodsType
());
}
if
(
thirdLevelGoodsType
!=
null
)
{
match
=
match
&&
Objects
.
equals
(
thirdLevelGoodsType
,
order
.
getThirdLevelGoodsType
());
}
return
match
;
}
// 1:圈定产品
if
(
Objects
.
equals
(
ProductConfigTypeEnum
.
DESIGNATED_PRODUCT
.
getCode
(),
goodsConfigType
))
{
RpcAssert
.
assertNotNull
(
productDefine
,
DefaultErrorEnum
.
DATA_NULL
,
"productDefine不能为空"
);
return
productDefine
.
getItemList
().
stream
()
.
anyMatch
(
item
->
Objects
.
equals
(
item
.
getItemId
(),
order
.
getUpgradeGoodsId
()));
}
return
false
;
}
}
rpc-dj-staff/src/main/java/cn/com/glsx/dj/staff/util/DataCalUtil.java
0 → 100644
View file @
aef7c28
package
cn
.
com
.
glsx
.
dj
.
staff
.
util
;
import
cn.com.glsx.dj.staff.constant.CommonConstants
;
import
java.math.BigDecimal
;
public
class
DataCalUtil
{
public
static
BigDecimal
divideToPercent
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
null
;
}
return
dividend
.
divide
(
divisor
,
4
,
BigDecimal
.
ROUND_HALF_UP
)
.
multiply
(
CommonConstants
.
ONEHUNDRED_BIGDECIMAL
).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
);
}
public
static
BigDecimal
divide
(
BigDecimal
dividend
,
BigDecimal
divisor
)
{
if
(
divisor
.
compareTo
(
BigDecimal
.
ZERO
)
==
0
)
{
return
BigDecimal
.
ZERO
;
}
return
dividend
.
divide
(
divisor
,
4
,
BigDecimal
.
ROUND_HALF_UP
);
}
}
rpc-dj-staff/src/main/resources/META-INF/orm/EffectiveReferralReviewMapper.xml
View file @
aef7c28
...
@@ -47,26 +47,17 @@
...
@@ -47,26 +47,17 @@
manager_commit_time, reviewed_by, reviewed_name, reviewed_time,
manager_commit_time, reviewed_by, reviewed_name, reviewed_time,
created_by, created_date, updated_by, updated_date, deleted_flag
created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
</sql>
<select
id=
"select
OneByQuery
"
resultMap=
"DTOResultMap"
>
<select
id=
"select
EffectiveReferralReview
"
resultMap=
"DTOResultMap"
>
SELECT
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
FROM
FROM
sal_effective_referral_review
sal_effective_referral_review
<where>
WHERE
deleted_flag = 'N'
deleted_flag = 'N'
<if
test=
"merchantId != null"
>
AND merchant_id = #{merchantId}
AND merchant_id = #{merchantId}
</if>
<if
test=
"sceneType != null"
>
AND scene_type = #{sceneType}
AND scene_type = #{sceneType}
</if>
<if
test=
"brandId != null"
>
AND brand_id = #{brandId}
AND brand_id = #{brandId}
</if>
AND review_month = #{reviewMonth}
<if
test=
"reviewMonth != null"
>
and review_month = #{reviewMonth}
</if>
</where>
LIMIT
LIMIT
1
1
</select>
</select>
...
@@ -77,30 +68,42 @@
...
@@ -77,30 +68,42 @@
MIN(dclsm.merchant_name) AS merchant_name,
MIN(dclsm.merchant_name) AS merchant_name,
serr.review_month,
serr.review_month,
CASE
CASE
WHEN MAX(CASE WHEN serr.status IN (0, 1) THEN 1 ELSE 0 END) = 1
WHEN MAX(
THEN 0
CASE
WHEN serr.status IN (0, 1) THEN 1
ELSE 0
END
) = 1 THEN 0
ELSE 1
ELSE 1
END AS submit_status
END AS submit_status
FROM sal_effective_referral_review serr
FROM
sal_effective_referral_review serr
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
and serr.merchant_id in
serr.deleted_flag = 'N'
AND serr.merchant_id IN
<foreach
collection=
"merchantIds"
item=
"item"
open=
"("
separator=
","
close=
")"
>
<foreach
collection=
"merchantIds"
item=
"item"
open=
"("
separator=
","
close=
")"
>
#{item}
#{item}
</foreach>
</foreach>
<if
test=
"merchantName != null and merchantName != ''"
>
<if
test=
"merchantName != null and merchantName != ''"
>
AND dclsm.merchant_name LIKE CONCAT('%', #{merchantName}, '%')
AND dclsm.merchant_name LIKE CONCAT('%', #{merchantName},
'%')
</if>
</if>
<if
test=
"createdDate != null and createdDate != ''"
>
<if
test=
"createdDate != null and createdDate != ''"
>
AND DATE_FORMAT(serr.created_date, '%Y-%m') = #{createdDate}
AND DATE_FORMAT(serr.created_date, '%Y-%m') = #{createdDate}
</if>
</if>
GROUP BY serr.merchant_id
GROUP BY
serr.merchant_id
<if
test=
"submitStatus != null"
>
<if
test=
"submitStatus != null"
>
HAVING
HAVING
CASE
CASE
WHEN MAX(CASE WHEN serr.status IN (0, 1) THEN 1 ELSE 0 END) = 1
WHEN MAX(
THEN 0
CASE
WHEN serr.status IN (0, 1) THEN 1
ELSE 0
END
) = 1 THEN 0
ELSE 1
ELSE 1
END = #{submitStatus}
END = #{submitStatus}
</if>
</if>
...
@@ -112,10 +115,12 @@
...
@@ -112,10 +115,12 @@
SELECT
SELECT
serr.*,
serr.*,
dclsm.merchant_name
dclsm.merchant_name
FROM sal_effective_referral_review serr
FROM
sal_effective_referral_review serr
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'
AND serr.merchant_id = #{merchantId}
AND serr.merchant_id = #{merchantId}
</select>
</select>
...
...
rpc-dj-staff/src/main/resources/META-INF/orm/PerformanceConfigMapper.xml
View file @
aef7c28
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<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_name"
property=
"merchantName"
jdbcType=
"VARCHAR"
/>
</resultMap>
</resultMap>
<resultMap
id=
"MerchantPerformanceResultMap"
<resultMap
id=
"MerchantPerformanceResultMap"
...
@@ -40,17 +40,17 @@
...
@@ -40,17 +40,17 @@
</sql>
</sql>
<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
SELECT c.*,
c.*
dclsm.merchant_name
FROM
FROM dj_car_life_performance_config c
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 AND r.deleted_flag = 'N'
LEFT JOIN dj_car_life_service_merchant dclsm ON dclsm.merchant_id = r.merchant_id
WHERE
AND dclsm.deleted_flag = 'N'
c.deleted_flag = 'N'
WHERE
c.deleted_flag = 'N'
AND c.status = 2
AND c.status = 2
AND C.business_type = #{businessType}
AND c.enable_flag = 'Y'
AND c.enable_flag = 'Y'
AND c.effective_month = #{performanceMonth}
AND c.business_type = #{businessType}
AND c.effective_month = #{effectiveMonth}
AND r.merchant_id = #{merchantId}
AND r.merchant_id = #{merchantId}
AND r.brand_id = #{brandId}
AND r.brand_id = #{brandId}
AND r.child_id = #{childBrandId}
AND r.child_id = #{childBrandId}
...
@@ -66,22 +66,22 @@
...
@@ -66,22 +66,22 @@
c.deleted_flag = 'N'
c.deleted_flag = 'N'
AND c.status = 2
AND c.status = 2
AND r.scheme_name = #{schemeName}
AND r.scheme_name = #{schemeName}
LIMIT 1
LIMIT
1
</select>
</select>
<select
id=
"listPerformanceConfig"
parameterType=
"cn.com.glsx.dj.staff.dto.performance.PerformanceConfigPageDTO"
resultType=
"cn.com.glsx.dj.staff.dto.performance.PerformanceConfigPageDTO"
>
<select
id=
"listPerformanceConfig"
parameterType=
"cn.com.glsx.dj.staff.dto.performance.PerformanceConfigPageDTO"
resultType=
"cn.com.glsx.dj.staff.dto.performance.PerformanceConfigPageDTO"
>
SELECT
SELECT
c.id,
c.id,
c.scheme_name as
schemeName,
c.scheme_name AS
schemeName,
c.business_type as
businessType,
c.business_type AS
businessType,
c.status,
c.status,
c.effective_month as
effectiveMonth,
c.effective_month AS
effectiveMonth,
c.updated_date as
updatedDate,
c.updated_date AS
updatedDate,
IFNULL(COUNT(DISTINCT r.merchant_id), 0) as
applicationQuantity
IFNULL(COUNT(DISTINCT r.merchant_id), 0) AS
applicationQuantity
FROM
FROM
dj_car_life_performance_config c
dj_car_life_performance_config c
LEFT JOIN dj_car_life_performance_config_merchant_brand_ref r
LEFT JOIN dj_car_life_performance_config_merchant_brand_ref r ON c.id = r.performance_config_id
ON c.id = r.performance_config_id
AND r.deleted_flag = 'N'
AND r.deleted_flag = 'N'
WHERE
WHERE
c.deleted_flag = 'N'
c.deleted_flag = 'N'
...
@@ -94,7 +94,6 @@
...
@@ -94,7 +94,6 @@
c.updated_date
c.updated_date
ORDER BY
ORDER BY
c.updated_date DESC
c.updated_date DESC
</select>
</select>
<!-- 根据ID查询提成方案配置(未删除) -->
<!-- 根据ID查询提成方案配置(未删除) -->
...
@@ -108,7 +107,8 @@
...
@@ -108,7 +107,8 @@
WHERE
WHERE
c.deleted_flag = 'N'
c.deleted_flag = 'N'
AND c.id = #{id}
AND c.id = #{id}
LIMIT 1
LIMIT
1
</select>
</select>
<select
id=
"listByMerchant"
<select
id=
"listByMerchant"
...
...
rpc-dj-staff/src/main/resources/META-INF/orm/PerformanceParamConfigConditionMapper.xml
View file @
aef7c28
...
@@ -30,16 +30,6 @@
...
@@ -30,16 +30,6 @@
<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.PerformanceParamConfigConditionDTO"
extends=
"BaseResultMap"
>
<resultMap
id =
"DTOResultMap"
type =
"cn.com.glsx.dj.staff.dto.PerformanceParamConfigConditionDTO"
extends=
"BaseResultMap"
>
<association
property=
"productDefine"
javaType=
"cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO"
>
<id
column=
"product_define_id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"define_type"
property=
"defineType"
jdbcType=
"TINYINT"
/>
<result
column=
"define_name"
property=
"defineName"
jdbcType=
"VARCHAR"
/>
<!-- <collection property="itemList" ofType="cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineItemDTO">-->
<!-- <id column="product_define_item_id" property="id" jdbcType="INTEGER" />-->
<!-- <result column="item_id" property="itemId" jdbcType="INTEGER" />-->
<!-- <result column="item_name" property="itemName" jdbcType="VARCHAR" />-->
<!-- </collection>-->
</association>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
<!--
<!--
...
...
rpc-dj-staff/src/main/resources/META-INF/orm/PerformanceParamConfigMapper.xml
View file @
aef7c28
...
@@ -30,16 +30,6 @@
...
@@ -30,16 +30,6 @@
<result
column=
"deleted_flag"
property=
"deletedFlag"
jdbcType=
"CHAR"
/>
<result
column=
"deleted_flag"
property=
"deletedFlag"
jdbcType=
"CHAR"
/>
</resultMap>
</resultMap>
<resultMap
id=
"ListByConfigIdResultMap"
type=
"cn.com.glsx.dj.staff.dto.PerformanceParamConfigDTO"
extends=
"BaseResultMap"
>
<resultMap
id=
"ListByConfigIdResultMap"
type=
"cn.com.glsx.dj.staff.dto.PerformanceParamConfigDTO"
extends=
"BaseResultMap"
>
<association
property=
"productDefine"
javaType=
"cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.MerchantPerformanceProductDefineDTO"
>
<id
column=
"product_define_id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"define_type"
property=
"defineType"
jdbcType=
"TINYINT"
/>
<result
column=
"define_name"
property=
"defineName"
jdbcType=
"VARCHAR"
/>
<collection
property=
"itemList"
ofType=
"cn.com.glsx.dj.smartcarlife.model.MerchantPerformanceProductDefineItem"
>
<id
column=
"product_define_item_id"
property=
"id"
jdbcType=
"INTEGER"
/>
<result
column=
"item_id"
property=
"itemId"
jdbcType=
"INTEGER"
/>
<result
column=
"item_name"
property=
"itemName"
jdbcType=
"VARCHAR"
/>
</collection>
</association>
<collection
property=
"performanceParamConfigConditions"
column=
"id"
<collection
property=
"performanceParamConfigConditions"
column=
"id"
select=
"cn.com.glsx.dj.staff.mapper.PerformanceParamConfigConditionMapper.listByParamConfigId"
/>
select=
"cn.com.glsx.dj.staff.mapper.PerformanceParamConfigConditionMapper.listByParamConfigId"
/>
</resultMap>
</resultMap>
...
...
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceBaseMapper.xml
deleted
100644 → 0
View file @
9dcc24b
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper
namespace=
"cn.com.glsx.dj.staff.mapper.StaffPerformanceBaseMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.dj.staff.model.StaffPerformanceBase"
>
<!--
WARNING - @mbg.generated
-->
<id
column=
"id"
property=
"id"
jdbcType=
"BIGINT"
/>
<result
column=
"staff_name"
property=
"staffName"
jdbcType=
"VARCHAR"
/>
<result
column=
"staff_phone"
property=
"staffPhone"
jdbcType=
"VARCHAR"
/>
<result
column=
"merchant_id"
property=
"merchantId"
jdbcType=
"INTEGER"
/>
<result
column=
"merchant_name"
property=
"merchantName"
jdbcType=
"VARCHAR"
/>
<result
column=
"business_type"
property=
"businessType"
jdbcType=
"TINYINT"
/>
<result
column=
"brand_id"
property=
"brandId"
jdbcType=
"INTEGER"
/>
<result
column=
"brand_name"
property=
"brandName"
jdbcType=
"VARCHAR"
/>
<result
column=
"child_brand_id"
property=
"childBrandId"
jdbcType=
"INTEGER"
/>
<result
column=
"child_brand_name"
property=
"childBrandName"
jdbcType=
"VARCHAR"
/>
<result
column=
"month"
property=
"month"
jdbcType=
"VARCHAR"
/>
<result
column=
"effective_referral_quantity"
property=
"effectiveReferralQuantity"
jdbcType=
"INTEGER"
/>
<result
column=
"touch_number"
property=
"touchNumber"
jdbcType=
"INTEGER"
/>
<result
column=
"created_by"
property=
"createdBy"
jdbcType=
"VARCHAR"
/>
<result
column=
"created_date"
property=
"createdDate"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"updated_by"
property=
"updatedBy"
jdbcType=
"VARCHAR"
/>
<result
column=
"updated_date"
property=
"updatedDate"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"deleted_flag"
property=
"deletedFlag"
jdbcType=
"CHAR"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
-->
id, staff_name, staff_phone, merchant_id, merchant_name, business_type, brand_id,
brand_name, child_brand_id, child_brand_name, month, effective_referral_quantity,
touch_number, created_by, created_date, updated_by, updated_date, deleted_flag
</sql>
</mapper>
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceCalMapper.xml
View file @
aef7c28
...
@@ -3,15 +3,11 @@
...
@@ -3,15 +3,11 @@
<mapper
namespace=
"cn.com.glsx.dj.staff.mapper.StaffPerformanceCalMapper"
>
<mapper
namespace=
"cn.com.glsx.dj.staff.mapper.StaffPerformanceCalMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO"
>
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.dj.staff.dto.StaffPerformanceSubOrderDTO"
>
<!--
TODO: 用户自行补充 ResultMap 映射
例如:
<result column="order_no" property="orderNo" jdbcType="VARCHAR"/>
-->
<result
column=
"order_code"
property=
"orderCode"
jdbcType=
"VARCHAR"
/>
<result
column=
"order_code"
property=
"orderCode"
jdbcType=
"VARCHAR"
/>
<result
column=
"sub_order_code"
property=
"subOrderCode"
jdbcType=
"VARCHAR"
/>
<result
column=
"sub_order_code"
property=
"subOrderCode"
jdbcType=
"VARCHAR"
/>
<result
column=
"merchant_id"
property=
"merchantId"
jdbcType=
"INTEGER"
/>
<result
column=
"merchant_id"
property=
"merchantId"
jdbcType=
"INTEGER"
/>
<result
column=
"phone_number"
property=
"staffPhone"
jdbcType=
"VARCHAR"
/>
<result
column=
"phone_number"
property=
"staffPhone"
jdbcType=
"VARCHAR"
/>
<result
column=
"staff_name"
property=
"staffName"
jdbcType=
"VARCHAR"
/>
<result
column=
"business_type"
property=
"businessType"
jdbcType=
"TINYINT"
/>
<result
column=
"business_type"
property=
"businessType"
jdbcType=
"TINYINT"
/>
<result
column=
"dj_order_type"
property=
"djOrderType"
jdbcType=
"TINYINT"
/>
<result
column=
"dj_order_type"
property=
"djOrderType"
jdbcType=
"TINYINT"
/>
<result
column=
"car_brand_id"
property=
"brandId"
jdbcType=
"INTEGER"
/>
<result
column=
"car_brand_id"
property=
"brandId"
jdbcType=
"INTEGER"
/>
...
@@ -30,6 +26,7 @@
...
@@ -30,6 +26,7 @@
dclgso.sub_order_code,
dclgso.sub_order_code,
dclgo.merchant_id,
dclgo.merchant_id,
dclsi.phone_number,
dclsi.phone_number,
dclsi.staff_name,
if(dclgo.scene_type = 1, 0, dclgo.business_type) business_type,
if(dclgo.scene_type = 1, 0, dclgo.business_type) business_type,
dclgo.dj_order_type,
dclgo.dj_order_type,
dclgoc.car_brand_id,
dclgoc.car_brand_id,
...
@@ -94,8 +91,10 @@
...
@@ -94,8 +91,10 @@
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
>
= concat( #{month}, '-01')
AND dclsdrh.report_date
>
= concat( #{month},
AND dclsdrh.report_date
<
DATE_ADD(concat( #{month}, '-01'), INTERVAL 1 MONTH)
'-01')
AND dclsdrh.report_date
<
DATE_ADD(concat( #{month},
'-01'), INTERVAL 1 MONTH)
</if>
</if>
</where>
</where>
</select>
</select>
...
...
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceDetailMapper.xml
View file @
aef7c28
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
<result
column=
"child_brand_name"
property=
"childBrandName"
jdbcType=
"VARCHAR"
/>
<result
column=
"child_brand_name"
property=
"childBrandName"
jdbcType=
"VARCHAR"
/>
<result
column=
"month"
property=
"month"
jdbcType=
"VARCHAR"
/>
<result
column=
"month"
property=
"month"
jdbcType=
"VARCHAR"
/>
<result
column=
"performance_config_id"
property=
"performanceConfigId"
jdbcType=
"INTEGER"
/>
<result
column=
"performance_config_id"
property=
"performanceConfigId"
jdbcType=
"INTEGER"
/>
<result
column=
"assessment_factor"
property=
"assessmentFactor"
jdbcType=
"
VARCHAR
"
/>
<result
column=
"assessment_factor"
property=
"assessmentFactor"
jdbcType=
"
TINYINT
"
/>
<result
column=
"goods_config_type"
property=
"goodsConfigType"
jdbcType=
"TINYINT"
/>
<result
column=
"goods_config_type"
property=
"goodsConfigType"
jdbcType=
"TINYINT"
/>
<result
column=
"goods_type"
property=
"goodsType"
jdbcType=
"INTEGER"
/>
<result
column=
"goods_type"
property=
"goodsType"
jdbcType=
"INTEGER"
/>
<result
column=
"goods_type_name"
property=
"goodsTypeName"
jdbcType=
"VARCHAR"
/>
<result
column=
"goods_type_name"
property=
"goodsTypeName"
jdbcType=
"VARCHAR"
/>
...
@@ -64,4 +64,17 @@
...
@@ -64,4 +64,17 @@
-->
-->
params_json
params_json
</sql>
</sql>
<update
id=
"removePerformanceDetail"
parameterType=
"cn.com.glsx.dj.staff.model.StaffPerformanceDetail"
>
UPDATE dj_car_life_staff_performance_detail
SET
deleted_flag = 'D',
updated_by = #{updatedBy},
updated_date = now()
WHERE
merchant_id = #{merchantId,jdbcType=INTEGER}
AND business_type = #{businessType,jdbcType=TINYINT}
AND brand_id = #{brandId,jdbcType=INTEGER}
AND child_brand_id = #{childBrandId,jdbcType=INTEGER}
AND month = #{month,jdbcType=VARCHAR}
</update>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/resources/META-INF/orm/StaffPerformanceMapper.xml
View file @
aef7c28
...
@@ -16,18 +16,8 @@
...
@@ -16,18 +16,8 @@
<result
column=
"child_brand_id"
property=
"childBrandId"
jdbcType=
"INTEGER"
/>
<result
column=
"child_brand_id"
property=
"childBrandId"
jdbcType=
"INTEGER"
/>
<result
column=
"child_brand_name"
property=
"childBrandName"
jdbcType=
"VARCHAR"
/>
<result
column=
"child_brand_name"
property=
"childBrandName"
jdbcType=
"VARCHAR"
/>
<result
column=
"month"
property=
"month"
jdbcType=
"VARCHAR"
/>
<result
column=
"month"
property=
"month"
jdbcType=
"VARCHAR"
/>
<result
column=
"goods_config_type"
property=
"goodsConfigType"
jdbcType=
"TINYINT"
/>
<result
column=
"effective_referral_quantity"
property=
"effectiveReferralQuantity"
jdbcType=
"INTEGER"
/>
<result
column=
"goods_type"
property=
"goodsType"
jdbcType=
"INTEGER"
/>
<result
column=
"touch_number"
property=
"touchNumber"
jdbcType=
"INTEGER"
/>
<result
column=
"goods_type_name"
property=
"goodsTypeName"
jdbcType=
"VARCHAR"
/>
<result
column=
"secondary_goods_type"
property=
"secondaryGoodsType"
jdbcType=
"INTEGER"
/>
<result
column=
"secondary_goods_type_name"
property=
"secondaryGoodsTypeName"
jdbcType=
"VARCHAR"
/>
<result
column=
"third_level_goods_type"
property=
"thirdLevelGoodsType"
jdbcType=
"INTEGER"
/>
<result
column=
"third_level_goods_type_name"
property=
"thirdLevelGoodsTypeName"
jdbcType=
"VARCHAR"
/>
<result
column=
"product_define_id"
property=
"productDefineId"
jdbcType=
"INTEGER"
/>
<result
column=
"product_define_name"
property=
"productDefineName"
jdbcType=
"VARCHAR"
/>
<result
column=
"gmv_output"
property=
"gmvOutput"
jdbcType=
"DECIMAL"
/>
<result
column=
"upgrade_order_num"
property=
"upgradeOrderNum"
jdbcType=
"INTEGER"
/>
<result
column=
"personal_penetration_rate"
property=
"personalPenetrationRate"
jdbcType=
"DECIMAL"
/>
<result
column=
"performance_amount"
property=
"performanceAmount"
jdbcType=
"DECIMAL"
/>
<result
column=
"performance_amount"
property=
"performanceAmount"
jdbcType=
"DECIMAL"
/>
<result
column=
"created_by"
property=
"createdBy"
jdbcType=
"VARCHAR"
/>
<result
column=
"created_by"
property=
"createdBy"
jdbcType=
"VARCHAR"
/>
<result
column=
"created_date"
property=
"createdDate"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"created_date"
property=
"createdDate"
jdbcType=
"TIMESTAMP"
/>
...
@@ -35,7 +25,13 @@
...
@@ -35,7 +25,13 @@
<result
column=
"updated_date"
property=
"updatedDate"
jdbcType=
"TIMESTAMP"
/>
<result
column=
"updated_date"
property=
"updatedDate"
jdbcType=
"TIMESTAMP"
/>
<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.StaffPerformanceDTO"
extends=
"BaseResultMap"
>
<resultMap
id=
"ResultMapWithBLOBs"
type=
"cn.com.glsx.dj.staff.model.StaffPerformanceDetail"
extends=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
-->
<result
column=
"params_json"
property=
"paramsJson"
jdbcType=
"LONGVARCHAR"
/>
</resultMap>
<resultMap
id=
"DTOResultMap"
type=
"cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO"
extends=
"BaseResultMap"
>
</resultMap>
</resultMap>
<sql
id=
"Base_Column_List"
>
<sql
id=
"Base_Column_List"
>
...
@@ -43,25 +39,44 @@
...
@@ -43,25 +39,44 @@
WARNING - @mbg.generated
WARNING - @mbg.generated
-->
-->
id, staff_name, staff_phone, merchant_id, merchant_name, business_type, brand_id,
id, staff_name, staff_phone, merchant_id, merchant_name, business_type, brand_id,
brand_name, child_brand_id, child_brand_name, month, goods_config_type, goods_type,
brand_name, child_brand_id, child_brand_name, month, effective_referral_quantity,
goods_type_name, secondary_goods_type, secondary_goods_type_name, third_level_goods_type,
touch_number, performance_amount, created_by, created_date, updated_by, updated_date, deleted_flag
third_level_goods_type_name, product_define_id, product_define_name, gmv_output,
</sql>
upgrade_order_num, personal_penetration_rate, performance_amount, created_by, created_date,
<sql
id=
"Blob_Column_List"
>
updated_by, updated_date, deleted_flag
<!--
WARNING - @mbg.generated
-->
params_json
</sql>
</sql>
<select
id=
"listStaffPerformance"
resultMap=
"DTOResultMap"
>
<select
id=
"listStaffPerformance"
resultMap=
"DTOResultMap"
>
select
SELECT
<include
refid=
"Base_Column_List"
/>
<include
refid=
"Base_Column_List"
/>
from dj_car_life_staff_performance dclsp
FROM
dj_car_life_staff_performance dclsp
<where>
<where>
dclsp.deleted_flag = 'N'
dclsp.deleted_flag = 'N'
<if
test=
"staffPhone != null"
>
<if
test=
"staffPhone != null"
>
and
dclsp.staff_phone = #{staffPhone}
AND
dclsp.staff_phone = #{staffPhone}
</if>
</if>
<if
test=
"month != null"
>
<if
test=
"month != null"
>
and
dclsp.month = #{month}
AND
dclsp.month = #{month}
</if>
</if>
</where>
</where>
</select>
</select>
<update
id=
"removeStaffPerformance"
parameterType=
"cn.com.glsx.dj.staff.model.StaffPerformance"
>
UPDATE dj_car_life_staff_performance
SET
deleted_flag = 'D',
updated_by = #{updatedBy},
updated_date = now()
WHERE
merchant_id = #{merchantId}
AND business_type = #{businessType}
AND brand_id = #{brandId}
AND child_brand_id = #{childBrandId}
AND month = #{month}
AND deleted_flag = 'N'
</update>
</mapper>
</mapper>
\ No newline at end of file
\ No newline at end of file
rpc-dj-staff/src/main/resources/META-INF/orm/StaffProductPerformanceMapper.xml
0 → 100644
View file @
aef7c28
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"cn.com.glsx.dj.staff.mapper.StaffProductPerformanceMapper"
>
<select
id=
"listStaffPerformance"
parameterType=
"cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO"
resultType=
"cn.com.glsx.dj.staff.dto.StaffProductPerformanceDTO"
>
SELECT
*
FROM
dj_car_life_staff_product_performance
WHERE
deleted_flag = 'N'
<if
test=
"dto.staffName != null and dto.staffName != ''"
>
AND staff_name LIKE CONCAT('%', #{dto.staffName},
'%')
</if>
<if
test=
"dto.staffPhone != null and dto.staffPhone != ''"
>
AND staff_phone = #{dto.staffPhone}
</if>
<if
test=
"dto.month != null and dto.month != ''"
>
AND month = #{dto.month}
</if>
</select>
<update
id=
"removeStaffProductPerformance"
>
UPDATE dj_car_life_staff_product_performance
SET
deleted_flag = 'D',
updated_by = #{updatedBy},
updated_date = now()
WHERE
staff_phone = #{staffPhone}
AND merchant_id = #{merchantId}
AND business_type = #{businessType}
AND brand_id = #{brandId}
AND child_brand_id = #{childBrandId}
AND month = #{performanceMonth}
AND deleted_flag = 'N'
</update>
</mapper>
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