hu 2 лет назад
Родитель
Сommit
85a391b8dd

+ 2 - 1
src/custom/restcontroller/webmanage/sale/aftersalesmag/SQL/商品列表查询.sql

@@ -8,4 +8,5 @@ FROM
 WHERE
   t1.siteid = $siteid$
 	AND $where$
-	AND t1.itemid not in (select itemid from sa_aftersalesmag_items where sa_aftersalesmagid=$sa_aftersalesmagid$ and siteid = $siteid$ )
+	AND t1.itemid not in (select itemid from sa_aftersalesmag_items where sa_aftersalesmagid=$sa_aftersalesmagid$ and siteid = $siteid$ )
+	and t1.itemid in (SELECT t2.itemid FROM plm_item t2 LEFT JOIN sa_itemsaleclass t4 ON t2.itemid = t4.itemid AND t2.siteid = t4.siteid LEFT JOIN plm_itemclass t5 ON t5.itemclassid = t4.itemclassid AND t5.siteid = t4.siteid where  t5.itemclassid in $itemclassid$ and t2.siteid=$siteid$)

+ 9 - 0
src/custom/restcontroller/webmanage/sale/aftersalesmag/aftersalesmag.java

@@ -83,6 +83,15 @@ public class aftersalesmag extends Controller {
             }
 
             sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
+            if (!content.containsKey("sys_enterpriseid")) {
+                Rows accountclassRows =dbConnect.runSqlQuery("select * from sa_accountclass where siteid='"+siteid+"' and accountname='现金账户'");
+                if(accountclassRows.isNotEmpty()){
+                    sqlFactory.addParameter("sa_accountclassid",accountclassRows.get(0).getLong("sa_accountclassid"));
+                }else {
+                    return getErrReturnObject().setErrMsg("现金账户不存在,无法新建").toString();
+                }
+
+            }
             sqlFactory.addParameter("type", type);
             sqlList.add(
                     DataContrlLog.createLog(this, "sa_aftersalesmag", sa_aftersalesmagid, "新增", "返退单新增成功").getSQL());

+ 29 - 1
src/custom/restcontroller/webmanage/sale/aftersalesmag/aftersalesmagItems.java

@@ -1,6 +1,8 @@
 package restcontroller.webmanage.sale.aftersalesmag;
 
 import beans.data.BatchDeleteErr;
+import beans.enterprise.Enterprise;
+import beans.itemclass.ItemClass;
 import beans.itemprice.ItemPrice;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -32,7 +34,9 @@ public class aftersalesmagItems extends Controller {
          */
         Long sa_orderid = content.getLong("sa_orderid");
         Long sa_aftersalesmagid = content.getLong("sa_aftersalesmagid");
-        Long sys_enterpriseid = content.getLong("sys_enterpriseid");
+        if(content.containsKey("sys_enterpriseid")){
+            sys_enterpriseid = content.getLong("sys_enterpriseid");
+        }
         StringBuffer where = new StringBuffer(" 1=1 ");
         if (content.containsKey("where")) {
             JSONObject whereObject = content.getJSONObject("where");
@@ -48,6 +52,30 @@ public class aftersalesmagItems extends Controller {
             sqlFactory = new SQLFactory(this, "返退商品列表查询", pageSize, pageNumber, pageSorting);
         } else {
             sqlFactory = new SQLFactory(this, "商品列表查询", pageSize, pageNumber, pageSorting);
+            String itemclasssql="select itemclassid from plm_itemclass where siteid='" + siteid +"'";
+            if(!content.containsKey("sys_enterpriseid")){
+                if(sys_enterpriseid>0){
+                    Row enterpriseRow = Enterprise.getEnterprise(this, sys_enterpriseid);
+                    if (!enterpriseRow.isEmpty()) {
+                        //企业营销类别
+                        boolean saleclassauth = enterpriseRow.getBoolean("saleclassauth");
+                        if (saleclassauth) {
+                            itemclasssql = "select itemclassid from plm_itemclass where siteid='" + siteid + "' and itemclassid in ( SELECT itemclassid from sys_enterprise_saleclass WHERE sys_enterpriseid = " + sys_enterpriseid + " and siteid='" + siteid + "')";
+                        }
+                    }
+                }
+            }
+
+            Rows itemclassRows = dbConnect.runSqlQuery(itemclasssql);
+
+            ArrayList<Long> itemclassList = new ArrayList<Long>();
+            for (Row row : itemclassRows) {
+                //System.out.println(row.getLong("itemclassid"));
+                itemclassList.add(row.getLong("itemclassid"));
+                itemclassList.addAll(ItemClass.getSubItemClassIds(this, row.getLong("itemclassid")));
+            }
+            sqlFactory.addParameter_in("itemclassid", itemclassList);
+
         }
 
         sqlFactory.addParameter_SQL("where", where);