Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jiedao-api-boot-master
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lanbaoming
jiedao-api-boot-master
Commits
921ced92
Commit
921ced92
authored
Oct 17, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(601): 订单V值启用规则修改
parent
7469b864
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
136 additions
and
25 deletions
+136
-25
ScoreRuleServiceImpl.java
...module/member/service/scoreRule/ScoreRuleServiceImpl.java
+134
-23
messages_en.properties
yudao-server/src/main/resources/i18n/messages_en.properties
+1
-1
messages_zh.properties
yudao-server/src/main/resources/i18n/messages_zh.properties
+1
-1
No files found.
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreRule/ScoreRuleServiceImpl.java
View file @
921ced92
...
...
@@ -48,6 +48,8 @@ import java.util.stream.Collectors;
import
static
cn
.
iocoder
.
yudao
.
framework
.
common
.
exception
.
util
.
ServiceExceptionUtil
.
exception
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
ErrorCodeConstants
.*;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
TransportTypeEnum
.
OCEAN_LCL
;
import
static
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
.
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
;
/**
* 积分规则 Service 实现类
...
...
@@ -108,25 +110,25 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
throw
exception
(
SCORE_RULE_EXTRA_ERROR
);
}
Integer
transportType
=
extraOrderV
.
getTransportType
();
if
(
transportType
!=
TransportTypeEnum
.
OCEAN_LCL
.
getValue
()
&&
transportType
!=
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
if
(
transportType
!=
OCEAN_LCL
.
getValue
()
&&
transportType
!=
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
throw
exception
(
SCORE_RULE_TRANSPORT_TYPE_ERROR
);
}
scoreRuleUniqueCheck
(
scoreRuleIn
.
getType
(),
transportType
,
scoreRuleIn
.
getStartTime
(),
scoreRuleIn
.
getEndTime
(),
null
);
orderVUniqueCheck
(
extraOrderV
,
scoreRuleIn
.
getStartTime
(),
scoreRuleIn
.
getEndTime
(),
null
);
}
else
{
scoreRuleUniqueCheck
(
scoreRuleIn
.
getType
(),
null
,
scoreRuleIn
.
getStartTime
(),
scoreRuleIn
.
getEndTime
(),
null
);
scoreRuleUniqueCheck
(
scoreRuleIn
.
getType
(),
scoreRuleIn
.
getStartTime
(),
scoreRuleIn
.
getEndTime
(),
null
);
}
}
}
/**
* 积分规则唯一性校验
* 积分规则唯一性校验
(订单V值单独校验)
*
* @param type 类型
* @param
transportType 运输类型(订单V值传)
* @param newScoreRule
Start 新积分规则开始
时间
* @param delayId 延期
时的规则
id
* @param
newScoreRuleStart 新规则的开始时间
* @param newScoreRule
End 新规则的结束
时间
* @param delayId 延期
规则的
id
*/
private
void
scoreRuleUniqueCheck
(
Integer
type
,
Integer
transportType
,
Date
newScoreRuleStart
,
Date
newScoreRuleEnd
,
Long
delayId
)
{
private
void
scoreRuleUniqueCheck
(
Integer
type
,
Date
newScoreRuleStart
,
Date
newScoreRuleEnd
,
Long
delayId
)
{
LambdaQuery
<
ScoreRuleDO
>
scoreRuleDOLambdaQuery
=
new
LambdaQuery
<>();
scoreRuleDOLambdaQuery
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
())
.
eq
(
ScoreRuleDO:
:
getType
,
type
);
...
...
@@ -137,22 +139,131 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
scoreRuleDOS
==
null
||
scoreRuleDOS
.
isEmpty
())
{
return
;
}
if
(
transportType
!=
null
)
{
for
(
ScoreRuleDO
scoreRuleDO
:
scoreRuleDOS
)
{
ScoreRuleOrderVExtraVO
bean
=
JSONUtil
.
toBean
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
);
if
(
Objects
.
equals
(
bean
.
getTransportType
(),
transportType
)
&&
verifyTimeOverlap
(
newScoreRuleStart
,
newScoreRuleEnd
,
scoreRuleDO
))
{
throw
exception
(
SCORE_RULE_UNIQUE_CHECK_ERROR
);
if
(
verifyTimeOverlap
(
newScoreRuleStart
,
newScoreRuleEnd
,
scoreRuleDO
))
{
throw
exception
(
SCORE_RULE_UNIQUE_CHECK_ERROR
,
scoreRuleDO
.
getCode
());
}
}
}
else
{
}
/**
* 订单V规则唯一性校验
*
* @param extraOrderV 订单v值额外信息
* @param newScoreRuleStart 新规则的开始时间
* @param newScoreRuleEnd 新规则的结束时间
* @param delayId 延期时的规则id
*/
private
void
orderVUniqueCheck
(
ScoreRuleOrderVExtraVO
extraOrderV
,
Date
newScoreRuleStart
,
Date
newScoreRuleEnd
,
Long
delayId
)
{
LambdaQuery
<
ScoreRuleDO
>
scoreRuleDOLambdaQuery
=
new
LambdaQuery
<>();
scoreRuleDOLambdaQuery
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
())
.
eq
(
ScoreRuleDO:
:
getType
,
ScoreRuleTypeEnum
.
ORDER_V
.
getValue
());
if
(
delayId
!=
null
)
{
scoreRuleDOLambdaQuery
.
ne
(
ScoreRuleDO:
:
getId
,
delayId
);
}
List
<
ScoreRuleDO
>
scoreRuleDOS
=
scoreRuleMapper
.
selectList
(
scoreRuleDOLambdaQuery
);
if
(
scoreRuleDOS
==
null
||
scoreRuleDOS
.
isEmpty
())
{
return
;
}
for
(
ScoreRuleDO
scoreRuleDO
:
scoreRuleDOS
)
{
if
(
verifyTimeOverlap
(
newScoreRuleStart
,
newScoreRuleEnd
,
scoreRuleDO
))
{
throw
exception
(
SCORE_RULE_UNIQUE_CHECK_ERROR
);
ScoreRuleOrderVExtraVO
oldExtraVO
=
JSONUtil
.
toBean
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
);
if
(
verifyTimeOverlap
(
newScoreRuleStart
,
newScoreRuleEnd
,
scoreRuleDO
)
&&
isSameOrderVRule
(
oldExtraVO
,
extraOrderV
))
{
throw
exception
(
SCORE_RULE_UNIQUE_CHECK_ERROR
,
scoreRuleDO
.
getCode
());
}
}
}
private
boolean
isSameOrderVRule
(
ScoreRuleOrderVExtraVO
oldExtraVO
,
ScoreRuleOrderVExtraVO
extraOrderV
)
{
return
oldExtraVO
.
getTransportType
().
equals
(
extraOrderV
.
getTransportType
())
&&
Objects
.
equals
(
oldExtraVO
.
getFirstOrder
(),
extraOrderV
.
getFirstOrder
())
&&
verifyReceiveAddr
(
oldExtraVO
,
extraOrderV
)
&&
verifyChannel
(
oldExtraVO
,
extraOrderV
)
&&
verifyOrderEntry
(
oldExtraVO
.
getOrderEntry
(),
extraOrderV
.
getOrderEntry
());
}
private
boolean
verifyChannel
(
ScoreRuleOrderVExtraVO
oldExtraVO
,
ScoreRuleOrderVExtraVO
extraOrderV
)
{
// 运输方式空运时,判断渠道是否有交集
if
(
oldExtraVO
.
getTransportType
().
equals
(
SPECIAL_LINE_AIR_FREIGHT
.
getValue
()))
{
List
<
Long
>
oldChannel
=
oldExtraVO
.
getChannel
();
List
<
Long
>
newChannel
=
extraOrderV
.
getChannel
();
if
(
CollectionUtils
.
isEmpty
(
oldChannel
)
||
CollectionUtils
.
isEmpty
(
newChannel
))
{
return
false
;
}
return
CollectionUtils
.
containsAny
(
oldChannel
,
newChannel
);
}
return
false
;
}
private
boolean
verifyReceiveAddr
(
ScoreRuleOrderVExtraVO
oldExtraVO
,
ScoreRuleOrderVExtraVO
extraOrderV
)
{
List
<
String
>
oldReceiveAddrList
=
Arrays
.
asList
(
oldExtraVO
.
getReceiveAddr
().
split
(
","
));
List
<
String
>
newReceiveAddrList
=
new
ArrayList
<>();
// 如果是前端传入的,国家,城市,仓库id从receiveAddrList中获取
if
(
extraOrderV
.
getReceiveAddrList
()
!=
null
)
{
List
<
List
<
Long
>>
receiveAddrList
=
extraOrderV
.
getReceiveAddrList
();
if
(
extraOrderV
.
getReceiveAddrList
().
isEmpty
())
{
throw
exception
(
SCORE_RULE_RECEIVE_ADDRESS_ERROR
);
}
for
(
List
<
Long
>
integers
:
receiveAddrList
)
{
try
{
newReceiveAddrList
.
add
(
integers
.
get
(
2
).
toString
());
}
catch
(
Exception
e
)
{
throw
exception
(
SCORE_RULE_RECEIVE_ADDRESS_ERROR
);
}
}
}
else
{
newReceiveAddrList
=
Arrays
.
asList
(
extraOrderV
.
getReceiveAddr
().
split
(
","
));
}
// 如果有一个选的是全部,则返回true
if
(
oldReceiveAddrList
.
contains
(
"0"
)
||
newReceiveAddrList
.
contains
(
"0"
))
{
return
true
;
}
// 如果两个集合有交集,则返回true
return
CollectionUtils
.
containsAny
(
oldReceiveAddrList
,
newReceiveAddrList
);
}
private
boolean
verifyOrderEntry
(
String
oldOrderEntry
,
String
newOrderEntry
)
{
List
<
String
>
oldEntryList
=
Arrays
.
asList
(
oldOrderEntry
.
split
(
","
));
List
<
String
>
newEntryList
=
Arrays
.
asList
(
newOrderEntry
.
split
(
","
));
// 对订单入口进行归类后比较
Set
<
String
>
categorizedSources1
=
categorizeOrderEntry
(
oldEntryList
);
Set
<
String
>
categorizedSources2
=
categorizeOrderEntry
(
newEntryList
);
// 如果一个规则归类为 "ALL",则无论另一个是什么都算相同
if
(
categorizedSources1
.
contains
(
"ALL"
)
||
categorizedSources2
.
contains
(
"ALL"
))
{
return
true
;
}
// 仅当分类后的集合完全一致时才算相同
return
categorizedSources1
.
equals
(
categorizedSources2
);
}
private
Set
<
String
>
categorizeOrderEntry
(
List
<
String
>
orderEntrys
)
{
Set
<
String
>
categorizedSources
=
new
HashSet
<>();
boolean
hasBackend
=
false
;
boolean
hasClient
=
false
;
for
(
String
orderEntry
:
orderEntrys
)
{
if
(
orderEntry
.
equals
(
"1"
))
{
hasBackend
=
true
;
}
else
if
(
orderEntry
.
equals
(
"2"
)
||
orderEntry
.
equals
(
"3"
))
{
hasClient
=
true
;
}
}
// 如果同时有后台和客户端,归为 "ALL"
if
(
hasBackend
&&
hasClient
)
{
categorizedSources
.
add
(
"ALL"
);
}
else
{
if
(
hasBackend
)
{
categorizedSources
.
add
(
"BACKEND"
);
}
if
(
hasClient
)
{
categorizedSources
.
add
(
"CLIENT"
);
}
}
return
categorizedSources
;
}
/**
* 校验规则时间区间是否有交集
*/
...
...
@@ -194,7 +305,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
YES
.
ordinal
()
&&
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
NO
.
ordinal
())
{
throw
exception
(
SCORE_RULE_FIRST_ORDER_ERROR
);
}
if
(
extraOrderV
.
getTransportType
()
!=
TransportTypeEnum
.
OCEAN_LCL
.
getValue
()
&&
extraOrderV
.
getTransportType
()
!=
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
if
(
extraOrderV
.
getTransportType
()
!=
OCEAN_LCL
.
getValue
()
&&
extraOrderV
.
getTransportType
()
!=
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
throw
exception
(
SCORE_RULE_TRANSPORT_TYPE_ERROR
);
}
// 国家,城市,仓库id从receiveAddrList中获取
...
...
@@ -389,9 +500,9 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
scoreRuleDO
.
getType
()
!=
ScoreRuleTypeEnum
.
SHARE
.
getValue
())
{
if
(
scoreRuleDO
.
getType
()
==
ScoreRuleTypeEnum
.
ORDER_V
.
getValue
())
{
ScoreRuleOrderVExtraVO
extraOrderV
=
JSONUtil
.
toBean
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
);
scoreRuleUniqueCheck
(
scoreRuleDO
.
getType
(),
extraOrderV
.
getTransportType
()
,
scoreRuleDO
.
getStartTime
(),
scoreRuleDO
.
getEndTime
(),
null
);
orderVUniqueCheck
(
extraOrderV
,
scoreRuleDO
.
getStartTime
(),
scoreRuleDO
.
getEndTime
(),
null
);
}
else
{
scoreRuleUniqueCheck
(
scoreRuleDO
.
getType
(),
null
,
scoreRuleDO
.
getStartTime
(),
scoreRuleDO
.
getEndTime
(),
null
);
scoreRuleUniqueCheck
(
scoreRuleDO
.
getType
(),
scoreRuleDO
.
getStartTime
(),
scoreRuleDO
.
getEndTime
(),
null
);
}
}
upScoreRuleDO
.
setStatus
(
scoreRuleStatusReqVO
.
getStatus
());
...
...
@@ -435,9 +546,9 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
// 新时间区间规则唯一校验
if
(
scoreRuleDO
.
getType
()
==
ScoreRuleTypeEnum
.
ORDER_V
.
getValue
())
{
ScoreRuleOrderVExtraVO
extraOrderV
=
JSONUtil
.
toBean
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
);
scoreRuleUniqueCheck
(
scoreRuleDO
.
getType
(),
extraOrderV
.
getTransportType
()
,
scoreRuleDO
.
getStartTime
(),
delayReqVO
.
getEndTime
(),
scoreRuleDO
.
getId
());
orderVUniqueCheck
(
extraOrderV
,
scoreRuleDO
.
getStartTime
(),
delayReqVO
.
getEndTime
(),
scoreRuleDO
.
getId
());
}
else
{
scoreRuleUniqueCheck
(
scoreRuleDO
.
getType
(),
null
,
scoreRuleDO
.
getStartTime
(),
delayReqVO
.
getEndTime
(),
scoreRuleDO
.
getId
());
scoreRuleUniqueCheck
(
scoreRuleDO
.
getType
(),
scoreRuleDO
.
getStartTime
(),
delayReqVO
.
getEndTime
(),
scoreRuleDO
.
getId
());
}
ScoreRuleDO
upScoreRuleDO
=
new
ScoreRuleDO
();
upScoreRuleDO
.
setId
(
delayReqVO
.
getId
());
...
...
@@ -447,7 +558,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
@Override
public
ScoreRuleDO
getEnabledOrderVScoreRuleByTransportType
(
Integer
transportType
)
{
if
(
transportType
!=
TransportTypeEnum
.
OCEAN_LCL
.
getValue
()
&&
transportType
!=
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
if
(
transportType
!=
OCEAN_LCL
.
getValue
()
&&
transportType
!=
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
throw
exception
(
SCORE_RULE_TRANSPORT_TYPE_ERROR
);
}
LambdaQuery
<
ScoreRuleDO
>
lambdaQuery
=
new
LambdaQuery
<>();
...
...
yudao-server/src/main/resources/i18n/messages_en.properties
View file @
921ced92
...
...
@@ -1057,7 +1057,7 @@ score.rule.update.error = only disabled rule can update
score.rule.delete.error
=
only disabled rule can delete
score.rule.status.error
=
score rule status error
score.rule.status.not.enable
=
score rule status not enable
score.rule.unique.check.error
=
The same rule already exists during the validity period
score.rule.unique.check.error
=
The same rule already exists during the validity period
: {}
score.rule.transport.type.error
=
transport type error
score.rule.time.error
=
score rule time error
score.rule.period.error
=
score rule period error
...
...
yudao-server/src/main/resources/i18n/messages_zh.properties
View file @
921ced92
...
...
@@ -1058,7 +1058,7 @@ score.rule.update.error = \u53EA\u6709\u672A\u542F\u7528\u89C4\u5219\u53EF\u4EE5
score.rule.delete.error
=
\u
53EA
\u6709\u
672A
\u
542F
\u7528\u
53EF
\u
4EE5
\u5220\u9664
score.rule.status.error
=
\u
79EF
\u5206\u
89C4
\u5219\u
72B6
\u6001\u9519\u
8BEF
score.rule.status.not.enable
=
\u
79EF
\u5206\u
89C4
\u5219\u
672A
\u
542F
\u7528
score.rule.unique.check.error
=
\u6709\u6548\u
671F
\u5185\u
5DF2
\u
5B58
\u5728\u
76F8
\u
540C
\u
89C4
\u5219
score.rule.unique.check.error
=
\u6709\u6548\u
671F
\u5185\u
5DF2
\u
5B58
\u5728\u
76F8
\u
540C
\u
89C4
\u5219
\u
FF1A{}
score.rule.transport.type.error
=
\u
8FD0
\u
8F93
\u
7C7B
\u
578B
\u9519\u
8BEF
score.rule.time.error
=
\u
6D3B
\u
52A8
\u
65F6
\u
95F4
\u
4E0D
\u5408\u
6CD5
score.rule.period.error
=
\u
8FC7
\u
671F
\u
65F6
\u
95F4
\u9519\u
8BEF
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment