Browse Source

TradingDataController规范调整

Hu Jie 7 years ago
parent
commit
66c88130c2

+ 213 - 102
src/main/java/com/uas/platform/b2b/openapi/service/impl/TradingDataServiceImpl.java

@@ -23,7 +23,7 @@ import java.util.List;
  * @Date: Created in 15:45 2018/9/20.
  */
 @Service
-public class TradingDataServiceImpl implements TradingDataService{
+public class TradingDataServiceImpl implements TradingDataService {
 
 
     @Autowired
@@ -45,7 +45,7 @@ public class TradingDataServiceImpl implements TradingDataService{
         // 获取累计发票金额
         Double apBillSum = getApBillSum(enUU);
         // 获取历史退货率
-        String historyReturn = NumFormat.getPercent(realSum/getOrderSum(enUU));
+        String historyReturn = NumFormat.getPercent(realSum / getOrderSum(enUU));
         map.put("timeSum", timeSum);
         map.put("acceptSum", acceptSum);
         map.put("returnSum", returnSum);
@@ -89,9 +89,9 @@ public class TradingDataServiceImpl implements TradingDataService{
         List<RecentOfYear> years = new ArrayList<>();
         // 有交易额客户数量
         RecentOfYear ofYear1 = new RecentOfYear("有交易额客户数量");
-        ofYear1.setTwoYear((double)getAcceptCust(enUU, NumFormat.getTwoYear(), NumFormat.getOneYear()));
-        ofYear1.setOneYear((double)getAcceptCust(enUU, NumFormat.getOneYear(), NumFormat.getThisYear()));
-        ofYear1.setThisYear((double)getAcceptCust(enUU, NumFormat.getThisYear(), NumFormat.getNow()));
+        ofYear1.setTwoYear((double) getAcceptCust(enUU, NumFormat.getTwoYear(), NumFormat.getOneYear()));
+        ofYear1.setOneYear((double) getAcceptCust(enUU, NumFormat.getOneYear(), NumFormat.getThisYear()));
+        ofYear1.setThisYear((double) getAcceptCust(enUU, NumFormat.getThisYear(), NumFormat.getNow()));
         ofYear1.setOneYearNum(NumFormat.getIncrease(ofYear1.getTwoYear(), ofYear1.getOneYear()));
         ofYear1.setThisYearNum(NumFormat.getIncrease(ofYear1.getOneYear(), ofYear1.getThisYear()));
         years.add(ofYear1);
@@ -105,9 +105,9 @@ public class TradingDataServiceImpl implements TradingDataService{
         years.add(ofYear2);
         // 验收笔数
         RecentOfYear ofYear3 = new RecentOfYear("验收笔数");
-        ofYear3.setTwoYear((double)getAcceptNumTime(enUU, NumFormat.getTwoYear(), NumFormat.getOneYear()));
-        ofYear3.setOneYear((double)getAcceptNumTime(enUU, NumFormat.getOneYear(), NumFormat.getThisYear()));
-        ofYear3.setThisYear((double)getAcceptNumTime(enUU, NumFormat.getThisYear(), NumFormat.getNow()));
+        ofYear3.setTwoYear((double) getAcceptNumTime(enUU, NumFormat.getTwoYear(), NumFormat.getOneYear()));
+        ofYear3.setOneYear((double) getAcceptNumTime(enUU, NumFormat.getOneYear(), NumFormat.getThisYear()));
+        ofYear3.setThisYear((double) getAcceptNumTime(enUU, NumFormat.getThisYear(), NumFormat.getNow()));
         ofYear3.setOneYearNum(NumFormat.getIncrease(ofYear3.getTwoYear(), ofYear3.getOneYear()));
         ofYear3.setThisYearNum(NumFormat.getIncrease(ofYear3.getOneYear(), ofYear3.getThisYear()));
         years.add(ofYear3);
@@ -121,9 +121,9 @@ public class TradingDataServiceImpl implements TradingDataService{
         years.add(ofYear4);
         // 验退笔数
         RecentOfYear ofYear5 = new RecentOfYear("验退笔数");
-        ofYear5.setTwoYear((double)getReturnNumTime(enUU, NumFormat.getTwoYear(), NumFormat.getOneYear()));
-        ofYear5.setOneYear((double)getReturnNumTime(enUU, NumFormat.getOneYear(), NumFormat.getThisYear()));
-        ofYear5.setThisYear((double)getReturnNumTime(enUU, NumFormat.getThisYear(), NumFormat.getNow()));
+        ofYear5.setTwoYear((double) getReturnNumTime(enUU, NumFormat.getTwoYear(), NumFormat.getOneYear()));
+        ofYear5.setOneYear((double) getReturnNumTime(enUU, NumFormat.getOneYear(), NumFormat.getThisYear()));
+        ofYear5.setThisYear((double) getReturnNumTime(enUU, NumFormat.getThisYear(), NumFormat.getNow()));
         ofYear5.setOneYearNum(NumFormat.getIncrease(ofYear5.getTwoYear(), ofYear5.getOneYear()));
         ofYear5.setThisYearNum(NumFormat.getIncrease(ofYear5.getOneYear(), ofYear5.getThisYear()));
         years.add(ofYear5);
@@ -190,13 +190,13 @@ public class TradingDataServiceImpl implements TradingDataService{
         List<RecentOfMonth> months = new ArrayList<>();
         // 有交易额客户数量
         RecentOfMonth ofMonth1 = new RecentOfMonth("有交易额客户数量");
-        ofMonth1.setFourMonth((double)getAcceptCust(enUU, four, three));
-        ofMonth1.setThreeMonth((double)getAcceptCust(enUU, three, two));
-        ofMonth1.setTwoMonth((double)getAcceptCust(enUU, two, one));
-        ofMonth1.setOneMonth((double)getAcceptCust(enUU, one, now));
+        ofMonth1.setFourMonth((double) getAcceptCust(enUU, four, three));
+        ofMonth1.setThreeMonth((double) getAcceptCust(enUU, three, two));
+        ofMonth1.setTwoMonth((double) getAcceptCust(enUU, two, one));
+        ofMonth1.setOneMonth((double) getAcceptCust(enUU, one, now));
         ofMonth1.setThreeMonthNum(NumFormat.getIncrease(ofMonth1.getFourMonth(), ofMonth1.getThreeMonth()));
         ofMonth1.setTwoMonthNum(NumFormat.getIncrease(ofMonth1.getThreeMonth(), ofMonth1.getTwoMonth()));
-        ofMonth1.setOneMonthNum(NumFormat.getIncrease(ofMonth1.getTwoMonth(),ofMonth1.getOneMonth()));
+        ofMonth1.setOneMonthNum(NumFormat.getIncrease(ofMonth1.getTwoMonth(), ofMonth1.getOneMonth()));
         months.add(ofMonth1);
         // 验收金额
         RecentOfMonth ofMonth2 = new RecentOfMonth("验收金额");
@@ -206,17 +206,17 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth2.setOneMonth(getAcceptSumTime(enUU, one, now));
         ofMonth2.setThreeMonthNum(NumFormat.getIncrease(ofMonth2.getFourMonth(), ofMonth2.getThreeMonth()));
         ofMonth2.setTwoMonthNum(NumFormat.getIncrease(ofMonth2.getThreeMonth(), ofMonth2.getTwoMonth()));
-        ofMonth2.setOneMonthNum(NumFormat.getIncrease(ofMonth2.getTwoMonth(),ofMonth2.getOneMonth()));
+        ofMonth2.setOneMonthNum(NumFormat.getIncrease(ofMonth2.getTwoMonth(), ofMonth2.getOneMonth()));
         months.add(ofMonth2);
         // 验收笔数
         RecentOfMonth ofMonth3 = new RecentOfMonth("验收笔数");
-        ofMonth3.setFourMonth((double)getAcceptNumTime(enUU, four, three));
-        ofMonth3.setThreeMonth((double)getAcceptNumTime(enUU, three, two));
-        ofMonth3.setTwoMonth((double)getAcceptNumTime(enUU, two, one));
-        ofMonth3.setOneMonth((double)getAcceptNumTime(enUU, one, now));
+        ofMonth3.setFourMonth((double) getAcceptNumTime(enUU, four, three));
+        ofMonth3.setThreeMonth((double) getAcceptNumTime(enUU, three, two));
+        ofMonth3.setTwoMonth((double) getAcceptNumTime(enUU, two, one));
+        ofMonth3.setOneMonth((double) getAcceptNumTime(enUU, one, now));
         ofMonth3.setThreeMonthNum(NumFormat.getIncrease(ofMonth3.getFourMonth(), ofMonth3.getThreeMonth()));
         ofMonth3.setTwoMonthNum(NumFormat.getIncrease(ofMonth3.getThreeMonth(), ofMonth3.getTwoMonth()));
-        ofMonth3.setOneMonthNum(NumFormat.getIncrease(ofMonth3.getTwoMonth(),ofMonth3.getOneMonth()));
+        ofMonth3.setOneMonthNum(NumFormat.getIncrease(ofMonth3.getTwoMonth(), ofMonth3.getOneMonth()));
         months.add(ofMonth3);
         // 验退金额
         RecentOfMonth ofMonth4 = new RecentOfMonth("验退金额");
@@ -226,17 +226,17 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth4.setOneMonth(getReturnSumTime(enUU, one, now));
         ofMonth4.setThreeMonthNum(NumFormat.getIncrease(ofMonth4.getFourMonth(), ofMonth4.getThreeMonth()));
         ofMonth4.setTwoMonthNum(NumFormat.getIncrease(ofMonth4.getThreeMonth(), ofMonth4.getTwoMonth()));
-        ofMonth4.setOneMonthNum(NumFormat.getIncrease(ofMonth4.getTwoMonth(),ofMonth4.getOneMonth()));
+        ofMonth4.setOneMonthNum(NumFormat.getIncrease(ofMonth4.getTwoMonth(), ofMonth4.getOneMonth()));
         months.add(ofMonth4);
         // 验退笔数
         RecentOfMonth ofMonth5 = new RecentOfMonth("验退笔数");
-        ofMonth5.setFourMonth((double)getReturnNumTime(enUU, four, three));
-        ofMonth5.setThreeMonth((double)getReturnNumTime(enUU, three, two));
-        ofMonth5.setTwoMonth((double)getReturnNumTime(enUU, two, one));
-        ofMonth5.setOneMonth((double)getReturnNumTime(enUU, one, now));
+        ofMonth5.setFourMonth((double) getReturnNumTime(enUU, four, three));
+        ofMonth5.setThreeMonth((double) getReturnNumTime(enUU, three, two));
+        ofMonth5.setTwoMonth((double) getReturnNumTime(enUU, two, one));
+        ofMonth5.setOneMonth((double) getReturnNumTime(enUU, one, now));
         ofMonth5.setThreeMonthNum(NumFormat.getIncrease(ofMonth5.getFourMonth(), ofMonth5.getThreeMonth()));
         ofMonth5.setTwoMonthNum(NumFormat.getIncrease(ofMonth5.getThreeMonth(), ofMonth5.getTwoMonth()));
-        ofMonth5.setOneMonthNum(NumFormat.getIncrease(ofMonth5.getTwoMonth(),ofMonth5.getOneMonth()));
+        ofMonth5.setOneMonthNum(NumFormat.getIncrease(ofMonth5.getTwoMonth(), ofMonth5.getOneMonth()));
         months.add(ofMonth5);
         // 实收金额
         RecentOfMonth ofMonth6 = new RecentOfMonth("实收金额");
@@ -246,7 +246,7 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth6.setOneMonth(ofMonth2.getOneMonth() - ofMonth4.getOneMonth());
         ofMonth6.setThreeMonthNum(NumFormat.getIncrease(ofMonth6.getFourMonth(), ofMonth6.getThreeMonth()));
         ofMonth6.setTwoMonthNum(NumFormat.getIncrease(ofMonth6.getThreeMonth(), ofMonth6.getTwoMonth()));
-        ofMonth6.setOneMonthNum(NumFormat.getIncrease(ofMonth6.getTwoMonth(),ofMonth6.getOneMonth()));
+        ofMonth6.setOneMonthNum(NumFormat.getIncrease(ofMonth6.getTwoMonth(), ofMonth6.getOneMonth()));
         months.add(ofMonth6);
         // 实收笔数
         RecentOfMonth ofMonth7 = new RecentOfMonth("实收笔数");
@@ -256,7 +256,7 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth7.setOneMonth(ofMonth3.getOneMonth() - ofMonth5.getOneMonth());
         ofMonth7.setThreeMonthNum(NumFormat.getIncrease(ofMonth7.getFourMonth(), ofMonth7.getThreeMonth()));
         ofMonth7.setTwoMonthNum(NumFormat.getIncrease(ofMonth7.getThreeMonth(), ofMonth7.getTwoMonth()));
-        ofMonth7.setOneMonthNum(NumFormat.getIncrease(ofMonth7.getTwoMonth(),ofMonth7.getOneMonth()));
+        ofMonth7.setOneMonthNum(NumFormat.getIncrease(ofMonth7.getTwoMonth(), ofMonth7.getOneMonth()));
         months.add(ofMonth7);
         // 对账金额
         RecentOfMonth ofMonth8 = new RecentOfMonth("对账金额");
@@ -266,7 +266,7 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth8.setOneMonth(getApCheckSumTime(enUU, one, now));
         ofMonth8.setThreeMonthNum(NumFormat.getIncrease(ofMonth8.getFourMonth(), ofMonth8.getThreeMonth()));
         ofMonth8.setTwoMonthNum(NumFormat.getIncrease(ofMonth8.getThreeMonth(), ofMonth8.getTwoMonth()));
-        ofMonth8.setOneMonthNum(NumFormat.getIncrease(ofMonth8.getTwoMonth(),ofMonth8.getOneMonth()));
+        ofMonth8.setOneMonthNum(NumFormat.getIncrease(ofMonth8.getTwoMonth(), ofMonth8.getOneMonth()));
         months.add(ofMonth8);
         // 对账笔数
         RecentOfMonth ofMonth9 = new RecentOfMonth("对账笔数");
@@ -276,7 +276,7 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth9.setOneMonth(getApCheckNumTime(enUU, one, now));
         ofMonth9.setThreeMonthNum(NumFormat.getIncrease(ofMonth9.getFourMonth(), ofMonth9.getThreeMonth()));
         ofMonth9.setTwoMonthNum(NumFormat.getIncrease(ofMonth9.getThreeMonth(), ofMonth9.getTwoMonth()));
-        ofMonth9.setOneMonthNum(NumFormat.getIncrease(ofMonth9.getTwoMonth(),ofMonth9.getOneMonth()));
+        ofMonth9.setOneMonthNum(NumFormat.getIncrease(ofMonth9.getTwoMonth(), ofMonth9.getOneMonth()));
         months.add(ofMonth9);
         // 开票金额
         RecentOfMonth ofMonth10 = new RecentOfMonth("开票金额");
@@ -286,7 +286,7 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth10.setOneMonth(getApBillSumTime(enUU, one, now));
         ofMonth10.setThreeMonthNum(NumFormat.getIncrease(ofMonth10.getFourMonth(), ofMonth10.getThreeMonth()));
         ofMonth10.setTwoMonthNum(NumFormat.getIncrease(ofMonth10.getThreeMonth(), ofMonth10.getTwoMonth()));
-        ofMonth10.setOneMonthNum(NumFormat.getIncrease(ofMonth10.getTwoMonth(),ofMonth10.getOneMonth()));
+        ofMonth10.setOneMonthNum(NumFormat.getIncrease(ofMonth10.getTwoMonth(), ofMonth10.getOneMonth()));
         months.add(ofMonth10);
         // 开票笔数
         RecentOfMonth ofMonth11 = new RecentOfMonth("开票笔数");
@@ -296,177 +296,288 @@ public class TradingDataServiceImpl implements TradingDataService{
         ofMonth11.setOneMonth(getApBillNumTime(enUU, one, now));
         ofMonth11.setThreeMonthNum(NumFormat.getIncrease(ofMonth11.getFourMonth(), ofMonth11.getThreeMonth()));
         ofMonth11.setTwoMonthNum(NumFormat.getIncrease(ofMonth11.getThreeMonth(), ofMonth11.getTwoMonth()));
-        ofMonth11.setOneMonthNum(NumFormat.getIncrease(ofMonth11.getTwoMonth(),ofMonth11.getOneMonth()));
+        ofMonth11.setOneMonthNum(NumFormat.getIncrease(ofMonth11.getTwoMonth(), ofMonth11.getOneMonth()));
         months.add(ofMonth11);
         map.put("data", months);
         return map;
     }
 
-    private Double getTimeSum(Long enUU, Long custUU){
-        StringBuffer last = new StringBuffer("SELECT ifnull((SELECT pu_date from purc$orders " +
-                "WHERE pu_venduu = " + enUU + " and pu_date is not null ");
+    /**
+     * 交易时间
+     * @param enUU 卖方uu
+     * @param custUU 客户uu
+     * @return 交易时间
+     */
+    private Double getTimeSum(Long enUU, Long custUU) {
+        StringBuffer last = new StringBuffer("SELECT ifnull((SELECT pu_date from purc$orders "
+                + "WHERE pu_venduu = " + enUU + " and pu_date is not null ");
         if (!StringUtils.isEmpty(custUU)) {
             last.append("and pu_enuu = " + custUU + "");
         }
         last.append(" ORDER BY pu_date desc limit 1),now()) pu_date");
-        StringBuffer first = new StringBuffer("SELECT ifnull((SELECT pu_date from purc$orders " +
-                "WHERE pu_venduu = " + enUU + " and pu_date is not null ");
+        StringBuffer first = new StringBuffer("SELECT ifnull((SELECT pu_date from purc$orders "
+                + "WHERE pu_venduu = " + enUU + " and pu_date is not null ");
         if (!StringUtils.isEmpty(custUU)) {
             first.append("and pu_enuu = " + custUU + "");
         }
         first.append(" ORDER BY pu_date asc limit 1),now()) pu_date");
         Date lastTime = commonDao.queryForObject(last.toString(), Date.class);
         Date firstTime = commonDao.queryForObject(first.toString(), Date.class);
-        StringBuffer result = new StringBuffer("SELECT TIMESTAMPDIFF(MONTH,'" + firstTime + "','" + lastTime +"')");
+        StringBuffer result = new StringBuffer("SELECT TIMESTAMPDIFF(MONTH,'" + firstTime + "','" + lastTime + "')");
         Double resultTime = commonDao.queryForObject(result.toString(), Double.class) / TimeStauts.TYEAR.value();
         return NumFormat.getOne(resultTime);
     }
 
+    /**
+     * 验收金额
+     * @param enUU 卖方uu
+     * @param custUU 客户uu
+     * @return 验收金额
+     */
     private Double getAcceptSum(Long enUU, Long custUU) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (SELECT SUM(pai_qty*pai_orderprice) amount,pa_currency currency FROM purc$accept LEFT JOIN purc$acceptitem " +
-                "on pai_paid=pa_id WHERE pa_venduu= " + enUU);
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + " then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) "
+                + " result FROM (SELECT SUM(pai_qty*pai_orderprice) amount,pa_currency currency FROM purc$accept LEFT "
+                + " JOIN purc$acceptitem on pai_paid=pa_id WHERE pa_venduu= " + enUU);
         if (!StringUtils.isEmpty(custUU)) {
             sql.append(" and pa_enuu = " + custUU + " ");
         }
         sql.append(" GROUP BY pa_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
-        return NumFormat.getTwo(result);
+        return NumFormat.getTwo(NumFormat.getTenThousand(result));
     }
 
+    /**
+     * 验退金额
+     * @param enUU 卖方uu
+     * @param custUU 客户uu
+     * @return 验退金额
+     */
     private Double getReturnSum(Long enUU, Long custUU) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (SELECT SUM(pri_qty*pri_orderprice) amount,pr_currency currency FROM purc$return LEFT JOIN purc$returnitem " +
-                "on pri_prid=pr_id WHERE pr_venduu= " + enUU);
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) "
+                + " result FROM (SELECT SUM(pri_qty*pri_orderprice) amount,pr_currency currency FROM purc$return "
+                + " LEFT JOIN purc$returnitem on pri_prid=pr_id WHERE pr_venduu= " + enUU);
         if (!StringUtils.isEmpty(custUU)) {
             sql.append(" and pr_enuu = " + custUU + " ");
         }
         sql.append(" GROUP BY pr_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
-        return NumFormat.getTwo(result);
+        return NumFormat.getTwo(NumFormat.getTenThousand(result));
     }
 
+    /**
+     * 对账金额
+     * @param enUU 卖方uu
+     * @return 对账金额
+     */
     private Double getApCheckSum(Long enUU) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (select sum(pa_checkamount) amount,pa_currency currency from purc$apcheck where pa_enuu = " + enUU +
-                " and pa_checkstatus = '已确认' GROUP BY pa_currency) a");
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
+                + "FROM (select sum(pa_checkamount) amount,pa_currency currency from purc$apcheck where pa_enuu = " + enUU
+                + " and pa_checkstatus = '已确认' GROUP BY pa_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
-        return NumFormat.getTwo(result);
+        return NumFormat.getTwo(NumFormat.getTenThousand(result));
     }
 
+    /**
+     * 发票金额
+     * @param enUU 卖方uu
+     * @return 发票金额
+     */
     private Double getApBillSum(Long enUU) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (SELECT SUM(pab_paymount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU  +
-                " GROUP BY pab_currency) a");
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
+                + "FROM (SELECT SUM(pab_paymount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU
+                + " GROUP BY pab_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
-        return NumFormat.getTwo(result);
+        return NumFormat.getTwo(NumFormat.getTenThousand(result));
     }
 
+    /**
+     * 订单金额
+     * @param enUU 卖方uu
+     * @return 订单金额
+     */
     private Double getOrderSum(Long enUU) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (SELECT sum(pd_price) amount,pu_currency currency FROM purc$orders LEFT JOIN purc$orderitems " +
-                "on pu_id=pd_puid where pu_venduu = " + enUU + " GROUP BY pu_currency) a");
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
+                + "FROM (SELECT sum(pd_price) amount,pu_currency currency FROM purc$orders LEFT JOIN purc$orderitems "
+                + "on pu_id=pd_puid where pu_venduu = " + enUU + " GROUP BY pu_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
-        return NumFormat.getTwo(result);
+        return NumFormat.getTwo(NumFormat.getTenThousand(result));
     }
 
+    /**
+     * 客户
+     * @param enUU 卖方uu
+     * @return 客户
+     */
     private List<CustTrading> getCust(Long enUU) {
-        StringBuffer sql = new StringBuffer("SELECT en_uu custUU,en_name custName FROM sec$enterprises WHERE en_uu in " +
-                "(SELECT ve_myenuu FROM purc$vendors WHERE ve_vendenuu= " + enUU + " ) ORDER BY en_name");
-        List<CustTrading> custTradings = new ArrayList<>();
+        StringBuffer sql = new StringBuffer("SELECT en_uu custUU,en_name custName FROM sec$enterprises WHERE en_uu in "
+                + "(SELECT ve_myenuu FROM purc$vendors WHERE ve_vendenuu= " + enUU + " ) ORDER BY en_name");
         return commonDao.query(sql.toString(), CustTrading.class);
     }
 
+    /**
+     * 验收笔数
+     * @param enUU 卖方uu
+     * @param custUU 客户uu
+     * @return 验收笔数
+     */
     private Integer getAcceptNum(Long enUU, Long custUU) {
-        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$accept WHERE pa_venduu= " + enUU +
-                " AND pa_enuu=" + custUU);
+        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$accept WHERE pa_venduu= " + enUU
+                + " AND pa_enuu=" + custUU);
         Integer result = commonDao.queryForObject(sql.toString(), Integer.class);
         return result;
     }
 
+    /**
+     * 验退金额
+     * @param enUU 卖方uu
+     * @param custUU 客户uu
+     * @return 验退金额
+     */
     private Integer getReturnNum(Long enUU, Long custUU) {
-        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$return  WHERE pr_venduu= " + enUU +
-                " and  pr_enuu= " + custUU);
+        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$return  WHERE pr_venduu= " + enUU
+                + " and  pr_enuu= " + custUU);
         Integer result = commonDao.queryForObject(sql.toString(), Integer.class);
         return result;
     }
 
+    /**
+     * 有交易客户数
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 有交易客户数
+     */
     private Integer getAcceptCust(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT COUNT(1) from purc$orders WHERE pu_venduu= " + enUU +
-                " AND pu_date >= '" + startTime + "' and pu_date < " + endTime);
+        StringBuffer sql = new StringBuffer("SELECT COUNT(1) from purc$orders WHERE pu_venduu= " + enUU
+                + " AND pu_date >= '" + startTime + "' and pu_date < " + endTime);
         Integer result = commonDao.queryForObject(sql.toString(), Integer.class);
         return result;
     }
 
+    /**
+     * 验收金额
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return  验收金额
+     */
     private Double getAcceptSumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (SELECT SUM(pai_qty*pai_orderprice) amount,pa_currency currency FROM purc$accept LEFT JOIN purc$acceptitem " +
-                "on pai_paid=pa_id WHERE pa_venduu= " + enUU + " and pa_date >= " + startTime + " and pa_date < " + endTime +
-                " GROUP BY pa_currency) a");
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
+                + "FROM (SELECT SUM(pai_qty*pai_orderprice) amount,pa_currency currency FROM purc$accept LEFT JOIN purc$acceptitem "
+                + "on pai_paid=pa_id WHERE pa_venduu= " + enUU + " and pa_date >= " + startTime + " and pa_date < " + endTime
+                + " GROUP BY pa_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
         return NumFormat.getTwo(result);
     }
 
+    /**
+     * 验退金额
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 验退金额
+     */
     private Double getReturnSumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (SELECT SUM(pri_qty*pri_orderprice) amount,pr_currency currency FROM purc$return LEFT JOIN purc$returnitem " +
-                "on pri_prid=pr_id WHERE pr_venduu= " + enUU +" and pr_date >= " + startTime + " and pr_date < " + endTime +
-                " GROUP BY pr_currency) a");
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
+                + "FROM (SELECT SUM(pri_qty*pri_orderprice) amount,pr_currency currency FROM purc$return LEFT JOIN purc$returnitem "
+                + "on pri_prid=pr_id WHERE pr_venduu= " + enUU + " and pr_date >= " + startTime + " and pr_date < " + endTime
+                + " GROUP BY pr_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
         return NumFormat.getTwo(result);
     }
 
+    /**
+     * 验收笔数
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 验收笔数
+     */
     private Integer getAcceptNumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$accept WHERE pa_venduu= " + enUU +
-                " and pa_date >= " + startTime + " and pa_date < " + endTime);
+        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$accept WHERE pa_venduu= " + enUU
+                + " and pa_date >= " + startTime + " and pa_date < " + endTime);
         Integer result = commonDao.queryForObject(sql.toString(), Integer.class);
         return result;
     }
 
+    /**
+     * 验退笔数
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 验退笔数
+     */
     private Integer getReturnNumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$return  WHERE pr_venduu= " + enUU +
-                " and pr_date >= " + startTime + " and pr_date < " + endTime);
+        StringBuffer sql = new StringBuffer("SELECT COUNT(1) FROM purc$return  WHERE pr_venduu= " + enUU
+                + " and pr_date >= " + startTime + " and pr_date < " + endTime);
         Integer result = commonDao.queryForObject(sql.toString(), Integer.class);
         return result;
     }
 
+    /**
+     * 对账金额
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 对账金额
+     */
     private Double getApCheckSumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (select sum(pa_checkamount) amount,pa_currency currency from purc$apcheck where pa_enuu = " + enUU +
-                " and pa_checkstatus = '已确认' and pa_recorddate >= " + startTime + " and pa_recorddate < " + endTime +
-                " GROUP BY pa_currency) a");
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + " then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
+                + " FROM (select sum(pa_checkamount) amount,pa_currency currency from purc$apcheck where pa_enuu = " + enUU
+                + " and pa_checkstatus = '已确认' and pa_recorddate >= " + startTime + " and pa_recorddate < " + endTime
+                + " GROUP BY pa_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
         return NumFormat.getTwo(result);
     }
 
+    /**
+     * 对账笔数
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 对账笔数
+     */
     private Double getApCheckNumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT COUNT(1) from purc$apcheck where pa_enuu = " + enUU +
-                " and pa_checkstatus = '已确认' and pa_recorddate >= " + startTime + " and pa_recorddate < " + endTime);
+        StringBuffer sql = new StringBuffer("SELECT COUNT(1) from purc$apcheck where pa_enuu = " + enUU
+                + " and pa_checkstatus = '已确认' and pa_recorddate >= " + startTime + " and pa_recorddate < " + endTime);
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
         return NumFormat.getTwo(result);
     }
 
+    /**
+     * 发票金额
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 发票金额
+     */
     private Double getApBillSumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' " +
-                "then a.amount * " + ErpRate.USD_RATE+ " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result " +
-                "FROM (SELECT SUM(pab_paymount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU  +
-                " and pab_date >= " + startTime + " and pab_date < " + endTime +
-                " GROUP BY pab_currency) a");
+        StringBuffer sql = new StringBuffer("SELECT sum(case currency when 'RMB' then a.amount when 'USD' "
+                + "then a.amount * " + ErpRate.USD_RATE + " when 'HKD' then a.amount * " + ErpRate.HKD_RATE + " end) result "
+                + "FROM (SELECT SUM(pab_paymount) amount,pab_currency currency FROM purc$apbill WHERE pad_venduu=" + enUU
+                + " and pab_date >= " + startTime + " and pab_date < " + endTime + " GROUP BY pab_currency) a");
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
         return NumFormat.getTwo(result);
     }
 
+    /**
+     * 发票笔数
+     * @param enUU 卖方uu
+     * @param startTime 起始时间
+     * @param endTime 终止时间
+     * @return 发票笔数
+     */
     private Double getApBillNumTime(Long enUU, Date startTime, Date endTime) {
-        StringBuffer sql = new StringBuffer("SELECT COUNT(1) from purc$apbill WHERE pad_venduu=" + enUU  +
-                " and pab_date >= " + startTime + " and pab_date < " + endTime );
+        StringBuffer sql = new StringBuffer("SELECT COUNT(1) from purc$apbill WHERE pad_venduu=" + enUU
+                + " and pab_date >= " + startTime + " and pab_date < " + endTime);
         Double result = commonDao.queryForObject(sql.toString(), Double.class);
         return NumFormat.getTwo(result);
     }

+ 1 - 1
src/main/java/com/uas/platform/b2b/openapi/service/impl/UsoftFxServiceImpl.java

@@ -76,7 +76,7 @@ public class UsoftFxServiceImpl implements UsoftFxService{
                         if (order.getId().equals(fxPurOrder.getId())) {
                             // 不存在该明细,新增
                             if (!exitOrderItem) {
-                                Double orderItemAmout = 0d ;
+                                Double orderItemAmout = 0d;
                                 if (!StringUtils.isEmpty(orderItem.getQty()) && !StringUtils.isEmpty(orderItem.getPrice())) {
                                     orderItemAmout = orderItem.getQty() * orderItem.getPrice();
                                 }

+ 8 - 0
src/main/java/com/uas/platform/b2b/openapi/support/NumFormat.java

@@ -13,6 +13,14 @@ import java.util.Date;
  */
 public class NumFormat {
 
+    public static Double getTenThousand(Double result) {
+        if (StringUtils.isEmpty(result)) {
+            return getTwo(result);
+        } else {
+            return result / 10000;
+        }
+    }
+
     public static Double getOne(Double result) {
         DecimalFormat df = new DecimalFormat("#.0");
         if (StringUtils.isEmpty(result)) {