Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package me.chanjar.weixin.mp.bean.pay.request;

import java.math.BigDecimal;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import me.chanjar.weixin.common.util.ToStringUtils;

Expand Down Expand Up @@ -110,6 +112,16 @@ public String getSign() {
public void setSign(String sign) {
this.sign = sign;
}

/**
* 将单位为元转换为单位为分
*
* @param yuan
* @return
*/
public static Integer yuanToFee(String yuan) {
return new BigDecimal(yuan).setScale(2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).intValue();
}

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.chanjar.weixin.mp.bean.pay.result;

import java.math.BigDecimal;
import java.util.Map;

import com.thoughtworks.xstream.annotations.XStreamAlias;
Expand Down Expand Up @@ -146,6 +147,15 @@ public void setSign(String sign) {
this.sign = sign;
}

/**
* 将单位分转换成单位圆
* @param fee
* @return
*/
public static String feeToYuan(Integer fee) {
return new BigDecimal(Double.valueOf(fee) / 100).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
}

public Map<String,String> toMap(){
return BeanUtils.xmlBean2Map(this);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package me.chanjar.weixin.mp.bean.pay.result;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -397,16 +396,6 @@ public Map<String,String> toMap(){
return resultMap;
}


/**
* 将单位分转换成单位圆
* @param fee
* @return
*/
public static String feeToYuan(Integer fee) {
return new BigDecimal(Double.valueOf(fee) / 100).setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString();
}

@Override
public String toString() {
return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
Expand Down