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
15297d0f
Commit
15297d0f
authored
Jan 27, 2021
by
chongfu.liang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
d7b89ef8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
144 additions
and
62 deletions
+144
-62
shopping-cart-application-service/src/main/java/cn/freemud/demo/entities/CheckSpqBO.java
+16
-0
shopping-cart-application-service/src/main/java/cn/freemud/demo/manager/coupon/CouponService.java
+4
-0
shopping-cart-application-service/src/main/java/cn/freemud/demo/manager/coupon/KgdCouponServiceImpl.java
+108
-7
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/AbstractAddGoodsService.java
+12
-55
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/PlatformUpdateGoodsQtyService.java
+4
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/demo/entities/CheckSpqBO.java
0 → 100644
View file @
15297d0f
package
cn
.
freemud
.
demo
.
entities
;
import
lombok.Data
;
@Data
public
class
CheckSpqBO
{
private
String
spuId
;
private
String
skuId
;
private
Integer
type
;
private
CouponDetailBO
.
Details
details
;
}
shopping-cart-application-service/src/main/java/cn/freemud/demo/manager/coupon/CouponService.java
View file @
15297d0f
package
cn
.
freemud
.
demo
.
manager
.
coupon
;
import
cn.freemud.demo.entities.CheckSpqBO
;
import
cn.freemud.demo.entities.CouponDetailBO
;
import
cn.freemud.demo.entities.GetCouponDetailBO
;
import
cn.freemud.demo.entities.bo.goods.GetProductBO
;
import
cn.freemud.demo.entities.bo.goods.add.BaseAddGoodsBO
;
public
interface
CouponService
{
CouponDetailBO
getCouponDetail
(
GetCouponDetailBO
getCouponDetailBO
);
CheckSpqBO
checkSpq
(
BaseAddGoodsBO
baseRequestBO
);
}
shopping-cart-application-service/src/main/java/cn/freemud/demo/manager/coupon/KgdCouponServiceImpl.java
View file @
15297d0f
package
cn
.
freemud
.
demo
.
manager
.
coupon
;
import
cn.freemud.constant.ResponseCodeConstant
;
import
cn.freemud.demo.entities.
CouponDetailBO
;
import
cn.freemud.demo.entities.
GetCouponDetail
BO
;
import
cn.freemud.demo.entities.
GetStore
BO
;
import
cn.freemud.demo.entities.
*
;
import
cn.freemud.demo.entities.
bo.goods.GetProductBySkuIdResponse
BO
;
import
cn.freemud.demo.entities.
bo.goods.add.BaseAddGoods
BO
;
import
cn.freemud.demo.entities.bo.goods.add.MCoffeeAddGoodsBO
;
import
cn.freemud.demo.manager.product.ProductManager
;
import
cn.freemud.demo.manager.store.StoreService
;
import
cn.freemud.entities.dto.GetAppKeyRequestDto
;
import
cn.freemud.entities.dto.GetAppKeyResponseDto
;
import
cn.freemud.entities.dto.GetCouponDetailResponseDto
;
import
cn.freemud.enums.CouponStatus
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.enums.StoreItemStatus
;
import
cn.freemud.redis.RedisCache
;
import
cn.freemud.service.thirdparty.CardBinClient
;
import
cn.freemud.service.thirdparty.CouponOnlineClient
;
...
...
@@ -17,7 +20,9 @@ import cn.freemud.utils.LogUtil;
import
cn.freemud.utils.RedisUtil
;
import
com.freemud.card.sdk.comm.Finals
;
import
com.freemud.card.sdk.comm.SignUtil
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
import
com.google.common.base.Joiner
;
import
com.google.common.collect.Lists
;
import
ma.glasnost.orika.MapperFacade
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -27,10 +32,7 @@ import org.springframework.beans.factory.annotation.Value;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.TreeMap
;
import
java.util.*
;
@Service
(
"KgdCouponService"
)
public
class
KgdCouponServiceImpl
implements
CouponService
{
...
...
@@ -54,6 +56,9 @@ public class KgdCouponServiceImpl implements CouponService {
@Resource
private
MapperFacade
mapperFacade
;
@Autowired
private
ProductManager
productManager
;
@Override
public
CouponDetailBO
getCouponDetail
(
GetCouponDetailBO
getCouponDetailBO
)
{
Map
<
String
,
String
>
map
=
new
TreeMap
<
String
,
String
>();
...
...
@@ -82,6 +87,79 @@ public class KgdCouponServiceImpl implements CouponService {
return
null
;
}
@Override
public
CheckSpqBO
checkSpq
(
BaseAddGoodsBO
baseRequestBO
)
{
CheckSpqBO
result
=
new
CheckSpqBO
();
GetCouponDetailBO
getCouponDetail
=
convert2GetCouponDetailBO
(
baseRequestBO
);
// 如果是商品券,获取商品券信息
CouponDetailBO
couponDetail
=
getCouponDetail
(
getCouponDetail
);
if
(
couponDetail
==
null
||
!
couponDetail
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetail
.
getDetails
()))
{
return
null
;
}
if
(
CollectionUtils
.
isEmpty
(
couponDetail
.
getDetails
()))
{
return
null
;
}
Integer
couponType
=
0
;
CouponDetailBO
.
Details
couponActivityDetail
=
null
;
if
(
StringUtils
.
isNotBlank
(
baseRequestBO
.
getSkuId
())){
boolean
productValid
=
false
;
for
(
CouponDetailBO
.
Details
detail
:
couponDetail
.
getDetails
())
{
if
(
productValid
)
break
;
if
(!
CouponStatus
.
STATUS_0
.
getCode
().
equals
(
detail
.
getStatus
()))
continue
;
for
(
CouponDetailBO
.
ActiveProduct
activeProduct
:
detail
.
getActiveProduct
())
{
if
(
baseRequestBO
.
getSkuId
().
equals
(
activeProduct
.
getProductIdPartner
()))
{
productValid
=
true
;
couponActivityDetail
=
detail
;
couponType
=
detail
.
getType
();
break
;
}
}
}
//检查商品是否有效
if
(!
productValid
)
{
return
null
;
}
}
else
{
couponActivityDetail
=
couponDetail
.
getDetails
().
get
(
0
);
}
// 判断该券是否在这个门店下(一个券可以在多个门店下使用)
List
<
String
>
couPonstoreIds
=
Lists
.
newArrayList
();
for
(
CouponDetailBO
.
Details
detail
:
couponDetail
.
getDetails
())
{
if
(!
CouponStatus
.
STATUS_0
.
getCode
().
equals
(
detail
.
getStatus
()))
continue
;
for
(
CouponDetailBO
.
ActiveRestrictionVOS
activeRestrictionVO
:
detail
.
getActiveRestrictionVOS
())
{
couPonstoreIds
.
add
(
activeRestrictionVO
.
getStoreIdPartner
());
}
}
if
(
CollectionUtils
.
isNotEmpty
(
couPonstoreIds
)
&&
!
couPonstoreIds
.
contains
(
baseRequestBO
.
getShopId
()))
{
return
null
;
}
//券返回的商品id
List
<
String
>
skuIds
=
Lists
.
newArrayList
();
String
skuId
=
baseRequestBO
.
getSkuId
();
if
(
StringUtils
.
isBlank
(
skuId
)){
skuId
=
couponDetail
.
getDetails
().
get
(
0
).
getActiveProduct
().
get
(
0
).
getProductIdPartner
();
}
skuIds
.
add
(
skuId
);
// 通过skuid查询spuid
GetProductBySkuIdBO
getProductBySkuIdBO
=
convert2GetProductBySkuIdBO
(
baseRequestBO
);
Map
<
String
,
GetProductBySkuIdResponseBO
>
productsInfoBySkuIds
=
productManager
.
getProductsInfoBySkuIds
(
getProductBySkuIdBO
,
baseRequestBO
.
getManagerService
().
getProductService
());
GetProductBySkuIdResponseBO
productsVo
=
productsInfoBySkuIds
.
get
(
skuId
);
if
(
null
==
productsVo
||
!
Objects
.
equals
(
productsVo
.
getStatus
(),
StoreItemStatus
.
PUT_ON_SALE
.
getCode
()))
{
return
null
;
}
result
.
setType
(
couponType
);
result
.
setDetails
(
couponActivityDetail
);
result
.
setSkuId
(
productsVo
.
getSkuId
());
result
.
setSpuId
(
productsVo
.
getSpuId
());
return
result
;
}
private
CouponDetailBO
convert2CouponDetailBO
(
GetCouponDetailResponseDto
responseDto
)
{
CouponDetailBO
couponDetailBO
=
mapperFacade
.
map
(
responseDto
,
CouponDetailBO
.
class
);
return
couponDetailBO
;
...
...
@@ -102,4 +180,27 @@ public class KgdCouponServiceImpl implements CouponService {
return
appSecret
;
}
private
GetCouponDetailBO
convert2GetCouponDetailBO
(
BaseAddGoodsBO
baseRequestBO
)
{
GetCouponDetailBO
getCouponDetailBO
=
new
GetCouponDetailBO
();
getCouponDetailBO
.
setPartnerId
(
baseRequestBO
.
getPartnerId
());
getCouponDetailBO
.
setCouponCode
(
StringUtils
.
isBlank
(
baseRequestBO
.
getCouponCode
())
?
baseRequestBO
.
getSpuId
().
substring
(
CommonsConstant
.
COUPON_PREFIX
.
length
())
:
baseRequestBO
.
getCouponCode
());
getCouponDetailBO
.
setStoreCode
(
baseRequestBO
.
getShopId
());
return
getCouponDetailBO
;
}
private
GetProductBySkuIdBO
convert2GetProductBySkuIdBO
(
BaseAddGoodsBO
baseRequestBO
)
{
GetProductBySkuIdBO
getProductBySkuIdBO
=
new
GetProductBySkuIdBO
();
getProductBySkuIdBO
.
setMenuType
(
baseRequestBO
.
getMenuType
());
getProductBySkuIdBO
.
setPartnerId
(
baseRequestBO
.
getPartnerId
());
List
<
String
>
skuids
=
new
ArrayList
<>();
skuids
.
add
(
baseRequestBO
.
getSkuId
());
getProductBySkuIdBO
.
setSkuids
(
skuids
);
getProductBySkuIdBO
.
setStoreId
(
baseRequestBO
.
getShopId
());
return
getProductBySkuIdBO
;
}
}
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/AbstractAddGoodsService.java
View file @
15297d0f
...
...
@@ -92,7 +92,8 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
private
static
final
String
limitCartKey
=
"ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"
;
@Autowired
private
CouponService
couponService
;
/**
* 加车的流程
...
...
@@ -204,6 +205,9 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
// 获取商品信息
GetProductBO
getProductBO
=
convert2ProductBO
(
baseRequestBO
);
if
(
getProductBO
==
null
){
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_COUPON_MIX_NOT_EXIST
);
}
List
<
ProductBO
>
productsInfoList
=
productManager
.
getProductsInfo
(
getProductBO
,
baseRequestBO
.
getManagerService
().
getProductService
());
ProductBO
productsInfo
=
productsInfoList
.
get
(
0
);
bo
.
setProduct
(
productsInfo
);
...
...
@@ -260,7 +264,7 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
private
GetCouponDetailBO
convert2GetCouponDetailBO
(
BaseAddGoodsBO
baseRequestBO
)
{
GetCouponDetailBO
getCouponDetailBO
=
new
GetCouponDetailBO
();
getCouponDetailBO
.
setPartnerId
(
baseRequestBO
.
getPartnerId
());
getCouponDetailBO
.
setCouponCode
(
baseRequestBO
.
getCouponCode
());
getCouponDetailBO
.
setCouponCode
(
StringUtils
.
isBlank
(
baseRequestBO
.
getCouponCode
())
?
baseRequestBO
.
getSpuId
().
substring
(
CommonsConstant
.
COUPON_PREFIX
.
length
())
:
baseRequestBO
.
getCouponCode
());
getCouponDetailBO
.
setStoreCode
(
baseRequestBO
.
getShopId
());
return
getCouponDetailBO
;
...
...
@@ -268,65 +272,19 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
private
GetProductBO
convert2ProductBO
(
BaseAddGoodsBO
baseRequestBO
)
{
GetProductBO
getProductBO
=
new
GetProductBO
();
GetCouponDetailBO
getCouponDetail
=
convert2GetCouponDetailBO
(
baseRequestBO
);
getProductBO
.
setStoreId
(
baseRequestBO
.
getShopId
());
getProductBO
.
setMenuType
(
baseRequestBO
.
getMenuType
());
getProductBO
.
setPartnerId
(
baseRequestBO
.
getPartnerId
());
if
(
baseRequestBO
.
getSpuId
().
startsWith
(
CommonsConstant
.
COUPON_PREFIX
))
{
// 如果是商品券,获取商品券信息
CouponDetailBO
couponDetail
=
couponManager
.
getCouponDetail
(
getCouponDetail
,
baseRequestBO
.
getManagerService
().
getCouponService
());
if
(
couponDetail
==
null
||
!
couponDetail
.
getResult
().
equals
(
ResponseCodeConstant
.
RESPONSE_SUCCESS_1
)
||
CollectionUtils
.
isEmpty
(
couponDetail
.
getDetails
()))
{
return
null
;
}
if
(
CollectionUtils
.
isEmpty
(
couponDetail
.
getDetails
()))
{
return
null
;
}
Integer
couponType
=
0
;
boolean
productValid
=
false
;
for
(
CouponDetailBO
.
Details
detail
:
couponDetail
.
getDetails
())
{
if
(
productValid
)
break
;
if
(!
CouponStatus
.
STATUS_0
.
getCode
().
equals
(
detail
.
getStatus
()))
continue
;
for
(
CouponDetailBO
.
ActiveProduct
activeProduct
:
detail
.
getActiveProduct
())
{
if
(
baseRequestBO
.
getSkuId
().
equals
(
activeProduct
.
getProductIdPartner
()))
{
productValid
=
true
;
couponType
=
detail
.
getType
();
break
;
}
}
}
//检查商品是否有效
if
(!
productValid
)
{
return
null
;
}
// 判断该券是否在这个门店下(一个券可以在多个门店下使用)
List
<
String
>
couPonstoreIds
=
Lists
.
newArrayList
();
for
(
CouponDetailBO
.
Details
detail
:
couponDetail
.
getDetails
())
{
if
(!
CouponStatus
.
STATUS_0
.
getCode
().
equals
(
detail
.
getStatus
()))
continue
;
for
(
CouponDetailBO
.
ActiveRestrictionVOS
activeRestrictionVO
:
detail
.
getActiveRestrictionVOS
())
{
couPonstoreIds
.
add
(
activeRestrictionVO
.
getStoreIdPartner
());
}
}
if
(
CollectionUtils
.
isNotEmpty
(
couPonstoreIds
)
&&
!
couPonstoreIds
.
contains
(
baseRequestBO
.
getShopId
()))
{
return
null
;
}
//券返回的商品id
List
<
String
>
skuIds
=
Lists
.
newArrayList
();
String
skuId
=
baseRequestBO
.
getSpuId
();
skuIds
.
add
(
skuId
);
// 通过skuid查询spuid
GetProductBySkuIdBO
getProductBySkuIdBO
=
convert2GetProductBySkuIdBO
(
baseRequestBO
);
Map
<
String
,
GetProductBySkuIdResponseBO
>
productsInfoBySkuIds
=
productManager
.
getProductsInfoBySkuIds
(
getProductBySkuIdBO
,
baseRequestBO
.
getManagerService
().
getProductService
());
GetProductBySkuIdResponseBO
productsVo
=
productsInfoBySkuIds
.
get
(
skuId
);
if
(
null
==
productsVo
||
!
Objects
.
equals
(
productsVo
.
getStatus
(),
StoreItemStatus
.
PUT_ON_SALE
.
getCode
()))
{
CheckSpqBO
checkSpqBO
=
couponService
.
checkSpq
(
baseRequestBO
);
if
(
checkSpqBO
==
null
){
return
null
;
}
getProductBO
.
setSpuid
(
Collections
.
singletonList
(
productsVo
.
getSpuId
()));
getProductBO
.
setSkuid
(
Collections
.
singletonList
(
productsVo
.
getSkuId
()));
getProductBO
.
setCouponType
(
c
ouponType
);
getProductBO
.
setActivityCode
(
c
ouponDetail
.
getDetails
().
get
(
0
).
getActive
().
getActiveCode
());
getProductBO
.
setSpuid
(
Collections
.
singletonList
(
checkSpqBO
.
getSpuId
()));
getProductBO
.
setSkuid
(
Collections
.
singletonList
(
checkSpqBO
.
getSkuId
()));
getProductBO
.
setCouponType
(
c
heckSpqBO
.
getType
()
);
getProductBO
.
setActivityCode
(
c
heckSpqBO
.
getDetails
(
).
getActive
().
getActiveCode
());
}
else
{
getProductBO
.
setSkuid
(
Collections
.
singletonList
(
baseRequestBO
.
getSkuId
()));
getProductBO
.
setSpuid
(
Collections
.
singletonList
(
baseRequestBO
.
getSpuId
()));
...
...
@@ -621,7 +579,6 @@ public abstract class AbstractAddGoodsService implements AddGoodsService {
/**
* 设置没有加入购物车的提示语
* @param messageBuilder
* @param activityList
*/
private
ArrayList
<
ActivityList
>
setMessageNotInShoppingCart
(
StringBuilder
messageBuilder
,
ActivityBO
activityBO
,
List
<
BenefitBeanBO
>
benefitBeanBOList
,
BenefitBeanBO
benefitBeanBO
)
{
...
...
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/PlatformUpdateGoodsQtyService.java
View file @
15297d0f
...
...
@@ -73,6 +73,7 @@ public class PlatformUpdateGoodsQtyService extends AbstractUpdateGoodsQtyService
this
.
setCommonDiscountGoods
(
calculationDiscountGoodsList
,
cartGoods
);
}
else
{
//商品券->商品券ID换取商品
String
goodsId
=
StringUtils
.
isNotBlank
(
cartGoods
.
getSkuId
())
?
cartGoods
.
getSkuId
()
:
cartGoods
.
getSpuId
();
GetCalculationDiscountBO
.
CalculationDiscountCoupon
coupon
=
new
GetCalculationDiscountBO
.
CalculationDiscountCoupon
();
coupon
.
setCode
(
cartGoods
.
getCouponCode
());
...
...
@@ -159,6 +160,9 @@ public class PlatformUpdateGoodsQtyService extends AbstractUpdateGoodsQtyService
@Override
public
AddGoodsToShoppingCartBO
checkCustomBusinessRules
(
UpdateAddGoodsBO
baseRequestDTO
,
CheckBussinessRulesBO
checkBussinessRulesBO
,
AddGoodsToShoppingCartBO
addGoodsToShoppingCartBO
)
{
// 校验商品券
// 商品券商品时间校验
ValidateShopProductRequestBO
validateShopProductRequestBO
=
getValidateShopProductRequestBO
(
checkBussinessRulesBO
.
getProduct
(),
baseRequestDTO
);
ValiadShopProductBO
valiadShopProductBO
=
productManager
.
validateShopProduct
(
validateShopProductRequestBO
,
baseRequestDTO
.
getManagerService
().
getProductService
());
...
...
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