Browse Source

门店商品逻辑调整

eganwu 1 năm trước cách đây
mục cha
commit
a3d5a21359

BIN
lib/yos.core-2.5.3-sources.jar → lib/yos.core-2.5.4-sources.jar


BIN
lib/yos.core-2.5.3.jar → lib/yos.core-2.5.4.jar


+ 17 - 0
src/custom/restcontroller/ClientUserInfo.java

@@ -10,6 +10,7 @@ import common.data.Rows;
 import org.apache.commons.lang.StringUtils;
 
 import java.util.ArrayList;
+import java.util.LinkedHashSet;
 
 public class ClientUserInfo extends UserInfo {
     public ClientUserInfo(Controller controller) {
@@ -181,4 +182,20 @@ public class ClientUserInfo extends UserInfo {
         return rows.isNotEmpty() ? rows.get(0).getString("url") : "";
     }
 
+    public LinkedHashSet<Long> getSaleareaidsPath(Controller controller, Long sys_enterpriseid) throws YosException {
+        Rows rows = controller.dbConnect.runSqlQuery("SELECT DISTINCT sa_saleareaids FROM sa_salearea t1 " +
+                "INNER JOIN sys_enterprise_tradefield t2 ON t2.sa_saleareaid=t1.sa_saleareaid and t2.siteid=t1.siteid " +
+                "WHERE t1.siteid='" + controller.siteid + "' and t2.sys_enterpriseid=" + sys_enterpriseid + "");
+        LinkedHashSet<Long> ids = new LinkedHashSet<>();
+        ids.add(-1L);
+        for (Row row : rows) {
+            JSONArray jsonArray = row.getJSONArray("sa_saleareaids");
+            for (Object object : jsonArray) {
+                ids.add(Long.parseLong(object.toString()));
+            }
+        }
+
+        return ids;
+    }
+
 }

+ 13 - 5
src/custom/restcontroller/webmanage/saletool/fad/FadGoods.java

@@ -3,6 +3,7 @@ package restcontroller.webmanage.saletool.fad;
 import beans.attachment.Attachment;
 import beans.datacontrllog.DataContrlLog;
 import beans.datatag.DataTag;
+import beans.salearea.SaleArea;
 import beans.time.Time;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
@@ -14,7 +15,9 @@ import org.apache.commons.lang.StringUtils;
 import restcontroller.R;
 import restcontroller.system.dataauth.DataAuthHelper;
 
+import java.awt.geom.Area;
 import java.util.ArrayList;
+import java.util.LinkedHashSet;
 
 /**
  * 商品管理
@@ -115,7 +118,6 @@ public class FadGoods extends Controller {
         }
 
 
-
         sa_fadids.add(sa_fadid);
         for (Long id : sa_fadids) {
             listSQL.add(FadHelper.getIsOnSalesUpdateSQL(this, id).getSQL());
@@ -400,18 +402,21 @@ public class FadGoods extends Controller {
         sys_enterpriseids.add(sys_enterpriseid);
         sys_enterpriseids.add(0L);
 
+        LinkedHashSet<Long> saleareaidsPath = userInfo.getSaleareaidsPath(this, sys_enterpriseid);
+        String wheresql = "t1.sa_fadid in (SELECT ownerid from sys_dataauths WHERE ownertable='sa_fad' and (sys_enterpriseid =" + sys_enterpriseid + " or sa_saleareaid in " + saleareaidsPath + "))";
+
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, sa_fad,
                         "sa_fadid", "name", "pricetype", "price", "price_deposit", "unitname")
                 .setTableAlias("t1");
 
         querySQL.addJoinTable(JOINTYPE.left, "sys_datatag", "t2", "t2.ownertable='sa_fad' and t2.ownerid=t1.sa_fadid and t2.siteid=t1.siteid");
         querySQL.setSiteid(siteid);
-        querySQL.setWhere("not EXISTS(SELECT 1 from sa_fad WHERE sys_enterpriseid=" + sys_enterpriseid + " and parentid=t1.sa_fadid and siteid=t1.siteid)");
+        querySQL.setWhere("t1.sa_fadid not in (SELECT parentid from sa_fad WHERE sys_enterpriseid=" + sys_enterpriseid + ")");
+        querySQL.setWhere(wheresql.replace("[", "(").replace("]", ")"));
         querySQL.setWhere("sys_enterpriseid", sys_enterpriseids);
         querySQL.setWhere("classid", 2);
         querySQL.setWhere("isonsale", 1);
         querySQL.setWhere(where.toString());
-        querySQL.setDataAuth(true);
         querySQL.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();
 
@@ -465,19 +470,22 @@ public class FadGoods extends Controller {
         sys_enterpriseids.add(sys_enterpriseid);
         sys_enterpriseids.add(0L);
 
+        LinkedHashSet<Long> saleareaidsPath = userInfo.getSaleareaidsPath(this, sys_enterpriseid);
+        String wheresql = "t1.sa_fadid in (SELECT ownerid from sys_dataauths WHERE ownertable='sa_fad' and (sys_enterpriseid =" + sys_enterpriseid + " or sa_saleareaid in " + saleareaidsPath + "))";
+
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, sa_fad,
                         "sa_fadid", "name", "pricetype", "price", "price_deposit", "unitname")
                 .setTableAlias("t1");
 
         querySQL.addJoinTable(JOINTYPE.left, "sys_datatag", "t2", "t2.ownertable='sa_fad' and t2.ownerid=t1.sa_fadid and t2.siteid=t1.siteid");
         querySQL.setSiteid(siteid);
-        querySQL.setWhere("not EXISTS(SELECT 1 from sa_fad WHERE sys_enterpriseid=" + sys_enterpriseid + " and parentid=t1.sa_fadid and siteid=t1.siteid)");
+        querySQL.setWhere("t1.sa_fadid not in (SELECT parentid from sa_fad WHERE sys_enterpriseid=" + sys_enterpriseid + ")");
+        querySQL.setWhere(wheresql.replace("[", "(").replace("]", ")"));
         querySQL.setWhere("sys_enterpriseid", sys_enterpriseids);
         querySQL.setWhere("classid", 2);
         querySQL.setWhere("isonsale", 1);
         querySQL.setWhere("canadjust", 1);
         querySQL.setWhere(where.toString());
-        querySQL.setDataAuth(true);
         querySQL.setOrderBy(pageSorting).setPage(pageSize, pageNumber);
         Rows rows = querySQL.query();