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
668a2af3
Commit
668a2af3
authored
Jul 28, 2021
by
ping.wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
benefitBeanDtos.get(0)报错修改,判断benefitBeanDtos集合不为空
parent
bf8799ba
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
166 deletions
+25
-166
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/FullPromotionService.java
+7
-4
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/FullSubtractionActivityServiceImpl.java
+3
-150
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/FullSharingService.java
+8
-8
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/FullPromotionCalculation.java
+7
-4
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/FullPromotionService.java
View file @
668a2af3
...
...
@@ -77,9 +77,8 @@ public class FullPromotionService implements IPromotionService {
if
(
calculationDiscountResult
==
null
)
{
// 因为没有促销活动的计算信息,所以没有加入购物车内
List
<
BenefitBeanDto
>
benefitBeanDtos
=
activityResponseDto
.
getBenefits
();
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
//调用没有加入购物车的提示语的方法
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
benefitBeanDto
,
activityList
);
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
activityList
);
}
else
{
//促销返回满减提示语
...
...
@@ -134,8 +133,13 @@ public class FullPromotionService implements IPromotionService {
}
//设置没有加入购物车的提示语
private
void
setMessageNotInShoppingCart
(
StringBuilder
messageBuilder
,
ActivityResponseDto
activityResponseDto
,
List
<
BenefitBeanDto
>
benefitBeanDtos
,
BenefitBeanDto
benefitBeanDto
,
private
void
setMessageNotInShoppingCart
(
StringBuilder
messageBuilder
,
ActivityResponseDto
activityResponseDto
,
List
<
BenefitBeanDto
>
benefitBeanDtos
,
ArrayList
<
ActivityList
>
activityList
)
{
if
(
CollectionUtils
.
isEmpty
(
benefitBeanDtos
)){
return
;
}
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
if
(
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_11
.
getCode
(),
activityResponseDto
.
getActivityType
()))
{
messageBuilder
.
append
(
"每满 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getThresholdAmount
()
*
1.00
/
100
))
...
...
@@ -189,7 +193,6 @@ public class FullPromotionService implements IPromotionService {
else
if
(
GiftTypeEnum
.
TYPE_2
.
getType
().
equals
(
activityResponseDto
.
getActivitySubType
()))
{
notInShopping
.
setTipType
(
7
);
}
//int len = benefitBeanDto.getSendGoodsList().size();
Collections
.
sort
(
benefitBeanDtos
);
BenefitBeanDto
dto
=
benefitBeanDtos
.
get
(
0
);
int
len
=
dto
.
getSendGoodsList
().
size
();
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/FullSubtractionActivityServiceImpl.java
View file @
668a2af3
...
...
@@ -27,154 +27,6 @@ public class FullSubtractionActivityServiceImpl {
@Autowired
private
ActivityService
activityService
;
/**
* 获取满减活动
*
* @param activityQueryDto
* @param totalAmount 处理过了的总价
* @return
*/
public
PromotionMessageDto
getFullPromotionActivityInfo
(
ActivityQueryDto
activityQueryDto
,
Long
totalAmount
,
boolean
hasOtherDiscount
)
{
totalAmount
=
totalAmount
==
null
?
0L
:
totalAmount
;
ActivityQueryResponseDto
activityQueryResponseDto
=
activityService
.
queryActivitys
(
activityQueryDto
,
null
,
null
);
if
(
activityQueryResponseDto
==
null
)
{
return
null
;
}
PromotionMessageDto
promotionMessageDto
=
new
PromotionMessageDto
();
List
<
ActivityResponseDto
>
activityQueryDtoList
=
activityQueryResponseDto
.
getResult
();
if
(
CollectionUtils
.
isNotEmpty
(
activityQueryDtoList
))
{
activityQueryDtoList
=
activityQueryDtoList
.
parallelStream
().
filter
(
k
->
{
Integer
activityType
=
k
.
getActivityType
();
return
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_11
.
getCode
(),
activityType
)
||
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_12
.
getCode
(),
activityType
);
}).
limit
(
1
).
collect
(
Collectors
.
toList
());
// 存在满减活动
if
(
CollectionUtils
.
isNotEmpty
(
activityQueryDtoList
))
{
totalAmount
=
totalAmount
==
null
?
0L
:
totalAmount
;
StringBuilder
messageBuilder
=
new
StringBuilder
();
ActivityResponseDto
activityResponseDto
=
activityQueryDtoList
.
get
(
0
);
promotionMessageDto
.
setActivityId
(
activityResponseDto
.
getActivityCode
());
promotionMessageDto
.
setActivityName
(
activityResponseDto
.
getActivityName
());
promotionMessageDto
.
setActivityType
(
activityResponseDto
.
getActivityType
());
promotionMessageDto
.
setPromotionAmount
(
0L
);
// 每满减
List
<
BenefitBeanDto
>
benefitBeanDtos
=
activityResponseDto
.
getBenefits
();
if
(
CollectionUtils
.
isNotEmpty
(
benefitBeanDtos
))
{
if
(
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_11
.
getCode
(),
activityResponseDto
.
getActivityType
()))
{
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
Integer
thresholdAmount
=
benefitBeanDto
.
getThresholdAmount
();
Integer
discountAmount
=
benefitBeanDto
.
getDiscountAmount
();
// 购物车中无商品或者存在与满减互斥的活动
if
(
totalAmount
==
0
||
(
hasOtherDiscount
&&
Objects
.
equals
(
activityResponseDto
.
getIsShared
(),
0
)))
{
messageBuilder
.
append
(
"每满 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getThresholdAmount
()
*
1.00
/
100
))
.
append
(
"</span> 减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getDiscountAmount
()
*
1.00
/
100
))
.
append
(
"</span> "
)
.
append
(
"最高减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
activityResponseDto
.
getMaxMoney
()
*
1.00
/
100
))
.
append
(
"</span> "
);
}
// 购物车中有商品但还不够满减
else
if
(
totalAmount
<
thresholdAmount
)
{
messageBuilder
.
append
(
"满 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
thresholdAmount
*
1.00
/
100
))
.
append
(
"</span> 减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
discountAmount
*
1.00
/
100
))
.
append
(
"</span> "
)
.
append
(
"还差 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
((
thresholdAmount
-
totalAmount
)
*
1.00
/
100
))
.
append
(
"</span> 元"
);
}
// 已够满减
else
if
(
totalAmount
>=
thresholdAmount
)
{
// 最大阶级
Long
maxLevel
=
activityResponseDto
.
getMaxMoney
()
/
discountAmount
;
Long
currentLevel
=
totalAmount
/
thresholdAmount
;
if
(
currentLevel
>
maxLevel
||
currentLevel
*
discountAmount
==
activityResponseDto
.
getMaxMoney
())
{
Long
diccountAmount
=
activityResponseDto
.
getMaxMoney
()
<
currentLevel
*
discountAmount
?
activityResponseDto
.
getMaxMoney
()
:
maxLevel
*
discountAmount
;
messageBuilder
.
append
(
"已减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
diccountAmount
*
1.00
/
100
))
.
append
(
"</span> 元"
);
}
else
{
Long
maxDiscountAmount
=
activityResponseDto
.
getMaxMoney
()
<
(
discountAmount
*
(
currentLevel
+
1
))
?
activityResponseDto
.
getMaxMoney
()
:
(
discountAmount
*
(
currentLevel
+
1
));
messageBuilder
.
append
(
"已减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
discountAmount
*
currentLevel
*
1.00
/
100
))
.
append
(
"</span> 元 再买 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
((
thresholdAmount
*
(
currentLevel
+
1
)
-
totalAmount
)
*
1.00
/
100
))
.
append
(
"</span> 元减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
maxDiscountAmount
*
1.00
/
100
))
.
append
(
"</span> 元"
);
}
}
}
// 阶梯满减
else
if
(
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_12
.
getCode
(),
activityResponseDto
.
getActivityType
()))
{
int
len
=
benefitBeanDtos
.
size
();
BenefitBeanDto
minBenefitBeanDto
=
benefitBeanDtos
.
get
(
len
-
1
);
// // 购物车中无商品或者存在与满减互斥的活动
if
(
totalAmount
==
0
||
(
hasOtherDiscount
&&
Objects
.
equals
(
activityResponseDto
.
getIsShared
(),
0
)))
{
for
(
int
i
=
len
-
1
,
j
=
0
;
i
>=
0
&&
j
<
2
;
i
--,
j
++)
{
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
i
);
messageBuilder
.
append
(
"满 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getThresholdAmount
()
*
1.00
/
100
))
.
append
(
"</span> 减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getDiscountAmount
()
*
1.00
/
100
))
.
append
(
"</span> "
);
}
}
// 购物车中有商品但还不够满减
else
if
(
totalAmount
<
minBenefitBeanDto
.
getThresholdAmount
())
{
messageBuilder
.
append
(
"满 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
minBenefitBeanDto
.
getThresholdAmount
()
*
1.00
/
100
))
.
append
(
"</span> 减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
minBenefitBeanDto
.
getDiscountAmount
()
*
1.00
/
100
))
.
append
(
"</span> "
)
.
append
(
"还差 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
((
minBenefitBeanDto
.
getThresholdAmount
()
-
totalAmount
)
*
1.00
/
100
))
.
append
(
"</span> 元"
);
}
// 已够满减
else
{
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
i
);
int
thresholdAmount
=
benefitBeanDto
.
getThresholdAmount
();
// 最高阶
if
(
i
==
0
&&
totalAmount
>=
thresholdAmount
)
{
messageBuilder
.
append
(
"已减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getDiscountAmount
()
*
1.00
/
100
))
.
append
(
"</span> 元"
);
break
;
}
else
{
if
(
i
>
0
&&
totalAmount
>=
thresholdAmount
)
{
int
lastThresholdAmount
=
benefitBeanDtos
.
get
(
i
-
1
).
getThresholdAmount
();
int
lastDiscountAmount
=
benefitBeanDtos
.
get
(
i
-
1
).
getDiscountAmount
();
messageBuilder
.
append
(
"已减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getDiscountAmount
()
*
1.00
/
100
))
.
append
(
"</span> 元 再买 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
((
lastThresholdAmount
-
totalAmount
)
*
1.00
/
100
))
.
append
(
"</span> 元减 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
lastDiscountAmount
*
1.00
/
100
))
.
append
(
"</span> 元"
);
break
;
}
}
}
}
}
promotionMessageDto
.
setPromotionMessage
(
messageBuilder
.
toString
());
return
promotionMessageDto
;
}
}
}
return
null
;
}
/**
* 获取满减活动信息_新方法
*
...
...
@@ -211,8 +63,10 @@ public class FullSubtractionActivityServiceImpl {
// 没有加入购物车
if
(
calculationDiscountResult
==
null
)
{
List
<
BenefitBeanDto
>
benefitBeanDtos
=
activityResponseDto
.
getBenefits
();
if
(
CollectionUtils
.
isEmpty
(
benefitBeanDtos
)){
return
promotionMessageDto
;
}
ArrayList
<
ActivityList
>
arrayList
=
new
ArrayList
();
//BenefitBeanDto benefitBeanDto = benefitBeanDtos.get(0);
BenefitBeanDto
benefitBeanDto
=
null
;
// 每满减
if
(
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_11
.
getCode
(),
activityResponseDto
.
getActivityType
()))
{
...
...
@@ -235,7 +89,6 @@ public class FullSubtractionActivityServiceImpl {
arrayList
.
add
(
notInShopping
);
}
if
(
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_12
.
getCode
(),
activityResponseDto
.
getActivityType
()))
{
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
int
len
=
benefitBeanDtos
.
size
();
// // 购物车中无商品或者存在与满减互斥的活动
for
(
int
i
=
len
-
1
,
j
=
0
;
i
>=
0
&&
j
<
2
;
i
--,
j
++)
{
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/FullSharingService.java
View file @
668a2af3
...
...
@@ -79,9 +79,8 @@ public class FullSharingService {
ArrayList
<
ActivityList
>
activityList
=
new
ArrayList
<>();
List
<
BenefitBeanDto
>
benefitBeanDtos
=
activityResponseDto
.
getBenefits
();
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
//调用没有加入购物车的提示语的方法
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
benefitBeanDto
,
activityList
);
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
activityList
);
promotionMessageDto
.
setPromotionMessage
(
messageBuilder
.
toString
());
ActivityTip
activityTip
=
new
ActivityTip
();
...
...
@@ -189,9 +188,8 @@ public class FullSharingService {
*/
if
(
null
==
discountResult
)
{
List
<
BenefitBeanDto
>
benefitBeanDtos
=
activityResponseDto
.
getBenefits
();
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
//调用没有加入购物车的提示语的方法
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
benefitBeanDto
,
activityList
);
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
activityList
);
}
//促销返回满减提示语
else
{
...
...
@@ -226,12 +224,14 @@ public class FullSharingService {
* @param messageBuilder
* @param activityResponseDto
* @param benefitBeanDtos
* @param benefitBeanDto
* @param activityList
*/
private
void
setMessageNotInShoppingCart
(
StringBuilder
messageBuilder
,
ActivityResponseDto
activityResponseDto
,
List
<
BenefitBeanDto
>
benefitBeanDtos
,
BenefitBeanDto
benefitBeanDto
,
ArrayList
<
ActivityList
>
activityList
)
{
private
void
setMessageNotInShoppingCart
(
StringBuilder
messageBuilder
,
ActivityResponseDto
activityResponseDto
,
List
<
BenefitBeanDto
>
benefitBeanDtos
,
ArrayList
<
ActivityList
>
activityList
)
{
if
(
CollectionUtils
.
isEmpty
(
benefitBeanDtos
)){
return
;
}
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
if
(
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_11
.
getCode
(),
activityResponseDto
.
getActivityType
()))
{
messageBuilder
.
append
(
"每满 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getThresholdAmount
()
*
1.00
/
100
))
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/mcoffee/calculation/FullPromotionCalculation.java
View file @
668a2af3
...
...
@@ -70,9 +70,8 @@ public class FullPromotionCalculation {
if
(
calculationDiscountResult
==
null
)
{
// 因为没有促销活动的计算信息,所以没有加入购物车内
List
<
BenefitBeanDto
>
benefitBeanDtos
=
activityResponseDto
.
getBenefits
();
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
//调用没有加入购物车的提示语的方法
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
benefitBeanDto
,
activityList
);
setMessageNotInShoppingCart
(
messageBuilder
,
activityResponseDto
,
benefitBeanDtos
,
activityList
);
}
else
{
//促销返回满减提示语
List
<
ActivityCalculationDiscountResponseDto
.
CalculationDiscountResult
.
ActivityPrompt
>
activityPrompts
=
calculationDiscountResult
.
getActivityPrompts
();
...
...
@@ -130,8 +129,12 @@ public class FullPromotionCalculation {
//设置没有加入购物车的提示语
private
void
setMessageNotInShoppingCart
(
StringBuilder
messageBuilder
,
ActivityResponseDto
activityResponseDto
,
List
<
BenefitBeanDto
>
benefitBeanDtos
,
BenefitBeanDto
benefitBeanDto
,
ArrayList
<
ActivityList
>
activityList
)
{
private
void
setMessageNotInShoppingCart
(
StringBuilder
messageBuilder
,
ActivityResponseDto
activityResponseDto
,
List
<
BenefitBeanDto
>
benefitBeanDtos
,
ArrayList
<
ActivityList
>
activityList
)
{
if
(
CollectionUtils
.
isEmpty
(
benefitBeanDtos
)){
return
;
}
BenefitBeanDto
benefitBeanDto
=
benefitBeanDtos
.
get
(
0
);
if
(
Objects
.
equals
(
ActivityTypeEnum
.
TYPE_11
.
getCode
(),
activityResponseDto
.
getActivityType
()))
{
messageBuilder
.
append
(
"每满 <span style=\"color:#fa5555\">"
)
.
append
(
WebUtil
.
formatAmount
(
benefitBeanDto
.
getThresholdAmount
()
*
1.00
/
100
))
...
...
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