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
793ec24d
Commit
793ec24d
authored
Sep 23, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化会员等级滚动降级定时任务
parent
1f1cc81f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
106 additions
and
104 deletions
+106
-104
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+106
-104
No files found.
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
793ec24d
...
...
@@ -344,110 +344,7 @@ public class RedisTask {
redisUtil
.
delete
(
o
);
throw
new
BaseException
(
"订单不存在!"
);
}
//查询是否有上级
LambdaQueryWrapper
<
SharingActivities
>
sharingActivitiesLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities:
:
getNewUid
,
sOrder
.
getConsumerId
());
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
SharingActivities
sharingActivities
=
sharingActivitiesService
.
getOne
(
sharingActivitiesLambdaQueryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
sharingActivities
))
{
//查询当前用户是否只有一个订单
LambdaQueryWrapper
<
SOrder
>
sOrderLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getConsumerId
,
sOrder
.
getConsumerId
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getPayStatus
,
YesNoEnum
.
yes
.
getIndex
());
sOrderLambdaQueryWrapper
.
notIn
(
SOrder:
:
getRefundStatus
,
RefundStatusEnum
.
getRefundedStatus
());
sOrderLambdaQueryWrapper
.
in
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
getValidOrderStatus
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
List
<
SOrder
>
sOrderList
=
isOrderService
.
list
(
sOrderLambdaQueryWrapper
);
if
(
sOrderList
.
size
()
==
1
)
{
LambdaQueryWrapper
<
ConsumerWallet
>
consumerWalletLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
consumerWalletLambdaQueryWrapper
.
eq
(
ConsumerWallet:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
consumerWalletLambdaQueryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
//添加时长
BigDecimal
anHour
=
new
BigDecimal
(
1.0
);
BigDecimal
accumulateEquityFund
=
ObjectUtil
.
isNotEmpty
(
consumerWallet
.
getRemainingDuration
())
?
consumerWallet
.
getRemainingDuration
()
:
BigDecimal
.
ZERO
;
consumerWallet
.
setRemainingDuration
(
accumulateEquityFund
.
add
(
anHour
));
consumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setVariableDuration
(
anHour
);
durationLog
.
setCurrentDuration
(
accumulateEquityFund
);
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setOperationTime
(
DateUtils
.
getNowDate
());
durationLogService
.
insertDurationLog
(
durationLog
);
consumerWalletService
.
updateConsumerWallet
(
consumerWallet
);
}
else
{
//新增钱包
ConsumerWallet
newConsumerWallet
=
new
ConsumerWallet
();
BigDecimal
defaultVlue
=
new
BigDecimal
(
0.0
);
newConsumerWallet
.
setConsumerId
(
sharingActivities
.
getUid
());
newConsumerWallet
.
setBalance
(
defaultVlue
);
newConsumerWallet
.
setRemainingIntegral
(
defaultVlue
);
newConsumerWallet
.
setEquityFund
(
defaultVlue
);
newConsumerWallet
.
setAccumulateEquityFund
(
defaultVlue
);
BigDecimal
anHour
=
new
BigDecimal
(
1.0
);
newConsumerWallet
.
setRemainingDuration
(
defaultVlue
.
add
(
anHour
));
newConsumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
consumerWalletService
.
insertConsumerWallet
(
newConsumerWallet
);
DurationLog
newDurationLog
=
new
DurationLog
();
newDurationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
newDurationLog
.
setVariableDuration
(
anHour
);
newDurationLog
.
setCurrentDuration
(
consumerWallet
.
getRemainingDuration
());
newDurationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
newDurationLog
.
setOperationTime
(
DateUtils
.
getNowDate
());
durationLogService
.
insertDurationLog
(
newDurationLog
);
}
}
//查询会员用户类型
LambdaQueryWrapper
<
ConsumerMember
>
consumerMemberWrapper
=
new
LambdaQueryWrapper
<>();
consumerMemberWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
consumerMemberWrapper
);
LambdaQueryWrapper
<
ConsumerMember
>
newConsumerMemberQueryWrapper
=
new
LambdaQueryWrapper
<>();
newConsumerMemberQueryWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getNewUid
());
ConsumerMember
newConsumerMember
=
consumerMemberService
.
getOne
(
newConsumerMemberQueryWrapper
);
if
(!(
ObjectUtils
.
isEmpty
(
newConsumerMember
))
&&
!(
ObjectUtils
.
isEmpty
(
consumerMember
)))
{
//判断是否为权益会员和会员是否有效
if
(
YesNoEnum
.
yes
.
getIndex
().
equals
(
consumerMember
.
getIsRights
())
&&
new
Date
().
getTime
()
<
consumerMember
.
getExpirationDate
().
getTime
()
&&
((
YesNoEnum
.
yes
.
getIndex
().
equals
(
newConsumerMember
.
getIsRights
())
&&
new
Date
().
getTime
()
<
newConsumerMember
.
getExpirationDate
().
getTime
())
||
(
newConsumerMember
.
getIsRecharge
().
equals
(
YesNoEnum
.
yes
.
getIndex
())))
)
{
Boolean
aBoolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
.
getValue
()
+
sharingActivities
.
getUid
().
toString
());
Boolean
newAboolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
.
getValue
()
+
sharingActivities
.
getNewUid
().
toString
());
if
(
aBoolean
&&
(
newAboolean
||
newConsumerMember
.
getIsRecharge
().
equals
(
YesNoEnum
.
yes
.
getIndex
())))
{
LambdaQueryWrapper
<
ConsumerWallet
>
consumerWalletLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
consumerWalletLambdaQueryWrapper
.
eq
(
ConsumerWallet:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
consumerWalletLambdaQueryWrapper
);
BigDecimal
payPrice
=
sOrder
.
getPayPrice
();
if
(
payPrice
.
signum
()
>
0
)
{
String
equityFund
=
sysConfigService
.
selectConfigByKey
(
"sys.equityFundLog.equityFund"
);
BigDecimal
addEquityFund
=
payPrice
.
multiply
(
new
BigDecimal
(
equityFund
)).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
// BigDecimal addEquityFund = new BigDecimal(99).multiply(new BigDecimal(equityFund)).setScale(2, RoundingMode.HALF_UP);
// BigDecimal aEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getEquityFund()) ? consumerWallet.getEquityFund() : BigDecimal.ZERO;
// consumerWallet.setEquityFund(aEquityFund.add(addEquityFund));
BigDecimal
accumulateEquityFund
=
ObjectUtil
.
isNotEmpty
(
consumerWallet
.
getAccumulateEquityFund
())
?
consumerWallet
.
getAccumulateEquityFund
()
:
BigDecimal
.
ZERO
;
consumerWallet
.
setAccumulateEquityFund
(
accumulateEquityFund
.
add
(
addEquityFund
));
consumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
consumerWalletService
.
updateConsumerWallet
(
consumerWallet
);
//添加临时权益金日志记录
String
equityFundExc
=
sysConfigService
.
selectConfigByKey
(
"sys.equityFundExcess.equityFundExcess"
);
EquityFundExcess
equityFundExcess
=
new
EquityFundExcess
();
equityFundExcess
.
setExpireTime
(
DateUtils
.
addDays
(
new
Date
(),
Integer
.
parseInt
(
equityFundExc
)));
equityFundExcess
.
setEquityFund
(
addEquityFund
);
equityFundExcess
.
setOutTradeNo
(
sOrder
.
getOrderNo
());
equityFundExcess
.
setUid
(
sharingActivities
.
getUid
());
equityFundExcess
.
setNewUid
(
sharingActivities
.
getNewUid
());
equityFundExcessService
.
insertEquityFundExcess
(
equityFundExcess
);
}
}
}
}
}
extracted
(
sOrder
);
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
//更改订单状态
sOrder
.
setStatus
(
OrderStatusEnum
.
USED
.
getCode
());
...
...
@@ -486,6 +383,111 @@ public class RedisTask {
logger
.
debug
(
"AutoAddSCleanRecords:自动添加保洁记录结束"
);
}
private
void
extracted
(
SOrder
sOrder
)
{
//查询是否有上级
LambdaQueryWrapper
<
SharingActivities
>
sharingActivitiesLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities:
:
getNewUid
,
sOrder
.
getConsumerId
());
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
SharingActivities
sharingActivities
=
sharingActivitiesService
.
getOne
(
sharingActivitiesLambdaQueryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
sharingActivities
))
{
//查询当前用户是否只有一个订单
LambdaQueryWrapper
<
SOrder
>
sOrderLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getConsumerId
,
sOrder
.
getConsumerId
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getPayStatus
,
YesNoEnum
.
yes
.
getIndex
());
sOrderLambdaQueryWrapper
.
notIn
(
SOrder:
:
getRefundStatus
,
RefundStatusEnum
.
getRefundedStatus
());
sOrderLambdaQueryWrapper
.
in
(
SOrder:
:
getStatus
,
OrderStatusEnum
.
getValidOrderStatus
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
List
<
SOrder
>
sOrderList
=
isOrderService
.
list
(
sOrderLambdaQueryWrapper
);
if
(
sOrderList
.
size
()
==
1
)
{
LambdaQueryWrapper
<
ConsumerWallet
>
consumerWalletLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
consumerWalletLambdaQueryWrapper
.
eq
(
ConsumerWallet:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
consumerWalletLambdaQueryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
//添加时长
BigDecimal
anHour
=
new
BigDecimal
(
1.0
);
BigDecimal
accumulateEquityFund
=
ObjectUtil
.
isNotEmpty
(
consumerWallet
.
getRemainingDuration
())
?
consumerWallet
.
getRemainingDuration
()
:
BigDecimal
.
ZERO
;
consumerWallet
.
setRemainingDuration
(
accumulateEquityFund
.
add
(
anHour
));
consumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setVariableDuration
(
anHour
);
durationLog
.
setCurrentDuration
(
accumulateEquityFund
);
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setOperationTime
(
DateUtils
.
getNowDate
());
durationLogService
.
insertDurationLog
(
durationLog
);
consumerWalletService
.
updateConsumerWallet
(
consumerWallet
);
}
else
{
//新增钱包
ConsumerWallet
newConsumerWallet
=
new
ConsumerWallet
();
BigDecimal
defaultVlue
=
new
BigDecimal
(
0.0
);
newConsumerWallet
.
setConsumerId
(
sharingActivities
.
getUid
());
newConsumerWallet
.
setBalance
(
defaultVlue
);
newConsumerWallet
.
setRemainingIntegral
(
defaultVlue
);
newConsumerWallet
.
setEquityFund
(
defaultVlue
);
newConsumerWallet
.
setAccumulateEquityFund
(
defaultVlue
);
BigDecimal
anHour
=
new
BigDecimal
(
1.0
);
newConsumerWallet
.
setRemainingDuration
(
defaultVlue
.
add
(
anHour
));
newConsumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
consumerWalletService
.
insertConsumerWallet
(
newConsumerWallet
);
DurationLog
newDurationLog
=
new
DurationLog
();
newDurationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
newDurationLog
.
setVariableDuration
(
anHour
);
newDurationLog
.
setCurrentDuration
(
consumerWallet
.
getRemainingDuration
());
newDurationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
newDurationLog
.
setOperationTime
(
DateUtils
.
getNowDate
());
durationLogService
.
insertDurationLog
(
newDurationLog
);
}
}
//查询会员用户类型
LambdaQueryWrapper
<
ConsumerMember
>
consumerMemberWrapper
=
new
LambdaQueryWrapper
<>();
consumerMemberWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
consumerMemberWrapper
);
LambdaQueryWrapper
<
ConsumerMember
>
newConsumerMemberQueryWrapper
=
new
LambdaQueryWrapper
<>();
newConsumerMemberQueryWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getNewUid
());
ConsumerMember
newConsumerMember
=
consumerMemberService
.
getOne
(
newConsumerMemberQueryWrapper
);
if
(!(
ObjectUtils
.
isEmpty
(
newConsumerMember
))
&&
!(
ObjectUtils
.
isEmpty
(
consumerMember
)))
{
//判断是否为权益会员和会员是否有效
if
(
YesNoEnum
.
yes
.
getIndex
().
equals
(
consumerMember
.
getIsRights
())
&&
new
Date
().
getTime
()
<
consumerMember
.
getExpirationDate
().
getTime
()
&&
((
YesNoEnum
.
yes
.
getIndex
().
equals
(
newConsumerMember
.
getIsRights
())
&&
new
Date
().
getTime
()
<
newConsumerMember
.
getExpirationDate
().
getTime
())
||
(
newConsumerMember
.
getIsRecharge
().
equals
(
YesNoEnum
.
yes
.
getIndex
())))
)
{
Boolean
aBoolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
.
getValue
()
+
sharingActivities
.
getUid
().
toString
());
Boolean
newAboolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
.
getValue
()
+
sharingActivities
.
getNewUid
().
toString
());
if
(
aBoolean
&&
(
newAboolean
||
newConsumerMember
.
getIsRecharge
().
equals
(
YesNoEnum
.
yes
.
getIndex
())))
{
LambdaQueryWrapper
<
ConsumerWallet
>
consumerWalletLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
consumerWalletLambdaQueryWrapper
.
eq
(
ConsumerWallet:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
consumerWalletLambdaQueryWrapper
);
BigDecimal
payPrice
=
sOrder
.
getPayPrice
();
if
(
payPrice
.
signum
()
>
0
)
{
String
equityFund
=
sysConfigService
.
selectConfigByKey
(
"sys.equityFundLog.equityFund"
);
BigDecimal
addEquityFund
=
payPrice
.
multiply
(
new
BigDecimal
(
equityFund
)).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
// BigDecimal addEquityFund = new BigDecimal(99).multiply(new BigDecimal(equityFund)).setScale(2, RoundingMode.HALF_UP);
// BigDecimal aEquityFund = ObjectUtil.isNotEmpty(consumerWallet.getEquityFund()) ? consumerWallet.getEquityFund() : BigDecimal.ZERO;
// consumerWallet.setEquityFund(aEquityFund.add(addEquityFund));
BigDecimal
accumulateEquityFund
=
ObjectUtil
.
isNotEmpty
(
consumerWallet
.
getAccumulateEquityFund
())
?
consumerWallet
.
getAccumulateEquityFund
()
:
BigDecimal
.
ZERO
;
consumerWallet
.
setAccumulateEquityFund
(
accumulateEquityFund
.
add
(
addEquityFund
));
consumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
consumerWalletService
.
updateConsumerWallet
(
consumerWallet
);
//添加临时权益金日志记录
String
equityFundExc
=
sysConfigService
.
selectConfigByKey
(
"sys.equityFundExcess.equityFundExcess"
);
EquityFundExcess
equityFundExcess
=
new
EquityFundExcess
();
equityFundExcess
.
setExpireTime
(
DateUtils
.
addDays
(
new
Date
(),
Integer
.
parseInt
(
equityFundExc
)));
equityFundExcess
.
setEquityFund
(
addEquityFund
);
equityFundExcess
.
setOutTradeNo
(
sOrder
.
getOrderNo
());
equityFundExcess
.
setUid
(
sharingActivities
.
getUid
());
equityFundExcess
.
setNewUid
(
sharingActivities
.
getNewUid
());
equityFundExcessService
.
insertEquityFundExcess
(
equityFundExcess
);
}
}
}
}
}
}
@XxlJob
(
"autoRoomExpireTime"
)
public
void
autoRoomExpireTime
()
{
logger
.
debug
(
"autoRoomExpireTime:房间15分钟续单开始"
);
...
...
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