记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
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
董敬伟
liquidnet-bus-v1
Commits
be04f1ef
Commit
be04f1ef
authored
Jul 05, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
非法途径 申请退款
下单接口增加锁
parent
7be6f7a1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
26 deletions
+24
-26
KylinOrderTicketsServiceImpl.java
...vice/kylin/service/impl/KylinOrderTicketsServiceImpl.java
+1
-2
KylinOrderTicketsServiceImpl.java
...vice/order/service/impl/KylinOrderTicketsServiceImpl.java
+23
-24
No files found.
liquidnet-bus-service/liquidnet-service-kylin/liquidnet-service-kylin-impl/src/main/java/com/liquidnet/service/kylin/service/impl/KylinOrderTicketsServiceImpl.java
View file @
be04f1ef
...
@@ -1148,14 +1148,13 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -1148,14 +1148,13 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
KylinOrderTicketVo
orderTicketVo
=
dataUtils
.
getOrderTicketVo
(
orderId
);
KylinOrderTicketVo
orderTicketVo
=
dataUtils
.
getOrderTicketVo
(
orderId
);
List
<
KylinOrderRefundsVo
>
kylinOrderRefundsVoBaseList
=
dataUtils
.
getOrderRefundVoByOrderId
(
orderTicketVo
.
getOrderTicketsId
());
List
<
KylinOrderRefundsVo
>
kylinOrderRefundsVoBaseList
=
dataUtils
.
getOrderRefundVoByOrderId
(
orderTicketVo
.
getOrderTicketsId
());
String
ticketId
=
orderTicketVo
.
getTicketId
();
if
(!
orderTicketVo
.
getUserId
().
equals
(
uid
))
{
if
(!
orderTicketVo
.
getUserId
().
equals
(
uid
))
{
return
"无权查看"
;
return
"无权查看"
;
}
}
if
(!
orderTicketVo
.
getPayStatus
().
equals
(
1
))
{
if
(!
orderTicketVo
.
getPayStatus
().
equals
(
1
))
{
return
"暂不支持退款"
;
return
"暂不支持退款"
;
}
}
or
KylinPerformanceVo
performanceVo
=
dataUtils
.
getPerformanceVo
(
orderTicketVo
.
getPerformanceId
());
KylinPerformanceVo
performanceVo
=
dataUtils
.
getPerformanceVo
(
orderTicketVo
.
getPerformanceId
());
KylinTicketVo
ticketVo
=
null
;
KylinTicketVo
ticketVo
=
null
;
...
...
liquidnet-bus-service/liquidnet-service-order/liquidnet-service-order-impl/src/main/java/com/liquidnet/service/order/service/impl/KylinOrderTicketsServiceImpl.java
View file @
be04f1ef
...
@@ -109,12 +109,11 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -109,12 +109,11 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
Long
currentTime
;
Long
currentTime
;
boolean
isDownGeneral
=
false
;
boolean
isDownGeneral
=
false
;
List
<
AdamEntersVo
>
entersVoList
=
new
ArrayList
<>();
List
<
AdamEntersVo
>
entersVoList
=
new
ArrayList
<>();
Long
startTime
=
System
.
currentTimeMillis
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
uid
=
CurrentUtil
.
getCurrentUid
();
String
lock
=
"userId:"
+
uid
;
String
lock
=
"userId:"
+
uid
;
//
if (!redisLockUtil.tryLock(lock, 1, 5)) {
if
(!
redisLockUtil
.
tryLock
(
lock
,
1
,
5
))
{
//
return ResponseDto.failure(ErrorMapping.get("20023"));//参数错误
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20023"
));
//参数错误
//
}
}
try
{
try
{
currentTime
=
System
.
currentTimeMillis
();
currentTime
=
System
.
currentTimeMillis
();
KylinPerformanceVo
performanceData
=
dataUtils
.
getPerformanceVo
(
payOrderParam
.
getPerformanceId
());
KylinPerformanceVo
performanceData
=
dataUtils
.
getPerformanceVo
(
payOrderParam
.
getPerformanceId
());
...
@@ -138,20 +137,20 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -138,20 +137,20 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
}
}
if
(
performanceData
==
null
||
ticketTimesData
==
null
||
ticketData
==
null
)
{
if
(
performanceData
==
null
||
ticketTimesData
==
null
||
ticketData
==
null
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20004"
));
//参数错误
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20004"
));
//参数错误
}
}
if
(!
ticketData
.
getTimeId
().
equals
(
payOrderParam
.
getTimeId
())
||
!
ticketTimesData
.
getPerformanceId
().
equals
(
payOrderParam
.
getPerformanceId
()))
{
if
(!
ticketData
.
getTimeId
().
equals
(
payOrderParam
.
getTimeId
())
||
!
ticketTimesData
.
getPerformanceId
().
equals
(
payOrderParam
.
getPerformanceId
()))
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20004"
));
//参数错误
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20004"
));
//参数错误
}
}
if
(
payOrderParam
.
getNumber
()
%
ticketData
.
getCounts
()
!=
0
)
{
if
(
payOrderParam
.
getNumber
()
%
ticketData
.
getCounts
()
!=
0
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20007"
));
//数量错误
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20007"
));
//数量错误
}
}
//判断代理
//判断代理
if
(!
checkAgent
(
payOrderParam
.
getAgentId
(),
ticketData
))
{
if
(!
checkAgent
(
payOrderParam
.
getAgentId
(),
ticketData
))
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20008"
));
//无权购买
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20008"
));
//无权购买
}
}
...
@@ -169,7 +168,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -169,7 +168,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
if
(
ticketData
.
getIsExclusive
()
==
1
)
{
if
(
ticketData
.
getIsExclusive
()
==
1
)
{
memberType
=
2
;
memberType
=
2
;
if
(!
isMember
)
{
if
(!
isMember
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20009"
));
//没有会员权限
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20009"
));
//没有会员权限
}
}
}
else
{
}
else
{
...
@@ -177,7 +176,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -177,7 +176,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
// 会员购买逻辑
// 会员购买逻辑
memberType
=
1
;
memberType
=
1
;
if
(!
isMember
)
{
if
(!
isMember
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20009"
));
//没有会员权限
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20009"
));
//没有会员权限
}
}
}
else
{
}
else
{
...
@@ -199,45 +198,45 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -199,45 +198,45 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
}
}
if
(!
canBuyStatus
.
contains
(
performanceData
.
getAppStatus
()))
{
if
(!
canBuyStatus
.
contains
(
performanceData
.
getAppStatus
()))
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20010"
));
//当前不可购买
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20010"
));
//当前不可购买
}
}
//通用判断时间
//通用判断时间
if
(
isMember
)
{
if
(
isMember
)
{
if
(
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
memberTimeStart
)
==
-
1
)
{
if
(
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
memberTimeStart
)
==
-
1
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20011"
));
//未开始
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20011"
));
//未开始
}
}
}
else
{
}
else
{
if
(
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
timeStart
)
==
-
1
)
{
if
(
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
timeStart
)
==
-
1
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20011"
));
//未开始
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20011"
));
//未开始
}
}
}
}
if
(
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
timeEnd
)
==
1
)
{
if
(
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
timeEnd
)
==
1
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20012"
));
//已结束
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20012"
));
//已结束
}
}
//快递票判断
//快递票判断
if
(
payOrderParam
.
getIsExpress
()
!=
null
)
{
if
(
payOrderParam
.
getIsExpress
()
!=
null
)
{
if
(
payOrderParam
.
getIsExpress
()
==
1
&&
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
timeExpressEnd
)
==
1
)
{
if
(
payOrderParam
.
getIsExpress
()
==
1
&&
DateUtil
.
compareStrDay
(
DateUtil
.
getNowTime
(),
timeExpressEnd
)
==
1
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20013"
));
//快递票不卖
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20013"
));
//快递票不卖
}
}
if
(
payOrderParam
.
getIsExpress
()
==
1
&&
payOrderParam
.
getAddressId
().
isEmpty
())
{
if
(
payOrderParam
.
getIsExpress
()
==
1
&&
payOrderParam
.
getAddressId
().
isEmpty
())
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20014"
));
//快递票未填写收货地址
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20014"
));
//快递票未填写收货地址
}
}
}
}
//实名判断
//实名判断
if
(
isTrueName
==
1
&&
payOrderParam
.
getEnterIdList
().
size
()
<=
0
)
{
if
(
isTrueName
==
1
&&
payOrderParam
.
getEnterIdList
().
size
()
<=
0
)
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20015"
));
//需要实名 未实名
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20015"
));
//需要实名 未实名
}
}
if
(
isTrueName
==
1
&&
payOrderParam
.
getEnterIdList
().
size
()
!=
payOrderParam
.
getNumber
())
{
if
(
isTrueName
==
1
&&
payOrderParam
.
getEnterIdList
().
size
()
!=
payOrderParam
.
getNumber
())
{
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20015"
));
//入场人数量错误
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20015"
));
//入场人数量错误
}
}
...
@@ -255,7 +254,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -255,7 +254,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
log
.
debug
(
"redis 修改库存 售罄 -> time:"
+
(
currentTime
)
+
"毫秒"
);
log
.
debug
(
"redis 修改库存 售罄 -> time:"
+
(
currentTime
)
+
"毫秒"
);
log
.
debug
(
"TAG_REDIS 售罄 回滚库存1 -> count:"
+
payOrderParam
.
getNumber
());
log
.
debug
(
"TAG_REDIS 售罄 回滚库存1 -> count:"
+
payOrderParam
.
getNumber
());
//
redisLockUtil.unlock(lock);
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20016"
));
//没抢到
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20016"
));
//没抢到
}
else
{
}
else
{
isDownGeneral
=
true
;
isDownGeneral
=
true
;
...
@@ -270,9 +269,9 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -270,9 +269,9 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
if
(
isStudent
==
1
)
{
if
(
isStudent
==
1
)
{
int
age
=
IDCard
.
getAgeByIdCard
(
adamEnters
.
getIdCard
());
int
age
=
IDCard
.
getAgeByIdCard
(
adamEnters
.
getIdCard
());
if
(
age
>
25
)
{
if
(
age
>
25
)
{
// redisLockUtil.unlock(lock);
dataUtils
.
changeSurplusGeneral
(
payOrderParam
.
getTicketId
(),
payOrderParam
.
getNumber
());
dataUtils
.
changeSurplusGeneral
(
payOrderParam
.
getTicketId
(),
payOrderParam
.
getNumber
());
log
.
debug
(
"TAG_REDIS 学生票 回滚库存2 -> count:"
+
payOrderParam
.
getNumber
());
log
.
debug
(
"TAG_REDIS 学生票 回滚库存2 -> count:"
+
payOrderParam
.
getNumber
());
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20017"
));
//年龄超了
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20017"
));
//年龄超了
}
}
}
}
...
@@ -288,9 +287,9 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -288,9 +287,9 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
String
res1
=
orderUtils
.
judgeOrderLimit
(
performanceData
.
getType
(),
uid
,
entersVoList
.
get
(
i
).
getIdCard
(),
payOrderParam
.
getPerformanceId
(),
payOrderParam
.
getTicketId
(),
performanceLimit
,
performanceMemberLimit
,
ticketLimit
,
ticketMemberLimit
,
1
,
1
,
memberType
,
isTrueName
);
String
res1
=
orderUtils
.
judgeOrderLimit
(
performanceData
.
getType
(),
uid
,
entersVoList
.
get
(
i
).
getIdCard
(),
payOrderParam
.
getPerformanceId
(),
payOrderParam
.
getTicketId
(),
performanceLimit
,
performanceMemberLimit
,
ticketLimit
,
ticketMemberLimit
,
1
,
1
,
memberType
,
isTrueName
);
log
.
debug
(
"redis 判断库存 -> time:"
+
(
currentTime
)
+
"毫秒"
);
log
.
debug
(
"redis 判断库存 -> time:"
+
(
currentTime
)
+
"毫秒"
);
if
(!
res1
.
equals
(
""
))
{
if
(!
res1
.
equals
(
""
))
{
// redisLockUtil.unlock(lock);
dataUtils
.
changeSurplusGeneral
(
payOrderParam
.
getTicketId
(),
payOrderParam
.
getNumber
());
dataUtils
.
changeSurplusGeneral
(
payOrderParam
.
getTicketId
(),
payOrderParam
.
getNumber
());
log
.
debug
(
"TAG_REDIS 限购 回滚库存3 -> count:"
+
payOrderParam
.
getNumber
());
log
.
debug
(
"TAG_REDIS 限购 回滚库存3 -> count:"
+
payOrderParam
.
getNumber
());
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
res1
);
//乱七八糟异常
return
ResponseDto
.
failure
(
res1
);
//乱七八糟异常
}
}
}
}
...
@@ -302,9 +301,9 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -302,9 +301,9 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
String
res1
=
orderUtils
.
judgeOrderLimit
(
performanceData
.
getType
(),
uid
,
""
,
payOrderParam
.
getPerformanceId
(),
payOrderParam
.
getTicketId
(),
performanceLimit
,
performanceMemberLimit
,
ticketLimit
,
ticketMemberLimit
,
payOrderParam
.
getNumber
(),
payOrderParam
.
getNumber
(),
memberType
,
isTrueName
);
String
res1
=
orderUtils
.
judgeOrderLimit
(
performanceData
.
getType
(),
uid
,
""
,
payOrderParam
.
getPerformanceId
(),
payOrderParam
.
getTicketId
(),
performanceLimit
,
performanceMemberLimit
,
ticketLimit
,
ticketMemberLimit
,
payOrderParam
.
getNumber
(),
payOrderParam
.
getNumber
(),
memberType
,
isTrueName
);
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
if
(!
res1
.
equals
(
""
))
{
if
(!
res1
.
equals
(
""
))
{
// redisLockUtil.unlock(lock);
dataUtils
.
changeSurplusGeneral
(
payOrderParam
.
getTicketId
(),
payOrderParam
.
getNumber
());
dataUtils
.
changeSurplusGeneral
(
payOrderParam
.
getTicketId
(),
payOrderParam
.
getNumber
());
log
.
debug
(
"TAG_REDIS 限购 回滚库存3 -> count:"
+
payOrderParam
.
getNumber
());
log
.
debug
(
"TAG_REDIS 限购 回滚库存3 -> count:"
+
payOrderParam
.
getNumber
());
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
res1
);
//乱七八糟异常
return
ResponseDto
.
failure
(
res1
);
//乱七八糟异常
}
}
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
currentTime
=
System
.
currentTimeMillis
()
-
currentTime
;
...
@@ -312,9 +311,8 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -312,9 +311,8 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
}
}
ResponseDto
<
PayResultVo
>
resultData
=
order
(
payOrderParam
,
uid
,
isMember
,
isTrueName
,
performanceData
,
ticketData
,
entersVoList
,
isStudent
,
ticketTimesData
,
currentTime
);
ResponseDto
<
PayResultVo
>
resultData
=
order
(
payOrderParam
,
uid
,
isMember
,
isTrueName
,
performanceData
,
ticketData
,
entersVoList
,
isStudent
,
ticketTimesData
,
currentTime
);
// redisLockUtil.unlock(lock);
isDownGeneral
=
false
;
isDownGeneral
=
false
;
log
.
debug
(
"总耗时 ->"
+
(
System
.
currentTimeMillis
()
-
startTime
)
+
"毫秒"
);
redisLockUtil
.
unlock
(
lock
);
return
resultData
;
return
resultData
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -335,6 +333,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
...
@@ -335,6 +333,7 @@ public class KylinOrderTicketsServiceImpl implements IKylinOrderTicketsService {
}
}
e
.
printStackTrace
();
e
.
printStackTrace
();
log
.
error
(
"Kylin Order Pay Error = "
+
e
.
getMessage
());
log
.
error
(
"Kylin Order Pay Error = "
+
e
.
getMessage
());
redisLockUtil
.
unlock
(
lock
);
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20018"
));
//乱七八糟异常
return
ResponseDto
.
failure
(
ErrorMapping
.
get
(
"20018"
));
//乱七八糟异常
}
}
}
}
...
...
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