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
e3d95941
Commit
e3d95941
authored
Jul 22, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
会员进度日志表增加过期时间
parent
f677c315
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
34 deletions
+97
-34
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+71
-3
MemberProgressLog.java
.../src/main/java/share/system/domain/MemberProgressLog.java
+5
-20
ConsumerWalletServiceImpl.java
.../share/system/service/impl/ConsumerWalletServiceImpl.java
+15
-11
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+0
-0
MemberProgressLogMapper.xml
.../main/resources/mapper/system/MemberProgressLogMapper.xml
+6
-0
No files found.
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
e3d95941
...
...
@@ -24,6 +24,7 @@ import share.common.constant.MqttConstants;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.*
;
import
share.common.exception.base.BaseException
;
import
share.common.utils.DateUtils
;
import
share.system.domain.*
;
import
share.system.domain.vo.MqttxVo
;
import
share.system.service.*
;
...
...
@@ -92,6 +93,15 @@ public class RedisTask {
@Autowired
private
SConsumerTokenService
sConsumerTokenService
;
@Autowired
private
ConsumerMemberService
consumerMemberService
;
@Autowired
private
ConsumerWalletService
consumerWalletService
;
@Autowired
private
MemberProgressLogService
memberProgressLogService
;
//15分钟的常量
final
long
FIFTEEN_MINUTES
=
60
*
15
;
...
...
@@ -103,8 +113,8 @@ public class RedisTask {
final
long
FOUR_MINUTES
=
60
*
4
;
//1分钟的常量
final
long
ONE_MINUTES
=
60
;
final
long
FOUR_DAY
=
60
*
24
*
4
;
final
long
THREE_DAY
=
60
*
24
*
3
;
final
long
TWO_DAY
=
60
*
24
*
2
;
/**
...
...
@@ -459,7 +469,7 @@ public class RedisTask {
});
}
public
void
AutoEquityMembers
()
{
public
void
AutoEquityMembers
Sms
()
{
Set
<
String
>
keys
=
redisTemplate
.
keys
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
+
"*"
);
if
(
keys
.
size
()
==
0
)
{
return
;
...
...
@@ -471,13 +481,71 @@ public class RedisTask {
Long
consumerId
=
jsonObject
.
getLong
(
"consumerId"
);
//判断当前的日期是否在第3天和第2天中
long
expire
=
(
expirationTime
.
getTime
()
-
new
Date
().
getTime
())
/
1000
/
60
/
60
;
if
(
T
WO_DAY
<
expire
&&
expire
<
THREE
_DAY
)
{
if
(
T
HREE_DAY
<
expire
&&
expire
<
FOUR
_DAY
)
{
SConsumer
sConsumer
=
sConsumerService
.
getById
(
consumerId
);
logger
.
debug
(
"手机号为:{}的用户年度权益会员将在3天后失效"
,
sConsumer
.
getPhone
());
smsService
.
sendOneSms
(
sConsumer
.
getPhone
(),
"年度权益会员将在3天后失效,请及时续约保障权益会员的权益"
);
}
});
}
//权益会员降级
public
void
AutoUpdateEquityMembers
()
{
Set
<
String
>
keys
=
redisTemplate
.
keys
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
+
"*"
);
if
(
keys
.
size
()
==
0
)
{
return
;
}
keys
.
stream
().
forEach
(
key
->
{
String
value
=
redisUtil
.
get
(
String
.
valueOf
(
key
));
JSONObject
jsonObject
=
new
JSONObject
(
value
);
Date
expirationTime
=
jsonObject
.
getDate
(
"expirationTime"
);
Long
consumerId
=
jsonObject
.
getLong
(
"consumerId"
);
if
(
expirationTime
.
getTime
()
<
new
Date
().
getTime
())
{
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerWallet
>().
eq
(
ConsumerWallet:
:
getConsumerId
,
consumerId
));
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
consumerId
));
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
consumerMember
.
setMemberType
(
MemberTypeEnum
.
RECHARGE
.
getIndex
());
}
else
{
consumerMember
.
setMemberType
(
MemberTypeEnum
.
NORMAL
.
getIndex
());
}
consumerMemberService
.
updateConsumerMember
(
consumerMember
);
}
});
}
public
void
AutoProgressLog
()
{
//查询1年之前的数据
List
<
MemberProgressLog
>
list
=
memberProgressLogService
.
list
(
new
LambdaQueryWrapper
<
MemberProgressLog
>()
.
gt
(
MemberProgressLog:
:
getCreateTime
,
DateUtils
.
addYears
(
new
Date
(),
-
1
))
);
list
.
sort
(
Comparator
.
comparing
(
MemberProgressLog:
:
getOperationType
).
reversed
());
//获得list的consumerId
List
<
Long
>
consumerIds
=
list
.
stream
().
map
(
MemberProgressLog:
:
getConsumerId
).
distinct
().
collect
(
Collectors
.
toList
());
//按照consumerId进行分组
Map
<
Long
,
List
<
MemberProgressLog
>>
collect
=
list
.
stream
().
collect
(
Collectors
.
groupingBy
(
MemberProgressLog:
:
getConsumerId
));
consumerIds
.
stream
().
forEach
(
item
->
{
List
<
MemberProgressLog
>
memberProgressLogs
=
collect
.
get
(
item
);
if
(
memberProgressLogs
.
size
()
>
1
)
{
final
BigDecimal
[]
sum
=
{
new
BigDecimal
(
100
)};
memberProgressLogs
.
stream
().
forEach
(
log
->
{
if
(
log
.
getOperationType
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
sum
[
0
]
=
sum
[
0
].
subtract
(
log
.
getVariableProgress
());
}
else
if
(
log
.
getOperationType
().
equals
(
YesNoEnum
.
no
.
getIndex
()))
{
sum
[
0
]
=
sum
[
0
].
add
(
log
.
getVariableProgress
());
}
});
sum
[
0
].
subtract
(
new
BigDecimal
(
100
));
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
item
));
if
(
consumerMember
.
getMembershipProgress
().
compareTo
(
sum
[
0
])
>=
0
)
{
consumerMember
.
setMembershipProgress
(
consumerMember
.
getMembershipProgress
().
subtract
(
sum
[
0
]));
consumerMemberService
.
updateConsumerMember
(
consumerMember
);
}
}
});
}
public
void
AutoAddRoomLabel
()
{
List
<
RoomLabel
>
roomLabelList
=
roomLabelService
.
list
();
//获取roomLabelList中的roomId,去重
...
...
share-system/src/main/java/share/system/domain/MemberProgressLog.java
View file @
e3d95941
...
...
@@ -3,8 +3,6 @@ package share.system.domain;
import
com.baomidou.mybatisplus.annotation.*
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
share.common.annotation.Excel
;
import
share.common.core.domain.BaseEntity
;
...
...
@@ -59,6 +57,11 @@ public class MemberProgressLog extends BaseEntity {
@Excel
(
name
=
"操作时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
operationTime
;
//过期时间
@JsonFormat
(
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
@Excel
(
name
=
"过期时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd"
)
private
Date
expirationTime
;
/**
* 是否删除
*/
...
...
@@ -67,22 +70,4 @@ public class MemberProgressLog extends BaseEntity {
@TableField
(
select
=
false
)
private
Long
isDelete
;
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
.
append
(
"id"
,
getId
())
.
append
(
"consumerId"
,
getConsumerId
())
.
append
(
"variableProgress"
,
getVariableProgress
())
.
append
(
"currentProgress"
,
getCurrentProgress
())
.
append
(
"operationType"
,
getOperationType
())
.
append
(
"operationTime"
,
getOperationTime
())
.
append
(
"isDelete"
,
getIsDelete
())
.
append
(
"createBy"
,
getCreateBy
())
.
append
(
"createTime"
,
getCreateTime
())
.
append
(
"updateBy"
,
getUpdateBy
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"remark"
,
getRemark
())
.
toString
();
}
}
share-system/src/main/java/share/system/service/impl/ConsumerWalletServiceImpl.java
View file @
e3d95941
...
...
@@ -129,6 +129,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
@Override
public
boolean
addConsumerWallet
(
ConsumerWallet
consumerWallet
)
{
int
i
=
consumerWalletMapper
.
insertConsumerWallet
(
consumerWallet
);
ConsumerMember
one
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
consumerWallet
.
getConsumerId
()));
MemberConfig
memberConfig
=
memberConfigService
.
getById
(
one
.
getMemberConfigId
());
if
(
consumerWallet
.
getBalance
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
...
...
@@ -165,6 +167,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
memberProgressLog
.
setOperationTime
(
new
Date
());
memberProgressLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
memberProgressLog
.
setCreateTime
(
new
Date
());
memberProgressLog
.
setExpirationTime
(
DateUtils
.
addYears
(
new
Date
(),
memberConfig
.
getValidityPeriod
().
intValue
()));
memberProgressLogService
.
save
(
memberProgressLog
);
}
return
i
==
1
;
...
...
@@ -194,7 +197,18 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
}
int
i
=
updateConsumerWallet
(
consumerWallet
);
//查询当前会员类型和下一级的会员配置
MemberConfig
memberConfigServiceOne
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMemberType
,
one
.
getMemberType
())
.
eq
(
MemberConfig:
:
getMembershipLevel
,
one
.
getMembershipLevel
()
+
1L
));
if
(
ObjectUtil
.
isNotEmpty
(
memberConfigServiceOne
))
{
//判断是否升级
if
(
one
.
getMembershipProgress
().
compareTo
(
BigDecimal
.
valueOf
(
memberConfigServiceOne
.
getLimitRequirements
()))
>=
0
)
{
one
.
setMembershipLevel
(
one
.
getMembershipLevel
()
+
1L
);
one
.
setMemberConfigId
(
one
.
getId
());
}
}
if
(
consumerWallet
.
getBalance
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
...
...
@@ -234,21 +248,11 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
memberProgressLog
.
setOperationTime
(
new
Date
());
memberProgressLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
memberProgressLog
.
setCreateTime
(
new
Date
());
memberProgressLog
.
setExpirationTime
(
DateUtils
.
addYears
(
new
Date
(),
memberConfigService
.
getById
(
one
.
getConsumerId
()).
getValidityPeriod
().
intValue
()));
memberProgressLogService
.
save
(
memberProgressLog
);
one
.
setMembershipProgress
(
one
.
getMembershipProgress
().
add
(
divide
));
}
//查询当前会员类型和下一级的会员配置
MemberConfig
memberConfigServiceOne
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMemberType
,
one
.
getMemberType
())
.
eq
(
MemberConfig:
:
getMembershipLevel
,
one
.
getMembershipLevel
()
+
1L
));
if
(
ObjectUtil
.
isNotEmpty
(
memberConfigServiceOne
))
{
//判断是否升级
if
(
one
.
getMembershipProgress
().
compareTo
(
BigDecimal
.
valueOf
(
memberConfigServiceOne
.
getLimitRequirements
()))
>=
0
)
{
one
.
setMembershipLevel
(
one
.
getMembershipLevel
()
+
1L
);
one
.
setMemberConfigId
(
one
.
getId
());
}
}
consumerMemberService
.
updateConsumerMember
(
one
);
return
i
==
1
;
}
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
e3d95941
This diff is collapsed.
Click to expand it.
share-system/src/main/resources/mapper/system/MemberProgressLogMapper.xml
View file @
e3d95941
...
...
@@ -14,6 +14,7 @@
<result
property=
"currentProgress"
column=
"current_progress"
/>
<result
property=
"operationType"
column=
"operation_type"
/>
<result
property=
"operationTime"
column=
"operation_time"
/>
<result
property=
"expirationTime"
column=
"expiration_time"
/>
<result
property=
"isDelete"
column=
"is_delete"
/>
<result
property=
"createBy"
column=
"create_by"
/>
<result
property=
"createTime"
column=
"create_time"
/>
...
...
@@ -29,6 +30,7 @@
current_progress,
operation_type,
operation_time,
expiration_time,
is_delete,
create_by,
create_time,
...
...
@@ -48,6 +50,7 @@
m.current_progress,
m.operation_type,
m.operation_time,
m.expiration_time,
m.is_delete,
m.create_by,
m.create_time,
...
...
@@ -82,6 +85,7 @@
<if
test=
"currentProgress != null"
>
current_progress,
</if>
<if
test=
"operationType != null"
>
operation_type,
</if>
<if
test=
"operationTime != null"
>
operation_time,
</if>
<if
test=
"expirationTime != null"
>
expiration_time,
</if>
<if
test=
"isDelete != null"
>
is_delete,
</if>
<if
test=
"createBy != null"
>
create_by,
</if>
<if
test=
"createTime != null"
>
create_time,
</if>
...
...
@@ -95,6 +99,7 @@
<if
test=
"currentProgress != null"
>
#{currentProgress},
</if>
<if
test=
"operationType != null"
>
#{operationType},
</if>
<if
test=
"operationTime != null"
>
#{operationTime},
</if>
<if
test=
"expirationTime != null"
>
#{expirationTime},
</if>
<if
test=
"isDelete != null"
>
#{isDelete},
</if>
<if
test=
"createBy != null"
>
#{createBy},
</if>
<if
test=
"createTime != null"
>
#{createTime},
</if>
...
...
@@ -112,6 +117,7 @@
<if
test=
"currentProgress != null"
>
current_progress = #{currentProgress},
</if>
<if
test=
"operationType != null"
>
operation_type = #{operationType},
</if>
<if
test=
"operationTime != null"
>
operation_time = #{operationTime},
</if>
<if
test=
"expirationTime != null"
>
expiration_time = #{expirationTime},
</if>
<if
test=
"isDelete != null"
>
is_delete = #{isDelete},
</if>
<if
test=
"createBy != null"
>
create_by = #{createBy},
</if>
<if
test=
"createTime != null"
>
create_time = #{createTime},
</if>
...
...
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