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
f43fbba8
Commit
f43fbba8
authored
Jun 23, 2021
by
周晓航
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新算价 计算使用优惠券金额
Signed-off-by: 周晓航 <xiaohang.zhou@freemud.com>
parent
3432fb72
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
12 deletions
+47
-12
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/CouponSharingService.java
+4
-12
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/DeliverySharingService.java
+43
-0
No files found.
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/CouponSharingService.java
View file @
f43fbba8
package
cn
.
freemud
.
service
.
impl
.
calculate
.
promotion
;
package
cn
.
freemud
.
service
.
impl
.
calculate
.
promotion
;
import
cn.freemud.entities.dto.ActivityCalculationDiscountResponseDto
;
import
cn.freemud.entities.dto.CheckSpqInfoResponseDto
;
import
cn.freemud.entities.dto.CheckSpqInfoResponseDto
;
import
cn.freemud.entities.dto.GetMemberCouponListRequestDto
;
import
cn.freemud.entities.dto.GetMemberCouponListResponseDto
;
import
cn.freemud.entities.dto.activity.ActivityDiscountsDto
;
import
cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto
;
import
cn.freemud.entities.dto.calculate.CalculationSharingDiscountResponseDto
;
import
cn.freemud.entities.dto.shoppingCart.ShoppingCartGoodsDto
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.entities.vo.*
;
import
cn.freemud.enums.ActivityTypeEnum
;
import
cn.freemud.enums.CouponFlag
;
import
cn.freemud.enums.CouponFlag
;
import
cn.freemud.enums.CouponStatus
;
import
cn.freemud.enums.GoodsTypeEnum
;
import
cn.freemud.enums.GoodsTypeEnum
;
import
cn.freemud.enums.ResponseResult
;
import
cn.freemud.interceptor.ServiceException
;
import
cn.freemud.service.CouponService
;
import
cn.freemud.service.CouponService
;
import
cn.freemud.service.impl.AssortmentSdkService
;
import
cn.freemud.service.impl.AssortmentSdkService
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
import
com.freemud.sdk.api.assortment.shoppingcart.constant.CommonsConstant
;
...
@@ -22,7 +15,6 @@ import org.apache.commons.collections4.CollectionUtils;
...
@@ -22,7 +15,6 @@ import org.apache.commons.collections4.CollectionUtils;
import
org.apache.commons.collections4.MapUtils
;
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.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -96,10 +88,10 @@ public class CouponSharingService {
...
@@ -96,10 +88,10 @@ public class CouponSharingService {
if
(
couponPromotionVO
!=
null
&&
StringUtils
.
isNotEmpty
(
couponPromotionVO
.
getCouponCode
())
if
(
couponPromotionVO
!=
null
&&
StringUtils
.
isNotEmpty
(
couponPromotionVO
.
getCouponCode
())
&&
calculationDiscountResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getDiscounts
()))
{
&&
calculationDiscountResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getDiscounts
()))
{
//List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.CouponResults> couponResultsList = calculationDiscountResult.getCouponDiscounts();
//List<CalculationSharingDiscountResponseDto.CalculationDiscountResult.CouponResults> couponResultsList = calculationDiscountResult.getCouponDiscounts();
List
<
Integer
>
asList
=
Arrays
.
asList
(
3
,
31
);
// 需要加上 配送券的 配送券 type = 34
List
<
Integer
>
asList
=
Arrays
.
asList
(
ActivityTypeEnum
.
TYPE_3
.
getCode
(),
ActivityTypeEnum
.
TYPE_31
.
getCode
(),
ActivityTypeEnum
.
TYPE_34
.
getCode
());
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
couponResultsList
=
calculationDiscountResult
.
getDiscounts
();
List
<
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Discount
>
couponResultsList
=
calculationDiscountResult
.
getDiscounts
();
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Discount
first
=
couponResultsList
.
stream
().
filter
(
d
->
asList
.
contains
(
d
.
getType
())).
findFirst
().
orElse
(
null
);
couponDiscount
=
couponResultsList
.
stream
().
filter
(
d
->
asList
.
contains
(
d
.
getType
())).
mapToLong
(
d
->
d
.
getDiscount
().
longValue
()).
sum
();
if
(
first
!=
null
)
couponDiscount
=
first
.
getDiscount
().
longValue
();
}
}
shoppingCartGoodsResponseVo
.
setCouponDiscount
(
couponDiscount
);
shoppingCartGoodsResponseVo
.
setCouponDiscount
(
couponDiscount
);
...
...
shopping-cart-application-service/src/main/java/cn/freemud/service/impl/calculate/promotion/DeliverySharingService.java
View file @
f43fbba8
...
@@ -35,6 +35,14 @@ public class DeliverySharingService {
...
@@ -35,6 +35,14 @@ public class DeliverySharingService {
private
ActivityService
activityService
;
private
ActivityService
activityService
;
/**
* 老算价有相同逻辑 别再踩坑了
* @set cn.freemud.service.impl.ShoppingCartNewServiceImpl line 1786
* @param discountResult
* @param activityQueryDto
* @param shoppingCartGoodsResponseVo
* @param deliveryAmount
*/
public
void
deliveryResponse
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
public
void
deliveryResponse
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
discountResult
,
ActivityQueryDto
activityQueryDto
,
ActivityQueryDto
activityQueryDto
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
,
ShoppingCartGoodsResponseVo
shoppingCartGoodsResponseVo
...
@@ -66,6 +74,11 @@ public class DeliverySharingService {
...
@@ -66,6 +74,11 @@ public class DeliverySharingService {
String
desc
=
DELIVERY_DISCOUNT_DESC1
;
String
desc
=
DELIVERY_DISCOUNT_DESC1
;
shoppingCartGoodsResponseVo
.
setDeliveryDiscountDesc
(
String
.
format
(
desc
,
df
.
format
(
beanDto
.
getThresholdAmount
().
doubleValue
()
/
100
)
,
df
.
format
(
beanDto
.
getDiscountAmount
().
doubleValue
()
/
100
)));
shoppingCartGoodsResponseVo
.
setDeliveryDiscountDesc
(
String
.
format
(
desc
,
df
.
format
(
beanDto
.
getThresholdAmount
().
doubleValue
()
/
100
)
,
df
.
format
(
beanDto
.
getDiscountAmount
().
doubleValue
()
/
100
)));
}
}
boolean
isType34
=
verifyActivity
(
discountResult
);
if
(
isType34
)
{
String
desc
=
shoppingCartGoodsResponseVo
.
getDeliveryDiscountDesc
();
shoppingCartGoodsResponseVo
.
setDeliveryDiscountDesc
(
desc
+
","
+
DELIVERY_DISCOUNT_DESC4
);
}
shoppingCartGoodsResponseVo
.
setDeliveryAmount
(
discountResult
.
getDeliveryAmount
());
shoppingCartGoodsResponseVo
.
setDeliveryAmount
(
discountResult
.
getDeliveryAmount
());
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
discountResult
.
getDistributionFee
());
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
discountResult
.
getDistributionFee
());
shoppingCartGoodsResponseVo
.
setThresholdAmount
(
discount
.
getThresholdAmount
());
shoppingCartGoodsResponseVo
.
setThresholdAmount
(
discount
.
getThresholdAmount
());
...
@@ -85,6 +98,14 @@ public class DeliverySharingService {
...
@@ -85,6 +98,14 @@ public class DeliverySharingService {
shoppingCartGoodsResponseVo
.
setDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setIsDiscountDelivery
(
false
);
shoppingCartGoodsResponseVo
.
setIsDiscountDelivery
(
false
);
// fisherman 有活动 并且使用了优惠券
boolean
isType34
=
verifyActivity
(
discountResult
);
if
(
isType34
)
{
// 使用了优惠券
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
discountResult
.
getDistributionFee
());
String
deliveryDiscountDesc
=
shoppingCartGoodsResponseVo
.
getDeliveryDiscountDesc
();
shoppingCartGoodsResponseVo
.
setDeliveryDiscountDesc
(
deliveryDiscountDesc
+
","
+
DELIVERY_DISCOUNT_DESC4
);
}
}
else
{
}
else
{
String
desc
=
DELIVERY_DISCOUNT_DESC3
;
String
desc
=
DELIVERY_DISCOUNT_DESC3
;
...
@@ -92,6 +113,14 @@ public class DeliverySharingService {
...
@@ -92,6 +113,14 @@ public class DeliverySharingService {
shoppingCartGoodsResponseVo
.
setDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setIsDiscountDelivery
(
false
);
shoppingCartGoodsResponseVo
.
setIsDiscountDelivery
(
false
);
// fisherman 确认是否 使用了优惠券
boolean
isType34
=
verifyActivity
(
discountResult
);
if
(
isType34
)
{
// 使用了优惠券
shoppingCartGoodsResponseVo
.
setDiscountDeliveryAmount
(
discountResult
.
getDistributionFee
());
String
deliveryDiscountDesc
=
shoppingCartGoodsResponseVo
.
getDeliveryDiscountDesc
();
shoppingCartGoodsResponseVo
.
setDeliveryDiscountDesc
(
deliveryDiscountDesc
+
","
+
DELIVERY_DISCOUNT_DESC4
);
}
}
}
}
}
...
@@ -104,4 +133,18 @@ public class DeliverySharingService {
...
@@ -104,4 +133,18 @@ public class DeliverySharingService {
shoppingCartGoodsResponseVo
.
setTotalAmount
(
shoppingCartGoodsResponseVo
.
getTotalAmount
()
+
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setTotalAmount
(
shoppingCartGoodsResponseVo
.
getTotalAmount
()
+
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setOriginalTotalAmount
(
shoppingCartGoodsResponseVo
.
getOriginalTotalAmount
()
+
deliveryAmount
);
shoppingCartGoodsResponseVo
.
setOriginalTotalAmount
(
shoppingCartGoodsResponseVo
.
getOriginalTotalAmount
()
+
deliveryAmount
);
}
}
/**
* 检验是否使用的 配送券
* @param calculationDiscountResult
* @return
*/
private
boolean
verifyActivity
(
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
calculationDiscountResult
)
{
if
(
calculationDiscountResult
!=
null
&&
CollectionUtils
.
isNotEmpty
(
calculationDiscountResult
.
getDiscounts
()))
{
CalculationSharingDiscountResponseDto
.
CalculationDiscountResult
.
Discount
discount
=
calculationDiscountResult
.
getDiscounts
().
stream
().
filter
(
couponResults
->
couponResults
.
getType
()
!=
null
&&
couponResults
.
getType
().
compareTo
(
ActivityTypeEnum
.
TYPE_34
.
getCode
())
==
0
).
findFirst
().
orElse
(
null
);
return
discount
!=
null
;
}
return
false
;
}
}
}
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