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
3251655e
Commit
3251655e
authored
Mar 17, 2021
by
孙昱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sunyu::update::月享卡2.0加购逻辑&&促销返回逻辑修改&&月享卡异常流程处理
parent
95b0fb32
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
28 deletions
+118
-28
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/ActivityCalculationDiscountResponseDto.java
+34
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+53
-28
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
+31
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/ActivityCalculationDiscountResponseDto.java
View file @
3251655e
...
...
@@ -56,6 +56,12 @@ public class ActivityCalculationDiscountResponseDto {
* 总的优惠信息集合
*/
private
List
<
Discount
>
discounts
;
/**
* 月享卡2.0优惠
*/
private
MonthCardDiscount
monthlyEnjoyCardDiscount
;
/**
* 商品优惠信息
*/
...
...
@@ -110,6 +116,34 @@ public class ActivityCalculationDiscountResponseDto {
private
SendPoint
sendPointVo
;
@Data
public
static
class
MonthCardDiscount
{
/**
* 月享卡2.0优惠总额
*/
private
Long
discountAmount
;
/**
* 月享卡名称
*/
private
String
cardName
;
/**
* 月享卡券号
*/
private
String
couponCode
;
/**
* 券标识
*/
private
String
couponLogo
;
/**
* 优惠标识
*/
private
String
discountLogo
;
/**
* 优惠描述
*/
private
String
discountDesc
;
}
@Data
public
static
class
ActivityPrompt
{
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
3251655e
...
...
@@ -162,8 +162,11 @@ public class ShoppingCartMCoffeeServiceImpl {
}
productIds
.
add
(
Long
.
parseLong
(
goodsId
));
List
<
ProductBeanDTO
>
productBeanListSpuClass
=
null
;
// 获取添加商品的详细信息
List
<
ProductBeanDTO
>
productBeanListSpuClass
=
assortmentSdkService
.
getProductsInfoSdk
(
partnerId
,
storeId
,
Collections
.
singletonList
(
spuId2
),
menuType
,
this
.
shoppingCartBaseService
);
if
(
addShoppingCartGoodsRequestVo
.
getIsMonthCard
()
<
1
)
{
productBeanListSpuClass
=
assortmentSdkService
.
getProductsInfoSdk
(
partnerId
,
storeId
,
Collections
.
singletonList
(
spuId2
),
menuType
,
this
.
shoppingCartBaseService
);
}
// 查询购物车缓存
List
<
CartGoods
>
oldCartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
null
,
null
,
shoppingCartBaseService
);
...
...
@@ -179,18 +182,14 @@ public class ShoppingCartMCoffeeServiceImpl {
//加锁,防止重复请求导致的加购数量错误
synchronized
(
oldCartGoodsList
)
{
//餐具和月享卡数量限制
if
(
mcCafeTablewareSkuId
.
equals
(
skuId
)
||
Objects
.
equals
(
addShoppingCartGoodsRequestVo
.
getIsMonthCard
(),
1
))
{
if
(
mcCafeTablewareSkuId
.
equals
(
skuId
)
||
StringUtils
.
equals
(
"9999"
,
skuId
))
{
for
(
CartGoods
cartGoods
:
oldCartGoodsList
)
{
if
(
mcCafeTablewareSkuId
.
equals
(
cartGoods
.
getSkuId
()))
{
return
ResponseUtil
.
error
(
ResponseResult
.
SHOPPING_CART_ADD_ERROR
.
getCode
(),
"不能重复添加餐具商品"
);
}
if
(
Objects
.
equals
(
addShoppingCartGoodsRequestVo
.
getIsMonthCard
(),
1
)
&&
cartGoods
.
getQty
()
>=
10
)
{
shoppingCartGoodsResponseVo
.
setChanged
(
true
);
shoppingCartGoodsResponseVo
.
setToastMsg
(
"该商品单次购买数量限制为10,请知晓"
);
if
(
StringUtils
.
equals
(
"9999"
,
skuId
))
{
// 返回购物车数据
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
oldCartGoodsList
,
ResponseResult
.
SHOPPING_CART_ADD_ERROR
.
getMessage
(),
ShoppingCartConstant
.
ADD_AND_UPDATE
,
null
);
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
oldCartGoodsList
,
null
,
ShoppingCartConstant
.
ADD_AND_UPDATE
,
null
);
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
}
}
...
...
@@ -211,7 +210,14 @@ public class ShoppingCartMCoffeeServiceImpl {
CustomerInfoVo
userLoginInfoDto
=
getCustomerInfoVo
(
sessionId
);
couponName
=
getCouponNameByCode
(
couponCode
,
userLoginInfoDto
,
BusinessTypeEnum
.
getByType
(
addShoppingCartGoodsRequestVo
.
getMenuType
()).
getCode
(),
storeId
);
addCartGoods
.
setCouponName
(
couponName
);
//月享卡2.0之后不在显示月享卡券的名称 与普通商品券不同,故过滤掉月享卡券名称查询
if
(!(
"9999"
).
equals
(
addCartGoods
.
getSpuId
())
&&
!(
"9999"
).
equals
(
addCartGoods
.
getSkuId
())){
addCartGoods
.
setCouponName
(
couponName
);
}
else
{
//将卡券名称赋值给 虚拟商品作为 月享卡2.0的优惠项展示
addCartGoods
.
setSpuName
(
couponName
);
addCartGoods
.
setSkuName
(
couponName
);
}
}
// 如果购物车中有商品券,则当前添加的商品是特价商品时,需要提示“已选商品券,与其他优惠商品不同享,商品将恢复原价”
...
...
@@ -221,14 +227,25 @@ public class ShoppingCartMCoffeeServiceImpl {
setToastMsgIfNotExist
(
shoppingCartGoodsResponseVo
,
ShoppingCartConstant
.
HAS_GOODS_COUPON_WHEN_ADD_SPECIAL_GOODS
);
}
// 购物车数据更新(保存商品原价)
List
<
CartGoods
>
newCartGoods
=
updateCartGoodsLegal
(
partnerId
,
storeId
,
orderType
,
tableNumber
,
menuType
,
userId
,
addCartGoods
,
shoppingCartGoodsResponseVo
,
oldCartGoodsList
);
// 促销活动等价格计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
newCartGoods
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
null
);
// 重新保存购物车数据
updateCartGoodsLegal
(
partnerId
,
storeId
,
orderType
,
tableNumber
,
menuType
,
userId
,
addCartGoods
,
shoppingCartGoodsResponseVo
,
oldCartGoodsList
);
List
<
CartGoods
>
newCartGoods
=
null
;
if
(
addCartGoods
.
getIsMonthCard
()
<
1
)
{
// 购物车数据更新(保存商品原价)
newCartGoods
=
updateCartGoodsLegal
(
partnerId
,
storeId
,
orderType
,
tableNumber
,
menuType
,
userId
,
addCartGoods
,
shoppingCartGoodsResponseVo
,
oldCartGoodsList
);
// 促销活动等价格计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
newCartGoods
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
null
);
// 重新保存购物车数据
updateCartGoodsLegal
(
partnerId
,
storeId
,
orderType
,
tableNumber
,
menuType
,
userId
,
addCartGoods
,
shoppingCartGoodsResponseVo
,
oldCartGoodsList
);
}
else
{
// 将月享卡2.0的虚拟商品保存到购物车中
oldCartGoodsList
.
add
(
addCartGoods
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
couponCode
,
oldCartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
null
);
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
oldCartGoodsList
,
null
,
tableNumber
,
this
.
shoppingCartBaseService
);
newCartGoods
=
oldCartGoodsList
;
}
// 返回购物车数据
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
newCartGoods
,
null
,
ShoppingCartConstant
.
ADD_AND_UPDATE
,
null
);
}
...
...
@@ -595,13 +612,19 @@ public class ShoppingCartMCoffeeServiceImpl {
// 获取购物车商品
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
sessionId
,
""
,
shoppingCartBaseService
);
log
.
info
(
"cartGoodsList: {}"
,
JSONObject
.
toJSONString
(
cartGoodsList
));
CartGoods
monthCardProduct
=
null
;
// 如果购物车商品不为空, 则check购物车中所有商品
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
// check购物车中所有商品
List
<
CartGoods
>
temList
=
new
ArrayList
<>();
for
(
CartGoods
goods
:
cartGoodsList
)
{
if
(
StringUtils
.
equals
(
goods
.
getSkuId
(),
"9999"
)){
monthCardProduct
=
goods
;
continue
;
}
temList
.
addAll
(
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
Arrays
.
asList
(
goods
)));
}
temList
.
add
(
monthCardProduct
);
cartGoodsList
=
temList
;
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
int
size
=
cartGoodsList
.
size
();
...
...
@@ -2258,24 +2281,26 @@ public class ShoppingCartMCoffeeServiceImpl {
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SEED_COUPON_VALID
);
}
int
seedCouponCount
=
0
;
int
seedCouponGoodsCount
=
0
;
//
int seedCouponCount = 0;
//
int seedCouponGoodsCount = 0;
for
(
CartGoods
cartGoods
:
oldCartGoodsList
)
{
//1.种子券商品券信息与月卡信息一致
if
(
null
!=
cartGoods
.
getMonthCardInfo
()
&&
!
addShoppingCartGoodsRequestVo
.
getCouponCode
().
equals
(
cartGoods
.
getMonthCardInfo
().
getCardCode
())){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_COUPON_NOT_EXIST
);
}
if
(
cartGoods
.
getIsMonthCard
()>
0
){
seedCouponCount
=
seedCouponCount
+
cartGoods
.
getQty
();
}
if
(
cartGoods
.
getIsSeedCouponGoods
()>
0
&&
cartGoods
.
getIsMonthCard
()<
1
){
seedCouponGoodsCount
=
seedCouponGoodsCount
+
cartGoods
.
getQty
();
}
//@Date 2021-03-15 月享卡2.0需求不再校验月享卡商品购买次数限制
// if (cartGoods.getIsMonthCard()>0){
// seedCouponCount = seedCouponCount + cartGoods.getQty();
// }
// if (cartGoods.getIsSeedCouponGoods()>0 && cartGoods.getIsMonthCard()<1){
// seedCouponGoodsCount = seedCouponGoodsCount + cartGoods.getQty();
// }
}
//2.种子券商品数量不可大于种子券数量
if
((
seedCouponGoodsCount
+
addShoppingCartGoodsRequestVo
.
getQty
())
>
seedCouponCount
){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SEED_COUPON_VALID
);
}
//
if ((seedCouponGoodsCount+addShoppingCartGoodsRequestVo.getQty()) > seedCouponCount){
//
throw new ServiceException(ResponseResult.SHOPPING_CART_SEED_COUPON_VALID);
//
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
3251655e
...
...
@@ -97,6 +97,37 @@ public class CouponDiscountCalculation {
if
(
CollectionUtils
.
isEmpty
(
couponDiscounts
))
{
return
;
}
/**
* 月享卡2.0 促销单独返回 月享卡优惠
*/
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
MonthCardDiscount
monthCardDiscount
=
calculationDiscountResult
.
getMonthlyEnjoyCardDiscount
();
if
(
null
!=
monthCardDiscount
){
Boolean
hasMonCardDiscountVirtualProduct
=
false
;
//如果购物车列表已有优惠项,则更新促销返回的优惠信息
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
if
(
StringUtils
.
equals
(
cartGoods
.
getSkuId
(),
"9999"
)){
cartGoods
.
setAmount
(
monthCardDiscount
.
getDiscountAmount
());
cartGoods
.
setCouponCode
(
monthCardDiscount
.
getCouponCode
());
cartGoods
.
setPic
(
monthCardDiscount
.
getCouponLogo
());
hasMonCardDiscountVirtualProduct
=
true
;
}
}
//如果是菜单页加购月享卡商品.促销返回月享卡优惠后 虚拟一个 优惠项返回给前端
if
(!
hasMonCardDiscountVirtualProduct
){
CartGoods
virtualProduct
=
new
CartGoods
();
virtualProduct
.
setSkuId
(
"9999"
);
virtualProduct
.
setSpuId
(
"9999"
);
virtualProduct
.
setSkuName
(
monthCardDiscount
.
getCardName
());
virtualProduct
.
setSpuName
(
monthCardDiscount
.
getCardName
());
virtualProduct
.
setCouponCode
(
monthCardDiscount
.
getCouponCode
());
virtualProduct
.
setPic
(
monthCardDiscount
.
getCouponLogo
());
virtualProduct
.
setCouponName
(
monthCardDiscount
.
getCardName
());
virtualProduct
.
setAmount
(
monthCardDiscount
.
getDiscountAmount
());
cartGoodsList
.
add
(
virtualProduct
);
}
}
Map
<
String
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsMap
=
goodsList
.
parallelStream
()
.
collect
(
Collectors
.
toMap
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getCartGoodsUid
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
...
...
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