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
7392e8ae
Commit
7392e8ae
authored
Jun 17, 2021
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物车支持多张券进行选择
Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent
178c9141
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
70 additions
and
34 deletions
+70
-34
shopping-cart-application-service/src/main/java/cn/freemud/adapter/CouponAdapter.java
+16
-0
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/impl/PlatformListCartGoodsService.java
+1
-1
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/CouponPromotionVO.java
+12
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/CouponService.java
+9
-2
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponPromotionService.java
+6
-6
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
+15
-12
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+1
-1
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/CouponSharingService.java
+1
-1
shopping-cart-application-service/src/test/java/cn.freemud/service/CouponServiceTest.java
+9
-11
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/adapter/CouponAdapter.java
View file @
7392e8ae
...
...
@@ -559,6 +559,10 @@ public class CouponAdapter {
if
(
CollectionUtils
.
isEmpty
(
couponCodes
))
{
couponPromotionVO
.
setCouponCode
(
""
);
}
else
{
// 把所有的券信息装入 set中 用于可选优惠券判断
Set
<
String
>
setCoupons
=
new
HashSet
<>();
couponCodes
.
forEach
(
c
->
setCoupons
.
add
(
c
.
getCouponCode
()));
couponPromotionVO
.
setCouponCodes
(
setCoupons
);
ShoppingCartInfoRequestVo
.
couponCode
otherCouponCode
=
couponCodes
.
stream
()
.
filter
(
couponCode
->
!
couponCode
.
getCouponType
().
equals
(
CouponTypeEnum
.
TYPE_5
.
getCode
()))
// 只能使用一张券 排除配送券情况下
...
...
@@ -587,6 +591,12 @@ public class CouponAdapter {
*/
public
CouponPromotionVO
getCouponPromotionVO
(
ListCartGoodsBO
baseRequestDTO
)
{
CouponPromotionVO
couponPromotionVO
=
new
CouponPromotionVO
();
List
<
ListCartGoodsBO
.
couponCode
>
couponCodes
=
baseRequestDTO
.
getCouponCodes
();
if
(
CollectionUtils
.
isNotEmpty
(
couponCodes
))
{
Set
<
String
>
setCoupons
=
new
HashSet
<>();
couponCodes
.
forEach
(
c
->
setCoupons
.
add
(
c
.
getCouponCode
()));
couponPromotionVO
.
setCouponCodes
(
setCoupons
);
}
couponPromotionVO
.
setPartnerId
(
baseRequestDTO
.
getPartnerId
());
couponPromotionVO
.
setUserId
(
baseRequestDTO
.
getUserId
());
couponPromotionVO
.
setStoreId
(
baseRequestDTO
.
getShopId
());
...
...
@@ -604,6 +614,12 @@ public class CouponAdapter {
*/
public
CouponPromotionVO
getCouponPromotionVO
(
ShoppingCartGoodsApportionBO
baseRequestDTO
)
{
CouponPromotionVO
couponPromotionVO
=
new
CouponPromotionVO
();
List
<
ShoppingCartGoodsApportionBO
.
couponCode
>
couponCodes
=
baseRequestDTO
.
getCouponCodes
();
if
(
CollectionUtils
.
isNotEmpty
(
couponCodes
))
{
Set
<
String
>
setCoupons
=
new
HashSet
<>();
couponCodes
.
forEach
(
c
->
setCoupons
.
add
(
c
.
getCouponCode
()));
couponPromotionVO
.
setCouponCodes
(
setCoupons
);
}
couponPromotionVO
.
setPartnerId
(
baseRequestDTO
.
getPartnerId
());
couponPromotionVO
.
setUserId
(
baseRequestDTO
.
getUserId
());
couponPromotionVO
.
setStoreId
(
baseRequestDTO
.
getShopId
());
...
...
shopping-cart-application-service/src/main/java/cn/freemud/demo/service/impl/PlatformListCartGoodsService.java
View file @
7392e8ae
...
...
@@ -186,7 +186,7 @@ public class PlatformListCartGoodsService extends AbstractListCartGoodsService {
,
couponPromotionVO
.
getPartnerId
()
,
couponPromotionVO
.
getUserId
()
,
couponPromotionVO
.
getStoreId
()
,
couponPromotionVO
.
getCouponCode
()
,
couponPromotionVO
,
hasGoodssCoupon
,
couponPromotionVO
.
getOrderType
()
,
1
...
...
shopping-cart-application-service/src/main/java/cn/freemud/entities/vo/CouponPromotionVO.java
View file @
7392e8ae
...
...
@@ -2,6 +2,9 @@ package cn.freemud.entities.vo;
import
lombok.Data
;
import
java.util.HashSet
;
import
java.util.Set
;
/**
* All rights Reserved; Designed By www.freemud.cn
*
...
...
@@ -23,4 +26,13 @@ public class CouponPromotionVO {
private
Integer
flg
;
private
Integer
orderType
;
private
String
unChooseCouponCode
;
// 用于存放 优惠券数组 兼并老版本的 couponCode
private
Set
<
String
>
couponCodes
=
new
HashSet
<>();
public
void
setCouponCode
(
String
couponCode
)
{
this
.
couponCode
=
couponCode
;
this
.
couponCodes
.
add
(
couponCode
);
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/CouponService.java
View file @
7392e8ae
...
...
@@ -13,7 +13,6 @@
package
cn
.
freemud
.
service
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.vo.*
;
...
...
@@ -79,7 +78,15 @@ public interface CouponService {
* @param cartGoods
* @return
*/
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
,
int
isNew
,
String
appId
,
String
MenuType
,
String
unChooseCouponCode
);
//ActivityClassifyCouponBean availableCoupon(List<CartGoods> cartGoods, String partnerId, String userId, String storeId, String couponCode, boolean hasGoodsCoupon, Integer orderType, int isNew,String appId,String MenuType, String unChooseCouponCode);
/**
* 调用会员接口列表
*
* @param cartGoods
* @return
*/
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
,
String
storeId
,
CouponPromotionVO
couponPromotionVO
,
boolean
hasGoodsCoupon
,
Integer
orderType
,
int
isNew
,
String
appId
,
String
MenuType
,
String
unChooseCouponCode
);
/**
* 获取卡券服务商户密钥
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponPromotionService.java
View file @
7392e8ae
package
cn
.
freemud
.
service
.
impl
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.entities.dto.*
;
import
cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto
;
import
cn.freemud.entities.dto.CheckSpqInfoResponseDto
;
import
cn.freemud.entities.dto.UserLoginInfoDto
;
import
cn.freemud.entities.dto.activity.ActivityDiscountsDto
;
import
cn.freemud.entities.dto.activity.ActivityQueryDto
;
import
cn.freemud.entities.dto.activity.ShareDiscountActivityDto
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.
*
;
import
cn.freemud.
interceptor.ServiceException
;
import
cn.freemud.enums.
CouponFlag
;
import
cn.freemud.
enums.GoodsTypeEnum
;
import
cn.freemud.service.CouponService
;
import
cn.freemud.service.IPromotionService
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
...
...
@@ -70,7 +70,7 @@ public class CouponPromotionService implements IPromotionService {
couponPromotionVO
.
getPartnerId
(),
couponPromotionVO
.
getUserId
(),
couponPromotionVO
.
getStoreId
(),
couponPromotionVO
.
getCouponCode
()
,
couponPromotionVO
,
hasGoodssCoupon
,
couponPromotionVO
.
getOrderType
(),
0
,
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
View file @
7392e8ae
...
...
@@ -436,16 +436,19 @@ public class CouponServiceImpl implements CouponService {
return
result
;
}
@Override
public
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
,
int
isNew
,
String
appId
,
String
menuType
,
String
chooseCouponCode
)
{
,
String
partnerId
,
String
userId
,
String
storeId
,
CouponPromotionVO
couponPromotionVO
,
boolean
hasGoodsCoupon
,
Integer
orderType
,
int
isNew
,
String
appId
,
String
menuType
,
String
chooseCouponCode
)
{
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
=
new
GetMemberCouponListRequestDto
(
partnerId
,
userId
);
getMemberCouponListRequestDto
.
setStatusFlags
(
Arrays
.
asList
(
CouponStatus
.
STATUS_0
.
getCode
(),
CouponStatus
.
STATUS_2
.
getCode
()));
getMemberCouponListRequestDto
.
setPageNum
(
1
);
...
...
@@ -483,7 +486,7 @@ public class CouponServiceImpl implements CouponService {
});
List
<
CouponStateVo
>
couponStateList
=
buildAvailiableCoupons
(
cartGoods
,
partnerId
,
storeId
,
couponCodes
,
isNew
,
appId
,
menuType
);
if
(
CollectionUtils
.
isNotEmpty
(
couponStateList
))
{
return
returnSuccessAvailiableCoupons
(
coupon
Code
,
hasGoodsCoupon
,
availableCouponResponseVo
,
usableCoupons
,
disableCoupons
,
memberCouponMap
,
couponStateList
,
chooseCouponCode
);
return
returnSuccessAvailiableCoupons
(
coupon
PromotionVO
==
null
?
new
HashSet
<>()
:
couponPromotionVO
.
getCouponCodes
()
,
hasGoodsCoupon
,
availableCouponResponseVo
,
usableCoupons
,
disableCoupons
,
memberCouponMap
,
couponStateList
,
chooseCouponCode
);
}
return
null
;
}
...
...
@@ -537,10 +540,10 @@ public class CouponServiceImpl implements CouponService {
return
couponStateList
;
}
private
ActivityClassifyCouponBean
returnSuccessAvailiableCoupons
(
S
tring
couponCode
,
boolean
hasGoodsCoupon
,
ActivityClassifyCouponBean
availableCouponResponseVo
,
List
<
ActivityCouponBean
>
usableCoupons
,
private
ActivityClassifyCouponBean
returnSuccessAvailiableCoupons
(
S
et
<
String
>
couponCodes
,
boolean
hasGoodsCoupon
,
ActivityClassifyCouponBean
availableCouponResponseVo
,
List
<
ActivityCouponBean
>
usableCoupons
,
List
<
ActivityCouponBean
>
disableCoupons
,
Map
<
String
,
GetMemberCouponListResponseDto
.
Result
.
MemberCoupon
>
memberCouponMap
,
List
<
CouponStateVo
>
couponStateList
,
String
chooseCouponCode
)
{
LogUtil
.
info
(
"returnSuccessAvailiableCoupons 01 couponCode : hasGoodsCoupon"
,
couponCode
,
hasGoodsCoupon
);
LogUtil
.
info
(
"returnSuccessAvailiableCoupons 01 couponCode : hasGoodsCoupon"
,
couponCode
s
,
hasGoodsCoupon
);
LogUtil
.
info
(
"returnSuccessAvailiableCoupons 02 availableCouponResponseVo : usableCoupons"
,
availableCouponResponseVo
,
usableCoupons
);
LogUtil
.
info
(
"returnSuccessAvailiableCoupons 03 disableCoupons : memberCouponMap"
,
disableCoupons
,
memberCouponMap
);
LogUtil
.
info
(
"returnSuccessAvailiableCoupons 04 couponStateList : chooseCouponCode"
,
couponStateList
,
chooseCouponCode
);
...
...
@@ -618,7 +621,7 @@ public class CouponServiceImpl implements CouponService {
activityCouponBean
.
setDailyAvailableTimes
(
couponStateVo
.
getDailyAvailableTimes
());
}
// 券状态 0 可用 1 不可用 2 限制可用
if
(
Objects
.
equals
(
activityCouponBean
.
getCouponCode
(),
couponCode
))
{
if
(
couponCodes
.
contains
(
activityCouponBean
.
getCouponCode
()
))
{
activityCouponBean
.
setSelected
(
YesOrNoEnum
.
YES
.
getCode
());
}
else
{
activityCouponBean
.
setSelected
(
YesOrNoEnum
.
NO
.
getCode
());
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
7392e8ae
...
...
@@ -1205,7 +1205,7 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
List
<
CartGoods
>
cartGoodsList
=
orderItemList
.
stream
().
map
(
each
->
convert2ShopCartGoods
(
each
)).
collect
(
toList
());
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoodsList
,
partnerId
,
memberId
,
request
.
getStoreId
(),
""
,
false
,
request
.
getOrderType
(),
0
,
""
,
""
,
""
);
,
memberId
,
request
.
getStoreId
(),
new
CouponPromotionVO
()
,
false
,
request
.
getOrderType
(),
0
,
""
,
""
,
""
);
if
(
activityClassifyCouponBean
!=
null
&&
CollectionUtils
.
isNotEmpty
(
activityClassifyCouponBean
.
getUsableCoupons
())){
List
<
GetMemberInfoResponseVo
.
Coupon
>
coupons
=
activityClassifyCouponBean
.
getUsableCoupons
().
stream
().
map
(
each
->
convert2MemberCoupon
(
each
)).
collect
(
toList
());
responseData
.
setCoupons
(
coupons
);
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/CouponSharingService.java
View file @
7392e8ae
...
...
@@ -72,7 +72,7 @@ public class CouponSharingService {
,
couponPromotionVO
.
getPartnerId
()
,
couponPromotionVO
.
getUserId
()
,
couponPromotionVO
.
getStoreId
()
,
couponPromotionVO
.
getCouponCode
()
,
couponPromotionVO
,
hasGoodssCoupon
,
couponPromotionVO
.
getOrderType
()
,
1
...
...
shopping-cart-application-service/src/test/java/cn.freemud/service/CouponServiceTest.java
View file @
7392e8ae
package
cn
.
freemud
.
service
;
import
cn.freemud.base.entity.BaseResponse
;
import
cn.freemud.entities.dto.ActivityDiscountDto
;
import
cn.freemud.entities.dto.CheckSpqInfoRequestDto
;
import
cn.freemud.entities.dto.CheckSpqInfoResponseDto
;
import
cn.freemud.entities.dto.GetCouponDetailResponseDto
;
import
cn.freemud.entities.vo.*
;
import
com.alibaba.fastjson.JSON
;
import
com.freemud.application.sdk.api.log.LogThreadLocal
;
import
com.freemud.application.sdk.api.storecenter.request.vo.GetOrgTreeListRequest
;
//import com.freemud.card.sdk.comm.Finals;
//import com.freemud.card.sdk.comm.SignUtil;
//import com.freemud.card.sdk.vo.coupon.request.MemberAddCouponVo;
import
cn.freemud.entities.vo.ActivityClassifyCouponBean
;
import
cn.freemud.entities.vo.CartGoods
;
import
cn.freemud.entities.vo.CouponPromotionVO
;
import
cn.freemud.entities.vo.GetMemberCouponRequestVo
;
import
com.google.common.collect.Lists
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang.StringUtils
;
...
...
@@ -27,11 +22,14 @@ import org.springframework.test.context.junit4.SpringRunner;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
//import com.freemud.card.sdk.comm.Finals;
//import com.freemud.card.sdk.comm.SignUtil;
//import com.freemud.card.sdk.vo.coupon.request.MemberAddCouponVo;
/**
* All rights Reserved, Designed By www.freemud.cn
*
...
...
@@ -133,7 +131,7 @@ public class CouponServiceTest {
List
<
CartGoods
>
cartGoods
=
Lists
.
newArrayList
();
CartGoods
cartGood
=
new
CartGoods
();
cartGoods
.
add
(
cartGood
);
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoods
,
"1864"
,
"122424124"
,
"1011"
,
"88123124"
,
true
,
1
,
1
,
""
,
""
,
""
);
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoods
,
"1864"
,
"122424124"
,
"1011"
,
new
CouponPromotionVO
()
,
true
,
1
,
1
,
""
,
""
,
""
);
assertTrue
(
activityClassifyCouponBean
.
getCouponNum
()
>=
1
);
}
...
...
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