Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
dj
/
rpc-dj-strategy
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 8ad58348
authored
Jun 23, 2026
by
chenxi
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge remote-tracking branch 'origin/v5.8.3' into v5.8.3
2 parents
920b0c6e
32975ebf
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
482 additions
and
116 deletions
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/sop/SopStageDTO.java
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/sop/SopStrategyMetaDTO.java
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/model/sop/SopStrategyMetaDateVariable.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/config/SmartcarlifeDubboConfig.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/job/CancelCustomerProductTagJob.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/job/InspectionCustomerProductTagJob.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/sop/SopStrategyMetaDateVariableMapper.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/InspectionCustomerTagSyncService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/MarketingActivityService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategySopQueryService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/util/DateUtil.java
rpc-dj-strategy/src/main/resources/META-INF/orm/SopStrategyMetaDateVariableMapper.xml
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/sop/SopStageDTO.java
View file @
8ad5834
package
cn
.
com
.
glsx
.
dj
.
strategy
.
dto
.
sop
;
import
cn.com.glsx.dj.strategy.dto.sop.SopStrategyMetaDTO.SopMetaItemDTO
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.io.Serializable
;
import
java.util.List
;
import
lombok.Data
;
@Data
...
...
@@ -21,4 +23,7 @@ public class SopStageDTO implements Serializable {
@ApiModelProperty
(
notes
=
"排序序号"
)
private
Integer
sortOrder
;
@ApiModelProperty
(
notes
=
"触发时间类型列表"
)
private
List
<
SopMetaItemDTO
>
triggerMetaDates
;
}
\ No newline at end of file
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/dto/sop/SopStrategyMetaDTO.java
View file @
8ad5834
...
...
@@ -24,9 +24,6 @@ public class SopStrategyMetaDTO implements Serializable {
@ApiModelProperty
(
notes
=
"触发类型列表"
)
private
List
<
SopMetaItemDTO
>
triggers
;
@ApiModelProperty
(
notes
=
"触发时间类型列表"
)
private
List
<
SopMetaItemDTO
>
triggerMetaDates
;
@ApiModelProperty
(
notes
=
"消息变量列表"
)
private
List
<
SopMetaItemDTO
>
messageVariables
;
...
...
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/model/sop/SopStrategyMetaDateVariable.java
View file @
8ad5834
...
...
@@ -13,6 +13,9 @@ public class SopStrategyMetaDateVariable {
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Integer
id
;
@Column
(
name
=
"stage_code"
,
length
=
64
)
private
String
stageCode
;
@Column
(
name
=
"date_code"
,
nullable
=
false
,
length
=
64
)
private
String
dateCode
;
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/config/SmartcarlifeDubboConfig.java
View file @
8ad5834
package
cn
.
com
.
glsx
.
dj
.
strategy
.
config
;
import
cn.com.glsx.dj.smartcarlife.remote.CustomerInfoRemote
;
import
cn.com.glsx.dj.peanalysis.remote.BiAnalyseBackgroundRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.GoodsOrderRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.SceneMerchantRefRemote
;
import
lombok.RequiredArgsConstructor
;
import
org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory
;
...
...
@@ -9,7 +11,7 @@ import org.springframework.context.annotation.Configuration;
@Configuration
@RequiredArgsConstructor
public
class
SmartcarlifeDubboConfig
{
public
class
SmartcarlifeDubboConfig
extends
DubboConfig
{
private
final
ReferenceBuilderFactory
factory
;
...
...
@@ -39,4 +41,9 @@ public class SmartcarlifeDubboConfig {
.
timeout
(
TIMEOUT
)
.
build
();
}
@Bean
public
GoodsOrderRemote
goodsOrderRemote
(){
return
factory
.
builder
(
GoodsOrderRemote
.
class
).
check
(
check
).
timeout
(
timeout
).
build
();
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/job/CancelCustomerProductTagJob.java
0 → 100644
View file @
8ad5834
package
cn
.
com
.
glsx
.
dj
.
strategy
.
job
;
import
cn.com.glsx.dj.strategy.service.InspectionCustomerTagSyncService
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
lombok.extern.slf4j.Slf4j
;
import
org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* @ClassName CancelCustomerProductTagJob
* @Description 取消客户产品标签任务 - 15日退单数据
* @Author lqWang
* @Date 2026/6/23 10:16
*/
@Slf4j
@ElasticJobConf
(
name
=
"CancelCustomerProductTagJob"
,
cron
=
"0 0 2 * * ?"
,
description
=
"取消退款订单客户产品标签任务"
,
overwrite
=
false
)
public
class
CancelCustomerProductTagJob
implements
SimpleJob
{
@Autowired
private
InspectionCustomerTagSyncService
inspectionCustomerTagSyncService
;
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
log
.
info
(
"----------------取消退款订单-客户档案产品标签任务开始-----------------"
);
try
{
// 自定义参数如:指定开始、截止日期范围{"startDate":"2026-06-01","endDate":"2026-06-22"}
inspectionCustomerTagSyncService
.
cancelCustomerProductTagFromInspection
(
shardingContext
.
getJobParameter
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
log
.
info
(
"----------------取消退款订单-客户档案产品标签任务结束-----------------"
);
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/job/InspectionCustomerProductTagJob.java
0 → 100644
View file @
8ad5834
package
cn
.
com
.
glsx
.
dj
.
strategy
.
job
;
import
cn.com.glsx.dj.strategy.service.InspectionCustomerTagSyncService
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
lombok.extern.slf4j.Slf4j
;
import
org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf
;
import
org.springframework.beans.factory.annotation.Autowired
;
/**
* @ClassName InspectionCustomerProductTagJob
* @Description 客户产品标签定时任务-每天
* @Author lqWang
* @Date 2026/6/18 15:58
*/
@Slf4j
@ElasticJobConf
(
name
=
"InspectionCustomerProductTagJob"
,
cron
=
"0 0 3 * * ?"
,
description
=
"客户产品标签定时任务"
,
overwrite
=
false
)
public
class
InspectionCustomerProductTagJob
implements
SimpleJob
{
@Autowired
private
InspectionCustomerTagSyncService
inspectionCustomerTagSyncService
;
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
log
.
info
(
"----------------客户档案每日标记产品标签任务开始-----------------"
);
try
{
// 自定义参数如:指定开始、截止日期范围{"startDate":"2026-06-01","endDate":"2026-06-22"}
inspectionCustomerTagSyncService
.
syncCustomerProductTagFromInspection
(
shardingContext
.
getJobParameter
());
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
log
.
info
(
"----------------客户档案每日标记产品标签任务结束-----------------"
);
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/mapper/sop/SopStrategyMetaDateVariableMapper.java
View file @
8ad5834
...
...
@@ -13,4 +13,6 @@ public interface SopStrategyMetaDateVariableMapper extends OreMapper<SopStrategy
List
<
SopStrategyMetaDateVariable
>
selectByStatus
(
@Param
(
"status"
)
Integer
status
);
SopStrategyMetaDateVariable
selectByDateCode
(
@Param
(
"dateCode"
)
String
dateCode
);
List
<
SopStrategyMetaDateVariable
>
selectByStageCode
(
@Param
(
"stageCode"
)
String
stageCode
);
}
\ No newline at end of file
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/InspectionCustomerTagSyncService.java
View file @
8ad5834
...
...
@@ -3,33 +3,44 @@ package cn.com.glsx.dj.strategy.service;
import
cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagDTO
;
import
cn.com.glsx.dj.mindworkplate.dto.InspectionCustomerTagPageRequestDTO
;
import
cn.com.glsx.dj.mindworkplate.remote.InspectionCustomerTagRemote
;
import
cn.com.glsx.dj.smartcarlife.dto.GoodsOrderDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.GoodsSubOrderDTO
;
import
cn.com.glsx.dj.smartcarlife.enums.CarLifeEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.RefundGoodsSubOrderStatusEnum
;
import
cn.com.glsx.dj.smartcarlife.enums.SceneTypeEnum
;
import
cn.com.glsx.dj.smartcarlife.model.GoodsOrderCustomer
;
import
cn.com.glsx.dj.smartcarlife.remote.GoodsOrderRemote
;
import
cn.com.glsx.dj.strategy.dto.TagCategoryDimensionQueryReqDTO
;
import
cn.com.glsx.dj.strategy.dto.TagCategoryDimensionRespDTO
;
import
cn.com.glsx.dj.strategy.dto.TagDimensionRespDTO
;
import
cn.com.glsx.dj.strategy.dto.TagEnumRespDTO
;
import
cn.com.glsx.dj.strategy.mapper.CustomerTagProfileMapper
;
import
cn.com.glsx.dj.strategy.mapper.TagEnumMapper
;
import
cn.com.glsx.dj.strategy.model.CustomerTagProfile
;
import
cn.com.glsx.dj.strategy.model.TagDimension
;
import
cn.com.glsx.dj.strategy.model.TagEnum
;
import
cn.com.glsx.framework.core.beans.rpc.RpcPagination
;
import
cn.com.glsx.framework.core.beans.rpc.RpcResponse
;
import
cn.com.glsx.framework.core.enums.DefaultErrorEnum
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.oreframework.boot.env.OrePropertyConfigurer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.util.*
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
import
tk.mybatis.mapper.entity.Example
;
/**
* 客户标签同步服务
...
...
@@ -57,9 +68,15 @@ public class InspectionCustomerTagSyncService {
private
InspectionCustomerTagRemote
inspectionCustomerTagRemote
;
@Autowired
private
GoodsOrderRemote
goodsOrderRemote
;
@Autowired
private
CustomerTagProfileMapper
customerTagProfileMapper
;
@Autowired
private
TagEnumMapper
tagEnumMapper
;
@Autowired
private
TagCategoryService
tagCategoryService
;
/**
...
...
@@ -484,4 +501,326 @@ public class InspectionCustomerTagSyncService {
customerTagProfileMapper
.
batchInsert
(
batch
);
}
}
/**
* @description: 同步客户档案标签
* @param: [jobParameter]
* @return: void
* @author: lqWang
* @date: 2026/6/22 10:04
*/
public
void
syncCustomerProductTagFromInspection
(
String
jobParameter
)
{
try
{
log
.
info
(
"开始同步客户档案标签, jobParameter={}"
,
jobParameter
);
DateTimeFormatter
dateFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
LocalDate
startLocalDate
;
LocalDate
endLocalDate
;
if
(
StrUtil
.
isBlank
(
jobParameter
))
{
// 空参默认:昨天
LocalDate
yesterday
=
LocalDate
.
now
().
minusDays
(
1
);
startLocalDate
=
yesterday
;
endLocalDate
=
yesterday
;
}
else
{
JSONObject
params
=
JSONUtil
.
parseObj
(
jobParameter
);
String
startDateStr
=
params
.
getStr
(
"startDate"
);
String
endDateStr
=
params
.
getStr
(
"endDate"
);
startLocalDate
=
LocalDate
.
parse
(
startDateStr
,
dateFormatter
);
endLocalDate
=
LocalDate
.
parse
(
endDateStr
,
dateFormatter
);
}
Date
installUpgradeBeginTime
=
cn
.
com
.
glsx
.
dj
.
strategy
.
util
.
DateUtil
.
getStartOfDay
(
startLocalDate
);
Date
installUpgradeEndTime
=
cn
.
com
.
glsx
.
dj
.
strategy
.
util
.
DateUtil
.
getEndOfDay
(
endLocalDate
);
GoodsOrderDTO
condition
=
GoodsOrderDTO
.
builder
().
statusList
(
Arrays
.
asList
(
CarLifeEnum
.
OrderStatus
.
PAYED
.
getValue
(),
CarLifeEnum
.
OrderStatus
.
FINISHED
.
getValue
()))
.
installUpgradeBeginTime
(
installUpgradeBeginTime
).
installUpgradeEndTime
(
installUpgradeEndTime
).
sceneType
(
SceneTypeEnum
.
SCENE1_1
.
getValue
()).
build
();
RpcResponse
<
List
<
GoodsOrderDTO
>>
response
=
goodsOrderRemote
.
listSimpleGoodsOrder
(
condition
);
// 将返回结果中所有的客户取出来,循环客户列表,获取每个客户的订单商品信息,匹配商品标签信息,跟当前客户标签做对比,若当前客户没有标签,则全量新增。若已存在标签,只新增没有的产品标签。
//太阳膜
Integer
solarFilmTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.solarFilm"
,
Integer
.
class
,
1
);
//车衣
Integer
carCoverTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.dailyReport.carCover"
,
Integer
.
class
,
12
);
//电动踏板
Integer
electricPedalTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.electricPedal"
,
Integer
.
class
,
17
);
//底盘护板
Integer
groundGuardBoardTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.groundGuardBoard"
,
Integer
.
class
,
165
);
//小桌板
Integer
smallTableBoardId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.smallTableBoard"
,
Integer
.
class
,
14
);
//脚垫
Integer
footMatId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.footMat"
,
Integer
.
class
,
143
);
// ========== 基于订单商品品类自动打标客户产品标签 ==========
if
(
response
==
null
||
!
response
.
isSuccess
()
||
CollectionUtils
.
isEmpty
(
response
.
getResult
()))
{
log
.
info
(
"未查询到订单数据,跳过产品标签同步"
);
log
.
info
(
"结束同步客户档案标签"
);
return
;
}
List
<
GoodsOrderDTO
>
orderList
=
response
.
getResult
();
// 1. 收集所有客户手机号(去重)
List
<
String
>
phoneList
=
orderList
.
stream
().
map
(
GoodsOrderDTO:
:
getCustomer
).
filter
(
Objects:
:
nonNull
).
map
(
GoodsOrderCustomer:
:
getCustomerPhone
)
.
filter
(
StrUtil:
:
isNotBlank
).
distinct
().
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
phoneList
))
{
log
.
info
(
"无有效客户手机号,跳过产品标签同步"
);
log
.
info
(
"结束同步客户档案标签"
);
return
;
}
// 2. 查询客户已有的产品标签
Example
example
=
new
Example
(
CustomerTagProfile
.
class
);
example
.
createCriteria
()
.
andEqualTo
(
"deletedFlag"
,
"N"
)
.
andEqualTo
(
"categoryCode"
,
"INIT_C3"
)
.
andEqualTo
(
"dimensionCode"
,
"INIT_D12"
)
.
andIn
(
"phone"
,
phoneList
);
List
<
CustomerTagProfile
>
existingTags
=
customerTagProfileMapper
.
selectByExample
(
example
);
Map
<
String
,
Set
<
String
>>
existingEnumMap
=
new
HashMap
<>();
if
(!
CollectionUtils
.
isEmpty
(
existingTags
))
{
for
(
CustomerTagProfile
tag
:
existingTags
)
{
existingEnumMap
.
computeIfAbsent
(
tag
.
getPhone
(),
k
->
new
HashSet
<>())
.
add
(
tag
.
getEnumCode
());
}
}
// 3. 品类ID → 产品标签枚举映射
Map
<
Integer
,
String
>
goodsTypeEnumMap
=
new
LinkedHashMap
<>();
goodsTypeEnumMap
.
put
(
solarFilmTypeId
,
"INIT_E36"
);
goodsTypeEnumMap
.
put
(
carCoverTypeId
,
"INIT_E37"
);
goodsTypeEnumMap
.
put
(
electricPedalTypeId
,
"INIT_E38"
);
goodsTypeEnumMap
.
put
(
groundGuardBoardTypeId
,
"INIT_E39"
);
goodsTypeEnumMap
.
put
(
smallTableBoardId
,
"INIT_E40"
);
goodsTypeEnumMap
.
put
(
footMatId
,
"INIT_E41"
);
// 4. 遍历客户订单,匹配商品品类
List
<
CustomerTagProfile
>
newProfiles
=
new
ArrayList
<>();
for
(
GoodsOrderDTO
order
:
orderList
)
{
GoodsOrderCustomer
customer
=
order
.
getCustomer
();
if
(
customer
==
null
||
StrUtil
.
isBlank
(
customer
.
getCustomerPhone
()))
{
continue
;
}
String
phone
=
customer
.
getCustomerPhone
();
Set
<
String
>
existingEnums
=
existingEnumMap
.
getOrDefault
(
phone
,
Collections
.
emptySet
());
List
<
GoodsSubOrderDTO
>
subOrders
=
order
.
getSubOrderList
();
if
(
CollectionUtils
.
isEmpty
(
subOrders
))
{
continue
;
}
Set
<
String
>
matchedEnums
=
new
HashSet
<>();
for
(
GoodsSubOrderDTO
sub
:
subOrders
)
{
for
(
Map
.
Entry
<
Integer
,
String
>
entry
:
goodsTypeEnumMap
.
entrySet
())
{
Integer
configTypeId
=
entry
.
getKey
();
if
(
configTypeId
!=
null
&&
(
configTypeId
.
equals
(
sub
.
getUpgradeGoodsType
())
||
configTypeId
.
equals
(
sub
.
getUpgradeSecondaryGoodsType
())
||
configTypeId
.
equals
(
sub
.
getUpgradeThirdLevelGoodsType
())))
{
matchedEnums
.
add
(
entry
.
getValue
());
}
}
}
// 只新增客户尚未拥有的标签
for
(
String
enumCode
:
matchedEnums
)
{
if
(!
existingEnums
.
contains
(
enumCode
))
{
CustomerTagProfile
profile
=
new
CustomerTagProfile
();
profile
.
setPhone
(
phone
);
profile
.
setCategoryCode
(
"INIT_C3"
);
profile
.
setDimensionCode
(
"INIT_D12"
);
profile
.
setEnumCode
(
enumCode
);
profile
.
setSourceType
(
"ORDER"
);
profile
.
setSourceRefId
(
order
.
getOrderCode
());
profile
.
setDeletedFlag
(
"N"
);
newProfiles
.
add
(
profile
);
}
}
}
// 5. 查询枚举分值并批量插入
if
(!
CollectionUtils
.
isEmpty
(
newProfiles
))
{
List
<
String
>
enumCodes
=
newProfiles
.
stream
()
.
map
(
CustomerTagProfile:
:
getEnumCode
)
.
distinct
()
.
collect
(
Collectors
.
toList
());
List
<
TagEnum
>
tagEnums
=
tagEnumMapper
.
selectByEnumCodes
(
enumCodes
);
Map
<
String
,
Integer
>
enumScoreMap
=
new
HashMap
<>();
if
(!
CollectionUtils
.
isEmpty
(
tagEnums
))
{
for
(
TagEnum
te
:
tagEnums
)
{
enumScoreMap
.
put
(
te
.
getEnumCode
(),
te
.
getScore
());
}
}
for
(
CustomerTagProfile
profile
:
newProfiles
)
{
profile
.
setScore
(
enumScoreMap
.
getOrDefault
(
profile
.
getEnumCode
(),
0
));
}
batchInsertProfiles
(
newProfiles
);
log
.
info
(
"产品标签同步完成,新增 {} 条标签"
,
newProfiles
.
size
());
}
else
{
log
.
info
(
"产品标签同步完成,无新增标签"
);
}
log
.
info
(
"结束同步客户档案标签"
);
}
catch
(
RpcServiceException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
log
.
error
(
"客户档案每日标记产品标签异常:{}"
,
e
.
getMessage
(),
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
e
.
getMessage
());
}
}
/**
* @description: 取消客户产品标签 - 默认15天内退款订单
* @param: [jobParameter]
* @return: void
* @author: lqWang
* @date: 2026/6/23 10:21
*/
public
void
cancelCustomerProductTagFromInspection
(
String
jobParameter
)
{
try
{
log
.
info
(
"开始取消客户产品标签, jobParameter={}"
,
jobParameter
);
// 1. 日期范围:默认15天前~当前时间
DateTimeFormatter
dateFormatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
LocalDate
startLocalDate
;
LocalDate
endLocalDate
;
if
(
StrUtil
.
isBlank
(
jobParameter
))
{
endLocalDate
=
LocalDate
.
now
();
startLocalDate
=
endLocalDate
.
minusDays
(
15
);
}
else
{
JSONObject
params
=
JSONUtil
.
parseObj
(
jobParameter
);
String
startDateStr
=
params
.
getStr
(
"startDate"
);
String
endDateStr
=
params
.
getStr
(
"endDate"
);
startLocalDate
=
LocalDate
.
parse
(
startDateStr
,
dateFormatter
);
endLocalDate
=
LocalDate
.
parse
(
endDateStr
,
dateFormatter
);
}
log
.
info
(
"取消标签时间范围:{} ~ {}"
,
startLocalDate
,
endLocalDate
);
// 2. 查询已退款订单
Date
beginTime
=
cn
.
com
.
glsx
.
dj
.
strategy
.
util
.
DateUtil
.
getStartOfDay
(
startLocalDate
);
Date
endTime
=
cn
.
com
.
glsx
.
dj
.
strategy
.
util
.
DateUtil
.
getEndOfDay
(
endLocalDate
);
GoodsOrderDTO
condition
=
GoodsOrderDTO
.
builder
()
.
statusList
(
Collections
.
singletonList
(
CarLifeEnum
.
OrderStatus
.
REFUNDED
.
getValue
()))
.
installUpgradeBeginTime
(
beginTime
)
.
installUpgradeEndTime
(
endTime
)
.
sceneType
(
SceneTypeEnum
.
SCENE1_1
.
getValue
())
.
build
();
RpcResponse
<
List
<
GoodsOrderDTO
>>
response
=
goodsOrderRemote
.
listSimpleGoodsOrder
(
condition
);
if
(
response
==
null
||
!
response
.
isSuccess
()
||
CollectionUtils
.
isEmpty
(
response
.
getResult
()))
{
log
.
info
(
"未查询到已退款订单数据,跳过取消产品标签"
);
return
;
}
List
<
GoodsOrderDTO
>
orderList
=
response
.
getResult
();
log
.
info
(
"查询到 {} 条已退款订单"
,
orderList
.
size
());
// 3. 品类配置
Integer
solarFilmTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.solarFilm"
,
Integer
.
class
,
1
);
Integer
carCoverTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.dailyReport.carCover"
,
Integer
.
class
,
12
);
Integer
electricPedalTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.electricPedal"
,
Integer
.
class
,
17
);
Integer
groundGuardBoardTypeId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.groundGuardBoard"
,
Integer
.
class
,
165
);
Integer
smallTableBoardId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.smallTableBoard"
,
Integer
.
class
,
14
);
Integer
footMatId
=
OrePropertyConfigurer
.
getProperty
(
"smartcarlife.goodsType.footMat"
,
Integer
.
class
,
143
);
Map
<
Integer
,
String
>
goodsTypeEnumMap
=
new
LinkedHashMap
<>();
goodsTypeEnumMap
.
put
(
solarFilmTypeId
,
"INIT_E36"
);
goodsTypeEnumMap
.
put
(
carCoverTypeId
,
"INIT_E37"
);
goodsTypeEnumMap
.
put
(
electricPedalTypeId
,
"INIT_E38"
);
goodsTypeEnumMap
.
put
(
groundGuardBoardTypeId
,
"INIT_E39"
);
goodsTypeEnumMap
.
put
(
smallTableBoardId
,
"INIT_E40"
);
goodsTypeEnumMap
.
put
(
footMatId
,
"INIT_E41"
);
// 4. 查询已有产品标签
List
<
String
>
phoneList
=
orderList
.
stream
()
.
map
(
GoodsOrderDTO:
:
getCustomer
).
filter
(
Objects:
:
nonNull
)
.
map
(
GoodsOrderCustomer:
:
getCustomerPhone
).
filter
(
StrUtil:
:
isNotBlank
)
.
distinct
().
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
phoneList
))
{
log
.
info
(
"无有效客户手机号,跳过取消产品标签"
);
return
;
}
Example
example
=
new
Example
(
CustomerTagProfile
.
class
);
example
.
createCriteria
()
.
andEqualTo
(
"deletedFlag"
,
"N"
)
.
andEqualTo
(
"categoryCode"
,
"INIT_C3"
)
.
andEqualTo
(
"dimensionCode"
,
"INIT_D12"
)
.
andIn
(
"phone"
,
phoneList
);
List
<
CustomerTagProfile
>
existingTags
=
customerTagProfileMapper
.
selectByExample
(
example
);
Map
<
String
,
Set
<
String
>>
existingEnumMap
=
new
HashMap
<>();
if
(!
CollectionUtils
.
isEmpty
(
existingTags
))
{
for
(
CustomerTagProfile
tag
:
existingTags
)
{
existingEnumMap
.
computeIfAbsent
(
tag
.
getPhone
(),
k
->
new
HashSet
<>())
.
add
(
tag
.
getEnumCode
());
}
}
// 5. 按客户分组订单
Map
<
String
,
List
<
GoodsOrderDTO
>>
customerOrderMap
=
orderList
.
stream
()
.
filter
(
o
->
o
.
getCustomer
()
!=
null
&&
StrUtil
.
isNotBlank
(
o
.
getCustomer
().
getCustomerPhone
()))
.
collect
(
Collectors
.
groupingBy
(
o
->
o
.
getCustomer
().
getCustomerPhone
()));
// 6. 遍历分组,匹配退款子订单品类并逻辑删除
int
totalDeleted
=
0
;
for
(
Map
.
Entry
<
String
,
List
<
GoodsOrderDTO
>>
entry
:
customerOrderMap
.
entrySet
())
{
String
phone
=
entry
.
getKey
();
Set
<
String
>
existingEnums
=
existingEnumMap
.
get
(
phone
);
if
(
CollectionUtils
.
isEmpty
(
existingEnums
))
{
continue
;
}
Set
<
String
>
refundedEnums
=
new
HashSet
<>();
for
(
GoodsOrderDTO
order
:
entry
.
getValue
())
{
List
<
GoodsSubOrderDTO
>
subOrders
=
order
.
getSubOrderList
();
if
(
CollectionUtils
.
isEmpty
(
subOrders
))
{
continue
;
}
for
(
GoodsSubOrderDTO
sub
:
subOrders
)
{
// 只处理已退款的子订单
if
(!
Objects
.
equals
(
sub
.
getStatus
(),
RefundGoodsSubOrderStatusEnum
.
REFUNDED
.
getValue
()))
{
continue
;
}
for
(
Map
.
Entry
<
Integer
,
String
>
typeEntry
:
goodsTypeEnumMap
.
entrySet
())
{
Integer
configTypeId
=
typeEntry
.
getKey
();
if
(
configTypeId
!=
null
&&
(
configTypeId
.
equals
(
sub
.
getUpgradeGoodsType
())
||
configTypeId
.
equals
(
sub
.
getUpgradeSecondaryGoodsType
())
||
configTypeId
.
equals
(
sub
.
getUpgradeThirdLevelGoodsType
())))
{
refundedEnums
.
add
(
typeEntry
.
getValue
());
}
}
}
}
// 取交集:已有标签 ∩ 退款商品标签 → 需要删除
Set
<
String
>
toDelete
=
new
HashSet
<>(
refundedEnums
);
toDelete
.
retainAll
(
existingEnums
);
for
(
String
enumCode
:
toDelete
)
{
Example
deleteExample
=
new
Example
(
CustomerTagProfile
.
class
);
deleteExample
.
createCriteria
()
.
andEqualTo
(
"phone"
,
phone
)
.
andEqualTo
(
"categoryCode"
,
"INIT_C3"
)
.
andEqualTo
(
"dimensionCode"
,
"INIT_D12"
)
.
andEqualTo
(
"enumCode"
,
enumCode
)
.
andEqualTo
(
"deletedFlag"
,
"N"
);
CustomerTagProfile
updateRecord
=
new
CustomerTagProfile
();
updateRecord
.
setDeletedFlag
(
"D"
);
customerTagProfileMapper
.
updateByExampleSelective
(
updateRecord
,
deleteExample
);
totalDeleted
++;
log
.
debug
(
"取消客户产品标签, phone={}, enumCode={}"
,
phone
,
enumCode
);
}
}
log
.
info
(
"取消客户产品标签完成,共取消 {} 条标签"
,
totalDeleted
);
}
catch
(
RpcServiceException
e
)
{
throw
e
;
}
catch
(
Exception
e
)
{
log
.
error
(
"取消客户产品标签异常:{}"
,
e
.
getMessage
(),
e
);
throw
new
RpcServiceException
(
DefaultErrorEnum
.
SERVICE_ERROR
,
e
.
getMessage
());
}
}
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/MarketingActivityService.java
View file @
8ad5834
...
...
@@ -222,25 +222,13 @@ public class MarketingActivityService {
marketingActivityStoreMapper
.
deleteByActivityId
(
request
.
getActivityId
());
batchInsertStores
(
request
.
getActivityId
(),
request
.
getStoreIds
(),
activity
.
getUpdatedBy
());
// 商品/套餐变动检测(按车系维度对比嵌套结构)
MarketingActivityProductPageReqDTO
queryDTO
=
new
MarketingActivityProductPageReqDTO
();
queryDTO
.
setActivityId
(
request
.
getActivityId
());
List
<
MarketingActivityProductRespDTO
>
existingProducts
=
marketingActivityProductMapper
.
selectProductDTOList
(
queryDTO
);
List
<
MarketingActivityCarSeries
>
existingCarSeries
=
marketingActivityCarSeriesMapper
.
selectByActivityId
(
request
.
getActivityId
());
boolean
productChanged
=
detectProductChange
(
request
.
getCarSeriesList
(),
existingCarSeries
,
existingProducts
);
if
(
productChanged
)
{
// TODO: 商品/套餐发生变动,触发第三方调用(如通知下游系统)
log
.
info
(
"活动{}的商品/套餐发生变动,需触发第三方调用"
,
request
.
getActivityId
());
}
// 删除旧数据并重新插入
marketingActivityCarSeriesMapper
.
deleteByActivityId
(
request
.
getActivityId
());
marketingActivityProductMapper
.
deleteByActivityIdAndCarSeriesId
(
request
.
getActivityId
(),
null
);
insertCarSeriesListWithProducts
(
request
.
getActivityId
(),
request
.
getCarSeriesList
(),
request
.
getCarSeriesMode
(),
activity
.
getUpdatedBy
());
// 异步触发预学习剧本生成(商品发生变动时才触发)
if
(
productChanged
)
{
triggerPreLearnAsync
(
request
.
getActivityId
());
}
// 异步触发预学习剧本生成(商品发生变动时才触发)
triggerPreLearnAsync
(
request
.
getActivityId
());
}
// ==================== 删除 ====================
...
...
@@ -724,66 +712,6 @@ public class MarketingActivityService {
}
/**
* 检测商品/套餐是否有变动(按车系维度对比嵌套结构)
*/
private
boolean
detectProductChange
(
List
<
MarketingActivityCarSeriesReqDTO
>
incomingCarSeriesList
,
List
<
MarketingActivityCarSeries
>
existingCarSeries
,
List
<
MarketingActivityProductRespDTO
>
existingProducts
)
{
if
(
existingProducts
==
null
)
existingProducts
=
Collections
.
emptyList
();
if
(
incomingCarSeriesList
==
null
)
incomingCarSeriesList
=
Collections
.
emptyList
();
if
(
existingCarSeries
==
null
)
existingCarSeries
=
Collections
.
emptyList
();
// 构建已有数据:carSeriesId → 业务键
Map
<
Integer
,
String
>
csIdToKey
=
new
HashMap
<>();
for
(
MarketingActivityCarSeries
cs
:
existingCarSeries
)
{
csIdToKey
.
put
(
cs
.
getId
(),
cs
.
getCarSeriesId
()
+
""
);
}
// 构建已有数据:业务键 → 商品编码集
Map
<
String
,
Set
<
String
>>
existingMap
=
new
HashMap
<>();
for
(
MarketingActivityProductRespDTO
p
:
existingProducts
)
{
String
code
=
buildProductCode
(
p
);
if
(
code
==
null
)
continue
;
String
csKey
=
csIdToKey
.
get
(
p
.
getCarSeriesId
());
existingMap
.
computeIfAbsent
(
csKey
,
k
->
new
HashSet
<>()).
add
(
code
);
}
// 构建请求数据:业务键 → 商品编码集
Map
<
String
,
Set
<
String
>>
incomingMap
=
new
HashMap
<>();
for
(
MarketingActivityCarSeriesReqDTO
cs
:
incomingCarSeriesList
)
{
String
key
=
cs
.
getCarSeriesId
()
+
""
;
Set
<
String
>
codes
=
new
HashSet
<>();
if
(
cs
.
getProducts
()
!=
null
)
{
for
(
MarketingActivityProductReqDTO
p
:
cs
.
getProducts
())
{
String
code
=
buildProductCode
(
p
);
if
(
code
!=
null
)
codes
.
add
(
code
);
}
}
incomingMap
.
put
(
key
,
codes
);
}
boolean
equals
=
existingMap
.
equals
(
incomingMap
);
if
(!
equals
)
{
log
.
info
(
"商品/车系发生变动,old:{}, new:{}"
,
existingMap
,
incomingMap
);
}
return
!
equals
;
}
private
String
buildProductCode
(
MarketingActivityProductRespDTO
p
)
{
if
(
ProductTypeEnum
.
PACKAGE
.
getValue
().
equals
(
p
.
getProductType
()))
{
return
StringUtils
.
hasLength
(
p
.
getPackageCode
())
?
"PACKAGE:"
+
p
.
getPackageCode
()
:
null
;
}
return
StringUtils
.
hasLength
(
p
.
getGoodsCode
())
?
"GOODS:"
+
p
.
getGoodsCode
()
:
null
;
}
private
String
buildProductCode
(
MarketingActivityProductReqDTO
p
)
{
if
(
ProductTypeEnum
.
PACKAGE
.
getValue
().
equals
(
p
.
getProductType
()))
{
return
StringUtils
.
hasLength
(
p
.
getPackageCode
())
?
"PACKAGE:"
+
p
.
getPackageCode
()
:
null
;
}
return
StringUtils
.
hasLength
(
p
.
getGoodsCode
())
?
"GOODS:"
+
p
.
getGoodsCode
()
:
null
;
}
/**
* 根据 goodsCode 查询 goods_type/现售价/最低限价
*/
private
GoodsTypeInfoDTO
lookupGoodsTypeInfo
(
String
goodsCode
)
{
...
...
@@ -824,24 +752,6 @@ public class MarketingActivityService {
marketingActivityOperationLogMapper
.
insert
(
log
);
}
private
String
formatDate
(
Date
date
)
{
if
(
date
==
null
)
return
null
;
return
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
date
);
}
private
Date
parseDate
(
String
dateStr
)
{
if
(!
StringUtils
.
hasText
(
dateStr
))
return
null
;
try
{
if
(
dateStr
.
length
()
<=
10
)
{
return
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
parse
(
dateStr
);
}
return
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
parse
(
dateStr
);
}
catch
(
Exception
e
)
{
log
.
error
(
"日期解析失败: {}"
,
dateStr
,
e
);
return
null
;
}
}
/**
* 查询活动详情(含活动信息及关联商品/套餐)
*/
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/StrategySopQueryService.java
View file @
8ad5834
...
...
@@ -223,7 +223,6 @@ public class StrategySopQueryService {
meta
.
setConditionVariables
(
allConditionVariables
);
meta
.
setStep2ConditionVariables
(
filterStep2ConditionVariables
(
allConditionVariables
));
meta
.
setTriggers
(
buildTriggers
());
meta
.
setTriggerMetaDates
(
buildMetaDates
());
meta
.
setMessageVariables
(
buildMessageVariables
());
...
...
@@ -246,7 +245,7 @@ public class StrategySopQueryService {
}
/**
* 构建营销阶段列表
* 构建营销阶段列表
(包含关联的触发时间变量)
*
* @return 营销阶段DTO列表
*/
...
...
@@ -260,6 +259,13 @@ public class StrategySopQueryService {
dto
.
setStageDesc
(
stage
.
getStageDesc
());
dto
.
setQuerySql
(
stage
.
getQuerySql
());
dto
.
setSortOrder
(
stage
.
getSortOrder
());
List
<
SopStrategyMetaDateVariable
>
dateVariables
=
sopStrategyMetaDateVariableMapper
.
selectByStageCode
(
stage
.
getStageCode
());
if
(
CollUtil
.
isNotEmpty
(
dateVariables
))
{
dto
.
setTriggerMetaDates
(
dateVariables
.
stream
()
.
map
(
variable
->
createMetaItem
(
variable
.
getDateCode
(),
variable
.
getDateName
(),
4
,
variable
.
getDateDesc
()))
.
collect
(
Collectors
.
toList
()));
}
return
dto
;
})
.
collect
(
Collectors
.
toList
());
...
...
@@ -417,17 +423,6 @@ public class StrategySopQueryService {
*
* @return 触发类型元数据项列表
*/
private
List
<
SopStrategyMetaDTO
.
SopMetaItemDTO
>
buildMetaDates
()
{
List
<
SopStrategyMetaDateVariable
>
sopStrategyMetaDateVariables
=
sopStrategyMetaDateVariableMapper
.
selectByStatus
(
1
);
return
sopStrategyMetaDateVariables
.
stream
()
.
map
(
trigger
->
createMetaItem
(
trigger
.
getDateCode
(),
trigger
.
getDateName
(),
4
,
trigger
.
getDateDesc
()))
.
collect
(
Collectors
.
toList
());
}
/**
* 构建触发类型列表
*
* @return 触发类型元数据项列表
*/
private
List
<
SopStrategyMetaDTO
.
SopMetaItemDTO
>
buildTriggers
()
{
List
<
SopStrategyMetaTrigger
>
triggers
=
metaTriggerMapper
.
selectByStatus
(
1
);
return
triggers
.
stream
()
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/util/DateUtil.java
View file @
8ad5834
package
cn
.
com
.
glsx
.
dj
.
strategy
.
util
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.util.Calendar
;
import
java.util.Date
;
import
java.util.concurrent.ConcurrentHashMap
;
...
...
@@ -83,4 +85,34 @@ public class DateUtil {
return
addDays
(
date
,
-
days
);
}
// ==================== 日期起止时间 ====================
/**
* 获取指定日期的开始时间(00:00:00)
*
* @param localDate 日期,为null时返回null
* @return 当日 00:00:00 对应的 Date
*/
public
static
Date
getStartOfDay
(
LocalDate
localDate
)
{
if
(
localDate
==
null
)
{
return
null
;
}
return
Date
.
from
(
localDate
.
atStartOfDay
()
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
}
/**
* 获取指定日期的结束时间(23:59:59)
*
* @param localDate 日期,为null时返回null
* @return 当日 23:59:59 对应的 Date
*/
public
static
Date
getEndOfDay
(
LocalDate
localDate
)
{
if
(
localDate
==
null
)
{
return
null
;
}
return
Date
.
from
(
localDate
.
atTime
(
23
,
59
,
59
)
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
}
}
rpc-dj-strategy/src/main/resources/META-INF/orm/SopStrategyMetaDateVariableMapper.xml
View file @
8ad5834
...
...
@@ -4,6 +4,7 @@
<resultMap
id=
"BaseResultMap"
type=
"cn.com.glsx.dj.strategy.model.sop.SopStrategyMetaDateVariable"
>
<id
column=
"id"
property=
"id"
/>
<result
column=
"stage_code"
property=
"stageCode"
/>
<result
column=
"date_code"
property=
"dateCode"
/>
<result
column=
"date_name"
property=
"dateName"
/>
<result
column=
"date_desc"
property=
"dateDesc"
/>
...
...
@@ -30,4 +31,12 @@
AND date_code = #{dateCode}
</select>
<select
id=
"selectByStageCode"
resultMap=
"BaseResultMap"
>
SELECT * FROM sop_strategy_meta_date_variable
WHERE deleted_flag = 'N'
AND status = 1
AND (stage_code = #{stageCode} OR stage_code IS NULL)
ORDER BY sort_order ASC
</select>
</mapper>
\ No newline at end of file
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