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
56eade07
Commit
56eade07
authored
Oct 11, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into test
parents
6b86b2dd
5bbff7b3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
13 deletions
+85
-13
pom.xml
share-common/pom.xml
+2
-0
RedisLockUtil.java
...ommon/src/main/java/share/common/utils/RedisLockUtil.java
+75
-0
QPServiceImpl.java
...rc/main/java/share/system/service/impl/QPServiceImpl.java
+0
-0
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+8
-4
TiktokServiceImpl.java
...ain/java/share/system/service/impl/TiktokServiceImpl.java
+0
-0
share.iml
share.iml
+0
-9
No files found.
share-common/pom.xml
View file @
56eade07
...
...
@@ -176,6 +176,7 @@
<artifactId>
xstream
</artifactId>
<version>
1.4.9
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
share-common/src/main/java/share/common/utils/RedisLockUtil.java
0 → 100644
View file @
56eade07
package
share
.
common
.
utils
;
import
org.springframework.data.redis.core.RedisCallback
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.Objects
;
/**
* @ClassName RedisLockUtil
* @Description 使用redis做锁
* @Author Wangyujie
* @Version V1.1.0
*/
@Component
public
class
RedisLockUtil
{
@Resource
RedisTemplate
<
String
,
Object
>
redisTemplate
;
/**
* 获取锁Key
*
* @param prefix 前缀
* @param name 名称
* @return
*/
public
static
String
getFullKey
(
String
prefix
,
String
name
)
{
return
prefix
+
"_"
+
name
;
}
/**
* 获取锁,true 则得到锁,false 已被锁定
*
* @param lockName 锁名称
* @param lockExoire 锁时间毫秒
* @return
*/
public
Boolean
getLock
(
String
lockName
,
Integer
lockExoire
)
{
return
(
Boolean
)
redisTemplate
.
execute
((
RedisCallback
<?>)
connection
->
{
// 获取时间毫秒值
long
expireAt
=
System
.
currentTimeMillis
()
+
lockExoire
+
1
;
// 获取锁
Boolean
acquire
=
connection
.
setNX
(
lockName
.
getBytes
(),
String
.
valueOf
(
expireAt
).
getBytes
());
if
(
acquire
)
{
return
true
;
}
else
{
byte
[]
bytes
=
connection
.
get
(
lockName
.
getBytes
());
// 非空判断
if
(
Objects
.
nonNull
(
bytes
)
&&
bytes
.
length
>
0
)
{
long
expireTime
=
Long
.
parseLong
(
new
String
(
bytes
));
// 如果锁已经过期
if
(
expireTime
<
System
.
currentTimeMillis
())
{
// 重新加锁,防止死锁
byte
[]
set
=
connection
.
getSet
(
lockName
.
getBytes
(),
String
.
valueOf
(
System
.
currentTimeMillis
()
+
lockExoire
+
1
).
getBytes
());
return
Long
.
parseLong
(
new
String
(
set
))
<
System
.
currentTimeMillis
();
}
}
}
return
false
;
});
}
/**
* 删除锁
*
* @param lockName
*/
public
void
delLock
(
String
lockName
)
{
redisTemplate
.
delete
(
lockName
);
}
}
share-system/src/main/java/share/system/service/impl/QPServiceImpl.java
View file @
56eade07
This diff is collapsed.
Click to expand it.
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
56eade07
...
...
@@ -2304,12 +2304,11 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
// }
// 是否满足退款
boolean
isRefunds
;
SConsumerCoupon
coupon
=
null
;
if
(
ObjectUtil
.
isNotNull
(
sOrder
.
getCouponId
()))
{
SConsumerCoupon
coupon
=
consumerCouponService
.
getById
(
sOrder
.
getCouponId
());
coupon
=
consumerCouponService
.
getById
(
sOrder
.
getCouponId
());
// 判断是否可以退款
isRefunds
=
isRefund
(
sOrder
,
coupon
);
coupon
.
setUseStatus
(
UserStatusEnum
.
UNUSED
.
getCode
());
consumerCouponService
.
updateById
(
coupon
);
}
else
{
// 判断是否可以退款
isRefunds
=
isRefund
(
sOrder
,
null
);
...
...
@@ -2375,8 +2374,13 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
//微信退款
// if (sOrder.getPayType().equals(PayTypeEnum.WECHAT.getCode()) && request.getAmount().compareTo(BigDecimal.ZERO) == 0) {
// 退款task, 定时任务退优惠券
redisUtil
.
lPush
(
Constants
.
ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER
,
sOrder
.
getId
());
//
redisUtil.lPush(Constants.ORDER_TASK_REDIS_KEY_AFTER_REFUND_BY_USER, sOrder.getId());
// }
// 退优惠券
if
(
coupon
!=
null
)
{
coupon
.
setUseStatus
(
UserStatusEnum
.
UNUSED
.
getCode
());
consumerCouponService
.
updateById
(
coupon
);
}
execute
=
Boolean
.
TRUE
;
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
toString
());
...
...
share-system/src/main/java/share/system/service/impl/TiktokServiceImpl.java
View file @
56eade07
This diff is collapsed.
Click to expand it.
share.iml
deleted
100644 → 0
View file @
6b86b2dd
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"AdditionalModuleElements"
>
<content
url=
"file://$MODULE_DIR$"
dumb=
"true"
>
<excludeFolder
url=
"file://$MODULE_DIR$/target"
/>
</content>
</component>
</module>
\ No newline at end of file
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