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
5801b83d
Commit
5801b83d
authored
Oct 10, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接促销算价Alpha->fix
parent
b534264f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
11 deletions
+47
-11
shopping-cart-application-service/src/main/java/cn/freemud/enums/CalculationGoodsType.java
+31
-0
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/AdditionSharingService.java
+16
-11
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/enums/CalculationGoodsType.java
0 → 100644
View file @
5801b83d
package
cn
.
freemud
.
enums
;
public
enum
CalculationGoodsType
{
TYPE_0
(
0
,
"原来的购物车商品"
),
TYPE_1
(
1
,
"赠品"
),
TYPE_2
(
2
,
"加购商品"
);
Integer
type
;
String
desc
;
CalculationGoodsType
(
Integer
type
,
String
desc
)
{
this
.
type
=
type
;
this
.
desc
=
desc
;
}
public
Integer
getType
()
{
return
type
;
}
public
void
setType
(
Integer
type
)
{
this
.
type
=
type
;
}
public
String
getDesc
()
{
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
}
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/AdditionSharingService.java
View file @
5801b83d
...
...
@@ -6,6 +6,7 @@ import cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.ActivityTypeEnum
;
import
cn.freemud.enums.CalculationGoodsType
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.ItemService
;
...
...
@@ -232,14 +233,17 @@ public class AdditionSharingService {
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
CreateOrderVo
.
PremiumExchangeActivity
premiumExchangeActivity
)
{
if
(
premiumExchangeActivity
==
null
||
CollectionUtils
.
isEmpty
(
premiumExchangeActivity
.
getProducts
()))
{
if
(
discountResult
==
null
||
CollectionUtils
.
isEmpty
(
discountResult
.
getGoods
())
||
premiumExchangeActivity
==
null
||
CollectionUtils
.
isEmpty
(
premiumExchangeActivity
.
getProducts
()))
{
return
;
}
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
hgGood
=
discountResult
.
getGoods
()
.
stream
()
.
filter
(
d
->
CalculationGoodsType
.
TYPE_2
.
getType
().
equals
(
d
.
getCartGoodType
()))
.
findFirst
()
.
orElse
(
null
);
//检查是否有加价购商品
ResponseResult
checkResult
=
checkAdditionalGoods
(
premiumExchangeActivity
.
getProducts
(),
discountResult
.
getSendGoods
());
if
(!
ObjectUtils
.
equals
(
ResponseResult
.
SUCCESS
,
checkResult
))
{
throw
new
ServiceException
(
checkResult
);
if
(
hgGood
==
null
)
{
throw
new
ServiceException
(
ResponseResult
.
PREMIUM_EXCHANGE_ACTIVITY_NOT_EXIST
);
}
//检查是否有加价购商品
...
...
@@ -256,7 +260,9 @@ public class AdditionSharingService {
//添加商品行
List
<
String
>
productIds
=
premiumExchangeActivity
.
getProducts
().
stream
().
map
(
p
->
StringUtils
.
isEmpty
(
p
.
getSkuId
())
?
p
.
getSpuId
()
:
p
.
getSkuId
()).
collect
(
Collectors
.
toList
());
Map
<
String
,
GetProductsVo
>
getProductsVoMap
=
itemService
.
getProducts
(
productIds
,
shoppingCartInfoRequestVo
.
getPartnerId
(),
shoppingCartInfoRequestVo
.
getShopId
(),
BusinessTypeEnum
.
getByType
(
shoppingCartInfoRequestVo
.
getMenuType
()).
getCode
());
if
(
getProductsVoMap
.
isEmpty
())
{
throw
new
ServiceException
(
ResponseResult
.
PREMIUM_EXCHANGE_ACTIVITY_NOT_EXIST
);
}
// 获取计算返回的价格
Long
originalTotalAmount
=
shoppingCartGoodsDto
.
getOriginalTotalAmount
();
Long
totalAmount
=
shoppingCartGoodsDto
.
getTotalAmount
();
...
...
@@ -271,7 +277,7 @@ public class AdditionSharingService {
continue
;
}
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
send
=
sendGoodsMap
.
get
(
goodsId
);
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
this
.
getCartGoodsDetailDto
(
product
,
getProductsVo
,
goodsId
,
sen
d
);
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
this
.
getCartGoodsDetailDto
(
product
,
getProductsVo
,
goodsId
,
hgGoo
d
);
shoppingCartGoodsDto
.
getProducts
().
add
(
cartGoodsDetailDto
);
//2.计算优惠价格
originalTotalAmount
+=
getProductsVo
.
getFinalPrice
();
...
...
@@ -293,12 +299,11 @@ public class AdditionSharingService {
public
ShoppingCartGoodsDto
.
CartGoodsDetailDto
getCartGoodsDetailDto
(
CreateOrderVo
.
PremiumExchangeActivity
.
Product
product
,
GetProductsVo
getProductsVo
,
String
goodsId
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
.
SendGoods
sendGoods
)
{
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
hgGood
)
{
ShoppingCartGoodsDto
.
CartGoodsDetailDto
cartGoodsDetailDto
=
new
ShoppingCartGoodsDto
.
CartGoodsDetailDto
();
cartGoodsDetailDto
.
setOriginalPrice
(
getProductsVo
.
getFinalPrice
());
int
totalDiscountAmount
=
product
.
getQty
()
*
(
getProductsVo
.
getFinalPrice
().
intValue
()
-
sendGoods
.
getNowPrice
().
intValue
());
cartGoodsDetailDto
.
setTotalDiscountAmount
(
totalDiscountAmount
);
cartGoodsDetailDto
.
setOriginalPrice
(
hgGood
.
getOriginalPrice
());
cartGoodsDetailDto
.
setTotalDiscountAmount
(
hgGood
.
getDiscountAmount
().
intValue
());
cartGoodsDetailDto
.
setSpuId
(
product
.
getSpuId
());
cartGoodsDetailDto
.
setSkuId
(
goodsId
);
cartGoodsDetailDto
.
setQty
(
product
.
getQty
());
...
...
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