Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
RvApp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
lify
RvApp
Commits
cae3ec7c
Commit
cae3ec7c
authored
Jul 10, 2019
by
linfeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-member-john' of
http://113.105.137.151:22280/lify/rvapp
parents
7054fe26
a2b4c22d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
151 additions
and
5 deletions
+151
-5
Arith.java
...ent_utils/src/main/java/com/rv/component/utils/Arith.java
+141
-0
ChooseAVisitorActivity.java
...n/java/com/rv/rvmine/traveler/ChooseAVisitorActivity.java
+5
-1
TravelerConfirmOrderActivity.java
...va/com/rv/tourism/other/TravelerConfirmOrderActivity.java
+5
-4
No files found.
component_utils/src/main/java/com/rv/component/utils/Arith.java
0 → 100644
View file @
cae3ec7c
package
com
.
rv
.
component
.
utils
;
import
java.math.BigDecimal
;
/**
* 商业高精准计算
* float和double只能用来做科学计算或者是工程计算,在商业计算中我们要用 BigDecimal
* 使用BigDecimal并且一定要用String来够造
*
* 注意:Double.toString 只支持千万以下数据 不然会显示科学计数法, 要使用 BigDecimal.toString()
*
*/
public
class
Arith
{
private
static
final
int
DEF_DIV_SCALE
=
10
;
private
Arith
(){}
/**
* 精确加法运算
* @param v1 被加数
* @param v2 加数
* @return 两个参数的和
*/
public
static
double
add
(
double
v1
,
double
v2
){
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
add
(
b2
).
doubleValue
();
}
public
static
String
add
(
String
v1
,
String
v2
){
BigDecimal
b1
=
new
BigDecimal
(
v1
);
BigDecimal
b2
=
new
BigDecimal
(
v2
);
return
b1
.
add
(
b2
).
toString
();
}
/**
* 精确减法
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public
static
double
sub
(
double
v1
,
double
v2
){
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
subtract
(
b2
).
doubleValue
();
}
public
static
String
sub
(
String
v1
,
String
v2
){
BigDecimal
b1
=
new
BigDecimal
(
v1
);
BigDecimal
b2
=
new
BigDecimal
(
v2
);
return
b1
.
subtract
(
b2
).
toString
();
}
/**
* 精确乘法
* @param v1 被乘数
* @param v2 乘数
* @return 两个参数的积
*/
public
static
double
mul
(
double
v1
,
double
v2
){
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
multiply
(
b2
).
doubleValue
();
}
public
static
String
mul
(
String
v1
,
String
v2
){
BigDecimal
b1
=
new
BigDecimal
(
v1
);
BigDecimal
b2
=
new
BigDecimal
(
v2
);
return
b1
.
multiply
(
b2
).
toString
();
}
/**
* 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到小数点以后10位,以后的数字四舍五入。
* @param v1 被除数
* @param v2 除数
* @return 两个参数的商
*/
public
static
double
div
(
double
v1
,
double
v2
){
return
div
(
v1
,
v2
,
DEF_DIV_SCALE
)
;
}
/**
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public
static
double
div
(
double
v1
,
double
v2
,
int
scale
){
if
(
scale
<
0
){
throw
new
IllegalArgumentException
(
"The scale must be a positive integer or zero"
);
}
BigDecimal
b1
=
new
BigDecimal
(
Double
.
toString
(
v1
));
BigDecimal
b2
=
new
BigDecimal
(
Double
.
toString
(
v2
));
return
b1
.
divide
(
b2
,
scale
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
}
public
static
String
div
(
String
v1
,
String
v2
){
return
div
(
v1
,
v2
,
DEF_DIV_SCALE
)
;
}
/**
* 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指 定精度,以后的数字四舍五入。
* @param v1 被除数
* @param v2 除数
* @param scale 表示表示需要精确到小数点以后几位。
* @return 两个参数的商
*/
public
static
String
div
(
String
v1
,
String
v2
,
int
scale
){
if
(
scale
<
0
){
throw
new
IllegalArgumentException
(
"The scale must be a positive integer or zero"
);
}
BigDecimal
b1
=
new
BigDecimal
(
v1
);
BigDecimal
b2
=
new
BigDecimal
(
v2
);
return
b1
.
divide
(
b2
,
scale
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
}
/**
* 提供精确的小数位四舍五入处理。
* @param v 需要四舍五入的数字
* @param scale 小数点后保留几位
* @return 四舍五入后的结果
*/
public
static
double
round
(
double
v
,
int
scale
){
if
(
scale
<
0
){
throw
new
IllegalArgumentException
(
"The scale must be a positive integer or zero"
);
}
BigDecimal
b
=
new
BigDecimal
(
Double
.
toString
(
v
));
BigDecimal
one
=
new
BigDecimal
(
"1"
);
return
b
.
divide
(
one
,
scale
,
BigDecimal
.
ROUND_HALF_UP
).
doubleValue
();
}
public
static
String
round
(
String
v
,
int
scale
){
if
(
scale
<
0
){
throw
new
IllegalArgumentException
(
"The scale must be a positive integer or zero"
);
}
BigDecimal
b
=
new
BigDecimal
(
v
);
BigDecimal
one
=
new
BigDecimal
(
"1"
);
return
b
.
divide
(
one
,
scale
,
BigDecimal
.
ROUND_HALF_UP
).
toString
();
}
}
module_mine/src/main/java/com/rv/rvmine/traveler/ChooseAVisitorActivity.java
View file @
cae3ec7c
...
@@ -68,7 +68,11 @@ public class ChooseAVisitorActivity extends BaseStatusActivity<CommonPresenter>
...
@@ -68,7 +68,11 @@ public class ChooseAVisitorActivity extends BaseStatusActivity<CommonPresenter>
visitorType
=
intent
.
getIntExtra
(
"visitorType"
,
-
1
);
visitorType
=
intent
.
getIntExtra
(
"visitorType"
,
-
1
);
openType
=
intent
.
getIntExtra
(
"openType"
,
0
);
openType
=
intent
.
getIntExtra
(
"openType"
,
0
);
hasChoIdCards
=
intent
.
getStringExtra
(
"hasChoice"
);
hasChoIdCards
=
intent
.
getStringExtra
(
"hasChoice"
);
titleView
.
setTitle
(
"选择出游人"
);
if
(
openType
==
0
)
{
titleView
.
setTitle
(
"出游人"
);
}
else
{
titleView
.
setTitle
(
"选择出游人"
);
}
titleView
.
setImageResource
(
R
.
id
.
iv_title_right
,
R
.
drawable
.
rv_common_icon_thestaff
);
titleView
.
setImageResource
(
R
.
id
.
iv_title_right
,
R
.
drawable
.
rv_common_icon_thestaff
);
titleView
.
setChildClickListener
(
R
.
id
.
iv_title_right
,
new
View
.
OnClickListener
()
{
titleView
.
setChildClickListener
(
R
.
id
.
iv_title_right
,
new
View
.
OnClickListener
()
{
@Override
@Override
...
...
module_tourism/src/main/java/com/rv/tourism/other/TravelerConfirmOrderActivity.java
View file @
cae3ec7c
...
@@ -37,6 +37,7 @@ import com.rv.component.control.SwitchButton;
...
@@ -37,6 +37,7 @@ import com.rv.component.control.SwitchButton;
import
com.rv.component.dialog.OrderPriceDetailPw
;
import
com.rv.component.dialog.OrderPriceDetailPw
;
import
com.rv.component.dialog.PaymentTypeSelection
;
import
com.rv.component.dialog.PaymentTypeSelection
;
import
com.rv.component.dialog.bean.OrderPriceDetailBean
;
import
com.rv.component.dialog.bean.OrderPriceDetailBean
;
import
com.rv.component.utils.Arith
;
import
com.rv.component.utils.DateUtils
;
import
com.rv.component.utils.DateUtils
;
import
com.rv.tourism.R
;
import
com.rv.tourism.R
;
import
com.rv.tourism.R2
;
import
com.rv.tourism.R2
;
...
@@ -114,7 +115,7 @@ public class TravelerConfirmOrderActivity extends BaseStatusActivity<TourismPres
...
@@ -114,7 +115,7 @@ public class TravelerConfirmOrderActivity extends BaseStatusActivity<TourismPres
private
int
mPosition
;
private
int
mPosition
;
private
int
adultNum
;
private
int
adultNum
;
private
int
childNum
;
private
int
childNum
;
private
float
price
;
private
double
price
;
private
IWXAPI
api
;
private
IWXAPI
api
;
private
int
isInsuranceType
;
private
int
isInsuranceType
;
private
OrderPriceDetailBean
orderPriceDetailBean
;
//订单价格明细实体类
private
OrderPriceDetailBean
orderPriceDetailBean
;
//订单价格明细实体类
...
@@ -145,9 +146,9 @@ public class TravelerConfirmOrderActivity extends BaseStatusActivity<TourismPres
...
@@ -145,9 +146,9 @@ public class TravelerConfirmOrderActivity extends BaseStatusActivity<TourismPres
adultNum
=
Integer
.
valueOf
(
dataBean
.
getAdultNum
());
adultNum
=
Integer
.
valueOf
(
dataBean
.
getAdultNum
());
childNum
=
Integer
.
valueOf
(
dataBean
.
getChildNum
());
childNum
=
Integer
.
valueOf
(
dataBean
.
getChildNum
());
int
childPrice
=
Integer
.
valueOf
(
dataBean
.
getChildPrice
()
);
String
childPrice
=
dataBean
.
getChildPrice
(
);
int
adultPrice
=
Integer
.
valueOf
(
dataBean
.
getPrice
()
);
String
adultPrice
=
dataBean
.
getPrice
(
);
price
=
(
childNum
*
childPrice
)
+
(
adultNum
*
adultPrice
);
price
=
Arith
.
mul
(
Double
.
valueOf
(
childNum
),
Double
.
valueOf
(
childPrice
))
+
Arith
.
mul
(
Double
.
valueOf
(
adultNum
),
Double
.
valueOf
(
adultPrice
)
);
tvPaymentAmount
.
setText
(
String
.
format
(
"¥%1$s"
,
price
));
tvPaymentAmount
.
setText
(
String
.
format
(
"¥%1$s"
,
price
));
for
(
int
i
=
0
;
i
<
Integer
.
valueOf
(
dataBean
.
getAdultNum
());
i
++)
{
for
(
int
i
=
0
;
i
<
Integer
.
valueOf
(
dataBean
.
getAdultNum
());
i
++)
{
...
...
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