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
215da402
Commit
215da402
authored
Mar 12, 2021
by
chongfu.liang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
23842a35
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
31 deletions
+34
-31
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
+10
-8
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationSharingDiscountService.java
+10
-7
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/GiftSharingService.java
+14
-16
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/ShoppingCartNewServiceImpl.java
View file @
215da402
...
@@ -79,6 +79,7 @@ import com.google.common.collect.Lists;
...
@@ -79,6 +79,7 @@ import com.google.common.collect.Lists;
import
javafx.util.Pair
;
import
javafx.util.Pair
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.ObjectUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -1254,17 +1255,18 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
...
@@ -1254,17 +1255,18 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
discountDTO
=
result
.
getDiscounts
().
stream
().
filter
(
d
->
221
==
d
.
getType
()).
findFirst
().
get
();
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Discount
discountDTO
=
result
.
getDiscounts
().
stream
().
filter
(
d
->
221
==
d
.
getType
()).
findFirst
().
get
();
convert2SendPoint
(
result
,
discountDTO
);
convert2SendPoint
(
result
,
discountDTO
);
}
}
Pair
<
String
,
Integer
>
pair
=
giftSharingService
.
xPiecesYFoldAdapter
(
activityCalculationDiscountResponseDto
);
Map
<
String
,
Integer
>
qtyMap
=
giftSharingService
.
xPiecesYFoldAdapter
(
activityCalculationDiscountResponseDto
);
if
(
pair
!=
null
){
if
(
MapUtils
.
isNotEmpty
(
qtyMap
)){
CartGoods
cartGoods
=
cartGoodsList
.
stream
().
filter
(
p
->
p
.
getCartGoodsUid
().
equals
(
pair
.
getKey
())).
findFirst
().
orElseGet
(
null
);
for
(
String
key
:
qtyMap
.
keySet
()){
if
(
cartGoods
!=
null
){
CartGoods
cartGoods
=
cartGoodsList
.
stream
().
filter
(
p
->
p
.
getCartGoodsUid
().
equals
(
key
)).
findFirst
().
orElseGet
(
null
);
cartGoods
.
setActivityType
(
ActivityTypeEnum
.
TYPE_104
.
getCode
());
if
(
cartGoods
!=
null
){
cartGoods
.
setActualQty
(
cartGoods
.
getQty
());
cartGoods
.
setActivityType
(
ActivityTypeEnum
.
TYPE_104
.
getCode
());
cartGoods
.
setQty
(
pair
.
getValue
());
cartGoods
.
setActualQty
(
cartGoods
.
getQty
());
cartGoods
.
setQty
(
qtyMap
.
get
(
key
));
}
}
}
}
}
result
.
setValidCouponMap
(
validCouponMap
);
result
.
setValidCouponMap
(
validCouponMap
);
result
.
setDeliveryAmount
(
distributionFee
);
result
.
setDeliveryAmount
(
distributionFee
);
result
.
setDistributionFee
(
result
.
getDistributionFee
());
result
.
setDistributionFee
(
result
.
getDistributionFee
());
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/CalculationSharingDiscountService.java
View file @
215da402
...
@@ -28,6 +28,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBase
...
@@ -28,6 +28,7 @@ import com.freemud.sdk.api.assortment.shoppingcart.service.impl.ShoppingCartBase
import
javafx.util.Pair
;
import
javafx.util.Pair
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.MapUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -207,13 +208,15 @@ public class CalculationSharingDiscountService {
...
@@ -207,13 +208,15 @@ public class CalculationSharingDiscountService {
convert2SendPoint
(
result
,
discountDTO
);
convert2SendPoint
(
result
,
discountDTO
);
}
}
// 将x件y折的0折数据转为赠品
// 将x件y折的0折数据转为赠品
Pair
<
String
,
Integer
>
pair
=
giftSharingService
.
xPiecesYFoldAdapter
(
sharingDiscountResponseDto
);
Map
<
String
,
Integer
>
qtyMap
=
giftSharingService
.
xPiecesYFoldAdapter
(
sharingDiscountResponseDto
);
if
(
pair
!=
null
){
if
(
MapUtils
.
isNotEmpty
(
qtyMap
)){
CartGoods
cartGoods
=
cartGoodsList
.
stream
().
filter
(
p
->
p
.
getCartGoodsUid
().
equals
(
pair
.
getKey
())).
findFirst
().
orElseGet
(
null
);
for
(
String
key
:
qtyMap
.
keySet
()){
if
(
cartGoods
!=
null
){
CartGoods
cartGoods
=
cartGoodsList
.
stream
().
filter
(
p
->
p
.
getCartGoodsUid
().
equals
(
key
)).
findFirst
().
orElseGet
(
null
);
cartGoods
.
setActivityType
(
ActivityTypeEnum
.
TYPE_104
.
getCode
());
if
(
cartGoods
!=
null
){
cartGoods
.
setActualQty
(
cartGoods
.
getQty
());
cartGoods
.
setActivityType
(
ActivityTypeEnum
.
TYPE_104
.
getCode
());
cartGoods
.
setQty
(
pair
.
getValue
());
cartGoods
.
setActualQty
(
cartGoods
.
getQty
());
cartGoods
.
setQty
(
qtyMap
.
get
(
key
));
}
}
}
}
}
result
.
setValidCouponMap
(
validCouponMap
);
result
.
setValidCouponMap
(
validCouponMap
);
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/GiftSharingService.java
View file @
215da402
...
@@ -22,10 +22,7 @@ import org.apache.commons.lang.ObjectUtils;
...
@@ -22,10 +22,7 @@ import org.apache.commons.lang.ObjectUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.UUID
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -65,7 +62,7 @@ public class GiftSharingService {
...
@@ -65,7 +62,7 @@ public class GiftSharingService {
this
.
setCartGoods
(
discountResult
,
cartGoodsList
,
beanDTOList
,
shoppingCartInfoRequestVo
,
partnerId
,
flag
);
this
.
setCartGoods
(
discountResult
,
cartGoodsList
,
beanDTOList
,
shoppingCartInfoRequestVo
,
partnerId
,
flag
);
}
}
public
Pair
<
String
,
Integer
>
xPiecesYFoldAdapter
(
ActivityCalculationDiscountResponseDto
activityCalculationDiscountResponseDto
)
{
public
Map
<
String
,
Integer
>
xPiecesYFoldAdapter
(
ActivityCalculationDiscountResponseDto
activityCalculationDiscountResponseDto
)
{
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
result
=
activityCalculationDiscountResponseDto
.
getResult
();
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
result
=
activityCalculationDiscountResponseDto
.
getResult
();
if
(
result
==
null
){
if
(
result
==
null
){
...
@@ -85,8 +82,8 @@ public class GiftSharingService {
...
@@ -85,8 +82,8 @@ public class GiftSharingService {
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
discountGoodsList
=
result
.
getGoods
().
stream
().
filter
(
p
->
CollectionUtils
.
isNotEmpty
(
p
.
getDiscounts
())
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
discountGoodsList
=
result
.
getGoods
().
stream
().
filter
(
p
->
CollectionUtils
.
isNotEmpty
(
p
.
getDiscounts
())
&&
p
.
getDiscounts
().
stream
().
filter
(
discount
->
activityCode
.
contains
(
discount
.
getActivityCode
())).
count
()
>
0
).
collect
(
Collectors
.
toList
());
&&
p
.
getDiscounts
().
stream
().
filter
(
discount
->
activityCode
.
contains
(
discount
.
getActivityCode
())).
count
()
>
0
).
collect
(
Collectors
.
toList
());
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
goodsList
=
result
.
getSendGoods
();
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
SendActivity
>
goodsList
=
result
.
getSendGoods
()
==
null
?
new
ArrayList
<>()
:
result
.
getSendGoods
()
;
Map
<
String
,
Integer
>
qtyMap
=
new
HashMap
<>();
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
:
discountGoodsList
){
for
(
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
:
discountGoodsList
){
int
sendQty
=
0
;
int
sendQty
=
0
;
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
discountList
=
goods
.
getDiscounts
()
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
discountList
=
goods
.
getDiscounts
()
...
@@ -106,15 +103,15 @@ public class GiftSharingService {
...
@@ -106,15 +103,15 @@ public class GiftSharingService {
sendGoods
.
setActivityType
(
ActivityTypeEnum
.
TYPE_1040
.
getCode
());
sendGoods
.
setActivityType
(
ActivityTypeEnum
.
TYPE_1040
.
getCode
());
goodsList
.
add
(
sendGoods
);
goodsList
.
add
(
sendGoods
);
}
}
Pair
<
String
,
Integer
>
pair
=
new
Pair
<>(
goods
.
getCartGoodsUid
(),
goods
.
getGoodsQuantity
()
-
sendQty
);
qtyMap
.
put
(
goods
.
getCartGoodsUid
(),
goods
.
getGoodsQuantity
()
-
sendQty
);
return
pair
;
}
}
return
null
;
result
.
setSendGoods
(
goodsList
);
return
qtyMap
;
}
}
public
Pair
<
String
,
Integer
>
xPiecesYFoldAdapter
(
CalculationSharingDiscountResponseDto
sharingDiscountResponseDto
)
{
public
Map
<
String
,
Integer
>
xPiecesYFoldAdapter
(
CalculationSharingDiscountResponseDto
sharingDiscountResponseDto
)
{
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
result
=
sharingDiscountResponseDto
.
getResult
();
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
result
=
sharingDiscountResponseDto
.
getResult
();
if
(
result
==
null
){
if
(
result
==
null
){
...
@@ -133,8 +130,8 @@ public class GiftSharingService {
...
@@ -133,8 +130,8 @@ public class GiftSharingService {
}
}
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
discountGoodsList
=
result
.
getGoods
().
stream
().
filter
(
p
->
CollectionUtils
.
isNotEmpty
(
p
.
getDiscounts
())
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
discountGoodsList
=
result
.
getGoods
().
stream
().
filter
(
p
->
CollectionUtils
.
isNotEmpty
(
p
.
getDiscounts
())
&&
p
.
getDiscounts
().
stream
().
filter
(
discount
->
activityCode
.
contains
(
discount
.
getActivityCode
())).
count
()
>
0
).
collect
(
Collectors
.
toList
());
&&
p
.
getDiscounts
().
stream
().
filter
(
discount
->
activityCode
.
contains
(
discount
.
getActivityCode
())).
count
()
>
0
).
collect
(
Collectors
.
toList
());
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsList
=
result
.
getGoods
();
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
>
goodsList
=
result
.
getGoods
()
==
null
?
new
ArrayList
<>()
:
result
.
getGoods
()
;
Map
<
String
,
Integer
>
qtyMap
=
new
HashMap
<>();
for
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
:
discountGoodsList
){
for
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
goods
:
discountGoodsList
){
int
sendQty
=
0
;
int
sendQty
=
0
;
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
discountList
=
goods
.
getDiscounts
()
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Goods
.
GoodsDiscount
>
discountList
=
goods
.
getDiscounts
()
...
@@ -164,10 +161,11 @@ public class GiftSharingService {
...
@@ -164,10 +161,11 @@ public class GiftSharingService {
goodsList
.
add
(
sendGoods
);
goodsList
.
add
(
sendGoods
);
sendQty
+=
discount
.
getActualGoodsNumber
();
sendQty
+=
discount
.
getActualGoodsNumber
();
}
}
Pair
<
String
,
Integer
>
pair
=
new
Pair
<>(
goods
.
getCartGoodsUid
(),
goods
.
getGoodsQuantity
()
-
sendQty
);
qtyMap
.
put
(
goods
.
getCartGoodsUid
(),
goods
.
getGoodsQuantity
()
-
sendQty
);
return
pair
;
}
}
return
null
;
result
.
setGoods
(
goodsList
);
return
qtyMap
;
}
}
...
...
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