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 a2f21110
authored
Jun 25, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:标签枚举值提成公共的
1 parent
648d33d6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
320 additions
and
100 deletions
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/enums/ArchiveTagEnum.java
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/enums/CustomerTagEnum.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/CustomerTagProfileService.java
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/CustomerTagProfileSyncService.java
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/enums/ArchiveTagEnum.java
deleted
100644 → 0
View file @
648d33d
package
cn
.
com
.
glsx
.
dj
.
strategy
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
import
java.math.BigDecimal
;
/**
* 建档标签枚举
* 根据车系价格区间划分车型档次
*
* @author yangwei_by_claude
* @version 1.0
* @since 2026/06/17
*/
@Getter
@AllArgsConstructor
public
enum
ArchiveTagEnum
{
/**
* 高端车型:价格 > 25万
*/
HIGH_END
(
"INIT_E1"
,
"高端车型"
,
new
BigDecimal
(
"250001"
),
null
),
/**
* 中端车型:15万 <= 价格 < 25万
*/
MID_RANGE
(
"INIT_E2"
,
"中端车型"
,
new
BigDecimal
(
"150000"
),
new
BigDecimal
(
"250001"
)),
/**
* 低端车型:价格 < 15万
*/
LOW_END
(
"INIT_E3"
,
"低端车型"
,
null
,
new
BigDecimal
(
"150000"
));
/**
* 枚举代码
*/
private
final
String
enumCode
;
/**
* 描述
*/
private
final
String
desc
;
/**
* 最低价格(包含),单位:元
* null 表示无下限
*/
private
final
BigDecimal
minPrice
;
/**
* 最高价格(不包含),单位:元
* null 表示无上限
*/
private
final
BigDecimal
maxPrice
;
/**
* 根据价格获取对应的标签枚举
*
* @param price 价格,单位:元
* @return 标签枚举,如果价格不在任何区间则返回 null
*/
public
static
ArchiveTagEnum
getByPrice
(
BigDecimal
price
)
{
if
(
price
==
null
)
{
return
null
;
}
for
(
ArchiveTagEnum
tag
:
values
())
{
boolean
matchMin
=
tag
.
getMinPrice
()
==
null
||
price
.
compareTo
(
tag
.
getMinPrice
())
>=
0
;
boolean
matchMax
=
tag
.
getMaxPrice
()
==
null
||
price
.
compareTo
(
tag
.
getMaxPrice
())
<
0
;
if
(
matchMin
&&
matchMax
)
{
return
tag
;
}
}
return
null
;
}
/**
* 获取价格区间描述
*
* @return 价格区间描述,如 "大于25万"、"15万-25万"、"小于15万"
*/
public
String
getPriceRangeDesc
()
{
if
(
this
==
HIGH_END
)
{
return
"大于25万"
;
}
else
if
(
this
==
MID_RANGE
)
{
return
"15万-25万"
;
}
else
{
return
"小于15万"
;
}
}
}
rpc-dj-strategy-api/src/main/java/cn/com/glsx/dj/strategy/enums/CustomerTagEnum.java
0 → 100644
View file @
a2f2111
package
cn
.
com
.
glsx
.
dj
.
strategy
.
enums
;
import
lombok.AllArgsConstructor
;
import
lombok.Getter
;
/**
* 建档标签枚举
* 根据车系价格区间划分车型档次
*
* @author yangwei_by_claude
* @version 1.0
* @since 2026/06/17
*/
@Getter
@AllArgsConstructor
public
enum
CustomerTagEnum
{
/**
* 高端车型
*/
HIGH_END
(
"INIT_E1"
,
"高端车型"
),
/**
* 中端车型
*/
MID_RANGE
(
"INIT_E2"
,
"中端车型"
),
/**
* 低端车型
*/
LOW_END
(
"INIT_E3"
,
"低端车型"
);
/**
* 枚举代码
*/
private
final
String
enumCode
;
/**
* 描述
*/
private
final
String
desc
;
}
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/CustomerTagProfileService.java
View file @
a2f2111
...
@@ -2,12 +2,13 @@ package cn.com.glsx.dj.strategy.service;
...
@@ -2,12 +2,13 @@ package cn.com.glsx.dj.strategy.service;
import
cn.com.glsx.dj.strategy.dto.CarSeriesDetailDTO
;
import
cn.com.glsx.dj.strategy.dto.CarSeriesDetailDTO
;
import
cn.com.glsx.dj.strategy.dto.CustomerProfileRespDTO
;
import
cn.com.glsx.dj.strategy.dto.CustomerProfileRespDTO
;
import
cn.com.glsx.dj.strategy.enums.
Archive
TagEnum
;
import
cn.com.glsx.dj.strategy.enums.
Customer
TagEnum
;
import
cn.com.glsx.dj.strategy.mapper.CustomerTagProfileMapper
;
import
cn.com.glsx.dj.strategy.mapper.CustomerTagProfileMapper
;
import
cn.com.glsx.dj.strategy.model.CustomerTagProfile
;
import
cn.com.glsx.dj.strategy.model.CustomerTagProfile
;
import
cn.com.glsx.dj.strategy.util.GopApiUtil
;
import
cn.com.glsx.dj.strategy.util.GopApiUtil
;
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.core.env.Environment
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -32,6 +33,49 @@ public class CustomerTagProfileService {
...
@@ -32,6 +33,49 @@ public class CustomerTagProfileService {
private
static
final
String
SOURCE_TYPE_ARCHIVE
=
"ARCHIVE"
;
private
static
final
String
SOURCE_TYPE_ARCHIVE
=
"ARCHIVE"
;
private
static
final
int
DEFAULT_SCORE
=
1
;
private
static
final
int
DEFAULT_SCORE
=
1
;
/**
* 高端车型最低价格配置key
*/
private
static
final
String
CONFIG_HIGH_END_MIN_PRICE
=
"archive.tag.high-end.min-price"
;
/**
* 中端车型最低价格配置key
*/
private
static
final
String
CONFIG_MID_RANGE_MIN_PRICE
=
"archive.tag.mid-range.min-price"
;
/**
* 中端车型最高价格配置key
*/
private
static
final
String
CONFIG_MID_RANGE_MAX_PRICE
=
"archive.tag.mid-range.max-price"
;
/**
* 低端车型最高价格配置key
*/
private
static
final
String
CONFIG_LOW_END_MAX_PRICE
=
"archive.tag.low-end.max-price"
;
/**
* 默认高端车型最低价格(元)
*/
private
static
final
BigDecimal
DEFAULT_HIGH_END_MIN_PRICE
=
new
BigDecimal
(
"250001"
);
/**
* 默认中端车型最低价格(元)
*/
private
static
final
BigDecimal
DEFAULT_MID_RANGE_MIN_PRICE
=
new
BigDecimal
(
"150000"
);
/**
* 默认中端车型最高价格(元)
*/
private
static
final
BigDecimal
DEFAULT_MID_RANGE_MAX_PRICE
=
new
BigDecimal
(
"250001"
);
/**
* 默认低端车型最高价格(元)
*/
private
static
final
BigDecimal
DEFAULT_LOW_END_MAX_PRICE
=
new
BigDecimal
(
"150000"
);
@Autowired
private
Environment
env
;
@Autowired
@Autowired
private
CustomerTagProfileMapper
customerTagProfileMapper
;
private
CustomerTagProfileMapper
customerTagProfileMapper
;
...
@@ -64,7 +108,7 @@ public class CustomerTagProfileService {
...
@@ -64,7 +108,7 @@ public class CustomerTagProfileService {
}
}
// 根据价格获取标签枚举
// 根据价格获取标签枚举
ArchiveTagEnum
tagEnum
=
ArchiveTagEnum
.
get
ByPrice
(
avgPrice
);
CustomerTagEnum
tagEnum
=
getTag
ByPrice
(
avgPrice
);
if
(
tagEnum
==
null
)
{
if
(
tagEnum
==
null
)
{
log
.
warn
(
"无法匹配车型标签:avgPrice={}"
,
avgPrice
);
log
.
warn
(
"无法匹配车型标签:avgPrice={}"
,
avgPrice
);
return
;
return
;
...
@@ -115,13 +159,103 @@ public class CustomerTagProfileService {
...
@@ -115,13 +159,103 @@ public class CustomerTagProfileService {
*/
*/
public
List
<
CustomerProfileRespDTO
>
queryYesterdayChangedProfiles
()
{
public
List
<
CustomerProfileRespDTO
>
queryYesterdayChangedProfiles
()
{
List
<
String
>
phoneList
=
customerTagProfileMapper
.
selectYesterdayChangedPhones
();
List
<
String
>
phoneList
=
customerTagProfileMapper
.
selectYesterdayChangedPhones
();
if
(
CollectionUtils
.
isEmpty
(
phoneList
))
{
if
(
CollectionUtils
.
isEmpty
(
phoneList
))
{
return
new
ArrayList
<>();
return
new
ArrayList
<>();
}
}
return
customerTagProfileMapper
.
selectByPhoneList
(
phoneList
);
return
customerTagProfileMapper
.
selectByPhoneList
(
phoneList
);
}
}
/**
/**
* 根据价格获取对应的标签枚举
*
* @param price 价格,单位:元
* @return 标签枚举,如果价格不在任何区间则返回 null
*/
private
CustomerTagEnum
getTagByPrice
(
BigDecimal
price
)
{
if
(
price
==
null
)
{
return
null
;
}
BigDecimal
highEndMinPrice
=
getConfigPrice
(
CONFIG_HIGH_END_MIN_PRICE
,
DEFAULT_HIGH_END_MIN_PRICE
);
BigDecimal
midRangeMinPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MIN_PRICE
,
DEFAULT_MID_RANGE_MIN_PRICE
);
BigDecimal
midRangeMaxPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MAX_PRICE
,
DEFAULT_MID_RANGE_MAX_PRICE
);
BigDecimal
lowEndMaxPrice
=
getConfigPrice
(
CONFIG_LOW_END_MAX_PRICE
,
DEFAULT_LOW_END_MAX_PRICE
);
// 高端车型:价格 >= 高端最低价
if
(
price
.
compareTo
(
highEndMinPrice
)
>=
0
)
{
return
CustomerTagEnum
.
HIGH_END
;
}
// 中端车型:中端最低价 <= 价格 < 中端最高价
boolean
matchMidMin
=
price
.
compareTo
(
midRangeMinPrice
)
>=
0
;
boolean
matchMidMax
=
price
.
compareTo
(
midRangeMaxPrice
)
<
0
;
if
(
matchMidMin
&&
matchMidMax
)
{
return
CustomerTagEnum
.
MID_RANGE
;
}
// 低端车型:价格 < 低端最高价
if
(
price
.
compareTo
(
lowEndMaxPrice
)
<
0
)
{
return
CustomerTagEnum
.
LOW_END
;
}
log
.
warn
(
"价格未匹配任何标签区间:price={}, highEndMinPrice={}, midRangeMinPrice={}, midRangeMaxPrice={}, lowEndMaxPrice={}"
,
price
,
highEndMinPrice
,
midRangeMinPrice
,
midRangeMaxPrice
,
lowEndMaxPrice
);
return
null
;
}
/**
* 从配置读取价格值
*
* @param configKey 配置key
* @param defaultValue 默认值
* @return 价格值
*/
private
BigDecimal
getConfigPrice
(
String
configKey
,
BigDecimal
defaultValue
)
{
String
value
=
env
.
getProperty
(
configKey
);
if
(
value
==
null
||
value
.
isEmpty
())
{
return
defaultValue
;
}
try
{
return
new
BigDecimal
(
value
);
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
"配置价格格式错误:key={}, value={}"
,
configKey
,
value
);
return
defaultValue
;
}
}
/**
* 获取价格区间描述
*
* @param tagEnum 标签枚举
* @return 价格区间描述,如 "大于25万"、"15万-25万"、"小于15万"
*/
private
String
getPriceRangeDesc
(
CustomerTagEnum
tagEnum
)
{
if
(
tagEnum
==
null
)
{
return
""
;
}
BigDecimal
highEndMinPrice
=
getConfigPrice
(
CONFIG_HIGH_END_MIN_PRICE
,
DEFAULT_HIGH_END_MIN_PRICE
);
BigDecimal
midRangeMinPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MIN_PRICE
,
DEFAULT_MID_RANGE_MIN_PRICE
);
BigDecimal
midRangeMaxPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MAX_PRICE
,
DEFAULT_MID_RANGE_MAX_PRICE
);
BigDecimal
lowEndMaxPrice
=
getConfigPrice
(
CONFIG_LOW_END_MAX_PRICE
,
DEFAULT_LOW_END_MAX_PRICE
);
switch
(
tagEnum
)
{
case
HIGH_END:
int
highWan
=
highEndMinPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
return
"大于"
+
highWan
+
"万"
;
case
MID_RANGE:
int
minWan
=
midRangeMinPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
int
maxWan
=
midRangeMaxPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
return
minWan
+
"万-"
+
maxWan
+
"万"
;
case
LOW_END:
int
lowWan
=
lowEndMaxPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
return
"小于"
+
lowWan
+
"万"
;
default
:
return
""
;
}
}
/**
* 计算平均价格
* 计算平均价格
*
*
* @param carSeriesDetail 车系详情
* @param carSeriesDetail 车系详情
...
@@ -157,13 +291,13 @@ public class CustomerTagProfileService {
...
@@ -157,13 +291,13 @@ public class CustomerTagProfileService {
* @param avgPrice 平均价格
* @param avgPrice 平均价格
* @return 评分依据
* @return 评分依据
*/
*/
private
String
buildScoreBasis
(
Archive
TagEnum
tagEnum
,
CarSeriesDetailDTO
carSeriesDetail
,
BigDecimal
avgPrice
)
{
private
String
buildScoreBasis
(
Customer
TagEnum
tagEnum
,
CarSeriesDetailDTO
carSeriesDetail
,
BigDecimal
avgPrice
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
carSeriesDetail
.
getCarseries
()
!=
null
?
carSeriesDetail
.
getCarseries
()
:
"未知车系"
);
sb
.
append
(
carSeriesDetail
.
getCarseries
()
!=
null
?
carSeriesDetail
.
getCarseries
()
:
"未知车系"
);
sb
.
append
(
","
);
sb
.
append
(
","
);
sb
.
append
(
tagEnum
.
getDesc
());
sb
.
append
(
tagEnum
.
getDesc
());
sb
.
append
(
"("
);
sb
.
append
(
"("
);
sb
.
append
(
tagEnum
.
getPriceRangeDesc
(
));
sb
.
append
(
getPriceRangeDesc
(
tagEnum
));
sb
.
append
(
"),均价:"
);
sb
.
append
(
"),均价:"
);
sb
.
append
(
avgPrice
.
divide
(
new
BigDecimal
(
"10000"
),
2
,
BigDecimal
.
ROUND_HALF_UP
));
sb
.
append
(
avgPrice
.
divide
(
new
BigDecimal
(
"10000"
),
2
,
BigDecimal
.
ROUND_HALF_UP
));
sb
.
append
(
"万"
);
sb
.
append
(
"万"
);
...
...
rpc-dj-strategy/src/main/java/cn/com/glsx/dj/strategy/service/CustomerTagProfileSyncService.java
View file @
a2f2111
...
@@ -3,7 +3,7 @@ package cn.com.glsx.dj.strategy.service;
...
@@ -3,7 +3,7 @@ package cn.com.glsx.dj.strategy.service;
import
cn.com.glsx.dj.smartcarlife.dto.CustomerProfileInfoDTO
;
import
cn.com.glsx.dj.smartcarlife.dto.CustomerProfileInfoDTO
;
import
cn.com.glsx.dj.smartcarlife.remote.CustomerInfoRemote
;
import
cn.com.glsx.dj.smartcarlife.remote.CustomerInfoRemote
;
import
cn.com.glsx.dj.strategy.dto.CarSeriesDetailDTO
;
import
cn.com.glsx.dj.strategy.dto.CarSeriesDetailDTO
;
import
cn.com.glsx.dj.strategy.enums.
Archive
TagEnum
;
import
cn.com.glsx.dj.strategy.enums.
Customer
TagEnum
;
import
cn.com.glsx.dj.strategy.mapper.CustomerTagProfileMapper
;
import
cn.com.glsx.dj.strategy.mapper.CustomerTagProfileMapper
;
import
cn.com.glsx.dj.strategy.model.CustomerTagProfile
;
import
cn.com.glsx.dj.strategy.model.CustomerTagProfile
;
import
cn.com.glsx.dj.strategy.util.GopApiUtil
;
import
cn.com.glsx.dj.strategy.util.GopApiUtil
;
...
@@ -12,6 +12,7 @@ import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
...
@@ -12,6 +12,7 @@ import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
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.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -52,8 +53,52 @@ public class CustomerTagProfileSyncService {
...
@@ -52,8 +53,52 @@ public class CustomerTagProfileSyncService {
*/
*/
private
static
final
int
DEFAULT_SCORE
=
1
;
private
static
final
int
DEFAULT_SCORE
=
1
;
/**
* 高端车型最低价格配置key
*/
private
static
final
String
CONFIG_HIGH_END_MIN_PRICE
=
"archive.tag.high-end.min-price"
;
/**
* 中端车型最低价格配置key
*/
private
static
final
String
CONFIG_MID_RANGE_MIN_PRICE
=
"archive.tag.mid-range.min-price"
;
/**
* 中端车型最高价格配置key
*/
private
static
final
String
CONFIG_MID_RANGE_MAX_PRICE
=
"archive.tag.mid-range.max-price"
;
/**
* 低端车型最高价格配置key
*/
private
static
final
String
CONFIG_LOW_END_MAX_PRICE
=
"archive.tag.low-end.max-price"
;
/**
* 默认高端车型最低价格(元)
*/
private
static
final
BigDecimal
DEFAULT_HIGH_END_MIN_PRICE
=
new
BigDecimal
(
"250001"
);
/**
* 默认中端车型最低价格(元)
*/
private
static
final
BigDecimal
DEFAULT_MID_RANGE_MIN_PRICE
=
new
BigDecimal
(
"150000"
);
/**
* 默认中端车型最高价格(元)
*/
private
static
final
BigDecimal
DEFAULT_MID_RANGE_MAX_PRICE
=
new
BigDecimal
(
"250001"
);
/**
* 默认低端车型最高价格(元)
*/
private
static
final
BigDecimal
DEFAULT_LOW_END_MAX_PRICE
=
new
BigDecimal
(
"150000"
);
@Autowired
private
Environment
env
;
@Autowired
@Autowired
private
CustomerInfoRemote
customerInfoRemote
;
private
CustomerInfoRemote
customerInfoRemote
;
@Autowired
@Autowired
private
CustomerTagProfileMapper
customerTagProfileMapper
;
private
CustomerTagProfileMapper
customerTagProfileMapper
;
...
@@ -204,7 +249,7 @@ public class CustomerTagProfileSyncService {
...
@@ -204,7 +249,7 @@ public class CustomerTagProfileSyncService {
}
}
// 根据价格获取标签枚举
// 根据价格获取标签枚举
ArchiveTagEnum
tagEnum
=
ArchiveTagEnum
.
get
ByPrice
(
avgPrice
);
CustomerTagEnum
tagEnum
=
getTag
ByPrice
(
avgPrice
);
if
(
tagEnum
==
null
)
{
if
(
tagEnum
==
null
)
{
log
.
info
(
"无法匹配车型标签,跳过:phone={}, avgPrice={}"
,
phone
,
avgPrice
);
log
.
info
(
"无法匹配车型标签,跳过:phone={}, avgPrice={}"
,
phone
,
avgPrice
);
result
.
setSkipCount
(
result
.
getSkipCount
()
+
1
);
result
.
setSkipCount
(
result
.
getSkipCount
()
+
1
);
...
@@ -233,6 +278,96 @@ public class CustomerTagProfileSyncService {
...
@@ -233,6 +278,96 @@ public class CustomerTagProfileSyncService {
}
}
/**
/**
* 根据价格获取对应的标签枚举
*
* @param price 价格,单位:元
* @return 标签枚举,如果价格不在任何区间则返回 null
*/
private
CustomerTagEnum
getTagByPrice
(
BigDecimal
price
)
{
if
(
price
==
null
)
{
return
null
;
}
BigDecimal
highEndMinPrice
=
getConfigPrice
(
CONFIG_HIGH_END_MIN_PRICE
,
DEFAULT_HIGH_END_MIN_PRICE
);
BigDecimal
midRangeMinPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MIN_PRICE
,
DEFAULT_MID_RANGE_MIN_PRICE
);
BigDecimal
midRangeMaxPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MAX_PRICE
,
DEFAULT_MID_RANGE_MAX_PRICE
);
BigDecimal
lowEndMaxPrice
=
getConfigPrice
(
CONFIG_LOW_END_MAX_PRICE
,
DEFAULT_LOW_END_MAX_PRICE
);
// 高端车型:价格 >= 高端最低价
if
(
price
.
compareTo
(
highEndMinPrice
)
>=
0
)
{
return
CustomerTagEnum
.
HIGH_END
;
}
// 中端车型:中端最低价 <= 价格 < 中端最高价
boolean
matchMidMin
=
price
.
compareTo
(
midRangeMinPrice
)
>=
0
;
boolean
matchMidMax
=
price
.
compareTo
(
midRangeMaxPrice
)
<
0
;
if
(
matchMidMin
&&
matchMidMax
)
{
return
CustomerTagEnum
.
MID_RANGE
;
}
// 低端车型:价格 < 低端最高价
if
(
price
.
compareTo
(
lowEndMaxPrice
)
<
0
)
{
return
CustomerTagEnum
.
LOW_END
;
}
log
.
warn
(
"价格未匹配任何标签区间:price={}, highEndMinPrice={}, midRangeMinPrice={}, midRangeMaxPrice={}, lowEndMaxPrice={}"
,
price
,
highEndMinPrice
,
midRangeMinPrice
,
midRangeMaxPrice
,
lowEndMaxPrice
);
return
null
;
}
/**
* 从配置读取价格值
*
* @param configKey 配置key
* @param defaultValue 默认值
* @return 价格值
*/
private
BigDecimal
getConfigPrice
(
String
configKey
,
BigDecimal
defaultValue
)
{
String
value
=
env
.
getProperty
(
configKey
);
if
(
value
==
null
||
value
.
isEmpty
())
{
return
defaultValue
;
}
try
{
return
new
BigDecimal
(
value
);
}
catch
(
NumberFormatException
e
)
{
log
.
warn
(
"配置价格格式错误:key={}, value={}"
,
configKey
,
value
);
return
defaultValue
;
}
}
/**
* 获取价格区间描述
*
* @param tagEnum 标签枚举
* @return 价格区间描述,如 "大于25万"、"15万-25万"、"小于15万"
*/
private
String
getPriceRangeDesc
(
CustomerTagEnum
tagEnum
)
{
if
(
tagEnum
==
null
)
{
return
""
;
}
BigDecimal
highEndMinPrice
=
getConfigPrice
(
CONFIG_HIGH_END_MIN_PRICE
,
DEFAULT_HIGH_END_MIN_PRICE
);
BigDecimal
midRangeMinPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MIN_PRICE
,
DEFAULT_MID_RANGE_MIN_PRICE
);
BigDecimal
midRangeMaxPrice
=
getConfigPrice
(
CONFIG_MID_RANGE_MAX_PRICE
,
DEFAULT_MID_RANGE_MAX_PRICE
);
BigDecimal
lowEndMaxPrice
=
getConfigPrice
(
CONFIG_LOW_END_MAX_PRICE
,
DEFAULT_LOW_END_MAX_PRICE
);
switch
(
tagEnum
)
{
case
HIGH_END:
int
highWan
=
highEndMinPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
return
"大于"
+
highWan
+
"万"
;
case
MID_RANGE:
int
minWan
=
midRangeMinPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
int
maxWan
=
midRangeMaxPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
return
minWan
+
"万-"
+
maxWan
+
"万"
;
case
LOW_END:
int
lowWan
=
lowEndMaxPrice
.
divide
(
new
BigDecimal
(
"10000"
),
0
,
BigDecimal
.
ROUND_DOWN
).
intValue
();
return
"小于"
+
lowWan
+
"万"
;
default
:
return
""
;
}
}
/**
* 计算平均价格
* 计算平均价格
*
*
* @param carSeriesDetail 车系详情
* @param carSeriesDetail 车系详情
...
@@ -268,13 +403,13 @@ public class CustomerTagProfileSyncService {
...
@@ -268,13 +403,13 @@ public class CustomerTagProfileSyncService {
* @param avgPrice 平均价格
* @param avgPrice 平均价格
* @return 评分依据
* @return 评分依据
*/
*/
private
String
buildScoreBasis
(
Archive
TagEnum
tagEnum
,
CarSeriesDetailDTO
carSeriesDetail
,
BigDecimal
avgPrice
)
{
private
String
buildScoreBasis
(
Customer
TagEnum
tagEnum
,
CarSeriesDetailDTO
carSeriesDetail
,
BigDecimal
avgPrice
)
{
StringBuilder
sb
=
new
StringBuilder
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
carSeriesDetail
.
getCarseries
()
!=
null
?
carSeriesDetail
.
getCarseries
()
:
"未知车系"
);
sb
.
append
(
carSeriesDetail
.
getCarseries
()
!=
null
?
carSeriesDetail
.
getCarseries
()
:
"未知车系"
);
sb
.
append
(
","
);
sb
.
append
(
","
);
sb
.
append
(
tagEnum
.
getDesc
());
sb
.
append
(
tagEnum
.
getDesc
());
sb
.
append
(
"("
);
sb
.
append
(
"("
);
sb
.
append
(
tagEnum
.
getPriceRangeDesc
(
));
sb
.
append
(
getPriceRangeDesc
(
tagEnum
));
sb
.
append
(
"),均价:"
);
sb
.
append
(
"),均价:"
);
sb
.
append
(
avgPrice
.
divide
(
new
BigDecimal
(
"10000"
),
2
,
BigDecimal
.
ROUND_HALF_UP
));
sb
.
append
(
avgPrice
.
divide
(
new
BigDecimal
(
"10000"
),
2
,
BigDecimal
.
ROUND_HALF_UP
));
sb
.
append
(
"万"
);
sb
.
append
(
"万"
);
...
...
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