formaFee2Fen rename to formatFee2Fen

This commit is contained in:
jinyu 2016-08-01 13:44:47 +08:00
parent 92cc725f41
commit bbdd8980af
7 changed files with 19 additions and 15 deletions

View File

@ -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();
}

View File

@ -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() {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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);
}
/**

View File

@ -261,8 +261,8 @@ public class PayOldApi extends MpApi {
map.put("service_version", "1.1");
map.put("partner", weixinAccount.getPartnerId());
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));
map.put(idQuery.getType().getName(), idQuery.getId());
if (StringUtil.isBlank(opUserId)) {
opUserId = weixinAccount.getPartnerId();

View File

@ -133,8 +133,8 @@ public class PayPackageV2 extends PayPackage {
this.inputCharset = "UTF-8";
this.partner = partner;
this.transportFee = transportFee > 0d ? DateUtil
.formaFee2Fen(transportFee) : null;
this.productFee = productFee > 0 ? DateUtil.formaFee2Fen(productFee)
.formatFee2Fen(transportFee) : null;
this.productFee = productFee > 0 ? DateUtil.formatFee2Fen(productFee)
: null;
}
@ -165,7 +165,7 @@ public class PayPackageV2 extends PayPackage {
* 物流费用 单位为元
*/
public void setTransportFee(double transportFee) {
this.transportFee = DateUtil.formaFee2Fen(transportFee);
this.transportFee = DateUtil.formatFee2Fen(transportFee);
}
public String getProductFee() {
@ -179,7 +179,7 @@ public class PayPackageV2 extends PayPackage {
* 商品 单位为元
*/
public void setProductFee(double productFee) {
this.productFee = DateUtil.formaFee2Fen(productFee);
this.productFee = DateUtil.formatFee2Fen(productFee);
}
public String getInputCharset() {