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
c209442f
Commit
c209442f
authored
Jun 09, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add:通spu+sku识别商品数量
parent
b7a7c50f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
3 deletions
+26
-3
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+26
-3
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
c209442f
...
@@ -247,8 +247,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -247,8 +247,11 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if
(
CollectionUtils
.
isEmpty
(
allCartGoodsList
))
{
if
(
CollectionUtils
.
isEmpty
(
allCartGoodsList
))
{
allCartGoodsList
=
new
ArrayList
<>();
allCartGoodsList
=
new
ArrayList
<>();
}
}
Integer
checkQty
=
allCartGoodsList
.
indexOf
(
cartGoods
)
!=
-
1
?
/**
allCartGoodsList
.
get
(
allCartGoodsList
.
indexOf
(
cartGoods
)).
getQty
()
+
cartGoods
.
getQty
()
:
cartGoods
.
getQty
();
Integer checkQty = allCartGoodsList.indexOf(cartGoods) != -1 ?
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
*/
Integer
checkQty
=
this
.
checkSkuQty
(
allCartGoodsList
,
cartGoods
);
//查询多个商品库存信息
//查询多个商品库存信息
queryManyGoodsStocks
(
addShoppingCartGoodsRequestVo
,
productIds
,
productBeanListSpuClass
,
skuId
,
checkQty
);
queryManyGoodsStocks
(
addShoppingCartGoodsRequestVo
,
productIds
,
productBeanListSpuClass
,
skuId
,
checkQty
);
...
@@ -257,7 +260,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -257,7 +260,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 当添加的商品不是商品券时
// 当添加的商品不是商品券时
if
(!
spuId
.
startsWith
(
CommonsConstant
.
COUPON_PREFIX
))
{
if
(!
spuId
.
startsWith
(
CommonsConstant
.
COUPON_PREFIX
))
{
//添加非商品券商品
//添加非商品券商品
addNotProductGoods
(
addShoppingCartGoodsRequestVo
,
cartGoods
,
goodsId
,
userId
,
shoppingCartGoodsResponseVo
,
allCartGoodsList
);
addNotProductGoods
(
addShoppingCartGoodsRequestVo
,
cartGoods
,
goodsId
,
userId
,
shoppingCartGoodsResponseVo
,
allCartGoodsList
);
}
else
{
}
else
{
// 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null
// 当商品是商品券,里面会判断如果购物车中已有商品券,会将cartGoods的CartGoodsUid设为null
this
.
addProductGoods
(
addShoppingCartGoodsRequestVo
,
cartGoods
,
spuId2
,
userId
,
shoppingCartGoodsResponseVo
,
this
.
addProductGoods
(
addShoppingCartGoodsRequestVo
,
cartGoods
,
spuId2
,
userId
,
shoppingCartGoodsResponseVo
,
...
@@ -1510,4 +1513,24 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1510,4 +1513,24 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return
sessionUserInfo
.
getResult
();
return
sessionUserInfo
.
getResult
();
}
}
/**
* 检查sku数量
*
* @param allCartGoodsList
* @param cartGoods
* @return
*/
private
Integer
checkSkuQty
(
List
<
CartGoods
>
allCartGoodsList
,
CartGoods
cartGoods
)
{
Integer
qty
=
0
;
if
(
allCartGoodsList
==
null
)
{
qty
=
cartGoods
.
getQty
();
}
else
{
for
(
CartGoods
goods
:
allCartGoodsList
)
{
if
(
goods
.
getSkuId
().
equals
(
cartGoods
.
getSkuId
())
&&
goods
.
getSpuId
().
equals
(
cartGoods
.
getSpuId
()))
{
qty
=
qty
+
cartGoods
.
getQty
();
}
}
}
return
qty
;
}
}
}
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