Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
QG
customer-service
Commits
09a953d3
Commit
09a953d3
authored
Apr 29, 2020
by
fengjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式化金额
parent
d26cdd5e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
0 deletions
+53
-0
LoanOrder.java
...in/java/cn/quantgroup/customer/model/order/LoanOrder.java
+11
-0
Repayment.java
...in/java/cn/quantgroup/customer/model/order/Repayment.java
+10
-0
MoneySerializer.java
...ain/java/cn/quantgroup/customer/util/MoneySerializer.java
+32
-0
No files found.
src/main/java/cn/quantgroup/customer/model/order/LoanOrder.java
View file @
09a953d3
package
cn
.
quantgroup
.
customer
.
model
.
order
;
import
cn.quantgroup.customer.util.MoneySerializer
;
import
com.fasterxml.jackson.annotation.JsonFormat
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
lombok.Data
;
import
java.math.BigDecimal
;
import
java.util.Date
;
/**
* @author Wang Xiangwei
...
...
@@ -48,21 +52,25 @@ public class LoanOrder {
/**
* 担保费
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
guaranteeFee
;
/**
* 其他费用
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
otherFee
;
/**
* 一次性服务费
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
onceServiceFee
;
/**
* 月利率
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
monthlyInterestRate
;
/**
...
...
@@ -94,4 +102,7 @@ public class LoanOrder {
* 是否展示还款计划
*/
private
Boolean
showPlans
;
@JsonFormat
(
timezone
=
"GMT+8"
,
pattern
=
"yyyy-MM-dd HH:mm:ss"
)
private
Date
paidAt
;
}
src/main/java/cn/quantgroup/customer/model/order/Repayment.java
View file @
09a953d3
...
...
@@ -2,6 +2,8 @@ package cn.quantgroup.customer.model.order;
import
cn.quantgroup.customer.enums.UserRepayType
;
import
cn.quantgroup.customer.util.DateUtil
;
import
cn.quantgroup.customer.util.MoneySerializer
;
import
com.fasterxml.jackson.databind.annotation.JsonSerialize
;
import
lombok.Data
;
import
java.math.BigDecimal
;
...
...
@@ -24,42 +26,50 @@ public class Repayment {
/**
* 本金
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
principal
;
/**
* 利息
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
interest
;
/**
* 担保费
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
serviceFee
;
/**
* 其他担保
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
otherFee
;
/**
* 罚息
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
overdueInterest
;
/**
* 当前减免
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
reliefAmount
;
/**
* 还款总额
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
repayAmount
;
/**
* 应还总额
*/
@JsonSerialize
(
using
=
MoneySerializer
.
class
)
private
BigDecimal
requiredRepayment
;
/**
...
...
src/main/java/cn/quantgroup/customer/util/MoneySerializer.java
0 → 100644
View file @
09a953d3
package
cn
.
quantgroup
.
customer
.
util
;
import
com.fasterxml.jackson.core.JsonGenerator
;
import
com.fasterxml.jackson.databind.JsonSerializer
;
import
com.fasterxml.jackson.databind.SerializerProvider
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
/**
* 在字段或get上加:
* <b>@JsonSerialize(using = MoneySerializer.class)</b>
* @author Jie.Feng
* @date 2018/8/28
*/
public
class
MoneySerializer
extends
JsonSerializer
<
BigDecimal
>
{
/**
* Method that can be called to ask implementation to serialize
* values of type this serializer handles.
*
* @param value Value to serialize; can <b>not</b> be null.
* @param gen Generator used to output resulting Json content
* @param serializers Provider that can be used to get serializers for
*/
@Override
public
void
serialize
(
BigDecimal
value
,
JsonGenerator
gen
,
SerializerProvider
serializers
)
throws
IOException
{
if
(
value
==
null
)
gen
.
writeString
(
"0.00"
);
else
gen
.
writeString
(
value
.
setScale
(
2
,
BigDecimal
.
ROUND_HALF_UP
).
toString
());
}
}
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