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
373b94d7
Commit
373b94d7
authored
Jun 08, 2021
by
王世昌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化部分逻辑
parent
b492fd51
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
38 deletions
+52
-38
shopping-cart-application-service/src/main/java/cn/freemud/demo/adapter/service/CalculationSharingAdapter.java
+3
-1
shopping-cart-application-service/src/main/java/cn/freemud/demo/manager/coupon/KgdCouponServiceImpl.java
+26
-20
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/impl/AbstractAddGoodsService.java
+20
-14
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+3
-3
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/demo/adapter/service/CalculationSharingAdapter.java
View file @
373b94d7
...
...
@@ -51,7 +51,9 @@ public class CalculationSharingAdapter {
GetCalculationDiscountBO
.
CalculationDiscountCoupon
coupon
=
new
GetCalculationDiscountBO
.
CalculationDiscountCoupon
();
coupon
.
setCode
(
bo
.
getCouponCode
());
coupon
.
setActivityCode
(
bo
.
getActivityCode
());
GetCalculationDiscountBO
.
CalculationDiscountCoupon
calculationDiscountCoupon
=
coupons
.
stream
().
filter
(
p
->
coupon
.
getActivityCode
().
equals
(
p
.
getActivityCode
())
&&
coupon
.
getCode
().
equals
(
p
.
getCode
())).
findFirst
().
orElse
(
null
);
GetCalculationDiscountBO
.
CalculationDiscountCoupon
calculationDiscountCoupon
=
coupons
.
stream
()
.
filter
(
p
->
coupon
.
getActivityCode
().
equals
(
p
.
getActivityCode
())
&&
coupon
.
getCode
().
equals
(
p
.
getCode
()))
.
findFirst
().
orElse
(
null
);
if
(
calculationDiscountCoupon
==
null
){
coupons
.
add
(
coupon
);
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/demo/manager/coupon/KgdCouponServiceImpl.java
View file @
373b94d7
package
cn
.
freemud
.
demo
.
manager
.
coupon
;
import
cn.freemud.base.log.LogTreadLocal
;
import
cn.freemud.base.util.JsonUtil
;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.demo.entities.bo.goods.ValidateShopProductRequestBO
;
import
cn.freemud.demo.entities.bo.coupon.CheckSpqBO
;
...
...
@@ -22,6 +24,7 @@ import cn.freemud.interceptor.ServiceException;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.service.thirdparty.CardBinClient
;
import
cn.freemud.service.thirdparty.CouponOnlineClient
;
import
cn.freemud.utils.LogUtil
;
import
cn.freemud.utils.RedisUtil
;
import
com.freemud.application.sdk.api.productcenter.request.product.valid.ValidateShopProductType
;
import
com.freemud.card.sdk.comm.Finals
;
...
...
@@ -98,8 +101,9 @@ public class KgdCouponServiceImpl implements CouponService {
CheckSpqBO
result
=
new
CheckSpqBO
();
GetCouponDetailBO
getCouponDetail
=
convert2GetCouponDetailBO
(
getCheckSpqBo
);
// 如果是商品券
,获取商品
券信息
// 如果是商品券
/换购券,获取
券信息
CouponDetailBO
couponDetail
=
getCouponDetail
(
getCouponDetail
);
LogUtil
.
info
(
LogTreadLocal
.
getTrackingNo
(),
"KgdCouponServiceImpl.getCouponDetail"
,
JsonUtil
.
toJSONString
(
getCouponDetail
),
JsonUtil
.
toJSONString
(
couponDetail
));
if
(
couponDetail
==
null
||
!
couponDetail
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetail
.
getDetails
()))
{
return
null
;
...
...
@@ -109,30 +113,35 @@ public class KgdCouponServiceImpl implements CouponService {
}
Integer
couponType
=
0
;
CouponDetailBO
.
Details
couponActivityDetail
=
null
;
// 多规格券
if
(
StringUtils
.
isNotBlank
(
getCheckSpqBo
.
getSkuId
())){
boolean
productValid
=
false
;
for
(
CouponDetailBO
.
Details
detail
:
couponDetail
.
getDetails
())
{
if
(
productValid
)
break
;
if
(!
CouponStatus
.
STATUS_0
.
getCode
().
equals
(
detail
.
getStatus
()))
continue
;
if
(
Objects
.
nonNull
(
couponActivityDetail
))
break
;
if
(!
CouponStatus
.
STATUS_0
.
getCode
().
equals
(
detail
.
getStatus
())
||
!
CouponStatus
.
STATUS_2
.
getCode
().
equals
(
detail
.
getStatus
())){
continue
;
}
for
(
CouponDetailBO
.
ActiveProduct
activeProduct
:
detail
.
getActiveProduct
())
{
if
(
getCheckSpqBo
.
getSkuId
().
equals
(
activeProduct
.
getProductIdPartner
()))
{
productValid
=
true
;
couponActivityDetail
=
detail
;
// todo 和 CouponServiceImpl.checkSpqInfo不一致
couponType
=
detail
.
getType
();
break
;
}
}
}
//检查商品是否有效
if
(!
productValid
)
{
return
null
;
}
}
else
{
// 单规格券
if
(
Objects
.
equals
(
couponDetail
.
getDetails
().
get
(
0
).
getStatus
(),
CouponStatus
.
STATUS_0
.
getCode
()))
{
couponActivityDetail
=
couponDetail
.
getDetails
().
get
(
0
);
}
}
if
(
Objects
.
isNull
(
couponActivityDetail
))
{
return
null
;
}
// 判断该券是否在这个门店下(一个券可以在多个门店下使用)
List
<
String
>
couPonstoreIds
=
Lists
.
newArrayList
();
for
(
CouponDetailBO
.
Details
detail
:
couponDetail
.
getDetails
())
{
// todo STATUS_2 的又不要了?
if
(!
CouponStatus
.
STATUS_0
.
getCode
().
equals
(
detail
.
getStatus
()))
continue
;
for
(
CouponDetailBO
.
ActiveRestrictionVOS
activeRestrictionVO
:
detail
.
getActiveRestrictionVOS
())
{
couPonstoreIds
.
add
(
activeRestrictionVO
.
getStoreIdPartner
());
...
...
@@ -141,17 +150,16 @@ public class KgdCouponServiceImpl implements CouponService {
if
(
CollectionUtils
.
isNotEmpty
(
couPonstoreIds
)
&&
!
couPonstoreIds
.
contains
(
getCheckSpqBo
.
getStoreId
()))
{
return
null
;
}
//券返回的商品id
List
<
String
>
skuIds
=
Lists
.
newArrayList
();
// 券返回的商品id
String
skuId
=
getCheckSpqBo
.
getSkuId
();
if
(
StringUtils
.
isBlank
(
skuId
)){
skuId
=
coupon
Detail
.
getDetails
().
get
(
0
)
.
getActiveProduct
().
get
(
0
).
getProductIdPartner
();
if
(
StringUtils
.
isBlank
(
skuId
)){
skuId
=
coupon
ActivityDetail
.
getActiveProduct
().
get
(
0
).
getProductIdPartner
();
}
skuIds
.
add
(
skuId
);
// 通过skuid查询spuid
GetProductBySkuIdBO
getProductBySkuIdBO
=
convert2GetProductBySkuIdBO
(
getCheckSpqBo
);
GetProductBySkuIdBO
getProductBySkuIdBO
=
convert2GetProductBySkuIdBO
(
getCheckSpqBo
,
skuId
);
Map
<
String
,
GetProductBySkuIdResponseBO
>
productsInfoBySkuIds
=
productManager
.
getProductsInfoBySkuIds
(
getProductBySkuIdBO
,
getCheckSpqBo
.
getProductService
());
LogUtil
.
info
(
LogTreadLocal
.
getTrackingNo
(),
"getProductBySkuIdBO >>>>"
,
JsonUtil
.
toJSONString
(
getProductBySkuIdBO
),
JsonUtil
.
toJSONString
(
couponDetail
));
GetProductBySkuIdResponseBO
productsVo
=
productsInfoBySkuIds
.
get
(
skuId
);
if
(
null
==
productsVo
||
!
Objects
.
equals
(
productsVo
.
getStatus
(),
StoreItemStatus
.
PUT_ON_SALE
.
getCode
()))
{
return
null
;
...
...
@@ -236,13 +244,11 @@ public class KgdCouponServiceImpl implements CouponService {
return
getCouponDetailBO
;
}
private
GetProductBySkuIdBO
convert2GetProductBySkuIdBO
(
GetCheckSpqBo
getCheckSpqBo
)
{
private
GetProductBySkuIdBO
convert2GetProductBySkuIdBO
(
GetCheckSpqBo
getCheckSpqBo
,
String
skuId
)
{
GetProductBySkuIdBO
getProductBySkuIdBO
=
new
GetProductBySkuIdBO
();
getProductBySkuIdBO
.
setMenuType
(
getCheckSpqBo
.
getMenuType
());
getProductBySkuIdBO
.
setPartnerId
(
getCheckSpqBo
.
getPartnerId
());
List
<
String
>
skuids
=
new
ArrayList
<>();
skuids
.
add
(
getCheckSpqBo
.
getSkuId
());
getProductBySkuIdBO
.
setSkuids
(
skuids
);
getProductBySkuIdBO
.
setSkuids
(
Collections
.
singletonList
(
skuId
));
getProductBySkuIdBO
.
setStoreId
(
getCheckSpqBo
.
getStoreId
());
return
getProductBySkuIdBO
;
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/impl/AbstractAddGoodsService.java
View file @
373b94d7
...
...
@@ -2,6 +2,8 @@ package cn.freemud.demo.service.impl;
import
cn.freemud.adapter.ActivityAdapter
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.base.log.LogTreadLocal
;
import
cn.freemud.base.util.JsonUtil
;
import
cn.freemud.demo.entities.bo.promotion.GetActivityBO
;
import
cn.freemud.demo.constant.ResponseConstant
;
import
cn.freemud.demo.entities.bo.goods.ShoppingCartGoodsBO
;
...
...
@@ -34,6 +36,7 @@ import cn.freemud.redis.RedisCache;
import
cn.freemud.service.impl.AssortmentSdkService
;
import
cn.freemud.service.impl.calculate.CalculationCommonService
;
import
cn.freemud.utils.BeanUtil
;
import
cn.freemud.utils.LogUtil
;
import
cn.freemud.utils.WebUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
...
...
@@ -201,15 +204,15 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
bo
.
setIsMember
(
userInfo
.
getIsMember
());
baseRequestBO
.
setUserId
(
userInfo
.
getUserId
());
// 获取商品信息
// 获取商品券换购券
CheckSpqBO
spqBO
=
getSpqInfo
(
baseRequestBO
);
GetProductBO
getProductBO
=
convert2ProductBO
(
baseRequestBO
,
spqBO
);
if
(
getProductBO
==
null
){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_COUPON_MIX_NOT_EXIST
);
}
// 获取商品信息
List
<
ProductBO
>
productsInfoList
=
productManager
.
getProductsInfo
(
getProductBO
,
baseRequestBO
.
getManagerService
().
getProductService
());
LogUtil
.
info
(
LogTreadLocal
.
getTrackingNo
(),
"getProductsInfo >>>"
,
JsonUtil
.
toJSONString
(
getProductBO
),
JsonUtil
.
toJSONString
(
productsInfoList
));
ProductBO
productsInfo
=
productsInfoList
.
get
(
0
);
bo
.
setProduct
(
productsInfo
);
...
...
@@ -219,8 +222,12 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
if
(
CollectionUtils
.
isEmpty
(
allCartGoodsList
))
{
allCartGoodsList
=
new
ArrayList
<>();
}
List
<
CartGoods
>
oldCartGoodsList
=
BeanUtil
.
convertBeans
(
allCartGoodsList
,
CartGoods:
:
new
);
bo
.
setCartGoods
(
oldCartGoodsList
);
// 转换商品券购物车添加的商品
if
(
CommonUtils
.
isProductCoupon
(
baseRequestBO
.
getCouponCode
(),
baseRequestBO
.
getSpuId
()
))
{
if
(
Objects
.
nonNull
(
spqBO
))
{
CartGoods
cartGoods
=
baseRequestBO
.
getAddGoods
();
cartGoods
.
setCartGoodsUid
(
baseRequestBO
.
getSpuId
());
cartGoods
.
setOriginalPrice
(
spqBO
.
getProductPrice
());
...
...
@@ -268,9 +275,6 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
cartGoods
.
setStockLimit
(
stockLimit
);
}
List
<
CartGoods
>
oldCartGoodsList
=
BeanUtil
.
convertBeans
(
allCartGoodsList
,
CartGoods:
:
new
);
bo
.
setCartGoods
(
oldCartGoodsList
);
return
bo
;
}
...
...
@@ -284,22 +288,24 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
}
private
CheckSpqBO
getSpqInfo
(
BaseAddGoodsBO
baseRequestBO
)
{
CheckSpqBO
checkSpqBO
=
null
;
if
(
CommonUtils
.
isProductCoupon
(
baseRequestBO
.
getCouponCode
(),
baseRequestBO
.
getSpuId
()))
{
return
null
;
}
String
spuId
=
baseRequestBO
.
getSpuId
();
String
couponCode
=
CommonUtils
.
getCouponCode
(
baseRequestBO
.
getCouponCode
(),
spuId
);
GetCheckSpqBo
getCheckSpqBo
=
new
GetCheckSpqBo
(
baseRequestBO
.
getPartnerId
(),
couponCode
,
baseRequestBO
.
getShopId
(),
baseRequestBO
.
getMenuType
(),
baseRequestBO
.
getSpuId
(),
baseRequestBO
.
getSkuId
(),
baseRequestBO
.
getManagerService
().
getProductService
());
checkSpqBO
=
couponService
.
checkSpq
(
getCheckSpqBo
);
if
(
checkSpqBO
==
null
){
return
checkSpqBO
;
// 验证商品券和换购券
CheckSpqBO
checkSpqBO
=
couponService
.
checkSpq
(
getCheckSpqBo
);
if
(
checkSpqBO
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_COUPON_MIX_NOT_EXIST
);
}
if
(
checkSpqBO
.
getDetails
()
!=
null
)
{
if
(
checkSpqBO
.
getDetails
()
!=
null
)
{
checkSpqBO
.
setCouponName
(
checkSpqBO
.
getDetails
().
getTitle
());
}
}
return
checkSpqBO
;
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
373b94d7
...
...
@@ -792,17 +792,17 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
return
ResponseUtil
.
error
(
ResponseResult
.
PARAMETER_MISSING
);
}
//打包带走外卖
if
(
StringUtils
.
isNotBlank
(
shoppingCartInfoRequestVo
.
getCardCode
())
&&
shoppingCartInfoRequestVo
.
getOrderType
()
==
2
if
(
StringUtils
.
isNotBlank
(
shoppingCartInfoRequestVo
.
getCardCode
())
&&
Objects
.
equals
(
shoppingCartInfoRequestVo
.
getOrderType
(),
2
)
&&
StringUtils
.
isBlank
(
shoppingCartInfoRequestVo
.
getReceiveId
()))
{
return
ResponseUtil
.
error
(
ResponseResult
.
PARAMETER_MISSING
);
}
String
partnerId
=
shoppingCartInfoRequestVo
.
getPartnerId
();
String
storeId
=
shoppingCartInfoRequestVo
.
getShopId
();
// 是否走重构
if
(
SDKCommonBaseContextWare
.
getBean
(
ShoppingCartNewServiceImpl
.
class
).
newShoppingCartGray
(
shoppingCartInfoRequestVo
.
getPartnerId
(),
shoppingCartInfoRequestVo
.
getShopId
())){
Map
requestMap
=
mapperFacade
.
map
(
shoppingCartInfoRequestVo
,
Map
.
class
);
BaseResponse
<
BaseListCartGoodsVO
>
goodsList
=
null
;
goodsList
=
shoppingCartDemoController
.
listCartGoods
(
requestMap
);
BaseResponse
<
BaseListCartGoodsVO
>
goodsList
=
shoppingCartDemoController
.
listCartGoods
(
requestMap
);
if
(
goodsList
==
null
||
!
ResponseResult
.
SUCCESS
.
getCode
().
equals
(
goodsList
.
getCode
()))
{
return
goodsList
;
...
...
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