Преглед изворни кода

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

沈静伟 пре 2 година
родитељ
комит
0ed9d8fc48

+ 1 - 2
src/custom/restcontroller/sale/itemgroup/SQL/商品组商品明细查询.sql

@@ -20,5 +20,4 @@ FROM sa_itemgroupmx t1
          left join sa_brand t5 on t4.siteid = t5.siteid and t4.sa_brandid = t5.sa_brandid
 where $where$
   and t1.sa_itemgroupid = $sa_itemgroupid$
-  and t1.siteid = $siteid$
-order by t1.sequence asc
+  and t1.siteid = $siteid$

+ 3 - 3
src/custom/restcontroller/sale/promotion/SQL/促销方案列表查询.sql

@@ -52,7 +52,7 @@ from (SELECT t1.promnum,
                      where t1.siteid = t2.siteid
                        and t1.sa_promotionid = t2.sa_promotionid
                        and t2.sys_enterpriseid = $sys_enterpriseid$
-                       and t2.saledamount<t2.limitamount)
+                       and if(t2.islimit=1,t2.saledamount<t2.limitamount,1=1))
               OR NOT EXISTS(SELECT *
                             FROM sa_promotion_auth
                             WHERE sa_promotionid = t1.sa_promotionid AND siteid = t1.siteid))
@@ -65,7 +65,7 @@ with recursive salearea as (
     union all
     select t2.sa_saleareaid
     from salearea t1
-             inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid ='ccyosg'
+             inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid =$siteid$
 )
 select sa_saleareaid
 from salearea))
@@ -128,7 +128,7 @@ with recursive salearea as (
     union all
     select t2.sa_saleareaid
     from salearea t1
-             inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid ='ccyosg'
+             inner join sa_salearea t2 on t1.sa_saleareaid = t2.parentid and t2.siteid =$siteid$
 )
 select sa_saleareaid
 from salearea))

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

@@ -15,7 +15,9 @@ import common.data.Rows;
 import common.data.RowsMap;
 import common.data.SQLFactory;
 import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
 import restcontroller.R;
+import service.AftersalesmagAutoRecheckService;
 
 import javax.swing.text.StyledEditorKit;
 import java.math.BigDecimal;
@@ -33,7 +35,7 @@ public class stockbill extends Controller {
     public stockbill(JSONObject content) throws YosException {
         super(content);
     }
-
+    private static Logger logger = Logger.getLogger(stockbill.class);
     /**
      * 更新YOS销售出库单
      * @return
@@ -184,10 +186,13 @@ public class stockbill extends Controller {
                         sqlList.add("update sa_dispatch_items set outwarehousedate=CURRENT_TIME,outwarehouseqty=outwarehouseqty+"+fqty+" where siteid='lsa1986' 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());
                             sqlFactorydetail.addParameter("price", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price"));
                             sqlFactorydetail.addParameter("amount", fqty.multiply(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("price")));
-                            sqlFactorydetail.addParameter("sa_orderitemsid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderitemsid"));
-                            sqlFactorydetail.addParameter("sa_orderid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderid"));
+                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderitemsid"));
+                            logger.info(aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getBigDecimal("sa_orderid"));
+                            sqlFactorydetail.addParameter("sa_orderitemsid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderitemsid"));
+                            sqlFactorydetail.addParameter("sa_orderid", aftersalesmagRowsMap.get(sainvoicedetailid).get(0).getLong("sa_orderid"));
                         }else{
                             sqlFactorydetail.addParameter("price", 0);
                             sqlFactorydetail.addParameter("amount", 0);
@@ -312,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='lsa1986'");
             if(frb.equals("蓝")){
                 //查询可关闭的发货单
-                Rows dispatchrows =dbConnect.runSqlQuery( "select t.sa_dispatchid from (select t2.sa_dispatchid,sum(t2.qty) sumqty,sum(outwarehouseqty) sumoutwarehouseqty 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='lsa1986' group by t2.sa_dispatchid) t where t.sumqty=t.sumoutwarehouseqty");
-                Rows undispatchrows =dbConnect.runSqlQuery( "select t.sa_dispatchid from (select t2.sa_dispatchid,sum(t2.qty) sumqty,sum(outwarehouseqty) sumoutwarehouseqty 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='lsa1986' group by t2.sa_dispatchid) t where t.sumqty!=t.sumoutwarehouseqty");
+                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='lsa1986')) 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='lsa1986')) 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='lsa1986'");

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

@@ -488,7 +488,7 @@ public class dispatch extends Controller {
         Rows rows = dbConnect.runSqlQuery("select sa_dispatchid,status,billno,sa_orderid from sa_dispatch where sa_dispatchid ='"
                 + sa_dispatchid + "' and  siteid='" + siteid + "'");
 
-        Rows rowsdetail = dbConnect.runSqlQuery("select sa_dispatch_itemsid from sa_dispatch_items where sa_dispatchid ='"
+        Rows rowsdetail = dbConnect.runSqlQuery("select cast(sa_dispatch_itemsid AS CHAR) as sa_dispatch_itemsid from sa_dispatch_items where sa_dispatchid ='"
                 + sa_dispatchid + "' and  siteid='" + siteid + "'");
         if (rows.isEmpty()) {
             return getErrReturnObject().setErrMsg("该发货单不存在")
@@ -506,6 +506,7 @@ public class dispatch extends Controller {
         object.put("method", "getIcstockbillMsg");
 
         JSONObject content = new JSONObject();
+
         content.put("sa_dispatch_itemsids", rowsdetail.toJsonArray("sa_dispatch_itemsid"));
         object.put("content", content);
 

+ 6 - 1
src/custom/restcontroller/webmanage/sale/item/Item.java

@@ -663,7 +663,7 @@ public class Item extends Controller {
                     sqlFactory1.addParameter("siteid", siteid);
                     Rows rows = dbConnect.runSqlQuery(sqlFactory1.getSQL());
                     if(rows.isNotEmpty()){
-                        sqlList.add("update plm_item set marketingcategory='"+ rows.get(0).getString("itemclassname")+"' where siteid='"+siteid+"' and itemid="+id);
+                        sqlList.add("update plm_item set marketingcategory='"+ rows.get(0).getString("itemclassid")+"' where siteid='"+siteid+"' and itemid="+id);
                     }
                 }
             }
@@ -752,6 +752,11 @@ public class Item extends Controller {
             sqlFactory.addParameter("username", username);
             sqlFactory.addParameter("isonsale", isonsale);
             sqlList.add(sqlFactory.getSQL(false));
+            if (isonsale.equals("1")) {
+                sqlList.add(DataContrlLog.createLog(this, "plm_item", id, "商品上架", "商品上架成功" ).getSQL());
+            }else{
+                sqlList.add(DataContrlLog.createLog(this, "plm_item", id, "商品下架", "商品下架成功").getSQL());
+            }
 
             //审核商品时,自动添加至商品组中
             if (itemRowsMap.containsKey(String.valueOf(obj))) {

+ 1 - 1
src/custom/restcontroller/webmanage/sale/item/SQL/获取最上级营销类别名称.sql

@@ -1,4 +1,4 @@
-select itemclassname from plm_itemclass t1 inner join (with recursive itemclass as (
+select t1.itemclassid,itemclassname from plm_itemclass t1 inner join (with recursive itemclass as (
     select itemclassid, parentid
     from plm_itemclass
     where siteid = $siteid$

+ 1 - 2
src/custom/restcontroller/webmanage/sale/itemgroup/SQL/商品组商品明细查询.sql

@@ -15,5 +15,4 @@ FROM sa_itemgroupmx t1
          left join sa_customscheme t4 on t2.sa_customschemeid=t4.sa_customschemeid and t2.siteid=t4.siteid
 where $where$
   and t1.sa_itemgroupid = $sa_itemgroupid$
-  and t1.siteid = $siteid$
-order by t1.sequence asc
+  and t1.siteid = $siteid$

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

@@ -1233,6 +1233,13 @@ public class Order extends Controller {
         if (orderitems.isNotEmpty()) {
             return getErrReturnObject().setErrMsg("订单表体行号为【" + orderitems.get(0).getLong("rowno") + "】的商品数量为0无法提交").toString();
         }
+        String type = row.getString("type");
+        if (type.equals("标准订单")) {
+            Rows iteminfos = dbConnect.runSqlQuery("select t2.itemno from sa_orderitems t1 inner join plm_item t2 on t1.siteid=t2.siteid and t1.itemid=t2.itemid where t1.sa_orderid=" + sa_orderid + " and t1.siteid='" + siteid + "' and t2.isonsale!=1");
+            if (iteminfos.isNotEmpty()) {
+                return getErrReturnObject().setErrMsg("检测到品号"+iteminfos.get(0).getLong("itemno") + "未上架,请删除后重试").toString();
+            }
+        }
 
         //通过版本更新订单表头数据
         beans.order.Order.updateOrderWithVersion(this);
@@ -1264,7 +1271,6 @@ public class Order extends Controller {
         }
         ArrayList<String> sqlList = new ArrayList<>();
         String sonum = row.getString("sonum");
-        String type = row.getString("type");
         if (type.equals("促销订单")) {
             Rows orderdetails = dbConnect.runSqlQuery("select * from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid);
             Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + row.getLong("sa_promotionid"));

+ 17 - 9
src/custom/restcontroller/webmanage/sale/order/OrderItems.java

@@ -140,7 +140,7 @@ public class OrderItems extends Controller {
                     sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单商品【" + itemRow.getString("itemname") + "】由单价:" + price1 + "修改为单价:" + price, "订单修改单价").getSQL());
                 }
             }
-            if(price.compareTo(BigDecimal.ZERO)<0){
+            if (price.compareTo(BigDecimal.ZERO) < 0) {
                 return getErrReturnObject().setErrMsg("价格不可小于0").toString();
             }
             if (isInsert) {
@@ -158,7 +158,7 @@ public class OrderItems extends Controller {
                 if (promotionRows.get(0).getString("type").equals("打包促销")) {
                     BigDecimal orderaddqty = promotionRows.get(0).getBigDecimal("orderaddqty");
                     BigDecimal orderminqty = promotionRows.get(0).getBigDecimal("orderminqty");
-                    if (((sumqty.subtract(orderminqty)).remainder(orderaddqty)).compareTo(BigDecimal.ZERO) != 0 || sumqty.compareTo(orderminqty)<0) {
+                    if (((sumqty.subtract(orderminqty)).remainder(orderaddqty)).compareTo(BigDecimal.ZERO) != 0 || sumqty.compareTo(orderminqty) < 0) {
                         return getErrReturnObject().setErrMsg("不符合促销活动订购数量规则,修改不成功").toString();
                     }
                 }
@@ -179,6 +179,10 @@ public class OrderItems extends Controller {
         //更新订单扣款信息
         updateAccountclassinfos(sa_orderid);
 
+        if (systemclient.equalsIgnoreCase("wechatsaletool")) {
+            Rows rows = dbConnect.runSqlQuery("SELECT sa_orderitemsid,sa_orderitems_v,itemid from sa_orderitems WHERE sa_orderid=" + sa_orderid + " and siteid='" + siteid + "'");
+            return getSucReturnObject().setData(rows).toString();
+        }
 
         return getSucReturnObject().toString();
     }
@@ -403,6 +407,10 @@ public class OrderItems extends Controller {
             return getErrReturnObject().setErrMsg("该订单不存在").toString();
         }
 
+        if(!(discountrate.compareTo(BigDecimal.ZERO)>0 && discountrate.compareTo(new BigDecimal(1))<=0)){
+            return getErrReturnObject().setErrMsg("折扣必须在0-1之间").toString();
+        }
+
         //通过版本更新订单表头数据
         beans.order.Order.updateOrderWithVersion(this);
 
@@ -422,7 +430,7 @@ public class OrderItems extends Controller {
                 sqlList.add("update sa_orderitems set price=" + price + ",amount=" + amount + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
             }
         }
-        sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单整单折扣变更【"+discountrate+"】","整单折扣").getSQL());
+        sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单整单折扣变更【" + discountrate + "】", "整单折扣").getSQL());
         dbConnect.runSqlUpdate(sqlList);
 
         updateAccountclassinfos(sa_orderid);
@@ -466,7 +474,7 @@ public class OrderItems extends Controller {
                 sqlList.add("update sa_orderitems set price=" + price + ",amount=" + amount + " where sa_orderitemsid=" + row.getLong("sa_orderitemsid"));
             }
         }
-        sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单商品行价格刷新(恢复原价)","订单商品行价格刷新").getSQL());
+        sqlList.add(DataContrlLog.createLog(this, "sa_order", sa_orderid, "订单商品行价格刷新(恢复原价)", "订单商品行价格刷新").getSQL());
         dbConnect.runSqlUpdate(sqlList);
         updateAccountclassinfos(sa_orderid);
         return getSucReturnObject().toString();
@@ -571,7 +579,7 @@ public class OrderItems extends Controller {
         WebRequest request = new WebRequest();
         String result = request.doPost(object.toString(),
                 "http://60.190.151.198:8092/BYESB/jaxrs/webclientrest");
-        if(isJSONArray(result)){
+        if (isJSONArray(result)) {
             jsonArray = JSONArray.parseArray(result);
         }
         for (Object obj : jsonArray) {
@@ -729,13 +737,13 @@ public class OrderItems extends Controller {
                 String convenient = whereObject.getStringValue("convenient");
                 if (convenient.equals("待确认")) {
                     where.append(" and t5.status ='预提交' ");
-                }else if(convenient.equals("待审核")){
+                } else if (convenient.equals("待审核")) {
                     where.append(" and t5.status ='提交' ");
-                }else if(convenient.equals("待发货")){
+                } else if (convenient.equals("待发货")) {
                     where.append(" and t5.status not in ('预提交','新建') and not exists(select 1 from st_stockbill_items s1 inner join st_stockbill s2 on s1.st_stockbillid=s2.st_stockbillid and s1.siteid=s2.siteid where s2.status='审核' and s2.rb=1 and s1.sa_orderitemsid=t1.sa_orderitemsid)");
-                }else if(convenient.equals("已发货")){
+                } else if (convenient.equals("已发货")) {
                     where.append(" and exists(select 1 from st_stockbill_items s1 inner join st_stockbill s2 on s1.st_stockbillid=s2.st_stockbillid and s1.siteid=s2.siteid where s2.status='审核' and s2.rb=1 and s1.sa_orderitemsid=t1.sa_orderitemsid)");
-                }else if(convenient.equals("已取消")){
+                } else if (convenient.equals("已取消")) {
                     where.append(" and t5.status ='手工关闭' and  exists(select 1 from (\n" +
                             "select  s1.sa_orderitemsid,s1.siteid,sum(s1.qty) qty from st_stockbill_items s1 inner join st_stockbill s2 on s1.st_stockbillid=s2.st_stockbillid and s1.siteid=s2.siteid where s2.status='审核' and s2.rb=1 group by s1.sa_orderitemsid,s1.siteid) s right join sa_orderitems s1  on s.sa_orderitemsid=s1.sa_orderitemsid and s.siteid=s1.siteid where s1.qty>ifnull(s.qty,0) and s1.sa_orderitemsid=t1.sa_orderitemsid)");
                 }

+ 0 - 4
src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

@@ -305,10 +305,6 @@ public class OrderItemsHelper extends BaseClass {
 
         updateSQL.setWhere("siteid", controller.siteid);
         updateSQL.setWhere("sa_orderitemsid", sa_orderitemsid);
-        if (item.containsKey("sa_orderitems_v")) {
-            updateSQL.setDataVersion(item.getIntValue("sa_orderitems_v"));
-        }
-
 
         return updateSQL;
     }

+ 7 - 0
src/custom/restcontroller/webmanage/sale/promotion/promotion.java

@@ -293,12 +293,19 @@ public class promotion extends Controller {
             Rows RowsStatus = dbConnect.runSqlQuery("select sa_promotionid,status from sa_promotion where siteid='"
                     + siteid + "' and sa_promotionid='" + sa_promotionid + "'");
 
+            Rows Rowsdetail = dbConnect.runSqlQuery("select sa_promotion_authid from sa_promotion_auth where siteid='"
+                    + siteid + "' and sa_promotionid='" + sa_promotionid + "' and saledamount>0");
+
             if (RowsStatus.isNotEmpty()) {
                 if (!RowsStatus.get(0).getString("status").equals("新建")) {
                     batchDeleteErr.addErr(sa_promotionid, "非新建状态的促销方案无法删除");
                     continue;
                 }
             }
+            if (Rowsdetail.isNotEmpty()) {
+                batchDeleteErr.addErr(sa_promotionid, "存在已购金额的授权经销商禁止删除促销活动");
+                continue;
+            }
             sqlList.add("delete from sa_promotion where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);
             sqlList.add(
                     "delete from sa_promotion_auth where siteid='" + siteid + "' and sa_promotionid=" + sa_promotionid);

+ 26 - 6
src/custom/restcontroller/webmanage/sale/promotion/promotionAuth.java

@@ -9,9 +9,11 @@ import common.annotation.API;
 import common.annotation.CACHEING;
 import common.annotation.CACHEING_CLEAN;
 import common.data.Rows;
+import common.data.RowsMap;
 import common.data.SQLFactory;
 import restcontroller.R;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 
 public class promotionAuth extends Controller {
@@ -31,10 +33,10 @@ public class promotionAuth extends Controller {
         long[] sa_promotion_authid = createTableID("sa_promotion_auth", enterpriseinfos.size());
         for (Object obj : enterpriseinfos) {
             JSONObject enterpriseinfo = (JSONObject) obj;
-            if (enterpriseinfo.getLong("sa_promotion_authid") <= 0 || dbConnect.runSqlQuery(
-                            "select sa_promotion_authid from sa_promotion_auth where sa_promotion_authid="
-                                    + enterpriseinfo.getLong("sa_promotion_authid"))
-                    .isEmpty()) {
+            Rows rows = dbConnect.runSqlQuery(
+                    "select sa_promotion_authid,settlestatus,saledamount from sa_promotion_auth where sa_promotion_authid="
+                            + enterpriseinfo.getLong("sa_promotion_authid"));
+            if (enterpriseinfo.getLong("sa_promotion_authid") <= 0 || rows.isEmpty()) {
                 SQLFactory saleFactory = new SQLFactory(this, "促销方案参与授权范围新增");
                 saleFactory.addParameter("siteid", siteid);
                 saleFactory.addParameter("sa_promotion_authid", sa_promotion_authid[i]);
@@ -49,6 +51,12 @@ public class promotionAuth extends Controller {
 
                 i++;
             } else {
+                if(rows.get(0).getBoolean("settlestatus")){
+                    return getErrReturnObject().setErrMsg("已结算,无法修改").toString();
+                }
+                if(rows.get(0).getBigDecimal("saledamount").compareTo(enterpriseinfo.getBigDecimalValue("limitamount"))>0){
+                    return getErrReturnObject().setErrMsg("限购金额必须大于等于已购金额").toString();
+                }
                 SQLFactory saleFactory = new SQLFactory(this, "促销方案参与授权范围更新");
                 saleFactory.addParameter("sa_promotion_authid", enterpriseinfo.getLong("sa_promotion_authid"));
                 // saleFactory.addParameter("itemno", iteminfo.getString("itemno"));
@@ -129,11 +137,23 @@ public class promotionAuth extends Controller {
 
         JSONArray sa_promotion_authids = content.getJSONArray("sa_promotion_authids");
         BatchDeleteErr batchDeleteErr = BatchDeleteErr.create(this, sa_promotion_authids.size());
+        Rows rows = dbConnect.runSqlQuery(
+                "select sa_promotion_authid,settlestatus,saledamount from sa_promotion_auth where sa_promotion_authid in"
+                        + sa_promotion_authids.toJSONString().replace("[", "(").replace("]", ")"));
+        RowsMap rowsMap =rows.toRowsMap("sa_promotion_authid");
         for (Object o : sa_promotion_authids) {
-            long sa_promotion_authid = Long.parseLong(o.toString());
+            String sa_promotion_authid = o.toString();
             ArrayList<String> list = new ArrayList<>();
+            if(rowsMap.containsKey(sa_promotion_authid)){
+                if(rowsMap.get(sa_promotion_authid).isNotEmpty()){
+                    if(rowsMap.get(sa_promotion_authid).get(0).getBigDecimal("saledamount").compareTo(BigDecimal.ZERO)!=0){
+                        batchDeleteErr.addErr(Long.parseLong(sa_promotion_authid),"存在已购金额的授权经销商禁止删除");
+                        continue;
+                    }
+                }
+            }
             SQLFactory deletesql = new SQLFactory("sql:delete from sa_promotion_auth where siteid='" + siteid
-                    + "' and sa_promotion_authid=" + sa_promotion_authid);
+                    + "' and sa_promotion_authid='" + sa_promotion_authid+"'");
             list.add(deletesql.getSQL());
 
             dbConnect.runSqlUpdate(list);