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
94637acb
Commit
94637acb
authored
Aug 15, 2020
by
ping.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加购套餐商品数量调整
parent
fbe24166
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
8 deletions
+46
-8
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+46
-8
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
94637acb
...
@@ -13,6 +13,7 @@ import cn.freemud.entities.vo.*;
...
@@ -13,6 +13,7 @@ import cn.freemud.entities.vo.*;
import
cn.freemud.enums.*
;
import
cn.freemud.enums.*
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.ActivityService
;
import
cn.freemud.service.ActivityService
;
import
cn.freemud.service.CouponService
;
import
cn.freemud.service.impl.AssortmentSdkService
;
import
cn.freemud.service.impl.AssortmentSdkService
;
import
cn.freemud.service.impl.FullSubtractionActivityServiceImpl
;
import
cn.freemud.service.impl.FullSubtractionActivityServiceImpl
;
import
cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl
;
import
cn.freemud.service.impl.mcoffee.calculation.CalculationServiceImpl
;
...
@@ -33,6 +34,7 @@ import com.freemud.application.sdk.api.ordercenter.response.orderInfo.QueryByCod
...
@@ -33,6 +34,7 @@ import com.freemud.application.sdk.api.ordercenter.response.orderInfo.QueryByCod
import
com.freemud.application.sdk.api.ordercenter.service.OrderSdkService
;
import
com.freemud.application.sdk.api.ordercenter.service.OrderSdkService
;
import
com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO
;
import
com.freemud.application.sdk.api.productcenter.domain.ProductBeanDTO
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
...
@@ -116,6 +118,10 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -116,6 +118,10 @@ public class ShoppingCartMCoffeeServiceImpl {
productIds
.
add
(
Long
.
parseLong
(
goodsId
));
productIds
.
add
(
Long
.
parseLong
(
goodsId
));
CartGoods
addCartGoods
=
convent2CartGoods
(
addShoppingCartGoodsRequestVo
);
CartGoods
addCartGoods
=
convent2CartGoods
(
addShoppingCartGoodsRequestVo
);
if
(
StringUtils
.
isNotBlank
(
couponCode
)){
String
couponCodespq
=
CommonsConstant
.
COUPON_PREFIX
+
couponCode
;
spuId2
=
validCoupon
(
partnerId
,
storeId
,
couponCodespq
,
productIds
,
BusinessTypeEnum
.
getByType
(
addShoppingCartGoodsRequestVo
.
getMenuType
()).
getCode
());
}
// 获取添加商品的详细信息
// 获取添加商品的详细信息
List
<
ProductBeanDTO
>
productBeanListSpuClass
=
assortmentSdkService
.
getProductsInfoSdk
(
partnerId
,
storeId
,
Collections
.
singletonList
(
spuId2
),
menuType
,
this
.
shoppingCartBaseService
);
List
<
ProductBeanDTO
>
productBeanListSpuClass
=
assortmentSdkService
.
getProductsInfoSdk
(
partnerId
,
storeId
,
Collections
.
singletonList
(
spuId2
),
menuType
,
this
.
shoppingCartBaseService
);
...
@@ -124,6 +130,9 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -124,6 +130,9 @@ public class ShoppingCartMCoffeeServiceImpl {
if
(
CollectionUtils
.
isEmpty
(
oldCartGoodsList
))
{
if
(
CollectionUtils
.
isEmpty
(
oldCartGoodsList
))
{
oldCartGoodsList
=
new
ArrayList
<>();
oldCartGoodsList
=
new
ArrayList
<>();
}
}
//商品券已添加情况校验
//商品券已添加情况校验
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
checkGoodsCoupon
(
oldCartGoodsList
,
operationType
,
couponCode
);
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
coupons
=
checkGoodsCoupon
(
oldCartGoodsList
,
operationType
,
couponCode
);
setClassificationAndPrice
(
addCartGoods
,
productBeanListSpuClass
);
setClassificationAndPrice
(
addCartGoods
,
productBeanListSpuClass
);
...
@@ -151,6 +160,19 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -151,6 +160,19 @@ public class ShoppingCartMCoffeeServiceImpl {
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
return
ResponseUtil
.
success
(
shoppingCartGoodsResponseVo
);
}
}
private
String
validCoupon
(
String
partnerId
,
String
storeId
,
String
spuId
,
List
<
Long
>
productIds
,
String
menuType
)
{
String
spuId2
;
CheckSpqInfoRequestDto
checkSpqInfoRequestDto
=
new
CheckSpqInfoRequestDto
(
partnerId
,
storeId
,
spuId
.
substring
(
CommonsConstant
.
COUPON_PREFIX
.
length
()),
menuType
);
CouponService
couponService
=
SDKCommonBaseContextWare
.
getBean
(
CouponService
.
class
);
CheckSpqInfoResponseDto
checkSpqInfoResponseDto
=
couponService
.
checkSpqInfo
(
checkSpqInfoRequestDto
);
if
(
checkSpqInfoResponseDto
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_COUPON_NOT_EXIST
);
}
productIds
.
add
(
Long
.
parseLong
(
checkSpqInfoResponseDto
.
getSkuId
()));
spuId2
=
checkSpqInfoResponseDto
.
getSkuId
();
return
spuId2
;
}
private
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
checkGoodsCoupon
(
List
<
CartGoods
>
oldCartGoodsList
,
Integer
operationType
,
String
couponCode
)
{
private
List
<
ActivityCalculationDiscountRequestDto
.
CalculationDiscountCoupon
>
checkGoodsCoupon
(
List
<
CartGoods
>
oldCartGoodsList
,
Integer
operationType
,
String
couponCode
)
{
if
(
operationType
!=
null
&&
operationType
==
1
&&
StringUtils
.
isBlank
(
couponCode
))
{
if
(
operationType
!=
null
&&
operationType
==
1
&&
StringUtils
.
isBlank
(
couponCode
))
{
...
@@ -648,9 +670,21 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -648,9 +670,21 @@ public class ShoppingCartMCoffeeServiceImpl {
}
}
}
}
List
<
CartGoods
>
nowCartGoodsList
=
new
ArrayList
<>();
//判断当前商品在购物车是否已存在,存在则数量+1,不存在商品行 + 1
allCartGoodsList
.
forEach
(
oldCartGoods
->
{
int
index
;
if
((
index
=
nowCartGoodsList
.
indexOf
(
oldCartGoods
))
>=
0
)
{
nowCartGoodsList
.
get
(
index
).
setQty
(
nowCartGoodsList
.
get
(
index
).
getQty
()
+
addCartGoods
.
getQty
());
}
else
{
nowCartGoodsList
.
add
(
oldCartGoods
);
}
});
// 重新set购物车信息到缓存中
// 重新set购物车信息到缓存中
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
all
CartGoodsList
,
null
,
tableNumber
,
this
.
shoppingCartBaseService
);
assortmentSdkService
.
setShoppingCart
(
partnerId
,
storeId
,
userId
,
now
CartGoodsList
,
null
,
tableNumber
,
this
.
shoppingCartBaseService
);
return
all
CartGoodsList
;
return
now
CartGoodsList
;
}
}
/**
/**
...
@@ -723,14 +757,18 @@ public class ShoppingCartMCoffeeServiceImpl {
...
@@ -723,14 +757,18 @@ public class ShoppingCartMCoffeeServiceImpl {
private
List
<
CartGoods
>
checkNewCartGoods
(
List
<
CartGoods
>
newCartGoods
,
CartGoods
addCartGoods
)
{
private
List
<
CartGoods
>
checkNewCartGoods
(
List
<
CartGoods
>
newCartGoods
,
CartGoods
addCartGoods
)
{
Integer
qty
=
addCartGoods
.
getQty
()
==
null
?
0
:
addCartGoods
.
getQty
();
Integer
qty
=
addCartGoods
.
getQty
()
==
null
?
0
:
addCartGoods
.
getQty
();
if
(
StringUtils
.
isNotBlank
(
addCartGoods
.
getCouponCode
())){
newCartGoods
.
add
(
addCartGoods
);
return
newCartGoods
;
}
boolean
isadd
=
true
;
boolean
isadd
=
true
;
if
(
CollectionUtils
.
isNotEmpty
(
newCartGoods
)
&&
StringUtils
.
isBlank
(
addCartGoods
.
getCouponCode
())
)
{
if
(
CollectionUtils
.
isNotEmpty
(
newCartGoods
))
{
for
(
CartGoods
goods
:
newCartGoods
)
{
for
(
CartGoods
goods
:
newCartGoods
)
{
if
(
goods
.
getSkuId
().
equals
(
addCartGoods
.
getSkuId
())
&&
goods
.
getSpuId
().
equals
(
addCartGoods
.
getSpuId
())
&&
StringUtils
.
isBlank
(
goods
.
getCouponCode
()))
{
if
(
goods
.
getSkuId
().
equals
(
addCartGoods
.
getSkuId
())
&&
goods
.
getSpuId
().
equals
(
addCartGoods
.
getSpuId
())){
qty
+=
goods
.
getQty
();
if
(
goods
.
getProductGroupList
()
!=
null
&&
addCartGoods
.
getProductGroupList
()
!=
null
&&
goods
.
getProductGroupList
().
size
()
==
addCartGoods
.
getProductGroupList
().
size
()){
goods
.
setQty
(
qty
);
isadd
=
false
;
}
break
;
}
}
}
}
if
(
isadd
)
{
if
(
isadd
)
{
...
...
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