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
89fa8e3b
Commit
89fa8e3b
authored
Jul 08, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改充值支付回调
parent
1830afdf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
128 additions
and
58 deletions
+128
-58
GiveTypeEnum.java
...common/src/main/java/share/common/enums/GiveTypeEnum.java
+37
-0
ConsumerWalletServiceImpl.java
.../share/system/service/impl/ConsumerWalletServiceImpl.java
+73
-53
RechargeServiceImpl.java
...n/java/share/system/service/impl/RechargeServiceImpl.java
+18
-5
No files found.
share-common/src/main/java/share/common/enums/GiveTypeEnum.java
0 → 100644
View file @
89fa8e3b
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 @
89fa8e3b
...
...
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
share.common.enums.GiveTypeEnum
;
import
share.common.enums.MemberTypeEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.utils.DateUtils
;
...
...
@@ -122,71 +123,90 @@ public class ConsumerWalletServiceImpl extends ServiceImpl<ConsumerWalletMapper,
@Override
public
boolean
addConsumerWallet
(
ConsumerWallet
consumerWallet
)
{
int
i
=
consumerWalletMapper
.
insertConsumerWallet
(
consumerWallet
);
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
new
BigDecimal
(
0
));
balanceLog
.
setVariableAmount
(
consumerWallet
.
getBalance
());
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLogService
.
save
(
balanceLog
);
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setCurrentDuration
(
new
BigDecimal
(
0
));
durationLog
.
setVariableDuration
(
consumerWallet
.
getRemainingDuration
());
durationLog
.
setOperationTime
(
new
Date
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLogService
.
save
(
durationLog
);
IntegralLog
integralLog
=
new
IntegralLog
();
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setCurrentIntegral
(
new
BigDecimal
(
0
));
integralLog
.
setVariableIntegral
(
consumerWallet
.
getRemainingIntegral
());
integralLog
.
setOperationTime
(
new
Date
());
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLogService
.
save
(
integralLog
);
if
(
consumerWallet
.
getBalance
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
new
BigDecimal
(
0
));
balanceLog
.
setVariableAmount
(
consumerWallet
.
getBalance
());
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLogService
.
save
(
balanceLog
);
}
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setCurrentDuration
(
new
BigDecimal
(
0
));
durationLog
.
setVariableDuration
(
consumerWallet
.
getRemainingDuration
());
durationLog
.
setOperationTime
(
new
Date
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLogService
.
save
(
durationLog
);
}
if
(
consumerWallet
.
getRemainingIntegral
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
IntegralLog
integralLog
=
new
IntegralLog
();
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setCurrentIntegral
(
new
BigDecimal
(
0
));
integralLog
.
setVariableIntegral
(
consumerWallet
.
getRemainingIntegral
());
integralLog
.
setOperationTime
(
new
Date
());
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLogService
.
save
(
integralLog
);
}
return
i
==
1
;
}
@Override
public
boolean
editConsumerWallet
(
ConsumerWallet
consumerWallet
,
Recharge
recharge
,
ConsumerMember
one
)
{
BigDecimal
divide
=
new
BigDecimal
(
0
);
RechargeConf
rechargeConf
=
rechargeConfService
.
selectRechargeConfById
(
recharge
.
getRechargeConfId
());
MemberConfig
memberConfig
=
memberConfigService
.
getOne
(
new
LambdaQueryWrapper
<
MemberConfig
>()
.
eq
(
MemberConfig:
:
getMembershipLevel
,
1L
)
.
eq
(
MemberConfig:
:
getMemberType
,
MemberTypeEnum
.
RECHARGE
.
getIndex
()));
one
.
setExpirationDate
(
DateUtils
.
addYears
(
new
Date
(),
memberConfig
.
getValidityPeriod
().
intValue
()));
consumerMemberService
.
updateConsumerMember
(
one
);
BigDecimal
balance
=
consumerWallet
.
getBalance
().
add
(
recharge
.
getRechargeAmount
()).
add
(
rechargeConf
.
getGiveAmount
());
consumerWallet
.
setBalance
(
balance
);
BigDecimal
duration
=
consumerWallet
.
getRemainingDuration
().
add
(
rechargeConf
.
getGiveDuration
());
consumerWallet
.
setRemainingDuration
(
duration
);
BigDecimal
divide
=
recharge
.
getRechargeAmount
().
multiply
(
rechargeConf
.
getGiveRatio
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_UP
);
BigDecimal
Integral
=
consumerWallet
.
getRemainingIntegral
().
add
(
divide
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
AMOUNT
.
getIndex
()))
{
BigDecimal
balance
=
consumerWallet
.
getBalance
().
add
(
recharge
.
getRechargeAmount
()).
add
(
rechargeConf
.
getGiveAmount
());
consumerWallet
.
setBalance
(
balance
);
}
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
DURATION
.
getIndex
()))
{
BigDecimal
duration
=
consumerWallet
.
getRemainingDuration
().
add
(
rechargeConf
.
getGiveDuration
());
consumerWallet
.
setRemainingDuration
(
duration
);
}
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
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
}
int
i
=
updateConsumerWallet
(
consumerWallet
);
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
consumerWallet
.
getBalance
());
balanceLog
.
setVariableAmount
(
recharge
.
getRechargeAmount
().
add
(
rechargeConf
.
getGiveAmount
()));
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLog
.
setCreateTime
(
new
Date
());
balanceLogService
.
save
(
balanceLog
);
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setCurrentDuration
(
consumerWallet
.
getRemainingDuration
());
durationLog
.
setVariableDuration
(
rechargeConf
.
getGiveDuration
());
durationLog
.
setOperationTime
(
new
Date
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setCreateTime
(
new
Date
());
durationLogService
.
save
(
durationLog
);
IntegralLog
integralLog
=
new
IntegralLog
();
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setCurrentIntegral
(
consumerWallet
.
getRemainingIntegral
());
integralLog
.
setVariableIntegral
(
divide
);
integralLog
.
setOperationTime
(
new
Date
());
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLog
.
setCreateTime
(
new
Date
());
integralLogService
.
save
(
integralLog
);
if
(
consumerWallet
.
getBalance
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
BalanceLog
balanceLog
=
new
BalanceLog
();
balanceLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
balanceLog
.
setCurrentBalance
(
consumerWallet
.
getBalance
());
balanceLog
.
setVariableAmount
(
recharge
.
getRechargeAmount
().
add
(
rechargeConf
.
getGiveAmount
()));
balanceLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
balanceLog
.
setOperationTime
(
new
Date
());
balanceLog
.
setCreateTime
(
new
Date
());
balanceLogService
.
save
(
balanceLog
);
}
if
(
consumerWallet
.
getRemainingDuration
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
DurationLog
durationLog
=
new
DurationLog
();
durationLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
durationLog
.
setCurrentDuration
(
consumerWallet
.
getRemainingDuration
());
durationLog
.
setVariableDuration
(
rechargeConf
.
getGiveDuration
());
durationLog
.
setOperationTime
(
new
Date
());
durationLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
durationLog
.
setCreateTime
(
new
Date
());
durationLogService
.
save
(
durationLog
);
}
if
(
consumerWallet
.
getRemainingIntegral
().
compareTo
(
new
BigDecimal
(
0
))
>
0
)
{
IntegralLog
integralLog
=
new
IntegralLog
();
integralLog
.
setConsumerId
(
consumerWallet
.
getConsumerId
());
integralLog
.
setCurrentIntegral
(
consumerWallet
.
getRemainingIntegral
());
integralLog
.
setVariableIntegral
(
divide
);
integralLog
.
setOperationTime
(
new
Date
());
integralLog
.
setOperationType
(
YesNoEnum
.
yes
.
getIndex
());
integralLog
.
setCreateTime
(
new
Date
());
integralLogService
.
save
(
integralLog
);
}
return
i
==
1
;
}
}
share-system/src/main/java/share/system/service/impl/RechargeServiceImpl.java
View file @
89fa8e3b
...
...
@@ -8,6 +8,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
share.common.enums.GiveTypeEnum
;
import
share.common.enums.MemberTypeEnum
;
import
share.common.enums.YesNoEnum
;
import
share.common.exception.base.BaseException
;
...
...
@@ -199,11 +200,23 @@ public class RechargeServiceImpl extends ServiceImpl<RechargeMapper, Recharge> i
RechargeConf
rechargeConf
=
rechargeConfService
.
selectRechargeConfById
(
recharge
.
getRechargeConfId
());
ConsumerWallet
consumerWallet
=
new
ConsumerWallet
();
consumerWallet
.
setConsumerId
(
recharge
.
getConsumerId
());
BigDecimal
balance
=
recharge
.
getRechargeAmount
().
add
(
rechargeConf
.
getGiveAmount
());
consumerWallet
.
setBalance
(
balance
);
consumerWallet
.
setRemainingDuration
(
rechargeConf
.
getGiveDuration
());
BigDecimal
Integral
=
recharge
.
getRechargeAmount
().
multiply
(
rechargeConf
.
getGiveRatio
()).
divide
(
new
BigDecimal
(
100
),
2
,
RoundingMode
.
HALF_UP
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
AMOUNT
.
getIndex
()))
{
BigDecimal
balance
=
recharge
.
getRechargeAmount
().
add
(
rechargeConf
.
getGiveAmount
());
consumerWallet
.
setBalance
(
balance
);
}
else
{
consumerWallet
.
setBalance
(
new
BigDecimal
(
0
));
}
if
(
rechargeConf
.
getGiveType
().
contains
(
GiveTypeEnum
.
DURATION
.
getIndex
()))
{
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
);
consumerWallet
.
setRemainingIntegral
(
Integral
);
}
else
{
consumerWallet
.
setRemainingIntegral
(
new
BigDecimal
(
0
));
}
consumerWallet
.
setCreateTime
(
new
Date
());
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