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
ca854274
Commit
ca854274
authored
Feb 15, 2022
by
周晓航
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ka-商品技术需求购物车不校验商品库存'
parents
440ff24c
6ed92f00
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
32 deletions
+24
-32
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+24
-32
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
ca854274
...
@@ -627,22 +627,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -627,22 +627,12 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
ShoppingCartConvertAdapter
.
setClassification
(
cartGoods
,
getProductsVo
);
ShoppingCartConvertAdapter
.
setClassification
(
cartGoods
,
getProductsVo
);
GetProductStockRequestDto
requestDto
=
new
GetProductStockRequestDto
();
this
.
commonItemVerfity
(
BusinessTypeEnum
.
getByType
(
updateShoppingCartGoodsQtyRequestVo
.
getMenuType
()).
getCode
(),
requestDto
.
setChannel
(
BusinessTypeEnum
.
getByType
(
updateShoppingCartGoodsQtyRequestVo
.
getMenuType
()).
getCode
());
partnerId
,
requestDto
.
setPartnerId
(
partnerId
);
storeId
,
requestDto
.
setStoreId
(
storeId
);
Collections
.
singletonList
(
Long
.
parseLong
(
cartGoods
.
getGoodsId
())),
requestDto
.
setProductIds
(
Collections
.
singletonList
(
Long
.
parseLong
(
cartGoods
.
getGoodsId
())));
qty
);
GetProductStockResponseDto
availableStocks
=
stockClient
.
getAvailableStocks
(
requestDto
);
if
(
availableStocks
==
null
||
!
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
.
equals
(
availableStocks
.
getCode
()))
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
}
int
stock
=
CollectionUtils
.
isEmpty
(
availableStocks
.
getResult
())
||
availableStocks
.
getResult
().
get
(
0
).
getQty
()
==
null
?
0
:
availableStocks
.
getResult
().
get
(
0
).
getQty
();
if
(
stock
<=
0
)
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
}
else
if
(
stock
<
qty
)
{
throw
new
BizServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
,
"仅剩"
+
stock
+
"件库存了"
);
}
}
}
...
@@ -2362,12 +2352,26 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -2362,12 +2352,26 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if
(!
isLimit
)
{
if
(!
isLimit
)
{
return
;
return
;
}
}
this
.
commonItemVerfity
(
BusinessTypeEnum
.
getByType
(
addShoppingCartGoodsRequestVo
.
getMenuType
()).
getCode
(),
addShoppingCartGoodsRequestVo
.
getPartnerId
(),
addShoppingCartGoodsRequestVo
.
getShopId
(),
productIds
,
qty
);
}
private
void
commonItemVerfity
(
String
channel
,
String
partnerId
,
String
storeId
,
List
<
Long
>
productIds
,
Integer
qty
){
GetProductStockRequestDto
requestDto
=
new
GetProductStockRequestDto
();
GetProductStockRequestDto
requestDto
=
new
GetProductStockRequestDto
();
requestDto
.
setChannel
(
BusinessTypeEnum
.
getByType
(
addShoppingCartGoodsRequestVo
.
getMenuType
()).
getCode
()
);
requestDto
.
setChannel
(
BusinessTypeEnum
.
getByType
(
channel
);
requestDto
.
setPartnerId
(
addShoppingCartGoodsRequestVo
.
getPartnerId
()
);
requestDto
.
setPartnerId
(
partnerId
);
requestDto
.
setStoreId
(
addShoppingCartGoodsRequestVo
.
getShopId
()
);
requestDto
.
setStoreId
(
storeId
);
requestDto
.
setProductIds
(
productIds
);
requestDto
.
setProductIds
(
productIds
);
GetProductStockResponseDto
availableStocks
=
stockClient
.
getAvailableStocks
(
requestDto
);
GetProductStockResponseDto
availableStocks
=
stockClient
.
getAvailableStocks
(
requestDto
);
this
.
finalVerfity
(
availableStocks
,
qty
);
}
private
void
finalVerfity
(
GetProductStockResponseDto
availableStocks
,
Integer
qty
)
{
// 商品服务 返回null 或者 qty=null 表示不限制库存
// 商品服务 返回null 或者 qty=null 表示不限制库存
if
(
Objects
.
isNull
(
availableStocks
))
{
if
(
Objects
.
isNull
(
availableStocks
))
{
return
;
return
;
...
@@ -2386,7 +2390,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -2386,7 +2390,6 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
else
if
(
stock
<
qty
)
{
}
else
if
(
stock
<
qty
)
{
throw
new
BizServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
,
"仅剩"
+
stock
+
"件库存了"
);
throw
new
BizServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
,
"仅剩"
+
stock
+
"件库存了"
);
}
}
}
}
/**
/**
...
@@ -3507,18 +3510,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -3507,18 +3510,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
}
}
}
}
if
(
availableStocks
!=
null
&&
!
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
.
equals
(
availableStocks
.
getCode
()))
{
this
.
finalVerfity
(
availableStocks
,
qty
);
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
}
if
(
availableStocks
!=
null
&&
ResponseCodeConstant
.
RESPONSE_SUCCESS_STR
.
equals
(
availableStocks
.
getCode
())
&&
(
CollectionUtils
.
isEmpty
(
availableStocks
.
getResult
())
||
availableStocks
.
getResult
().
get
(
0
).
getQty
()
==
null
||
availableStocks
.
getResult
().
get
(
0
).
getQty
()
<
qty
))
{
Integer
stock
=
0
;
if
(!
CollectionUtils
.
isEmpty
(
availableStocks
.
getResult
())
&&
(
stock
=
availableStocks
.
getResult
().
get
(
0
).
getQty
())
>
0
)
{
throw
new
BizServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
,
"仅剩"
+
stock
+
"件库存了"
);
}
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_STOCK_NOT_HAVE
);
}
}
}
...
...
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