Parcourir la source

返利结算单导出

hu il y a 2 ans
Parent
commit
84525c1088

+ 4 - 0
src/custom/restcontroller/R.java

@@ -5237,6 +5237,10 @@ public class R {
         public static class v1 {
         }
     }
+    public static class ID20230829161203 {
+        public static class v1 {
+        }
+    }
 
 
 }

+ 12 - 0
src/custom/restcontroller/webmanage/sale/rebateaccount/SQL/返利结算单导出.sql

@@ -0,0 +1,12 @@
+SELECT
+    t4.billno,
+    t5.agentnum,
+    t2.sonum,
+		t1.amount,
+	  t1.rateamount
+FROM  sa_rebateaccountdetail t1
+    left join sa_order t2 on t1.sa_orderid=t2.sa_orderid and t1.siteid=t2.siteid
+    left join sa_rebateaccount t3 on t1.sa_rebateaccountid=t3.sa_rebateaccountid and t1.siteid=t3.siteid
+    left join sa_rebateaccounthead t4 on t4.sa_rebateaccountheadid=t3.sa_rebateaccountheadid and t4.siteid=t3.siteid
+    left join sa_agents t5 on t3.sys_enterpriseid=t5.sys_enterpriseid and t3.siteid=t5.siteid
+where  t1.siteid=$siteid$ and t4.sa_rebateaccountheadid=$sa_rebateaccountheadid$

+ 39 - 22
src/custom/restcontroller/webmanage/sale/rebateaccount/rebateaccounthead.java

@@ -85,15 +85,26 @@ public class rebateaccounthead extends Controller {
         return getSucReturnObject().setData(row).toString();
     }
 
+    @API(title = "返利结算单导出", apiversion = R.ID20230829161203.v1.class)
+    @CACHEING
+    public String expportrebateaccountheadMain() throws YosException, IOException {
+        Long sa_rebateaccountheadid = content.getLong("sa_rebateaccountheadid");
+        System.out.println(1111);
+        SQLFactory sqlFactory = new SQLFactory(this, "返利结算单导出");
+        sqlFactory.addParameter("sa_rebateaccountheadid", sa_rebateaccountheadid);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory);
+        Rows uploadRows = uploadExcelToObs("rebateaccount", " 返利结算单数据列表", rows, getTitleMap());
+        return getSucReturnObject().setData(uploadRows).toString();
+    }
+
     //返回导出的标题
     public HashMap<String, String> getTitleMap() {
         HashMap<String, String> titleMap = new HashMap<>();
+        titleMap.put("billno", "单号");
         titleMap.put("agentnum", "经销商编码");
-        titleMap.put("enterprisename", "经销商名称");
-        titleMap.put("accumulatedamount", "累计订购返利商品金额");
-        titleMap.put("rebateamount", "装修返利金额");
         titleMap.put("sonum", "订单号");
-        titleMap.put("amount", "订单金额(活动商品)");
+        titleMap.put("amount", "订单金额");
         titleMap.put("rateamount", "返利金额");
         return titleMap;
     }
@@ -412,27 +423,33 @@ public class rebateaccounthead extends Controller {
 
         if (ischeck) {
             for (Row row :rebateaccounts) {
-                CashbillEntity entity = new CashbillEntity();
-                entity.setAmount(row.getBigDecimal("rebateamount"));
-                entity.setOwnerid(row.getLong("sa_rebateaccountid"));
-                entity.setOwnertable("sa_rebateaccount");
-                entity.setSource("返利");
-                entity.setSourcenote(row.getString("billno")+"结算单返利");
-                entity.setRemarks(row.getString("billno")+"结算单装修补贴返利");
-                sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
-                sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), true, row.getBigDecimal("rebateamount")));
+                if(row.getBigDecimal("rebateamount").compareTo(BigDecimal.ZERO)>0){
+                    CashbillEntity entity = new CashbillEntity();
+                    entity.setAmount(row.getBigDecimal("rebateamount"));
+                    entity.setOwnerid(row.getLong("sa_rebateaccountid"));
+                    entity.setOwnertable("sa_rebateaccount");
+                    entity.setSource("返利");
+                    entity.setSourcenote(row.getString("billno")+"结算单返利");
+                    entity.setRemarks(row.getString("billno")+"结算单装修补贴返利");
+                    sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
+                    sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), true, row.getBigDecimal("rebateamount")));
+                }
+
             }
         }else{
             for (Row row :rebateaccounts) {
-                CashbillEntity entity = new CashbillEntity();
-                entity.setAmount(row.getBigDecimal("rebateamount").negate());
-                entity.setOwnerid(row.getLong("sa_rebateaccountid"));
-                entity.setOwnertable("sa_rebateaccount");
-                entity.setSource("返利");
-                entity.setSourcenote(row.getString("billno")+"结算单反审核");
-                entity.setRemarks("装修补贴返利反审核生成");
-                sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
-                sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), false, row.getBigDecimal("rebateamount")));
+                if(row.getBigDecimal("rebateamount").compareTo(BigDecimal.ZERO)>0){
+                    CashbillEntity entity = new CashbillEntity();
+                    entity.setAmount(row.getBigDecimal("rebateamount").negate());
+                    entity.setOwnerid(row.getLong("sa_rebateaccountid"));
+                    entity.setOwnertable("sa_rebateaccount");
+                    entity.setSource("返利");
+                    entity.setSourcenote(row.getString("billno")+"结算单反审核");
+                    entity.setRemarks("装修补贴返利反审核生成");
+                    sqlList.addAll(Accountbalance.createCashbillIncome(this, row.getLong("sys_enterpriseid"),sa_accountclassid,entity,true));
+                    sqlList.addAll(Accountbalance.rebateupdate(this, row.getLong("sys_enterpriseid"), false, row.getBigDecimal("rebateamount")));
+                }
+
             }
         }