formaFee2Fen rename to formatFee2Fen
This commit is contained in:
@@ -465,8 +465,8 @@ public class PayApi extends MchApi {
|
||||
try {
|
||||
Map<String, String> map = createBaseRequestMap(idQuery);
|
||||
map.put("out_refund_no", outRefundNo);
|
||||
map.put("total_fee", DateUtil.formaFee2Fen(totalFee));
|
||||
map.put("refund_fee", DateUtil.formaFee2Fen(refundFee));
|
||||
map.put("total_fee", DateUtil.formatFee2Fen(totalFee));
|
||||
map.put("refund_fee", DateUtil.formatFee2Fen(refundFee));
|
||||
if (StringUtil.isBlank(opUserId)) {
|
||||
opUserId = weixinAccount.getMchId();
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class PayPackage extends MerchantResult {
|
||||
this.body = body;
|
||||
this.detail = detail;
|
||||
this.outTradeNo = outTradeNo;
|
||||
this.totalFee = DateUtil.formaFee2Fen(totalFee);
|
||||
this.totalFee = DateUtil.formatFee2Fen(totalFee);
|
||||
this.notifyUrl = notifyUrl;
|
||||
this.createIp = createIp;
|
||||
this.attach = attach;
|
||||
@@ -163,7 +163,7 @@ public class PayPackage extends MerchantResult {
|
||||
* 订单总额 单位为元
|
||||
*/
|
||||
public void setTotalFee(double totalFee) {
|
||||
this.totalFee = DateUtil.formaFee2Fen(totalFee);
|
||||
this.totalFee = DateUtil.formatFee2Fen(totalFee);
|
||||
}
|
||||
|
||||
public String getNotifyUrl() {
|
||||
|
||||
@@ -91,7 +91,7 @@ public class CorpPayment extends MerchantResult {
|
||||
this.openId = openId;
|
||||
this.checkNameType = checkNameType;
|
||||
this.desc = desc;
|
||||
this.amount = DateUtil.formaFee2Fen(amount);
|
||||
this.amount = DateUtil.formatFee2Fen(amount);
|
||||
this.clientIp = clientIp;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,7 +134,7 @@ public class Redpacket extends MerchantResult {
|
||||
this.clientIp = clientIp;
|
||||
this.actName = actName;
|
||||
this.remark = remark;
|
||||
this.totalAmount = DateUtil.formaFee2Fen(totalAmount);
|
||||
this.totalAmount = DateUtil.formatFee2Fen(totalAmount);
|
||||
this.amtType = totalNum > 1 ? "ALL_RAND" : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.foxinmy.weixin4j.util;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
@@ -73,10 +74,13 @@ public class DateUtil {
|
||||
*
|
||||
* @param fee
|
||||
* 金额 单位为分
|
||||
* @return
|
||||
* @return 四舍五入后的字符串形式金额
|
||||
*/
|
||||
public static String formaFee2Fen(double fee) {
|
||||
return new DecimalFormat("#").format(fee * 100);
|
||||
public static String formatFee2Fen(double fee) {
|
||||
BigDecimal _fee = new BigDecimal(Double.toString(fee));
|
||||
fee = _fee.multiply(new BigDecimal("100"))
|
||||
.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
return new DecimalFormat("#").format(fee);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user