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
4e26a05c
Commit
4e26a05c
authored
Sep 12, 2024
by
YG8429
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改权益会员绑定逻辑。权益会员返佣逻辑
parent
f5558b68
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
42 deletions
+128
-42
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+46
-34
CallbackServiceImpl.java
...n/java/share/system/service/impl/CallbackServiceImpl.java
+82
-7
SConsumerCenterServiceImpl.java
...share/system/service/impl/SConsumerCenterServiceImpl.java
+0
-1
No files found.
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
4e26a05c
...
...
@@ -120,6 +120,9 @@ public class RedisTask {
@Autowired
private
EquityFundLogService
equityFundLogService
;
@Autowired
private
DurationLogService
durationLogService
;
//15分钟的常量
final
long
FIFTEEN_MINUTES
=
60
*
15
;
...
...
@@ -337,32 +340,38 @@ public class RedisTask {
redisUtil
.
delete
(
o
);
throw
new
BaseException
(
"订单不存在!"
);
}
//查询当前用户是否只有一个订单
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
.
getUnfinishOrderStatus
());
sOrderLambdaQueryWrapper
.
eq
(
SOrder:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
List
<
SOrder
>
sOrderList
=
isOrderService
.
list
(
sOrderLambdaQueryWrapper
);
if
(
sOrderList
.
size
()
==
1
){
//查询是否有上级
LambdaQueryWrapper
<
SharingActivities
>
sharingActivitiesLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities
::
getNewUid
,
sOrder
.
getConsumerId
());
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities
::
getActivityType
,
"0"
);
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities
::
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
SharingActivities
sharingActivities
=
sharingActivitiesService
.
getOne
(
sharingActivitiesLambdaQueryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
sharingActivities
)){
//查询是否有上级
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
.
getUnfinishOrderStatus
());
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
)){
consumerWalletLambdaQueryWrapper
.
eq
(
ConsumerWallet:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
consumerWalletLambdaQueryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
//添加时长
BigDecimal
anHour
=
new
BigDecimal
(
1.0
);
consumerWallet
.
setRemainingDuration
(
consumerWallet
.
getRemainingDuration
().
add
(
anHour
));
consumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
consumerWalletService
.
updateConsumerWallet
(
consumerWallet
);
}
else
{
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setVariableDuration
(
anHour
);
durationLog
.
setCurrentDuration
(
consumerWallet
.
getRemainingDuration
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setOperationTime
(
DateUtils
.
getNowDate
());
durationLogService
.
insertDurationLog
(
durationLog
);
}
else
{
//新增钱包
ConsumerWallet
newConsumerWallet
=
new
ConsumerWallet
();
BigDecimal
defaultVlue
=
new
BigDecimal
(
0.0
);
...
...
@@ -375,24 +384,28 @@ public class RedisTask {
newConsumerWallet
.
setRemainingDuration
(
newConsumerWallet
.
getRemainingDuration
().
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
<
SharingActivities
>
sharingActivitiesLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities
::
getNewUid
,
sOrder
.
getConsumerId
());
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities
::
getActivityType
,
"1"
);
sharingActivitiesLambdaQueryWrapper
.
eq
(
SharingActivities
::
getIsDelete
,
YesNoEnum
.
no
.
getIndex
());
SharingActivities
sharingActivities
=
sharingActivitiesService
.
getOne
(
sharingActivitiesLambdaQueryWrapper
);
if
(
ObjectUtil
.
isNotEmpty
(
sharingActivities
)){
//查询会员用户类型
LambdaQueryWrapper
<
ConsumerMember
>
consumerMemberLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
consumerMemberLambdaQueryWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
consumerMemberLambdaQueryWrapper
);
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
.
getUid
());
ConsumerMember
newConsumerMember
=
consumerMemberService
.
getOne
(
newConsumerMemberQueryWrapper
);
//判断是否为权益会员和会员是否有效
if
(
"2"
.
equals
(
consumerMember
.
getMemberType
())
&&
new
Date
().
getTime
()
<
consumerMember
.
getExpirationDate
().
getTime
()
){
if
(
"2"
.
equals
(
consumerMember
.
getMemberType
())
&&
new
Date
().
getTime
()
<
consumerMember
.
getExpirationDate
().
getTime
()
&&
"2"
.
equals
(
newConsumerMember
.
getMemberType
())
&&
new
Date
().
getTime
()
<
newConsumerMember
.
getExpirationDate
().
getTime
())
{
Boolean
aBoolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
+
sharingActivities
.
getUid
().
toString
());
if
(
aBoolean
){
Boolean
newAboolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
+
sharingActivities
.
getNewUid
().
toString
());
if
(
aBoolean
&&
newAboolean
)
{
LambdaQueryWrapper
<
ConsumerWallet
>
consumerWalletLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
consumerWalletLambdaQueryWrapper
.
eq
(
ConsumerWallet:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
consumerWalletLambdaQueryWrapper
);
...
...
@@ -426,7 +439,6 @@ public class RedisTask {
}
}
}
}
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
...
...
share-system/src/main/java/share/system/service/impl/CallbackServiceImpl.java
View file @
4e26a05c
...
...
@@ -470,7 +470,7 @@ public class CallbackServiceImpl implements CallbackService {
wechatInfo
.
setTradeStateDesc
(
"支付成功"
);
wechatPayInfoService
.
updateById
(
wechatInfo
);
//新增权益金日志
addEquityFundLog
(
recharge
.
getConsumerId
(),
addEquityFundLog
Recharge
(
recharge
.
getConsumerId
(),
recharge
.
getRechargeAmount
(),
recharge
.
getOutTradeNo
(),
recharge
.
getTerminalTrace
(),
"0"
);
aFalse
=
Boolean
.
TRUE
;
}
catch
(
Exception
e
)
{
...
...
@@ -552,7 +552,7 @@ public class CallbackServiceImpl implements CallbackService {
equityPayInfo
.
setTradeStateDesc
(
"支付成功"
);
wechatPayInfoService
.
updateById
(
equityPayInfo
);
//新增权益金日志
addEquityFundLog
(
equityMembersOrder
.
getConsumerId
(),
addEquityFundLog
Rights
(
equityMembersOrder
.
getConsumerId
(),
equityMembersOrder
.
getPayPrice
(),
equityMembersOrder
.
getEquityOrderNo
(),
equityMembersOrder
.
getTerminalTrace
(),
"1"
);
aBoolean
=
Boolean
.
TRUE
;
}
catch
(
Exception
e
)
{
...
...
@@ -765,7 +765,7 @@ public class CallbackServiceImpl implements CallbackService {
* @param terminalTrace 终端流水号
* @param type 权益类型
*/
private
void
addEquityFundLog
(
Long
consumerId
,
BigDecimal
payPrice
,
String
equityOrderNo
,
String
terminalTrace
,
String
type
)
{
private
void
addEquityFundLog
Recharge
(
Long
consumerId
,
BigDecimal
payPrice
,
String
equityOrderNo
,
String
terminalTrace
,
String
type
)
{
//查询是否有上级
SharingActivities
sharingActivities
=
sharingActivitiesService
.
getOne
(
new
LambdaQueryWrapper
<
SharingActivities
>()
.
eq
(
SharingActivities:
:
getNewUid
,
consumerId
)
...
...
@@ -774,12 +774,12 @@ public class CallbackServiceImpl implements CallbackService {
if
(
ObjectUtil
.
isNotEmpty
(
sharingActivities
))
{
//查询会员用户类型
LambdaQueryWrapper
<
ConsumerMember
>
consumerMemberLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
consumerMemberLambdaQueryWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
consumerMemberLambdaQueryWrapper
);
consumerMemberLambdaQueryWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
consumerMemberLambdaQueryWrapper
);
//判断是否为权益会员和会员是否有效
if
(
"2"
.
equals
(
consumerMember
.
getMemberType
())
&&
new
Date
().
getTime
()
<
consumerMember
.
getExpirationDate
().
getTime
()
)
{
if
(
"2"
.
equals
(
consumerMember
.
getMemberType
())
&&
new
Date
().
getTime
()
<
consumerMember
.
getExpirationDate
().
getTime
()
)
{
Boolean
aBoolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
+
sharingActivities
.
getUid
().
toString
());
if
(
aBoolean
){
if
(
aBoolean
)
{
String
equityFund
=
sysConfigService
.
selectConfigByKey
(
"sys.equityFundLog.equityFund"
);
//查询上级用户是否有钱包
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerWallet
>()
...
...
@@ -826,6 +826,81 @@ public class CallbackServiceImpl implements CallbackService {
}
}
}
/**
* 新增权益金日志
* @param consumerId 用户ID
* @param payPrice 消费金额
* @param equityOrderNo 订单编号
* @param terminalTrace 终端流水号
* @param type 权益类型
*/
private
void
addEquityFundLogRights
(
Long
consumerId
,
BigDecimal
payPrice
,
String
equityOrderNo
,
String
terminalTrace
,
String
type
)
{
//查询是否有上级
SharingActivities
sharingActivities
=
sharingActivitiesService
.
getOne
(
new
LambdaQueryWrapper
<
SharingActivities
>()
.
eq
(
SharingActivities:
:
getNewUid
,
consumerId
)
.
eq
(
SharingActivities:
:
getIsDelete
,
YesNoEnum
.
no
.
getIndex
()));
if
(
ObjectUtil
.
isNotEmpty
(
sharingActivities
))
{
//查询会员用户类型
LambdaQueryWrapper
<
ConsumerMember
>
consumerMemberWrapper
=
new
LambdaQueryWrapper
<>();
consumerMemberWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
consumerMemberWrapper
);
LambdaQueryWrapper
<
ConsumerMember
>
newConsumerMemberWrapper
=
new
LambdaQueryWrapper
<>();
newConsumerMemberWrapper
.
eq
(
ConsumerMember:
:
getConsumerId
,
sharingActivities
.
getUid
());
ConsumerMember
newConsumerMember
=
consumerMemberService
.
getOne
(
newConsumerMemberWrapper
);
//判断是否为权益会员和会员是否有效
if
(
"2"
.
equals
(
consumerMember
.
getMemberType
())
&&
new
Date
().
getTime
()
<
consumerMember
.
getExpirationDate
().
getTime
()
&&
"2"
.
equals
(
newConsumerMember
.
getMemberType
())
&&
new
Date
().
getTime
()
<
newConsumerMember
.
getExpirationDate
().
getTime
())
{
Boolean
aBoolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
+
sharingActivities
.
getUid
().
toString
());
Boolean
newAboolean
=
redisTemplate
.
hasKey
(
ReceiptRdeisEnum
.
EQUITY_MEMBERS_TIME
+
sharingActivities
.
getNewUid
().
toString
());
if
(
aBoolean
&&
newAboolean
)
{
String
equityFund
=
sysConfigService
.
selectConfigByKey
(
"sys.equityFundLog.equityFund"
);
//查询上级用户是否有钱包
ConsumerWallet
consumerWallet
=
consumerWalletService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerWallet
>()
.
eq
(
ConsumerWallet:
:
getConsumerId
,
sharingActivities
.
getUid
()));
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
consumerWallet
.
setEquityFund
(
consumerWallet
.
getEquityFund
().
add
(
payPrice
.
multiply
(
new
BigDecimal
(
equityFund
))));
consumerWallet
.
setAccumulateEquityFund
(
consumerWallet
.
getAccumulateEquityFund
().
add
(
payPrice
.
multiply
(
new
BigDecimal
(
equityFund
))));
consumerWallet
.
setUpdateTime
(
DateUtils
.
getNowDate
());
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
.
setRemainingDuration
(
defaultVlue
);
newConsumerWallet
.
setEquityFund
(
consumerWallet
.
getEquityFund
().
add
(
payPrice
.
multiply
(
new
BigDecimal
(
equityFund
).
setScale
(
2
,
RoundingMode
.
HALF_UP
))));
newConsumerWallet
.
setAccumulateEquityFund
(
consumerWallet
.
getAccumulateEquityFund
()
.
add
(
payPrice
.
multiply
(
new
BigDecimal
(
equityFund
).
setScale
(
2
,
RoundingMode
.
HALF_UP
))));
consumerWalletService
.
insertConsumerWallet
(
newConsumerWallet
);
}
//添加权益金日志记录
//下级用户
SConsumer
newConsumer
=
consumerService
.
getById
(
consumerId
);
//上级用户
SConsumer
consumer
=
consumerService
.
getById
(
sharingActivities
.
getUid
());
EquityFundLog
equityFundLog
=
new
EquityFundLog
();
equityFundLog
.
setEquityFund
(
payPrice
.
multiply
(
new
BigDecimal
(
equityFund
).
setScale
(
2
,
RoundingMode
.
HALF_UP
)));
equityFundLog
.
setEquityFundType
(
type
);
equityFundLog
.
setOutTradeNo
(
equityOrderNo
);
equityFundLog
.
setTerminalTrace
(
terminalTrace
);
equityFundLog
.
setUid
(
sharingActivities
.
getUid
());
equityFundLog
.
setNewUid
(
sharingActivities
.
getNewUid
());
equityFundLog
.
setPhone
(
consumer
.
getPhone
());
equityFundLog
.
setAccount
(
consumer
.
getAccount
());
equityFundLog
.
setNickName
(
consumer
.
getNickName
());
equityFundLog
.
setNewPhone
(
newConsumer
.
getPhone
());
equityFundLog
.
setNewAccount
(
newConsumer
.
getAccount
());
equityFundLog
.
setNewNickName
(
newConsumer
.
getNickName
());
equityFundLogService
.
insertEquityFundLog
(
equityFundLog
);
}
}
}
}
/**
* 支付订单回调通知
...
...
share-system/src/main/java/share/system/service/impl/SConsumerCenterServiceImpl.java
View file @
4e26a05c
...
...
@@ -313,7 +313,6 @@ public class SConsumerCenterServiceImpl extends ServiceImpl<SConsumerMapper, SCo
if
(
uid
!=
null
){
//添加绑定关系
SharingActivities
sharingActivities
=
new
SharingActivities
();
sharingActivities
.
setActivityType
(
request
.
getActivityType
());
sharingActivities
.
setUid
(
uid
);
sharingActivities
.
setNewUid
(
id
);
sharingActivities
.
setCreateTime
(
DateUtils
.
getNowDate
());
...
...
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