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
29df11f9
Commit
29df11f9
authored
Apr 18, 2022
by
胡敬轩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
多储值卡支付 listCartGoodsCheck接口改造
parent
cc28149a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
89 deletions
+56
-89
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+56
-89
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
29df11f9
...
@@ -1012,11 +1012,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1012,11 +1012,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/
*/
@Override
@Override
public
BaseResponse
getGoodsListCheck
(
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
)
{
public
BaseResponse
getGoodsListCheck
(
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
)
{
if
(
StringUtils
.
isBlank
(
shoppingCartInfoRequestVo
.
getCardCode
()))
{
List
<
String
>
cardCodes
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
shoppingCartInfoRequestVo
.
getCardCodes
())){
cardCodes
.
addAll
(
shoppingCartInfoRequestVo
.
getCardCodes
());
}
else
if
(
StringUtils
.
isNotBlank
(
shoppingCartInfoRequestVo
.
getCardCode
())){
cardCodes
.
add
(
shoppingCartInfoRequestVo
.
getCardCode
());
}
if
(
CollectionUtils
.
isEmpty
(
cardCodes
))
{
return
ResponseUtil
.
error
(
ResponseResult
.
PARAMETER_MISSING
);
return
ResponseUtil
.
error
(
ResponseResult
.
PARAMETER_MISSING
);
}
}
//打包带走外卖
//打包带走外卖
if
(
StringUtils
.
isNotBlank
(
shoppingCartInfoRequestVo
.
getCardCode
()
)
&&
Objects
.
equals
(
shoppingCartInfoRequestVo
.
getOrderType
(),
2
)
if
(
CollectionUtils
.
isNotEmpty
(
cardCodes
)
&&
Objects
.
equals
(
shoppingCartInfoRequestVo
.
getOrderType
(),
2
)
&&
StringUtils
.
isBlank
(
shoppingCartInfoRequestVo
.
getReceiveId
()))
{
&&
StringUtils
.
isBlank
(
shoppingCartInfoRequestVo
.
getReceiveId
()))
{
return
ResponseUtil
.
error
(
ResponseResult
.
PARAMETER_MISSING
);
return
ResponseUtil
.
error
(
ResponseResult
.
PARAMETER_MISSING
);
}
}
...
@@ -1034,7 +1040,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1034,7 +1040,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
BaseListCartGoodsVO
result
=
goodsList
.
getResult
();
BaseListCartGoodsVO
result
=
goodsList
.
getResult
();
//SVC卡支付
//SVC卡支付
SVCCardPay
(
shoppingCartInfoRequestVo
.
getCardCode
()
,
shoppingCartInfoRequestVo
.
getReceiveId
(),
partnerId
,
storeId
,
result
);
SVCCardPay
(
cardCodes
,
shoppingCartInfoRequestVo
.
getReceiveId
(),
partnerId
,
storeId
,
result
);
return
ResponseUtil
.
success
(
goodsList
.
getResult
());
return
ResponseUtil
.
success
(
goodsList
.
getResult
());
}
else
{
}
else
{
...
@@ -1045,7 +1051,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1045,7 +1051,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
=
goodsList
.
getResult
();
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
=
goodsList
.
getResult
();
//SVC卡支付
//SVC卡支付
SVCCardPay
(
shoppingCartInfoRequestVo
.
getCardCode
()
,
shoppingCartInfoRequestVo
.
getReceiveId
(),
partnerId
,
storeId
,
shoppingCartGoodsResponseVo
);
SVCCardPay
(
cardCodes
,
shoppingCartInfoRequestVo
.
getReceiveId
(),
partnerId
,
storeId
,
shoppingCartGoodsResponseVo
);
return
ResponseUtil
.
success
(
goodsList
.
getResult
());
return
ResponseUtil
.
success
(
goodsList
.
getResult
());
}
}
...
@@ -2512,16 +2518,16 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -2512,16 +2518,16 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
* 储值卡支付余额校验
* 储值卡支付余额校验
* 校验订单商品金额与外卖配送费
* 校验订单商品金额与外卖配送费
*/
*/
private
void
SVCCardPay
(
String
cardCode
,
String
receiveId
,
String
partnerId
,
String
storeId
,
private
void
SVCCardPay
(
List
<
String
>
cardCodes
,
String
receiveId
,
String
partnerId
,
String
storeId
,
BaseListCartGoodsVO
shoppingCartGoodsResponseVo
)
{
BaseListCartGoodsVO
shoppingCartGoodsResponseVo
)
{
if
(
StringUtils
.
isBlank
(
cardCode
))
{
if
(
CollectionUtils
.
isEmpty
(
cardCodes
))
{
return
;
return
;
}
}
Integer
orderAmount
=
shoppingCartGoodsResponseVo
.
getTotalAmount
().
intValue
();
Integer
orderAmount
=
shoppingCartGoodsResponseVo
.
getTotalAmount
().
intValue
();
String
trackingNo
=
LogThreadLocal
.
getTrackingNo
();
String
trackingNo
=
LogThreadLocal
.
getTrackingNo
();
SVCCardAmountRequest
request
=
new
SVCCardAmountRequest
();
SVCCardAmountRequest
request
=
new
SVCCardAmountRequest
();
request
.
setPartnerId
(
partnerId
);
request
.
setPartnerId
(
partnerId
);
request
.
setCardCodes
(
Arrays
.
asList
(
cardCode
)
);
request
.
setCardCodes
(
cardCodes
);
//查询svc卡金额
//查询svc卡金额
BaseResponse
<
SVCCardAmountResponse
>
response
=
svcAppClient
.
batchQueryCardAmount
(
request
);
BaseResponse
<
SVCCardAmountResponse
>
response
=
svcAppClient
.
batchQueryCardAmount
(
request
);
if
(
response
==
null
)
{
if
(
response
==
null
)
{
...
@@ -2530,67 +2536,47 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -2530,67 +2536,47 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if
(
response
.
getResult
()
==
null
||
CollectionUtils
.
isEmpty
(
response
.
getResult
().
getCardSimpleInfos
()))
{
if
(
response
.
getResult
()
==
null
||
CollectionUtils
.
isEmpty
(
response
.
getResult
().
getCardSimpleInfos
()))
{
throw
new
ServiceException
(
ResponseResult
.
USER_SVC_CARD_ERROR
);
throw
new
ServiceException
(
ResponseResult
.
USER_SVC_CARD_ERROR
);
}
}
boolean
check
=
this
.
checkSvcComPay
(
partnerId
,
storeId
);
Integer
applyType
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getApplyType
();
Integer
applyType
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getApplyType
();
applyType
=
applyType
==
null
?
3
:
applyType
;
applyType
=
applyType
==
null
?
3
:
applyType
;
String
svcDesc
=
applyType
==
3
?
"储值卡支付¥"
:
"礼品卡支付¥"
;
String
svcDesc
=
applyType
==
3
?
"储值卡支付¥"
:
"礼品卡支付¥"
;
if
(
check
)
{
int
totalAmount
=
response
.
getResult
().
getCardSimpleInfos
().
stream
().
mapToInt
(
CardSimpleInfo:
:
getAmount
).
sum
();
//混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付
int
totalVamount
=
response
.
getResult
().
getCardSimpleInfos
().
stream
().
mapToInt
(
CardSimpleInfo:
:
getVamount
).
sum
();
Integer
amount1
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getAmount
();
Integer
svcTotalAmount
=
totalAmount
+
totalVamount
;
Integer
vamount
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getVamount
();
//获取实际配送费
Integer
svcTotalAmount
=
amount1
+
vamount
;
Integer
deliveryAmount
=
0
;
//获取实际配送费
Integer
svcPayAmount
=
0
;
Integer
deliveryAmount
=
0
;
if
(
StringUtils
.
isNotBlank
(
receiveId
)
&&
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
()
!=
null
)
{
Integer
svcPayAmount
=
0
;
//Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
if
(
StringUtils
.
isNotBlank
(
receiveId
)
&&
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
()
!=
null
)
{
deliveryAmount
=
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
().
intValue
();
//Integer deliveryAmount = getDeliveryAmount(receiveId, partnerId, storeId);
orderAmount
+=
deliveryAmount
;
deliveryAmount
=
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
().
intValue
();
}
orderAmount
+=
deliveryAmount
;
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
>
orderAmount
)
{
}
svcPayAmount
=
orderAmount
;
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
>
orderAmount
)
{
svcPayAmount
=
orderAmount
;
shoppingCartGoodsResponseVo
.
setTotalAmount
(
0L
);
}
else
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
<=
orderAmount
)
{
svcPayAmount
=
svcTotalAmount
;
shoppingCartGoodsResponseVo
.
setTotalAmount
((
orderAmount
.
longValue
()
-
svcPayAmount
.
longValue
()));
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
svcPayAmount
);
String
amountStr
=
bigDecimal
.
divide
(
new
BigDecimal
(
100
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
shoppingCartGoodsResponseVo
.
setSvcPayAmount
(
amountStr
);
shoppingCartGoodsResponseVo
.
setSvcDiscountDesc
(
svcDesc
+
amountStr
);
}
else
{
//获取实际配送费
if
(
StringUtils
.
isNotBlank
(
receiveId
)
&&
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
()
!=
null
)
{
Integer
deliveryAmount
=
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
().
intValue
();
orderAmount
+=
deliveryAmount
;
}
Integer
amount1
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getAmount
();
Integer
vamount
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getVamount
();
if
(
orderAmount
>
amount1
+
vamount
)
{
throw
new
ServiceException
(
ResponseResult
.
USER_SVC_CARD_AMOUNT_DEFICIENCY
);
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
orderAmount
);
String
amountStr
=
bigDecimal
.
divide
(
new
BigDecimal
(
100
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
shoppingCartGoodsResponseVo
.
setTotalAmount
(
0L
);
shoppingCartGoodsResponseVo
.
setTotalAmount
(
0L
);
shoppingCartGoodsResponseVo
.
setSvcDiscountDesc
(
svcDesc
+
amountStr
);
}
else
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
<=
orderAmount
)
{
svcPayAmount
=
svcTotalAmount
;
shoppingCartGoodsResponseVo
.
setTotalAmount
((
orderAmount
.
longValue
()
-
svcPayAmount
.
longValue
()));
}
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
svcPayAmount
);
String
amountStr
=
bigDecimal
.
divide
(
new
BigDecimal
(
100
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
shoppingCartGoodsResponseVo
.
setSvcPayAmount
(
amountStr
);
shoppingCartGoodsResponseVo
.
setSvcDiscountDesc
(
svcDesc
+
amountStr
);
}
}
/**
/**
* 储值卡支付余额校验
* 储值卡支付余额校验
* 校验订单商品金额与外卖配送费
* 校验订单商品金额与外卖配送费
*/
*/
private
void
SVCCardPay
(
String
cardCode
,
String
receiveId
,
String
partnerId
,
String
storeId
,
private
void
SVCCardPay
(
List
<
String
>
cardCodes
,
String
receiveId
,
String
partnerId
,
String
storeId
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
)
{
if
(
StringUtils
.
isBlank
(
cardCode
))
{
if
(
CollectionUtils
.
isEmpty
(
cardCodes
))
{
return
;
return
;
}
}
Integer
orderAmount
=
shoppingCartGoodsResponseVo
.
getTotalAmount
().
intValue
();
Integer
orderAmount
=
shoppingCartGoodsResponseVo
.
getTotalAmount
().
intValue
();
String
trackingNo
=
LogThreadLocal
.
getTrackingNo
();
String
trackingNo
=
LogThreadLocal
.
getTrackingNo
();
SVCCardAmountRequest
request
=
new
SVCCardAmountRequest
();
SVCCardAmountRequest
request
=
new
SVCCardAmountRequest
();
request
.
setPartnerId
(
partnerId
);
request
.
setPartnerId
(
partnerId
);
request
.
setCardCodes
(
Arrays
.
asList
(
cardCode
)
);
request
.
setCardCodes
(
cardCodes
);
//查询svc卡金额
//查询svc卡金额
BaseResponse
<
SVCCardAmountResponse
>
response
=
svcAppClient
.
batchQueryCardAmount
(
request
);
BaseResponse
<
SVCCardAmountResponse
>
response
=
svcAppClient
.
batchQueryCardAmount
(
request
);
if
(
response
==
null
)
{
if
(
response
==
null
)
{
...
@@ -2599,52 +2585,33 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -2599,52 +2585,33 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if
(
response
.
getResult
()
==
null
||
CollectionUtils
.
isEmpty
(
response
.
getResult
().
getCardSimpleInfos
()))
{
if
(
response
.
getResult
()
==
null
||
CollectionUtils
.
isEmpty
(
response
.
getResult
().
getCardSimpleInfos
()))
{
throw
new
ServiceException
(
ResponseResult
.
USER_SVC_CARD_ERROR
);
throw
new
ServiceException
(
ResponseResult
.
USER_SVC_CARD_ERROR
);
}
}
boolean
check
=
this
.
checkSvcComPay
(
partnerId
,
storeId
);
Integer
applyType
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getApplyType
();
Integer
applyType
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getApplyType
();
applyType
=
applyType
==
null
?
3
:
applyType
;
applyType
=
applyType
==
null
?
3
:
applyType
;
String
svcDesc
=
applyType
==
3
?
"储值卡支付¥"
:
"礼品卡支付¥"
;
String
svcDesc
=
applyType
==
3
?
"储值卡支付¥"
:
"礼品卡支付¥"
;
if
(
check
)
{
int
totalAmount
=
response
.
getResult
().
getCardSimpleInfos
().
stream
().
mapToInt
(
CardSimpleInfo:
:
getAmount
).
sum
();
//混合支付无需校验svc卡余额,但是配送和包装费不计算在svc卡支付
int
totalVamount
=
response
.
getResult
().
getCardSimpleInfos
().
stream
().
mapToInt
(
CardSimpleInfo:
:
getVamount
).
sum
();
Integer
amount1
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getAmount
();
Integer
svcTotalAmount
=
totalAmount
+
totalVamount
;
Integer
vamount
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getVamount
();
//获取实际配送费
Integer
svcTotalAmount
=
amount1
+
vamount
;
Integer
deliveryAmount
=
0
;
//获取实际配送费
Integer
svcPayAmount
=
0
;
Integer
deliveryAmount
=
0
;
if
(
StringUtils
.
isNotBlank
(
receiveId
)
&&
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
()
!=
null
)
{
Integer
svcPayAmount
=
0
;
deliveryAmount
=
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
().
intValue
();
if
(
StringUtils
.
isNotBlank
(
receiveId
)
&&
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
()
!=
null
)
{
orderAmount
+=
deliveryAmount
;
deliveryAmount
=
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
().
intValue
();
}
orderAmount
+=
deliveryAmount
;
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
>
orderAmount
)
{
}
svcPayAmount
=
orderAmount
;
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
>
orderAmount
)
{
svcPayAmount
=
orderAmount
;
shoppingCartGoodsResponseVo
.
setTotalAmount
(
0L
);
}
else
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
<=
orderAmount
)
{
svcPayAmount
=
svcTotalAmount
;
shoppingCartGoodsResponseVo
.
setTotalAmount
((
orderAmount
.
longValue
()
-
svcPayAmount
.
longValue
()));
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
svcPayAmount
);
String
amountStr
=
bigDecimal
.
divide
(
new
BigDecimal
(
100
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
shoppingCartGoodsResponseVo
.
setSvcPayAmount
(
amountStr
);
shoppingCartGoodsResponseVo
.
setSvcDiscountDesc
(
svcDesc
+
amountStr
);
}
else
{
//获取实际配送费
if
(
StringUtils
.
isNotBlank
(
receiveId
)
&&
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
()
!=
null
)
{
Integer
deliveryAmount
=
shoppingCartGoodsResponseVo
.
getDiscountDeliveryAmount
().
intValue
();
orderAmount
+=
deliveryAmount
;
}
Integer
amount1
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getAmount
();
Integer
vamount
=
response
.
getResult
().
getCardSimpleInfos
().
get
(
0
).
getVamount
();
if
(
orderAmount
>
amount1
+
vamount
)
{
throw
new
ServiceException
(
ResponseResult
.
USER_SVC_CARD_AMOUNT_DEFICIENCY
);
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
orderAmount
);
String
amountStr
=
bigDecimal
.
divide
(
new
BigDecimal
(
100
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
shoppingCartGoodsResponseVo
.
setTotalAmount
(
0L
);
shoppingCartGoodsResponseVo
.
setTotalAmount
(
0L
);
shoppingCartGoodsResponseVo
.
setSvcDiscountDesc
(
svcDesc
+
amountStr
);
}
else
if
(
svcTotalAmount
>
0
&&
svcTotalAmount
<=
orderAmount
)
{
svcPayAmount
=
svcTotalAmount
;
shoppingCartGoodsResponseVo
.
setTotalAmount
((
orderAmount
.
longValue
()
-
svcPayAmount
.
longValue
()));
}
}
BigDecimal
bigDecimal
=
new
BigDecimal
(
svcPayAmount
);
String
amountStr
=
bigDecimal
.
divide
(
new
BigDecimal
(
100
)).
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
shoppingCartGoodsResponseVo
.
setSvcPayAmount
(
amountStr
);
shoppingCartGoodsResponseVo
.
setSvcDiscountDesc
(
svcDesc
+
amountStr
);
}
}
/**
/**
* 储值卡支付查询配送费
* 储值卡支付查询配送费
*
*
...
...
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