Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
b3580510
Commit
b3580510
authored
Feb 05, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
价格展示问题修复
parent
6d0028ca
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
ch-core/src/main/java/com/wwdz/ch/core/util/PriceUtil.java
ch-core/src/main/java/com/wwdz/ch/core/util/PriceUtil.java
+6
-5
No files found.
ch-core/src/main/java/com/wwdz/ch/core/util/PriceUtil.java
View file @
b3580510
...
@@ -6,10 +6,10 @@ import java.text.DecimalFormat;
...
@@ -6,10 +6,10 @@ import java.text.DecimalFormat;
public
class
PriceUtil
{
public
class
PriceUtil
{
public
static
String
convertPriceFenToYuan
(
Long
rawPrice
)
{
public
static
String
convertPriceFenToYuan
(
Long
rawPrice
)
{
BigDecimal
price
=
new
BigDecimal
(
String
.
valueOf
(
rawPrice
.
doubleValue
()
/
100
));
BigDecimal
price
=
new
BigDecimal
(
rawPrice
).
divide
(
new
BigDecimal
(
"100"
));
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
String
str
=
df
.
format
(
price
);
String
str
=
df
.
format
(
price
);
return
new
BigDecimal
(
str
).
stripTrailingZeros
().
toString
();
return
new
BigDecimal
(
str
).
stripTrailingZeros
().
to
Plain
String
();
}
}
public
static
String
convertPriceByTwo
(
int
price
){
public
static
String
convertPriceByTwo
(
int
price
){
...
@@ -17,7 +17,7 @@ public class PriceUtil {
...
@@ -17,7 +17,7 @@ public class PriceUtil {
BigDecimal
bigDecimal
=
new
BigDecimal
(
String
.
valueOf
(
num
));
BigDecimal
bigDecimal
=
new
BigDecimal
(
String
.
valueOf
(
num
));
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
String
str
=
df
.
format
(
bigDecimal
);
String
str
=
df
.
format
(
bigDecimal
);
return
new
BigDecimal
(
str
).
stripTrailingZeros
().
toString
();
return
new
BigDecimal
(
str
).
stripTrailingZeros
().
to
Plain
String
();
}
}
public
static
Long
convertPriceFromStr
(
String
price
){
public
static
Long
convertPriceFromStr
(
String
price
){
...
@@ -30,7 +30,7 @@ public class PriceUtil {
...
@@ -30,7 +30,7 @@ public class PriceUtil {
BigDecimal
bigDecimal
=
new
BigDecimal
(
String
.
valueOf
(
price
/
100
));
BigDecimal
bigDecimal
=
new
BigDecimal
(
String
.
valueOf
(
price
/
100
));
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
String
str
=
df
.
format
(
bigDecimal
);
String
str
=
df
.
format
(
bigDecimal
);
return
new
BigDecimal
(
str
).
stripTrailingZeros
().
toString
();
return
new
BigDecimal
(
str
).
stripTrailingZeros
().
to
Plain
String
();
}
}
...
@@ -41,11 +41,12 @@ public class PriceUtil {
...
@@ -41,11 +41,12 @@ public class PriceUtil {
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
">>>>"
+
convertPriceFenToYuan
(
2000L
));
String
num
=
"3.0000"
;
String
num
=
"3.0000"
;
BigDecimal
bigDecimal
=
new
BigDecimal
(
num
);
BigDecimal
bigDecimal
=
new
BigDecimal
(
num
);
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
DecimalFormat
df
=
new
DecimalFormat
(
"#0.00"
);
String
a
=
df
.
format
(
bigDecimal
);
String
a
=
df
.
format
(
bigDecimal
);
System
.
out
.
println
(
new
BigDecimal
(
a
).
stripTrailingZeros
().
toString
());
System
.
out
.
println
(
new
BigDecimal
(
a
).
stripTrailingZeros
().
to
Plain
String
());
}
}
...
...
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