瀏覽代碼

修复返利bug

eganwu 1 年之前
父節點
當前提交
42abbf696d
共有 2 個文件被更改,包括 16 次插入0 次删除
  1. 4 0
      src/custom/service/SQL/收支凭证新增.sql
  2. 12 0
      src/custom/service/SQL/查询返利数据.sql

+ 4 - 0
src/custom/service/SQL/收支凭证新增.sql

@@ -0,0 +1,4 @@
+insert into sa_cashbill (siteid, sa_cashbillid, createuserid,createby, createdate, billno,changeuserid,changeby, changedate,checkby,checkdate,
+                         sys_enterpriseid, sa_accountclassid,type,remarks,amount,status,source,sourcenote,ownertable,ownerid,balance,sa_cashbillid_rebate,class,subclass,period,updatek3flag)
+values ($siteid$, $sa_cashbillid$,$userid$,$username$, CURRENT_TIME, $billno$,$userid$, $username$, CURRENT_TIME,$checkby$,$checkdate$,$sys_enterpriseid$,$sa_accountclassid$,$type$,$remarks$,
+        $amount$,$status$,$source$,$sourcenote$,$ownertable$,$ownerid$,$balance$,$sa_cashbillid_rebate$,$class$,$subclass$,current_date,$updatek3flag$);

+ 12 - 0
src/custom/service/SQL/查询返利数据.sql

@@ -0,0 +1,12 @@
+SELECT t3.sa_orderitemsid, t3.price * t1.outwarehouseqty amount
+from sa_dispatch_items t1
+         inner join sa_dispatch t2 ON t2.sa_dispatchid = t1.sa_dispatchid and t2.siteid = t1.siteid
+         inner join sa_orderitems t3 on t3.sa_orderitemsid = t1.sa_orderitemsid and t3.siteid = t1.siteid
+         inner join plm_item t4 on t4.itemid = t3.itemid and t4.siteid = t3.siteid
+         inner join sa_order t5 ON t5.sa_orderid = t2.sa_orderid and t5.siteid = t2.siteid
+WHERE t2.sa_orderid = $sa_orderid$
+  and t1.siteid = $siteid$
+  and t1.outwarehouseqty > 0
+  and (t3.decorationrebateflag = 0 or t3.decorationrebateflag is null)
+  and t1.itemid in (select itemid from sa_itemsaleclass where itemclassid in $itemclassid$)
+  and t1.itemid not in $itemid$