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
173aa1ab
Commit
173aa1ab
authored
Jul 31, 2024
by
zhangfeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单V值触发
parent
855d2135
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
192 additions
and
6 deletions
+192
-6
OrderInShippingEvent.java
...dao/framework/apollo/core/event/OrderInShippingEvent.java
+16
-0
TransportTypeEnum.java
.../iocoder/yudao/module/member/enums/TransportTypeEnum.java
+2
-2
pom.xml
yudao-module-member/yudao-module-member-impl/pom.xml
+5
-0
OrderInShippingListener.java
...yudao/module/member/listener/OrderInShippingListener.java
+138
-0
ScoreRuleService.java
...dao/module/member/service/scoreRule/ScoreRuleService.java
+7
-0
ScoreRuleServiceImpl.java
...module/member/service/scoreRule/ScoreRuleServiceImpl.java
+24
-4
No files found.
yudao-framework/yudao-spring-boot-starter-config/src/main/java/cn/iocoder/yudao/framework/apollo/core/event/OrderInShippingEvent.java
0 → 100644
View file @
173aa1ab
package
cn
.
iocoder
.
yudao
.
framework
.
apollo
.
core
.
event
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
/**
* 订单起运事件
*
* @author zhangfeng
*/
@Data
@AllArgsConstructor
public
class
OrderInShippingEvent
{
private
Long
orderId
;
private
String
orderNo
;
}
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/TransportType.java
→
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/TransportType
Enum
.java
View file @
173aa1ab
package
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
;
package
cn
.
iocoder
.
yudao
.
module
.
member
.
enums
;
public
enum
TransportType
{
public
enum
TransportType
Enum
{
OCEAN_LCL
(
1
,
"海运拼柜"
),
OCEAN_LCL
(
1
,
"海运拼柜"
),
SPECIAL_LINE_AIR_FREIGHT
(
3
,
"专线空运"
);
SPECIAL_LINE_AIR_FREIGHT
(
3
,
"专线空运"
);
...
@@ -8,7 +8,7 @@ public enum TransportType {
...
@@ -8,7 +8,7 @@ public enum TransportType {
private
final
String
name
;
private
final
String
name
;
TransportType
(
int
value
,
String
name
)
{
TransportType
Enum
(
int
value
,
String
name
)
{
this
.
value
=
value
;
this
.
value
=
value
;
this
.
name
=
name
;
this
.
name
=
name
;
}
}
...
...
yudao-module-member/yudao-module-member-impl/pom.xml
View file @
173aa1ab
...
@@ -49,5 +49,10 @@
...
@@ -49,5 +49,10 @@
<artifactId>
yudao-module-depository-core
</artifactId>
<artifactId>
yudao-module-depository-core
</artifactId>
<version>
${revision}
</version>
<version>
${revision}
</version>
</dependency>
</dependency>
<dependency>
<groupId>
cn.iocoder.boot
</groupId>
<artifactId>
yudao-module-order-core
</artifactId>
<version>
${revision}
</version>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/listener/OrderInShippingListener.java
0 → 100644
View file @
173aa1ab
package
cn
.
iocoder
.
yudao
.
module
.
member
.
listener
;
import
cn.hutool.core.util.ArrayUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.iocoder.yudao.framework.apollo.core.event.OrderInShippingEvent
;
import
cn.iocoder.yudao.module.member.api.score.MemberUserScoreApi
;
import
cn.iocoder.yudao.module.member.api.score.dto.MemberUserScoreOperateReqDTO
;
import
cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO
;
import
cn.iocoder.yudao.module.member.enums.ScoreSourceTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.TransportTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.YesOrNoTypeEnum
;
import
cn.iocoder.yudao.module.member.service.memberUserScoreLog.MemberUserScoreLogService
;
import
cn.iocoder.yudao.module.member.service.scoreRule.ScoreRuleService
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.order.OrderDO
;
import
cn.iocoder.yudao.module.order.dal.dataobject.orderObjective.OrderObjectiveDO
;
import
cn.iocoder.yudao.module.order.enums.OrderStatusEnum
;
import
cn.iocoder.yudao.module.order.service.order.OrderService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.context.event.EventListener
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
@Component
@AllArgsConstructor
@Slf4j
public
class
OrderInShippingListener
{
@Resource
private
OrderService
orderService
;
@Resource
private
ScoreRuleService
scoreRuleService
;
@Resource
private
MemberUserScoreApi
memberUserScoreApi
;
@Resource
private
MemberUserScoreLogService
memberUserScoreLogService
;
@EventListener
(
OrderInShippingEvent
.
class
)
public
void
listen
(
OrderInShippingEvent
event
)
{
Long
orderId
=
event
.
getOrderId
();
String
orderNo
=
event
.
getOrderNo
();
OrderDO
orderDO
;
if
(
orderId
!=
null
)
{
orderDO
=
orderService
.
getById
(
orderId
);
}
else
{
orderDO
=
orderService
.
selectOne
(
new
LambdaQueryWrapper
<
OrderDO
>().
eq
(
OrderDO:
:
getOrderNo
,
orderNo
).
last
(
"limit 1"
));
}
if
(
Objects
.
isNull
(
orderDO
))
{
log
.
error
(
"Order in shipping listening error: The order does not exist,orderId:{},orderNo:{}"
,
orderId
,
orderNo
);
}
// 目的地信息
OrderObjectiveDO
orderObjectiveDO
=
orderDO
.
getOrderObjectiveDO
();
// 订单状态应为起运
if
(!
Objects
.
equals
(
orderDO
.
getStatus
(),
OrderStatusEnum
.
IN_SHIPPING
.
getValue
()))
{
return
;
}
// 判断海运空运
Integer
transportId
=
orderDO
.
getTransportId
();
ScoreRuleDO
scoreRuleDO
=
scoreRuleService
.
getEnabledOrderVScoreRuleByTransportType
(
transportId
);
if
(
Objects
.
isNull
(
scoreRuleDO
))
{
log
.
info
(
"No score rule match"
);
return
;
}
// 是否过期
if
(
scoreRuleDO
.
getEndTime
().
after
(
new
Date
()))
{
log
.
info
(
"The score rule has expired"
);
return
;
}
ScoreRuleOrderVExtraVO
extraInfo
=
JSONUtil
.
toBean
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
);
// 是否首单,首单只加一次
if
(
extraInfo
.
getFirstOrder
()
==
YesOrNoTypeEnum
.
YES
.
ordinal
()){
Long
count
=
orderService
.
selectCount
(
new
LambdaQueryWrapper
<
OrderDO
>().
eq
(
OrderDO:
:
getUserId
,
orderDO
.
getUserId
()));
if
(
count
>
1
)
{
log
.
info
(
"Not first order"
);
return
;
}
}
// 提货点是否包含
String
[]
warehouseIds
=
extraInfo
.
getReceiveAddr
().
split
(
","
);
if
(!
ArrayUtil
.
contains
(
warehouseIds
,
orderObjectiveDO
.
getObjectiveWarehouseId
().
toString
()))
{
return
;
}
// 计算积分
Integer
scoreCount
=
0
;
List
<
ScoreRuleOrderVExtraVO
.
OrderVRule
>
orderVRule
=
extraInfo
.
getOrderVRule
();
if
(
transportId
==
TransportTypeEnum
.
OCEAN_LCL
.
getValue
())
{
// 海运算重量
BigDecimal
orgVWeight
=
orderDO
.
getOrgVWeight
();
int
w
=
orgVWeight
.
setScale
(
0
,
RoundingMode
.
HALF_UP
).
intValue
();
for
(
ScoreRuleOrderVExtraVO
.
OrderVRule
rule
:
orderVRule
)
{
if
(
rule
.
getLow
()
<=
w
&&
rule
.
getHigh
()
>=
w
)
{
scoreCount
=
rule
.
getScore
();
break
;
}
}
}
else
if
(
transportId
==
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
// 空运校验渠道
// 渠道id
Long
channelId
=
orderDO
.
getChannelId
();
String
[]
channels
=
extraInfo
.
getChannel
().
split
(
","
);
if
(!
ArrayUtil
.
contains
(
channels
,
channelId
.
toString
()))
{
return
;
}
// 空运算体积
BigDecimal
orgWVolume
=
orderDO
.
getOrgWVolume
();
int
v
=
orgWVolume
.
setScale
(
0
,
RoundingMode
.
HALF_UP
).
intValue
();
for
(
ScoreRuleOrderVExtraVO
.
OrderVRule
rule
:
orderVRule
)
{
if
(
rule
.
getLow
()
<=
v
&&
rule
.
getHigh
()
>=
v
)
{
scoreCount
=
rule
.
getScore
();
break
;
}
}
}
if
(
scoreCount
>
scoreRuleDO
.
getGetScoreOnce
()){
scoreCount
=
scoreRuleDO
.
getGetScoreOnce
();
}
// 校验累计最高分,查member_user_score_log
// 增加积分
// 会员id
Long
userId
=
orderDO
.
getUserId
();
memberUserScoreApi
.
operateScore
(
MemberUserScoreOperateReqDTO
.
builder
()
.
memberId
(
userId
)
.
scoreCount
(
scoreCount
)
.
sourceType
(
ScoreSourceTypeEnum
.
EXCHANGE_REWARD
)
.
ruleId
(
scoreRuleDO
.
getId
())
.
expireDays
(
scoreRuleDO
.
getScorePeriod
())
.
build
()
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreRule/ScoreRuleService.java
View file @
173aa1ab
...
@@ -87,4 +87,11 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
...
@@ -87,4 +87,11 @@ public interface ScoreRuleService extends IService<ScoreRuleDO> {
* @return
* @return
*/
*/
void
delayScoreRule
(
ScoreDelayReqVO
scoreDelayReqVO
);
void
delayScoreRule
(
ScoreDelayReqVO
scoreDelayReqVO
);
/**
* 根据运输方式获取已启用订单V值规则
* @param transportType
* @return
*/
ScoreRuleDO
getEnabledOrderVScoreRuleByTransportType
(
Integer
transportType
);
}
}
yudao-module-member/yudao-module-member-impl/src/main/java/cn/iocoder/yudao/module/member/service/scoreRule/ScoreRuleServiceImpl.java
View file @
173aa1ab
...
@@ -4,6 +4,7 @@ import java.time.Instant;
...
@@ -4,6 +4,7 @@ import java.time.Instant;
import
java.util.*
;
import
java.util.*
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.hutool.json.JSONUtil
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.common.pojo.PageResult
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery
;
import
cn.iocoder.yudao.framework.mybatis.core.query.LambdaQuery
;
...
@@ -13,7 +14,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
...
@@ -13,7 +14,7 @@ import cn.iocoder.yudao.module.member.dal.dataobject.scoreRule.ScoreRuleDO;
import
cn.iocoder.yudao.module.member.dal.mysql.scoreRule.ScoreRuleMapper
;
import
cn.iocoder.yudao.module.member.dal.mysql.scoreRule.ScoreRuleMapper
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleStatusEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleStatusEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.ScoreRuleTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.TransportType
;
import
cn.iocoder.yudao.module.member.enums.TransportType
Enum
;
import
cn.iocoder.yudao.module.member.enums.YesOrNoTypeEnum
;
import
cn.iocoder.yudao.module.member.enums.YesOrNoTypeEnum
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.*
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.*
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO
;
import
cn.iocoder.yudao.module.member.vo.scoreRule.extra.ScoreRuleOrderVExtraVO
;
...
@@ -44,7 +45,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
...
@@ -44,7 +45,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
@Override
@Override
public
Long
createScoreRule
(
ScoreRuleCreateReqVO
createReqVO
)
{
public
Long
createScoreRule
(
ScoreRuleCreateReqVO
createReqVO
)
{
ScoreRuleDO
scoreRule
=
ScoreRuleConvert
.
INSTANCE
.
convert
(
createReqVO
);
ScoreRuleDO
scoreRule
=
ScoreRuleConvert
.
INSTANCE
.
convert
(
createReqVO
);
if
(
scoreRule
.
getStatus
()
!=
ScoreRuleStatusEnum
.
DISABLED
.
getValue
()
&&
scoreRule
.
getStatus
()
!=
ScoreRuleStatusEnum
.
ENABLED
.
getValue
()){
if
(
scoreRule
.
getStatus
()
!=
ScoreRuleStatusEnum
.
DISABLED
.
getValue
()
&&
scoreRule
.
getStatus
()
!=
ScoreRuleStatusEnum
.
ENABLED
.
getValue
())
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
}
verifyCommon
(
createReqVO
);
verifyCommon
(
createReqVO
);
...
@@ -80,7 +81,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
...
@@ -80,7 +81,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
}
Integer
transportType
=
extraOrderV
.
getTransportType
();
Integer
transportType
=
extraOrderV
.
getTransportType
();
if
(
transportType
!=
TransportType
.
OCEAN_LCL
.
getValue
()
&&
transportType
!=
TransportType
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
if
(
transportType
!=
TransportType
Enum
.
OCEAN_LCL
.
getValue
()
&&
transportType
!=
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
}
List
<
ScoreRuleDO
>
scoreRuleDOS
=
scoreRuleMapper
.
selectList
(
scoreRuleDOLambdaQuery
);
List
<
ScoreRuleDO
>
scoreRuleDOS
=
scoreRuleMapper
.
selectList
(
scoreRuleDOLambdaQuery
);
...
@@ -134,7 +135,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
...
@@ -134,7 +135,7 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
if
(
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
YES
.
ordinal
()
&&
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
NO
.
ordinal
())
{
if
(
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
YES
.
ordinal
()
&&
extraOrderV
.
getFirstOrder
()
!=
YesOrNoTypeEnum
.
NO
.
ordinal
())
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
}
if
(
extraOrderV
.
getTransportType
()
!=
TransportType
.
OCEAN_LCL
.
getValue
()
&&
extraOrderV
.
getTransportType
()
!=
TransportType
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
if
(
extraOrderV
.
getTransportType
()
!=
TransportType
Enum
.
OCEAN_LCL
.
getValue
()
&&
extraOrderV
.
getTransportType
()
!=
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
}
if
(
StringUtils
.
isAnyBlank
(
extraOrderV
.
getTargetCountry
(),
extraOrderV
.
getTargetCity
(),
extraOrderV
.
getReceiveAddr
(),
extraOrderV
.
getOrderEntry
()))
{
if
(
StringUtils
.
isAnyBlank
(
extraOrderV
.
getTargetCountry
(),
extraOrderV
.
getTargetCity
(),
extraOrderV
.
getReceiveAddr
(),
extraOrderV
.
getOrderEntry
()))
{
...
@@ -324,4 +325,23 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
...
@@ -324,4 +325,23 @@ public class ScoreRuleServiceImpl extends AbstractService<ScoreRuleMapper, Score
upScoreRuleDO
.
setEndTime
(
delayReqVO
.
getEndTime
());
upScoreRuleDO
.
setEndTime
(
delayReqVO
.
getEndTime
());
scoreRuleMapper
.
updateById
(
upScoreRuleDO
);
scoreRuleMapper
.
updateById
(
upScoreRuleDO
);
}
}
@Override
public
ScoreRuleDO
getEnabledOrderVScoreRuleByTransportType
(
Integer
transportType
)
{
if
(
transportType
!=
TransportTypeEnum
.
OCEAN_LCL
.
getValue
()
&&
transportType
!=
TransportTypeEnum
.
SPECIAL_LINE_AIR_FREIGHT
.
getValue
())
{
throw
exception
(
SCORE_RULE_FIELD_ERROR
);
}
LambdaQuery
<
ScoreRuleDO
>
lambdaQuery
=
new
LambdaQuery
<>();
lambdaQuery
.
eq
(
ScoreRuleDO:
:
getStatus
,
ScoreRuleStatusEnum
.
ENABLED
.
getValue
())
.
eq
(
ScoreRuleDO:
:
getType
,
ScoreRuleTypeEnum
.
ORDER_V
.
getValue
());
List
<
ScoreRuleDO
>
scoreRuleDOS
=
scoreRuleMapper
.
selectList
(
lambdaQuery
);
if
(!
CollectionUtil
.
isEmpty
(
scoreRuleDOS
))
{
for
(
ScoreRuleDO
scoreRuleDO
:
scoreRuleDOS
)
{
if
(
Objects
.
equals
(
JSONUtil
.
toBean
(
scoreRuleDO
.
getExtra
(),
ScoreRuleOrderVExtraVO
.
class
).
getTransportType
(),
transportType
))
{
return
scoreRuleDO
;
}
}
}
return
null
;
}
}
}
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