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
ea571c7e
Commit
ea571c7e
authored
Dec 17, 2021
by
胡敬轩
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/origin/feature/20211124-v3算价优化改造'
parents
c8ca553e
f29e10a1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
115 additions
and
26 deletions
+115
-26
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ActivityAdapter.java
+110
-26
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+5
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ActivityAdapter.java
View file @
ea571c7e
...
@@ -297,6 +297,14 @@ public class ActivityAdapter {
...
@@ -297,6 +297,14 @@ public class ActivityAdapter {
return
this
.
convert2PremiumExchange
(
calculationDiscountResult
);
return
this
.
convert2PremiumExchange
(
calculationDiscountResult
);
}
}
/**
* v2算价 根据购物车行级别商品处理
* @param partnerId
* @param storeId
* @param discountResult
* @param orgCodes
* @return
*/
public
CouponAvailableCartInfo
convert2CouponAvailableCartInfoSharing
(
String
partnerId
,
String
storeId
,
CalculationDiscountResult
discountResult
,
List
<
String
>
orgCodes
)
{
public
CouponAvailableCartInfo
convert2CouponAvailableCartInfoSharing
(
String
partnerId
,
String
storeId
,
CalculationDiscountResult
discountResult
,
List
<
String
>
orgCodes
)
{
// 返回构造对象
// 返回构造对象
CouponAvailableCartInfo
couponAvailableCartInfo
=
new
CouponAvailableCartInfo
();
CouponAvailableCartInfo
couponAvailableCartInfo
=
new
CouponAvailableCartInfo
();
...
@@ -309,11 +317,6 @@ public class ActivityAdapter {
...
@@ -309,11 +317,6 @@ public class ActivityAdapter {
// Long sendDiscountAmount = 0L;//赠送和换购商品优惠不算在内
// Long sendDiscountAmount = 0L;//赠送和换购商品优惠不算在内
// Long sendRealAmount = 0L;//赠送和换购商品实付不算在内
// Long sendRealAmount = 0L;//赠送和换购商品实付不算在内
if
(
discountResult
!=
null
){
if
(
discountResult
!=
null
){
boolean
newCalculation
=
discountResult
.
getV3Promotion
();
if
(
newCalculation
){
couponAvailableCartInfo
.
setNewCalculation
(
newCalculation
);
buildOrderDiscount
(
couponAvailableCartInfo
,
discountResult
.
getDiscounts
(),
discountResult
.
getCouponSharedExclusive
());
}
//已使用券
//已使用券
if
(
CollectionUtils
.
isNotEmpty
(
discountResult
.
getDiscounts
())){
if
(
CollectionUtils
.
isNotEmpty
(
discountResult
.
getDiscounts
())){
List
<
String
>
couponCodes
=
discountResult
.
getDiscounts
().
stream
().
filter
(
discount
->
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_3
.
getCode
())
List
<
String
>
couponCodes
=
discountResult
.
getDiscounts
().
stream
().
filter
(
discount
->
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_3
.
getCode
())
...
@@ -355,9 +358,7 @@ public class ActivityAdapter {
...
@@ -355,9 +358,7 @@ public class ActivityAdapter {
cartProduct
.
setOriginalTotalAmount
(
discountGood
.
getRealAmount
()+
discountGood
.
getDiscountAmount
()
+
triple
.
getLeft
()
+
triple
.
getMiddle
()
-
mealDiscountAmount
);
cartProduct
.
setOriginalTotalAmount
(
discountGood
.
getRealAmount
()+
discountGood
.
getDiscountAmount
()
+
triple
.
getLeft
()
+
triple
.
getMiddle
()
-
mealDiscountAmount
);
cartProduct
.
setRealAmount
(
discountGood
.
getRealAmount
()
+
triple
.
getLeft
());
cartProduct
.
setRealAmount
(
discountGood
.
getRealAmount
()
+
triple
.
getLeft
());
cartProduct
.
setDiscountAmount
(
discountGood
.
getDiscountAmount
()+
triple
.
getMiddle
()
-
mealDiscountAmount
);
cartProduct
.
setDiscountAmount
(
discountGood
.
getDiscountAmount
()+
triple
.
getMiddle
()
-
mealDiscountAmount
);
if
(
newCalculation
){
buildGoodDiscount
(
cartProduct
,
discountGood
,
discountResult
.
getCouponSharedExclusive
());
}
goods
.
add
(
cartProduct
);
goods
.
add
(
cartProduct
);
}
}
couponAvailableCartInfo
.
setProductList
(
goods
);
couponAvailableCartInfo
.
setProductList
(
goods
);
...
@@ -466,8 +467,8 @@ public class ActivityAdapter {
...
@@ -466,8 +467,8 @@ public class ActivityAdapter {
return
Pair
.
of
(
realAmount
,
discountAmount
);
return
Pair
.
of
(
realAmount
,
discountAmount
);
}
}
private
void
buildGoodDiscount
(
CartProduct
cartProduct
,
Goods
discountGood
,
Set
<
ActivityTypeSharedExclusive
>
couponSharedExclusive
){
private
void
buildGoodDiscount
(
CartProduct
cartProduct
,
ApportionGoods
apportionGoods
,
Set
<
ActivityTypeSharedExclusive
>
couponSharedExclusive
){
if
(
CollectionUtils
.
isEmpty
(
discountGood
.
getDiscount
s
())){
if
(
CollectionUtils
.
isEmpty
(
apportionGoods
.
getApportionDetail
s
())){
return
;
return
;
}
}
HashMap
<
Integer
,
Integer
>
cashExclusiveMap
=
new
HashMap
<>();
HashMap
<
Integer
,
Integer
>
cashExclusiveMap
=
new
HashMap
<>();
...
@@ -486,32 +487,31 @@ public class ActivityAdapter {
...
@@ -486,32 +487,31 @@ public class ActivityAdapter {
}
}
List
<
CartProduct
.
Discount
>
cartProductDiscountList
=
new
ArrayList
<>();
List
<
CartProduct
.
Discount
>
cartProductDiscountList
=
new
ArrayList
<>();
for
(
GoodsDiscount
discount
:
discountGood
.
getDiscounts
()){
for
(
ApportionDetails
discount
:
apportionGoods
.
getApportionDetails
()){
if
(
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_310
.
getCode
())){
continue
;
}
CartProduct
.
Discount
cartProductDiscount
=
new
CartProduct
.
Discount
();
CartProduct
.
Discount
cartProductDiscount
=
new
CartProduct
.
Discount
();
BeanUtils
.
copyProperties
(
discount
,
cartProductDiscount
);
BeanUtils
.
copyProperties
(
discount
,
cartProductDiscount
);
cartProductDiscount
.
setActualGoodsNumber
(
discount
.
getAddOnQuantity
());
cartProductDiscount
.
setDiscount
(
discount
.
getActivityApportionAmount
());
cartProductDiscount
.
setType
(
discount
.
getActivityType
());
cartProductDiscount
.
setActualGoodsNumber
(
cartProduct
.
getQuantity
());
//小料或者可选搭配的优惠金额合并至主商品
//小料或者可选搭配的优惠金额合并至主商品
long
smallDiscountAmount
=
getSmallA
ctivityDiscountAmount
(
discountGood
.
getSmallMaterial
(),
discount
.
get
Type
());
long
smallDiscountAmount
=
getSmallA
pportionDiscountAmount
(
apportionGoods
.
getSmallMaterial
(),
discount
.
getActivity
Type
());
cartProductDiscount
.
setDiscount
(
cartProductDiscount
.
getDiscount
()
+
smallDiscountAmount
);
cartProductDiscount
.
setDiscount
(
cartProductDiscount
.
getDiscount
()
+
smallDiscountAmount
);
//是否与代金券互斥
//是否与代金券互斥
boolean
cashExclusive
=
Objects
.
equals
(
cashExclusiveMap
.
get
(
discount
.
getType
()),
YesOrNoEnum
.
NO
.
getCode
());
boolean
cashExclusive
=
Objects
.
equals
(
cashExclusiveMap
.
get
(
discount
.
get
Activity
Type
()),
YesOrNoEnum
.
NO
.
getCode
());
cartProductDiscount
.
setCashExclusive
(
cashExclusive
);
cartProductDiscount
.
setCashExclusive
(
cashExclusive
);
//是否与代金券叠加门槛
//是否与代金券叠加门槛
boolean
cashMultiple
=
!
Objects
.
equals
(
cashMultipleMap
.
get
(
discount
.
getType
()),
YesOrNoEnum
.
NO
.
getCode
());
boolean
cashMultiple
=
!
Objects
.
equals
(
cashMultipleMap
.
get
(
discount
.
get
Activity
Type
()),
YesOrNoEnum
.
NO
.
getCode
());
cartProductDiscount
.
setCashMultiple
(
cashMultiple
);
cartProductDiscount
.
setCashMultiple
(
cashMultiple
);
//是否与折扣券互斥
//是否与折扣券互斥
boolean
discountExclusive
=
Objects
.
equals
(
discountExclusiveMap
.
get
(
discount
.
getType
()),
YesOrNoEnum
.
NO
.
getCode
());
boolean
discountExclusive
=
Objects
.
equals
(
discountExclusiveMap
.
get
(
discount
.
get
Activity
Type
()),
YesOrNoEnum
.
NO
.
getCode
());
cartProductDiscount
.
setDiscountExclusive
(
discountExclusive
);
cartProductDiscount
.
setDiscountExclusive
(
discountExclusive
);
//是否与折扣券叠加门槛
//是否与折扣券叠加门槛
boolean
discountMultiple
=
!
Objects
.
equals
(
discountMultipleMap
.
get
(
discount
.
getType
()),
YesOrNoEnum
.
NO
.
getCode
());
boolean
discountMultiple
=
!
Objects
.
equals
(
discountMultipleMap
.
get
(
discount
.
get
Activity
Type
()),
YesOrNoEnum
.
NO
.
getCode
());
cartProductDiscount
.
setDiscountMultiple
(
discountMultiple
);
cartProductDiscount
.
setDiscountMultiple
(
discountMultiple
);
cartProductDiscountList
.
add
(
cartProductDiscount
);
cartProductDiscountList
.
add
(
cartProductDiscount
);
...
@@ -567,14 +567,14 @@ public class ActivityAdapter {
...
@@ -567,14 +567,14 @@ public class ActivityAdapter {
couponAvailableCartInfo
.
setDiscounts
(
cartDiscountList
);
couponAvailableCartInfo
.
setDiscounts
(
cartDiscountList
);
}
}
private
Long
getSmallA
ctivityDiscountAmount
(
List
<
Small
Material
>
smallMaterial
,
Integer
activityType
){
private
Long
getSmallA
pportionDiscountAmount
(
List
<
Material
>
smallMaterial
,
Integer
activityType
){
long
discountAmount
=
0
;
long
discountAmount
=
0
;
if
(
org
.
apache
.
commons
.
collections
.
CollectionUtils
.
isNotEmpty
(
smallMaterial
)){
if
(
org
.
apache
.
commons
.
collections
.
CollectionUtils
.
isNotEmpty
(
smallMaterial
)){
for
(
Small
Material
small
:
smallMaterial
){
for
(
Material
small
:
smallMaterial
){
if
(
CollectionUtils
.
isNotEmpty
(
small
.
get
Discount
s
())){
if
(
CollectionUtils
.
isNotEmpty
(
small
.
get
ApportionDetail
s
())){
for
(
GoodsDiscount
smallDiscount
:
small
.
getDiscount
s
()){
for
(
ApportionDetails
smallDiscount
:
small
.
getApportionDetail
s
()){
if
(
Objects
.
equals
(
smallDiscount
.
getType
(),
activityType
)){
if
(
Objects
.
equals
(
smallDiscount
.
get
Activity
Type
(),
activityType
)){
discountAmount
+=
smallDiscount
.
get
Disc
ount
();
discountAmount
+=
smallDiscount
.
get
ActivityApportionAm
ount
();
}
}
}
}
}
}
...
@@ -582,4 +582,88 @@ public class ActivityAdapter {
...
@@ -582,4 +582,88 @@ public class ActivityAdapter {
}
}
return
discountAmount
;
return
discountAmount
;
}
}
/**
* v3算价 根据每件商品的均摊明细处理
* @param partnerId
* @param storeId
* @param discountResult
* @param orgCodes
* @return
*/
public
CouponAvailableCartInfo
convert2CouponAvailableCartInfoSharingV3
(
String
partnerId
,
String
storeId
,
CalculationDiscountResult
discountResult
,
List
<
String
>
orgCodes
)
{
// 返回构造对象
CouponAvailableCartInfo
couponAvailableCartInfo
=
new
CouponAvailableCartInfo
();
couponAvailableCartInfo
.
setProviderId
(
partnerId
);
couponAvailableCartInfo
.
setMerchantId
(
partnerId
);
couponAvailableCartInfo
.
setStoreId
(
storeId
);
couponAvailableCartInfo
.
setChannelIdList
(
orgCodes
);
if
(
discountResult
!=
null
){
boolean
newCalculation
=
discountResult
.
getV3Promotion
();
couponAvailableCartInfo
.
setNewCalculation
(
newCalculation
);
buildOrderDiscount
(
couponAvailableCartInfo
,
discountResult
.
getDiscounts
(),
discountResult
.
getCouponSharedExclusive
());
//已使用券
if
(
CollectionUtils
.
isNotEmpty
(
discountResult
.
getDiscounts
())){
List
<
String
>
couponCodes
=
discountResult
.
getDiscounts
().
stream
().
filter
(
discount
->
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_3
.
getCode
())
||
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_31
.
getCode
())
||
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_32
.
getCode
())
||
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_33
.
getCode
())
||
Objects
.
equals
(
discount
.
getType
(),
ActivityTypeEnum
.
TYPE_330
.
getCode
())).
map
(
Discount:
:
getActivityCode
).
collect
(
Collectors
.
toList
());
couponAvailableCartInfo
.
setCouponCodes
(
couponCodes
);
}
if
(
CollectionUtils
.
isNotEmpty
(
discountResult
.
getApportionGoods
())){
List
<
CartProduct
>
goods
=
new
ArrayList
<>();
for
(
ApportionGoods
apportionGoods
:
discountResult
.
getApportionGoods
()){
//小料和可选搭配金额
Triple
<
Long
,
Long
,
Long
>
triple
=
getSmallApportionAmountSharing
(
apportionGoods
.
getSmallMaterial
());
//value1=总实付 value2=总优惠 value3=单个主商品下总原价
CartProduct
cartProduct
=
new
CartProduct
();
cartProduct
.
setProductId
(
apportionGoods
.
getGoodsId
());
cartProduct
.
setQuantity
(
apportionGoods
.
getGoodsQuantity
());
cartProduct
.
setOriginalPrice
(
apportionGoods
.
getOriginalPrice
()+
triple
.
getRight
());
if
(
CollectionUtils
.
isNotEmpty
(
apportionGoods
.
getApportionDetails
())){
Optional
<
String
>
goodCoupon
=
apportionGoods
.
getApportionDetails
().
stream
().
filter
(
goodsDiscount
->
Objects
.
equals
(
goodsDiscount
.
getActivityType
(),
ActivityTypeEnum
.
TYPE_32
.
getCode
())
||
Objects
.
equals
(
goodsDiscount
.
getActivityType
(),
ActivityTypeEnum
.
TYPE_33
.
getCode
())
||
Objects
.
equals
(
goodsDiscount
.
getActivityType
(),
ActivityTypeEnum
.
TYPE_330
.
getCode
())
).
map
(
ApportionDetails:
:
getActivityCode
).
findFirst
();
cartProduct
.
setCouponCode
(
goodCoupon
!=
null
&&
goodCoupon
.
isPresent
()?
goodCoupon
.
get
():
null
);
}
cartProduct
.
setOriginalTotalAmount
((
apportionGoods
.
getOriginalPrice
()
+
triple
.
getRight
())
*
apportionGoods
.
getGoodsQuantity
());
cartProduct
.
setRealAmount
(
apportionGoods
.
getNowPrice
()
+
triple
.
getLeft
());
cartProduct
.
setDiscountAmount
(
apportionGoods
.
getApportionAmount
()
+
triple
.
getMiddle
());
buildGoodDiscount
(
cartProduct
,
apportionGoods
,
discountResult
.
getCouponSharedExclusive
());
goods
.
add
(
cartProduct
);
}
couponAvailableCartInfo
.
setProductList
(
goods
);
}
couponAvailableCartInfo
.
setOriginalTotalAmount
(
discountResult
.
getOriginalTotalAmount
());
couponAvailableCartInfo
.
setRealAmount
(
discountResult
.
getTotalAmount
());
couponAvailableCartInfo
.
setDiscountAmount
(
discountResult
.
getTotalDiscountAmount
());
}
else
{
couponAvailableCartInfo
.
setProductList
(
new
ArrayList
<>());
couponAvailableCartInfo
.
setOriginalTotalAmount
(
0L
);
couponAvailableCartInfo
.
setRealAmount
(
0L
);
couponAvailableCartInfo
.
setDiscountAmount
(
0L
);
}
couponAvailableCartInfo
.
setDeliveryAmount
(
discountResult
!=
null
?
discountResult
.
getDeliveryAmount
():
0
);
couponAvailableCartInfo
.
setDistributionFee
(
discountResult
!=
null
?
discountResult
.
getDistributionFee
():
0
);
return
couponAvailableCartInfo
;
}
private
Triple
<
Long
,
Long
,
Long
>
getSmallApportionAmountSharing
(
List
<
Material
>
smallMaterial
){
long
discountAmount
=
0
;
long
originalPrice
=
0
;
if
(
org
.
apache
.
commons
.
collections
.
CollectionUtils
.
isNotEmpty
(
smallMaterial
)){
for
(
Material
small
:
smallMaterial
){
discountAmount
+=
small
.
getApportionAmount
();
originalPrice
+=
small
.
getOriginalPrice
()
*
small
.
getGoodsQuantity
();
}
}
long
realAmount
=
originalPrice
-
discountAmount
;
return
Triple
.
of
(
realAmount
,
discountAmount
,
originalPrice
);
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
ea571c7e
...
@@ -3319,10 +3319,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -3319,10 +3319,15 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
,
deliveryAmount
,
deliveryAmount
,
null
,
bizType
,
accountFlag
,
sharingDto
);
,
null
,
bizType
,
accountFlag
,
sharingDto
);
if
(
discountResult
!=
null
&&
Objects
.
equals
(
discountResult
.
getV3Promotion
(),
true
)){
//v3
couponAvailableCartInfo
=
activityAdapter
.
convert2CouponAvailableCartInfoSharingV3
(
partnerId
,
storeId
,
discountResult
,
orgCodes
);
}
else
{
//v2
couponAvailableCartInfo
=
activityAdapter
.
convert2CouponAvailableCartInfoSharing
(
partnerId
,
storeId
,
discountResult
,
orgCodes
);
couponAvailableCartInfo
=
activityAdapter
.
convert2CouponAvailableCartInfoSharing
(
partnerId
,
storeId
,
discountResult
,
orgCodes
);
}
}
else
{
}
else
{
// 获取优惠信息
// 获取优惠信息
CalculationDiscountResult
calculationDiscountResult
=
getCalculationDiscountResult
(
menuType
,
partnerId
,
storeId
,
userId
,
appId
,
assortmentCustomerInfoVo
.
getWxAppId
(),
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
cartGoodsList
,
new
ArrayList
<>(),
null
,
null
,
deliveryAmount
,
bizType
,
accountFlag
);
CalculationDiscountResult
calculationDiscountResult
=
getCalculationDiscountResult
(
menuType
,
partnerId
,
storeId
,
userId
,
appId
,
assortmentCustomerInfoVo
.
getWxAppId
(),
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
cartGoodsList
,
new
ArrayList
<>(),
null
,
null
,
deliveryAmount
,
bizType
,
accountFlag
);
//v1
couponAvailableCartInfo
=
activityAdapter
.
convert2CouponAvailableCartInfo
(
partnerId
,
storeId
,
calculationDiscountResult
,
orgCodes
);
couponAvailableCartInfo
=
activityAdapter
.
convert2CouponAvailableCartInfo
(
partnerId
,
storeId
,
calculationDiscountResult
,
orgCodes
);
}
}
return
ResponseUtil
.
success
(
couponAvailableCartInfo
);
return
ResponseUtil
.
success
(
couponAvailableCartInfo
);
...
...
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