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
78c83097
Commit
78c83097
authored
Sep 17, 2020
by
ping.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
赠送商品限制数量
parent
324bb936
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
4 deletions
+85
-4
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+85
-4
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
78c83097
...
@@ -33,6 +33,7 @@ import cn.freemud.interceptor.BizServiceException;
...
@@ -33,6 +33,7 @@ import cn.freemud.interceptor.BizServiceException;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.service.*
;
import
cn.freemud.service.*
;
import
cn.freemud.service.thirdparty.*
;
import
cn.freemud.service.thirdparty.*
;
import
cn.freemud.utils.BeanUtil
;
import
cn.freemud.utils.PromotionFactory
;
import
cn.freemud.utils.PromotionFactory
;
import
cn.freemud.utils.PropertyConvertUtil
;
import
cn.freemud.utils.PropertyConvertUtil
;
import
cn.freemud.utils.ResponseUtil
;
import
cn.freemud.utils.ResponseUtil
;
...
@@ -144,6 +145,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -144,6 +145,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
@Autowired
@Autowired
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
private
static
final
String
limitCartKey
=
"ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"
;
/**
/**
* 从微信卡券向购物车中添加商品
* 从微信卡券向购物车中添加商品
...
@@ -233,6 +236,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -233,6 +236,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
String
menuType
=
addShoppingCartGoodsRequestVo
.
getMenuType
();
String
menuType
=
addShoppingCartGoodsRequestVo
.
getMenuType
();
Integer
orderType
=
addShoppingCartGoodsRequestVo
.
getOrderType
();
Integer
orderType
=
addShoppingCartGoodsRequestVo
.
getOrderType
();
String
receiveId
=
addShoppingCartGoodsRequestVo
.
getReceiveId
();
String
receiveId
=
addShoppingCartGoodsRequestVo
.
getReceiveId
();
String
tableNumber
=
addShoppingCartGoodsRequestVo
.
getTableNumber
();
CartGoods
cartGoods
=
ShoppingCartConvertAdapter
.
convent2CartGoods
(
addShoppingCartGoodsRequestVo
);
CartGoods
cartGoods
=
ShoppingCartConvertAdapter
.
convent2CartGoods
(
addShoppingCartGoodsRequestVo
);
List
<
Long
>
productIds
=
new
ArrayList
<>();
List
<
Long
>
productIds
=
new
ArrayList
<>();
...
@@ -254,6 +258,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -254,6 +258,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if
(
CollectionUtils
.
isEmpty
(
allCartGoodsList
))
{
if
(
CollectionUtils
.
isEmpty
(
allCartGoodsList
))
{
allCartGoodsList
=
new
ArrayList
<>();
allCartGoodsList
=
new
ArrayList
<>();
}
}
List
<
CartGoods
>
oldCartGoodsList
=
BeanUtil
.
convertBeans
(
allCartGoodsList
,
CartGoods:
:
new
);
/**
/**
Integer checkQty = allCartGoodsList.indexOf(cartGoods) != -1 ?
Integer checkQty = allCartGoodsList.indexOf(cartGoods) != -1 ?
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
allCartGoodsList.get(allCartGoodsList.indexOf(cartGoods)).getQty() + cartGoods.getQty() : cartGoods.getQty();
...
@@ -279,7 +284,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -279,7 +284,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
=
getCalculationDiscountResult
(
menuType
,
partnerId
,
storeId
,
userId
,
appId
,
userLoginInfoDto
.
getWxAppid
(),
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
allCartGoodsList
,
new
ArrayList
(),
new
ArrayList
<>(),
null
,
deliveryAmount
);
=
getCalculationDiscountResult
(
menuType
,
partnerId
,
storeId
,
userId
,
appId
,
userLoginInfoDto
.
getWxAppid
(),
orderType
,
assortmentCustomerInfoVo
.
isMemberPaid
(),
allCartGoodsList
,
new
ArrayList
(),
new
ArrayList
<>(),
null
,
deliveryAmount
);
sendGoodsQtyCheck
(
checkQty
,
appId
,
partnerId
,
userId
,
storeId
,
cartGoods
.
getCartGoodsUid
(),
""
,
shoppingCartBaseService
,
calculationDiscountResult
.
getSendGoods
());
sendGoodsQtyCheck
(
checkQty
,
appId
,
partnerId
,
userId
,
storeId
,
tableNumber
,
oldCartGoodsList
,
shoppingCartBaseService
,
calculationDiscountResult
.
getSendGoods
());
// 当商品数量被设为0时
// 当商品数量被设为0时
if
(
Objects
.
equals
(
cartGoods
.
getQty
(),
0
))
{
if
(
Objects
.
equals
(
cartGoods
.
getQty
(),
0
))
{
assortmentSdkService
.
updateGoodsQtyBySdk
(
partnerId
,
userId
,
storeId
,
cartGoods
.
getCartGoodsUid
(),
0
,
""
,
shoppingCartBaseService
);
assortmentSdkService
.
updateGoodsQtyBySdk
(
partnerId
,
userId
,
storeId
,
cartGoods
.
getCartGoodsUid
(),
0
,
""
,
shoppingCartBaseService
);
...
@@ -380,6 +385,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -380,6 +385,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
shoppingCartGoodsResponseVo
.
setProducts
(
cartGoodsList
);
shoppingCartGoodsResponseVo
.
setProducts
(
cartGoodsList
);
// return shoppingCartGoodsResponseVo;
// return shoppingCartGoodsResponseVo;
}
}
sendGoodsQtyCheckForUpdate
(
qty
,
cartGoods
.
getQty
(),
appId
,
partnerId
,
userId
,
storeId
,
null
,
cartGoodsUid
,
shoppingCartBaseService
,
calculationDiscountResult
.
getSendGoods
());
ActivityQueryDto
activityQueryDto
=
activityAdapter
.
getActivityQueryDto
(
partnerId
,
storeId
,
userId
,
appId
,
updateShoppingCartGoodsQtyRequestVo
.
getOrderType
());
ActivityQueryDto
activityQueryDto
=
activityAdapter
.
getActivityQueryDto
(
partnerId
,
storeId
,
userId
,
appId
,
updateShoppingCartGoodsQtyRequestVo
.
getOrderType
());
...
@@ -1642,10 +1648,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1642,10 +1648,9 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
* 查询生态配置限制加购开关与限制数量
* 查询生态配置限制加购开关与限制数量
*/
*/
public
void
limitGoodsQty
(
Integer
qty
,
String
appid
){
public
void
limitGoodsQty
(
Integer
qty
,
String
appid
){
String
redisKey
=
"ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"
+
appid
;
String
redisKey
=
limitCartKey
+
appid
;
Object
value
=
redisCache
.
hashGet
(
redisKey
,
"2"
);
Object
value
=
redisCache
.
hashGet
(
redisKey
,
"2"
);
List
<
AssortmentOpenPlatformPartnerWxappConfig
>
configs
=
null
;
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
;
return
;
}
else
{
}
else
{
...
@@ -1670,7 +1675,83 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1670,7 +1675,83 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
}
}
public
void
sendGoodsQtyCheck
(
Integer
qty
,
String
appid
,
String
partnerId
,
String
userId
,
String
storeId
,
String
cartGoodsUid
,
String
tableNumber
,
ShoppingCartBaseService
shoppingCartService
,
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
sendGoods
){
/**
* 购物车添加完成后促销返回赠送商品总数量校验
*/
public
void
sendGoodsQtyCheck
(
Integer
checkQty
,
String
appid
,
String
partnerId
,
String
userId
,
String
storeId
,
String
tableNumber
,
List
<
CartGoods
>
oldCartGoodsList
,
ShoppingCartBaseService
shoppingCartService
,
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
sendActivitys
){
if
(
CollectionUtils
.
isEmpty
(
sendActivitys
)){
return
;
}
int
sendQty
=
0
;
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
sendActivity
:
sendActivitys
){
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
sendGoods
:
sendActivity
.
getSendGoods
()){
sendQty
+=
sendGoods
.
getSendNumber
();
}
}
String
redisKey
=
limitCartKey
+
appid
;
Object
value
=
redisCache
.
hashGet
(
redisKey
,
"2"
);
if
(
value
==
null
)
{
return
;
}
else
{
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"
))){
cartLimitFlag
=
Integer
.
parseInt
((
String
)
hashMap
.
get
(
"appValue"
));
}
if
(
"cartLimitCount"
.
equals
(
hashMap
.
get
(
"appKey"
))){
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
);
}
}
}
/**
* 购物车添加完成后促销返回赠送商品总数量校验
*/
public
void
sendGoodsQtyCheckForUpdate
(
Integer
updateQty
,
Integer
goodsQty
,
String
appid
,
String
partnerId
,
String
userId
,
String
storeId
,
String
cartGoodsUid
,
String
tableNumber
,
ShoppingCartBaseService
shoppingCartService
,
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
sendActivitys
){
if
(
CollectionUtils
.
isEmpty
(
sendActivitys
)){
return
;
}
int
sendQty
=
0
;
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
sendActivity
:
sendActivitys
){
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
sendGoods
:
sendActivity
.
getSendGoods
()){
sendQty
+=
sendGoods
.
getSendNumber
();
}
}
String
redisKey
=
limitCartKey
+
appid
;
Object
value
=
redisCache
.
hashGet
(
redisKey
,
"2"
);
if
(
value
==
null
)
{
return
;
}
else
{
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"
))){
cartLimitFlag
=
Integer
.
parseInt
((
String
)
hashMap
.
get
(
"appValue"
));
}
if
(
"cartLimitCount"
.
equals
(
hashMap
.
get
(
"appKey"
))){
cartLimitCount
=
Integer
.
parseInt
((
String
)
hashMap
.
get
(
"appValue"
));
}
}
if
(
cartLimitFlag
==
1
&&
cartLimitCount
!=
0
&&
updateQty
+
sendQty
>
cartLimitCount
){
assortmentSdkService
.
updateGoodsQtyBySdk
(
partnerId
,
userId
,
storeId
,
cartGoodsUid
,
goodsQty
,
""
,
shoppingCartBaseService
);
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