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
218d7b80
Commit
218d7b80
authored
Mar 01, 2021
by
孙昱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sunyu::update::seedCouponGoodsInfo validate
parent
991428d6
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
21 deletions
+92
-21
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/product/ProductBindingCouponType.java
+25
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/product/ProductTypeBeanDTO.java
+1
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
+66
-21
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/product/ProductBindingCouponType.java
0 → 100644
View file @
218d7b80
package
cn
.
freemud
.
entities
.
dto
.
product
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
ProductBindingCouponType
{
@ApiModelProperty
(
name
=
"优惠券CODE"
)
private
String
activityCode
;
@ApiModelProperty
(
name
=
"数量"
)
private
Integer
num
;
@ApiModelProperty
(
name
=
"排序"
)
private
Integer
sequence
;
@ApiModelProperty
(
name
=
"ID(修改时必传)"
)
private
Long
Id
;
@ApiModelProperty
(
"卡编号"
)
private
String
cardId
;
@ApiModelProperty
(
"虚拟券号"
)
private
String
virtualCouponCode
;
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/product/ProductTypeBeanDTO.java
View file @
218d7b80
...
...
@@ -45,6 +45,7 @@ public class ProductTypeBeanDTO {
private
String
taxId
;
private
Integer
openMemberDiscount
;
private
Integer
memberDiscount
;
private
List
<
ProductBindingCouponType
>
productBindingCouponTypes
;
private
List
<
ProductAttributeGroupListBean
>
productAttributeGroupList
;
private
List
<
ProductPictureListBean
>
productPictureList
;
private
List
<
SkuProductBean
>
skuList
;
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/ShoppingCartMCoffeeServiceImpl.java
View file @
218d7b80
...
...
@@ -58,6 +58,7 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
...
...
@@ -170,27 +171,8 @@ public class ShoppingCartMCoffeeServiceImpl {
oldCartGoodsList
=
new
ArrayList
<>();
}
//种子券商品数量不可大于购买的券数量
if
(
addShoppingCartGoodsRequestVo
.
getIsMonthCard
()<
1
&&
addShoppingCartGoodsRequestVo
.
getIsSeedCouponGoods
()
>
0
)
{
if
(
CollectionUtils
.
isEmpty
(
oldCartGoodsList
))
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SEED_COUPON_VALID
);
}
else
{
int
seedCouponCount
=
0
;
int
seedCouponGoodsCount
=
0
;
for
(
CartGoods
cartGoods
:
oldCartGoodsList
)
{
if
(
cartGoods
.
getIsMonthCard
()>
0
){
seedCouponCount
=
seedCouponCount
+
cartGoods
.
getQty
();
}
if
(
cartGoods
.
getIsSeedCouponGoods
()>
0
&&
cartGoods
.
getIsMonthCard
()<
1
){
seedCouponGoodsCount
=
seedCouponGoodsCount
+
cartGoods
.
getQty
();
}
}
if
((
seedCouponGoodsCount
+
addShoppingCartGoodsRequestVo
.
getQty
())
>
seedCouponCount
){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SEED_COUPON_VALID
);
}
}
}
//种子券商品信息校验
seedCouponGoodsValidate
(
addShoppingCartGoodsRequestVo
,
oldCartGoodsList
);
//加锁,防止重复请求导致的加购数量错误
synchronized
(
oldCartGoodsList
)
{
...
...
@@ -1908,6 +1890,8 @@ public class ShoppingCartMCoffeeServiceImpl {
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setChanged
(
true
);
ValiadShopProductResult
validaProduct
=
validateResult
.
getFailureList
().
get
(
i
);
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
:
checkCartRequest
.
getCartGoodsList
())
{
//如果购物车中存在月享卡,则将商品返回的卡券信息替换购物车中的卡券信息
replaceMonthCardInfo
(
validaProduct
,
cartGoods
);
if
(
cartGoods
.
getSkuId
().
equals
(
validaProduct
.
getSkuId
()))
{
String
spuName
=
null
==
validaProduct
.
getProductType
()
?
cartGoods
.
getSpuName
()
:
validaProduct
.
getProductType
().
getName
();
String
couponName
=
StringUtils
.
isNotEmpty
(
cartGoods
.
getCouponName
())
?
cartGoods
.
getCouponName
()
:
""
;
...
...
@@ -1976,6 +1960,8 @@ public class ShoppingCartMCoffeeServiceImpl {
continue
;
}
for
(
ValiadShopProductResult
valiadShopProductResult
:
validateResult
.
getSuccessList
()){
//如果购物车中存在月享卡,则将商品返回的卡券信息替换购物车中的卡券信息
replaceMonthCardInfo
(
valiadShopProductResult
,
cartGoods
);
ProductTypeBeanDTO
productType
=
valiadShopProductResult
.
getProductType
();
if
(
ObjectUtils
.
equals
(
productType
.
getPid
(),
cartGoods
.
getSpuId
())){
//多规格商品更新套餐价格为商品返回
...
...
@@ -2221,4 +2207,63 @@ public class ShoppingCartMCoffeeServiceImpl {
singleUpdateRequest
.
setChannelType
(
requestVo
.
getChannelType
());
return
singleUpdateRequest
;
}
/**
* 根据商品校验校验接口返回的卡券信息替换前段传递的
* @param result
* @param cartGoods
*/
private
void
replaceMonthCardInfo
(
ValiadShopProductResult
result
,
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
){
if
(
null
==
result
.
getProductType
()
||
CollectionUtils
.
isEmpty
(
result
.
getProductType
().
getProductBindingCouponTypes
())){
return
;
}
List
<
ProductBindingCouponType
>
productBindingCouponTypes
=
result
.
getProductType
().
getProductBindingCouponTypes
();
if
(
cartGoods
.
getIsMonthCard
()
>
0
&&
null
!=
cartGoods
.
getMonthCardInfo
()
&&
result
.
getSkuId
().
equals
(
cartGoods
.
getSkuId
())){
for
(
ProductBindingCouponType
productBindingCouponType
:
productBindingCouponTypes
)
{
cartGoods
.
getMonthCardInfo
().
setCardCode
(
productBindingCouponType
.
getVirtualCouponCode
());
cartGoods
.
getMonthCardInfo
().
setCardNo
(
productBindingCouponType
.
getCardId
());
cartGoods
.
getMonthCardInfo
().
setType
(
cartGoods
.
getMonthCardInfo
().
getType
());
log
.
info
(
"【月享卡】信息替换成功,cartGoods:{},productInfo:{}"
,
cartGoods
.
toString
(),
result
.
toString
());
}
}
}
/**
* 种子加购逻辑校验
* 1.种子券商品券信息与月卡信息一致
* 2.种子券商品数量不可大于种子券数量
* @param addShoppingCartGoodsRequestVo
* @param oldCartGoodsList
*/
private
void
seedCouponGoodsValidate
(
MCoffeeAddGoodsRequestVo
addShoppingCartGoodsRequestVo
,
List
<
CartGoods
>
oldCartGoodsList
){
if
(
addShoppingCartGoodsRequestVo
.
getIsMonthCard
()<
1
&&
addShoppingCartGoodsRequestVo
.
getIsSeedCouponGoods
()
>
0
)
{
if
(
StringUtils
.
isEmpty
(
addShoppingCartGoodsRequestVo
.
getCouponCode
())){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_ADD_ERROR
);
}
if
(
CollectionUtils
.
isEmpty
(
oldCartGoodsList
))
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SEED_COUPON_VALID
);
}
int
seedCouponCount
=
0
;
int
seedCouponGoodsCount
=
0
;
for
(
CartGoods
cartGoods
:
oldCartGoodsList
)
{
//1.种子券商品券信息与月卡信息一致
if
(!
addShoppingCartGoodsRequestVo
.
getCouponCode
().
equals
(
cartGoods
.
getMonthCardInfo
().
getCardCode
())){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_COUPON_NOT_EXIST
);
}
if
(
cartGoods
.
getIsMonthCard
()>
0
){
seedCouponCount
=
seedCouponCount
+
cartGoods
.
getQty
();
}
if
(
cartGoods
.
getIsSeedCouponGoods
()>
0
&&
cartGoods
.
getIsMonthCard
()<
1
){
seedCouponGoodsCount
=
seedCouponGoodsCount
+
cartGoods
.
getQty
();
}
}
//2.种子券商品数量不可大于种子券数量
if
((
seedCouponGoodsCount
+
addShoppingCartGoodsRequestVo
.
getQty
())
>
seedCouponCount
){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_SEED_COUPON_VALID
);
}
}
}
}
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