记得上下班打卡 | 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
b51483f4
Commit
b51483f4
authored
Jun 25, 2021
by
胡佳晨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 mq 消费回滚限购
parent
23685fcf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
50 deletions
+60
-50
KylinUtils.java
.../liquidnet/service/consumer/service/Utils/KylinUtils.java
+60
-50
No files found.
liquidnet-bus-service/liquidnet-service-consumer/src/main/java/com/liquidnet/service/consumer/service/Utils/KylinUtils.java
View file @
b51483f4
...
@@ -20,6 +20,7 @@ public class KylinUtils {
...
@@ -20,6 +20,7 @@ public class KylinUtils {
@Autowired
@Autowired
private
RedisUtil
redisUtil
;
private
RedisUtil
redisUtil
;
/**
/**
* @param userId 用户id
* @param userId 用户id
* @param type 1新增 2修改
* @param type 1新增 2修改
...
@@ -31,13 +32,13 @@ public class KylinUtils {
...
@@ -31,13 +32,13 @@ public class KylinUtils {
KylinOrderListVo
voItem
=
new
KylinOrderListVo
();
KylinOrderListVo
voItem
=
new
KylinOrderListVo
();
KylinOrderTicketVo
data
;
KylinOrderTicketVo
data
;
if
(
dataSingle
==
null
)
{
if
(
dataSingle
==
null
)
{
data
=
(
KylinOrderTicketVo
)
redisUtil
.
get
(
KylinRedisConst
.
ORDER
+
orderId
);
data
=
(
KylinOrderTicketVo
)
redisUtil
.
get
(
KylinRedisConst
.
ORDER
+
orderId
);
}
else
{
}
else
{
data
=
dataSingle
;
data
=
dataSingle
;
}
}
BeanUtils
.
copyProperties
(
data
,
voItem
);
BeanUtils
.
copyProperties
(
data
,
voItem
);
List
<
KylinOrderListVo
>
redisData
=
(
List
<
KylinOrderListVo
>)
redisUtil
.
get
(
KylinRedisConst
.
ORDER_LIST
+
userId
);
List
<
KylinOrderListVo
>
redisData
=
(
List
<
KylinOrderListVo
>)
redisUtil
.
get
(
KylinRedisConst
.
ORDER_LIST
+
userId
);
if
(
type
==
1
)
{
if
(
type
==
1
)
{
redisVo
.
add
(
voItem
);
redisVo
.
add
(
voItem
);
if
(
redisData
.
size
()
>
0
)
{
if
(
redisData
.
size
()
>
0
)
{
if
(
redisData
.
get
(
0
).
getOrderTicketsId
().
equals
(
orderId
))
{
if
(
redisData
.
get
(
0
).
getOrderTicketsId
().
equals
(
orderId
))
{
...
@@ -63,7 +64,7 @@ public class KylinUtils {
...
@@ -63,7 +64,7 @@ public class KylinUtils {
if
(
redisVo
.
size
()
==
0
)
{
if
(
redisVo
.
size
()
==
0
)
{
vo
.
add
(
voItem
);
vo
.
add
(
voItem
);
}
}
redisUtil
.
set
(
KylinRedisConst
.
ORDER_LIST
+
userId
,
vo
);
redisUtil
.
set
(
KylinRedisConst
.
ORDER_LIST
+
userId
,
vo
);
return
true
;
return
true
;
case
2
:
case
2
:
for
(
int
i
=
0
;
i
<
redisVo
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
redisVo
.
size
();
i
++)
{
...
@@ -76,7 +77,7 @@ public class KylinUtils {
...
@@ -76,7 +77,7 @@ public class KylinUtils {
vo
.
add
(
redisVo
.
get
(
i
));
vo
.
add
(
redisVo
.
get
(
i
));
}
}
}
}
redisUtil
.
set
(
KylinRedisConst
.
ORDER_LIST
+
userId
,
vo
);
redisUtil
.
set
(
KylinRedisConst
.
ORDER_LIST
+
userId
,
vo
);
return
true
;
return
true
;
default
:
default
:
return
false
;
return
false
;
...
@@ -116,56 +117,65 @@ public class KylinUtils {
...
@@ -116,56 +117,65 @@ public class KylinUtils {
String
ticketIdKey
=
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
ticketId
;
String
ticketIdKey
=
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
ticketId
;
String
ticketUseTimeKey
=
ticketIdKey
+
":"
+
KylinRedisConst
.
USE_TIME
;
String
ticketUseTimeKey
=
ticketIdKey
+
":"
+
KylinRedisConst
.
USE_TIME
;
redisUtil
.
set
(
ticketUseTimeKey
,
useTime
);
redisUtil
.
set
(
ticketUseTimeKey
,
useTime
);
if
(
buyCount
>
0
)
{
if
(
buyCount
>
0
)
{
redisUtil
.
incr
(
ticketIdKey
,
buyCount
);
redisUtil
.
incr
(
ticketIdKey
,
buyCount
);
if
(
1
==
ticketType
)
{
int
count
=
0
;
for
(
int
i
=
0
;
i
<
allTicketId
.
get
(
useTime
).
size
();
i
++)
{
String
item
=
allTicketId
.
get
(
useTime
).
get
(
i
);
if
(
allTicketId
.
get
(
useTime
).
size
()
==
1
)
{
redisUtil
.
incr
(
performanceIdKey
,
buyCount
);
break
;
}
if
(
null
==
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
redisUtil
.
set
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
,
0
);
}
if
(
i
==
0
)
{
count
=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
);
}
else
{
if
(
count
!=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
redisUtil
.
incr
(
performanceIdKey
,
buyCount
);
redisUtil
.
incr
(
performanceIdKey
,
buyCount
);
break
;
}
}
}
}
else
{
redisUtil
.
incr
(
performanceIdKey
,
buyCount
);
}
}
else
{
}
else
{
redisUtil
.
decr
(
ticketIdKey
,
Math
.
abs
(
buyCount
));
redisUtil
.
decr
(
ticketIdKey
,
Math
.
abs
(
buyCount
));
if
(
1
==
ticketType
)
{
int
count
=
0
;
for
(
int
i
=
0
;
i
<
allTicketId
.
get
(
useTime
).
size
();
i
++)
{
String
item
=
allTicketId
.
get
(
useTime
).
get
(
i
);
if
(
allTicketId
.
get
(
useTime
).
size
()
==
1
)
{
redisUtil
.
decr
(
performanceIdKey
,
Math
.
abs
(
buyCount
));
redisUtil
.
decr
(
performanceIdKey
,
Math
.
abs
(
buyCount
));
break
;
}
if
(
null
==
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
redisUtil
.
set
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
,
0
);
}
if
(
i
==
0
)
{
count
=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
);
}
else
{
if
(
count
!=
(
int
)
redisUtil
.
get
(
redisKey
+
":"
+
KylinRedisConst
.
TICKET_ID
+
":"
+
item
))
{
redisUtil
.
decr
(
performanceIdKey
,
Math
.
abs
(
buyCount
));
break
;
}
}
}
}
else
{
redisUtil
.
decr
(
performanceIdKey
,
Math
.
abs
(
buyCount
));
}
}
}
// if (buyCount > 0) {
// redisUtil.incr(ticketIdKey, buyCount);
// if (1 == ticketType) {
// int count = 0;
// for (int i = 0; i < allTicketId.get(useTime).size(); i++) {
// String item = allTicketId.get(useTime).get(i);
// if (allTicketId.get(useTime).size() == 1) {
// redisUtil.incr(performanceIdKey, buyCount);
// break;
// }
// if (null == redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.set(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item, 0);
// }
// if (i == 0) {
// count = (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item);
// } else {
// if (count != (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.incr(performanceIdKey, buyCount);
// break;
// }
// }
// }
// } else {
// redisUtil.incr(performanceIdKey, buyCount);
// }
// } else {
// redisUtil.decr(ticketIdKey, Math.abs(buyCount));
// if (1 == ticketType) {
// int count = 0;
// for (int i = 0; i < allTicketId.get(useTime).size(); i++) {
// String item = allTicketId.get(useTime).get(i);
// if (allTicketId.get(useTime).size() == 1) {
// redisUtil.decr(performanceIdKey, Math.abs(buyCount));
// break;
// }
// if (null == redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.set(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item, 0);
// }
// if (i == 0) {
// count = (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item);
// } else {
// if (count != (int) redisUtil.get(redisKey + ":" + KylinRedisConst.TICKET_ID + ":" + item)) {
// redisUtil.decr(performanceIdKey, Math.abs(buyCount));
// break;
// }
// }
// }
// } else {
// redisUtil.decr(performanceIdKey, Math.abs(buyCount));
// }
// }
}
}
}
}
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