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
ff703c2f
Commit
ff703c2f
authored
Jul 08, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refs/heads/dev' into test
parents
600b2d7f
89fa8e3b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
2 deletions
+72
-2
GiveTypeEnum.java
...common/src/main/java/share/common/enums/GiveTypeEnum.java
+37
-0
ConsumerWalletServiceImpl.java
.../share/system/service/impl/ConsumerWalletServiceImpl.java
+22
-2
RechargeServiceImpl.java
...n/java/share/system/service/impl/RechargeServiceImpl.java
+13
-0
No files found.
share-common/src/main/java/share/common/enums/GiveTypeEnum.java
0 → 100644
View file @
ff703c2f
package
share
.
common
.
enums
;
public
enum
GiveTypeEnum
{
//金额
AMOUNT
(
"1"
,
"金额"
),
//时长
DURATION
(
"2"
,
"时长"
),
//积分
INTEGRAL
(
"3"
,
"积分"
),
;
private
String
index
;
private
String
name
;
GiveTypeEnum
(
String
index
,
String
name
)
{
this
.
index
=
index
;
this
.
name
=
name
;
}
GiveTypeEnum
()
{
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getIndex
()
{
return
index
;
}
public
void
setIndex
(
String
index
)
{
this
.
index
=
index
;
}
}
share-system/src/main/java/share/system/service/impl/ConsumerWalletServiceImpl.java
View file @
ff703c2f
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
share.common.enums.GiveTypeEnum
;
import
share.common.enums.MemberTypeEnum
;
import
share.common.enums.MemberTypeEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.utils.DateUtils
;
import
share.common.utils.DateUtils
;
...
@@ -122,6 +123,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
...
@@ -122,6 +123,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
@Override
@Override
public
boolean
addConsumerWallet
(
ConsumerWallet
consumerWallet
)
{
public
boolean
addConsumerWallet
(
ConsumerWallet
consumerWallet
)
{
int
i
=
consumerWalletMapper
.
insertConsumerWallet
(
consumerWallet
);
int
i
=
consumerWalletMapper
.
insertConsumerWallet
(
consumerWallet
);
if
(
consumerWallet
.
getBalance
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
BalanceLog
balanceLog
=
new
BalanceLog
();
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
new
BigDecimal
(
0
));
balanceLog
.
setCurrentBalance
(
new
BigDecimal
(
0
));
...
@@ -129,6 +131,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
...
@@ -129,6 +131,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLogService
.
save
(
balanceLog
);
balanceLogService
.
save
(
balanceLog
);
}
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
DurationLog
durationLog
=
new
DurationLog
();
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setCurrentDuration
(
new
BigDecimal
(
0
));
durationLog
.
setCurrentDuration
(
new
BigDecimal
(
0
));
...
@@ -136,6 +140,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
...
@@ -136,6 +140,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
durationLog
.
setOperationTime
(
new
Date
());
durationLog
.
setOperationTime
(
new
Date
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLogService
.
save
(
durationLog
);
durationLogService
.
save
(
durationLog
);
}
if
(
consumerWallet
.
getRemainingIntegral
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
IntegralLog
integralLog
=
new
IntegralLog
();
IntegralLog
integralLog
=
new
IntegralLog
();
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setCurrentIntegral
(
new
BigDecimal
(
0
));
integralLog
.
setCurrentIntegral
(
new
BigDecimal
(
0
));
...
@@ -143,26 +149,35 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
...
@@ -143,26 +149,35 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
integralLog
.
setOperationTime
(
new
Date
());
integralLog
.
setOperationTime
(
new
Date
());
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLogService
.
save
(
integralLog
);
integralLogService
.
save
(
integralLog
);
}
return
i
==
1
;
return
i
==
1
;
}
}
@Override
@Override
public
boolean
editConsumerWallet
(
ConsumerWallet
consumerWallet
,
Recharge
recharge
,
ConsumerMember
one
)
{
public
boolean
editConsumerWallet
(
ConsumerWallet
consumerWallet
,
Recharge
recharge
,
ConsumerMember
one
)
{
BigDecimal
divide
=
new
BigDecimal
(
0
);
RechargeConf
rechargeConf
=
rechargeConfService
.
selectRechargeConfById
(
recharge
.
getRechargeConfId
());
RechargeConf
rechargeConf
=
rechargeConfService
.
selectRechargeConfById
(
recharge
.
getRechargeConfId
());
MemberConfig
memberConfig
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
MemberConfig
memberConfig
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMembershipLevel
,
1L
)
.
eq
(
MemberConfig:
:
getMembershipLevel
,
1L
)
.
eq
(
MemberConfig:
:
getMemberType
,
MemberTypeEnum
.
RECHARGE
.
getIndex
()));
.
eq
(
MemberConfig:
:
getMemberType
,
MemberTypeEnum
.
RECHARGE
.
getIndex
()));
one
.
setExpirationDate
(
DateUtils
.
addYears
(
new
Date
(),
memberConfig
.
getValidityPeriod
().
intValue
()));
one
.
setExpirationDate
(
DateUtils
.
addYears
(
new
Date
(),
memberConfig
.
getValidityPeriod
().
intValue
()));
consumerMemberService
.
updateConsumerMember
(
one
);
consumerMemberService
.
updateConsumerMember
(
one
);
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
AMOUNT
.
getIndex
()))
{
BigDecimal
balance
=
consumerWallet
.
getBalance
().
add
(
recharge
.
getRechargeAmount
()).
add
(
rechargeConf
.
getGiveAmount
());
BigDecimal
balance
=
consumerWallet
.
getBalance
().
add
(
recharge
.
getRechargeAmount
()).
add
(
rechargeConf
.
getGiveAmount
());
consumerWallet
.
setBalance
(
balance
);
consumerWallet
.
setBalance
(
balance
);
}
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
DURATION
.
getIndex
()))
{
BigDecimal
duration
=
consumerWallet
.
getRemainingDuration
().
add
(
rechargeConf
.
getGiveDuration
());
BigDecimal
duration
=
consumerWallet
.
getRemainingDuration
().
add
(
rechargeConf
.
getGiveDuration
());
consumerWallet
.
setRemainingDuration
(
duration
);
consumerWallet
.
setRemainingDuration
(
duration
);
BigDecimal
divide
=
recharge
.
getRechargeAmount
().
multiply
(
rechargeConf
.
getGiveRatio
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_UP
);
}
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
INTEGRAL
.
getIndex
()))
{
divide
=
recharge
.
getRechargeAmount
().
multiply
(
rechargeConf
.
getGiveRatio
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_UP
);
BigDecimal
Integral
=
consumerWallet
.
getRemainingIntegral
().
add
(
divide
);
BigDecimal
Integral
=
consumerWallet
.
getRemainingIntegral
().
add
(
divide
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
}
int
i
=
updateConsumerWallet
(
consumerWallet
);
int
i
=
updateConsumerWallet
(
consumerWallet
);
if
(
consumerWallet
.
getBalance
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
BalanceLog
balanceLog
=
new
BalanceLog
();
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
consumerWallet
.
getBalance
());
balanceLog
.
setCurrentBalance
(
consumerWallet
.
getBalance
());
...
@@ -171,6 +186,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
...
@@ -171,6 +186,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
balanceLog
.
setOperationTime
(
new
Date
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLog
.
setCreateTime
(
new
Date
());
balanceLog
.
setCreateTime
(
new
Date
());
balanceLogService
.
save
(
balanceLog
);
balanceLogService
.
save
(
balanceLog
);
}
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
DurationLog
durationLog
=
new
DurationLog
();
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setCurrentDuration
(
consumerWallet
.
getRemainingDuration
());
durationLog
.
setCurrentDuration
(
consumerWallet
.
getRemainingDuration
());
...
@@ -179,6 +196,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
...
@@ -179,6 +196,8 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setCreateTime
(
new
Date
());
durationLog
.
setCreateTime
(
new
Date
());
durationLogService
.
save
(
durationLog
);
durationLogService
.
save
(
durationLog
);
}
if
(
consumerWallet
.
getRemainingIntegral
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
IntegralLog
integralLog
=
new
IntegralLog
();
IntegralLog
integralLog
=
new
IntegralLog
();
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setCurrentIntegral
(
consumerWallet
.
getRemainingIntegral
());
integralLog
.
setCurrentIntegral
(
consumerWallet
.
getRemainingIntegral
());
...
@@ -187,6 +206,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
...
@@ -187,6 +206,7 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLog
.
setCreateTime
(
new
Date
());
integralLog
.
setCreateTime
(
new
Date
());
integralLogService
.
save
(
integralLog
);
integralLogService
.
save
(
integralLog
);
}
return
i
==
1
;
return
i
==
1
;
}
}
}
}
share-system/src/main/java/share/system/service/impl/RechargeServiceImpl.java
View file @
ff703c2f
...
@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
share.common.enums.GiveTypeEnum
;
import
share.common.enums.MemberTypeEnum
;
import
share.common.enums.MemberTypeEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.exception.base.BaseException
;
import
share.common.exception.base.BaseException
;
...
@@ -199,11 +200,23 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
...
@@ -199,11 +200,23 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
RechargeConf
rechargeConf
=
rechargeConfService
.
selectRechargeConfById
(
recharge
.
getRechargeConfId
());
RechargeConf
rechargeConf
=
rechargeConfService
.
selectRechargeConfById
(
recharge
.
getRechargeConfId
());
ConsumerWallet
consumerWallet
=
new
ConsumerWallet
();
ConsumerWallet
consumerWallet
=
new
ConsumerWallet
();
consumerWallet
.
setConsumerId
(
recharge
.
getConsumerId
());
consumerWallet
.
setConsumerId
(
recharge
.
getConsumerId
());
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
AMOUNT
.
getIndex
()))
{
BigDecimal
balance
=
recharge
.
getRechargeAmount
().
add
(
rechargeConf
.
getGiveAmount
());
BigDecimal
balance
=
recharge
.
getRechargeAmount
().
add
(
rechargeConf
.
getGiveAmount
());
consumerWallet
.
setBalance
(
balance
);
consumerWallet
.
setBalance
(
balance
);
}
else
{
consumerWallet
.
setBalance
(
new
BigDecimal
(
0
));
}
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
DURATION
.
getIndex
()))
{
consumerWallet
.
setRemainingDuration
(
rechargeConf
.
getGiveDuration
());
consumerWallet
.
setRemainingDuration
(
rechargeConf
.
getGiveDuration
());
}
else
{
consumerWallet
.
setRemainingDuration
(
new
BigDecimal
(
0
));
}
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
INTEGRAL
.
getIndex
()))
{
BigDecimal
Integral
=
recharge
.
getRechargeAmount
().
multiply
(
rechargeConf
.
getGiveRatio
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_UP
);
BigDecimal
Integral
=
recharge
.
getRechargeAmount
().
multiply
(
rechargeConf
.
getGiveRatio
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_UP
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
}
else
{
consumerWallet
.
setRemainingIntegral
(
new
BigDecimal
(
0
));
}
consumerWallet
.
setCreateTime
(
new
Date
());
consumerWallet
.
setCreateTime
(
new
Date
());
consumerWalletService
.
addConsumerWallet
(
consumerWallet
);
consumerWalletService
.
addConsumerWallet
(
consumerWallet
);
}
}
...
...
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