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
682ca036
Commit
682ca036
authored
Jul 31, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改会员等级逻辑
parent
0c2521ea
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
67 deletions
+85
-67
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+30
-9
ConsumerMember.java
...tem/src/main/java/share/system/domain/ConsumerMember.java
+10
-21
Recharge.java
share-system/src/main/java/share/system/domain/Recharge.java
+12
-29
EquityMembersOrderServiceImpl.java
...re/system/service/impl/EquityMembersOrderServiceImpl.java
+1
-0
RechargeServiceImpl.java
...n/java/share/system/service/impl/RechargeServiceImpl.java
+16
-0
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+16
-8
No files found.
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
682ca036
...
...
@@ -25,6 +25,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.*
;
...
...
@@ -508,14 +509,20 @@ public class RedisTask {
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
));
consumerMember
.
setIsRight
(
YesNoEnum
.
no
.
getIndex
());
if
(
ObjectUtil
.
isNotEmpty
(
consumerMember
))
{
if
(
ObjectUtil
.
isNotEmpty
(
consumerWallet
))
{
if
(
consumerMember
.
getIsRecharge
().
equals
(
YesNoEnum
.
yes
.
getIndex
()
))
{
consumerMember
.
setMemberType
(
MemberTypeEnum
.
RECHARGE
.
getIndex
());
}
else
{
consumerMember
.
setMemberType
(
MemberTypeEnum
.
NORMAL
.
getIndex
());
}
MemberConfig
memberConfigServiceOne
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMemberType
,
consumerMember
.
getMemberType
())
.
eq
(
MemberConfig:
:
getMembershipLevel
,
consumerMember
.
getMembershipLevel
())
);
consumerMember
.
setMemberConfigId
(
memberConfigServiceOne
.
getId
());
consumerMember
.
setExpirationDate
(
DateUtils
.
addYears
(
new
Date
(),
memberConfigServiceOne
.
getValidityPeriod
().
intValue
()));
consumerMemberService
.
updateConsumerMember
(
consumerMember
);
}
redisUtil
.
delete
(
key
);
...
...
@@ -539,20 +546,28 @@ public class RedisTask {
consumerIds
.
stream
().
forEach
(
item
->
{
List
<
MemberProgressLog
>
memberProgressLogs
=
collect
.
get
(
item
);
if
(
memberProgressLogs
.
size
()
>
0
)
{
//查询会员
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
item
));
//查询会员配置
MemberConfig
memberConfig
=
memberConfigService
.
getById
(
consumerMember
.
getMemberConfigId
());
final
BigDecimal
[]
sum
=
{
BigDecimal
.
ZERO
};
//计算扣除进度
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
());
}
else
if
(
log
.
getOperationType
().
equals
(
YesNoEnum
.
no
.
getIndex
()))
{
sum
[
0
]
=
sum
[
0
].
subtract
(
log
.
getVariableProgress
());
}
});
ConsumerMember
consumerMember
=
consumerMemberService
.
getOne
(
new
LambdaQueryWrapper
<
ConsumerMember
>().
eq
(
ConsumerMember:
:
getConsumerId
,
item
));
MemberConfig
memberConfig
=
memberConfigService
.
getById
(
consumerMember
.
getMemberConfigId
());
if
(
consumerMember
.
getMembershipProgress
().
compareTo
(
sum
[
0
])
>=
0
)
{
//判断会员进度是否大于扣除进度
if
(
consumerMember
.
getMembershipProgress
().
compareTo
(
sum
[
0
])
>
0
)
{
//会员进度减去扣除进度
BigDecimal
subtract
=
consumerMember
.
getMembershipProgress
().
subtract
(
sum
[
0
]);
consumerMember
.
setMembershipProgress
(
subtract
);
if
(
subtract
.
compareTo
(
BigDecimal
.
valueOf
(
memberConfig
.
getLimitRequirements
()))
<
0
)
{
//等级降一级
if
(
consumerMember
.
getMembershipLevel
()
>
0L
)
{
consumerMember
.
setMembershipLevel
(
memberConfig
.
getMembershipLevel
()
-
1
);
MemberConfig
memberConfigServiceOne
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMemberType
,
consumerMember
.
getMemberType
())
...
...
@@ -560,10 +575,16 @@ public class RedisTask {
);
consumerMember
.
setMemberConfigId
(
memberConfigServiceOne
.
getId
());
}
}
else
{
}
}
else
if
(
consumerMember
.
getMembershipProgress
().
compareTo
(
sum
[
0
])
==
0
)
{
consumerMember
.
setMembershipProgress
(
BigDecimal
.
ZERO
);
consumerMember
.
setMembershipLevel
(
0L
);
consumerMember
.
setMemberType
(
MemberTypeEnum
.
NORMAL
.
getIndex
());
MemberConfig
memberConfigServiceOne
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMemberType
,
consumerMember
.
getMemberType
())
.
eq
(
MemberConfig:
:
getMembershipLevel
,
consumerMember
.
getMembershipLevel
())
);
consumerMember
.
setMemberConfigId
(
memberConfigServiceOne
.
getId
());
}
consumerMemberService
.
updateConsumerMember
(
consumerMember
);
}
...
...
share-system/src/main/java/share/system/domain/ConsumerMember.java
View file @
682ca036
...
...
@@ -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
;
...
...
@@ -66,6 +64,16 @@ public class ConsumerMember extends BaseEntity {
private
BigDecimal
membershipProgress
;
/**
* 是否为充值
*/
private
Integer
isRecharge
;
/**
* 是否为权益
*/
private
Integer
isRight
;
/**
* 是否删除
*/
//逻辑删除注解(0 未删除 1 已删除)
...
...
@@ -73,23 +81,4 @@ public class ConsumerMember 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
(
"membershipLevel"
,
getMembershipLevel
())
.
append
(
"memberType"
,
getMemberType
())
.
append
(
"memberConfigId"
,
getMemberConfigId
())
.
append
(
"expirationDate"
,
getExpirationDate
())
.
append
(
"membershipProgress"
,
getMembershipProgress
())
.
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/domain/Recharge.java
View file @
682ca036
...
...
@@ -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
;
...
...
@@ -53,6 +51,18 @@ public class Recharge extends BaseEntity {
private
BigDecimal
giveAmount
;
/**
* 充值赠送时长
*/
@Excel
(
name
=
"充值赠送时长"
)
private
BigDecimal
giveDuration
;
/**
* 充值赠送积分
*/
@Excel
(
name
=
"充值赠送积分"
)
private
BigDecimal
giveIntegral
;
/**
* 充值赠送方式;1-不送,2-送金额,3-送优惠券,4-送金额及优惠券
*/
@Excel
(
name
=
"充值赠送方式;1-不送,2-送金额,3-送优惠券,4-送金额及优惠券"
)
...
...
@@ -122,31 +132,4 @@ public class Recharge extends BaseEntity {
@Excel
(
name
=
"支付时间"
,
width
=
30
,
dateFormat
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
payTime
;
@Override
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
.
append
(
"id"
,
getId
())
.
append
(
"rechargeNo"
,
getRechargeNo
())
.
append
(
"rechargeAmount"
,
getRechargeAmount
())
.
append
(
"payType"
,
getPayType
())
.
append
(
"giveAmount"
,
getGiveAmount
())
.
append
(
"giveType"
,
getGiveType
())
.
append
(
"status"
,
getStatus
())
.
append
(
"consumerCouponIds"
,
getConsumerCouponIds
())
.
append
(
"rechargeConfId"
,
getRechargeConfId
())
.
append
(
"consumerId"
,
getConsumerId
())
.
append
(
"phone"
,
getPhone
())
.
append
(
"rechargeDate"
,
getRechargeDate
())
.
append
(
"isDelete"
,
getIsDelete
())
.
append
(
"createBy"
,
getCreateBy
())
.
append
(
"createTime"
,
getCreateTime
())
.
append
(
"updateBy"
,
getUpdateBy
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"remark"
,
getRemark
())
.
append
(
"outTradeNo"
,
getOutTradeNo
())
.
append
(
"terminalTrace"
,
getTerminalTrace
())
.
append
(
"payTime"
,
getPayTime
())
.
toString
();
}
}
share-system/src/main/java/share/system/service/impl/EquityMembersOrderServiceImpl.java
View file @
682ca036
...
...
@@ -161,6 +161,7 @@ public class EquityMembersOrderServiceImpl extends ServiceImpl<EquityMembersOrde
equityMembersOrderConfig
.
getValidityPeriod
().
intValue
()));
newConsumerMember
.
setMembershipProgress
(
BigDecimal
.
ZERO
);
newConsumerMember
.
setCreateTime
(
new
Date
());
newConsumerMember
.
setIsRight
(
YesNoEnum
.
yes
.
getIndex
());
consumerMemberService
.
save
(
newConsumerMember
);
logger
.
debug
(
"新增权益会员"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
...
share-system/src/main/java/share/system/service/impl/RechargeServiceImpl.java
View file @
682ca036
...
...
@@ -164,6 +164,7 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
consumerMember
.
setMembershipProgress
(
BigDecimal
.
ZERO
);
consumerMember
.
setExpirationDate
(
DateUtils
.
addYears
(
new
Date
(),
memberConfig
.
getValidityPeriod
().
intValue
()));
consumerMember
.
setCreateTime
(
new
Date
());
consumerMember
.
setIsRecharge
(
YesNoEnum
.
yes
.
getIndex
());
consumerMemberService
.
save
(
consumerMember
);
logger
.
debug
(
"新增充值会员"
);
extracted
(
recharge
);
...
...
@@ -245,7 +246,22 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
if
(
ObjectUtil
.
isEmpty
(
byId
))
{
throw
new
BaseException
(
"充值模板异常"
);
}
if
(
byId
.
getGiveType
().
contains
(
GiveTypeEnum
.
AMOUNT
.
getIndex
()))
{
recharge
.
setRechargeAmount
(
byId
.
getRechargeAmount
());
}
else
{
recharge
.
setRechargeAmount
(
BigDecimal
.
ZERO
);
}
if
(
byId
.
getGiveType
().
contains
(
GiveTypeEnum
.
DURATION
.
getIndex
()))
{
recharge
.
setGiveDuration
(
byId
.
getGiveDuration
());
}
else
{
recharge
.
setGiveDuration
(
BigDecimal
.
ZERO
);
}
if
(
byId
.
getGiveType
().
contains
(
GiveTypeEnum
.
INTEGRAL
.
getIndex
()))
{
BigDecimal
Integral
=
recharge
.
getRechargeAmount
().
multiply
(
byId
.
getGiveRatio
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_UP
);
recharge
.
setGiveIntegral
(
Integral
);
}
else
{
recharge
.
setGiveIntegral
(
BigDecimal
.
ZERO
);
}
recharge
.
setGiveAmount
(
byId
.
getGiveAmount
());
recharge
.
setGiveType
(
byId
.
getGiveType
());
recharge
.
setStatus
(
YesNoEnum
.
no
.
getIndex
());
...
...
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
682ca036
...
...
@@ -1137,13 +1137,23 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
memberProgressLog
.
setConsumerId
(
sOrder
.
getConsumerId
());
memberProgressLog
.
setCurrentProgress
(
consumerMember
.
getMembershipProgress
());
if
(
consumerMember
.
getMemberType
().
equals
(
MemberTypeEnum
.
NORMAL
.
getIndex
()))
{
MemberConfig
memberConfig
=
memberConfigService
.
getById
(
consumerMember
.
getMemberConfigId
());
if
(
ObjectUtil
.
isNotEmpty
(
memberConfig
))
{
//判断是否升级
if
(
membershipProgress
.
compareTo
(
BigDecimal
.
valueOf
(
memberConfig
.
getLimitRequirements
()))
>=
0
)
{
consumerMember
.
setMembershipLevel
(
consumerMember
.
getMembershipLevel
()
+
1L
);
consumerMember
.
setMemberConfigId
(
memberConfig
.
getId
());
if
(
consumerMember
.
getIsRecharge
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
consumerMember
.
setMemberType
(
MemberTypeEnum
.
RECHARGE
.
getIndex
());
MemberConfig
one
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMemberType
,
consumerMember
.
getMemberType
())
.
eq
(
MemberConfig:
:
getMembershipLevel
,
consumerMember
.
getMembershipLevel
()
+
1L
));
if
(
membershipProgress
.
compareTo
(
BigDecimal
.
valueOf
(
one
.
getLimitRequirements
()))
>=
0
)
{
consumerMember
.
setMembershipLevel
(
consumerMember
.
getMembershipLevel
()
+
1L
);
consumerMember
.
setMemberConfigId
(
one
.
getId
());
}
}
else
if
(
consumerMember
.
getIsRight
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
consumerMember
.
setMemberType
(
MemberTypeEnum
.
RIGHTS
.
getIndex
());
MemberConfig
one
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMemberType
,
consumerMember
.
getMemberType
())
.
eq
(
MemberConfig:
:
getMembershipLevel
,
consumerMember
.
getMembershipLevel
()
+
1L
));
if
(
membershipProgress
.
compareTo
(
BigDecimal
.
valueOf
(
one
.
getLimitRequirements
()))
>=
0
)
{
consumerMember
.
setMembershipLevel
(
consumerMember
.
getMembershipLevel
()
+
1L
);
consumerMember
.
setMemberConfigId
(
one
.
getId
());
}
}
}
else
{
...
...
@@ -1159,7 +1169,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
}
}
}
memberProgressLog
.
setVariableProgress
(
membershipProgress
.
subtract
(
consumerMember
.
getMembershipProgress
()));
consumerMember
.
setMembershipProgress
(
membershipProgress
);
memberProgressLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
...
...
@@ -1168,7 +1177,6 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
memberProgressLog
.
setExpirationTime
(
DateUtils
.
addYears
(
new
Date
(),
Math
.
toIntExact
(
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>().
eq
(
MemberConfig:
:
getId
,
consumerMember
.
getMemberConfigId
())).
getValidityPeriod
())));
memberProgressLogService
.
save
(
memberProgressLog
);
consumerMemberService
.
updateConsumerMember
(
consumerMember
);
// }
...
...
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