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
6342f2ce
Commit
6342f2ce
authored
Nov 30, 2020
by
刘鹏飞
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
买一赠一寄件活动只加券
parent
7409b784
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
112 deletions
+2
-112
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/BuyOneGiveOneSendService.java
+2
-112
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/BuyOneGiveOneSendService.java
View file @
6342f2ce
...
...
@@ -74,126 +74,16 @@ public class BuyOneGiveOneSendService {
if
(
discountResult
==
null
||
CollectionUtils
.
isEmpty
(
discountResult
.
getGoods
()))
{
return
;
}
String
menuType
=
shoppingCartInfoRequestVo
==
null
?
null
:
shoppingCartInfoRequestVo
.
getMenuType
();
/*
String menuType = shoppingCartInfoRequestVo == null ? null : shoppingCartInfoRequestVo.getMenuType();
// 构建赠品detail
List<ProductBeanDTO> beanDTOList = this.drawGiftInfo(discountResult, activityQueryDto, menuType);
this
.
setCartGoods
(
discountResult
,
cartGoodsList
,
beanDTOList
);
this.setCartGoods(discountResult, cartGoodsList, beanDTOList);
*/
// 设置用户可以选择的寄送商品券码
this
.
buildSendGoods
(
discountResult
,
shoppingCartGoodsResponseVo
,
shoppingCartInfoRequestVo
);
}
/**
* 抽取赠品
* goodsId->goods
*
* @param discountResult
* @return
*/
private
List
<
String
>
getProductIdsForGift
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
)
{
List
<
String
>
gifts
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isEmpty
(
discountResult
.
getGoods
()))
{
return
gifts
;
}
gifts
=
discountResult
.
getGoods
()
.
stream
()
.
filter
(
d
->
CalculationGoodsType
.
TYPE_1
.
getType
().
equals
(
d
.
getCartGoodType
()))
.
map
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getGoodsId
)
.
collect
(
Collectors
.
toList
());
return
gifts
;
}
/**
* 转换参加促销的商品为Map<goodsId,Goods>
*
* @param discountResult
* @return
*/
public
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
getDiscountForGift
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
)
{
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
gifts
=
discountResult
.
getGoods
()
.
stream
()
.
filter
(
d
->
CalculationGoodsType
.
TYPE_1
.
getType
().
equals
(
d
.
getCartGoodType
()))
.
collect
(
Collectors
.
toMap
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
::
getGoodsId
,
Function
.
identity
(),
(
k1
,
k2
)
->
k1
));
return
gifts
;
}
/**
* 赠品detail
*
* @param discountResult
* @param activityQueryDto
* @param menuType
*/
private
List
<
ProductBeanDTO
>
drawGiftInfo
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
ActivityQueryDto
activityQueryDto
,
String
menuType
)
{
List
<
ProductBeanDTO
>
productBeanList
=
new
ArrayList
<>();
// 抽取赠品
List
<
String
>
gifts
=
this
.
getProductIdsForGift
(
discountResult
);
if
(
CollectionUtils
.
isEmpty
(
gifts
))
return
productBeanList
;
productBeanList
=
assortmentSdkService
.
getProductsInfoSdk
(
activityQueryDto
.
getPartnerId
()
,
activityQueryDto
.
getStoreId
(),
gifts
,
menuType
,
shoppingCartBaseService
);
if
(
CollectionUtils
.
isEmpty
(
productBeanList
))
{
throw
new
ServiceException
(
ResponseResult
.
SHOPPING_CART_GIFTS_PRODUCT_NOT_EXIST
);
}
return
productBeanList
;
}
/**
* 响应购物车行
*/
public
void
setCartGoods
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
List
<
CartGoods
>
cartGoodsLists
,
List
<
ProductBeanDTO
>
products
)
{
if
(
CollectionUtils
.
isEmpty
(
products
))
return
;
// 转换参加促销的商品为Map<goodsId,Goods>
Map
<
String
,
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
discountForGift
=
this
.
getDiscountForGift
(
discountResult
);
List
<
CartGoods
>
cartGoodsList
=
new
ArrayList
<>();
for
(
ProductBeanDTO
product
:
products
)
{
String
k
=
product
.
getPid
();
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
=
discountForGift
.
get
(
k
);
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
discount
=
goods
.
getDiscounts
()
.
stream
()
.
filter
(
g
->
ActivityTypeEnum
.
TYPE_63
.
getCode
().
equals
(
g
.
getType
()))
.
findFirst
()
.
get
();
CartGoods
cartGood
=
new
CartGoods
();
cartGood
.
setGoodsId
(
goods
.
getGoodsId
());
cartGood
.
setGoodsType
(
1
);
cartGood
.
setSpuId
(
goods
.
getGoodsId
());
cartGood
.
setSkuId
(
goods
.
getGoodsId
());
cartGood
.
setOriginalPrice
(
product
.
getFinalPrice
());
cartGood
.
setPackPrice
(
product
.
getPackPrice
());
cartGood
.
setOriginalAmount
(
goods
.
getOriginalPrice
()
*
goods
.
getGoodsQuantity
());
cartGood
.
setAmount
(
goods
.
getRealAmount
());
cartGood
.
setName
(
product
.
getName
());
cartGood
.
setSpuName
(
product
.
getName
());
cartGood
.
setCategoryName
(
product
.
getName
());
cartGood
.
setPic
(
product
.
getPicture
());
cartGood
.
setSkuName
(
product
.
getName
());
cartGood
.
setActivityType
(
discount
.
getType
());
cartGood
.
setStockLimit
(
ObjectUtils
.
equals
(
1
,
product
.
getStockLimit
()));
cartGood
.
setCustomerCode
(
product
.
getCustomerCode
());
cartGood
.
setUnit
(
product
.
getUnit
());
cartGood
.
setWeight
(
product
.
getWeight
());
cartGood
.
setQty
(
goods
.
getGoodsQuantity
());
cartGood
.
setClassificationId
(
product
.
getCategory
());
cartGood
.
setClassificationName
(
product
.
getCategoryName
());
// nodeId标识activeCode,用于计算均摊时每个商品在每个活动上均摊金额
cartGood
.
setNodeId
(
discount
.
getActivityCode
());
cartGoodsList
.
add
(
cartGood
);
}
cartGoodsLists
.
addAll
(
cartGoodsList
);
}
/**
* 构建用户可以商品券信息
*
* @param discountResult
...
...
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