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
203d7cb3
Commit
203d7cb3
authored
Feb 04, 2024
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单、房间状态监控及修正
parent
56290163
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
OrderTask.java
share-quartz/src/main/java/share/quartz/task/OrderTask.java
+54
-0
No files found.
share-quartz/src/main/java/share/quartz/task/OrderTask.java
View file @
203d7cb3
...
@@ -3,9 +3,11 @@ package share.quartz.task;
...
@@ -3,9 +3,11 @@ package share.quartz.task;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateField
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bouncycastle.util.Store
;
import
org.bouncycastle.util.Store
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -313,4 +315,56 @@ public class OrderTask {
...
@@ -313,4 +315,56 @@ public class OrderTask {
}
}
}
}
/**
* 订单状态因未知原因导致时间结束未完成的,修改订单状态
* 房间状态因未知原因导致未有使用中订单而占用的,修改房间状态
*/
public
void
orderCompensate
()
{
// 订单状态处理
LambdaQueryWrapper
<
SOrder
>
queryWrapper
=
new
LambdaQueryWrapper
();
queryWrapper
.
le
(
SOrder:
:
getEndDate
,
DateUtil
.
offset
(
DateUtil
.
date
(),
DateField
.
MINUTE
,
-
5
));
queryWrapper
.
in
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
UNUSED
.
getCode
(),
OrderStatusEnum
.
INUSE
.
getCode
());
queryWrapper
.
eq
(
SOrder:
:
getPayStatus
,
1
);
List
<
SOrder
>
orders
=
orderService
.
list
(
queryWrapper
);
if
(
orders
!=
null
&&
orders
.
size
()
>
0
)
{
orders
.
forEach
(
order
->
{
order
.
setStatus
(
OrderStatusEnum
.
USED
.
getCode
());
order
.
setUpdateTime
(
new
Date
());
});
}
Boolean
execute
=
transactionTemplate
.
execute
(
e
->
{
orderService
.
updateBatchById
(
orders
,
orders
.
size
());
return
true
;
});
if
(
execute
)
{
// 房间状态处理
LambdaQueryWrapper
<
SRoom
>
queryRoomWrapper
=
new
LambdaQueryWrapper
();
queryRoomWrapper
.
ne
(
SRoom:
:
getStatus
,
RoomStatusEnum
.
HOLD
.
getValue
());
List
<
SRoom
>
rooms
=
roomService
.
list
(
queryRoomWrapper
);
if
(
rooms
!=
null
&&
rooms
.
size
()
>
0
)
{
List
<
Long
>
roomIds
=
rooms
.
stream
().
map
(
SRoom:
:
getId
).
collect
(
Collectors
.
toList
());
// 房间使用中订单
LambdaQueryWrapper
<
SOrder
>
queryOrderWrapper
=
new
LambdaQueryWrapper
();
queryOrderWrapper
.
eq
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
INUSE
.
getCode
());
queryOrderWrapper
.
in
(
SOrder:
:
getRoomId
,
roomIds
);
queryOrderWrapper
.
eq
(
SOrder:
:
getPayStatus
,
1
);
List
<
SOrder
>
orderList
=
orderService
.
list
(
queryOrderWrapper
);
Map
<
Long
,
List
<
SOrder
>>
sOrderMap
=
Optional
.
ofNullable
(
orderList
).
orElse
(
new
ArrayList
<>()).
stream
().
collect
(
Collectors
.
groupingBy
(
SOrder:
:
getRoomId
));
List
<
SRoom
>
roomList
=
new
ArrayList
<>();
rooms
.
forEach
(
room
->
{
if
(
sOrderMap
.
get
(
room
.
getId
())
==
null
||
sOrderMap
.
get
(
room
.
getId
()).
size
()
==
0
)
{
room
.
setStatus
(
RoomStatusEnum
.
FREE
.
getValue
());
room
.
setUpdateTime
(
new
Date
());
roomList
.
add
(
room
);
}
});
Boolean
execute2
=
transactionTemplate
.
execute
(
e
->
{
roomService
.
updateBatchById
(
roomList
,
roomList
.
size
());
return
true
;
});
}
}
}
}
}
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