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
5afb50c3
Commit
5afb50c3
authored
Jun 11, 2021
by
徐康
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
买3赠1券
parent
71c0bcd5
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
185 additions
and
15 deletions
+185
-15
shopping-cart-application-service/src/main/java/cn/freemud/controller/MCoffeeShoppingCartController.java
+2
-2
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/BatchOperateCartGoodsRequestVo.java
+5
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/CartGoods.java
+4
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartInfoRequestVo.java
+1
-1
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+171
-12
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
+2
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/controller/MCoffeeShoppingCartController.java
View file @
5afb50c3
...
...
@@ -86,8 +86,8 @@ public class MCoffeeShoppingCartController {
*/
@ApiAnnotation
(
logMessage
=
"removeB3S1Coupon"
)
@PostMapping
(
value
=
"/removeB3S1Coupon"
)
public
BaseResponse
delet
eB3S1Coupon
(
@Validated
@LogParams
@RequestBody
MCoffeeAddGoodsRequestVo
request
)
{
return
shoppingCartMCoffeeService
.
addGoods
(
request
);
public
BaseResponse
remov
eB3S1Coupon
(
@Validated
@LogParams
@RequestBody
MCoffeeAddGoodsRequestVo
request
)
{
return
shoppingCartMCoffeeService
.
removeB3S1Coupon
(
request
);
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/BatchOperateCartGoodsRequestVo.java
View file @
5afb50c3
...
...
@@ -49,6 +49,11 @@ public class BatchOperateCartGoodsRequestVo extends BaseRequestVo{
private
String
redundancyCouponCode
;
/**
* 根据券号清除当前购物车中月卡及商品信息
*/
private
String
redundancyB3S1CouponCode
;
/**
* 是否使用月享卡2.0
* 1 是
* 0 否
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/CartGoods.java
View file @
5afb50c3
...
...
@@ -244,6 +244,10 @@ public class CartGoods {
*/
private
int
isB3S1Coupon
=
0
;
/**
* 是否使用了买3赠1券
*/
private
int
isB3S1CouponGoods
=
0
;
/**
* 是否是太阳蛋商品
*/
private
int
isSunnyCoupon
=
0
;
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartInfoRequestVo.java
View file @
5afb50c3
...
...
@@ -82,7 +82,7 @@ public class ShoppingCartInfoRequestVo extends BaseRequestVo {
* 1 是
* 0 否
*/
private
Integer
isUseB3S
3
Coupon
=
1
;
private
Integer
isUseB3S
1
Coupon
=
1
;
/**
* 优惠券对应的活动号
*/
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
5afb50c3
...
...
@@ -428,6 +428,16 @@ public class ShoppingCartMCoffeeServiceImpl {
clearCouponCodeRequestVo
.
setIsUseMonthCard
(
requestVo
.
getIsUseMonthCard
());
baseResponse
=
clearCouponInfoByCode
(
clearCouponCodeRequestVo
);
}
if
(
StringUtils
.
isNotEmpty
(
requestVo
.
getRedundancyB3S1CouponCode
())){
MCoffeeAddGoodsRequestVo
clearCouponCodeRequestVo
=
new
MCoffeeAddGoodsRequestVo
();
clearCouponCodeRequestVo
.
setCouponCode
(
requestVo
.
getRedundancyB3S1CouponCode
());
clearCouponCodeRequestVo
.
setSessionId
(
requestVo
.
getSessionId
());
clearCouponCodeRequestVo
.
setPartnerId
(
requestVo
.
getPartnerId
());
clearCouponCodeRequestVo
.
setShopId
(
requestVo
.
getShopId
());
clearCouponCodeRequestVo
.
setOrderType
(
requestVo
.
getOrderType
());
clearCouponCodeRequestVo
.
setChannelType
(
requestVo
.
getChannelType
());
baseResponse
=
removeB3S1Coupon
(
clearCouponCodeRequestVo
);
}
if
(
CollectionUtils
.
isNotEmpty
(
requestVo
.
getQtyInfoList
()))
{
BatchUpdateGoodsQtyRequestVo
updateGoodsQtyRequestVo
=
new
BatchUpdateGoodsQtyRequestVo
();
...
...
@@ -498,6 +508,132 @@ public class ShoppingCartMCoffeeServiceImpl {
}
/**
* 批量更新购物车商品数量
* @param addShoppingCartGoodsRequestVo
* @return
*/
public
BaseResponse
removeB3S1Coupon
(
MCoffeeAddGoodsRequestVo
addShoppingCartGoodsRequestVo
){
if
(
StringUtils
.
isEmpty
(
addShoppingCartGoodsRequestVo
.
getShopId
()))
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SHOP_ID_NOT_EMPTY
);
}
if
(
StringUtils
.
isEmpty
(
addShoppingCartGoodsRequestVo
.
getCouponCode
())){
return
ResponseUtil
.
error
(
ResponseResult
.
SHOPPING_CART_UPDATE_ERROR
,
"买3赠1券号不能为空"
);
}
String
sessionId
=
addShoppingCartGoodsRequestVo
.
getSessionId
();
// 获取用户信息
CustomerInfoVo
assortmentCustomerInfoVo
=
getCustomerInfoVo
(
sessionId
);
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
=
new
ShoppingCartGoodsResponseVo
();
String
userId
=
assortmentCustomerInfoVo
.
getMemberId
();
String
partnerId
=
addShoppingCartGoodsRequestVo
.
getPartnerId
();
String
storeId
=
addShoppingCartGoodsRequestVo
.
getShopId
();
String
appId
=
addShoppingCartGoodsRequestVo
.
getAppId
();
String
spuId
=
addShoppingCartGoodsRequestVo
.
getSpuId
();
String
skuId
=
StringUtils
.
isNotBlank
(
addShoppingCartGoodsRequestVo
.
getSkuId
())
?
addShoppingCartGoodsRequestVo
.
getSkuId
()
:
""
;
String
goodsId
=
StringUtils
.
isEmpty
(
skuId
)
?
spuId
:
skuId
;
String
tableNumber
=
addShoppingCartGoodsRequestVo
.
getTableNumber
();
String
menuType
=
addShoppingCartGoodsRequestVo
.
getMenuType
();
Integer
orderType
=
addShoppingCartGoodsRequestVo
.
getOrderType
();
String
receiveId
=
addShoppingCartGoodsRequestVo
.
getReceiveId
();
Integer
operationType
=
addShoppingCartGoodsRequestVo
.
getOperationType
();
String
couponCode
=
addShoppingCartGoodsRequestVo
.
getCouponCode
();
// 查询购物车缓存
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
null
,
null
,
shoppingCartBaseService
);
if
(
CollectionUtils
.
isEmpty
(
cartGoodsList
))
{
cartGoodsList
=
new
ArrayList
<>();
}
cartGoodsList
=
clearB3S1CouponInfo
(
cartGoodsList
,
couponCode
);
Optional
<
CartGoods
>
cartGoods9998
=
cartGoodsList
.
stream
().
filter
(
o
->
"9998"
.
equals
(
skuId
)
&&
o
.
getIsB3S1Coupon
()
==
1
).
findFirst
();
if
(
cartGoods9998
.
isPresent
())
{
cartGoods9998
.
get
().
getB3S1CouponGoodsInfo
().
getCardCodeSet
().
remove
(
couponCode
);
}
CartGoods
monthCardProduct
=
null
;
CartGoods
B3S1CouponProduct
=
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
;
}
if
(
StringUtils
.
equals
(
goods
.
getSkuId
(),
"9998"
)){
B3S1CouponProduct
=
goods
;
continue
;
}
temList
.
add
(
goods
);
}
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
temList
,
sessionId
);
if
(
null
!=
monthCardProduct
)
{
cartGoodsList
.
add
(
monthCardProduct
);
}
if
(
null
!=
B3S1CouponProduct
)
{
cartGoodsList
.
add
(
B3S1CouponProduct
);
}
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
int
size
=
cartGoodsList
.
size
();
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
//先把月卡放到最后
if
(
null
!=
cartGoodsList
.
get
(
i
)
&&
Objects
.
equals
(
1
,
cartGoodsList
.
get
(
i
).
getIsB3S1Coupon
()))
{
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
if
(
i
!=
size
-
1
)
{
cartGoodsList
.
remove
(
i
);
cartGoodsList
.
add
(
cartGoods
);
break
;
}
}
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
//先把月卡放到最后
if
(
null
!=
cartGoodsList
.
get
(
i
)
&&
Objects
.
equals
(
1
,
cartGoodsList
.
get
(
i
).
getIsMonthCard
()))
{
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
if
(
i
!=
size
-
1
)
{
cartGoodsList
.
remove
(
i
);
cartGoodsList
.
add
(
cartGoods
);
break
;
}
}
}
for
(
int
i
=
0
;
i
<
size
;
i
++)
{
//如果是餐具商品,则放到最后
if
(
null
!=
cartGoodsList
.
get
(
i
)
&&
cartGoodsList
.
get
(
i
).
getSkuId
().
equals
(
mcCafeTablewareSkuId
))
{
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
cartGoods
.
setIsTableware
(
true
);
if
(
i
!=
size
-
1
)
{
cartGoodsList
.
remove
(
i
);
cartGoodsList
.
add
(
cartGoods
);
break
;
}
}
}
}
}
String
productCouponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
,
SaveCouponType
.
COUPON
.
getCode
());
String
freightCouponCode
=
assortmentSdkService
.
getShoppingCartCoupon
(
partnerId
,
storeId
,
userId
,
shoppingCartBaseService
,
SaveCouponType
.
FREIGHT_COUPON
.
getCode
());
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
productCouponCode
,
null
,
cartGoodsList
,
freightCouponCode
,
null
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
couponCode
,
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
,
null
);
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
null
,
tableNumber
,
this
.
shoppingCartBaseService
);
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
cartGoodsList
,
null
,
ShoppingCartConstant
.
ADD_AND_UPDATE
,
null
);
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
}
/**
* 根据券号清除券信息
* @param requestVo
* @return
...
...
@@ -564,10 +700,14 @@ public class ShoppingCartMCoffeeServiceImpl {
CartGoods
cartGoods
=
null
;
String
skuId
=
""
;
Integer
finalQty
=
qty
;
boolean
isB3S1Coupon
=
false
;
String
b3S1CouponCode
=
""
;
List
<
CartGoods
>
temList
=
new
ArrayList
<>();
CartGoods
b3S1CartGoods
=
new
CartGoods
();
for
(
CartGoods
cartGoods_
:
cartGoodsList
)
{
//如果菜单购月卡数量大于10,则不作数量修改,直接算价并返回之前购物车信息
if
(
Objects
.
equals
(
1
,
cartGoods_
.
getIsMonthCard
())
&&
cartGoods_
.
getCartGoodsUid
().
equals
(
updateShoppingCartGoodsQtyRequestVo
.
getCartGoodsUid
()
)
&&
cartGoods_
.
getCartGoodsUid
().
equals
(
cartGoodsUid
)
&&
updateShoppingCartGoodsQtyRequestVo
.
getQty
()>
10
)
{
shoppingCartGoodsResponseVo
.
setChanged
(
true
);
shoppingCartGoodsResponseVo
.
setToastMsg
(
ResponseResult
.
SHOPPING_CART_QTY_LIMIT_ERR
.
getMessage
());
...
...
@@ -587,12 +727,24 @@ public class ShoppingCartMCoffeeServiceImpl {
if
(
cartGoods_
.
getIsMonthCard
()
==
1
&&
cartGoods_
.
getMonthCardInfo
()
!=
null
&&
qty
!=
null
&&
qty
==
0
){
cartGoodsList
=
clearMonthCouponInfo
(
cartGoodsList
,
cartGoods_
.
getMonthCardInfo
().
getCardCode
(),
cartGoodsUid
);
}
if
(
cartGoods_
.
getIsB3S1Coupon
()
==
1
&&
cartGoods_
.
getB3S1CouponGoodsInfo
()
!=
null
&&
qty
!=
null
&&
qty
==
0
){
isB3S1Coupon
=
true
;
b3S1CouponCode
=
cartGoods_
.
getB3S1CouponGoodsInfo
().
getCardCode
();
}
cartGoods
=
cartGoods_
;
cartGoods_
.
setQty
(
qty
);
skuId
=
cartGoods_
.
getSkuId
();
finalQty
=
cartGoods_
.
getQty
();
break
;
}
if
(
"9998"
.
equals
(
cartGoods_
.
getSkuId
()))
{
b3S1CartGoods
=
cartGoods_
;
}
else
{
temList
.
add
(
cartGoods_
);
}
}
if
(
isB3S1Coupon
)
{
cartGoodsList
=
clearB3S1CouponInfo
(
cartGoodsList
,
b3S1CouponCode
);
}
if
(!
mcCafeTablewareSkuId
.
equals
(
skuId
)
&&
finalQty
==
0
&&
CollectionUtils
.
isNotEmpty
(
cartGoodsList
)
&&
cartGoodsList
.
size
()
==
2
)
{
...
...
@@ -612,16 +764,14 @@ public class ShoppingCartMCoffeeServiceImpl {
throw
new
ServiceException
(
ResponseResult
.
NOT_SUPPORTED
);
}
// 检查购物车商品库存数量
// checkUpdateStock(partnerId, storeId, menuType, qty, cartGoods);
// check购物车中所有商品
// cartGoodsList = checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, cartGoodsList);
List
<
CartGoods
>
temList
=
new
ArrayList
<>();
for
(
CartGoods
goods
:
cartGoodsList
)
{
temList
.
addAll
(
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
Arrays
.
asList
(
goods
),
sessionId
));
}
cartGoodsList
=
temList
;
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
temList
,
sessionId
);
cartGoodsList
.
add
(
b3S1CartGoods
);
// List<CartGoods> temList = new ArrayList<>();
// for (CartGoods goods : cartGoodsList) {
// temList.addAll(checkCartGoods(partnerId, storeId, orderType, menuType, shoppingCartGoodsResponseVo, Arrays.asList(goods), sessionId));
// }
// cartGoodsList = temList;
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
sessionId
,
""
,
shoppingCartBaseService
);
...
...
@@ -695,8 +845,8 @@ public class ShoppingCartMCoffeeServiceImpl {
if
(
shoppingCartInfoRequestVo
.
getIsUseMonthCard
()
!=
null
&&
goods
.
getMonthCardInfo
()
!=
null
)
{
goods
.
getMonthCardInfo
().
setIsUseMonthCard
(
shoppingCartInfoRequestVo
.
getIsUseMonthCard
());
}
if
(
shoppingCartInfoRequestVo
.
getIsUseB3S
3
Coupon
()
!=
null
&&
goods
.
getB3S1CouponGoodsInfo
()
!=
null
)
{
goods
.
get
MonthCardInfo
().
setIsUseMonthCard
(
shoppingCartInfoRequestVo
.
getIsUseMonthCard
());
if
(
shoppingCartInfoRequestVo
.
getIsUseB3S
1
Coupon
()
!=
null
&&
goods
.
getB3S1CouponGoodsInfo
()
!=
null
)
{
goods
.
get
B3S1CouponGoodsInfo
().
setIsUseB3S1Coupon
(
shoppingCartInfoRequestVo
.
getIsUseB3S1Coupon
());
}
if
(
StringUtils
.
equals
(
goods
.
getSkuId
(),
"9999"
)){
monthCardProduct
=
goods
;
...
...
@@ -2439,4 +2589,13 @@ public class ShoppingCartMCoffeeServiceImpl {
}
return
cartGoods
.
stream
().
filter
(
t
->
!
StringUtils
.
equals
(
"9999"
,
t
.
getSkuId
())
&&
!
t
.
getCartGoodsUid
().
equals
(
cartGoodsUid
)).
collect
(
Collectors
.
toList
());
}
/**
* 清除购物车商品使用买3赠1券信息
* @param couponCode
*/
private
List
<
CartGoods
>
clearB3S1CouponInfo
(
List
<
CartGoods
>
cartGoodsList
,
String
couponCode
){
cartGoodsList
.
removeIf
(
o
->
couponCode
.
equals
(
o
.
getCouponCode
()));
return
cartGoodsList
;
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/CouponDiscountCalculation.java
View file @
5afb50c3
...
...
@@ -167,6 +167,7 @@ public class CouponDiscountCalculation {
List
<
CartGoods
>
newCartGoodsList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
cartGoodsList
.
size
();
i
++)
{
CartGoods
cartGoods
=
cartGoodsList
.
get
(
i
);
cartGoods
.
setIsB3S1CouponGoods
(
0
);
if
(
"9998"
.
equals
(
cartGoods
.
getSkuId
()))
{
continue
;
}
...
...
@@ -204,6 +205,7 @@ public class CouponDiscountCalculation {
cartGoods
.
setQty
(
b3S1DiscountOptional
.
get
().
getActualGoodsNumber
());
cartGoods
.
setCouponName
(
b3S1DiscountOptional
.
get
().
getActivityName
());
cartGoods
.
setCouponCode
(
b3S1DiscountOptional
.
get
().
getActivityCode
());
cartGoods
.
setIsB3S1Coupon
(
1
);
CartGoods
cartGoodsNew
=
new
CartGoods
();
BeanUtils
.
copyProperties
(
cartGoods
,
cartGoodsNew
);
cartGoodsNew
.
setCartGoodsUid
(
UUID
.
randomUUID
().
toString
());
...
...
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