Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
order-group
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
order-group-application
order-group
Commits
150ae092
Commit
150ae092
authored
Jul 01, 2021
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug 修复 使用多券 核销
Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent
de80cc8c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
9 deletions
+45
-9
order-application-service/src/main/java/cn/freemud/enums/OrderAccountType.java
+15
-0
order-application-service/src/main/java/cn/freemud/service/coupon/impl/PlatformCouponRelationServiceImpl.java
+30
-9
No files found.
order-application-service/src/main/java/cn/freemud/enums/OrderAccountType.java
View file @
150ae092
...
...
@@ -13,6 +13,9 @@
package
cn
.
freemud
.
enums
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* 应该是下面这个type对应
* @see com.freemud.sdk.api.assortment.order.enums.OldOrderAccountType
...
...
@@ -39,6 +42,18 @@ public enum OrderAccountType {
private
String
desc
;
/**
* 需要 核销的 券 归类
* 代金券
* 商品券
* 运费全
* 折扣券
*/
public
static
List
<
Integer
>
verificationCoupon
=
Arrays
.
asList
(
OrderAccountType
.
COUPON
.
getCode
(),
OrderAccountType
.
PRODUCT_COUPON
.
getCode
(),
OrderAccountType
.
FREIGHT_COUPON
.
getCode
(),
OrderAccountType
.
DISCOUNT_COUPON
.
getCode
());
OrderAccountType
(
Integer
code
,
String
desc
)
{
this
.
code
=
code
;
this
.
desc
=
desc
;
...
...
order-application-service/src/main/java/cn/freemud/service/coupon/impl/PlatformCouponRelationServiceImpl.java
View file @
150ae092
...
...
@@ -40,10 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
(
"platformCouponRelationService"
)
...
...
@@ -64,7 +61,7 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
private
static
final
String
ORDER_RESOURCE_PUSH_LOG_ROUTING_KEY
=
"order-resource-push-log-routing-key"
;
@Value
(
"${baffleOpen.verification.coupon:false}"
)
private
Boolean
baffleOpen
=
false
;
private
Boolean
baffleOpen
=
false
;
@Override
public
BaseResponse
verificationCoupon
(
List
<
QueryOrdersResponseDto
.
DataBean
.
OrderBean
.
AccountBean
>
accountList
,
QueryOrdersResponseDto
.
DataBean
.
OrderBean
orderBean
,
CouponReqType
couponReqType
)
{
...
...
@@ -72,7 +69,9 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
if
(
CollectionUtils
.
isEmpty
(
accountList
))
{
return
ResponseUtil
.
success
();
}
if
(
accountList
.
size
()
>
1
)
{
// 需要判断 accountList 里面 是都 同时包含 配送券+ other券
boolean
isDoubleCoupon
=
checkAccountList
(
accountList
);
if
(
isDoubleCoupon
)
{
Integer
code
=
OrderAccountType
.
FREIGHT_COUPON
.
getCode
();
// 运费券 塞进 核销接口里面, 这里真的是贼恶心 逻辑不敢动
QueryOrdersResponseDto
.
DataBean
.
OrderBean
.
AccountBean
freightCouponAccountBean
=
accountList
.
stream
().
filter
(
accountBean
->
code
.
equals
(
accountBean
.
getType
())).
findFirst
().
orElse
(
null
);
...
...
@@ -91,6 +90,28 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
}
/**
* 要校验一遍是否 使用了 需要核销的券 代金券 商品券 运费全 折扣券 需要核销
*
* @param accountList 这里会传递 多张券 和其他的计算 类型
* @return
*/
private
boolean
checkAccountList
(
List
<
QueryOrdersResponseDto
.
DataBean
.
OrderBean
.
AccountBean
>
accountList
)
{
// 里面只有一个值 直接使用老逻辑 不管是 什么券
if
(
accountList
.
size
()
==
1
)
{
return
false
;
}
// 拿出 所有的使用券信息 代金券 商品券 运费全 折扣券 需要核销
int
count
=
0
;
for
(
QueryOrdersResponseDto
.
DataBean
.
OrderBean
.
AccountBean
accountBean
:
accountList
)
{
if
(
OrderAccountType
.
verificationCoupon
.
contains
(
accountBean
.
getType
())){
count
++;
}
}
// 说明使用了 2张以上的优惠券 需要核销
return
count
>
1
;
}
/**
* 原有逻辑没变动的基础上 加上 配送券信息对象
*
* @param couponCodeVerificationTransDto 配送券信息对象 如果为null 就是原来的逻辑
...
...
@@ -180,12 +201,12 @@ public class PlatformCouponRelationServiceImpl implements CouponRelationService
lastException
=
ex
;
ErrorLog
.
printErrorLog
(
"verification_error"
,
"/api"
,
couponCodeVerificationDto
,
ex
);
}
if
(
lastException
!=
null
){
if
(
lastException
!=
null
)
{
sendMessage
(
orderBean
,
LogThreadLocal
.
getTrackingNo
(),
couponCodeVerificationDto
,
lastException
);
}
else
if
(!
ok
||
Objects
.
equals
(
baffleOpen
,
true
))
{
}
else
if
(!
ok
||
Objects
.
equals
(
baffleOpen
,
true
))
{
sendMessage
(
orderBean
,
LogThreadLocal
.
getTrackingNo
(),
couponCodeVerificationDto
,
ok
?
"模拟券核销失败"
:
couponCodeResponseDto
);
}
if
(!
ok
){
if
(!
ok
)
{
emailAlertService
.
sendEmailAlert
(
"核销券码失败"
,
String
.
format
(
"request:%s \r\nresponse:%s"
,
JSONObject
.
toJSONString
(
couponCodeVerificationDto
),
JSONObject
.
toJSONString
(
lastException
==
null
?
couponCodeResponseDto
:
lastException
)));
return
ResponseUtil
.
error
(
ResponseResult
.
COUPON_VERIFICATION_FAIL
);
}
...
...
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