Browse Source

B2B新增对账返回ERP时对账总金额进行保留两位小数处理

hejq 7 years ago
parent
commit
48dada12ab

+ 2 - 2
src/main/java/com/uas/platform/b2b/erp/model/APCheck.java

@@ -2,6 +2,7 @@ package com.uas.platform.b2b.erp.model;
 
 import com.uas.platform.b2b.model.PurchaseApCheck;
 import com.uas.platform.b2b.model.PurchaseApCheckItem;
+import com.uas.platform.b2b.support.DecimalUtils;
 import org.springframework.util.CollectionUtils;
 
 import java.util.*;
@@ -172,9 +173,8 @@ public class APCheck{
 		this.ac_remark = apCheck.getRemark();
 		this.ac_commitdate = apCheck.getCommitDate();
 		this.ac_status = apCheck.getStatus();
-		this.ac_checkamount = apCheck.getCheckAmount();
+		this.ac_checkamount = DecimalUtils.decimalPoint(apCheck.getCheckAmount(), 2);
 		this.ac_currency = apCheck.getCurrency();
-//		this.ac_rate = apCheck.getTaxrate();
 		this.ac_rate = apCheck.getRate();
 		this.ac_paymentname = apCheck.getPayments();
 		this.ac_custuu = apCheck.getCustUu();

+ 32 - 0
src/main/java/com/uas/platform/b2b/support/DecimalUtils.java

@@ -0,0 +1,32 @@
+package com.uas.platform.b2b.support;
+
+import java.text.DecimalFormat;
+
+/**
+ * 平台数据小数点处理方式
+ *
+ * @author hejq
+ * @date 2018-08-16 15:30
+ */
+public class DecimalUtils {
+
+    /**
+     * 小数分割
+     *      <pre>
+     *          默认会四舍五入
+     *      </pre>
+     * @param oldValue 原值
+     * @param digit 小数点
+     * @return 返回处理后的数据
+     */
+    public static Double decimalPoint(Double oldValue, Integer digit) {
+        if (null != oldValue) {
+            String str = "#.###############";
+            String digitStr = str.substring(0, (2 + digit));
+            DecimalFormat decimalFormat = new java.text.DecimalFormat(digitStr);
+            return Double.valueOf(decimalFormat.format(oldValue));
+        } else {
+            return 0.00;
+        }
+    }
+}