Browse Source

尾货促销

hu 2 years ago
parent
commit
295f5be686

+ 1 - 0
src/custom/restcontroller/sale/promotion/SQL/促销方案商品查询.sql

@@ -9,6 +9,7 @@ SELECT
 	t1.islimit,
 	t1.isonsale,
 	t1.itemid,
+	t1.signaturecode,
 	t2.iscustomsize,
   t2.widthschemeid,
   t2.lengthschemeid,

+ 43 - 27
src/custom/restcontroller/webmanage/sale/order/Order.java

@@ -1319,23 +1319,23 @@ public class Order extends Controller {
         ArrayList<String> sqlList = new ArrayList<>();
         String sonum = row.getString("sonum");
         if (type.equals("促销订单")) {
-            Rows orderdetails = dbConnect.runSqlQuery("select itemid,itemno,sum(qty) qty from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid+" group by itemid,itemno");
+            Rows orderdetails = dbConnect.runSqlQuery("select sa_promotion_itemsid,itemno,sum(qty) qty  from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid +" group by sa_promotion_itemsid,itemno");
             Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + row.getLong("sa_promotionid"));
-            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("itemid");
+            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("sa_promotion_itemsid");
             for (Row orderdetail : orderdetails) {
-                String itemid = orderdetail.getString("itemid");
+                String sa_promotion_itemsid = orderdetail.getString("sa_promotion_itemsid");
                 BigDecimal qty = orderdetail.getBigDecimal("qty");
-                if (promotionitemsRowsMap.containsKey(itemid)) {
-                    if (promotionitemsRowsMap.get(itemid).isNotEmpty()) {
-                        BigDecimal saledqty = promotionitemsRowsMap.get(itemid).get(0).getBigDecimal("saledqty");
-                        BigDecimal groupqty = promotionitemsRowsMap.get(itemid).get(0).getBigDecimal("groupqty");
-                        boolean islimit = promotionitemsRowsMap.get(itemid).get(0).getBoolean("islimit");
+                if (promotionitemsRowsMap.containsKey(sa_promotion_itemsid)) {
+                    if (promotionitemsRowsMap.get(sa_promotion_itemsid).isNotEmpty()) {
+                        BigDecimal saledqty = promotionitemsRowsMap.get(sa_promotion_itemsid).get(0).getBigDecimal("saledqty");
+                        BigDecimal groupqty = promotionitemsRowsMap.get(sa_promotion_itemsid).get(0).getBigDecimal("groupqty");
+                        boolean islimit = promotionitemsRowsMap.get(sa_promotion_itemsid).get(0).getBoolean("islimit");
                         if (islimit) {
                             if (groupqty.compareTo(saledqty.add(qty)) < 0) {
                                 return getErrReturnObject().setErrMsg("品号:" + orderdetail.getString("itemno") + "已超过限购数量:" + groupqty.subtract(saledqty)).toString();
                             }
                         }
-                        sqlList.add("update sa_promotion_items set saledqty=ifnull(saledqty,0)+" + qty + " where sa_promotion_itemsid=" + promotionitemsRowsMap.get(itemid).get(0).getLong("sa_promotion_itemsid"));
+                        sqlList.add("update sa_promotion_items set saledqty=ifnull(saledqty,0)+" + qty + " where sa_promotion_itemsid=" + sa_promotion_itemsid);
                     }
                 }
             }
@@ -1865,15 +1865,15 @@ public class Order extends Controller {
 
         String type = row.getString("type");
         if (type.equals("促销订单")) {
-            Rows orderdetails = dbConnect.runSqlQuery("select itemid,itemno,sum(qty) qty from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid+" group by itemid,itemno");
+            Rows orderdetails = dbConnect.runSqlQuery("select sa_promotion_itemsid,itemno,sum(qty) qty  from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid +" group by sa_promotion_itemsid,itemno");
             Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + row.getLong("sa_promotionid"));
-            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("itemid");
+            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("sa_promotion_itemsid");
             for (Row orderdetail : orderdetails) {
-                String itemid = orderdetail.getString("itemid");
+                String sa_promotion_itemsid = orderdetail.getString("sa_promotion_itemsid");
                 BigDecimal qty = orderdetail.getBigDecimal("qty");
-                if (promotionitemsRowsMap.containsKey(itemid)) {
-                    if (promotionitemsRowsMap.get(itemid).isNotEmpty()) {
-                        sqlList.add("update sa_promotion_items set saledqty=saledqty-" + qty + " where sa_promotion_itemsid=" + promotionitemsRowsMap.get(itemid).get(0).getLong("sa_promotion_itemsid"));
+                if (promotionitemsRowsMap.containsKey(sa_promotion_itemsid)) {
+                    if (promotionitemsRowsMap.get(sa_promotion_itemsid).isNotEmpty()) {
+                        sqlList.add("update sa_promotion_items set saledqty=saledqty-" + qty + " where sa_promotion_itemsid=" + sa_promotion_itemsid);
                     }
                 }
             }
@@ -1964,15 +1964,15 @@ public class Order extends Controller {
 
         String type = row.getString("type");
         if (type.equals("促销订单")) {
-            Rows orderdetails = dbConnect.runSqlQuery("select itemid,itemno,sum(qty) qty from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid+" group by itemid,itemno");
+            Rows orderdetails = dbConnect.runSqlQuery("select sa_promotion_itemsid,itemno,sum(qty) qty  from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid +" group by sa_promotion_itemsid,itemno");
             Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + row.getLong("sa_promotionid"));
-            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("itemid");
+            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("sa_promotion_itemsid");
             for (Row orderdetail : orderdetails) {
-                String itemid = orderdetail.getString("itemid");
+                String sa_promotion_itemsid = orderdetail.getString("sa_promotion_itemsid");
                 BigDecimal qty = orderdetail.getBigDecimal("qty");
-                if (promotionitemsRowsMap.containsKey(itemid)) {
-                    if (promotionitemsRowsMap.get(itemid).isNotEmpty()) {
-                        sqlList.add("update sa_promotion_items set saledqty=saledqty-" + qty + " where sa_promotion_itemsid=" + promotionitemsRowsMap.get(itemid).get(0).getLong("sa_promotion_itemsid"));
+                if (promotionitemsRowsMap.containsKey(sa_promotion_itemsid)) {
+                    if (promotionitemsRowsMap.get(sa_promotion_itemsid).isNotEmpty()) {
+                        sqlList.add("update sa_promotion_items set saledqty=saledqty-" + qty + " where sa_promotion_itemsid=" +sa_promotion_itemsid);
                     }
                 }
             }
@@ -3060,20 +3060,36 @@ public class Order extends Controller {
 
         String type = orderRow.get(0).getString("type");
         if (type.equals("促销订单")) {
-            Rows orderdetails = dbConnect.runSqlQuery("select itemid,itemno,sum(undeliqty) qty  from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid + " group by itemid,itemno");
+            Rows orderdetails = dbConnect.runSqlQuery("select sa_promotion_itemsid,itemno,sum(undeliqty) qty  from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid +" group by sa_promotion_itemsid,itemno");
             Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + orderRow.get(0).getLong("sa_promotionid"));
-            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("itemid");
+            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("sa_promotion_itemsid");
             for (Row orderdetail : orderdetails) {
-                String itemid = orderdetail.getString("itemid");
+                String sa_promotion_itemsid = orderdetail.getString("sa_promotion_itemsid");
                 BigDecimal qty = orderdetail.getBigDecimal("qty");
-                if (promotionitemsRowsMap.containsKey(itemid)) {
-                    if (promotionitemsRowsMap.get(itemid).isNotEmpty()) {
-                        sqlList.add("update sa_promotion_items set saledqty=saledqty-" + qty + " where sa_promotion_itemsid=" + promotionitemsRowsMap.get(itemid).get(0).getLong("sa_promotion_itemsid"));
+                if (promotionitemsRowsMap.containsKey(sa_promotion_itemsid)) {
+                    if (promotionitemsRowsMap.get(sa_promotion_itemsid).isNotEmpty()) {
+                        sqlList.add("update sa_promotion_items set saledqty=saledqty-" + qty + " where sa_promotion_itemsid=" + sa_promotion_itemsid);
                     }
                 }
             }
         }
 
+//        String type = orderRow.get(0).getString("type");
+//        if (type.equals("促销订单")) {
+//            Rows orderdetails = dbConnect.runSqlQuery("select itemid,itemno,sum(undeliqty) qty  from sa_orderitems where siteid='" + siteid + "' and sa_orderid=" + sa_orderid + " group by itemid,itemno");
+//            Rows promotionitems = dbConnect.runSqlQuery("select * from sa_promotion_items where siteid='" + siteid + "' and sa_promotionid=" + orderRow.get(0).getLong("sa_promotionid"));
+//            RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("itemid");
+//            for (Row orderdetail : orderdetails) {
+//                String itemid = orderdetail.getString("itemid");
+//                BigDecimal qty = orderdetail.getBigDecimal("qty");
+//                if (promotionitemsRowsMap.containsKey(itemid)) {
+//                    if (promotionitemsRowsMap.get(itemid).isNotEmpty()) {
+//                        sqlList.add("update sa_promotion_items set saledqty=saledqty-" + qty + " where sa_promotion_itemsid=" + promotionitemsRowsMap.get(itemid).get(0).getLong("sa_promotion_itemsid"));
+//                    }
+//                }
+//            }
+//        }
+
         Rows rows = dbConnect.runSqlQuery("SELECT cast(sum(undeliqty*price) as DECIMAL(16,2)) totalprice from sa_orderitems WHERE sa_orderid=" + sa_orderid + " and siteid = '" + siteid + "'");
         if (rows.isNotEmpty()) {
             BigDecimal totalprice = rows.get(0).getBigDecimal("totalprice");

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

@@ -103,7 +103,7 @@ public class OrderItems extends Controller {
                 //获取定制属性
                 customproperties = orderItemsHelper.getCustomProperties(itemRowsMap, item);
                 spec=orderItemsHelper.getCustomSpec(itemRowsMap, item);
-                Rows rows = dbConnect.runSqlQuery("SELECT sa_orderitemsid,price from sa_orderitems WHERE siteid='" + siteid + "' and itemid=" + itemid + " and sa_orderid=" + sa_orderid);
+                Rows rows = dbConnect.runSqlQuery("SELECT sa_orderitemsid,price from sa_orderitems WHERE siteid='" + siteid + "' and itemid=" + itemid + " and sa_orderid=" + sa_orderid+" and sa_promotion_itemsid="+item.getLongValue("sa_promotion_itemsid"));
 
                 if (rows.isEmpty()) {
                     sa_orderitemsid = createTableID("sa_orderitems");
@@ -148,7 +148,7 @@ public class OrderItems extends Controller {
                 return getErrReturnObject().setErrMsg("价格不可小于0").toString();
             }
             if (isInsert) {
-                sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice, itemPrice.getMarketprice(),spec).getSQL());
+                sqlList.add(orderItemsHelper.getInsertSQL(customproperties, sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice, itemPrice.getMarketprice(),spec,promotionitems).getSQL());
             } else {
                 sqlList.add(orderItemsHelper.getUpdateSQL(sa_orderitemsid, item, itemRow, type, defaultprice, price,saleprice).getSQL());
             }

+ 21 - 11
src/custom/restcontroller/webmanage/sale/order/OrderItemsHelper.java

@@ -48,15 +48,15 @@ public class OrderItemsHelper extends BaseClass {
                 }
             }
         }
-        RowsMap pRowsMap = promotionitems.toRowsMap("itemid");
+        RowsMap pRowsMap = promotionitems.toRowsMap("sa_promotion_itemsid");
         if (type.equals("促销订单")) {
-            if (pRowsMap.containsKey(itemid)) {
-                if (pRowsMap.get(itemid).isNotEmpty()) {
-                    BigDecimal saledqty = pRowsMap.get(itemid).get(0).getBigDecimal("saledqty");
-                    BigDecimal groupqty = pRowsMap.get(itemid).get(0).getBigDecimal("groupqty");
-                    BigDecimal orderaddqty = pRowsMap.get(itemid).get(0).getBigDecimal("orderaddqty");
-                    BigDecimal orderminqty = pRowsMap.get(itemid).get(0).getBigDecimal("orderminqty");
-                    boolean islimit = pRowsMap.get(itemid).get(0).getBoolean("islimit");
+            if (pRowsMap.containsKey(item.getString("sa_promotion_itemsid"))) {
+                if (pRowsMap.get(item.getString("sa_promotion_itemsid")).isNotEmpty()) {
+                    BigDecimal saledqty = pRowsMap.get(item.getString("sa_promotion_itemsid")).get(0).getBigDecimal("saledqty");
+                    BigDecimal groupqty = pRowsMap.get(item.getString("sa_promotion_itemsid")).get(0).getBigDecimal("groupqty");
+                    BigDecimal orderaddqty = pRowsMap.get(item.getString("sa_promotion_itemsid")).get(0).getBigDecimal("orderaddqty");
+                    BigDecimal orderminqty = pRowsMap.get(item.getString("sa_promotion_itemsid")).get(0).getBigDecimal("orderminqty");
+                    boolean islimit = pRowsMap.get(item.getString("sa_promotion_itemsid")).get(0).getBoolean("islimit");
                     if (orderaddqty.compareTo(BigDecimal.ZERO) != 0) {
                         if (((qty.subtract(orderminqty)).remainder(orderaddqty)).compareTo(BigDecimal.ZERO) != 0 || qty.compareTo(orderminqty) < 0) {
                             throw new YosException(false, "品号为" + itemRowsMap.get(itemid).get(0).getString("itemno") + "的商品数量不符合该商品的起订量和增量");
@@ -195,9 +195,18 @@ public class OrderItemsHelper extends BaseClass {
 
     String sa_orderitems = "sa_orderitems";
 
-    public InsertSQL getInsertSQL(JSONArray customproperties, long sa_orderitemsid, JSONObject item, Row itemRow, String type, BigDecimal defaultprice, BigDecimal price,BigDecimal saleprice, BigDecimal marketprice,String spec) throws YosException {
+    public InsertSQL getInsertSQL(JSONArray customproperties, long sa_orderitemsid, JSONObject item, Row itemRow, String type, BigDecimal defaultprice, BigDecimal price,BigDecimal saleprice, BigDecimal marketprice,String spec, Rows promotionitems) throws YosException {
         Long itemid = item.getLong("itemid");
         BigDecimal qty = item.getBigDecimalValue("qty");
+        RowsMap promotionitemsRowsMap = promotionitems.toRowsMap("sa_promotion_itemsid");
+        String signaturecode="";
+        if (type.equals("促销订单")) {
+            if (promotionitemsRowsMap.containsKey(item.getString("sa_promotion_itemsid"))) {
+                if (promotionitemsRowsMap.get(item.getString("sa_promotion_itemsid")).isNotEmpty()) {
+                    signaturecode = promotionitemsRowsMap.get(item.getString("sa_promotion_itemsid")).get(0).getString("signaturecode");
+                }
+            }
+        }
 
         InsertSQL insertSQL = SQLFactory.createInsertSQL(controller, sa_orderitems);
         insertSQL.setValue("customproperties", customproperties.toJSONString().replace("[", "").replace("]", "").replace("\"", ""));
@@ -206,7 +215,7 @@ public class OrderItemsHelper extends BaseClass {
         insertSQL.setValue("sa_orderid", content.getLongValue("sa_orderid"));
         insertSQL.setValue("rowno", 1);
         insertSQL.setValue("itemid", itemid);
-        insertSQL.setValue("remarks", item.getStringValue("remarks"));
+        insertSQL.setValue("remarks", item.getStringValue("remarks")+signaturecode);
         insertSQL.setValue("itemno", itemRow.getString("itemno"));
         insertSQL.setValue("itemname", itemRow.getString("itemname"));
         insertSQL.setValue("model", itemRow.getString("model"));
@@ -217,7 +226,7 @@ public class OrderItemsHelper extends BaseClass {
         insertSQL.setValue("position", item.getOrDefault("position", "null"));
         insertSQL.setValue("batchno", item.getOrDefault("batchno", "null"));
         insertSQL.setValue("spec",spec);
-
+        insertSQL.setValue("sa_promotion_itemsid",item.getLongValue("sa_promotion_itemsid"));
         String deliverydate = item.getStringValue("deliverydate");
         Rows rows = dbConnect.runSqlQuery("SELECT deliverydate,defaultprice from sa_orderitems WHERE sa_orderitemsid =" + sa_orderitemsid);
         if (deliverydate.isEmpty()) {
@@ -231,6 +240,7 @@ public class OrderItemsHelper extends BaseClass {
         insertSQL.setValue("needdate", needdate.equals("") ? "null" : needdate);
         insertSQL.setValue("deliverydate", deliverydate.equals("") ? "null" : deliverydate);
         BigDecimal conversionrate = itemRow.getBigDecimal("conversionrate");
+
         if (conversionrate.compareTo(BigDecimal.ZERO) <= 0) {
             conversionrate = BigDecimal.valueOf(1);
         }

+ 4 - 1
src/custom/restcontroller/webmanage/sale/order/SQL/促销方案商品列表.sql

@@ -11,7 +11,10 @@ SELECT t1.itemid,
        t3.orderminqty,
        t1.orderaddqty_auxunit,
        t3.orderaddqty,
+       t3.sa_promotion_itemsid,
+       t3.signaturecode,
        t3.groupqty,
+       t3.saledqty,
        t1.spec,
        t1.marketprice,
        (SELECT unitname FROM plm_unit WHERE unitid = t1.unitid and siteid = t1.siteid)    unit,
@@ -24,7 +27,7 @@ from plm_item t1
          LEFT JOIN plm_unitgroup t2 ON t2.unitgroupid = t1.unitgroupid and t2.siteid = t1.siteid
          LEFT JOIN sa_promotion_items t3 ON t3.itemid = t1.itemid and t3.siteid = t1.siteid
          LEFT JOIN sa_promotion_itemprice t5
-                   ON t5.itemid = t3.itemid and t5.siteid = t3.siteid and t5.sa_promotionid = t3.sa_promotionid
+                   ON t5.sa_promotion_itemsid = t3.sa_promotion_itemsid and t5.siteid = t3.siteid and t5.sa_promotionid = t3.sa_promotionid
          LEFT JOIN sys_enterprise t6 ON t6.grade = t5.pricegrade and t6.siteid = t5.siteid
 WHERE t1.siteid = $siteid$
   and t1.status = '审核'

+ 1 - 0
src/custom/restcontroller/webmanage/sale/order/SQL/订单商品明细_列表.sql

@@ -30,6 +30,7 @@ SELECT t1.sa_orderitemsid,
        t1.position,
        t1.batchno,
        t1.isfreeze,
+       t1.sa_promotion_itemsid,
        ifnull(t2.candispatchqty, 0)   candispatchqty,
        ifnull(t2.cansaleqty, 0)       cansaleqty,
        ifnull(t2.qty, 0)              totalaty,

+ 2 - 2
src/custom/restcontroller/webmanage/sale/order/SQL/订单商品明细_新增.sql

@@ -2,8 +2,8 @@ insert into sa_orderitems (sa_orderitemsid, siteid, createby, createdate, change
                            createuserid, itemid, rowno, batchcontrol, itemno, itemname, model, unit, auxunit,
                            isclose, conversionrate, price, amount, marketprice,
                            defaultprice, defaultamount, qty, auxqty, undeliqty, sa_orderid, remarks, stockno, position,
-                           batchno,customproperties)
+                           batchno,customproperties,sa_promotion_itemsid)
 values ($sa_orderitemsid$, $siteid$, $username$, current_time, $userid$, $username$, current_time, $userid$, $itemid$,
         $rowno$, $batchcontrol$, $itemno$, $itemname$, $model$, $unit$, $auxunit$, 0, $conversionrate$, $price$,
         $amount$, $marketprice$, $defaultprice$, $defaultamount$, $qty$, $auxqty$, $qty$, $sa_orderid$, $remarks$,
-        $stockno$, $position$, $batchno$,$customproperties$);
+        $stockno$, $position$, $batchno$,$customproperties$,$sa_promotion_itemsid$);

+ 2 - 2
src/custom/restcontroller/webmanage/sale/order/SQL/订单商品明细_更新.sql

@@ -11,7 +11,7 @@ set qty           = $qty$,
     remarks       = $remarks$,
     stockno       = $stockno$,
     position      = $position$,
-    batchno       = $batchno$
-
+    batchno       = $batchno$,
+    sa_promotion_itemsid=$sa_promotion_itemsid$
 where siteid = $siteid$
   and sa_orderitemsid = $sa_orderitemsid$

+ 17 - 5
src/custom/restcontroller/webmanage/sale/promotion/ExportExcel.java

@@ -113,6 +113,7 @@ public class ExportExcel {
         sheet.setColumnWidth((short) 6, (short) 5500);
         sheet.setColumnWidth((short) 7, (short) 5500);
         sheet.setColumnWidth((short) 8, (short) 5500);
+        sheet.setColumnWidth((short) 9, (short) 5500);
     }
 
 
@@ -132,6 +133,7 @@ public class ExportExcel {
         sheet.setColumnWidth((short) 7, (short) 5500);
         sheet.setColumnWidth((short) 8, (short) 5500);
         sheet.setColumnWidth((short) 9, (short) 5500);
+        sheet.setColumnWidth((short) 10, (short) 5500);
     }
 
     /**
@@ -159,7 +161,7 @@ public class ExportExcel {
         cellStyle2.setWrapText(true);
 
         /*第一行*/
-        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 8));
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));
 
         /*第一行塞值*/
         row = sheet.createRow(0);
@@ -167,7 +169,7 @@ public class ExportExcel {
         cell.setCellStyle(cellStyle4);
         cell.setCellValue("促销商品导入");
         /*第二行*/
-        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 8));
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));
         /*第二行塞值*/
         row = sheet.createRow(1);
         cell = row.createCell(0);// ID
@@ -212,7 +214,9 @@ public class ExportExcel {
         cell.setCellStyle(cellStyle2);
         cell.setCellValue("价格五活动价");
 
-
+        cell = row.createCell(9);
+        cell.setCellStyle(cellStyle2);
+        cell.setCellValue("特征码");
 
         /*第四行塞值*/
         row = sheet.createRow(3);
@@ -253,6 +257,10 @@ public class ExportExcel {
         cell.setCellStyle(cellStyle3);
         cell.setCellValue("0");
 
+        cell = row.createCell(9);
+        cell.setCellStyle(cellStyle3);
+        cell.setCellValue("特征码");
+
     }
 
 
@@ -281,7 +289,7 @@ public class ExportExcel {
 
 
         /*第一行*/
-        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));
+        sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 10));
 
         /*第一行塞值*/
         row = sheet.createRow(0);
@@ -289,7 +297,7 @@ public class ExportExcel {
         cell.setCellStyle(cellStyle3);
         cell.setCellValue("促销商品导入");
         /*第二行*/
-        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));
+        sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 10));
         /*第二行塞值*/
         row = sheet.createRow(1);
         cell = row.createCell(0);// ID
@@ -336,6 +344,10 @@ public class ExportExcel {
 
         cell = row.createCell(9);
         cell.setCellStyle(cellStyle2);
+        cell.setCellValue("特征码");
+
+        cell = row.createCell(10);
+        cell.setCellStyle(cellStyle2);
         cell.setCellValue("错误信息");
 
     }

+ 2 - 2
src/custom/restcontroller/webmanage/sale/promotion/SQL/促销方案商品新增.sql

@@ -1,2 +1,2 @@
-insert into sa_promotion_items (siteid, sa_promotion_itemsid,sa_promotionid,sa_promotion_itemgroupid,groupqty,itemid, orderaddqty,orderminqty,islimit)
-values ($siteid$, $sa_promotion_itemsid$,$sa_promotionid$,$sa_promotion_itemgroupid$, $groupqty$, $itemid$, $orderaddqty$, $orderminqty$, $islimit$);
+insert into sa_promotion_items (siteid, sa_promotion_itemsid,sa_promotionid,sa_promotion_itemgroupid,groupqty,itemid, orderaddqty,orderminqty,islimit,signaturecode)
+values ($siteid$, $sa_promotion_itemsid$,$sa_promotionid$,$sa_promotion_itemgroupid$, $groupqty$, $itemid$, $orderaddqty$, $orderminqty$, $islimit$,$signaturecode$);

+ 2 - 1
src/custom/restcontroller/webmanage/sale/promotion/SQL/促销方案商品更新.sql

@@ -5,5 +5,6 @@ SET
     orderaddqty= $orderaddqty$,
     orderminqty= $orderminqty$,
     islimit= $islimit$,
-    isonsale= $isonsale$
+    isonsale= $isonsale$,
+    signaturecode=$signaturecode$
 WHERE sa_promotion_itemsid = $sa_promotion_itemsid$ and siteid=$siteid$

+ 6 - 5
src/custom/restcontroller/webmanage/sale/promotion/SQL/促销方案商品查询.sql

@@ -5,6 +5,7 @@ SELECT t1.sa_promotion_itemsid,
        t1.orderaddqty,
        t1.orderminqty,
        t1.saledqty,
+       t1.signaturecode,
        t1.islimit,
        t1.isonsale,
        t1.itemid,
@@ -32,19 +33,19 @@ FROM sa_promotion_items t1
          left join plm_item t2 on t1.itemid = t2.itemid and t1.siteid = t2.siteid
          left join plm_unit t3 on t2.unitid = t3.unitid and t2.siteid = t3.siteid
          left join sa_promotion_itemprice t4
-                   on t1.sa_promotionid = t4.sa_promotionid and t1.itemid = t4.itemid and t1.siteid = t4.siteid and
+                   on t1.sa_promotionid = t4.sa_promotionid and t1.sa_promotion_itemsid = t4.sa_promotion_itemsid and t1.siteid = t4.siteid and
                       t4.pricegrade = 1
          left join sa_promotion_itemprice t5
-                   on t1.sa_promotionid = t5.sa_promotionid and t1.itemid = t5.itemid and t1.siteid = t5.siteid and
+                   on t1.sa_promotionid = t5.sa_promotionid and t1.sa_promotion_itemsid = t5.sa_promotion_itemsid and t1.siteid = t5.siteid and
                       t5.pricegrade = 2
          left join sa_promotion_itemprice t6
-                   on t1.sa_promotionid = t6.sa_promotionid and t1.itemid = t6.itemid and t1.siteid = t6.siteid and
+                   on t1.sa_promotionid = t6.sa_promotionid and t1.sa_promotion_itemsid = t6.sa_promotion_itemsid and t1.siteid = t6.siteid and
                       t6.pricegrade = 3
          left join sa_promotion_itemprice t7
-                   on t1.sa_promotionid = t7.sa_promotionid and t1.itemid = t7.itemid and t1.siteid = t7.siteid and
+                   on t1.sa_promotionid = t7.sa_promotionid and t1.sa_promotion_itemsid = t7.sa_promotion_itemsid and t1.siteid = t7.siteid and
                       t7.pricegrade = 4
          left join sa_promotion_itemprice t8
-                   on t1.sa_promotionid = t8.sa_promotionid and t1.itemid = t8.itemid and t1.siteid = t8.siteid and
+                   on t1.sa_promotionid = t8.sa_promotionid and t1.sa_promotion_itemsid = t8.sa_promotion_itemsid and t1.siteid = t8.siteid and
                       t8.pricegrade = 5
 where t1.siteid = $siteid$
   and t1.sa_promotionid = $sa_promotionid$

+ 1 - 1
src/custom/restcontroller/webmanage/sale/promotion/SQL/商品查询.sql

@@ -12,7 +12,7 @@ SELECT
 FROM
 	plm_item t1
 	 LEFT JOIN plm_unit t2 ON t2.unitid = t1.unitid AND t2.siteid = t1.siteid
-	where $where$ and t1.siteid=$siteid$ and t1.status='审核' and t1.itemid not in (select itemid from sa_promotion_items where sa_promotionid=$sa_promotionid$)
+	where $where$ and t1.siteid=$siteid$ and t1.status='审核'
 	  and t1.itemid in (SELECT itemid
                     from plm_item_tradefield
                     WHERE ($where1$)

+ 14 - 6
src/custom/restcontroller/webmanage/sale/promotion/promotionItems.java

@@ -158,6 +158,7 @@ public class promotionItems extends Controller {
                     saleFactory.addParameter("orderminqty", 1);
                 }
                 saleFactory.addParameter("islimit", iteminfo.getLong("islimit"));
+                saleFactory.addParameter("signaturecode", iteminfo.getStringValue("signaturecode"));
                 sqlList.add(saleFactory.getSQL());
                 Rows rows = itempricerowsMap.get(iteminfo.getLong("itemid"));
                 if (!rows.isEmpty()) {
@@ -187,6 +188,7 @@ public class promotionItems extends Controller {
                 saleFactory.addParameter("orderminqty", iteminfo.getBigDecimal("orderminqty"));
                 saleFactory.addParameter("islimit", iteminfo.getLong("islimit"));
                 saleFactory.addParameter("isonsale", iteminfo.getBooleanValue("isonsale"));
+                saleFactory.addParameter("signaturecode", iteminfo.getStringValue("signaturecode"));
                 sqlList.add(saleFactory.getSQL());
             }
 
@@ -272,28 +274,28 @@ public class promotionItems extends Controller {
         querySQL.addJoinTable(JOINTYPE.left, "plm_item", "t2", "t1.itemid = t2.itemid and t1.siteid = t2.siteid",
                 "itemno", "itemname","spec","model");
         querySQL.addJoinTable(JOINTYPE.left, "plm_unit", "t3", "t2.unitid = t3.unitid and t2.siteid = t3.siteid", "unitname");
-        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t4", "t1.sa_promotion_itemsid = t4.sa_promotion_itemsid and t1.itemid = t4.itemid and t1.siteid = t4.siteid and t4.pricegrade = 1");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t4", "t1.sa_promotion_itemsid = t4.sa_promotion_itemsid and t1.sa_promotion_itemsid = t4.sa_promotion_itemsid and t1.siteid = t4.siteid and t4.pricegrade = 1");
         querySQL.addQueryFields("oldprice1", "ifnull(t4.oldprice, 0)");
         querySQL.addQueryFields("price1", "ifnull(t4.price, 0)");
         querySQL.addQueryFields("sa_promotion_itempriceid1", "ifnull(t4.sa_promotion_itempriceid, 0)");
 
-        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t5", "t1.sa_promotion_itemsid = t5.sa_promotion_itemsid and t1.itemid = t5.itemid and t1.siteid = t5.siteid and t5.pricegrade = 2");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t5", "t1.sa_promotion_itemsid = t5.sa_promotion_itemsid and t1.sa_promotion_itemsid = t5.sa_promotion_itemsid and t1.siteid = t5.siteid and t5.pricegrade = 2");
         querySQL.addQueryFields("oldprice2", "ifnull(t5.oldprice, 0)");
         querySQL.addQueryFields("price2", "ifnull(t5.price, 0)");
         querySQL.addQueryFields("sa_promotion_itempriceid2", "ifnull(t5.sa_promotion_itempriceid, 0)");
 
 
-        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t6", "t1.sa_promotion_itemsid = t6.sa_promotion_itemsid and t1.itemid = t6.itemid and t1.siteid = t6.siteid and t6.pricegrade = 3");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t6", "t1.sa_promotion_itemsid = t6.sa_promotion_itemsid and t1.sa_promotion_itemsid = t6.sa_promotion_itemsid and t1.siteid = t6.siteid and t6.pricegrade = 3");
         querySQL.addQueryFields("oldprice3", "ifnull(t6.oldprice, 0)");
         querySQL.addQueryFields("price3", "ifnull(t6.price, 0)");
         querySQL.addQueryFields("sa_promotion_itempriceid3", "ifnull(t6.sa_promotion_itempriceid, 0)");
 
-        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t7", "t1.sa_promotion_itemsid = t7.sa_promotion_itemsid and t1.itemid = t7.itemid and t1.siteid = t7.siteid and t7.pricegrade = 4");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t7", "t1.sa_promotion_itemsid = t7.sa_promotion_itemsid and t1.sa_promotion_itemsid = t7.sa_promotion_itemsid and t1.siteid = t7.siteid and t7.pricegrade = 4");
         querySQL.addQueryFields("oldprice4", "ifnull(t7.oldprice, 0)");
         querySQL.addQueryFields("price4", "ifnull(t7.price, 0)");
         querySQL.addQueryFields("sa_promotion_itempriceid4", "ifnull(t7.sa_promotion_itempriceid, 0)");
 
-        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t8", "t1.sa_promotion_itemsid = t8.sa_promotion_itemsid and t1.itemid = t8.itemid and t1.siteid = t8.siteid and t8.pricegrade = 5");
+        querySQL.addJoinTable(JOINTYPE.left, "sa_promotion_itemprice", "t8", "t1.sa_promotion_itemsid = t8.sa_promotion_itemsid and t1.sa_promotion_itemsid = t8.sa_promotion_itemsid and t1.siteid = t8.siteid and t8.pricegrade = 5");
         querySQL.addQueryFields("oldprice5", "ifnull(t8.oldprice, 0)");
         querySQL.addQueryFields("price5", "ifnull(t8.price, 0)");
         querySQL.addQueryFields("sa_promotion_itempriceid5", "ifnull(t8.sa_promotion_itempriceid, 0)");
@@ -394,6 +396,7 @@ public class promotionItems extends Controller {
             keys.add("price3");
             keys.add("price4");
             keys.add("price5");
+            keys.add("signaturecode");
 
             int i = 0;
             int a = 0;
@@ -418,6 +421,7 @@ public class promotionItems extends Controller {
                 String price3 = row.getString("price3");
                 String price4 = row.getString("price4");
                 String price5 = row.getString("price5");
+                String signaturecode = row.getString("signaturecode");
                 if (StringUtils.isEmpty(itemno)) {
                     iserr = true;
                     row.put("msg", "产品编码不能为空");
@@ -484,6 +488,7 @@ public class promotionItems extends Controller {
                 map.put("price3", "价格三活动价");
                 map.put("price4", "价格四活动价");
                 map.put("price5", "价格五活动价");
+                map.put("signaturecode", "特征码");
                 map.put("msg", "错误信息");
                 ArrayList<String> colNameList = new ArrayList<String>();
                 HashMap<String, Class> keytypemap = new HashMap<String, Class>();
@@ -496,6 +501,7 @@ public class promotionItems extends Controller {
                 colNameList.add("price3");
                 colNameList.add("price4");
                 colNameList.add("price5");
+                colNameList.add("signaturecode");
                 colNameList.add("msg");
                 keytypemap.put("itemno", String.class);
                 keytypemap.put("orderminqty", String.class);
@@ -506,6 +512,7 @@ public class promotionItems extends Controller {
                 keytypemap.put("price3", String.class);
                 keytypemap.put("price4", String.class);
                 keytypemap.put("price5", String.class);
+                keytypemap.put("signaturecode", String.class);
                 keytypemap.put("msg", String.class);
                 rowserr.setFieldList(colNameList);
                 rowserr.setFieldTypeMap(keytypemap);
@@ -533,6 +540,7 @@ public class promotionItems extends Controller {
                     sqlFactory.addParameter("orderaddqty", row.getString("orderaddqty"));
                     sqlFactory.addParameter("orderminqty", row.getString("orderminqty"));
                     sqlFactory.addParameter("islimit", row.getString("islimit"));
+                    sqlFactory.addParameter("signaturecode", row.getString("signaturecode"));
                     sqllist.add(sqlFactory.getSQL());
                     for (int o = 1; o <= 5; o++) {
                         long sa_promotion_itempriceid = sa_promotion_itempriceids[a];
@@ -598,7 +606,7 @@ public class promotionItems extends Controller {
                 } else {
                     datarow.createCell(i1).setCellValue(row.getString((String) keylist.get(i1)));
                 }
-                if (i1 == 9) {
+                if (i1 == 10) {
                     datarow.getCell(i1).setCellStyle(xssfCellStyle1);
                 }
             }