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
84dd371d
Commit
84dd371d
authored
Jul 24, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refs/heads/dev' into test
parents
93246edb
eb645956
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
99 deletions
+164
-99
OrderTask.java
share-quartz/src/main/java/share/quartz/task/OrderTask.java
+36
-10
ComputedOrderPriceResponse.java
...ava/share/system/response/ComputedOrderPriceResponse.java
+7
-1
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+121
-88
No files found.
share-quartz/src/main/java/share/quartz/task/OrderTask.java
View file @
84dd371d
package
share
.
quartz
.
task
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.*
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONObject
;
...
...
@@ -15,6 +12,7 @@ import org.springframework.data.redis.core.RedisTemplate;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.support.TransactionTemplate
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.ObjectUtils
;
import
share.common.constant.Constants
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.*
;
...
...
@@ -72,6 +70,9 @@ public class OrderTask {
@Autowired
private
ISStoreService
storeService
;
@Autowired
private
ISCleanRecordsService
isCleanRecordsService
;
final
int
ZERO
=
0
;
//10分钟的常量
...
...
@@ -324,16 +325,41 @@ public class OrderTask {
public
void
orderCompensate
()
{
// 订单状态处理
LambdaQueryWrapper
<
SOrder
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
le
(
SOrder:
:
getEndDate
,
DateUtil
.
offset
(
DateUtil
.
date
(),
DateField
.
MINUTE
,
-
5
));
queryWrapper
.
le
(
SOrder:
:
getEndDate
,
DateUtil
.
offset
(
DateUtil
.
date
(),
DateField
.
MINUTE
,
-
2
));
queryWrapper
.
in
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
UNUSED
.
getCode
(),
OrderStatusEnum
.
INUSE
.
getCode
());
queryWrapper
.
eq
(
SOrder:
:
getPayStatus
,
1
);
queryWrapper
.
eq
(
SOrder:
:
getPayStatus
,
YesNoEnum
.
yes
.
getIndex
()
);
List
<
SOrder
>
orders
=
orderService
.
list
(
queryWrapper
);
if
(
orders
!=
null
&&
orders
.
size
()
>
0
)
{
orders
.
forEach
(
order
->
{
order
.
setStatus
(
OrderStatusEnum
.
USED
.
getCode
());
order
.
setUpdateTime
(
new
Date
());
orders
.
stream
().
forEach
(
sOrder
->
{
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单异常"
);
//更改订单状态
sOrder
.
setStatus
(
OrderStatusEnum
.
USED
.
getCode
());
sOrder
.
setUpdateTime
(
new
Date
());
orderService
.
updateById
(
sOrder
);
// 修改房间状态
SRoom
room
=
roomService
.
getById
(
sOrder
.
getRoomId
());
if
(
ObjectUtil
.
isNotEmpty
(
room
))
{
room
.
setStatus
(
RoomStatusEnum
.
FREE
.
getValue
());
room
.
setUpdateTime
(
new
Date
());
roomService
.
updateById
(
room
);
}
//判断订单是否已经添加保洁记录
SCleanRecords
cleanRecords
=
isCleanRecordsService
.
lastCleanByRoomId
(
sOrder
.
getRoomId
());
if
(
ObjectUtils
.
isEmpty
(
cleanRecords
)
||
cleanRecords
.
getStatus
().
compareTo
(
CleaningStatusEnum
.
UNCLEAN
.
getCode
())
!=
0
)
{
boolean
b
=
isCleanRecordsService
.
addSCleanRecords
(
sOrder
.
getStoreId
(),
sOrder
.
getRoomId
());
}
deviceOpService
.
actionExecute
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
SEND_CUSTOMER
.
getCode
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
//延时3分钟断电
deviceOpService
.
openOrCloseDevice
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
OpTypeEnum
.
CUT_ELECTRIC
.
getCode
(),
false
,
0L
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单已结束,更改订单状态为已使用"
);
// order.setStatus(OrderStatusEnum.USED.getCode());
// order.setUpdateTime(new Date());
});
orderService
.
updateBatchById
(
orders
,
orders
.
size
());
//
orderService.updateBatchById(orders,orders.size());
}
// 房间状态处理
LambdaQueryWrapper
<
SRoom
>
queryRoomWrapper
=
new
LambdaQueryWrapper
();
...
...
share-system/src/main/java/share/system/response/ComputedOrderPriceResponse.java
View file @
84dd371d
...
...
@@ -27,8 +27,14 @@ public class ComputedOrderPriceResponse implements Serializable {
@ApiModelProperty
(
value
=
"实际支付金额"
)
private
BigDecimal
payFee
;
@ApiModelProperty
(
value
=
"总金额"
)
@ApiModelProperty
(
value
=
"
原
总金额"
)
private
BigDecimal
totalFee
;
//现总金额
@ApiModelProperty
(
value
=
"现总金额"
)
private
BigDecimal
totalFeeNow
;
//优惠折扣
@ApiModelProperty
(
value
=
"优惠折扣"
)
private
BigDecimal
discount
;
@ApiModelProperty
(
value
=
"优惠金额"
)
private
BigDecimal
discountFee
;
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
84dd371d
...
...
@@ -1159,8 +1159,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
}
consumerMember
.
setMembershipProgress
(
membershipProgress
);
memberProgressLog
.
setVariableProgress
(
membershipProgress
.
subtract
(
consumerMember
.
getMembershipProgress
()));
consumerMember
.
setMembershipProgress
(
membershipProgress
);
memberProgressLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
memberProgressLog
.
setOperationTime
(
new
Date
());
memberProgressLog
.
setCreateTime
(
new
Date
());
...
...
@@ -1616,35 +1617,38 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
unLockOrder
(
sOrder
.
getRoomId
());
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerWallet
>().
eq
(
ConsumerWallet:
:
getConsumerId
,
sOrder
.
getConsumerId
()));
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
sOrder
.
getConsumerId
()));
// LambdaQueryWrapper<SOrder> queryWrapper = new LambdaQueryWrapper<>();
// queryWrapper.ne(SOrder::getOrderNo,sOrder.getOrderNo());
// queryWrapper.eq(SOrder::getOrderType,OrderTypeEnum.RESERVER.getCode());
// queryWrapper.notIn(SOrder::getRefundStatus, RefundStatusEnum.getRefundedStatus());
// queryWrapper.in(SOrder::getStatus, OrderStatusEnum.getUnfinishOrderStatus());
// queryWrapper.eq(SOrder::getIsDelete, YesNoEnum.no.getIndex());
// queryWrapper.eq(SOrder::getStoreId, sOrder.getStoreId());
// queryWrapper.eq(SOrder::getRoomId, sOrder.getRoomId());
// queryWrapper.apply("(IFNULL(start_date,pre_start_date) BETWEEN '"
// + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sOrder.getPreStartDate())
// + "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(sOrder.getPreEndDate(), Constants.ROOM_LOCK_DELAY_MINUTE)) + "' " +
// "OR IFNULL(end_date,pre_end_date) BETWEEN '"
// + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.addMinutes(sOrder.getPreStartDate(), -Constants.ROOM_LOCK_DELAY_MINUTE))
// + "' AND '" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sOrder.getPreEndDate()) + "' )");
// SOrder order = getOne(queryWrapper);
// if(ObjectUtil.isNotEmpty(order)){
// //退款
// AdminRefundRequest refundRequest = new AdminRefundRequest();
// refundRequest.setOrderNo(sOrder.getOrderNo());
// refundRequest.setAmount(sOrder.getPayPrice());
// refundRequest.setIsClean(YesNoEnum.no.getIndex());
// refundRequest.setRefundCoupon(YesNoEnum.yes.getIndex());
// refundRequest.setRefundReason("当前订单:"+sOrder.getOrderNo()+"和订单:"+order.getOrderNo()+"预约时间有干涉");
// int i = sOrderService.refundOp(refundRequest);
// if(i==1){
// sOrderService.removeById(sOrder);
// }
// return;
// }
logger
.
debug
(
"订单查询预约时间是否干涉"
);
LambdaQueryWrapper
<
SOrder
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
ne
(
SOrder:
:
getOrderNo
,
sOrder
.
getOrderNo
());
queryWrapper
.
eq
(
SOrder:
:
getOrderType
,
OrderTypeEnum
.
RESERVER
.
getCode
());
queryWrapper
.
eq
(
SOrder:
:
getPayStatus
,
YesNoEnum
.
yes
.
getIndex
());
queryWrapper
.
notIn
(
SOrder:
:
getRefundStatus
,
RefundStatusEnum
.
getRefundedStatus
());
queryWrapper
.
in
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
getUnfinishOrderStatus
());
queryWrapper
.
eq
(
SOrder:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
queryWrapper
.
eq
(
SOrder:
:
getStoreId
,
sOrder
.
getStoreId
());
queryWrapper
.
eq
(
SOrder:
:
getRoomId
,
sOrder
.
getRoomId
());
queryWrapper
.
apply
(
"(IFNULL(start_date,pre_start_date) BETWEEN '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
sOrder
.
getPreStartDate
())
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
sOrder
.
getPreEndDate
(),
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' "
+
"OR IFNULL(end_date,pre_end_date) BETWEEN '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
DateUtils
.
addMinutes
(
sOrder
.
getPreStartDate
(),
-
Constants
.
ROOM_LOCK_DELAY_MINUTE
))
+
"' AND '"
+
DateUtils
.
parseDateToStr
(
DateUtils
.
YYYY_MM_DD_HH_MM_SS
,
sOrder
.
getPreEndDate
())
+
"' )"
);
SOrder
order
=
getOne
(
queryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
order
))
{
logger
.
debug
(
"订单:"
+
sOrder
.
getOrderNo
()
+
"和订单:"
+
order
.
getOrderNo
()
+
"预约时间有干涉"
);
//退款
AdminRefundRequest
refundRequest
=
new
AdminRefundRequest
();
refundRequest
.
setOrderNo
(
sOrder
.
getOrderNo
());
refundRequest
.
setAmount
(
sOrder
.
getPayPrice
());
refundRequest
.
setIsClean
(
YesNoEnum
.
no
.
getIndex
());
refundRequest
.
setRefundCoupon
(
YesNoEnum
.
yes
.
getIndex
());
refundRequest
.
setRefundReason
(
"当前订单:"
+
sOrder
.
getOrderNo
()
+
"和订单:"
+
order
.
getOrderNo
()
+
"预约时间有干涉"
);
int
i
=
sOrderService
.
refundOp
(
refundRequest
);
if
(
i
==
1
)
{
sOrderService
.
removeById
(
sOrder
);
}
return
;
}
if
(
sOrder
.
getOrderType
().
equals
(
OrderTypeEnum
.
RENEW
.
getCode
()))
{
SRoom
room
=
roomService
.
getById
(
sOrder
.
getRoomId
());
...
...
@@ -2220,6 +2224,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
BigDecimal
timeLong
=
DateUtils
.
differentHour
(
request
.
getPreStartDate
(),
request
.
getPreEndDate
());
// 计算各种价格
ComputedOrderPriceResponse
priceResponse
=
new
ComputedOrderPriceResponse
();
priceResponse
.
setBalance
(
BigDecimal
.
ZERO
);
priceResponse
.
setRemainingBalance
(
BigDecimal
.
ZERO
);
priceResponse
.
setDuration
(
BigDecimal
.
ZERO
);
priceResponse
.
setRemainingDuration
(
BigDecimal
.
ZERO
);
priceResponse
.
setDiscount
(
BigDecimal
.
ZERO
);
Activity
activity
=
null
;
ConsumerMember
consumerMember
=
null
;
ConsumerWallet
consumerWallet
=
null
;
...
...
@@ -2240,32 +2249,41 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
RoomLabel
roomLabel
=
roomLabelService
.
selectRoomLabelById
(
request
.
getRoomLabelId
());
if
(
ObjectUtils
.
isEmpty
(
roomLabel
.
getPackId
()))
{
payPrice
=
totalPrice
;
priceResponse
.
setTotalFeeNow
(
payPrice
);
request
.
setBuyType
(
BuyTypeEnum
.
TIME
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
queryWrapper
.
eq
(
Activity:
:
getLabelId
,
roomLabel
.
getLabelId
());
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
,
consumerMember
);
priceResponse
.
setTotalFeeNow
(
totalFee
);
priceResponse
.
setDiscount
(
totalFee
.
divide
(
payPrice
).
multiply
(
new
BigDecimal
(
100
)));
}
totalFee
=
getBigDecimal
(
consumerWallet
,
activity
,
timeLong
,
priceResponse
,
totalFee
,
room
,
request
);
}
else
{
SPack
byId
=
packService
.
getById
(
roomLabel
.
getPackId
());
if
(!
ObjectUtils
.
isEmpty
(
byId
)
&&
byId
.
getIsOpen
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
payPrice
=
computeTotalPrice
(
roomLabel
.
getPackId
(),
totalPrice
);
priceResponse
.
setTotalFeeNow
(
payPrice
);
request
.
setBuyType
(
BuyTypeEnum
.
PACK
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
queryWrapper
.
eq
(
Activity:
:
getPackId
,
roomLabel
.
getPackId
());
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
,
consumerMember
);
priceResponse
.
setTotalFeeNow
(
totalFee
);
priceResponse
.
setDiscount
(
totalFee
.
divide
(
payPrice
).
multiply
(
new
BigDecimal
(
100
)));
}
// totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, byId);
totalFee
=
getBigDecimal
(
consumerWallet
,
activity
,
timeLong
,
priceResponse
,
totalFee
,
byId
,
request
);
}
else
{
payPrice
=
totalPrice
;
priceResponse
.
setTotalFeeNow
(
payPrice
);
request
.
setBuyType
(
BuyTypeEnum
.
TIME
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
queryWrapper
.
eq
(
Activity:
:
getLabelId
,
roomLabel
.
getLabelId
());
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
,
consumerMember
);
priceResponse
.
setTotalFeeNow
(
totalFee
);
priceResponse
.
setDiscount
(
totalFee
.
divide
(
payPrice
).
multiply
(
new
BigDecimal
(
100
)));
}
// totalFee = getBigDecimal(consumerWallet, timeLong, priceResponse, totalFee, room);
totalFee
=
getBigDecimal
(
consumerWallet
,
activity
,
timeLong
,
priceResponse
,
totalFee
,
room
,
request
);
...
...
@@ -2274,11 +2292,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
else
if
(!
ObjectUtils
.
isEmpty
(
request
.
getPackId
()))
{
SPack
byId
=
packService
.
getById
(
request
.
getPackId
());
payPrice
=
computeTotalPrice
(
request
.
getPackId
(),
totalPrice
);
priceResponse
.
setTotalFeeNow
(
payPrice
);
request
.
setBuyType
(
BuyTypeEnum
.
PACK
.
getCode
());
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
queryWrapper
.
eq
(
Activity:
:
getPackId
,
request
.
getPackId
());
activity
=
activityService
.
getOne
(
queryWrapper
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
);
totalFee
=
getBigDecimal
(
request
,
activity
,
payPrice
,
user
,
consumerMember
);
priceResponse
.
setTotalFeeNow
(
totalFee
);
priceResponse
.
setDiscount
(
totalFee
.
divide
(
payPrice
).
multiply
(
new
BigDecimal
(
100
)));
}
totalFee
=
getBigDecimal
(
consumerWallet
,
activity
,
timeLong
,
priceResponse
,
totalFee
,
byId
,
request
);
}
...
...
@@ -2297,32 +2318,32 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
else
{
priceResponse
.
setDiscountRatio
(
priceResponse
.
getDiscountFee
().
divide
(
priceResponse
.
getTotalFee
(),
2
,
RoundingMode
.
HALF_UP
).
multiply
(
new
BigDecimal
(
100
)));
}
CronParser
cronParser
=
new
CronParser
(
CronDefinitionBuilder
.
instanceDefinitionFor
(
CronType
.
QUARTZ
));
if
(
ObjectUtil
.
isNotEmpty
(
activity
))
{
Cron
cron
=
cronParser
.
parse
(
activity
.
getCronExpression
());
ExecutionTime
executionTime
=
ExecutionTime
.
forCron
(
cron
);
boolean
match
=
executionTime
.
isMatch
(
ZonedDateTime
.
ofInstant
(
request
.
getPreStartDate
().
toInstant
(),
ZoneId
.
systemDefault
()));
boolean
match1
=
executionTime
.
isMatch
(
ZonedDateTime
.
ofInstant
(
request
.
getPreEndDate
().
toInstant
(),
ZoneId
.
systemDefault
()));
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
)
&&
!
match
&&
!
match1
)
{
MemberConfig
memberConfig
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>().
eq
(
MemberConfig:
:
getId
,
consumerMember
.
getMemberConfigId
()));
//总金额乘以折扣比例除以100
priceResponse
.
setPayFee
(
priceResponse
.
getPayFee
().
multiply
(
memberConfig
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
)));
priceResponse
.
setCouponFee
(
priceResponse
.
getDiscountFee
());
}
}
else
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
MemberConfig
memberConfig
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>().
eq
(
MemberConfig:
:
getId
,
consumerMember
.
getMemberConfigId
()));
//总金额乘以折扣比例除以100
priceResponse
.
setPayFee
(
priceResponse
.
getPayFee
().
multiply
(
memberConfig
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
)));
priceResponse
.
setDiscountFee
(
priceResponse
.
getTotalFee
().
subtract
(
priceResponse
.
getPayFee
()));
priceResponse
.
setCouponFee
(
priceResponse
.
getDiscountFee
());
if
(
ObjectUtil
.
isNotEmpty
(
priceResponse
.
getDiscountFee
())
&&
priceResponse
.
getTotalFee
().
compareTo
(
new
BigDecimal
(
0.00
))
>
0
)
{
priceResponse
.
setDiscountRatio
(
priceResponse
.
getDiscountFee
().
divide
(
priceResponse
.
getTotalFee
(),
2
,
RoundingMode
.
HALF_UP
).
multiply
(
new
BigDecimal
(
100
)));
}
else
{
priceResponse
.
setDiscountRatio
(
new
BigDecimal
(
0
));
}
}
}
//
CronParser cronParser = new CronParser(CronDefinitionBuilder.instanceDefinitionFor(CronType.QUARTZ));
//
if (ObjectUtil.isNotEmpty(activity)) {
//
Cron cron = cronParser.parse(activity.getCronExpression());
//
ExecutionTime executionTime = ExecutionTime.forCron(cron);
//
boolean match = executionTime.isMatch(ZonedDateTime.ofInstant(request.getPreStartDate().toInstant(), ZoneId.systemDefault()));
//
boolean match1 = executionTime.isMatch(ZonedDateTime.ofInstant(request.getPreEndDate().toInstant(), ZoneId.systemDefault()));
//
if (ObjectUtil.isNotEmpty(consumerMember) && !match && !match1) {
//
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getId, consumerMember.getMemberConfigId()));
//
//总金额乘以折扣比例除以100
//
priceResponse.setPayFee(priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100)));
////
priceResponse.setCouponFee(priceResponse.getDiscountFee());
//
}
//
} else {
//
if (ObjectUtil.isNotEmpty(consumerMember)) {
//
MemberConfig memberConfig = memberConfigService.getOne(new LambdaQueryWrapper<MemberConfig>().eq(MemberConfig::getId, consumerMember.getMemberConfigId()));
//
//总金额乘以折扣比例除以100
//
priceResponse.setPayFee(priceResponse.getPayFee().multiply(memberConfig.getDiscountRatio()).divide(new BigDecimal(100)));
//
priceResponse.setDiscountFee(priceResponse.getTotalFee().subtract(priceResponse.getPayFee()));
////
priceResponse.setCouponFee(priceResponse.getDiscountFee());
//
if (ObjectUtil.isNotEmpty(priceResponse.getDiscountFee()) && priceResponse.getTotalFee().compareTo(new BigDecimal(0.00)) > 0) {
//
priceResponse.setDiscountRatio(priceResponse.getDiscountFee().divide(priceResponse.getTotalFee(), 2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)));
//
} else {
//
priceResponse.setDiscountRatio(new BigDecimal(0));
//
}
//
}
//
}
priceResponse
.
setDiscountFee
(
priceResponse
.
getTotalFee
().
subtract
(
priceResponse
.
getPayFee
()));
if
(
ObjectUtil
.
isNotEmpty
(
priceResponse
.
getDiscountFee
())
&&
priceResponse
.
getTotalFee
().
compareTo
(
new
BigDecimal
(
0.00
))
>
0
)
{
priceResponse
.
setDiscountRatio
(
priceResponse
.
getDiscountFee
().
divide
(
priceResponse
.
getTotalFee
(),
2
,
RoundingMode
.
HALF_UP
).
multiply
(
new
BigDecimal
(
100
)));
...
...
@@ -2333,6 +2354,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// 判断优惠券是否可以使用
if
(
Objects
.
nonNull
(
user
)
&&
Objects
.
nonNull
(
request
.
getCouponId
()))
{
priceResponse
.
setTotalFee
(
payPrice
);
priceResponse
.
setTotalFeeNow
(
payPrice
);
SConsumerCoupon
consumerCoupon
=
consumerCouponService
.
getById
(
request
.
getCouponId
());
computedCouponPrice
(
request
,
priceResponse
,
user
,
consumerCoupon
);
priceResponse
.
setDuration
(
new
BigDecimal
(
0
));
...
...
@@ -2340,30 +2362,29 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse
.
setRemainingBalance
(
new
BigDecimal
(
0
));
priceResponse
.
setRemainingDuration
(
new
BigDecimal
(
0
));
if
(
priceResponse
.
getPayFee
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getPayFee
())
>=
0
)
{
priceResponse
.
setBalance
(
priceResponse
.
getPayFee
());
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
priceResponse
.
getPayFee
()));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getPayFee
())
<
0
)
{
priceResponse
.
setBalance
(
consumerWallet
.
getBalance
());
totalFee
=
priceResponse
.
getPayFee
().
subtract
(
consumerWallet
.
getBalance
());
}
priceResponse
.
setPayFee
(
totalFee
);
}
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
MemberConfig
memberConfig
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>().
eq
(
MemberConfig:
:
getId
,
consumerMember
.
getMemberConfigId
()));
//总金额乘以折扣比例除以100
priceResponse
.
setPayFee
(
priceResponse
.
getPayFee
().
multiply
(
memberConfig
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
)));
priceResponse
.
setDiscountFee
(
priceResponse
.
getTotalFee
().
subtract
(
priceResponse
.
getPayFee
()));
priceResponse
.
setCouponFee
(
priceResponse
.
getDiscountFee
());
//
priceResponse.setCouponFee(priceResponse.getDiscountFee());
if
(
ObjectUtil
.
isNotEmpty
(
priceResponse
.
getDiscountFee
())
&&
priceResponse
.
getTotalFee
().
compareTo
(
new
BigDecimal
(
0.00
))
>
0
)
{
priceResponse
.
setDiscountRatio
(
priceResponse
.
getDiscountFee
().
divide
(
priceResponse
.
getTotalFee
(),
2
,
RoundingMode
.
HALF_UP
).
multiply
(
new
BigDecimal
(
100
)));
}
else
{
priceResponse
.
setDiscountRatio
(
new
BigDecimal
(
0
));
}
}
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getPayFee
())
>=
0
)
{
priceResponse
.
setBalance
(
priceResponse
.
getPayFee
());
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
priceResponse
.
getPayFee
()));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getPayFee
())
<
0
)
{
priceResponse
.
setBalance
(
consumerWallet
.
getBalance
());
totalFee
=
priceResponse
.
getPayFee
().
subtract
(
consumerWallet
.
getBalance
());
}
priceResponse
.
setPayFee
(
totalFee
);
}
}
}
priceResponse
.
setDiscountFee
(
priceResponse
.
getTotalFee
().
subtract
(
priceResponse
.
getPayFee
()));
...
...
@@ -2404,7 +2425,8 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
else
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
<
0
)
{
priceResponse
.
setDuration
(
consumerWallet
.
getRemainingDuration
());
priceResponse
.
setRemainingDuration
(
new
BigDecimal
(
0
));
BigDecimal
remainingBalance
=
timeLong
.
subtract
(
consumerWallet
.
getRemainingDuration
()).
multiply
(
room
.
getPrice
());
BigDecimal
remainingBalance
=
consumerWallet
.
getRemainingDuration
().
multiply
(
room
.
getPrice
());
remainingBalance
=
priceResponse
.
getTotalFeeNow
().
subtract
(
remainingBalance
);
if
(
consumerWallet
.
getBalance
().
compareTo
(
remainingBalance
)
>=
0
)
{
priceResponse
.
setBalance
(
remainingBalance
);
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
remainingBalance
));
...
...
@@ -2423,7 +2445,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
else
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
<
0
)
{
priceResponse
.
setDuration
(
consumerWallet
.
getRemainingDuration
());
priceResponse
.
setRemainingDuration
(
new
BigDecimal
(
0
));
BigDecimal
remainingBalance
=
timeLong
.
subtract
(
consumerWallet
.
getRemainingDuration
()).
multiply
(
room
.
getPrice
());
BigDecimal
remainingBalance
=
consumerWallet
.
getRemainingDuration
().
multiply
(
room
.
getPrice
());
remainingBalance
=
priceResponse
.
getTotalFeeNow
().
subtract
(
remainingBalance
);
if
(
consumerWallet
.
getBalance
().
compareTo
(
remainingBalance
)
>=
0
)
{
priceResponse
.
setBalance
(
remainingBalance
);
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
remainingBalance
));
...
...
@@ -2466,14 +2490,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse
.
setRemainingDuration
(
consumerWallet
.
getRemainingDuration
().
subtract
(
timeLong
));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
<
0
)
{
if
(
consumerWallet
.
getBalance
().
compareTo
(
byId
.
getPrice
())
>=
0
)
{
priceResponse
.
setBalance
(
byId
.
getPrice
());
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
byId
.
getPrice
()));
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getTotalFeeNow
())
>=
0
)
{
priceResponse
.
setBalance
(
priceResponse
.
getTotalFeeNow
());
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
priceResponse
.
getTotalFeeNow
()));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
byId
.
getPrice
())
<
0
)
{
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getTotalFeeNow
())
<
0
)
{
priceResponse
.
setBalance
(
consumerWallet
.
getBalance
());
priceResponse
.
setRemainingBalance
(
new
BigDecimal
(
0
));
totalFee
=
byId
.
getPrice
().
subtract
(
consumerWallet
.
getBalance
());
totalFee
=
priceResponse
.
getTotalFeeNow
().
subtract
(
consumerWallet
.
getBalance
());
}
}
}
...
...
@@ -2483,14 +2507,14 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
priceResponse
.
setRemainingDuration
(
consumerWallet
.
getRemainingDuration
().
subtract
(
timeLong
));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
timeLong
)
<
0
)
{
if
(
consumerWallet
.
getBalance
().
compareTo
(
byId
.
getPrice
())
>=
0
)
{
priceResponse
.
setBalance
(
byId
.
getPrice
());
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
byId
.
getPrice
()));
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getTotalFeeNow
())
>=
0
)
{
priceResponse
.
setBalance
(
priceResponse
.
getTotalFeeNow
());
priceResponse
.
setRemainingBalance
(
consumerWallet
.
getBalance
().
subtract
(
priceResponse
.
getTotalFeeNow
()));
totalFee
=
new
BigDecimal
(
0
);
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
byId
.
getPrice
())
<
0
)
{
}
else
if
(
consumerWallet
.
getBalance
().
compareTo
(
priceResponse
.
getTotalFeeNow
())
<
0
)
{
priceResponse
.
setBalance
(
consumerWallet
.
getBalance
());
priceResponse
.
setRemainingBalance
(
new
BigDecimal
(
0
));
totalFee
=
byId
.
getPrice
().
subtract
(
consumerWallet
.
getBalance
());
totalFee
=
priceResponse
.
getTotalFeeNow
().
subtract
(
consumerWallet
.
getBalance
());
}
}
}
...
...
@@ -2498,8 +2522,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
return
totalFee
;
}
private
BigDecimal
getBigDecimal
(
OrderComputedPriceRequest
request
,
Activity
activity
,
BigDecimal
payPrice
,
SConsumer
user
)
{
if
(
ObjectUtil
.
isNotEmpty
(
activity
)
&&
ObjectUtil
.
isNotEmpty
(
user
))
{
private
BigDecimal
getBigDecimal
(
OrderComputedPriceRequest
request
,
Activity
activity
,
BigDecimal
payPrice
,
SConsumer
user
,
ConsumerMember
consumerMember
)
{
if
(
ObjectUtil
.
isNotEmpty
(
user
))
{
if
(
ObjectUtil
.
isNotEmpty
(
activity
))
{
CronParser
cronParser
=
new
CronParser
(
CronDefinitionBuilder
.
instanceDefinitionFor
(
CronType
.
QUARTZ
));
Cron
cron
=
cronParser
.
parse
(
activity
.
getCronExpression
());
ExecutionTime
executionTime
=
ExecutionTime
.
forCron
(
cron
);
...
...
@@ -2517,6 +2542,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
boolean
match1
=
executionTime
.
isMatch
(
ZonedDateTime
.
ofInstant
(
request
.
getPreEndDate
().
toInstant
(),
ZoneId
.
systemDefault
()));
if
(
match
&&
match1
)
{
payPrice
=
payPrice
.
multiply
(
activity
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
));
}
else
{
MemberConfig
memberConfig
=
memberConfigService
.
getById
(
consumerMember
.
getMemberConfigId
());
payPrice
=
payPrice
.
multiply
(
memberConfig
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
));
}
}
else
{
AtomicInteger
i
=
new
AtomicInteger
();
...
...
@@ -2532,8 +2560,13 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if
(
i
.
get
()
==
0
)
{
payPrice
=
payPrice
.
multiply
(
activity
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
));
}
else
{
return
payPrice
;
MemberConfig
memberConfig
=
memberConfigService
.
getById
(
consumerMember
.
getMemberConfigId
());
payPrice
=
payPrice
.
multiply
(
memberConfig
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
));
}
}
}
else
{
MemberConfig
memberConfig
=
memberConfigService
.
getById
(
consumerMember
.
getMemberConfigId
());
payPrice
=
payPrice
.
multiply
(
memberConfig
.
getDiscountRatio
()).
divide
(
new
BigDecimal
(
100
));
}
}
return
payPrice
;
...
...
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