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
1b93a61a
Commit
1b93a61a
authored
Aug 06, 2021
by
胡博文
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/bowen-fix-cartlimit'
parents
91741560
24fe754b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
69 deletions
+69
-69
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+69
-69
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
1b93a61a
...
...
@@ -353,7 +353,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
Integer
checkQty
=
this
.
checkSkuQty
(
allCartGoodsList
,
cartGoods
);
//购物车添加数量限制
//
Integer productsCount = limitGoodsQty(allCartGoodsList, cartGoods, appId);
Integer
productsCount
=
limitGoodsQty
(
allCartGoodsList
,
cartGoods
,
appId
);
//查询多个商品库存信息 TODO
queryManyGoodsStocks
(
addShoppingCartGoodsRequestVo
,
productIds
,
productBeanListSpuClass
,
skuId
,
checkQty
);
String
productName
=
null
;
...
...
@@ -404,9 +404,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
// 获取优惠信息
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
=
getCalculationDiscountResult
(
menuType
,
partnerId
,
storeId
,
userId
,
appId
,
userLoginInfoDto
.
getWxAppid
(),
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
allCartGoodsList
,
new
ArrayList
(),
new
ArrayList
<>(),
null
,
deliveryAmount
);
//
if (calculationDiscountResult != null && CollectionUtils.isNotEmpty(calculationDiscountResult.getSendGoods())) {
//
sendGoodsQtyCheck(productsCount, appId, partnerId, userId, storeId, tableNumber, oldCartGoodsList, shoppingCartBaseService, calculationDiscountResult.getSendGoods());
//
}
if
(
calculationDiscountResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getSendGoods
()))
{
sendGoodsQtyCheck
(
productsCount
,
appId
,
partnerId
,
userId
,
storeId
,
tableNumber
,
oldCartGoodsList
,
shoppingCartBaseService
,
calculationDiscountResult
.
getSendGoods
());
}
// 当商品数量被设为0时
if
(
Objects
.
equals
(
cartGoods
.
getQty
(),
0
))
{
...
...
@@ -2619,39 +2619,39 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if
(
Objects
.
nonNull
(
cartGoods
))
{
qty
+=
cartGoods
.
getQty
();
}
//
String redisKey = limitCartKey + appid;
//
//
Object value = redisCache.hashGet(redisKey, "2");
//
if (value == null) {
//
return qty;
//
} else {
//
boolean bool = value.getClass().getName().equals("java.lang.String");
//
if (bool) {
//
return qty;
//
}
//
JSONArray jsonArray = (JSONArray) value;
//
int cartLimitFlag = 0;
//
int cartLimitCount = 0;
//
for (Object object : jsonArray) {
//
JSONObject jsonObject = (JSONObject) object;
//
HashMap hashMap = JSONObject.parseObject(jsonObject.toJSONString(), HashMap.class);
//
if ("cartLimitFlag".equals(hashMap.get("appKey"))) {
//
if (StringUtils.isBlank((String) hashMap.get("appValue"))) {
//
return qty;
//
}
//
cartLimitFlag = Integer.parseInt((String) hashMap.get("appValue"));
//
}
//
if ("cartLimitCount".equals(hashMap.get("appKey"))) {
//
if (StringUtils.isBlank((String) hashMap.get("appValue"))) {
//
return qty;
//
}
//
cartLimitCount = Integer.parseInt((String) hashMap.get("appValue"));
//
}
//
}
//
if (cartLimitFlag == 1 && cartLimitCount != 0 && qty > cartLimitCount) {
//
throw new ServiceException(ResponseResult.SHOPPING_CART_LIMIT_ADD);
//
}
//
}
String
redisKey
=
limitCartKey
+
appid
;
Object
value
=
redisCache
.
hashGet
(
redisKey
,
"2"
);
if
(
value
==
null
)
{
return
qty
;
}
else
{
boolean
bool
=
value
.
getClass
().
getName
().
equals
(
"java.lang.String"
);
if
(
bool
)
{
return
qty
;
}
JSONArray
jsonArray
=
(
JSONArray
)
value
;
int
cartLimitFlag
=
0
;
int
cartLimitCount
=
0
;
for
(
Object
object
:
jsonArray
)
{
JSONObject
jsonObject
=
(
JSONObject
)
object
;
HashMap
hashMap
=
JSONObject
.
parseObject
(
jsonObject
.
toJSONString
(),
HashMap
.
class
);
if
(
"cartLimitFlag"
.
equals
(
hashMap
.
get
(
"appKey"
)))
{
if
(
StringUtils
.
isBlank
((
String
)
hashMap
.
get
(
"appValue"
)))
{
return
qty
;
}
cartLimitFlag
=
Integer
.
parseInt
((
String
)
hashMap
.
get
(
"appValue"
));
}
if
(
"cartLimitCount"
.
equals
(
hashMap
.
get
(
"appKey"
)))
{
if
(
StringUtils
.
isBlank
((
String
)
hashMap
.
get
(
"appValue"
)))
{
return
qty
;
}
cartLimitCount
=
Integer
.
parseInt
((
String
)
hashMap
.
get
(
"appValue"
));
}
}
if
(
cartLimitFlag
==
1
&&
cartLimitCount
!=
0
&&
qty
>
cartLimitCount
)
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_LIMIT_ADD
);
}
}
return
qty
;
}
...
...
@@ -2671,38 +2671,38 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
String
redisKey
=
limitCartKey
+
appid
;
//
Object value = redisCache.hashGet(redisKey, "2");
//
if (value == null) {
//
return;
//
} else {
//
boolean bool = value.getClass().getName().equals("java.lang.String");
//
if (bool) {
//
return;
//
}
//
JSONArray jsonArray = (JSONArray) value;
//
int cartLimitFlag = 0;
//
int cartLimitCount = 0;
//
for (Object object : jsonArray) {
//
JSONObject jsonObject = (JSONObject) object;
//
HashMap hashMap = JSONObject.parseObject(jsonObject.toJSONString(), HashMap.class);
//
if ("cartLimitFlag".equals(hashMap.get("appKey"))) {
//
if (StringUtils.isBlank((String) hashMap.get("appValue"))) {
//
return;
//
}
//
cartLimitFlag = Integer.parseInt((String) hashMap.get("appValue"));
//
}
//
if ("cartLimitCount".equals(hashMap.get("appKey"))) {
//
if (StringUtils.isBlank((String) hashMap.get("appValue"))) {
//
return;
//
}
//
cartLimitCount = Integer.parseInt((String) hashMap.get("appValue"));
//
}
//
}
//
if (cartLimitFlag == 1 && cartLimitCount != 0 && checkQty + sendQty > cartLimitCount) {
//
assortmentSdkService.setShoppingCart(partnerId, storeId, userId, oldCartGoodsList, null, tableNumber, shoppingCartService);
//
throw new ServiceException(ResponseResult.SHOPPING_CART_LIMIT_ADD);
//
}
//
}
Object
value
=
redisCache
.
hashGet
(
redisKey
,
"2"
);
if
(
value
==
null
)
{
return
;
}
else
{
boolean
bool
=
value
.
getClass
().
getName
().
equals
(
"java.lang.String"
);
if
(
bool
)
{
return
;
}
JSONArray
jsonArray
=
(
JSONArray
)
value
;
int
cartLimitFlag
=
0
;
int
cartLimitCount
=
0
;
for
(
Object
object
:
jsonArray
)
{
JSONObject
jsonObject
=
(
JSONObject
)
object
;
HashMap
hashMap
=
JSONObject
.
parseObject
(
jsonObject
.
toJSONString
(),
HashMap
.
class
);
if
(
"cartLimitFlag"
.
equals
(
hashMap
.
get
(
"appKey"
)))
{
if
(
StringUtils
.
isBlank
((
String
)
hashMap
.
get
(
"appValue"
)))
{
return
;
}
cartLimitFlag
=
Integer
.
parseInt
((
String
)
hashMap
.
get
(
"appValue"
));
}
if
(
"cartLimitCount"
.
equals
(
hashMap
.
get
(
"appKey"
)))
{
if
(
StringUtils
.
isBlank
((
String
)
hashMap
.
get
(
"appValue"
)))
{
return
;
}
cartLimitCount
=
Integer
.
parseInt
((
String
)
hashMap
.
get
(
"appValue"
));
}
}
if
(
cartLimitFlag
==
1
&&
cartLimitCount
!=
0
&&
checkQty
+
sendQty
>
cartLimitCount
)
{
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
oldCartGoodsList
,
null
,
tableNumber
,
shoppingCartService
);
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_LIMIT_ADD
);
}
}
}
...
...
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