Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
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
pseer
gxpt_ht
Commits
4d4d4eb8
Commit
4d4d4eb8
authored
Apr 24, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改计算订单金额
parent
1dbdec0b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
17 deletions
+41
-17
OrderComputedPriceRequest.java
.../java/share/system/request/OrderComputedPriceRequest.java
+3
-0
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+38
-17
No files found.
share-system/src/main/java/share/system/request/OrderComputedPriceRequest.java
View file @
4d4d4eb8
...
@@ -52,4 +52,7 @@ public class OrderComputedPriceRequest {
...
@@ -52,4 +52,7 @@ public class OrderComputedPriceRequest {
@ApiModelProperty
(
value
=
"预约结束时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@ApiModelProperty
(
value
=
"预约结束时间 yyyy-MM-dd HH:mm"
,
required
=
true
)
@NotNull
(
message
=
"预约结束时间不能为空"
)
@NotNull
(
message
=
"预约结束时间不能为空"
)
private
Date
preEndDate
;
private
Date
preEndDate
;
@ApiModelProperty
(
value
=
"标签id"
)
private
Long
roomLabelId
;
}
}
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
4d4d4eb8
...
@@ -44,8 +44,8 @@ import share.system.response.ComputedOrderPriceResponse;
...
@@ -44,8 +44,8 @@ import share.system.response.ComputedOrderPriceResponse;
import
share.system.response.OrderPayResultResponse
;
import
share.system.response.OrderPayResultResponse
;
import
share.system.service.*
;
import
share.system.service.*
;
import
javax.annotation.Resource
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -123,6 +123,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -123,6 +123,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
@Autowired
private
SaobeiApiLogService
saobeiApiLogService
;
private
SaobeiApiLogService
saobeiApiLogService
;
@Resource
private
RoomLabelService
roomLabelService
;
private
final
static
Long
FIVE
=
5
l
;
private
final
static
Long
FIVE
=
5
l
;
...
@@ -1808,11 +1811,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1808,11 +1811,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
break
;
break
;
case
PACKAGE:
//套餐券
case
PACKAGE:
//套餐券
case
CASH:
//现金券(团购券)
case
CASH:
//现金券(团购券)
case
DURATION:
//时长券
//判断优惠券最小使用金额
//判断优惠券最小使用金额
if
(
consumerCoupon
.
getMinPrice
().
compareTo
(
priceResponse
.
getTotalFee
())
>
0
)
{
if
(
consumerCoupon
.
getMinPrice
().
compareTo
(
priceResponse
.
getTotalFee
())
>
0
)
{
throw
new
BaseException
(
"总金额小于优惠券最小使用金额"
);
throw
new
BaseException
(
"总金额小于优惠券最小使用金额"
);
}
}
BigDecimal
subtract
=
priceResponse
.
getTotalFee
().
subtract
(
consumerCoupon
.
getSubPrice
());
RoomLabel
roomLabel
=
roomLabelService
.
selectRoomLabelById
(
request
.
getRoomLabelId
());
//(促销价-优惠券促销价)+((时长-促销时长)*单价)
SRoom
room
=
roomService
.
getById
(
request
.
getRoomId
());
BigDecimal
subtract
=
roomLabel
.
getPromotionAmount
().
subtract
(
consumerCoupon
.
getPromotionPrice
()).
add
((
DateUtils
.
differentHour
(
request
.
getPreStartDate
(),
request
.
getPreEndDate
()).
subtract
(
new
BigDecimal
(
roomLabel
.
getPromotionDuration
()))).
multiply
(
room
.
getPrice
()));
//判断是否为负数
//判断是否为负数
if
(
subtract
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
if
(
subtract
.
compareTo
(
BigDecimal
.
ZERO
)
<
0
)
{
priceResponse
.
setPayFee
(
BigDecimal
.
ZERO
);
priceResponse
.
setPayFee
(
BigDecimal
.
ZERO
);
...
@@ -1822,21 +1830,34 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -1822,21 +1830,34 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse
.
setCouponFee
(
priceResponse
.
getTotalFee
().
subtract
(
subtract
));
priceResponse
.
setCouponFee
(
priceResponse
.
getTotalFee
().
subtract
(
subtract
));
}
}
break
;
break
;
case
DURATION:
//时长券
//
BigDecimal
timeLong
=
DateUtils
.
differentHour
(
request
.
getPreStartDate
(),
request
.
getPreEndDate
());
// BigDecimal timeLong = DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate());
if
(
new
BigDecimal
(
consumerCoupon
.
getMinDuration
()).
compareTo
(
timeLong
)
>
0
)
{
// if (new BigDecimal(consumerCoupon.getMinDuration()).compareTo(timeLong) > 0) {
throw
new
BaseException
(
"总时长小于优惠券最小使用时长"
);
// throw new BaseException("总时长小于优惠券最小使用时长");
}
// }
BigDecimal
duration
=
new
BigDecimal
(
consumerCoupon
.
getDuration
());
// roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
if
(
duration
.
compareTo
(
timeLong
)
>=
0
)
{
// //(促销价-优惠券促销价)+((时长-促销时长)*单价)
priceResponse
.
setPayFee
(
BigDecimal
.
ZERO
);
// room = roomService.getById(request.getRoomId());
priceResponse
.
setCouponFee
(
priceResponse
.
getTotalFee
());
// subtract = roomLabel.getPromotionAmount().subtract(consumerCoupon.getPromotionPrice()).
}
else
{
// add((DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()));
BigDecimal
unitPrice
=
priceResponse
.
getTotalFee
().
divide
(
timeLong
);
// BigDecimal duration = new BigDecimal(consumerCoupon.getDuration());
priceResponse
.
setPayFee
(
unitPrice
.
multiply
(
timeLong
.
subtract
(
duration
)).
setScale
(
2
,
RoundingMode
.
HALF_DOWN
));
// if (duration.compareTo(timeLong) >= 0) {
priceResponse
.
setCouponFee
(
priceResponse
.
getTotalFee
().
subtract
(
priceResponse
.
getPayFee
()));
// priceResponse.setPayFee(BigDecimal.ZERO);
}
// priceResponse.setCouponFee(priceResponse.getTotalFee());
break
;
// } else {
// BigDecimal unitPrice = priceResponse.getTotalFee().divide(timeLong);
// priceResponse.setPayFee(unitPrice.multiply(timeLong.subtract(duration)).setScale(2, RoundingMode.HALF_DOWN));
// priceResponse.setCouponFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
// }
//判断是否为负数
// if (subtract.compareTo(BigDecimal.ZERO) < 0) {
// priceResponse.setPayFee(BigDecimal.ZERO);
// priceResponse.setCouponFee(priceResponse.getTotalFee());
// } else {
// priceResponse.setPayFee(subtract);
// priceResponse.setCouponFee(priceResponse.getTotalFee().subtract(subtract));
// }
// break;
default
:
default
:
break
;
break
;
}
}
...
...
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