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
892480d0
Commit
892480d0
authored
Jun 12, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
订单增加30秒锁定
parent
09801629
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
0 deletions
+18
-0
Constants.java
...common/src/main/java/share/common/constant/Constants.java
+2
-0
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+16
-0
No files found.
share-common/src/main/java/share/common/constant/Constants.java
View file @
892480d0
...
...
@@ -26,6 +26,8 @@ public class Constants
public
static
final
String
ORDER_AUTO_CANCEL_KEY
=
"order_auto_cancel_key"
;
// 订单锁定Key
public
static
final
String
ORDER_LOCK_KEY
=
"order_lock_key"
;
//订单锁定
public
static
final
String
ORDER_LOCK_KEY_PREFIX
=
"order_lock_key_prefix:"
;
//测试环境,经测试需要,手机验证码测试环境可以不需要就能登录,value为1,则不验证验证码
public
static
final
String
PHONE_TEST_KEY
=
"phone_test_key"
;
//通过uuid缓存的key 查找对应的 token数据 WX_TOKEN_USER:TOKEN
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
892480d0
...
...
@@ -801,6 +801,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
public
OrderPayResultResponse
createOrder
(
CreateOrderRequest
request
)
{
String
lockResult
=
""
;
try
{
lockOrder
(
request
.
getRoomId
());
lockResult
=
lockOrder
(
request
);
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
if
(
ObjectUtil
.
isNull
(
user
))
{
...
...
@@ -926,6 +927,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map
.
put
(
"expirationTime"
,
sOrder
.
getEndDate
().
toString
());
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
sOrder
.
getOrderNo
(),
jsonObject
.
toString
());
unLockOrder
(
request
.
getRoomId
());
}
if
(
response
.
getStatus
().
equals
(
YesNoEnum
.
yes
.
getFlag
()))
{
if
(
Objects
.
nonNull
(
byId
))
{
...
...
@@ -943,6 +945,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
JSONObject
jsonObject
=
new
JSONObject
(
map
);
if
(
sOrder
.
getOrderType
().
equals
(
OrderTypeEnum
.
RESERVER
.
getCode
()))
{
redisUtil
.
set
(
ReceiptRdeisEnum
.
ORDER_NO
.
getValue
()
+
sOrder
.
getOrderNo
(),
jsonObject
.
toString
());
unLockOrder
(
request
.
getRoomId
());
}
// 订单预定成功, 发送短信通知运维客服
List
<
String
>
phones
=
new
ArrayList
<>();
...
...
@@ -966,6 +969,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
throw
e
;
}
finally
{
unLockOrder
(
request
,
lockResult
);
unLockOrder
(
request
.
getRoomId
());
}
}
...
...
@@ -987,12 +991,22 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
private
void
lockOrder
(
Long
roomId
)
{
if
(
redisUtil
.
exists
(
Constants
.
ORDER_LOCK_KEY_PREFIX
+
roomId
))
{
throw
new
BaseException
(
"当前房间下单太火爆了,请稍后再试!"
);
}
redisUtil
.
set
(
Constants
.
ORDER_LOCK_KEY_PREFIX
+
roomId
,
roomId
,
Long
.
valueOf
(
Constants
.
ROOM_LOCK_DELAY_MINUTE
));
}
private
void
unLockOrder
(
CreateOrderRequest
request
,
String
keyValue
)
{
if
(
StringUtils
.
isNotBlank
(
keyValue
))
{
redisUtil
.
unLock
(
Constants
.
ORDER_LOCK_KEY
+
request
.
getRoomId
(),
keyValue
,
2
);
}
}
private
void
unLockOrder
(
Long
roomId
)
{
redisUtil
.
delete
(
Constants
.
ORDER_LOCK_KEY_PREFIX
+
roomId
);
}
private
void
checkOrderPack
(
CreateOrderRequest
request
,
SConsumer
user
)
{
if
(
Objects
.
nonNull
(
request
.
getPackId
())
&&
request
.
getPackId
()
>
0
)
{
//判断是否首次订单套餐
...
...
@@ -1332,6 +1346,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
map
.
put
(
"expirationTime"
,
date
.
toString
());
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
ORDER_CANCEL_PAY
.
getValue
()
+
orderNo
,
jsonObject
.
toString
());
unLockOrder
(
selectSOrderByOrderNo
(
orderNo
).
getRoomId
());
return
true
;
}
...
...
@@ -1390,6 +1405,7 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Override
public
void
paymentSuccessful
(
SOrder
sOrder
)
{
unLockOrder
(
sOrder
.
getRoomId
());
if
(
sOrder
.
getOrderType
().
equals
(
OrderTypeEnum
.
RENEW
.
getCode
()))
{
SRoom
room
=
roomService
.
getById
(
sOrder
.
getRoomId
());
if
(
room
.
getStatus
().
equals
(
RoomStatusEnum
.
FREE
.
getValue
()))
{
...
...
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