Просмотр исходного кода

业务员、经销商业绩统计月度明细季度明细增加已开票金额统计

沈静伟 4 лет назад
Родитель
Сommit
5eb168654c

+ 34 - 0
src/rest/openapi/restcontroller/wechatapp/tagents/SQL/开票金额汇总查询.sql

@@ -0,0 +1,34 @@
+with a as ( select MONTH(t1.checkdate)fmonth,sum(t3.taxincludedamount)as finvoiceamount from tinvoiceapply t1
+			inner join tinvoicebill t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid and t2.status='2'
+			inner join tinvoicebillitem t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoicebillid=t3.tinvoicebillid
+           where t1.fagentnum=$fagentnum$ and t1.siteid=$siteid$
+		   and YEAR (t1.checkdate)=$fyear$ and t1.fstatus='审核'  and t1.ftype='自动'
+		   group by MONTH (t1.checkdate)
+union all
+ select MONTH(t1.checkdate)fmonth,sum(t3.taxincludedamount)as finvoiceamount from tinvoiceapply t1
+			inner join tinvoicebill t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid
+			inner join tinvoicebillitem t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoicebillid=t3.tinvoicebillid
+            where t1.fagentnum=$fagentnum$ and t1.siteid=$siteid$
+		   and YEAR (t1.checkdate)=$fyear$ and t1.fstatus='审核'  and t1.ftype='手工'
+		   group by MONTH (t1.checkdate)
+)
+select '月' ftype, fmonth number, sum(finvoiceamount)finvoiceamount from a group by fmonth
+
+union all
+select '季'               ftype,
+       case
+         when fmonth in (1, 2, 3) then 1
+         when fmonth in (4, 5, 6) then 2
+         when fmonth in (7, 8, 9) then 3
+         when fmonth in (10, 11, 12) then 4 end,
+       sum(finvoiceamount) finvoiceamount
+from a
+group by case
+           when fmonth in (1, 2, 3) then 1
+           when fmonth in (4, 5, 6) then 2
+           when fmonth in (7, 8, 9) then 3
+           when fmonth in (10, 11, 12) then 4 end
+union all
+select '年' ftype, $fyear$, sum (finvoiceamount) finvoiceamount
+from a
+

+ 39 - 2
src/rest/openapi/restcontroller/wechatapp/tagents/Tagents.java

@@ -367,11 +367,19 @@ public class Tagents extends Controller {
             amountfactory.addParameter("fieldname", fieldname);
             amountfactory.addParameter("fieldname", fieldname);
             Rows amountRows = connect.runSqlQuery(amountfactory.getSQL());
             Rows amountRows = connect.runSqlQuery(amountfactory.getSQL());
 
 
+            SQLFactory ainvoicefactory = new SQLFactory(this, "开票金额汇总查询");
+            ainvoicefactory.addParameter("fagentnum", fagentnum);
+            ainvoicefactory.addParameter("siteid", siteid);
+            ainvoicefactory.addParameter_SQL("fyear", content.getString("fyear"));
+            ainvoicefactory.addParameter("fieldname", fieldname);
+            Rows invoiceamountRows = connect.runSqlQuery(ainvoicefactory.getSQL());
+
             /**
             /**
              * 年度订单金额及完成率预设
              * 年度订单金额及完成率预设
              */
              */
             yearrow.put("forderamount", 0);
             yearrow.put("forderamount", 0);
             yearrow.put("fcompletionrate", 0);
             yearrow.put("fcompletionrate", 0);
+            yearrow.put("finvoiceamount", 0);
 
 
             /**
             /**
              * 开始遍历年度订单金额及完成率计算
              * 开始遍历年度订单金额及完成率计算
@@ -385,6 +393,16 @@ public class Tagents extends Controller {
                     break;
                     break;
                 }
                 }
             }
             }
+            /**
+             * 开始遍历年度开票金额
+             */
+            for (Row invoiceamountRow : invoiceamountRows) {
+                if ("年".equals(invoiceamountRow.getString("ftype"))) {
+                    double finvoiceamount = invoiceamountRow.getDouble("finvoiceamount");
+                    yearrow.put("finvoiceamount", finvoiceamount);
+                    break;
+                }
+            }
 
 
             /**
             /**
              * SQL季度任务查询参数设置并查询
              * SQL季度任务查询参数设置并查询
@@ -408,7 +426,7 @@ public class Tagents extends Controller {
                  */
                  */
                 quarterrow.put("forderamount", 0);
                 quarterrow.put("forderamount", 0);
                 quarterrow.put("fcompletionrate", 0);
                 quarterrow.put("fcompletionrate", 0);
-
+                quarterrow.put("finvoiceamount", 0);
                 /**
                 /**
                  * 开始遍历季度订单金额及完成率计算
                  * 开始遍历季度订单金额及完成率计算
                  */
                  */
@@ -421,8 +439,17 @@ public class Tagents extends Controller {
                         break;
                         break;
                     }
                     }
                 }
                 }
+                /**
+                 * 开始遍历季度开票金额
+                 */
+                for (Row invoiceamountRow : invoiceamountRows) {
+                    if ("季".equals(invoiceamountRow.getString("ftype")) && quarter.equals(invoiceamountRow.getString("number"))) {
+                        double finvoiceamount = invoiceamountRow.getDouble("finvoiceamount");
+                        quarterrow.put("finvoiceamount", finvoiceamount);
+                        break;
+                    }
+                }
             }
             }
-
             /**
             /**
              * SQL月度任务查询参数设置并查询
              * SQL月度任务查询参数设置并查询
              */
              */
@@ -457,6 +484,16 @@ public class Tagents extends Controller {
                         break;
                         break;
                     }
                     }
                 }
                 }
+                /**
+                 * 开始遍历月度开票金额
+                 */
+                for (Row invoiceamountRow : invoiceamountRows) {
+                    if ("月".equals(invoiceamountRow.getString("ftype")) && month.equals(invoiceamountRow.getString("number"))) {
+                        double finvoiceamount = invoiceamountRow.getDouble("finvoiceamount");
+                        monthrow.put("finvoiceamount", finvoiceamount);
+                        break;
+                    }
+                }
             }
             }
             yearrow.put("quarter", quarterrows);
             yearrow.put("quarter", quarterrows);
             yearrow.put("month", monthrows);
             yearrow.put("month", monthrows);

+ 34 - 0
src/rest/openapi/restcontroller/wechatapp/tsaler/SQL/开票金额汇总查询.sql

@@ -0,0 +1,34 @@
+with a as ( select MONTH(t1.checkdate)fmonth,sum(t3.taxincludedamount)as finvoiceamount from tinvoiceapply t1
+			inner join tinvoicebill t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid and t2.status='2'
+			inner join tinvoicebillitem t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoicebillid=t3.tinvoicebillid
+           where exists(select fagentnum from tagents_field where hrid in $hrid$ and siteid=t1.siteid and fagentnum=t1.fagentnum) and t1.siteid=$siteid$
+		   and YEAR (t1.checkdate)=$fyear$ and t1.fstatus='审核'  and t1.ftype='自动'
+		   group by MONTH (t1.checkdate)
+union all
+ select MONTH(t1.checkdate)fmonth,sum(t3.taxincludedamount)as finvoiceamount from tinvoiceapply t1
+			inner join tinvoicebill t2 on t1.siteid=t2.siteid and t1.tinvoiceapplyid=t2.tinvoiceapplyid
+			inner join tinvoicebillitem t3 on t2.siteid=t3.siteid and t2.tinvoiceapplyid=t3.tinvoiceapplyid and t2.tinvoicebillid=t3.tinvoicebillid
+           where exists(select fagentnum from tagents_field where hrid in $hrid$ and siteid=t1.siteid and fagentnum=t1.fagentnum) and t1.siteid=$siteid$
+		   and YEAR (t1.checkdate)=$fyear$ and t1.fstatus='审核'  and t1.ftype='手工'
+		   group by MONTH (t1.checkdate)
+)
+select '月' ftype, fmonth number, sum(finvoiceamount)finvoiceamount from a group by fmonth
+
+union all
+select '季'               ftype,
+       case
+         when fmonth in (1, 2, 3) then 1
+         when fmonth in (4, 5, 6) then 2
+         when fmonth in (7, 8, 9) then 3
+         when fmonth in (10, 11, 12) then 4 end,
+       sum(finvoiceamount) finvoiceamount
+from a
+group by case
+           when fmonth in (1, 2, 3) then 1
+           when fmonth in (4, 5, 6) then 2
+           when fmonth in (7, 8, 9) then 3
+           when fmonth in (10, 11, 12) then 4 end
+union all
+select '年' ftype, $fyear$, sum (finvoiceamount) finvoiceamount
+from a
+

+ 40 - 0
src/rest/openapi/restcontroller/wechatapp/tsaler/Tsaler.java

@@ -82,6 +82,7 @@ public class Tsaler extends Controller {
                 ftype = content.getString("ftype");
                 ftype = content.getString("ftype");
             }
             }
             Rows amountRows = null;
             Rows amountRows = null;
+            Rows invoiceamountRows = null;
             if ("打款".equals(ftype)) {
             if ("打款".equals(ftype)) {
                 SQLFactory amountfactory = new SQLFactory(this, "收入凭证金额汇总查询");
                 SQLFactory amountfactory = new SQLFactory(this, "收入凭证金额汇总查询");
                 amountfactory.addParameter_SQL("hrid", hridinwhere);
                 amountfactory.addParameter_SQL("hrid", hridinwhere);
@@ -96,12 +97,20 @@ public class Tsaler extends Controller {
                 amountfactory.addParameter_SQL("fyear", content.getString("fyear"));
                 amountfactory.addParameter_SQL("fyear", content.getString("fyear"));
                 amountRows = connect.runSqlQuery(amountfactory.getSQL());
                 amountRows = connect.runSqlQuery(amountfactory.getSQL());
             }
             }
+            {
+                SQLFactory amountfactory = new SQLFactory(this, "开票金额汇总查询");
+                amountfactory.addParameter_SQL("hrid", hridinwhere);
+                amountfactory.addParameter("siteid", siteid);
+                amountfactory.addParameter_SQL("fyear", content.getString("fyear"));
+                invoiceamountRows = connect.runSqlQuery(amountfactory.getSQL());
+            }
 
 
             /**
             /**
              * 年度订单金额及完成率预设
              * 年度订单金额及完成率预设
              */
              */
             yearrow.put("forderamount", 0);
             yearrow.put("forderamount", 0);
             yearrow.put("fcompletionrate", 0);
             yearrow.put("fcompletionrate", 0);
+            yearrow.put("finvoiceamount", 0);
 
 
             /**
             /**
              * 开始遍历年度订单金额及完成率计算
              * 开始遍历年度订单金额及完成率计算
@@ -115,6 +124,16 @@ public class Tsaler extends Controller {
                     break;
                     break;
                 }
                 }
             }
             }
+            /**
+             * 开始遍历年度开票金额
+             */
+            for (Row invoiceamountRow : invoiceamountRows) {
+                if ("年".equals(invoiceamountRow.getString("ftype"))) {
+                    double finvoiceamount = invoiceamountRow.getDouble("finvoiceamount");
+                    yearrow.put("finvoiceamount", finvoiceamount);
+                    break;
+                }
+            }
 
 
             /**
             /**
              * SQL季度任务查询参数设置并查询
              * SQL季度任务查询参数设置并查询
@@ -137,6 +156,7 @@ public class Tsaler extends Controller {
                  */
                  */
                 quarterrow.put("forderamount", 0);
                 quarterrow.put("forderamount", 0);
                 quarterrow.put("fcompletionrate", 0);
                 quarterrow.put("fcompletionrate", 0);
+                quarterrow.put("finvoiceamount", 0);
                 /**
                 /**
                  * 开始遍历季度订单金额及完成率计算
                  * 开始遍历季度订单金额及完成率计算
                  */
                  */
@@ -149,6 +169,16 @@ public class Tsaler extends Controller {
                         break;
                         break;
                     }
                     }
                 }
                 }
+                /**
+                 * 开始遍历季度开票金额
+                 */
+                for (Row invoiceamountRow : invoiceamountRows) {
+                    if ("季".equals(invoiceamountRow.getString("ftype")) && quarter.equals(invoiceamountRow.getString("number"))) {
+                        double finvoiceamount = invoiceamountRow.getDouble("finvoiceamount");
+                        quarterrow.put("finvoiceamount", finvoiceamount);
+                        break;
+                    }
+                }
             }
             }
             /**
             /**
              * SQL月度任务查询参数设置并查询
              * SQL月度任务查询参数设置并查询
@@ -184,6 +214,16 @@ public class Tsaler extends Controller {
                         break;
                         break;
                     }
                     }
                 }
                 }
+                /**
+                 * 开始遍历月度开票金额
+                 */
+                for (Row invoiceamountRow : invoiceamountRows) {
+                    if ("月".equals(invoiceamountRow.getString("ftype")) && month.equals(invoiceamountRow.getString("number"))) {
+                        double finvoiceamount = invoiceamountRow.getDouble("finvoiceamount");
+                        monthrow.put("finvoiceamount", finvoiceamount);
+                        break;
+                    }
+                }
             }
             }
 
 
             //季度任务
             //季度任务