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
b55e6c21
Commit
b55e6c21
authored
Oct 18, 2021
by
ping.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkAllCartGoodsNew 从购物车sdk迁移到项目中ProductServiceImpl实现类
parent
71aad640
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
578 additions
and
51 deletions
+578
-51
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
+257
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/GetCouponDetailResponseDto.java
+35
-0
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/product/ProductTypeBeanDTO.java
+7
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/AssortmentSdkService.java
+3
-1
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
+37
-48
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ProductServiceImpl.java
+239
-2
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/adapter/ShoppingCartConvertAdapter.java
View file @
b55e6c21
...
@@ -24,10 +24,14 @@ import cn.freemud.enums.GoodsTypeEnum;
...
@@ -24,10 +24,14 @@ import cn.freemud.enums.GoodsTypeEnum;
import
cn.freemud.enums.ProductType
;
import
cn.freemud.enums.ProductType
;
import
cn.freemud.utils.BeanUtil
;
import
cn.freemud.utils.BeanUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.freemud.application.sdk.api.log.ErrorLog
;
import
com.freemud.application.sdk.api.log.ErrorLog
;
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.CartResponseConstant
;
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.exception.ServiceException
;
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.util.ShoppingSdkLogUtil
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.ObjectUtils
;
...
@@ -43,6 +47,7 @@ public class ShoppingCartConvertAdapter {
...
@@ -43,6 +47,7 @@ public class ShoppingCartConvertAdapter {
private
static
final
String
ATTRIBUTEID
=
"attributeId"
;
private
static
final
String
ATTRIBUTEID
=
"attributeId"
;
private
static
final
String
ATTRIBUTENAME
=
"attributeName"
;
private
static
final
String
ATTRIBUTENAME
=
"attributeName"
;
private
static
final
String
ATTRIBUTEFOREIGNNAME
=
"attributeForeignName"
;
@Value
(
"${mccafe.tableware.skuId}"
)
@Value
(
"${mccafe.tableware.skuId}"
)
private
String
mcCafeTablewareSkuId
;
private
String
mcCafeTablewareSkuId
;
...
@@ -600,6 +605,115 @@ public class ShoppingCartConvertAdapter {
...
@@ -600,6 +605,115 @@ public class ShoppingCartConvertAdapter {
* @param cartGoods 当前购物车商品行
* @param cartGoods 当前购物车商品行
* @param productBeans 购物车中所有的productId对应的商品详情
* @param productBeans 购物车中所有的productId对应的商品详情
*/
*/
public
void
updateCartGoodsInfoNew
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
,
List
<
ProductTypeBeanDTO
>
productBeans
)
{
try
{
Optional
<
ProductTypeBeanDTO
>
firstProduct
=
productBeans
.
stream
().
filter
(
p
->
ObjectUtils
.
equals
(
p
.
getPid
(),
cartGoods
.
getSpuId
())).
findFirst
();
if
(!
firstProduct
.
isPresent
())
{
return
;
}
ProductTypeBeanDTO
spuProduct
=
firstProduct
.
get
();
// fisherman 添加原有商品服务的商品类型 -> 后续只为存表B端使用, 暂无其他地方有逻辑判断 20210810
cartGoods
.
setOriginalProductType
(
spuProduct
.
getType
());
//是否是sku商品
boolean
isSkuProduct
=
ObjectUtils
.
equals
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
GoodsTypeEnum
.
SKU_GOODS
.
getGoodsType
(),
cartGoods
.
getGoodsType
());
// 如果是套餐商品,更新套餐内固定商品&可选商品的详细信息
boolean
isSetMealProduct
=
ObjectUtils
.
equals
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
ProductType
.
SetMeal
.
getCode
(),
spuProduct
.
getType
())
||
ObjectUtils
.
equals
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
ProductType
.
IncreasedPackage
.
getCode
(),
spuProduct
.
getType
());
ProductTypeBeanDTO
.
SkuProductBean
skuProduct
=
isSkuProduct
?
spuProduct
.
getSkuList
().
stream
().
filter
(
p
->
ObjectUtils
.
equals
(
cartGoods
.
getSkuId
(),
p
.
getSkuId
())).
findFirst
().
orElse
(
null
):
null
;
if
(
isSkuProduct
&&
skuProduct
==
null
){
//特殊场景前端传一个skuid非spuid下多规格商品
throw
new
ServiceException
(
CartResponseConstant
.
FAIL
);
}
Map
<
String
,
String
>
attributes
=
getAttributesNew
(
cartGoods
.
getExtra
());
if
(!
"早餐啡常搭"
.
equals
(
cartGoods
.
getName
())
&&
!
"早餐啡常搭"
.
equals
(
cartGoods
.
getSkuName
())
&&
!
"早餐啡常搭"
.
equals
(
cartGoods
.
getSpuName
())
&&
!
"啡常搭"
.
equals
(
cartGoods
.
getName
())
&&
!
"啡常搭"
.
equals
(
cartGoods
.
getSkuName
())
&&
!
"啡常搭"
.
equals
(
cartGoods
.
getSpuName
()))
{
cartGoods
.
setName
(
spuProduct
.
getName
());
cartGoods
.
setForeignName
(
spuProduct
.
getForeignName
());
cartGoods
.
setSpuName
(
spuProduct
.
getName
());
cartGoods
.
setSpuForeignName
(
spuProduct
.
getForeignName
());
cartGoods
.
setSkuName
(
isSkuProduct
?
skuProduct
.
getProductName
()
:
spuProduct
.
getName
());
cartGoods
.
setSkuForeignName
(
isSkuProduct
?
skuProduct
.
getForeignProductName
()
:
spuProduct
.
getForeignName
());
}
cartGoods
.
setSpecProductId
(
attributes
.
get
(
ATTRIBUTEID
));
cartGoods
.
setPic
(
spuProduct
.
getPicture
());
cartGoods
.
setPackPrice
(
isSkuProduct
?
skuProduct
.
getPackPrice
()
:
spuProduct
.
getPackPrice
());
cartGoods
.
setStockLimit
(
isSkuProduct
?
ObjectUtils
.
equals
(
1
,
skuProduct
.
getStockLimit
())
:
ObjectUtils
.
equals
(
1
,
spuProduct
.
getStockLimit
()));
cartGoods
.
setCustomerCode
(
isSkuProduct
?
skuProduct
.
getCustomerCode
()
:
spuProduct
.
getCustomerCode
());
cartGoods
.
setRiseSell
(
isSkuProduct
?
skuProduct
.
getRiseSell
()
:
spuProduct
.
getRiseSell
());
cartGoods
.
setMemberDiscount
(
spuProduct
.
getMemberDiscountResult
());
cartGoods
.
setClassificationId
(
spuProduct
.
getCategory
());
cartGoods
.
setClassificationName
(
spuProduct
.
getCategoryName
());
cartGoods
.
setClassificationForeignName
(
spuProduct
.
getCategoryName
());
cartGoods
.
setTax
(
spuProduct
.
getTax
());
cartGoods
.
setTaxId
(
spuProduct
.
getTaxId
());
String
skuSpecName
=
""
;
String
skuForeignSpecName
=
""
;
if
(
isSkuProduct
&&
CollectionUtils
.
isNotEmpty
(
skuProduct
.
getSkuSpecValues
()))
{
List
<
String
>
skuSpecValus
=
skuProduct
.
getSkuSpecValues
().
stream
().
map
(
p
->
p
.
getSpecValue
()).
collect
(
Collectors
.
toList
());
skuSpecName
=
StringUtils
.
join
(
skuSpecValus
,
"/"
);
}
if
(
isSkuProduct
&&
CollectionUtils
.
isNotEmpty
(
skuProduct
.
getSkuSpecValues
()))
{
List
<
String
>
skuSpecValus
=
skuProduct
.
getSkuSpecValues
().
stream
().
map
(
p
->
p
.
getForeignSpecValue
()).
collect
(
Collectors
.
toList
());
skuForeignSpecName
=
StringUtils
.
join
(
skuSpecValus
,
"/"
);
}
String
attributeName
=
attributes
.
get
(
ATTRIBUTENAME
)
==
null
?
""
:
attributes
.
get
(
ATTRIBUTENAME
);
String
attributeForeignName
=
attributes
.
get
(
ATTRIBUTEFOREIGNNAME
)
==
null
?
""
:
attributes
.
get
(
ATTRIBUTEFOREIGNNAME
);
//购物车小标题
cartGoods
.
setSubName
(
StringUtils
.
isNotEmpty
(
skuSpecName
)
&&
StringUtils
.
isNotEmpty
(
attributeName
)
?
skuSpecName
+
"/"
+
attributeName
:
skuSpecName
+
attributeName
);
//购物车英文小标题
cartGoods
.
setSubForeignName
(
StringUtils
.
isNotEmpty
(
skuForeignSpecName
)
&&
StringUtils
.
isNotEmpty
(
attributeForeignName
)
?
skuForeignSpecName
+
"/"
+
attributeForeignName
:
skuForeignSpecName
+
attributeForeignName
);
if
(
isSetMealProduct
)
{
if
(
CollectionUtils
.
isNotEmpty
(
cartGoods
.
getProductComboList
()))
{
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
ComboxGoods
productCombo
:
cartGoods
.
getProductComboList
())
{
updateComboxGoodsInfoNew
(
productCombo
,
spuProduct
,
true
);
}
}
if
(
CollectionUtils
.
isNotEmpty
(
cartGoods
.
getProductGroupList
()))
{
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
ComboxGoods
productGroup
:
cartGoods
.
getProductGroupList
())
{
updateComboxGoodsInfoNew
(
productGroup
,
spuProduct
,
false
);
}
}
cartGoods
.
setGoodsType
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
GoodsTypeEnum
.
SET_MEAL_GOODS
.
getGoodsType
());
}
//更新当前商品行价格
Long
newOrigOriginalPrice
=
0L
;
if
(
isSetMealProduct
)
{
newOrigOriginalPrice
+=
cartGoods
.
getProductComboList
().
stream
().
mapToLong
(
t
->
t
.
getOriginalAmount
()).
sum
();
newOrigOriginalPrice
+=
cartGoods
.
getProductGroupList
().
stream
().
mapToLong
(
t
->
t
.
getOriginalAmount
()).
sum
();
}
else
{
newOrigOriginalPrice
=
isSkuProduct
?
skuProduct
.
getFinalPrice
()
:
spuProduct
.
getFinalPrice
();
}
cartGoods
.
setOriginalPrice
(
newOrigOriginalPrice
);
cartGoods
.
setOriginalAmount
(
newOrigOriginalPrice
*
cartGoods
.
getQty
());
cartGoods
.
setAmount
(
newOrigOriginalPrice
*
cartGoods
.
getQty
());
//咨询商品服务,套餐售价取originalPrice
cartGoods
.
setFinalPrice
(
isSetMealProduct
?
spuProduct
.
getOriginalPrice
()
:
isSkuProduct
?
skuProduct
.
getFinalPrice
()
:
spuProduct
.
getFinalPrice
());
cartGoods
.
setWeight
(
isSkuProduct
?
skuProduct
.
getWeight
()
:
spuProduct
.
getWeight
());
cartGoods
.
setUnit
(
isSkuProduct
?
skuProduct
.
getUnit
()
:
spuProduct
.
getUnit
());
cartGoods
.
setWeightType
(
CommonsConstant
.
WEIGHT_PRODUCT
.
equals
(
spuProduct
.
getWeightType
()));
cartGoods
.
setMaterialAmount
(
0L
);
cartGoods
.
setOriginalMaterialAmount
(
0L
);
// todo 设置加料
this
.
checkMaterialProduct
(
cartGoods
,
spuProduct
);
}
catch
(
Exception
ex
)
{
ShoppingSdkLogUtil
.
errorLog
(
"updateCartGoodsInfoNew_Error cartGoods:{},productBeans:{}"
,
ex
,
JSONObject
.
toJSONString
(
cartGoods
),
JSONObject
.
toJSONString
(
productBeans
));
cartGoods
.
setCartGoodsUid
(
null
);
}
}
/**
* 更新当前购物车商品行信息
*
* @param cartGoods 当前购物车商品行
* @param productBeans 购物车中所有的productId对应的商品详情
*/
public
void
updateCartGoodsInfoForMCoffee
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
,
List
<
ProductTypeBeanDTO
>
productBeans
)
{
public
void
updateCartGoodsInfoForMCoffee
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
,
List
<
ProductTypeBeanDTO
>
productBeans
)
{
try
{
try
{
Optional
<
ProductTypeBeanDTO
>
firstProduct
=
productBeans
.
stream
().
filter
(
p
->
ObjectUtils
.
equals
(
p
.
getPid
(),
cartGoods
.
getSpuId
())).
findFirst
();
Optional
<
ProductTypeBeanDTO
>
firstProduct
=
productBeans
.
stream
().
filter
(
p
->
ObjectUtils
.
equals
(
p
.
getPid
(),
cartGoods
.
getSpuId
())).
findFirst
();
...
@@ -1233,4 +1347,147 @@ public class ShoppingCartConvertAdapter {
...
@@ -1233,4 +1347,147 @@ public class ShoppingCartConvertAdapter {
}
}
}
}
/**
* 更新套餐固定商品、可选商品信息
*
* @param comboxGoods 固定商品或可选商品
* @param parentProductBean 套餐服商品
* @param isComboxGoods 是否是固定商品
* @return
*/
private
void
updateComboxGoodsInfoNew
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
ComboxGoods
comboxGoods
,
ProductTypeBeanDTO
parentProductBean
,
boolean
isComboxGoods
)
{
ProductTypeBeanDTO
.
ProductComboType
productComboType
=
new
ProductTypeBeanDTO
.
ProductComboType
();
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
groupDetailType
=
new
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
();
if
(
isComboxGoods
)
{
productComboType
=
parentProductBean
.
getProductComboList
().
stream
().
filter
(
p
->
ObjectUtils
.
equals
(
comboxGoods
.
getGoodsId
(),
p
.
getProductId
())).
findFirst
().
orElse
(
new
ProductTypeBeanDTO
.
ProductComboType
());
}
else
{
Map
<
String
,
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
>
map
=
new
HashMap
<>();
parentProductBean
.
getProductGroupList
().
stream
().
map
(
t
->
t
.
getGroupDetail
()).
forEach
(
group
->
group
.
forEach
(
detailType
->
map
.
put
(
detailType
.
getProductId
(),
detailType
)));
groupDetailType
=
map
.
get
(
comboxGoods
.
getGoodsId
());
}
// 若是固定商品则取商品详情的FinalPrice,若是可选商品则取MarkUpPrice
Long
finalPrice
=
isComboxGoods
?
productComboType
.
getFinalPrice
().
longValue
()
:
groupDetailType
.
getMarkUpPrice
().
longValue
();
// 设置商品详情
Map
<
String
,
String
>
attributes
=
getAttributesNew
(
comboxGoods
.
getExtra
());
comboxGoods
.
setName
(
isComboxGoods
?
productComboType
.
getProductName
()
:
groupDetailType
.
getProductName
());
comboxGoods
.
setForeignName
(
isComboxGoods
?
productComboType
.
getForeignProductName
()
:
groupDetailType
.
getForeignProductName
());
comboxGoods
.
setSpuName
(
comboxGoods
.
getName
());
// 组合商品类型存放
comboxGoods
.
setOriginalProductType
(
isComboxGoods
?
productComboType
.
getProductType
()
:
groupDetailType
.
getProductType
());
comboxGoods
.
setSpuForeignName
(
comboxGoods
.
getForeignName
());
comboxGoods
.
setSpecProductId
(
attributes
.
get
(
ATTRIBUTEID
));
comboxGoods
.
setSubName
(
attributes
.
get
(
ATTRIBUTENAME
));
comboxGoods
.
setSubForeignName
(
attributes
.
get
(
ATTRIBUTEFOREIGNNAME
));
comboxGoods
.
setPic
(
isComboxGoods
?
productComboType
.
getPicture
()
:
groupDetailType
.
getPicture
());
comboxGoods
.
setOriginalPrice
(
isComboxGoods
?
productComboType
.
getFinalPrice
().
longValue
()
:
groupDetailType
.
getProductFinalPrice
().
longValue
());
comboxGoods
.
setOriginalAmount
(
comboxGoods
.
getOriginalPrice
()
*
comboxGoods
.
getQty
());
comboxGoods
.
setAmount
(
finalPrice
*
comboxGoods
.
getQty
());
comboxGoods
.
setCustomerCode
(
isComboxGoods
?
productComboType
.
getCustomerCode
()
:
groupDetailType
.
getCustomerCode
());
comboxGoods
.
setFinalPrice
(
finalPrice
);
comboxGoods
.
setWeightType
(
isComboxGoods
?
CommonsConstant
.
WEIGHT_PRODUCT
.
equals
(
productComboType
.
getWeightType
())
:
CommonsConstant
.
WEIGHT_PRODUCT
.
equals
(
groupDetailType
.
getWeightType
()));
comboxGoods
.
setUnit
(
isComboxGoods
?
productComboType
.
getUnit
()
:
groupDetailType
.
getUnit
());
comboxGoods
.
setWeight
(
isComboxGoods
?
productComboType
.
getWeight
()
:
groupDetailType
.
getWeight
());
comboxGoods
.
setTax
(
isComboxGoods
?
productComboType
.
getTax
()
:
groupDetailType
.
getTax
());
comboxGoods
.
setTaxId
(
isComboxGoods
?
productComboType
.
getTaxId
()
:
groupDetailType
.
getTaxId
());
}
/**
* 单独处理加料及标识小料信息是否有变化
*
* @param cartGoods
* @param spuProduct
*/
private
void
checkMaterialProduct
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
,
ProductTypeBeanDTO
spuProduct
)
{
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductMaterialList
()))
return
;
ProductTypeBeanDTO
.
SkuProductBean
skuProductBean
=
null
;
boolean
isSkuProduct
=
ObjectUtils
.
equals
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
GoodsTypeEnum
.
SKU_GOODS
.
getGoodsType
(),
cartGoods
.
getGoodsType
());
if
(
isSkuProduct
){
if
(
CollectionUtils
.
isEmpty
(
spuProduct
.
getSkuList
())){
cartGoods
.
setGoodsType
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
GoodsTypeEnum
.
EXCEPTION_GOODS
.
getGoodsType
());
cartGoods
.
setProductMaterialList
(
new
ArrayList
<>());
return
;
}
else
{
skuProductBean
=
spuProduct
.
getSkuList
().
stream
().
filter
(
p
->
p
.
getSkuId
().
equals
(
cartGoods
.
getSkuId
())).
findFirst
().
orElse
(
null
);
if
(
skuProductBean
==
null
||
CollectionUtils
.
isEmpty
(
skuProductBean
.
getAdditionalGroupList
())){
cartGoods
.
setGoodsType
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
GoodsTypeEnum
.
EXCEPTION_GOODS
.
getGoodsType
());
cartGoods
.
setProductMaterialList
(
new
ArrayList
<>());
return
;
}
}
}
else
{
//加料信息为空
if
(
CollectionUtils
.
isEmpty
(
spuProduct
.
getAdditionalGroupList
()))
{
cartGoods
.
setGoodsType
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
GoodsTypeEnum
.
EXCEPTION_GOODS
.
getGoodsType
());
cartGoods
.
setProductMaterialList
(
new
ArrayList
<>());
return
;
}
}
//提取加料信息
List
<
String
>
materialSpu
=
new
ArrayList
<>();
HashMap
<
String
,
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
>
materialHash
=
new
HashMap
<>();
if
(
isSkuProduct
){
List
<
ProductTypeBeanDTO
.
ProductGroupType
>
groupList
=
skuProductBean
.
getAdditionalGroupList
();
for
(
ProductTypeBeanDTO
.
ProductGroupType
groupDetail
:
groupList
)
{
for
(
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
groupDetailType
:
groupDetail
.
getGroupDetail
())
{
materialHash
.
put
(
groupDetailType
.
getProductId
(),
groupDetailType
);
materialSpu
.
add
(
groupDetailType
.
getProductId
());
}
}
}
else
{
List
<
ProductTypeBeanDTO
.
ProductGroupType
>
groupList
=
spuProduct
.
getAdditionalGroupList
();
for
(
ProductTypeBeanDTO
.
ProductGroupType
groupDetail
:
groupList
){
for
(
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
groupDetailType
:
groupDetail
.
getGroupDetail
())
{
materialHash
.
put
(
groupDetailType
.
getProductId
(),
groupDetailType
);
materialSpu
.
add
(
groupDetailType
.
getProductId
());
}
}
}
//加车小料和商品小料没有交集则提示商品信息有异常
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductMaterialList
().
stream
().
filter
(
e
->
materialSpu
.
contains
(
e
.
getSpuId
())).
collect
(
Collectors
.
toList
())))
{
cartGoods
.
setGoodsType
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
constant
.
GoodsTypeEnum
.
EXCEPTION_GOODS
.
getGoodsType
());
cartGoods
.
setProductMaterialList
(
new
ArrayList
<>());
return
;
}
ArrayList
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
>
materialGoodsList
=
new
ArrayList
<>();
Long
materialAmount
=
0L
;
Long
originalMaterAmount
=
0L
;
String
materialSubName
=
cartGoods
.
getSubName
();
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
materialGoods
:
cartGoods
.
getProductMaterialList
())
{
ProductTypeBeanDTO
.
ProductGroupType
.
GroupDetailType
detail
=
materialHash
.
get
(
materialGoods
.
getSpuId
());
if
(
detail
==
null
)
continue
;
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
material
=
new
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
.
MaterialGoods
();
material
.
setQty
(
materialGoods
.
getQty
());
material
.
setSpuName
(
detail
.
getProductName
());
material
.
setSpuForeignName
(
detail
.
getForeignProductName
());
material
.
setSpuId
(
detail
.
getProductId
());
//fisherman 小料商品设置原始商品类型
material
.
setOriginalProductType
(
detail
.
getProductType
());
//行单价 \ 行总价
material
.
setFinalPrice
(
detail
.
getProductFinalPrice
().
longValue
());
material
.
setAmount
(
detail
.
getProductFinalPrice
().
longValue
()
*
materialGoods
.
getQty
()
*
cartGoods
.
getQty
());
//原行单价*数量
material
.
setOriginalAmount
(
detail
.
getProductFinalPrice
().
longValue
()
*
materialGoods
.
getQty
()
*
cartGoods
.
getQty
());
material
.
setOriginalPrice
(
detail
.
getProductFinalPrice
().
longValue
());
material
.
setCustomerCode
(
detail
.
getCustomerCode
());
materialGoodsList
.
add
(
material
);
materialAmount
+=
detail
.
getProductFinalPrice
().
longValue
()
*
materialGoods
.
getQty
()
*
cartGoods
.
getQty
();
originalMaterAmount
+=
detail
.
getProductFinalPrice
().
longValue
()
*
materialGoods
.
getQty
()
*
cartGoods
.
getQty
();
;
materialSubName
=
materialSubName
+
"/"
+
detail
.
getProductName
();
}
//设置购物车行记录
cartGoods
.
setProductMaterialList
(
materialGoodsList
);
//加料行记录现价总价
cartGoods
.
setMaterialAmount
(
materialAmount
);
//加料行记录原价总价
cartGoods
.
setOriginalMaterialAmount
(
originalMaterAmount
);
//cartGoods.setOriginalAmount(cartGoods.getOriginalAmount() + originalMaterAmount);
//cartGoods.setSubName(StringUtils.strip(materialSubName, "/"));
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/GetCouponDetailResponseDto.java
View file @
b55e6c21
package
cn
.
freemud
.
entities
.
dto
;
package
cn
.
freemud
.
entities
.
dto
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.fasterxml.jackson.annotation.JsonProperty
;
import
com.freemud.application.sdk.api.couponcenter.backstage.domain.ActiveChannel
;
import
com.freemud.application.sdk.api.couponcenter.online.domain.ActiveGroupVO
;
import
com.freemud.application.sdk.api.couponcenter.online.domain.CouponProductVO
;
import
lombok.Data
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -38,6 +41,38 @@ public class GetCouponDetailResponseDto {
...
@@ -38,6 +41,38 @@ public class GetCouponDetailResponseDto {
*/
*/
private
List
<
ActiveRedeemTimeInterval
>
activeRedeemTimeIntervalList
;
private
List
<
ActiveRedeemTimeInterval
>
activeRedeemTimeIntervalList
;
private
Integer
today_available_times
;
private
Integer
today_available_times
;
// private String code;
// private String activeCode;
// private String title;
// private Integer type;
// private Integer status;
// private String create_time;
// private String redeem_time;
// private Integer storeChannelLimit;
// private String valid_start;
// private String valid_ends;
// private Integer minAmount;
private
String
sendReason
;
private
String
cancelReason
;
// private Active active;
// private List<ActiveRestrict> activeRestrictionVOS;
private
List
<
ActiveProductSetting
>
activeProductSetting
;
// private List<ActiveProduct> activeProduct;
private
List
<
ActiveGroupVO
>
activeGroupVOS
;
private
List
<
CouponProductVO
>
couponProductList
;
private
List
<
ActiveChannel
>
activeChannels
;
// private List<ActiveRedeemTimeIntervalVO> activeRedeemTimeIntervalList;
private
Integer
storeLimitLevel
;
private
String
limitStoreId
;
// private Integer today_available_times;
private
Integer
total_available_times
;
private
Integer
maxRedeemTime
;
private
Integer
availableTimes
;
private
Integer
dailyRedeemTime
;
private
Integer
dailyAvailableTimes
;
}
}
@Data
@Data
public
static
class
Active
{
public
static
class
Active
{
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/dto/product/ProductTypeBeanDTO.java
View file @
b55e6c21
...
@@ -58,6 +58,7 @@ public class ProductTypeBeanDTO {
...
@@ -58,6 +58,7 @@ public class ProductTypeBeanDTO {
private
Integer
isDishware
;
private
Integer
isDishware
;
private
Integer
weightType
;
private
Integer
weightType
;
private
Double
weight
;
private
Double
weight
;
private
String
foreignName
;
public
Integer
getMemberDiscountResult
()
{
public
Integer
getMemberDiscountResult
()
{
return
this
.
openMemberDiscount
!=
null
&&
this
.
openMemberDiscount
==
1
?
this
.
memberDiscount
:
100
;
return
this
.
openMemberDiscount
!=
null
&&
this
.
openMemberDiscount
==
1
?
this
.
memberDiscount
:
100
;
...
@@ -142,6 +143,8 @@ public class ProductTypeBeanDTO {
...
@@ -142,6 +143,8 @@ public class ProductTypeBeanDTO {
private
Double
weight
;
private
Double
weight
;
private
Double
tax
;
private
Double
tax
;
private
String
taxId
;
private
String
taxId
;
private
String
foreignProductName
;
private
Integer
productType
;
}
}
}
}
...
@@ -161,6 +164,8 @@ public class ProductTypeBeanDTO {
...
@@ -161,6 +164,8 @@ public class ProductTypeBeanDTO {
private
Double
weight
;
private
Double
weight
;
private
Double
tax
;
private
Double
tax
;
private
String
taxId
;
private
String
taxId
;
private
String
foreignProductName
;
private
Integer
productType
;
}
}
@Data
@Data
...
@@ -246,6 +251,7 @@ public class ProductTypeBeanDTO {
...
@@ -246,6 +251,7 @@ public class ProductTypeBeanDTO {
protected
String
unit
;
protected
String
unit
;
private
Integer
openMemberDiscount
;
private
Integer
openMemberDiscount
;
private
Integer
memberDiscount
;
private
Integer
memberDiscount
;
private
String
foreignProductName
;
public
Integer
getMemberDiscountResult
()
{
public
Integer
getMemberDiscountResult
()
{
return
this
.
openMemberDiscount
!=
null
&&
this
.
openMemberDiscount
==
1
?
this
.
memberDiscount
:
100
;
return
this
.
openMemberDiscount
!=
null
&&
this
.
openMemberDiscount
==
1
?
this
.
memberDiscount
:
100
;
...
@@ -262,6 +268,7 @@ public class ProductTypeBeanDTO {
...
@@ -262,6 +268,7 @@ public class ProductTypeBeanDTO {
private
String
specName
;
private
String
specName
;
private
String
specValue
;
private
String
specValue
;
private
String
specValueId
;
private
String
specValueId
;
private
String
foreignSpecValue
;
public
SkuSpecValue
()
{
public
SkuSpecValue
()
{
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/AssortmentSdkService.java
View file @
b55e6c21
...
@@ -50,6 +50,8 @@ public class AssortmentSdkService {
...
@@ -50,6 +50,8 @@ public class AssortmentSdkService {
@Autowired
@Autowired
private
ProductClient
storeItemClient
;
private
ProductClient
storeItemClient
;
@Autowired
private
ProductServiceImpl
productServiceImpl
;
@Value
(
"${mccafe.partner.id}"
)
@Value
(
"${mccafe.partner.id}"
)
private
String
mcCafePartnerId
;
private
String
mcCafePartnerId
;
...
@@ -294,7 +296,7 @@ public class AssortmentSdkService {
...
@@ -294,7 +296,7 @@ public class AssortmentSdkService {
checkCartRequest
.
setTrackingNo
(
LogThreadLocal
.
getTrackingNo
());
checkCartRequest
.
setTrackingNo
(
LogThreadLocal
.
getTrackingNo
());
checkCartRequest
.
setMenuType
(
BusinessTypeEnum
.
getByType
(
menuType
).
getCode
());
checkCartRequest
.
setMenuType
(
BusinessTypeEnum
.
getByType
(
menuType
).
getCode
());
BaseResponse
<
CheckCartRequest
>
baseResponse
;
BaseResponse
<
CheckCartRequest
>
baseResponse
;
baseResponse
=
shoppingCartService
.
checkAllCartGoodsNew
(
checkCartRequest
);
baseResponse
=
productServiceImpl
.
checkAllCartGoodsNew
(
checkCartRequest
);
if
(
baseResponse
==
null
)
{
if
(
baseResponse
==
null
)
{
return
null
;
return
null
;
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
View file @
b55e6c21
...
@@ -20,6 +20,7 @@ import cn.freemud.base.util.DateUtil;
...
@@ -20,6 +20,7 @@ import cn.freemud.base.util.DateUtil;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.demo.manager.coupon.Finals
;
import
cn.freemud.demo.manager.coupon.Finals
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.coupon.Active
;
import
cn.freemud.entities.dto.coupon.CouponAvailableRespDto
;
import
cn.freemud.entities.dto.coupon.CouponAvailableRespDto
;
import
cn.freemud.entities.dto.product.ValiadShopProductResponse
;
import
cn.freemud.entities.dto.product.ValiadShopProductResponse
;
import
cn.freemud.entities.dto.product.ValidateShopProductRequest
;
import
cn.freemud.entities.dto.product.ValidateShopProductRequest
;
...
@@ -42,6 +43,7 @@ import cn.freemud.utils.RedisUtil;
...
@@ -42,6 +43,7 @@ import cn.freemud.utils.RedisUtil;
import
com.freemud.application.sdk.api.log.ErrorLog
;
import
com.freemud.application.sdk.api.log.ErrorLog
;
import
com.freemud.application.sdk.api.productcenter.constant.ResponseConstant
;
import
com.freemud.application.sdk.api.productcenter.constant.ResponseConstant
;
import
com.freemud.application.sdk.api.util.SignUtil
;
import
com.freemud.application.sdk.api.util.SignUtil
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CartResponseConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.enums.BusinessTypeEnum
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
import
com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBaseServiceImpl
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
...
@@ -60,67 +62,26 @@ import java.util.*;
...
@@ -60,67 +62,26 @@ import java.util.*;
import
java.util.function.Predicate
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
//import com.freemud.card.sdk.comm.Finals;
//import com.freemud.card.sdk.comm.SignUtil;
//import com.freemud.card.sdk.service.CouponAvailableService;
//import com.freemud.card.sdk.service.GetCouponService;
//import com.freemud.card.sdk.service.MemberProductService;
//import com.freemud.card.sdk.vo.comm.GetCodeRespVo;
//import com.freemud.card.sdk.vo.comm.GetCouponVo;
//import com.freemud.card.sdk.vo.coupon.CouponStateVo;
//import com.freemud.card.sdk.vo.coupon.Product;
//import com.freemud.card.sdk.vo.coupon.request.CouponAvailableReqVo;
//import com.freemud.card.sdk.vo.coupon.CreateCouponVo;
//import com.freemud.card.sdk.vo.coupon.request.MemberAddCouponVo;
//import com.freemud.card.sdk.vo.coupon.response.MemberBaseRespVo;
//import com.freemud.sdk.api.assortment.shoppingcart.constant.CartResponseConstant;
@Service
@Service
public
class
CouponServiceImpl
implements
CouponService
{
public
class
CouponServiceImpl
implements
CouponService
{
private
final
Gson
gson
=
new
Gson
();
//@Autowired
//private MemberProductClient memberProductClient;
@Autowired
@Autowired
private
CustomerExtendClient
customerExtendClient
;
private
CustomerExtendClient
customerExtendClient
;
@Autowired
@Autowired
private
UserService
userService
;
// @Autowired
// private MemberProductService memberProductService;
@Autowired
private
CouponAdapter
couponAdapter
;
private
CouponAdapter
couponAdapter
;
@Autowired
@Autowired
private
StoreAdapter
storeAdapter
;
@Autowired
private
CouponOnlineClient
couponOnlineClient
;
private
CouponOnlineClient
couponOnlineClient
;
// @Autowired
// private CouponOnlineMCCafeClient couponOnlineMCCafeClient;
// @Autowired
// private CouponAvailableService couponAvailableService;
@Value
(
"${coupon.app.id}"
)
private
String
appid
;
@Autowired
@Autowired
private
RedisCache
redisCache
;
private
RedisCache
redisCache
;
@Autowired
@Autowired
private
CardBinClient
cardBinClient
;
private
CardBinClient
cardBinClient
;
// @Autowired
// private CardBinMCCafeClient cardBinMCCafeClient;
@Autowired
@Autowired
private
ProductClient
storeItemClient
;
private
ProductClient
storeItemClient
;
@Autowired
@Autowired
private
StoreItemAdapter
storeItemAdapter
;
@Autowired
private
CouponServiceImpl
couponService
;
// @Autowired
// private GetCouponService getCouponService;
@Autowired
private
OpenPlatformClient
openPlatformClient
;
@Autowired
private
ItemService
itemService
;
private
ItemService
itemService
;
@Autowired
@Autowired
private
CommonService
commonService
;
private
CommonService
commonService
;
@Value
(
"${coupon.partner.id}"
)
private
String
couponPartnerId
;
@Autowired
@Autowired
private
CouponAdapterClient
couponAdaptClient
;
private
CouponAdapterClient
couponAdaptClient
;
@Autowired
@Autowired
...
@@ -128,6 +89,11 @@ public class CouponServiceImpl implements CouponService {
...
@@ -128,6 +89,11 @@ public class CouponServiceImpl implements CouponService {
@Autowired
@Autowired
private
ShoppingCartBaseServiceImpl
shoppingCartBaseService
;
private
ShoppingCartBaseServiceImpl
shoppingCartBaseService
;
@Value
(
"${coupon.app.id}"
)
private
String
appid
;
/**
/**
* 获取优惠券列表
* 获取优惠券列表
*
*
...
@@ -384,7 +350,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -384,7 +350,7 @@ public class CouponServiceImpl implements CouponService {
public
Map
<
String
,
Boolean
>
couponOrderWay
(
String
partnerId
,
List
<
String
>
activityCodes
,
Integer
orderTye
)
{
public
Map
<
String
,
Boolean
>
couponOrderWay
(
String
partnerId
,
List
<
String
>
activityCodes
,
Integer
orderTye
)
{
// 去重
// 去重
List
<
String
>
activeCodes
=
new
ArrayList
<>(
new
HashSet
(
activityCodes
));
List
<
String
>
activeCodes
=
new
ArrayList
<>(
new
HashSet
(
activityCodes
));
String
appSecret
=
couponService
.
getAppSecret
(
partnerId
);
String
appSecret
=
this
.
getAppSecret
(
partnerId
);
// 最大15一提交
// 最大15一提交
int
maxNum
=
15
;
int
maxNum
=
15
;
int
count
=
activeCodes
.
size
()
/
maxNum
;
int
count
=
activeCodes
.
size
()
/
maxNum
;
...
@@ -751,7 +717,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -751,7 +717,7 @@ public class CouponServiceImpl implements CouponService {
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
GetCouponDetailResponseDto
couponDetailResponseDto
=
couponService
.
getMemberCoupon
(
requestVo
);
GetCouponDetailResponseDto
couponDetailResponseDto
=
this
.
getMemberCoupon
(
requestVo
);
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
return
null
;
return
null
;
}
}
...
@@ -904,7 +870,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -904,7 +870,7 @@ public class CouponServiceImpl implements CouponService {
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
GetCouponDetailResponseDto
couponDetailResponseDto
=
couponService
.
getMemberCoupon
(
requestVo
);
GetCouponDetailResponseDto
couponDetailResponseDto
=
this
.
getMemberCoupon
(
requestVo
);
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
return
null
;
return
null
;
}
}
...
@@ -1009,7 +975,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -1009,7 +975,7 @@ public class CouponServiceImpl implements CouponService {
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
GetCouponDetailResponseDto
couponDetailResponseDto
=
couponService
.
getMemberCoupon
(
requestVo
);
GetCouponDetailResponseDto
couponDetailResponseDto
=
this
.
getMemberCoupon
(
requestVo
);
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
return
null
;
return
null
;
}
}
...
@@ -1055,7 +1021,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -1055,7 +1021,7 @@ public class CouponServiceImpl implements CouponService {
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
GetCouponDetailResponseDto
couponDetailResponseDto
=
couponService
.
getMemberCoupon
(
requestVo
);
GetCouponDetailResponseDto
couponDetailResponseDto
=
this
.
getMemberCoupon
(
requestVo
);
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
return
null
;
return
null
;
}
}
...
@@ -1332,7 +1298,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -1332,7 +1298,7 @@ public class CouponServiceImpl implements CouponService {
getMemberCouponListRequestDto
.
setStatusFlags
(
Arrays
.
asList
(
CouponStatus
.
STATUS_0
.
getCode
(),
CouponStatus
.
STATUS_2
.
getCode
()));
getMemberCouponListRequestDto
.
setStatusFlags
(
Arrays
.
asList
(
CouponStatus
.
STATUS_0
.
getCode
(),
CouponStatus
.
STATUS_2
.
getCode
()));
getMemberCouponListRequestDto
.
setPageNum
(
1
);
getMemberCouponListRequestDto
.
setPageNum
(
1
);
getMemberCouponListRequestDto
.
setPageSize
(
Integer
.
MAX_VALUE
);
getMemberCouponListRequestDto
.
setPageSize
(
Integer
.
MAX_VALUE
);
List
<
GetMemberCouponListResponseDto
.
Result
.
MemberCoupon
>
validMemberCouponList
=
couponService
.
getValidMemberCouponList
(
getMemberCouponListRequestDto
,
couponPromotionVO
.
getOrderType
());
List
<
GetMemberCouponListResponseDto
.
Result
.
MemberCoupon
>
validMemberCouponList
=
this
.
getValidMemberCouponList
(
getMemberCouponListRequestDto
,
couponPromotionVO
.
getOrderType
());
validCouponCodeLis
=
validMemberCouponList
.
stream
().
map
(
GetMemberCouponListResponseDto
.
Result
.
MemberCoupon
::
getCouponCode
).
collect
(
Collectors
.
toList
());
validCouponCodeLis
=
validMemberCouponList
.
stream
().
map
(
GetMemberCouponListResponseDto
.
Result
.
MemberCoupon
::
getCouponCode
).
collect
(
Collectors
.
toList
());
}
}
if
(
CollectionUtils
.
isEmpty
(
validCouponCodeLis
)){
if
(
CollectionUtils
.
isEmpty
(
validCouponCodeLis
)){
...
@@ -1366,7 +1332,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -1366,7 +1332,7 @@ public class CouponServiceImpl implements CouponService {
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
requestVo
.
setStoreId
(
requestDto
.
getStoreId
());
GetCouponDetailResponseDto
couponDetailResponseDto
=
couponService
.
getMemberCoupon
(
requestVo
);
GetCouponDetailResponseDto
couponDetailResponseDto
=
this
.
getMemberCoupon
(
requestVo
);
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
return
null
;
return
null
;
}
}
...
@@ -1527,4 +1493,27 @@ public class CouponServiceImpl implements CouponService {
...
@@ -1527,4 +1493,27 @@ public class CouponServiceImpl implements CouponService {
}
}
/**
* 批量查询活动详情
*
* @param partnerId
* @param activityCodes
* @param trackingNo
* @return
*/
public
List
<
Active
>
batchQueryActivityInfo
(
String
partnerId
,
List
<
String
>
activityCodes
,
String
trackingNo
)
{
String
appSecret
=
this
.
getAppSecret
(
partnerId
);
BatchQueryActivityInfoRequestDto
requestDto
=
new
BatchQueryActivityInfoRequestDto
();
requestDto
.
setActiveCode
(
activityCodes
);
// 书写逻辑
requestDto
.
setPartnerId
(
Integer
.
valueOf
(
partnerId
));
String
sign
=
SignUtil
.
createMD5Sign
(
requestDto
,
appSecret
);
requestDto
.
setSign
(
sign
);
BatchQueryActivityInfoResponseDto
batchQueryActivityInfoResponseDto
=
cardBinClient
.
batchQueryActivityInfo
(
requestDto
);
if
(
batchQueryActivityInfoResponseDto
==
null
||
!
CartResponseConstant
.
SUCCESS
.
getCode
().
equals
(
batchQueryActivityInfoResponseDto
.
getStatusCode
())
||
CollectionUtils
.
isEmpty
(
batchQueryActivityInfoResponseDto
.
getActivities
()))
{
return
null
;
}
return
batchQueryActivityInfoResponseDto
.
getActivities
();
}
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ProductServiceImpl.java
View file @
b55e6c21
package
cn
.
freemud
.
service
.
impl
;
package
cn
.
freemud
.
service
.
impl
;
import
ch.qos.logback.classic.Level
;
import
cn.freemud.adapter.ShoppingCartConvertAdapter
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.entities.dto.GetCouponDetailResponseDto
;
import
cn.freemud.entities.dto.ProductBaseResponse
;
import
cn.freemud.entities.dto.ProductBaseResponse
;
import
cn.freemud.entities.dto.RequiredProductRequest
;
import
cn.freemud.entities.dto.RequiredProductRequest
;
import
cn.freemud.entities.dto.coupon.Active
;
import
cn.freemud.entities.dto.product.ProductTypeBeanDTO
;
import
cn.freemud.entities.dto.product.ValiadShopProductResponse
;
import
cn.freemud.entities.dto.product.ValiadShopProductResult
;
import
cn.freemud.entities.dto.product.ValidateShopProductRequest
;
import
cn.freemud.entities.vo.CartGoods
;
import
cn.freemud.entities.vo.CartGoods
;
import
cn.freemud.entities.vo.GetMemberCouponRequestVo
;
import
cn.freemud.service.ProductService
;
import
cn.freemud.service.ProductService
;
import
cn.freemud.service.thirdparty.ProductClient
;
import
cn.freemud.service.thirdparty.ProductClient
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.*
;
import
com.freemud.sdk.api.assortment.shoppingcart.domain.CartGoodsStates
;
import
com.freemud.sdk.api.assortment.shoppingcart.domain.ShoppingCartGoodsResponseVo
;
import
com.freemud.sdk.api.assortment.shoppingcart.request.CheckCartRequest
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.CartResponseUtil
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.PropertyConvertUtil
;
import
com.freemud.sdk.api.assortment.shoppingcart.util.ShoppingSdkLogUtil
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
import
java.util.*
;
import
java.util.function.Predicate
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -32,6 +51,12 @@ public class ProductServiceImpl implements ProductService {
...
@@ -32,6 +51,12 @@ public class ProductServiceImpl implements ProductService {
@Autowired
@Autowired
private
ProductClient
productClient
;
private
ProductClient
productClient
;
@Autowired
private
CouponServiceImpl
couponService
;
@Autowired
private
ShoppingCartConvertAdapter
shoppingCartConvertAdapter
;
@Override
@Override
public
boolean
hasRequiredProducts
(
String
partnerId
,
String
storeId
,
List
<
CartGoods
>
cartGoodsList
,
String
menuType
)
{
public
boolean
hasRequiredProducts
(
String
partnerId
,
String
storeId
,
List
<
CartGoods
>
cartGoodsList
,
String
menuType
)
{
RequiredProductRequest
request
=
RequiredProductRequest
.
builder
().
channel
(
menuType
).
partnerId
(
partnerId
).
shopId
(
storeId
).
build
();
RequiredProductRequest
request
=
RequiredProductRequest
.
builder
().
channel
(
menuType
).
partnerId
(
partnerId
).
shopId
(
storeId
).
build
();
...
@@ -46,4 +71,216 @@ public class ProductServiceImpl implements ProductService {
...
@@ -46,4 +71,216 @@ public class ProductServiceImpl implements ProductService {
}
}
return
false
;
return
false
;
}
}
/**
* 校验商品
*/
public
BaseResponse
<
CheckCartRequest
>
checkAllCartGoodsNew
(
CheckCartRequest
checkCartRequest
)
{
try
{
ValidateShopProductRequest
validateShopProductRequest
=
shoppingCartConvertAdapter
.
getValidateShopProductRequest
(
checkCartRequest
);
ProductBaseResponse
<
ValiadShopProductResponse
>
valiadResponse
=
productClient
.
validateShopProduct
(
validateShopProductRequest
);
if
(
valiadResponse
==
null
||
!
CartResponseConstant
.
SUCCESS
.
getCode
().
equals
(
valiadResponse
.
getErrmsg
())
||
valiadResponse
.
getData
()==
null
)
{
checkCartRequest
.
getCartGoodsList
().
clear
();
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setChanged
(
true
);
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setToastMsg
(
ShoppingCartConstant
.
SHOPPING_CART_INVALIAD_GOODS
);
return
CartResponseUtil
.
error
(
valiadResponse
.
getErrmsg
(),
checkCartRequest
);
}
ValiadShopProductResponse
valiadResult
=
valiadResponse
.
getData
();
//非法商品(商品是否存在、商品是否处于上架状态)自动移除,返回前端提示
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isNotEmpty
(
valiadResult
.
getFailureList
())){
setToastMsgIfNotExist
(
checkCartRequest
.
getShoppingCartGoodsResponseVo
(),
ShoppingCartConstant
.
SHOPPING_CART_GOODS_CHANGE
);
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
:
checkCartRequest
.
getCartGoodsList
())
{
if
(
valiadResult
.
getFailureList
().
stream
().
anyMatch
(
f
->
cartGoods
.
getCartGoodsUid
().
equals
(
f
.
getUuid
()))){
cartGoods
.
setCartGoodsUid
(
null
);
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setChanged
(
true
);
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setToastMsg
(
ShoppingCartConstant
.
SHOPPING_CART_INVALIAD_GOODS
);
}
}
checkCartRequest
.
getCartGoodsList
().
removeIf
(
k
->
StringUtils
.
isEmpty
(
k
.
getCartGoodsUid
()));
}
// Todo : 验证的商品信息
List
<
ProductTypeBeanDTO
>
productList
=
valiadResult
.
getSuccessList
().
stream
().
map
(
ValiadShopProductResult:
:
getProductType
).
collect
(
Collectors
.
toList
());
CartGoodsStates
cartGoodsStates
=
new
CartGoodsStates
();
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
:
checkCartRequest
.
getCartGoodsList
())
{
// 当goodsId为空或商品是商品券时直接跳过
if
(
StringUtils
.
isEmpty
(
cartGoods
.
getGoodsId
())
||
Objects
.
equals
(
cartGoods
.
getGoodsType
(),
GoodsTypeEnum
.
COUPON_GOODS
.
getGoodsType
())
||
Objects
.
equals
(
cartGoods
.
getGoodsType
(),
GoodsTypeEnum
.
HG_COUPON_GOODS
.
getGoodsType
())
||
Objects
.
equals
(
cartGoods
.
getGoodsType
(),
GoodsTypeEnum
.
BUY_M_SEND_N_COUPON
.
getGoodsType
()))
{
continue
;
}
// fisherman 添加原有商品类型
shoppingCartConvertAdapter
.
updateCartGoodsInfoNew
(
cartGoods
,
productList
);
}
//校验商品券是否有当前点餐方式
cartGoodsStates
=
updateSpqCartGoodsInfo
(
checkCartRequest
.
getCartGoodsList
(),
checkCartRequest
.
getOrderWay
(),
checkCartRequest
.
getPartnerId
(),
checkCartRequest
.
getTrackingNo
(),
cartGoodsStates
,
checkCartRequest
.
getStoreId
());
// 点餐方式改变商品券发生变动
if
(
cartGoodsStates
!=
null
&&
cartGoodsStates
.
isOrderWayFlag
())
{
setToastMsgIfNotExist
(
checkCartRequest
.
getShoppingCartGoodsResponseVo
(),
ShoppingCartConstant
.
ORDER_WAY_CHANGE
);
}
//若商品详情赋值有异常,直接移除购物车
if
(
checkCartRequest
.
getCartGoodsList
().
stream
().
anyMatch
(
cart
->
StringUtils
.
isEmpty
(
cart
.
getCartGoodsUid
())))
{
checkCartRequest
.
getCartGoodsList
().
removeIf
(
k
->
StringUtils
.
isEmpty
(
k
.
getCartGoodsUid
()));
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setChanged
(
true
);
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setToastMsg
(
ShoppingCartConstant
.
SHOPPING_CART_INVALIAD_GOODS
);
}
//todo 小料
if
(
checkCartRequest
.
getCartGoodsList
().
stream
().
anyMatch
(
cart
->
cart
.
getGoodsType
().
equals
(
GoodsTypeEnum
.
EXCEPTION_GOODS
.
getGoodsType
())))
{
checkCartRequest
.
getCartGoodsList
().
removeIf
(
k
->
k
.
getGoodsType
().
equals
(
GoodsTypeEnum
.
EXCEPTION_GOODS
.
getGoodsType
()));
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setChanged
(
true
);
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setToastMsg
(
ShoppingCartConstant
.
SHOPPING_CART_MATERIAL_ERROR
);
}
ShoppingSdkLogUtil
.
infoLog
(
"替换购物车数据检验结果 2 --> checkCartRequest:{}"
,
checkCartRequest
);
return
CartResponseUtil
.
success
(
checkCartRequest
);
}
catch
(
Exception
e
)
{
ShoppingSdkLogUtil
.
printErrorLog
(
"assortment-shoppingcart-sdk"
,
checkCartRequest
.
getTrackingNo
(),
e
.
getMessage
(),
"checkAllCartGoods"
,
checkCartRequest
,
e
,
Level
.
ERROR
);
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setChanged
(
true
);
checkCartRequest
.
getShoppingCartGoodsResponseVo
().
setToastMsg
(
ShoppingCartConstant
.
SHOPPING_CART_INVALIAD_GOODS
);
return
CartResponseUtil
.
error
(
e
.
getMessage
(),
checkCartRequest
);
}
}
/**
* 当ToastMsg为空时才赋值
*
* @param shoppingCartGoodsResponseVo
* @param message
*/
private
void
setToastMsgIfNotExist
(
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
String
message
)
{
if
(
StringUtils
.
isEmpty
(
shoppingCartGoodsResponseVo
.
getToastMsg
()))
{
shoppingCartGoodsResponseVo
.
setToastMsg
(
message
);
}
}
/**
* 根据点餐方式、校验商品券是否满足
*
* @param cartGoodsList
* @param orderWay
* @return
*/
private
CartGoodsStates
updateSpqCartGoodsInfo
(
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
>
cartGoodsList
,
Integer
orderWay
,
String
partnerId
,
String
trackingNo
,
CartGoodsStates
goodsStates
,
String
storeId
)
{
//获取所有商品券cartGoodsUid=sqp+code
List
<
String
>
couponIds
=
cartGoodsList
.
parallelStream
()
.
filter
(
k
->
StringUtils
.
isNotEmpty
(
k
.
getCartGoodsUid
())&&
k
.
getCartGoodsUid
().
startsWith
(
CommonsConstant
.
COUPON_PREFIX
)).
map
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
::
getSpuId
).
collect
(
Collectors
.
toList
());
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isEmpty
(
couponIds
))
{
couponIds
=
cartGoodsList
.
parallelStream
()
.
filter
(
k
->
StringUtils
.
isNotBlank
(
k
.
getCouponCode
())).
map
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
::
getCouponCode
).
collect
(
Collectors
.
toList
());
}
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isEmpty
(
couponIds
))
{
return
goodsStates
;
}
List
<
GetCouponDetailResponseDto
.
Details
>
detailVOList
=
getCouponsDetail
(
partnerId
,
storeId
,
couponIds
,
trackingNo
);
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isEmpty
(
detailVOList
))
{
return
goodsStates
;
}
Map
<
String
,
GetCouponDetailResponseDto
.
Details
>
detailsMap
;
List
<
String
>
activityCode
;
Map
<
String
,
Boolean
>
couponOrderWayMap
;
detailsMap
=
detailVOList
.
stream
().
collect
(
Collectors
.
toMap
(
p
->
p
.
getCode
(),
(
p
)
->
p
,
(
v1
,
v2
)
->
v1
));
activityCode
=
detailVOList
.
stream
().
map
(
p
->
p
.
getActiveCode
()).
collect
(
Collectors
.
toList
());
couponOrderWayMap
=
getCouponOrderWay
(
partnerId
,
activityCode
,
orderWay
,
trackingNo
);
//遍历商品券是否有当前点餐方式点餐
boolean
orderWayFlag
=
false
;
if
(
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isNotEmpty
(
cartGoodsList
))
{
orderWayFlag
=
checkProductOrderWay
(
cartGoodsList
,
detailsMap
,
couponOrderWayMap
);
}
if
(
orderWayFlag
)
{
goodsStates
.
setOrderWayFlag
(
true
);
cartGoodsList
.
removeIf
(
k
->
k
.
getCartGoodsUid
()
==
null
);
}
return
goodsStates
;
}
/**
* 查询券详情
*
* @param partnerId
* @param codes
* @param trackingNo
* @return
*/
private
List
<
GetCouponDetailResponseDto
.
Details
>
getCouponsDetail
(
String
partnerId
,
String
storeId
,
List
<
String
>
codes
,
String
trackingNo
)
{
String
couponCode
=
String
.
join
(
","
,
codes
);
//TODO 查询券详情券是否存在
GetMemberCouponRequestVo
requestVo
=
new
GetMemberCouponRequestVo
();
requestVo
.
setPartnerId
(
partnerId
);
requestVo
.
setCouponCode
(
couponCode
);
requestVo
.
setStoreId
(
storeId
);
GetCouponDetailResponseDto
couponDetailResponseDto
=
couponService
.
getMemberCoupon
(
requestVo
);
if
(
couponDetailResponseDto
==
null
||
!
couponDetailResponseDto
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
org
.
apache
.
commons
.
collections4
.
CollectionUtils
.
isEmpty
(
couponDetailResponseDto
.
getDetails
()))
{
return
null
;
}
return
couponDetailResponseDto
.
getDetails
();
}
/**
* 校验点餐方式
* key = 活动code , value = 返回是否匹配点餐方式
*
* @param partnerId
* @param activityCodes
* @param orderTye
* @param trackingNo
* @return
*/
public
Map
<
String
,
Boolean
>
getCouponOrderWay
(
String
partnerId
,
List
<
String
>
activityCodes
,
Integer
orderTye
,
String
trackingNo
)
{
try
{
List
<
Active
>
activeDetailVOList
=
couponService
.
batchQueryActivityInfo
(
partnerId
,
activityCodes
,
trackingNo
);
if
(
CollectionUtils
.
isEmpty
(
activeDetailVOList
))
{
return
null
;
}
Map
<
String
,
Boolean
>
result
=
new
HashMap
<>();
ActivityChannelEnum
activityChannelEnum
=
PropertyConvertUtil
.
orderTypeConvert2ActivityChannel
(
orderTye
);
activeDetailVOList
.
forEach
(
active
->
{
if
(
Objects
.
isNull
(
active
.
getRedeemChannel
()))
{
result
.
put
(
active
.
getActiveCode
(),
true
);
}
else
{
result
.
put
(
active
.
getActiveCode
(),
Arrays
.
stream
(
active
.
getRedeemChannel
().
split
(
","
)).
anyMatch
(
Predicate
.
isEqual
(
activityChannelEnum
.
getCode
())));
}
});
return
result
;
}
catch
(
Exception
e
)
{
ShoppingSdkLogUtil
.
printErrorLog
(
"assortment-shoppingcart-sdk"
,
trackingNo
,
e
.
getMessage
(),
"getCouponOrderWay"
,
null
,
e
,
Level
.
ERROR
);
return
null
;
}
}
/**
* 商品券是否有当前点餐方式点餐
*
* @param cartGoodsList
* @param detailsMap
* @param couponOrderWayMap
* @return
*/
private
boolean
checkProductOrderWay
(
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
>
cartGoodsList
,
Map
<
String
,
GetCouponDetailResponseDto
.
Details
>
detailsMap
,
Map
<
String
,
Boolean
>
couponOrderWayMap
)
{
boolean
orderWayFlag
=
false
;
List
<
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
>
cartGoodsByProduct
=
cartGoodsList
.
stream
()
.
filter
(
cartGoods
->
cartGoods
.
getCartGoodsUid
().
startsWith
(
CommonsConstant
.
COUPON_PREFIX
))
.
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isEmpty
(
cartGoodsByProduct
)){
cartGoodsByProduct
=
cartGoodsList
.
stream
()
.
filter
(
cartGoods
->
StringUtils
.
isNotBlank
(
cartGoods
.
getCouponCode
()))
.
collect
(
Collectors
.
toList
());
}
for
(
com
.
freemud
.
sdk
.
api
.
assortment
.
shoppingcart
.
domain
.
CartGoods
cartGoods
:
cartGoodsByProduct
)
{
GetCouponDetailResponseDto
.
Details
detail
=
detailsMap
.
get
(
cartGoods
.
getSpuId
());
String
activeCode
=
detail
!=
null
?
detail
.
getActiveCode
()
:
""
;
if
(
couponOrderWayMap
==
null
||
couponOrderWayMap
.
isEmpty
()
||
!
couponOrderWayMap
.
get
(
activeCode
))
{
orderWayFlag
=
true
;
cartGoods
.
setCartGoodsUid
(
null
);
}
}
return
orderWayFlag
;
}
}
}
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