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
52cb08f5
Commit
52cb08f5
authored
Sep 29, 2020
by
huiyang.chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
06b53272
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
138 additions
and
56 deletions
+138
-56
shopping-cart-application-service/src/main/java/cn/freemud/controller/MCoffeeShoppingCartController.java
+10
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartInfoRequestVo.java
+2
-11
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+111
-45
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/entity/MCoffeeCardAddVo.java
+15
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/controller/MCoffeeShoppingCartController.java
View file @
52cb08f5
...
...
@@ -5,6 +5,7 @@ import cn.freemud.entities.vo.*;
import
cn.freemud.service.impl.mcoffee.ShoppingCartMCoffeeServiceImpl
;
import
cn.freemud.service.impl.mcoffee.entity.CopyShoppingCartRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.MCoffeeCardAddVo
;
import
cn.freemud.service.impl.mcoffee.entity.SwitchShoppingCartRequestVo
;
import
com.freemud.application.sdk.api.log.ApiAnnotation
;
import
com.freemud.application.sdk.api.log.LogParams
;
...
...
@@ -58,6 +59,15 @@ public class MCoffeeShoppingCartController {
}
/**
* 修改或者新增购物车中商品
*/
@ApiAnnotation
(
logMessage
=
"updateGoodsByCard"
)
@PostMapping
(
value
=
"/card/updateGoods"
)
public
BaseResponse
updateGoodsByCard
(
@Validated
@LogParams
@RequestBody
MCoffeeCardAddVo
request
)
{
return
shoppingCartMCoffeeService
.
updateGoodsByCard
(
request
);
}
/**
* 查询购物车信息
*/
@ApiAnnotation
(
logMessage
=
"listCartGoods"
)
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/ShoppingCartInfoRequestVo.java
View file @
52cb08f5
...
...
@@ -116,17 +116,8 @@ public class ShoppingCartInfoRequestVo extends BaseRequestVo {
}
/**
*
万能券、咖啡月
卡券
*
运费
卡券
*/
private
String
coffeeCouponCode
;
/**
*
*/
private
String
coffeeCouponName
;
/**
* 咖啡月卡适用商品id
*/
private
List
<
String
>
goodsId
;
private
String
freightCouponCode
;
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
52cb08f5
...
...
@@ -19,8 +19,10 @@ import cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl;
import
cn.freemud.service.impl.mcoffee.calculation.CouponDiscountCalculation
;
import
cn.freemud.service.impl.mcoffee.entity.CopyShoppingCartRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.MCoffeeAddGoodsRequestVo
;
import
cn.freemud.service.impl.mcoffee.entity.MCoffeeCardAddVo
;
import
cn.freemud.service.impl.mcoffee.entity.SwitchShoppingCartRequestVo
;
import
cn.freemud.service.thirdparty.CustomerApplicationClient
;
import
cn.freemud.utils.BeanUtil
;
import
cn.freemud.utils.ResponseUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -305,53 +307,11 @@ public class ShoppingCartMCoffeeServiceImpl {
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
cartGoodsList
);
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
sessionId
,
""
,
shoppingCartBaseService
);
//校验咖啡月卡的商品是否在购物车里面存在
List
<
String
>
goodsId
=
shoppingCartInfoRequestVo
.
getGoodsId
();
if
(
CollectionUtils
.
isNotEmpty
(
goodsId
)
&&
StringUtils
.
isNotEmpty
(
shoppingCartInfoRequestVo
.
getCoffeeCouponCode
())){
List
<
CartGoods
>
cartGoodsListNew
=
new
ArrayList
<>();
for
(
String
id:
goodsId
)
{
List
<
CartGoods
>
CartGoodsList
=
cartGoodsList
.
stream
().
filter
(
t
->
t
.
getGoodsId
().
equals
(
id
)).
collect
(
Collectors
.
toList
());
cartGoodsListNew
.
addAll
(
CartGoodsList
);
}
if
(
CollectionUtils
.
isEmpty
(
cartGoodsListNew
)){
return
ResponseUtil
.
error
(
ResponseResult
.
SHOPPING_CART_GOODS_CHECK_ERROR
);
}
CartGoods
cartGoods
=
cartGoodsListNew
.
stream
().
max
(
Comparator
.
comparing
(
CartGoods:
:
getOriginalPrice
)).
get
();
if
(
cartGoods
!=
null
){
//修改购物车商品数量
UpdateShoppingCartGoodsQtyRequestVo
vo
=
new
UpdateShoppingCartGoodsQtyRequestVo
();
vo
.
setCartGoodsUid
(
cartGoods
.
getCartGoodsUid
());
vo
.
setPartnerId
(
partnerId
);
vo
.
setQty
(
cartGoods
.
getQty
()
-
1
);
vo
.
setOrderType
(
orderType
);
vo
.
setShopId
(
storeId
);
vo
.
setMenuType
(
menuType
);
vo
.
setChannelType
(
shoppingCartInfoRequestVo
.
getChannelType
());
vo
.
setAppId
(
appId
);
vo
.
setSessionId
(
shoppingCartInfoRequestVo
.
getSessionId
());
updateGoodsQty
(
vo
);
//添加商品券到购物车
MCoffeeAddGoodsRequestVo
requestVo
=
new
MCoffeeAddGoodsRequestVo
();
requestVo
.
setAppId
(
appId
);
requestVo
.
setCategoryName
(
"DSPQ"
);
requestVo
.
setCategoryName
(
shoppingCartInfoRequestVo
.
getCoffeeCouponName
());
requestVo
.
setChannelType
(
shoppingCartInfoRequestVo
.
getChannelType
());
requestVo
.
setMenuType
(
menuType
);
requestVo
.
setOrderType
(
orderType
);
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setQty
(
1
);
requestVo
.
setShopId
(
storeId
);
requestVo
.
setSkuId
(
cartGoods
.
getSkuId
());
requestVo
.
setSpuId
(
cartGoods
.
getSpuId
());
requestVo
.
setSessionId
(
shoppingCartInfoRequestVo
.
getSessionId
());
requestVo
.
setCouponCode
(
shoppingCartInfoRequestVo
.
getCoffeeCouponCode
());
addGoods
(
requestVo
);
}
}
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
sessionId
,
""
,
shoppingCartBaseService
);
}
// 当couponCode不为空时,需参与价格计算
if
(
StringUtils
.
isNotEmpty
(
shoppingCartInfoRequestVo
.
getFreightCouponCode
())){
couponCode
=
couponCode
+
","
+
shoppingCartInfoRequestVo
.
getFreightCouponCode
();
}
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
);
// 促销活动的优惠金额计算
...
...
@@ -1047,4 +1007,110 @@ public class ShoppingCartMCoffeeServiceImpl {
}
public
BaseResponse
updateGoodsByCard
(
MCoffeeCardAddVo
cardAddVo
)
{
// 参数校验
if
(
StringUtils
.
isEmpty
(
cardAddVo
.
getShopId
()))
{
return
ResponseUtil
.
error
(
ResponseResult
.
SHOPPING_CART_SHOP_ID_NOT_EMPTY
);
}
if
(
cardAddVo
.
getQty
()
!=
null
&&
cardAddVo
.
getQty
()
<
0
)
{
return
ResponseUtil
.
error
(
ResponseResult
.
SHOPPING_CART_ADD_ERROR
);
}
String
sessionId
=
cardAddVo
.
getSessionId
();
// 获取用户信息
CustomerInfoVo
assortmentCustomerInfoVo
=
getCustomerInfoVo
(
sessionId
);
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
=
new
ShoppingCartGoodsResponseVo
();
String
userId
=
assortmentCustomerInfoVo
.
getMemberId
();
String
partnerId
=
cardAddVo
.
getPartnerId
();
String
storeId
=
cardAddVo
.
getShopId
();
String
appId
=
cardAddVo
.
getAppId
();
String
spuId
=
cardAddVo
.
getSpuId
();
String
skuId
=
StringUtils
.
isNotBlank
(
cardAddVo
.
getSkuId
())
?
cardAddVo
.
getSkuId
()
:
""
;
String
goodsId
=
StringUtils
.
isEmpty
(
skuId
)
?
spuId
:
skuId
;
String
menuType
=
cardAddVo
.
getMenuType
();
Integer
orderType
=
cardAddVo
.
getOrderType
();
String
couponCode
=
cardAddVo
.
getCouponCode
();
String
receiveId
=
cardAddVo
.
getReceiveId
();
// 查询购物车缓存
List
<
CartGoods
>
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
null
,
null
,
shoppingCartBaseService
);
// 如果购物车商品不为空, 则check购物车中所有商品
if
(
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
// check购物车中所有商品
cartGoodsList
=
checkCartGoods
(
partnerId
,
storeId
,
orderType
,
menuType
,
shoppingCartGoodsResponseVo
,
cartGoodsList
);
// 重新存储最新购物车
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
cartGoodsList
,
sessionId
,
""
,
shoppingCartBaseService
);
if
(
StringUtils
.
isNotEmpty
(
couponCode
)
&&
StringUtils
.
isNotEmpty
(
goodsId
))
{
CartGoods
couponGoods
=
cartGoodsList
.
stream
().
findFirst
().
filter
(
t
->
t
.
getCouponCode
().
equals
(
couponCode
)).
get
();
CartGoods
cartGoods
=
cartGoodsList
.
stream
().
findFirst
().
filter
(
t
->
(
t
.
getGoodsId
().
equals
(
goodsId
)
&&
(!
t
.
getCartGoodsUid
().
equals
(
couponGoods
.
getCartGoodsUid
())))).
get
();
if
(
cartGoods
!=
null
)
{
if
(
cardAddVo
.
getIsSelect
())
{
//修改购物车商品数量
UpdateShoppingCartGoodsQtyRequestVo
vo
=
updateCartVo
(
cartGoods
,
cardAddVo
,
false
);
updateGoodsQty
(
vo
);
//添加商品券到购物车
MCoffeeAddGoodsRequestVo
requestVo
=
addCartVO
(
cardAddVo
,
true
);
addGoods
(
requestVo
);
}
else
{
if
(
couponGoods
!=
null
)
{
//删除购物车行,因为商品券再购物车始终是一
UpdateShoppingCartGoodsQtyRequestVo
vo
=
updateCartVo
(
cartGoods
,
cardAddVo
,
false
);
updateGoodsQty
(
vo
);
if
(
cartGoods
.
getQty
()
>=
1
)
{
//修改购物车商品数量
UpdateShoppingCartGoodsQtyRequestVo
requestVo
=
updateCartVo
(
couponGoods
,
cardAddVo
,
true
);
updateGoodsQty
(
requestVo
);
}
else
{
MCoffeeAddGoodsRequestVo
requestVo
=
addCartVO
(
cardAddVo
,
false
);
addGoods
(
requestVo
);
}
}
}
}
cartGoodsList
=
assortmentSdkService
.
getShoppingCart
(
partnerId
,
storeId
,
userId
,
null
,
null
,
shoppingCartBaseService
);
}
}
// 当couponCode不为空时,需参与价格计算
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
getCoupon
(
couponCode
,
null
,
cartGoodsList
);
// 促销活动的优惠金额计算
calculationService
.
updateShoppingCartGoodsDiscount
(
partnerId
,
storeId
,
userId
,
appId
,
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
menuType
,
receiveId
,
null
,
cartGoodsList
,
coupons
,
new
ArrayList
<>(),
shoppingCartGoodsResponseVo
);
//设置更新响应信息
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
=
new
ShoppingCartInfoRequestVo
();
BeanUtil
.
convertBean
(
cardAddVo
,
shoppingCartInfoRequestVo
);
setAddAndUpdateResponse
(
shoppingCartGoodsResponseVo
,
cartGoodsList
,
shoppingCartGoodsResponseVo
.
getToastMsg
(),
ShoppingCartConstant
.
QUERY_INFO
,
shoppingCartInfoRequestVo
);
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
}
private
UpdateShoppingCartGoodsQtyRequestVo
updateCartVo
(
CartGoods
cartGoods
,
MCoffeeCardAddVo
cardAddVo
,
Boolean
isAdd
){
UpdateShoppingCartGoodsQtyRequestVo
vo
=
new
UpdateShoppingCartGoodsQtyRequestVo
();
vo
.
setCartGoodsUid
(
cartGoods
.
getCartGoodsUid
());
vo
.
setPartnerId
(
cardAddVo
.
getPartnerId
());
if
(
isAdd
){
vo
.
setQty
(
cartGoods
.
getQty
()
+
1
);
}
else
{
vo
.
setQty
(
cartGoods
.
getQty
()
-
1
);
}
vo
.
setOrderType
(
cardAddVo
.
getOrderType
());
vo
.
setShopId
(
cardAddVo
.
getShopId
());
vo
.
setMenuType
(
cardAddVo
.
getMenuType
());
vo
.
setChannelType
(
cardAddVo
.
getChannelType
());
vo
.
setAppId
(
cardAddVo
.
getAppId
());
vo
.
setSessionId
(
cardAddVo
.
getSessionId
());
return
vo
;
}
private
MCoffeeAddGoodsRequestVo
addCartVO
(
MCoffeeCardAddVo
cardAddVo
,
Boolean
isCoupon
){
MCoffeeAddGoodsRequestVo
requestVo
=
new
MCoffeeAddGoodsRequestVo
();
BeanUtil
.
convertBean
(
cardAddVo
,
requestVo
);
requestVo
.
setQty
(
1
);
if
(
isCoupon
)
{
requestVo
.
setCategoryName
(
"DSPQ"
);
requestVo
.
setCouponCode
(
cardAddVo
.
getCouponCode
());
}
return
requestVo
;
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/entity/MCoffeeCardAddVo.java
0 → 100644
View file @
52cb08f5
package
cn
.
freemud
.
service
.
impl
.
mcoffee
.
entity
;
import
lombok.Data
;
@Data
public
class
MCoffeeCardAddVo
extends
MCoffeeAddGoodsRequestVo
{
/**
* true : 选中
* false : 取消选中
*/
private
Boolean
isSelect
;
}
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