Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
soss
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hooloo
ms
soss
Commits
bb5760ba
Commit
bb5760ba
authored
May 18, 2023
by
weijiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix orig_discount bug
parent
90d99a2b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
2 deletions
+23
-2
soss-system/src/main/java/com/soss/system/service/impl/CouponUserServiceImpl.java
+23
-2
No files found.
soss-system/src/main/java/com/soss/system/service/impl/CouponUserServiceImpl.java
View file @
bb5760ba
package
com
.
soss
.
system
.
service
.
impl
;
package
com
.
soss
.
system
.
service
.
impl
;
import
com.alibaba.fastjson.JSON
;
import
com.soss.common.enums.CouponCategoryType
;
import
com.soss.common.enums.CouponCategoryType
;
import
com.soss.common.enums.CouponState
;
import
com.soss.common.enums.CouponState
;
import
com.soss.common.enums.CouponUserType
;
import
com.soss.common.enums.CouponUserType
;
...
@@ -22,6 +23,7 @@ import org.springframework.util.CollectionUtils;
...
@@ -22,6 +23,7 @@ import org.springframework.util.CollectionUtils;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.function.Function
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -190,6 +192,9 @@ public class CouponUserServiceImpl implements ICouponUserService {
...
@@ -190,6 +192,9 @@ public class CouponUserServiceImpl implements ICouponUserService {
BigDecimal
orderTotalAmount
=
orderDetails
.
stream
().
map
(
OrderDetail:
:
getAmountShould
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
orderTotalAmount
=
orderDetails
.
stream
().
map
(
OrderDetail:
:
getAmountShould
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
orderTotalOrigDiscount
=
orderDetails
.
stream
().
map
(
OrderDetail:
:
getOrigDiscount
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
orderTotalOrigDiscount
=
orderDetails
.
stream
().
map
(
OrderDetail:
:
getOrigDiscount
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
log
.
info
(
"orderTotalAmount:{}, orderTotalOrigDiscount:{}"
,
orderTotalAmount
,
orderTotalOrigDiscount
);
log
.
info
(
"orderTotalAmount:{}, orderTotalOrigDiscount:{}"
,
orderTotalAmount
,
orderTotalOrigDiscount
);
if
(!
CollectionUtils
.
isEmpty
(
couponVos
))
{
orderDetails
.
forEach
(
x
->
x
.
setAmountShould
(
x
.
getOrigDiscount
()));
}
couponVos
.
stream
().
filter
(
couponVo
->
StringUtils
.
isEmpty
(
couponVo
.
getNotFitableDesc
())).
forEach
(
couponVo
->
{
couponVos
.
stream
().
filter
(
couponVo
->
StringUtils
.
isEmpty
(
couponVo
.
getNotFitableDesc
())).
forEach
(
couponVo
->
{
/** 可用饮品范围的判断 */
/** 可用饮品范围的判断 */
List
<
Long
>
fitCouponGoodsIdList
=
goods
.
stream
().
filter
(
good
->
List
<
Long
>
fitCouponGoodsIdList
=
goods
.
stream
().
filter
(
good
->
...
@@ -206,11 +211,27 @@ public class CouponUserServiceImpl implements ICouponUserService {
...
@@ -206,11 +211,27 @@ public class CouponUserServiceImpl implements ICouponUserService {
}
}
/** 券价值的判断 */
/** 券价值的判断 */
if
(
couponVo
.
getType
().
equals
(
CouponCategoryType
.
DEDUCTION
.
getType
()))
{
// 抵扣
if
(
couponVo
.
getType
().
equals
(
CouponCategoryType
.
DEDUCTION
.
getType
()))
{
// 抵扣
if
(
couponVo
.
getPriceLimit
()
!=
null
&&
couponVo
.
getPriceLimit
().
compareTo
(
BigDecimal
.
ZERO
)
!=
0
&&
couponVo
.
getPriceLimit
().
compareTo
(
orderTotal
Am
ount
)
>
0
)
{
if
(
couponVo
.
getPriceLimit
()
!=
null
&&
couponVo
.
getPriceLimit
().
compareTo
(
BigDecimal
.
ZERO
)
!=
0
&&
couponVo
.
getPriceLimit
().
compareTo
(
orderTotal
OrigDisc
ount
)
>
0
)
{
couponVo
.
setNotFitableDesc
(
"未达到满减要求"
);
couponVo
.
setNotFitableDesc
(
"未达到满减要求"
);
return
;
return
;
}
}
couponVo
.
setCouponAmount
(
couponVo
.
getPriceDiscount
().
min
(
orderTotalOrigDiscount
));
couponVo
.
setCouponAmount
(
couponVo
.
getPriceDiscount
().
min
(
orderTotalOrigDiscount
));
AtomicReference
<
Integer
>
nums
=
new
AtomicReference
<>(
0
);
orderDetails
.
forEach
(
x
->
nums
.
updateAndGet
(
v
->
v
+
x
.
getNum
()));
log
.
info
(
"nums:{}"
,
nums
);
if
(
nums
.
get
()
<=
1
)
{
OrderDetail
orderDetail
=
orderDetails
.
get
(
0
);
orderDetail
.
setCouponAmount
(
couponVo
.
getCouponAmount
().
negate
());
orderDetail
.
setRealAmount
(
orderDetail
.
getAmountShould
().
add
(
orderDetail
.
getCouponAmount
()));
}
else
{
orderDetails
.
forEach
(
orderDetail
->
{
BigDecimal
rate
=
orderDetail
.
getAmountShould
().
divide
(
orderTotalOrigDiscount
,
2
,
BigDecimal
.
ROUND_HALF_UP
);;
orderDetail
.
setCouponAmount
(
couponVo
.
getCouponAmount
().
negate
().
multiply
(
rate
));
orderDetail
.
setRealAmount
(
orderDetail
.
getAmountShould
().
add
(
orderDetail
.
getCouponAmount
()));
log
.
info
(
"rate:{},detail:{}"
,
rate
,
JSON
.
toJSON
(
orderDetail
));
});
}
}
else
{
}
else
{
List
<
OrderDetail
>
fitOrderDetails
=
orderDetails
.
stream
().
filter
(
orderDetail
->
fitCouponGoodsIdList
.
contains
(
orderDetail
.
getGoodsId
())).
collect
(
Collectors
.
toList
());
List
<
OrderDetail
>
fitOrderDetails
=
orderDetails
.
stream
().
filter
(
orderDetail
->
fitCouponGoodsIdList
.
contains
(
orderDetail
.
getGoodsId
())).
collect
(
Collectors
.
toList
());
BigDecimal
fitGoodsAmount
=
fitOrderDetails
.
stream
().
map
(
OrderDetail:
:
getAmountShould
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
BigDecimal
fitGoodsAmount
=
fitOrderDetails
.
stream
().
map
(
OrderDetail:
:
getAmountShould
).
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
...
@@ -261,7 +282,7 @@ public class CouponUserServiceImpl implements ICouponUserService {
...
@@ -261,7 +282,7 @@ public class CouponUserServiceImpl implements ICouponUserService {
orderDetail
.
setOriAmount
(
skuNum
.
multiply
(
sku
.
getPrice
()));
orderDetail
.
setOriAmount
(
skuNum
.
multiply
(
sku
.
getPrice
()));
orderDetail
.
setUnitPrice
(
sku
.
getDiscount
());
orderDetail
.
setUnitPrice
(
sku
.
getDiscount
());
orderDetail
.
setAmountShould
(
skuNum
.
multiply
(
sku
.
getDiscount
()));
orderDetail
.
setAmountShould
(
skuNum
.
multiply
(
sku
.
getDiscount
()));
orderDetail
.
setOrigDiscount
(
sku
.
getOrigDiscount
(
));
orderDetail
.
setOrigDiscount
(
sku
Num
.
multiply
(
sku
.
getOrigDiscount
()
));
});
});
return
goodsSkus
;
return
goodsSkus
;
}
}
...
...
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