Ver Fonte

Merge remote-tracking branch 'origin/develop' into develop

沈静伟 há 2 anos atrás
pai
commit
b72d4f0b2e

+ 7 - 25
src/custom/restcontroller/sale/order/Order.java

@@ -64,15 +64,6 @@ public class Order extends Controller {
             }
         }
         boolean isExport = content.getBooleanValue("isExport");
-//        SQLFactory sqlFactory = new SQLFactory(this, "订单_列表", pageSize, pageNumber, pageSorting);
-//        if (isExport) {
-//            sqlFactory = new SQLFactory(this, "订单_列表");
-//        }
-//
-//        sqlFactory.addParameter("siteid", siteid);
-//        sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
-//        sqlFactory.addParameter_SQL("where", where);
-//        Rows rows = dbConnect.runSqlQuery(sqlFactory);
         QuerySQL querySQL = queryList(where.toString());
         querySQL.setOrderBy(pageSorting);
         Rows rows;
@@ -88,20 +79,14 @@ public class Order extends Controller {
         sqlFactory.addParameter_in("sa_orderid", sa_orderids);
         RowsMap dataRowsMap = dbConnect.runSqlQuery(sqlFactory).toRowsMap("sa_orderid");
         //查询收货人信息
-        ArrayList<Long> rec_contactsids = rows.toArrayList("rec_contactsid", new ArrayList<>());
-        RowsMap contactsidRowsMap = beans.order.Order.getContactsRowsMap(this, rec_contactsids);
         for (Row row : rows) {
             Rows dataRows = dataRowsMap.getOrDefault(row.getString("sa_orderid"), new Rows());
             if (dataRows.isNotEmpty()) {
                 row.putAll(dataRows.get(0));
             } else {
                 row.put("amount", 0);
-                row.put("defaultamount", 0);
                 row.put("qty", 0);
             }
-
-            row.put("contacts", contactsidRowsMap.getOrDefault(row.getString("rec_contactsid"), new Rows()));
-
         }
 
         if (isExport) {
@@ -117,11 +102,15 @@ public class Order extends Controller {
             Rows uploadRows = uploadExcelToObs("order", "订单列表", rows, getTitleMap());
             return getSucReturnObject().setData(uploadRows).toString();
         }
+        if (systemclient.equals("web")) {
+            return getSucReturnObject().setData(rows).toString();
+        }
 
         sqlFactory = new SQLFactory(this, "订单-查询筛选出的价格");
         sqlFactory.addParameter("siteid", siteid);
         sqlFactory.addParameter("sys_enterpriseid", sys_enterpriseid);
         sqlFactory.addParameter_SQL("where", where);
+
         Rows amountrows = dbConnect.runSqlQuery(sqlFactory);
 
 
@@ -130,22 +119,15 @@ public class Order extends Controller {
 
     //查询订单列表(经销商)
     public QuerySQL queryList(String where) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order",
+                "sa_orderid","sonum","status","type","billdate","tradefield","remarks");
         querySQL.setTableAlias("t1");
         querySQL.addJoinTable(JOINTYPE.left, "sa_brand", "t3", "t3.sa_brandid = t1.sa_brandid",
                 "brandname");
         querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t4", "t4.contactsid = t1.rec_contactsid and t4.siteid = t1.siteid",
-                "name", "province", "city", "county", "address", "phonenumber");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t5", "t5.ownerid=t1.sa_orderid and t5.siteid=t1.siteid and t5.ownertable='sa_order'",
-                "backreason");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_hr", "t6", "t6.hrid = t1.saler_hrid and t6.siteid = t1.siteid");
-        //设置别名
-        querySQL.addQueryFields("salename", "t6.name");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_project", "t7", "t7.sa_projectid = t1.sa_projectid and t7.siteid = t1.siteid",
-                "projectname");
+                "name");
         querySQL.setWhere("t1.siteid", siteid);
         querySQL.setWhere(where);
-        querySQL.setWhere("t1.type!='工具借用单'");
         querySQL.setWhere("t1.sys_enterpriseid = $sys_enterpriseid$");
         querySQL.setWhere("t1.deleted=0");
         querySQL.setWhere("((t1.createflag=1 and t1.status!='新建') or t1.createflag=0)");

+ 0 - 1
src/custom/restcontroller/sale/order/SQL/订单_查询数据.sql

@@ -1,5 +1,4 @@
 SELECT 0 + CAST(ifnull(sum(amount), 0) as char)        amount,
-       0 + CAST(ifnull(sum(defaultamount), 0) as char) defaultamount,
        0 + CAST(ifnull(sum(qty), 0) as char)           qty,
        sa_orderid
 from sa_orderitems

+ 2 - 2
src/custom/restcontroller/webmanage/lsak3/aftersalesmag/aftersalesmag.java

@@ -27,10 +27,10 @@ public class aftersalesmag extends Controller {
      */
     @API(title = "获取DRP返退单", apiversion = R.ID20230715093903.v1.class,accesstoken = false)
     public String getAftersalesmag() throws YosException{
-        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sa_aftersalesmagid salereturnbillid,t1.billno fbillnum,t1.createby,t1.billdate fdate,t2.agentnum fagentnum,t1.reason fnotes from sa_aftersalesmag t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid where (t1.fupdatek3flag='0' or t1.fupdatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa'");
+        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sa_aftersalesmagid salereturnbillid,t1.billno fbillnum,t1.createby,ifnull(t1.billdate,CURRENT_DATE) fdate,t2.agentnum fagentnum,t1.reason fnotes from sa_aftersalesmag t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa1986'");
         for (Row row : rows) {
             String sa_aftersalesmagid = row.getString("sa_aftersalesmagid");
-            Rows detailRows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.st_stockbill_itemsid salereturnbilldeid,t2.itemno fitemno,t1.qty fqty,t1.price fprice,t1.reason fnotes,t4.billno fsaleissuebillno, t3.rowno fsaleissuebillentryid from sa_aftersalesmag_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join st_stockbill_items t3 on t1.st_stockbill_itemsid=t3.st_stockbill_itemsid and t1.siteid=t3.siteid left join st_stockbill t4 on t3.st_stockbillid=t4.st_stockbillid and t3.siteid=t4.siteid where t1.sa_aftersalesmagid='" + sa_aftersalesmagid + "' and t1.siteid='lsa'");
+            Rows detailRows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.st_stockbill_itemsid salereturnbilldeid,t2.itemno fitemno,t1.qty fqty,t1.price fprice,t1.reason fnotes,t4.billno fsaleissuebillno, t3.rowno fsaleissuebillentryid from sa_aftersalesmag_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid left join st_stockbill_items t3 on t1.st_stockbill_itemsid=t3.st_stockbill_itemsid and t1.siteid=t3.siteid left join st_stockbill t4 on t3.st_stockbillid=t4.st_stockbillid and t3.siteid=t4.siteid where t1.sa_aftersalesmagid='" + sa_aftersalesmagid + "' and t1.siteid='lsa1986'");
             row.put("salereturnbilldetil", detailRows.toJsonArray());
         }
         if(rows.isEmpty()) {

+ 1 - 1
src/custom/restcontroller/webmanage/lsak3/cashbill/cashbill.java

@@ -338,7 +338,7 @@ public class cashbill extends Controller {
     @API(title = "k3获取收入凭证", apiversion = R.ID20230714164903.v1.class,accesstoken = false)
     public String getcashbill() throws YosException{
 
-        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.billno fbillnum,t1.sa_cashbillid ficashbillid,t1.createby,t1.billdate fdate,t3.accountno faccclsnum,t2.agentnum fagentnum,t1.amount famount,t1.remarks fnotes,t1.updatek3flag fupdatek3flag from sa_cashbill t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t2.siteid=t2.siteid left join sa_accountclass t3 on t1.sa_accountclassid=t3.sa_accountclassid and t1.siteid=t3.siteid where t3.accountno!='03' and (updatek3flag='0' or updatek3flag='2') and t1.type=1 and ISNULL(t1.amount,0)!=0  and t1.status='审核' and isnull(t1.description,'')!='K3' and t1.createby !='LSA总0001'");
+        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.billno fbillnum,t1.sa_cashbillid ficashbillid,t1.createby,ifnull(t1.billdate,CURRENT_DATE) fdate,t3.accountno faccclsnum,t2.agentnum fagentnum,t1.amount famount,t1.remarks fnotes,t1.updatek3flag fupdatek3flag from sa_cashbill t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t2.siteid=t2.siteid left join sa_accountclass t3 on t1.sa_accountclassid=t3.sa_accountclassid and t1.siteid=t3.siteid where t3.accountno!='03' and (updatek3flag='0' or updatek3flag='2') and t1.type=1 and ifnull(t1.amount,0)!=0  and t1.status='审核' and ifnull(t1.description,'')!='K3' and t1.siteid='lsa1986' and t1.createby !='LSA总0001'");
         if (rows.isEmpty()) {
             JSONArray array = new JSONArray();
             return array.toString();

+ 2 - 2
src/custom/restcontroller/webmanage/lsak3/dispatch/dispatch.java

@@ -27,10 +27,10 @@ public class dispatch extends Controller {
      */
     @API(title = "获取DRP发货单", apiversion = R.ID20230715091603.v1.class,accesstoken = false)
     public String getDispatch() throws YosException{
-        Rows rows = dbConnect.runSqlQuery("select t3.sonum fsonum,t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.billno finvonum,t1.sa_dispatchid sainvoiceid,t1.createby,t1.trantype ftrantype,t1.billdate fdate,t2.agentnum fagentnum,t1.remarks fnotes from sa_dispatch t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sa_order t3 on  t3.sa_orderid=t1.sa_orderid and t3.siteid=t1.siteid  where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001'  and t1.siteid='lsa'");
+        Rows rows = dbConnect.runSqlQuery("select t3.sonum fsonum,t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.billno finvonum,t1.sa_dispatchid sainvoiceid,t1.createby,t1.trantype ftrantype,ifnull(t1.billdate,CURRENT_DATE) fdate,t2.agentnum fagentnum,t1.remarks fnotes from sa_dispatch t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid left join sa_order t3 on  t3.sa_orderid=t1.sa_orderid and t3.siteid=t1.siteid  where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001'  and t1.siteid='lsa1986'");
         for (Row row : rows) {
             String sa_dispatchid = row.getString("sa_dispatchid");
-            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid sainvoicedetailid,t2.itemno fitemno,t2.k3outcode fk3outcode,t3.qty fqty,t3.price fprice,t1.remarks fnotes,t3.customproperties,t2.spec flong from sa_dispatch_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t1.sa_orderitemsid=t3.sa_orderitemsid and t1.siteid=t3.siteid where t1.sa_dispatchid='" + sa_dispatchid + "'  and t1.siteid='lsa'");
+            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid sainvoicedetailid,t2.itemno fitemno,t2.k3outcode fk3outcode,t3.qty fqty,t3.price fprice,t1.remarks fnotes,t3.customproperties,t2.spec flong from sa_dispatch_items t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join sa_orderitems t3 on t1.sa_orderitemsid=t3.sa_orderitemsid and t1.siteid=t3.siteid where t1.sa_dispatchid='" + sa_dispatchid + "'  and t1.siteid='lsa1986'");
             row.put("sainvoicedetail", detailRows.toJsonArray());
         }
         if(rows.isEmpty()) {

+ 2 - 2
src/custom/restcontroller/webmanage/lsak3/order/order.java

@@ -29,10 +29,10 @@ public class order extends Controller {
     @API(title = "k3获取销售订单", apiversion = R.ID20230715090203.v1.class,accesstoken = false)
     public String getSaorder() throws  YosException{
 
-        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sonum fsonum,t1.sa_orderid saorderid,t1.createby,t1.billdate fdate,t2.agentnum fagentnum,t1.remarks fnotes from sa_order t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid  where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa'");
+        Rows rows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.updatek3flag fupdatek3flag,t1.sonum fsonum,t1.sa_orderid saorderid,t1.createby,t1.billdate fdate,t2.agentnum fagentnum,t1.remarks fnotes from sa_order t1 inner join sa_agents t2 on t1.sys_enterpriseid=t2.sys_enterpriseid and t1.siteid=t2.siteid  where (t1.updatek3flag='0' or t1.updatek3flag='2') and t1.createby !='LSA总0001' and t1.siteid='lsa1986'");
         for (Row row : rows) {
             String sa_orderid = row.getString("sa_orderid");
-            Rows detailRows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.sa_orderitemsid saorderdetailid,convert(t1.defaultamount,char) as ftaxamount,t2.itemno fitemno,t1.qty fqty,t1.price frateprice,t1.defaultprice fprice,t1.amount famount,t1.remarks fnotes,t1.customproperties,t2.spec flong from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid where sa_orderid='" + sa_orderid + "'  and t1.siteid='lsa'");
+            Rows detailRows = dbConnect.runSqlQuery("select t2.k3outcode fk3outcode,t1.sa_orderitemsid saorderdetailid,convert(t1.defaultamount,char) as ftaxamount,t2.itemno fitemno,t1.qty fqty,t1.price frateprice,t1.defaultprice fprice,t1.amount famount,t1.remarks fnotes,t1.customproperties,t2.spec flong from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid where sa_orderid='" + sa_orderid + "'  and t1.siteid='lsa1986'");
             row.put("saorderdetail", detailRows.toJsonArray());
         }
         if(rows.isEmpty()) {

+ 1 - 1
src/custom/restcontroller/webmanage/sale/databoard/databoard.java

@@ -543,7 +543,7 @@ public class databoard extends Controller {
         }
 
 
-        Rows topItemclassRows = dbConnect.runSqlQuery("select itemclassid,itemclassname from plm_itemclass where classtype='营销' and siteid='" + siteid + "' and ifnull(parentid,0)=0");
+        Rows topItemclassRows = dbConnect.runSqlQuery("select itemclassid,itemclassname marketingcategory from plm_itemclass where classtype='营销' and siteid='" + siteid + "' and ifnull(parentid,0)=0");
         for (Row row : topItemclassRows) {
             ArrayList<Long> itemclassids = ItemClass.getSubItemClassIds(this, row.getLong("itemclassid"));
             SQLFactory factory = new SQLFactory(this, "订货额类别统计分析");

+ 4 - 1
src/custom/restcontroller/webmanage/sale/itemgroup/itemgroup.java

@@ -127,7 +127,10 @@ public class itemgroup extends Controller {
 
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
                 where = where + " and (t1.groupname like'%" + whereObject.getString("condition")
-                        + "%' or t1.groupnum like'%" + whereObject.getString("condition") + "%') ";
+                        + "%' or t1.groupnum like'%" + whereObject.getString("condition")
+                        + "%' or exists(select 1 from sa_itemgroupmx s1 left join plm_item s2 on s1.itemid=s2.itemid and  s1.siteid=s2.siteid where (s2.itemname like '%"
+                        + whereObject.getString("condition") + "%' or s2.itemno like '%" + whereObject.getString("condition")
+                        + "%') and s1.sa_itemgroupid=t1.sa_itemgroupid) ) ";
             }
             if (whereObject.containsKey("brandname") && !"".equals(whereObject.getString("brandname"))) {
                 where = where + " and (t3.brandname ='" + whereObject.getString("brandname") + "') ";

+ 11 - 18
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -273,10 +273,8 @@ public class Order extends Controller {
         //营销账户类型ID
         if ((type.equals("标准订单") || type.equals("特殊订单")) && content.getString("tradefield").equals("整装工程")) {
             sqlFactory.addParameter("sa_accountclassid", "69");
-            sqlList1.addAll(updateAccountclassinfos(sa_orderid,69,sys_enterpriseid));
         } else {
             sqlFactory.addParameter("sa_accountclassid", beans.order.Order.getDefaultAccount(siteid, type));
-            sqlList1.addAll(updateAccountclassinfos(sa_orderid,beans.order.Order.getDefaultAccount(siteid, type),sys_enterpriseid));
         }
 
         //品牌ID
@@ -357,6 +355,12 @@ public class Order extends Controller {
 
         dbConnect.runSqlUpdate(sqlList);
 
+        if ((type.equals("标准订单") || type.equals("特殊订单")) && content.getString("tradefield").equals("整装工程")) {
+            sqlList1.addAll(updateAccountclassinfos(sa_orderid,69,sys_enterpriseid));
+        } else {
+            sqlList1.addAll(updateAccountclassinfos(sa_orderid,beans.order.Order.getDefaultAccount(siteid, type),sys_enterpriseid));
+        }
+
         dbConnect.runSqlUpdate(sqlList1);
 
         ClearData.clearShoppingCart(this);
@@ -541,7 +545,7 @@ public class Order extends Controller {
                 where.append("t1.sonum like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t2.enterprisename like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t2.abbreviation like'%").append(whereObject.getString("condition")).append("%' ");
-                where.append("or t5.erpbillno like'%").append(whereObject.getString("condition")).append("%' ");
+//                where.append("or t5.erpbillno like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append("or t1.remarks like'%").append(whereObject.getString("condition")).append("%' ");
                 where.append(")");
             }
@@ -780,26 +784,15 @@ public class Order extends Controller {
 
     //查询订单列表(管理端)
     public QuerySQL queryListManage(String where) throws YosException {
-        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order");
+        QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_order",
+                "sa_orderid","sonum","type","status","submitdate","checkdate","remarks","createby","checkby","billdate","tradefield");
         querySQL.setTableAlias("t1");
         querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise", "t2", "t2.sys_enterpriseid = t1.sys_enterpriseid and t2.siteid = t1.siteid",
-                "enterprisename", "abbreviation","abbreviation as amount","abbreviation as qty");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_brand", "t3", "t3.sa_brandid = t1.sa_brandid",
-                "brandname");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_enterprise_contacts", "t4", "t4.contactsid = t1.rec_contactsid and t4.siteid = t1.siteid",
-                "name");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t5", "t5.ownerid = t1.sa_orderid AND t1.siteid = t5.siteid and t5.erpbillno is not null and t5.ownertable = 'sa_order' ",
-                "erpbillno");
+                "enterprisename");
         querySQL.addJoinTable(JOINTYPE.left, "sa_agents", "t6", "t6.sys_enterpriseid=t1.sys_enterpriseid and t6.siteid = t1.siteid",
                 "agentnum");
-        querySQL.addJoinTable(JOINTYPE.left, "sys_hr", "t7", "t7.hrid = t1.saler_hrid and t7.siteid = t1.siteid");
-        //设置别名
-        querySQL.addQueryFields("salename", "t7.name");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_project", "t8", "t8.sa_projectid = t1.sa_projectid and t8.siteid = t1.siteid",
-                "projectname");
         querySQL.setWhere("t1.siteid", siteid);
         querySQL.setWhere(where);
-        querySQL.setWhere("t1.type!='工具借用单'");
         querySQL.setWhere("t1.deleted=0");
         querySQL.setWhere("(t1.status!='新建' or t1.createuserid =$userid$ or t1.createflag=1)");
         querySQL.addParameter("userid", userid);
@@ -2846,7 +2839,7 @@ public class Order extends Controller {
 //        }
         JSONArray jsonArray =new JSONArray();
         BigDecimal orderSumamount = BigDecimal.ZERO;
-        Rows classamountrows =dbConnect.runSqlQuery("select t3.topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join sa_itemsaleclass t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join (select itemclassid,find_top(itemclassid) topitemclassid,siteid  from plm_itemclass where siteid!='ZZYOS') t3 on t2.itemclassid=t3.itemclassid and t2.siteid=t3.siteid  where t1.sa_orderid="+sa_orderid+" group by t3.topitemclassid,t1.siteid");
+        Rows classamountrows = dbConnect.runSqlQuery("select t2.marketingcategory topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid   where t1.sa_orderid='"+sa_orderid+"' group by t2.marketingcategory,t1.siteid");
         for (Row classamountrow:classamountrows) {
             orderSumamount=orderSumamount.add(classamountrow.getBigDecimal("sumamount"));
         }

+ 14 - 13
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -353,7 +353,7 @@ public class OrderItems extends Controller {
         }
         JSONArray jsonArray = new JSONArray();
         BigDecimal orderSumamount = BigDecimal.ZERO;
-        Rows classamountrows = dbConnect.runSqlQuery("select t3.topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join sa_itemsaleclass t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid inner join (select itemclassid,find_top(itemclassid) topitemclassid,siteid  from plm_itemclass where siteid!='ZZYOS') t3 on t2.itemclassid=t3.itemclassid and t2.siteid=t3.siteid  where t1.sa_orderid=" + sa_orderid + " group by t3.topitemclassid,t1.siteid");
+        Rows classamountrows = dbConnect.runSqlQuery("select t2.marketingcategory topitemclassid,t1.siteid,sum(ifnull(t1.amount,0)) sumamount  from sa_orderitems t1 inner join plm_item t2 on t1.itemid=t2.itemid and t1.siteid=t2.siteid   where t1.sa_orderid='" + sa_orderid + "' group by t2.marketingcategory,t1.siteid");
         for (Row classamountrow : classamountrows) {
             orderSumamount = orderSumamount.add(classamountrow.getBigDecimal("sumamount"));
         }
@@ -665,17 +665,18 @@ public class OrderItems extends Controller {
         sqlFactory.addParameter_SQL("where", where);
         Rows rows = dbConnect.runSqlQuery(sqlFactory);
         ArrayList<Long> ids = rows.toArrayList("itemid", new ArrayList<>());
+        ArrayList<Long> itemnos = rows.toArrayList("itemno", new ArrayList<>());
         RowsMap rowsMap = rows.toRowsMap("itemno");
 
         SQLFactory sqlFactory1 = new SQLFactory(this, "商品发货数量汇总");
         sqlFactory1.addParameter("siteid", siteid);
-        sqlFactory1.addParameter_in("itemid", ids);
+        sqlFactory1.addParameter_in("itemnos", itemnos);
         Rows sumQtyRows = dbConnect.runSqlQuery(sqlFactory1);
         RowsMap sumQtyRowsMap = sumQtyRows.toRowsMap("itemno");
 
         SQLFactory sqlFactory2 = new SQLFactory(this, "商品未发货数量汇总");
         sqlFactory2.addParameter("siteid", siteid);
-        sqlFactory2.addParameter_in("itemid", ids);
+        sqlFactory2.addParameter_in("itemnos", itemnos);
         Rows sumUnQtyRows = dbConnect.runSqlQuery(sqlFactory2);
         RowsMap sumUnQtyRowsMap = sumUnQtyRows.toRowsMap("itemno");
 
@@ -783,20 +784,20 @@ public class OrderItems extends Controller {
             if (whereObject.containsKey("isuncheckout") && !"".equals(whereObject.getString("isuncheckout"))) {
                 String begindate = "";
                 String enddate = "";
-                if(whereObject.containsKey("datetype") && !"".equals(whereObject.getString("datetype"))) {
+                if (whereObject.containsKey("datetype") && !"".equals(whereObject.getString("datetype"))) {
                     String datetype = whereObject.getStringValue("datetype");
                     switch (datetype) {
-                        case "":
-                            begindate = getMonthFirstDay();
-                            enddate = getMonthLastDay();
+                        case "7":
+                            begindate = getDate_Str(-7);
+                            enddate = getDate_Str();
                             break;
-                        case "":
-                            begindate = new SimpleDateFormat("yyyy").format(new Date()) + "-01-01";
-                            enddate = new SimpleDateFormat("yyyy").format(new Date()) + "-12-31";
+                        case "30":
+                            begindate = getDate_Str(-30);
+                            enddate = getDate_Str();
                             break;
-                        case "":
-                            begindate = getWeekFirstDay();
-                            enddate = getWeekLastDay();
+                        case "90":
+                            begindate = getDate_Str(-90);
+                            enddate = getDate_Str();
                             break;
                         default:
                             break;

+ 1 - 2
src/custom/restcontroller/webmanage/sale/order/SQL/商品发货数量汇总.sql

@@ -3,5 +3,4 @@ SELECT  t3.itemno,
 FROM sa_dispatch_items t1
          inner join sa_dispatch t2 on t1.siteid = t2.siteid and t1.sa_dispatchid = t2.sa_dispatchid
          left join plm_item t3 on t1.siteid = t3.siteid and t1.itemid = t3.itemid
-          inner join sa_orderitems t4 on t1.sa_orderitemsid=t4.sa_orderitemsid and t1.siteid = t4.siteid
-WHERE t2.STATUS in ('审核','复核') and t1.siteid=$siteid$ and t1.itemid in $itemid$ group by t3.itemno
+WHERE t2.STATUS in ('审核','复核') and t1.siteid=$siteid$ and t3.itemno in $itemnos$ group by t3.itemno

+ 2 - 4
src/custom/restcontroller/webmanage/sale/order/SQL/商品未发货数量汇总.sql

@@ -1,8 +1,6 @@
-SELECT t2.itemno,
+SELECT t1.itemno,
        sum(t1.undeliqty) undeliqty
 FROM sa_orderitems t1
-         inner join plm_item t2 on t1.siteid = t2.siteid and t1.itemid = t2.itemid
          inner join sa_order t3 on t1.siteid=t3.siteid and t1.sa_orderid=t3.sa_orderid
-         left join plm_unit t4 on t2.unitid=t4.unitid and t2.siteid=t4.siteid
 WHERE t3.STATUS in ('审核')
-and  t1.siteid=$siteid$ and t1.itemid in $itemid$  group by t2.itemno
+  and  t1.siteid=$siteid$ and t1.itemno in $itemnos$ group by t1.itemno