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
630cd1b4
Commit
630cd1b4
authored
Sep 27, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'remotes/origin/feature/促销算价基于最新master的分支' into qa
parents
0d04bddf
25d58def
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
56 additions
and
17 deletions
+56
-17
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
+37
-6
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 @
630cd1b4
...
...
@@ -71,7 +71,7 @@ public interface CouponService {
* @param cartGoods
* @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 @
630cd1b4
...
...
@@ -373,8 +373,14 @@ public class CouponServiceImpl implements CouponService {
}
@Override
public
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
)
{
public
ActivityClassifyCouponBean
availableCoupon
(
List
<
CartGoods
>
cartGoods
,
String
partnerId
,
String
userId
,
String
storeId
,
String
couponCode
,
boolean
hasGoodsCoupon
,
Integer
orderType
,
int
isNew
)
{
GetMemberCouponListRequestDto
getMemberCouponListRequestDto
=
new
GetMemberCouponListRequestDto
(
partnerId
,
userId
);
getMemberCouponListRequestDto
.
setStatusFlags
(
Arrays
.
asList
(
CouponStatus
.
STATUS_0
.
getCode
()));
getMemberCouponListRequestDto
.
setPageNum
(
1
);
...
...
@@ -413,14 +419,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
))
{
return
returnSuccessAvailiableCoupons
(
couponCode
,
hasGoodsCoupon
,
availableCouponResponseVo
,
usableCoupons
,
disableCoupons
,
memberCouponMap
,
couponStateList
);
}
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
);
// 最大15一提交
int
maxNum
=
15
;
...
...
@@ -433,7 +439,7 @@ public class CouponServiceImpl implements CouponService {
List
<
Product
>
productList
=
Lists
.
newArrayList
();
// 优惠券优先级最高,根据商品原价做计算
// 订单金额
Long
totalAmount
=
createProductRequest
(
cartGoods
,
productList
);
Long
totalAmount
=
createProductRequest
(
cartGoods
,
productList
,
isNew
);
couponAvailableReqVo
.
setTotalAmount
(
Integer
.
valueOf
(
totalAmount
+
""
));
couponAvailableReqVo
.
setProductList
(
productList
);
couponAvailableReqVo
.
setChannelCodeList
(
commonService
.
getOrgCodes
(
partnerId
,
storeId
));
...
...
@@ -543,8 +549,32 @@ public class CouponServiceImpl implements CouponService {
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
;
if
(
isNew
==
1
)
{
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
(
cartGood
.
getAmount
().
intValue
());
totalAmount
=
totalAmount
+
cartGood
.
getAmount
();
// todo :小料价格累加到主商品上
if
(
CollectionUtils
.
isNotEmpty
(
cartGood
.
getProductMaterialList
()))
{
for
(
CartGoods
.
MaterialGoods
materialGoods
:
cartGood
.
getProductMaterialList
())
{
product
.
setAmount
(
product
.
getAmount
()
+
materialGoods
.
getAmount
().
intValue
());
totalAmount
=
totalAmount
+
materialGoods
.
getAmount
();
}
}
// 数量
product
.
setQuantity
(
cartGood
.
getQty
());
productList
.
add
(
product
);
}
}
else
{
for
(
CartGoods
cartGood
:
cartGoods
)
{
// 剔除商品券得商品
if
(
StringUtils
.
isEmpty
(
cartGood
.
getSkuId
())
&&
StringUtils
.
isEmpty
(
cartGood
.
getSpuId
()))
{
...
...
@@ -575,6 +605,7 @@ public class CouponServiceImpl implements CouponService {
product
.
setQuantity
(
cartGood
.
getQty
());
productList
.
add
(
product
);
}
}
return
totalAmount
;
}
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationCommonService.java
View file @
630cd1b4
...
...
@@ -64,23 +64,18 @@ public class CalculationCommonService {
originalAmount
=
0L
;
amount
=
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
);
//成交价行记录
//amount += find.getRealAmount() * cartGoods.getQty();
amount
=
cartGoods
.
getAmount
();
//cartGoods.setAmount(amount);
totalAmount
+=
amount
;
//原价行记录
originalAmount
=
cartGoods
.
getOriginalPrice
()
*
cartGoods
.
getQty
()
;
originalAmount
=
cartGoods
.
getOriginalPrice
();
cartGoods
.
setOriginalAmount
(
originalAmount
);
totalOriginalAmount
+=
originalAmount
;
//包装费行记录
packageAmount
=
cartGoods
.
getPackPrice
()
*
cartGoods
.
getQty
();
cartGoods
.
setPackPrice
(
packageAmount
);
totalPackageAmount
+=
packageAmount
;
}
shoppingCartGoodsResponseVo
.
setOriginalTotalAmount
(
discountResult
==
null
?
totalOriginalAmount
:
discountResult
.
getOriginalTotalAmount
());
shoppingCartGoodsResponseVo
.
setTotalAmount
(
discountResult
==
null
?
totalAmount
:
discountResult
.
getTotalAmount
());
...
...
@@ -97,22 +92,29 @@ public class CalculationCommonService {
if
(
find
==
null
)
return
;
cartGoods
.
setAmount
(
find
.
getRealAmount
());
cartGoods
.
setOriginalAmount
(
find
.
getOriginalPrice
());
Integer
type
=
2
;
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductGroupList
()))
return
;
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
>
choices
=
find
.
getSmallMaterial
()
.
stream
().
filter
(
d
->
type
.
equals
(
d
.
getType
()))
.
collect
(
Collectors
.
toMap
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
::
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
long
amount
=
0L
;
long
original
=
0L
;
//
for
(
CartGoods
.
ComboxGoods
choice
:
cartGoods
.
getProductGroupList
())
{
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
SmallMaterial
mt
=
choices
.
get
(
choice
.
getGoodsId
());
if
(
mt
==
null
)
{
amount
=
choice
.
getAmount
()
*
cartGoods
.
getQty
();
amount
+=
choice
.
getAmount
()
*
cartGoods
.
getQty
();
original
+=
choice
.
getOriginalPrice
()
*
cartGoods
.
getQty
();
}
else
{
amount
+=
mt
.
getRealAmount
();
original
+=
mt
.
getOriginalPrice
();
choice
.
setAmount
(
mt
.
getRealAmount
().
longValue
());
choice
.
setOriginalAmount
(
original
);
}
}
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 @
630cd1b4
...
...
@@ -48,8 +48,14 @@ public class CouponSharingService {
// 是否存在商品券
boolean
hasGoodssCoupon
=
CollectionUtils
.
isNotEmpty
(
tmpCartGoods
);
// 构建可用不可用优惠券
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoodsList
,
couponPromotionVO
.
getPartnerId
()
,
couponPromotionVO
.
getUserId
(),
couponPromotionVO
.
getStoreId
(),
couponPromotionVO
.
getCouponCode
(),
hasGoodssCoupon
,
couponPromotionVO
.
getOrderType
());
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoodsList
,
couponPromotionVO
.
getPartnerId
()
,
couponPromotionVO
.
getUserId
()
,
couponPromotionVO
.
getStoreId
()
,
couponPromotionVO
.
getCouponCode
()
,
hasGoodssCoupon
,
couponPromotionVO
.
getOrderType
()
,
1
);
if
(
Objects
.
equals
(
activityClassifyCouponBean
,
null
))
{
// 构建一个空得订单券信息
activityClassifyCouponBean
=
createEmptyActivityCouponBean
();
...
...
shopping-cart-application-service/src/test/java/cn.freemud/service/CouponServiceTest.java
View file @
630cd1b4
...
...
@@ -133,7 +133,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
);
ActivityClassifyCouponBean
activityClassifyCouponBean
=
couponService
.
availableCoupon
(
cartGoods
,
"1864"
,
"122424124"
,
"1011"
,
"88123124"
,
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