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
25d58def
Commit
25d58def
authored
Sep 27, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接促销算价Alpha->fix
parent
74bc1e70
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
41 deletions
+80
-41
shopping-cart-application-service/src/main/java/cn/freemud/service/CouponService.java
+1
-1
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
+61
-30
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationCommonService.java
+9
-7
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/CouponSharingService.java
+8
-2
shopping-cart-application-service/src/test/java/cn.freemud/service/CouponServiceTest.java
+1
-1
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/CouponService.java
View file @
25d58def
...
@@ -80,7 +80,7 @@ public interface CouponService {
...
@@ -80,7 +80,7 @@ public interface CouponService {
* @param cartGoods
* @param cartGoods
* @return
* @return
*/
*/
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
);
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
,
int
isNew
);
/**
/**
* 获取卡券服务商户密钥
* 获取卡券服务商户密钥
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/CouponServiceImpl.java
View file @
25d58def
...
@@ -402,8 +402,14 @@ public class CouponServiceImpl implements CouponService {
...
@@ -402,8 +402,14 @@ public class CouponServiceImpl implements CouponService {
}
}
@Override
@Override
public
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
public
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
)
{
,
String
partnerId
,
String
userId
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
,
int
isNew
)
{
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
=
new
GetMemberCouponListRequestDto
(
partnerId
,
userId
);
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
=
new
GetMemberCouponListRequestDto
(
partnerId
,
userId
);
getMemberCouponListRequestDto
.
setStatusFlags
(
Arrays
.
asList
(
CouponStatus
.
STATUS_0
.
getCode
()));
getMemberCouponListRequestDto
.
setStatusFlags
(
Arrays
.
asList
(
CouponStatus
.
STATUS_0
.
getCode
()));
getMemberCouponListRequestDto
.
setPageNum
(
1
);
getMemberCouponListRequestDto
.
setPageNum
(
1
);
...
@@ -442,14 +448,14 @@ public class CouponServiceImpl implements CouponService {
...
@@ -442,14 +448,14 @@ public class CouponServiceImpl implements CouponService {
}
}
}
}
});
});
List
<
CouponStateVo
>
couponStateList
=
buildAvailiableCoupons
(
cartGoods
,
partnerId
,
storeId
,
couponCodes
);
List
<
CouponStateVo
>
couponStateList
=
buildAvailiableCoupons
(
cartGoods
,
partnerId
,
storeId
,
couponCodes
,
isNew
);
if
(
CollectionUtils
.
isNotEmpty
(
couponStateList
))
{
if
(
CollectionUtils
.
isNotEmpty
(
couponStateList
))
{
return
returnSuccessAvailiableCoupons
(
couponCode
,
hasGoodsCoupon
,
availableCouponResponseVo
,
usableCoupons
,
disableCoupons
,
memberCouponMap
,
couponStateList
);
return
returnSuccessAvailiableCoupons
(
couponCode
,
hasGoodsCoupon
,
availableCouponResponseVo
,
usableCoupons
,
disableCoupons
,
memberCouponMap
,
couponStateList
);
}
}
return
null
;
return
null
;
}
}
private
List
<
CouponStateVo
>
buildAvailiableCoupons
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
storeId
,
List
<
String
>
couponCodes
)
{
private
List
<
CouponStateVo
>
buildAvailiableCoupons
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
storeId
,
List
<
String
>
couponCodes
,
int
isNew
)
{
String
appSecret
=
getAppSecret
(
partnerId
);
String
appSecret
=
getAppSecret
(
partnerId
);
// 最大15一提交
// 最大15一提交
int
maxNum
=
15
;
int
maxNum
=
15
;
...
@@ -462,7 +468,7 @@ public class CouponServiceImpl implements CouponService {
...
@@ -462,7 +468,7 @@ public class CouponServiceImpl implements CouponService {
List
<
Product
>
productList
=
Lists
.
newArrayList
();
List
<
Product
>
productList
=
Lists
.
newArrayList
();
// 优惠券优先级最高,根据商品原价做计算
// 优惠券优先级最高,根据商品原价做计算
// 订单金额
// 订单金额
Long
totalAmount
=
createProductRequest
(
cartGoods
,
productList
);
Long
totalAmount
=
createProductRequest
(
cartGoods
,
productList
,
isNew
);
couponAvailableReqVo
.
setTotalAmount
(
Integer
.
valueOf
(
totalAmount
+
""
));
couponAvailableReqVo
.
setTotalAmount
(
Integer
.
valueOf
(
totalAmount
+
""
));
couponAvailableReqVo
.
setProductList
(
productList
);
couponAvailableReqVo
.
setProductList
(
productList
);
couponAvailableReqVo
.
setChannelCodeList
(
commonService
.
getOrgCodes
(
partnerId
,
storeId
));
couponAvailableReqVo
.
setChannelCodeList
(
commonService
.
getOrgCodes
(
partnerId
,
storeId
));
...
@@ -572,37 +578,62 @@ public class CouponServiceImpl implements CouponService {
...
@@ -572,37 +578,62 @@ public class CouponServiceImpl implements CouponService {
return
availableCouponResponseVo
;
return
availableCouponResponseVo
;
}
}
private
Long
createProductRequest
(
List
<
CartGoods
>
cartGoods
,
List
<
Product
>
productList
)
{
private
Long
createProductRequest
(
List
<
CartGoods
>
cartGoods
,
List
<
Product
>
productList
,
int
isNew
)
{
Long
totalAmount
=
0L
;
Long
totalAmount
=
0L
;
for
(
CartGoods
cartGood
:
cartGoods
)
{
// 剔除商品券得商品
if
(
isNew
==
1
)
{
if
(
StringUtils
.
isEmpty
(
cartGood
.
getSkuId
())
&&
StringUtils
.
isEmpty
(
cartGood
.
getSpuId
()))
{
for
(
CartGoods
cartGood
:
cartGoods
)
{
continue
;
// 剔除商品券得商品
}
if
(
StringUtils
.
isEmpty
(
cartGood
.
getSkuId
())
&&
StringUtils
.
isEmpty
(
cartGood
.
getSpuId
()))
{
Product
product
=
new
Product
();
continue
;
product
.
setProductId
(
StringUtils
.
isEmpty
(
cartGood
.
getSkuId
())
?
cartGood
.
getSpuId
()
:
cartGood
.
getSkuId
());
}
// 普通商品价格
Product
product
=
new
Product
();
product
.
setAmount
(
Integer
.
valueOf
(
cartGood
.
getOriginalPrice
()
+
""
));
product
.
setProductId
(
StringUtils
.
isEmpty
(
cartGood
.
getSkuId
())
?
cartGood
.
getSpuId
()
:
cartGood
.
getSkuId
());
// 套餐价格为: 套餐价+可选商品总价格
// 普通商品价格
if
(
ObjectUtils
.
equals
(
GoodsTypeEnum
.
SET_MEAL_GOODS
.
getGoodsType
(),
cartGood
.
getGoodsType
()))
{
product
.
setAmount
(
cartGood
.
getAmount
().
intValue
());
Long
finalPrice
=
cartGood
.
getFinalPrice
();
totalAmount
=
totalAmount
+
cartGood
.
getAmount
();
if
(
CollectionUtils
.
isNotEmpty
(
cartGood
.
getProductGroupList
()))
{
// todo :小料价格累加到主商品上
finalPrice
+=
cartGood
.
getProductGroupList
().
stream
().
mapToLong
(
group
->
group
.
getFinalPrice
()
*
group
.
getQty
()).
sum
();
if
(
CollectionUtils
.
isNotEmpty
(
cartGood
.
getProductMaterialList
()))
{
for
(
CartGoods
.
MaterialGoods
materialGoods
:
cartGood
.
getProductMaterialList
())
{
product
.
setAmount
(
product
.
getAmount
()
+
materialGoods
.
getAmount
().
intValue
());
totalAmount
=
totalAmount
+
materialGoods
.
getAmount
();
}
}
}
product
.
setAmount
(
finalPrice
.
intValue
());
// 数量
product
.
setQuantity
(
cartGood
.
getQty
());
productList
.
add
(
product
);
}
}
}
else
{
for
(
CartGoods
cartGood
:
cartGoods
)
{
// 剔除商品券得商品
if
(
StringUtils
.
isEmpty
(
cartGood
.
getSkuId
())
&&
StringUtils
.
isEmpty
(
cartGood
.
getSpuId
()))
{
continue
;
}
Product
product
=
new
Product
();
product
.
setProductId
(
StringUtils
.
isEmpty
(
cartGood
.
getSkuId
())
?
cartGood
.
getSpuId
()
:
cartGood
.
getSkuId
());
// 普通商品价格
product
.
setAmount
(
Integer
.
valueOf
(
cartGood
.
getOriginalPrice
()
+
""
));
// 套餐价格为: 套餐价+可选商品总价格
if
(
ObjectUtils
.
equals
(
GoodsTypeEnum
.
SET_MEAL_GOODS
.
getGoodsType
(),
cartGood
.
getGoodsType
()))
{
Long
finalPrice
=
cartGood
.
getFinalPrice
();
if
(
CollectionUtils
.
isNotEmpty
(
cartGood
.
getProductGroupList
()))
{
finalPrice
+=
cartGood
.
getProductGroupList
().
stream
().
mapToLong
(
group
->
group
.
getFinalPrice
()
*
group
.
getQty
()).
sum
();
}
product
.
setAmount
(
finalPrice
.
intValue
());
}
totalAmount
=
totalAmount
+
product
.
getAmount
()
*
cartGood
.
getQty
();
totalAmount
=
totalAmount
+
product
.
getAmount
()
*
cartGood
.
getQty
();
// todo :小料价格累加到主商品上
// todo :小料价格累加到主商品上
if
(
CollectionUtils
.
isNotEmpty
(
cartGood
.
getProductMaterialList
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
cartGood
.
getProductMaterialList
()))
{
for
(
CartGoods
.
MaterialGoods
materialGoods
:
cartGood
.
getProductMaterialList
())
{
for
(
CartGoods
.
MaterialGoods
materialGoods
:
cartGood
.
getProductMaterialList
())
{
product
.
setAmount
(
product
.
getAmount
()
+
Integer
.
valueOf
(
materialGoods
.
getOriginalPrice
()
+
""
));
product
.
setAmount
(
product
.
getAmount
()
+
Integer
.
valueOf
(
materialGoods
.
getOriginalPrice
()
+
""
));
totalAmount
=
totalAmount
+
materialGoods
.
getOriginalPrice
()
*
cartGood
.
getQty
();
totalAmount
=
totalAmount
+
materialGoods
.
getOriginalPrice
()
*
cartGood
.
getQty
();
}
}
}
// 数量
product
.
setQuantity
(
cartGood
.
getQty
());
productList
.
add
(
product
);
}
}
// 数量
product
.
setQuantity
(
cartGood
.
getQty
());
productList
.
add
(
product
);
}
}
return
totalAmount
;
return
totalAmount
;
}
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationCommonService.java
View file @
25d58def
...
@@ -64,23 +64,18 @@ public class CalculationCommonService {
...
@@ -64,23 +64,18 @@ public class CalculationCommonService {
originalAmount
=
0L
;
originalAmount
=
0L
;
amount
=
0L
;
amount
=
0L
;
packageAmount
=
0L
;
packageAmount
=
0L
;
//CalculationSharingDiscountResponseDto.CalculationDiscountResult.Goods find = goods.stream().filter((k) -> k.getCartGoodsUid().equals(cartGoods.getCartGoodsUid())).findFirst().get();
//if (find == null) continue;
this
.
rowRealAmount
(
goods
,
cartGoods
);
this
.
rowRealAmount
(
goods
,
cartGoods
);
//成交价行记录
//成交价行记录
//amount += find.getRealAmount() * cartGoods.getQty();
amount
=
cartGoods
.
getAmount
();
amount
=
cartGoods
.
getAmount
();
//cartGoods.setAmount(amount);
totalAmount
+=
amount
;
totalAmount
+=
amount
;
//原价行记录
//原价行记录
originalAmount
=
cartGoods
.
getOriginalPrice
()
*
cartGoods
.
getQty
()
;
originalAmount
=
cartGoods
.
getOriginalPrice
();
cartGoods
.
setOriginalAmount
(
originalAmount
);
cartGoods
.
setOriginalAmount
(
originalAmount
);
totalOriginalAmount
+=
originalAmount
;
totalOriginalAmount
+=
originalAmount
;
//包装费行记录
//包装费行记录
packageAmount
=
cartGoods
.
getPackPrice
()
*
cartGoods
.
getQty
();
packageAmount
=
cartGoods
.
getPackPrice
()
*
cartGoods
.
getQty
();
cartGoods
.
setPackPrice
(
packageAmount
);
cartGoods
.
setPackPrice
(
packageAmount
);
totalPackageAmount
+=
packageAmount
;
totalPackageAmount
+=
packageAmount
;
}
}
shoppingCartGoodsResponseVo
.
setOriginalTotalAmount
(
discountResult
==
null
?
totalOriginalAmount
:
discountResult
.
getOriginalTotalAmount
());
shoppingCartGoodsResponseVo
.
setOriginalTotalAmount
(
discountResult
==
null
?
totalOriginalAmount
:
discountResult
.
getOriginalTotalAmount
());
shoppingCartGoodsResponseVo
.
setTotalAmount
(
discountResult
==
null
?
totalAmount
:
discountResult
.
getTotalAmount
());
shoppingCartGoodsResponseVo
.
setTotalAmount
(
discountResult
==
null
?
totalAmount
:
discountResult
.
getTotalAmount
());
...
@@ -97,22 +92,29 @@ public class CalculationCommonService {
...
@@ -97,22 +92,29 @@ public class CalculationCommonService {
if
(
find
==
null
)
return
;
if
(
find
==
null
)
return
;
cartGoods
.
setAmount
(
find
.
getRealAmount
());
cartGoods
.
setAmount
(
find
.
getRealAmount
());
cartGoods
.
setOriginalAmount
(
find
.
getOriginalPrice
());
Integer
type
=
2
;
Integer
type
=
2
;
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductGroupList
()))
return
;
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductGroupList
()))
return
;
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
>
choices
=
find
.
getSmallMaterial
()
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
>
choices
=
find
.
getSmallMaterial
()
.
stream
().
filter
(
d
->
type
.
equals
(
d
.
getType
()))
.
stream
().
filter
(
d
->
type
.
equals
(
d
.
getType
()))
.
collect
(
Collectors
.
toMap
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
::
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
.
collect
(
Collectors
.
toMap
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
::
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
long
amount
=
0L
;
long
amount
=
0L
;
long
original
=
0L
;
//
for
(
CartGoods
.
ComboxGoods
choice
:
cartGoods
.
getProductGroupList
())
{
for
(
CartGoods
.
ComboxGoods
choice
:
cartGoods
.
getProductGroupList
())
{
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
mt
=
choices
.
get
(
choice
.
getGoodsId
());
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
mt
=
choices
.
get
(
choice
.
getGoodsId
());
if
(
mt
==
null
)
{
if
(
mt
==
null
)
{
amount
=
choice
.
getAmount
()
*
cartGoods
.
getQty
();
amount
+=
choice
.
getAmount
()
*
cartGoods
.
getQty
();
original
+=
choice
.
getOriginalPrice
()
*
cartGoods
.
getQty
();
}
else
{
}
else
{
amount
+=
mt
.
getRealAmount
();
amount
+=
mt
.
getRealAmount
();
original
+=
mt
.
getOriginalPrice
();
choice
.
setAmount
(
mt
.
getRealAmount
().
longValue
());
choice
.
setAmount
(
mt
.
getRealAmount
().
longValue
());
choice
.
setOriginalAmount
(
original
);
}
}
}
}
cartGoods
.
setAmount
(
cartGoods
.
getAmount
()
+
amount
);
cartGoods
.
setAmount
(
cartGoods
.
getAmount
()
+
amount
);
cartGoods
.
setOriginalAmount
(
cartGoods
.
getOriginalMaterialAmount
()
+
original
);
}
}
/**
/**
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/CouponSharingService.java
View file @
25d58def
...
@@ -48,8 +48,14 @@ public class CouponSharingService {
...
@@ -48,8 +48,14 @@ public class CouponSharingService {
// 是否存在商品券
// 是否存在商品券
boolean
hasGoodssCoupon
=
CollectionUtils
.
isNotEmpty
(
tmpCartGoods
);
boolean
hasGoodssCoupon
=
CollectionUtils
.
isNotEmpty
(
tmpCartGoods
);
// 构建可用不可用优惠券
// 构建可用不可用优惠券
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoodsList
,
couponPromotionVO
.
getPartnerId
()
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoodsList
,
couponPromotionVO
.
getUserId
(),
couponPromotionVO
.
getStoreId
(),
couponPromotionVO
.
getCouponCode
(),
hasGoodssCoupon
,
couponPromotionVO
.
getOrderType
());
,
couponPromotionVO
.
getPartnerId
()
,
couponPromotionVO
.
getUserId
()
,
couponPromotionVO
.
getStoreId
()
,
couponPromotionVO
.
getCouponCode
()
,
hasGoodssCoupon
,
couponPromotionVO
.
getOrderType
()
,
1
);
if
(
Objects
.
equals
(
activityClassifyCouponBean
,
null
))
{
if
(
Objects
.
equals
(
activityClassifyCouponBean
,
null
))
{
// 构建一个空得订单券信息
// 构建一个空得订单券信息
activityClassifyCouponBean
=
createEmptyActivityCouponBean
();
activityClassifyCouponBean
=
createEmptyActivityCouponBean
();
...
...
shopping-cart-application-service/src/test/java/cn.freemud/service/CouponServiceTest.java
View file @
25d58def
...
@@ -133,7 +133,7 @@ public class CouponServiceTest {
...
@@ -133,7 +133,7 @@ public class CouponServiceTest {
List
<
CartGoods
>
cartGoods
=
Lists
.
newArrayList
();
List
<
CartGoods
>
cartGoods
=
Lists
.
newArrayList
();
CartGoods
cartGood
=
new
CartGoods
();
CartGoods
cartGood
=
new
CartGoods
();
cartGoods
.
add
(
cartGood
);
cartGoods
.
add
(
cartGood
);
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoods
,
"1864"
,
"122424124"
,
"1011"
,
"88123124"
,
true
,
1
);
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoods
,
"1864"
,
"122424124"
,
"1011"
,
"88123124"
,
true
,
1
,
1
);
assertTrue
(
activityClassifyCouponBean
.
getCouponNum
()
>=
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