Browse Source

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

沈静伟 2 years ago
parent
commit
0c6fe93df6

+ 2 - 1
src/custom/beans/accountbalance/Accountbalance.java

@@ -7,6 +7,7 @@ import common.Controller;
 import common.YosException;
 import common.data.Rows;
 import common.data.SQLFactory;
+import org.apache.commons.lang.StringUtils;
 
 import java.math.BigDecimal;
 import java.util.ArrayList;
@@ -121,7 +122,7 @@ public class Accountbalance extends BaseClass {
         if (ischeck) {
             BigDecimal balance = BigDecimal.ZERO;  //当前账户余额
             sqlFactory.addParameter("status", "审核");
-            sqlFactory.addParameter("checkby", controller.username);
+            sqlFactory.addParameter("checkby", StringUtils.isBlank(controller.username)?"autocheck":controller.username);
             sqlFactory.addParameter_SQL("checkdate", "CURRENT_TIME");
 
             // 审核逻辑判断

+ 1 - 1
src/custom/beans/remind/Remind.java

@@ -14,7 +14,7 @@ import utility.email.Email;
 import utility.email.EmailContent;
 import utility.sms.Sms;
 import utility.tools.Encryption;
-import utility.wechat.WechatService;
+import utility.wechat.wechatservice.WechatService;
 
 import java.util.ArrayList;
 import java.util.Calendar;

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

@@ -33,7 +33,7 @@ public class dispatch extends Controller {
             JSONArray array = new JSONArray();
             return array.toString();
         }else{
-            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_dispatchid ,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 in" + rows.toJsonArray("sainvoiceid").toJSONString().replace("[", "(").replace("]", ")") + "  and t1.siteid='lsa'");
+            Rows detailRows = dbConnect.runSqlQuery("select t1.sa_dispatchid ,t1.sa_dispatch_itemsid sainvoicedetailid,t2.itemno fitemno,t2.k3outcode fk3outcode,t1.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 in" + rows.toJsonArray("sainvoiceid").toJSONString().replace("[", "(").replace("]", ")") + "  and t1.siteid='lsa'");
             RowsMap rowsMap =detailRows.toRowsMap("sa_dispatchid");
             for (Row row : rows) {
                 String sainvoiceid = row.getString("sainvoiceid");

+ 2 - 1
src/custom/restcontroller/webmanage/lsak3/item/item.java

@@ -113,6 +113,7 @@ public class item extends Controller {
                 long itemid = createTableID("plm_item");
                 sqlFactory = new SQLFactory(this,"货品档案新增");
                 sqlFactory.addParameter("itemid",itemid);
+                sqlFactory.addParameter("sa_customschemeid", 0);
                 // 货品档案扩展属性字段表
                 SQLFactory sqlFactory1 = new SQLFactory(this, "货品档案-扩展新增");
                 sqlFactory1.addParameter("siteid", "lsa");
@@ -149,6 +150,7 @@ public class item extends Controller {
                 long itemid = itemRows.get(0).getLong("itemid");
                 sqlFactory = new SQLFactory(this,"货品档案更新");
                 sqlFactory.addParameter("itemid",itemid);
+                sqlFactory.addParameter("sa_customschemeid", itemRows.get(0).getLong("sa_customschemeid"));
                 Rows itemextendRows= dbConnect.runSqlQuery("select * from plm_itemextend where siteid='lsa' and itemid="+itemid);
                 SQLFactory sqlFactory1;
                 if(itemextendRows.isEmpty()){
@@ -254,7 +256,6 @@ public class item extends Controller {
             sqlFactory.addParameter("packageqty", fpackingqty);
             sqlFactory.addParameter("iswoodproducts", 0);
 
-            sqlFactory.addParameter("sa_customschemeid", 0);
             sqlFactory.addParameter("financeclasstype","");
             sqlFactory.addParameter("stockno","");
             sqlFactory.addParameter("volume", 0);

+ 5 - 5
src/custom/restcontroller/webmanage/lsak3/stockbill/stockbill.java

@@ -183,7 +183,7 @@ public class stockbill extends Controller {
                         /**
                          * 更新发货单数量
                          */
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=outwarehouseqty+"+fqty+" where siteid='lsa' and sa_dispatch_itemsid="+sainvoicedetailid);
+                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)+"+fqty+" where siteid='lsa' and sa_dispatch_itemsid="+sainvoicedetailid);
                     }else{
                         if(aftersalesmagRowsMap.containsKey(String.valueOf(sainvoicedetailid)) && aftersalesmagRowsMap.get(sainvoicedetailid).isNotEmpty()){
                             logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).toJsonObject().toString());
@@ -260,7 +260,7 @@ public class stockbill extends Controller {
                      */
                     Rows stockbilldetailrows =dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa' group by t1.sa_dispatch_itemsid");
                     for (Row row :stockbilldetailrows) {
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=outwarehouseqty-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
+                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
                         sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='lsa' and sa_dispatchid="+row.getLong("sa_dispatchid"));
                     }
                 }
@@ -301,7 +301,7 @@ public class stockbill extends Controller {
                      */
                     Rows stockbilldetailrows =dbConnect.runSqlQuery("select t1.sa_dispatch_itemsid,sum(t1.qty) qty,t2.sa_dispatchid from st_stockbill_items t1 inner join  sa_dispatch_items t2 on t1.sa_dispatch_itemsid=t2.sa_dispatch_itemsid and t1.siteid=t2.siteid where t1.st_stockbillid = "+stockbillRows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa' group by t1.sa_dispatch_itemsid");
                     for (Row row :stockbilldetailrows) {
-                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=outwarehouseqty-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
+                        sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=ifnull(outwarehouseqty,0)-"+row.getBigDecimal("qty")+" where siteid='lsa' and sa_dispatch_itemsid="+row.getLong("sa_dispatch_itemsid"));
                         sqlList.add("update sa_dispatch set closedate=null,closeby='',status='复核' where siteid='lsa' and sa_dispatchid="+row.getLong("sa_dispatchid"));
                     }
 
@@ -317,8 +317,8 @@ public class stockbill extends Controller {
             Rows stockbillrows =dbConnect.runSqlQuery("select st_stockbillid,status,rb from st_stockbill where billno='"+fbillnum+"' and siteid='lsa'");
             if(frb.equals("蓝")){
                 //查询可关闭的发货单
-                Rows dispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(outwarehouseqty) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty=t.sumoutwarehouseqty");
-                Rows undispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(outwarehouseqty) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty!=t.sumoutwarehouseqty");
+                Rows dispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty=t.sumoutwarehouseqty");
+                Rows undispatchrows =dbConnect.runSqlQuery("select t.sa_dispatchid from (select sa_dispatchid,sum(qty) sumqty,sum(ifnull(outwarehouseqty,0)) sumoutwarehouseqty from sa_dispatch_items where sa_dispatchid in(select sa_dispatchid from sa_dispatch_items where sa_dispatch_itemsid in(select t1.sa_dispatch_itemsid from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid where t1.st_stockbillid ="+stockbillrows.get(0).getLong("st_stockbillid")+" and t1.siteid='lsa')) group by sa_dispatchid)t where t.sumqty!=t.sumoutwarehouseqty");
                 ArrayList<String>  sqldispatch =new ArrayList<>();
                 for (Row row:dispatchrows) {
                     sqldispatch.add("update sa_dispatch set status='关闭',closedate=current_time,closeby='admin' where sa_dispatchid='" + row.getLong("sa_dispatchid") + "' and siteid='lsa'");

+ 5 - 1
src/custom/restcontroller/webmanage/sale/accountclass/accountclass.java

@@ -210,6 +210,7 @@ public class accountclass extends Controller {
             if (whereObject.containsKey("enterprisename") && !"".equals(whereObject.getString("enterprisename"))) {
                 where = where + " and t3.enterprisename='" + whereObject.getString("enterprisename") + "' ";
             }
+
             if (whereObject.containsKey("accountno") && !"".equals(whereObject.getString("accountno"))) {
                 where = where + " and t2.accountno='" + whereObject.getString("accountno") + "' ";
             }
@@ -217,7 +218,10 @@ public class accountclass extends Controller {
                 where = where + " and t2.accountname='" + whereObject.getString("accountname") + "' ";
             }
             if (whereObject.containsKey("condition") && !"".equals(whereObject.getString("condition"))) {
-                where = where + " and (t2.accountname like'%" + whereObject.getString("condition") + "%' or t3.enterprisename like'%" + whereObject.getString("condition") + "%') ";
+                where = where + " and (t2.accountname like'%" + whereObject.getString("condition") + "%' " +
+                        "or t3.enterprisename like'%" + whereObject.getString("condition") + "%' " +
+                        "or t4.agentnum like'%" + whereObject.getString("condition") + "%' " +
+                        ") ";
             }
         }
         if (type == 1) {

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

@@ -780,7 +780,7 @@ public class dispatch extends Controller {
         if (Parameter.get(siteid, "dispatchinstock").equals("1")) {
             for (Row row : rowsDispatchDetailGroupByItem) {
                 if (sumQtyRowsMap.containsKey(row.getString("itemno"))) {
-                    row.put("delinvbalqty", (row.containsKey("invbalqty")?row.getBigDecimal("invbalqty"):BigDecimal.ZERO).subtract(sumQtyRowsMap.get(row.getString("fitemno")).get(0).getBigDecimal("qty")));
+                    row.put("delinvbalqty", (row.containsKey("invbalqty")?row.getBigDecimal("invbalqty"):BigDecimal.ZERO).subtract(sumQtyRowsMap.get(row.getString("itemno")).get(0).getBigDecimal("qty")));
                 } else {
                     row.put("delinvbalqty", row.containsKey("invbalqty")?row.getBigDecimal("invbalqty"):BigDecimal.ZERO);
                 }

+ 16 - 0
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -184,6 +184,16 @@ public class Order extends Controller {
                 if(sa_accountclassid<=0){
                     return getErrReturnObject().setErrMsg("账户不存在").toString();
                 }
+                if(type.equals("特殊订单") || type.equals("标准订单")){
+                    Rows accountclassrows = dbConnect.runSqlQuery("select * from sa_accountclass where siteid='"+siteid+"' and sa_accountclassid="+sa_accountclassid);
+                    if(accountclassrows.isEmpty()){
+                        return getErrReturnObject().setErrMsg("账户不存在").toString();
+                    }else{
+                        if(accountclassrows.get(0).getString("accountname").equals("活动账户")){
+                            return getErrReturnObject().setErrMsg("标准订单或特殊订单禁止选择活动账户").toString();
+                        }
+                    }
+                }
                 sqlFactory.addParameter("sa_accountclassid", sa_accountclassid);
                 sqlList.addAll(updateAccountclassinfos(sa_orderid,sa_accountclassid, sys_enterpriseid));
             }
@@ -201,6 +211,12 @@ public class Order extends Controller {
                             return getErrReturnObject().setErrMsg("物料账户只能添加物料商品,请检查").toString();
                         }
                     }
+
+                    if(type.equals("特殊订单") || type.equals("标准订单")){
+                        if(accountclassRows.get(0).getString("accountname").equals("活动账户")){
+                            return getErrReturnObject().setErrMsg("标准订单或特殊订单禁止选择活动账户").toString();
+                        }
+                    }
                 }else {
                     return getErrReturnObject().setErrMsg("账户不存在").toString();
                 }

+ 2 - 2
src/custom/restcontroller/webmanage/sale/order/SQL/订单_出库单列表.sql

@@ -1,3 +1,3 @@
-select t.* from (select t2.st_stockbillid,t2.billno,t2.status,t2.remarks,t2.billdate from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid inner join sa_dispatch_items t3 on t1.sa_dispatch_itemsid=t3.sa_dispatch_itemsid and t1.siteid=t3.siteid inner join sa_orderitems t4 on t4.sa_orderitemsid=t3.sa_orderitemsid and t4.siteid=t3.siteid where t4.sa_orderid=$sa_orderid$ and t2.rb=1
+select  t.* from (select distinct t2.st_stockbillid,t2.billno,t2.status,t2.remarks,t2.billdate from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid inner join sa_dispatch_items t3 on t1.sa_dispatch_itemsid=t3.sa_dispatch_itemsid and t1.siteid=t3.siteid inner join sa_orderitems t4 on t4.sa_orderitemsid=t3.sa_orderitemsid and t4.siteid=t3.siteid where t4.sa_orderid=$sa_orderid$ and t2.rb=1
 union all
-select t2.st_stockbillid,t2.billno,t2.status,t2.remarks,t2.billdate from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid inner join sa_aftersalesmag_items t3 on t1.sa_dispatch_itemsid=t3.sa_aftersalesmag_itemsid and t1.siteid=t3.siteid inner join sa_orderitems t4 on t4.sa_orderitemsid=t3.sa_orderitemsid and t4.siteid=t3.siteid where t4.sa_orderid=$sa_orderid$ and t2.rb=0) t where $where$
+select distinct t2.st_stockbillid,t2.billno,t2.status,t2.remarks,t2.billdate from st_stockbill_items t1 inner join st_stockbill t2 on t1.st_stockbillid=t2.st_stockbillid and t1.siteid=t2.siteid inner join sa_aftersalesmag_items t3 on t1.sa_dispatch_itemsid=t3.sa_aftersalesmag_itemsid and t1.siteid=t3.siteid inner join sa_orderitems t4 on t4.sa_orderitemsid=t3.sa_orderitemsid and t4.siteid=t3.siteid where t4.sa_orderid=$sa_orderid$ and t2.rb=0) t where $where$

+ 4 - 4
src/custom/restcontroller/webmanage/sale/promotion/promotion.java

@@ -168,10 +168,10 @@ public class promotion extends Controller {
         sqlFactory.addParameter("sa_brandid", row.getLong("sa_brandid"));
         sqlFactory.addParameter("type", row.getString("type"));
         sqlFactory.addParameter("tradefield", row.getString("tradefield"));
-        sqlFactory.addParameter("orderminqty", row.getString("orderminqty"));
-        sqlFactory.addParameter("orderaddqty", row.getString("orderaddqty"));
-        sqlFactory.addParameter("orderminamount", row.getString("orderminamount"));
-        sqlFactory.addParameter("sa_openpromotionid", row.getString("sa_openpromotionid"));
+        sqlFactory.addParameter("orderminqty", row.getBigDecimal("orderminqty"));
+        sqlFactory.addParameter("orderaddqty", row.getBigDecimal("orderaddqty"));
+        sqlFactory.addParameter("orderminamount", row.getBigDecimal("orderminamount"));
+        sqlFactory.addParameter("sa_openpromotionid", row.getLong("sa_openpromotionid"));
         sqlFactory.addParameter("openamount", row.getBigDecimal("openamount"));
         sqlFactory.addParameter("isrelevancepromotion", row.getString("isrelevancepromotion"));
         sqlFactory.addParameter("associationamount", row.getString("associationamount"));

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

@@ -414,7 +414,7 @@ public class salearea extends Controller {
         QuerySQL querySQL = SQLFactory.createQuerySQL(this, "sa_agents");
         querySQL.setTableAlias("t1");
         querySQL.addJoinTable(JOINTYPE.inner, "sys_enterprise", "t2", "t1.siteid = t2.siteid and t1.sys_enterpriseid = t2.sys_enterpriseid",
-                "enterprisename", "phonenumber", "contact", "province", "city", "county", "address", "limitreturnday", "freefreightamount", "invoicingpoint");
+                "enterprisename", "phonenumber", "contact", "province", "city", "county", "address", "limitreturnday", "freefreightamount", "invoicingpoint","saleclassauth");
         querySQL.addJoinTable(JOINTYPE.left, "sys_dataextend", "t4", "t1.sys_enterpriseid = t4.ownerid and ownertable = 'sys_enterprise' and t1.siteid = t4.siteid",
                 "erpagentnum");
         querySQL.setWhere("t1.siteid", siteid);