Przeglądaj źródła

回款返利统计去重

hu 1 miesiąc temu
rodzic
commit
0d035ab907

+ 1 - 1
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/账户回款统计.sql

@@ -1,6 +1,6 @@
 select t3.accountname,substring(t1.period, 6, 2) month,sum(if(t1.type = 0, 0 - amount, 0 + amount)) amount
 from sa_cashbill t1
-         left join sys_enterprise_tradefield t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid
+         left join (select DISTINCT sys_enterpriseid,sa_saleareaid,siteid from sys_enterprise_tradefield) t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid
          left join sa_accountclass t3 on t3.sa_accountclassid=t1.sa_accountclassid and t3.siteid=t1.siteid
 where ((t1.type = 1 and t1.class in ('货款', '物流赔偿')) or
        (t1.type = 0 and t1.subclass = '拨款'))

+ 1 - 1
src/custom/restcontroller/webmanage/sale/salestarget_cucu/SQL/账户返利统计.sql

@@ -2,7 +2,7 @@ select  sum(amount) amount, substring(t1.period, 6, 2) month
 from sa_cashbill t1
          left join sa_agents t2
                    on t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid
-         left join sys_enterprise_tradefield t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid
+         left join (select DISTINCT sys_enterpriseid,sa_saleareaid,siteid from sys_enterprise_tradefield) t3 on t1.sys_enterpriseid=t3.sys_enterpriseid and t1.siteid=t3.siteid
 where t1.type = 1
   and t1.status = '审核'
   and t1.siteid = $siteid$