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
a4888c28
Commit
a4888c28
authored
Aug 08, 2020
by
xiaoer.li@freemud.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
去掉均摊
parent
6069a4fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
19 deletions
+36
-19
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/MaterialPromotionService.java
+36
-19
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/MaterialPromotionService.java
View file @
a4888c28
...
...
@@ -43,18 +43,25 @@ public class MaterialPromotionService implements IPromotionService {
*/
@Override
public
void
updateShoppingCartGoodsDiscount
(
CouponPromotionVO
couponPromotionVO
,
ActivityQueryDto
activityQueryDto
,
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
,
List
<
CartGoods
>
cartGoodsList
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
UserLoginInfoDto
userLoginInfoDto
,
ShoppingCartInfoRequestVo
shoppingCartInfoRequestVo
)
{
HashMap
<
String
,
MaterialApportion
>
map
=
getApportionGoodsDetail
(
calculationDiscountResult
);
if
(
map
.
size
()
>
0
)
{
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
if
(
CollectionUtils
.
isEmpty
(
cartGoods
.
getProductMaterialList
()))
continue
;
for
(
CartGoods
.
MaterialGoods
materialGoods
:
cartGoods
.
getProductMaterialList
())
{
MaterialApportion
apportion
=
map
.
get
(
materialGoods
.
getSpuId
());
//设置小料行单价和行总价
materialGoods
.
setFinalPrice
(
apportion
.
getSalePrice
());
materialGoods
.
setAmount
(
apportion
.
getAmount
());
}
}
}
/**
HashMap<String, MaterialApportion> map = getApportionGoodsDetail(calculationDiscountResult);
if (map.size() > 0) {
String pk = "";
for (CartGoods cartGoods : cartGoodsList) {
if (CollectionUtils.isEmpty(cartGoods.getProductMaterialList())) continue;
for (CartGoods.MaterialGoods materialGoods : cartGoods.getProductMaterialList()) {
pk = this.jointPk(cartGoods.getCartGoodsUid(),materialGoods.getSpuId());
MaterialApportion apportion = map.get(pk);
//设置小料行单价和行总价
if (apportion!=null && apportion.getApportionAmount().intValue()>0) {
materialGoods.setFinalPrice(apportion.getSalePrice());
materialGoods.setAmount(apportion.getAmount());
}
}
}
}
*/
long
materialAmount
=
0L
,
materialOriginal
=
0L
;
for
(
CartGoods
cartGoods
:
cartGoodsList
)
{
...
...
@@ -85,11 +92,13 @@ public class MaterialPromotionService implements IPromotionService {
HashMap
<
String
,
MaterialApportion
>
map
=
getApportionGoodsDetail
(
calculationDiscountResult
);
List
<
ShoppingCartGoodsDto
.
CartGoodsDetailDto
>
products
=
shoppingCartGoodsDto
.
getProducts
();
if
(
map
.
size
()
>
0
)
{
String
pk
=
""
;
for
(
ShoppingCartGoodsDto
.
CartGoodsDetailDto
product
:
products
)
{
if
(
CollectionUtils
.
isEmpty
(
product
.
getMaterialList
()))
continue
;
for
(
ShoppingCartGoodsDto
.
CartGoodsDetailDto
.
MaterialGoods
materialGoods
:
product
.
getMaterialList
())
{
MaterialApportion
material
=
map
.
get
(
materialGoods
.
getSpuId
());
if
(
material
.
getApportionAmount
().
intValue
()
==
0
)
continue
;
pk
=
this
.
jointPk
(
product
.
getCartGoodsUid
(),
materialGoods
.
getSpuId
());
MaterialApportion
material
=
map
.
get
(
pk
);
if
(
material
!=
null
&&
material
.
getApportionAmount
().
intValue
()
==
0
)
continue
;
//设置行记录参加的活动及总优惠
ActivityDiscountsDto
activityDiscountsDto
=
new
ActivityDiscountsDto
();
List
<
ActivityDiscountsDto
>
activityDiscountsDtoList
=
new
ArrayList
<>();
...
...
@@ -129,16 +138,20 @@ public class MaterialPromotionService implements IPromotionService {
if
(
calculationDiscountResult
==
null
||
CollectionUtils
.
isEmpty
(
calculationDiscountResult
.
getApportionGoods
()))
{
return
mApportion
;
}
String
pk
=
""
;
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ApportionGoods
apportionGood
:
calculationDiscountResult
.
getApportionGoods
())
{
if
(
CollectionUtils
.
isEmpty
(
apportionGood
.
getSmallMaterial
()))
continue
;
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ApportionGoods
.
Material
material
:
apportionGood
.
getSmallMaterial
())
{
if
(
material
.
getApportionAmount
()
==
0
)
continue
;
if
(
mApportion
.
get
(
material
.
getGoodsId
())
==
null
)
{
pk
=
this
.
jointPk
(
material
.
getCartGoodsUid
(),
material
.
getGoodsId
());
if
(
mApportion
.
get
(
pk
)
==
null
)
{
MaterialApportion
materialApportion
=
new
MaterialApportion
();
materialApportion
.
setSalePrice
(
material
.
getNowPrice
());
materialApportion
.
setAmount
(
material
.
getNowPrice
()
*
material
.
getGoodsQuantity
());
materialApportion
.
setApportionAmount
(
material
.
getApportionAmount
()
*
material
.
getGoodsQuantity
());
materialApportion
.
setGoodsId
(
material
.
getGoodsId
());
materialApportion
.
setPk
(
pk
);
ApportionDetails
apportionDetails
=
new
ApportionDetails
();
if
(
CollectionUtils
.
isNotEmpty
(
material
.
getApportionDetails
()))
{
apportionDetails
.
setActivityCode
(
material
.
getApportionDetails
().
get
(
0
).
getActivityCode
());
...
...
@@ -146,28 +159,32 @@ public class MaterialPromotionService implements IPromotionService {
apportionDetails
.
setActivityType
(
material
.
getApportionDetails
().
get
(
0
).
getActivityType
());
materialApportion
.
setDetails
(
apportionDetails
);
}
mApportion
.
put
(
material
.
getGoodsId
()
,
materialApportion
);
mApportion
.
put
(
pk
,
materialApportion
);
continue
;
}
MaterialApportion
apportion
=
mApportion
.
get
(
material
.
getGoodsId
());
apportion
.
setSalePrice
(
apportion
.
getSalePrice
()
+
material
.
getNowPrice
());
apportion
.
setAmount
(
apportion
.
getAmount
()
+
material
.
getNowPrice
()
*
material
.
getGoodsQuantity
());
apportion
.
setApportionAmount
(
apportion
.
getApportionAmount
()
+
material
.
getApportionAmount
()
*
material
.
getGoodsQuantity
());
mApportion
.
put
(
material
.
getGoodsId
(),
apportion
);
mApportion
.
put
(
pk
,
apportion
);
}
}
return
mApportion
;
}
private
String
jointPk
(
String
a
,
String
b
)
{
StringBuffer
stringBuffer
=
new
StringBuffer
();
return
stringBuffer
.
append
(
a
).
append
(
b
).
toString
();
}
@Data
private
class
MaterialApportion
{
// 累计
private
String
goodsId
;
private
Long
salePrice
;
private
Long
amount
;
private
Integer
apportionAmount
;
private
ApportionDetails
details
;
private
String
pk
;
}
@Data
...
...
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