zhijiezhao il y a 1 an
Parent
commit
4a8aebf032

+ 4 - 371
src/main/java/com/caimei/modules/order/entity/ShopOrderVo.java

@@ -1,6 +1,8 @@
 package com.caimei.modules.order.entity;
 
 
+import lombok.Data;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.util.List;
@@ -11,9 +13,11 @@ import java.util.List;
  * @author : Charles
  * @date : 2021/7/20
  */
+@Data
 public class ShopOrderVo implements Serializable {
     private static final long serialVersionUID = 1L;
 
+    private Double couponAmount;
     private Integer organizeId;
     /**
      * 子订单ID
@@ -196,375 +200,4 @@ public class ShopOrderVo implements Serializable {
      */
     private String splitCode;
 
-    public Integer getOrganizeId() {
-        return organizeId;
-    }
-
-    public void setOrganizeId(Integer organizeId) {
-        this.organizeId = organizeId;
-    }
-
-    public String getSplitCode() {
-        return splitCode;
-    }
-
-    public void setSplitCode(String splitCode) {
-        this.splitCode = splitCode;
-    }
-
-    public static long getSerialVersionUID() {
-        return serialVersionUID;
-    }
-
-    public Integer getShopOrderId() {
-        return shopOrderId;
-    }
-
-    public void setShopOrderId(Integer shopOrderId) {
-        this.shopOrderId = shopOrderId;
-    }
-
-    public String getShopOrderNo() {
-        return shopOrderNo;
-    }
-
-    public void setShopOrderNo(String shopOrderNo) {
-        this.shopOrderNo = shopOrderNo;
-    }
-
-    public Integer getOrderId() {
-        return orderId;
-    }
-
-    public void setOrderId(Integer orderId) {
-        this.orderId = orderId;
-    }
-
-    public String getOrderNo() {
-        return orderNo;
-    }
-
-    public void setOrderNo(String orderNo) {
-        this.orderNo = orderNo;
-    }
-
-    public Integer getShopId() {
-        return shopId;
-    }
-
-    public void setShopId(Integer shopId) {
-        this.shopId = shopId;
-    }
-
-    public String getShopName() {
-        return shopName;
-    }
-
-    public void setShopName(String shopName) {
-        this.shopName = shopName;
-    }
-
-    public String getShopLogo() {
-        return shopLogo;
-    }
-
-    public void setShopLogo(String shopLogo) {
-        this.shopLogo = shopLogo;
-    }
-
-    public String getNote() {
-        return note;
-    }
-
-    public void setNote(String note) {
-        this.note = note;
-    }
-
-    public Integer getUserId() {
-        return userId;
-    }
-
-    public void setUserId(Integer userId) {
-        this.userId = userId;
-    }
-
-    public Integer getClubId() {
-        return clubId;
-    }
-
-    public void setClubId(Integer clubId) {
-        this.clubId = clubId;
-    }
-
-    public Integer getSpId() {
-        return spId;
-    }
-
-    public void setSpId(Integer spId) {
-        this.spId = spId;
-    }
-
-    public Integer getOrderPromotionsId() {
-        return orderPromotionsId;
-    }
-
-    public void setOrderPromotionsId(Integer orderPromotionsId) {
-        this.orderPromotionsId = orderPromotionsId;
-    }
-
-    public Double getPromotionFullReduction() {
-        return promotionFullReduction;
-    }
-
-    public void setPromotionFullReduction(Double promotionFullReduction) {
-        this.promotionFullReduction = promotionFullReduction;
-    }
-
-    public Double getSvipShopReduction() {
-        return svipShopReduction;
-    }
-
-    public void setSvipShopReduction(Double svipShopReduction) {
-        this.svipShopReduction = svipShopReduction;
-    }
-
-    public Integer getPayStatus() {
-        return payStatus;
-    }
-
-    public void setPayStatus(Integer payStatus) {
-        this.payStatus = payStatus;
-    }
-
-    public Double getPayedShopAmount() {
-        return payedShopAmount;
-    }
-
-    public void setPayedShopAmount(Double payedShopAmount) {
-        this.payedShopAmount = payedShopAmount;
-    }
-
-    public Double getBrokerage() {
-        return brokerage;
-    }
-
-    public void setBrokerage(Double brokerage) {
-        this.brokerage = brokerage;
-    }
-
-    public Double getCanRefundAmount() {
-        return canRefundAmount;
-    }
-
-    public void setCanRefundAmount(Double canRefundAmount) {
-        this.canRefundAmount = canRefundAmount;
-    }
-
-    public Integer getItemCount() {
-        return itemCount;
-    }
-
-    public void setItemCount(Integer itemCount) {
-        this.itemCount = itemCount;
-    }
-
-    public Double getTotalAmount() {
-        return totalAmount;
-    }
-
-    public void setTotalAmount(Double totalAmount) {
-        this.totalAmount = totalAmount;
-    }
-
-    public Double getProductAmount() {
-        return productAmount;
-    }
-
-    public void setProductAmount(Double productAmount) {
-        this.productAmount = productAmount;
-    }
-
-    public Double getNeedPayAmount() {
-        return needPayAmount;
-    }
-
-    public void setNeedPayAmount(Double needPayAmount) {
-        this.needPayAmount = needPayAmount;
-    }
-
-    public Double getShopProductAmount() {
-        return shopProductAmount;
-    }
-
-    public void setShopProductAmount(Double shopProductAmount) {
-        this.shopProductAmount = shopProductAmount;
-    }
-
-    public Double getShopPostFee() {
-        return shopPostFee;
-    }
-
-    public void setShopPostFee(Double shopPostFee) {
-        this.shopPostFee = shopPostFee;
-    }
-
-    public Double getShopTaxFee() {
-        return shopTaxFee;
-    }
-
-    public void setShopTaxFee(Double shopTaxFee) {
-        this.shopTaxFee = shopTaxFee;
-    }
-
-    public Double getShouldPayShopAmount() {
-        return shouldPayShopAmount;
-    }
-
-    public void setShouldPayShopAmount(Double shouldPayShopAmount) {
-        this.shouldPayShopAmount = shouldPayShopAmount;
-    }
-
-    public Integer getOutStoreNum() {
-        return outStoreNum;
-    }
-
-    public void setOutStoreNum(Integer outStoreNum) {
-        this.outStoreNum = outStoreNum;
-    }
-
-    public Integer getOutStoreTimes() {
-        return outStoreTimes;
-    }
-
-    public void setOutStoreTimes(Integer outStoreTimes) {
-        this.outStoreTimes = outStoreTimes;
-    }
-
-    public Integer getSendOutStatus() {
-        return sendOutStatus;
-    }
-
-    public void setSendOutStatus(Integer sendOutStatus) {
-        this.sendOutStatus = sendOutStatus;
-    }
-
-    public Integer getPresentNum() {
-        return presentNum;
-    }
-
-    public void setPresentNum(Integer presentNum) {
-        this.presentNum = presentNum;
-    }
-
-    public String getOrderTime() {
-        return orderTime;
-    }
-
-    public void setOrderTime(String orderTime) {
-        this.orderTime = orderTime;
-    }
-
-    public Integer getOrderSubmitType() {
-        return orderSubmitType;
-    }
-
-    public void setOrderSubmitType(Integer orderSubmitType) {
-        this.orderSubmitType = orderSubmitType;
-    }
-
-    public Integer getSplitFlag() {
-        return splitFlag;
-    }
-
-    public void setSplitFlag(Integer splitFlag) {
-        this.splitFlag = splitFlag;
-    }
-
-    public Double getShopOtherFee() {
-        return shopOtherFee;
-    }
-
-    public void setShopOtherFee(Double shopOtherFee) {
-        this.shopOtherFee = shopOtherFee;
-    }
-
-    public PromotionsVo getShopPromotion() {
-        return shopPromotion;
-    }
-
-    public void setShopPromotion(PromotionsVo shopPromotion) {
-        this.shopPromotion = shopPromotion;
-    }
-
-    public List<OrderProductVo> getOrderProductList() {
-        return orderProductList;
-    }
-
-    public void setOrderProductList(List<OrderProductVo> orderProductList) {
-        this.orderProductList = orderProductList;
-    }
-
-    public List<LogisticsRecordVo> getLogisticsRecordList() {
-        return logisticsRecordList;
-    }
-
-    public void setLogisticsRecordList(List<LogisticsRecordVo> logisticsRecordList) {
-        this.logisticsRecordList = logisticsRecordList;
-    }
-
-    public OrderUserinfoVo getUserInfo() {
-        return userInfo;
-    }
-
-    public void setUserInfo(OrderUserinfoVo userInfo) {
-        this.userInfo = userInfo;
-    }
-
-    public Integer getReceiptStatus() {
-        return receiptStatus;
-    }
-
-    public void setReceiptStatus(Integer receiptStatus) {
-        this.receiptStatus = receiptStatus;
-    }
-
-    public BigDecimal getShopRefundAmount() {
-        return shopRefundAmount;
-    }
-
-    public void setShopRefundAmount(BigDecimal shopRefundAmount) {
-        this.shopRefundAmount = shopRefundAmount;
-    }
-
-    public String getHaveReturning() {
-        return haveReturning;
-    }
-
-    public void setHaveReturning(String haveReturning) {
-        this.haveReturning = haveReturning;
-    }
-
-    public Integer getReceiptedFlag() {
-        return receiptedFlag;
-    }
-
-    public void setReceiptedFlag(Integer receiptedFlag) {
-        this.receiptedFlag = receiptedFlag;
-    }
-
-    public Integer getReceiptedType() {
-        return receiptedType;
-    }
-
-    public void setReceiptedType(Integer receiptedType) {
-        this.receiptedType = receiptedType;
-    }
-
-    public OrderVo getMainOrder() {
-        return mainOrder;
-    }
-
-    public void setMainOrder(OrderVo mainOrder) {
-        this.mainOrder = mainOrder;
-    }
 }

+ 6 - 0
src/main/java/com/caimei/modules/order/service/SplitAccountService.java

@@ -65,6 +65,12 @@ public class SplitAccountService extends BaseService {
                 logger.info("【分账】>>>>>>>>>>子订单id:" + orderRelation.getShopOrderId() + "进入分账");
                 setSplitAccountDetail(costPrice, organizeCostPrice, cmCostPrice, total, shopOrder, orderRelation);
             }
+            /** todo
+             *  当前版本优惠券和促销活动为商家承担
+             */
+            if (shopOrder.getCouponAmount() > 0 || shopOrder.getPromotionFullReduction() > 0) {
+                costPrice.set(MathUtil.sub(costPrice, MathUtil.add(shopOrder.getCouponAmount(), shopOrder.getPromotionFullReduction())).doubleValue());
+            }
             if (MathUtil.compare(total, MathUtil.add(MathUtil.add(costPrice, cmCostPrice), organizeCostPrice)) <= 0) {
                 logger.info("收款总金额不足分帐------------->total: " + total.get()
                         + "costPrice: " + costPrice.get() + "----------"

+ 0 - 8
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -59,14 +59,6 @@ public interface ProductDao extends CrudDao<Product> {
      */
      List<GiftProduct> getGiftProductInfo(GiftProduct giftProduct);
 
-    /**
-     * 后去商品购买库存
-     *
-     * @param productId
-     * @return
-     */
-     Sku getProductSku(@Param("productId") Integer productId);
-
     /**
      * 更新赠送
      *

+ 1 - 1
src/main/java/com/caimei/modules/product/service/CmPromotionService.java

@@ -202,7 +202,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
          */
         if ("1".equals(product.getPromotionType())) {
             // 单品满赠
-            if (3 == product.getPromotionMode()) {
+            if (null != product.getPromotionMode() && 3 == product.getPromotionMode()) {
                 product.setShopID(cmPromotionDao.findShopId(product.getProductID()));
                 product.setProductID(null);
             }

+ 0 - 4
src/main/java/com/caimei/modules/product/service/ProductService.java

@@ -97,10 +97,6 @@ public class ProductService extends CrudService<ProductDao, Product> {
         return productDao.getGiftProductInfo(giftProduct);
     }
 
-    public Sku getProductSku(Integer productId) {
-        return productDao.getProductSku(productId);
-    }
-
     /**
      * 更新赠送
      *

+ 29 - 29
src/main/java/com/caimei/modules/product/web/CmPromotionController.java

@@ -7,9 +7,7 @@ import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
 import com.caimei.modules.opensearch.CoreServiceUitls;
 import com.caimei.modules.opensearch.GenerateUtils;
 import com.caimei.modules.product.dao.CmPromotionDao;
-import com.caimei.modules.product.entity.CmPromotion;
-import com.caimei.modules.product.entity.Product;
-import com.caimei.modules.product.entity.Shop;
+import com.caimei.modules.product.entity.*;
 import com.caimei.modules.product.service.CmPromotionService;
 import com.caimei.modules.product.service.ProductService;
 import com.caimei.redis.RedisService;
@@ -122,10 +120,10 @@ public class CmPromotionController extends BaseController {
 
     @RequestMapping(value = "delPromotion")
     @ResponseBody
-    public Map<String, Object> delPromotion(@RequestParam("id") String id,@RequestParam("skuId")Integer skuId, HttpServletRequest request) {
+    public Map<String, Object> delPromotion(@RequestParam("id") String id, @RequestParam("skuId") Integer skuId, HttpServletRequest request) {
         Map<String, Object> map = new HashMap<>();
         try {
-            cmPromotionService.delPromotion(id,skuId);
+            cmPromotionService.delPromotion(id, skuId);
             map.put("success", "true");
             map.put("msg", "删除成功");
         } catch (Exception e) {
@@ -142,11 +140,11 @@ public class CmPromotionController extends BaseController {
     @RequestMapping(value = "form")
     public String form(CmPromotion cmPromotion, Model model) {
         if (cmPromotion != null) {
-            if("1".equals(cmPromotion.getType())&&"1".equals(cmPromotion.getMode())){
-                if(StringUtils.isNotBlank(cmPromotion.getId())){
+            if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())) {
+                if (StringUtils.isNotBlank(cmPromotion.getId())) {
                     //单品优惠价的时候给优惠商品的skus赋值
                     cmPromotion.setSkus(cmPromotionDao.getPromotionSkus(cmPromotion.getId()));
-                }else{
+                } else {
                     //新增单品促销的时候没有id
                     cmPromotion.setSkus(cmPromotionDao.getPromotionSkusByProduct(cmPromotion.getProductIds()));
                 }
@@ -185,20 +183,11 @@ public class CmPromotionController extends BaseController {
                     String[] split = cmPromotion.getProductIds().split(",");
                     for (String productId : split) {
                         if (StringUtil.isNotBlank(productId)) {
-                            if(StringUtils.isNotBlank(cmPromotion.getType()) && "2".equals(cmPromotion.getType())){
-                                //凑单促销的时候取的是skuId
-                                productId=productService.getProductIdBySku(productId);
-                            }
                             Product product = productService.get(productId);
                             promotionProducts.add(product);
                         }
                     }
                 } else {
-                    if(StringUtils.isNotBlank(cmPromotion.getType()) && "2".equals(cmPromotion.getType())){
-                        //凑单促销的时候取的是skuId
-                       String productId=productService.getProductIdBySku(cmPromotion.getProductIds());
-                        cmPromotion.setProductIds(productId);
-                    }
                     Product product = productService.get(cmPromotion.getProductIds());
                     promotionProducts.add(product);
                 }
@@ -209,13 +198,29 @@ public class CmPromotionController extends BaseController {
                     String[] split = cmPromotion.getGiftIds().split(",");
                     for (String skuId : split) {
                         if (StringUtil.isNotBlank(skuId)) {
-                            Product product = productService.getBySku(skuId);
-                            giftProducts.add(product);
+                            if ("1".equals(cmPromotion.getType()) && "3".equals(cmPromotion.getMode())) {
+                                List<CmSku> skuList = productService.findSkuList(Integer.valueOf(skuId));
+                                Product product = productService.get(skuId);
+                                product.setSkuId(skuList.get(0).getSkuId());
+                                product.setUnit(skuList.get(0).getUnit());
+                                giftProducts.add(product);
+                            } else {
+                                Product product = productService.getBySku(skuId);
+                                giftProducts.add(product);
+                            }
                         }
                     }
                 } else {
-                    Product product = productService.getBySku(cmPromotion.getGiftIds());
-                    giftProducts.add(product);
+                    if ("1".equals(cmPromotion.getType()) && "3".equals(cmPromotion.getMode())) {
+                        Product product = productService.get(cmPromotion.getGiftIds());
+                        List<CmSku> skuList = productService.findSkuList(Integer.valueOf(cmPromotion.getGiftIds()));
+                        product.setSkuId(skuList.get(0).getSkuId());
+                        product.setUnit(skuList.get(0).getUnit());
+                        giftProducts.add(product);
+                    } else {
+                        Product product = productService.getBySku(cmPromotion.getGiftIds());
+                        giftProducts.add(product);
+                    }
                 }
             }
             if (StringUtil.isNotBlank(cmPromotion.getShopIds())) {
@@ -337,11 +342,6 @@ public class CmPromotionController extends BaseController {
             cmPromotion.setGiftProducts(giftProducts);
             cmPromotion.setPromotionShops(promotionShops);
             model.addAttribute("cmPromotion", cmPromotion);
-            if (cmPromotion.getPromotionProducts().size() > 0) {
-                model.addAttribute("price1", cmPromotion.getPromotionProducts().get(0).getPrice());
-            } else {
-                model.addAttribute("price1", 0);
-            }
             if ("1".equals(cmPromotion.getType())) {
                 return "modules/product-new/singlePromotionForm";
             } else if ("2".equals(cmPromotion.getType())) {
@@ -352,7 +352,6 @@ public class CmPromotionController extends BaseController {
         } else {
             return null;
         }
-
     }
 
     /**
@@ -405,6 +404,7 @@ public class CmPromotionController extends BaseController {
         cleanRedisCache();
         return map;
     }
+
     //更新促销索引
     private void updateIndex(CmPromotion cmPromotion) {
         List<Integer> productIdsByPromotion = new ArrayList<>();
@@ -415,8 +415,8 @@ public class CmPromotionController extends BaseController {
             productIdByPromotion = cmPromotionDao.findProductIdByPromotion(cmPromotion.getId());
         }
         // 更新索引
-        productIdsByPromotion.forEach(p->coreServiceUitls.updateProductIndex(p));
-        productIdByPromotion.forEach(p->coreServiceUitls.updateProductIndex(p));
+        productIdsByPromotion.forEach(p -> coreServiceUitls.updateProductIndex(p));
+        productIdByPromotion.forEach(p -> coreServiceUitls.updateProductIndex(p));
     }
 
     /**

+ 0 - 5
src/main/java/com/caimei/modules/product/web/ProductController.java

@@ -269,12 +269,7 @@ public class ProductController extends BaseController{
                     if(null != productInfo){
                         gp.setProductImage(AppUtils.getImageURL("product", productInfo.getMainImage(), 0,""));
                         gp.setProductCode(productInfo.getProductCode());
-                        //获取购买最大库存
-                        Sku productSku = productService.getProductSku(gp.getGiftProductId());
                         Integer sku = 0;//默认库存
-                        if(null != productSku){
-                            sku = productSku.getStock();
-                        }
                         gp.setProductSku(sku);
                     }
                 }

+ 3 - 1
src/main/resources/mappings/modules/order/OrderMapper.xml

@@ -1166,7 +1166,9 @@
                sendOutStatus,
                splitFlag,
                splitCode,
-               organizeId
+               organizeId,
+               ifnull(promotionFullReduction,0) as promotionFullReduction,
+               ifnull(couponAmount,0) as couponAmount
         FROM cm_shop_order
         WHERE delFlag = 0
           AND shopOrderID = #{shopOrderId}

+ 1 - 1
src/main/resources/mappings/modules/product/CmPromotionMapper.xml

@@ -491,7 +491,7 @@
     </select>
 
     <select id="findShopId" resultType="java.lang.Integer">
-        select shopId from prodduct where productId = #{productID}
+        select shopId from product where productId = #{productID}
     </select>
 
     <delete id="deletePromotion">

+ 232 - 213
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -99,10 +99,13 @@
     <sql id="ActivityJoins">
         LEFT JOIN shop s on s.shopID = a.shopID
     </sql>
-    <insert id="insertMallProduct" keyColumn="id" keyProperty="id" useGeneratedKeys="true" parameterType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
-        INSERT INTO cm_mall_organize_products (organizeID, productID, shopId, normalPrice, costPrice, ladderPriceFlag, minBuyNumber,
+    <insert id="insertMallProduct" keyColumn="id" keyProperty="id" useGeneratedKeys="true"
+            parameterType="com.caimei.modules.weisha.entity.CmOrganizeProduct">
+        INSERT INTO cm_mall_organize_products (organizeID, productID, shopId, normalPrice, costPrice, ladderPriceFlag,
+                                               minBuyNumber,
                                                validFlag, addTime, updateTime, delFlag)
-        VALUES (#{organizeId}, #{productId}, #{shopId}, #{normalPrice}, #{costPrice}, #{ladderPriceFlag}, #{minBuyNumber},
+        VALUES (#{organizeId}, #{productId}, #{shopId}, #{normalPrice}, #{costPrice}, #{ladderPriceFlag},
+                #{minBuyNumber},
                 #{validFlag}, #{addTime}, #{updateTime}, #{delFlag})
     </insert>
     <update id="saveSort">
@@ -123,8 +126,10 @@
     <select id="get" resultType="Product">
         SELECT
         <include refid="productColumns"/>,
-        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 0 ) as costCheckFlag,
-        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 4 ) as mallCostCheckFlag
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 0 ) as
+        costCheckFlag,
+        (select costCheckFlag from cm_organize_product_info where productId = #{id} and organizeId = 4 ) as
+        mallCostCheckFlag
         FROM product a
         <include refid="productJoins"/>
         WHERE a.productID = #{id}
@@ -356,7 +361,7 @@
         bigTypeID,
         smallTypeID,
         tinyTypeID,
---         selfTypeID,
+        -- selfTypeID,
         shopID,
         aliasName,
         name,
@@ -368,28 +373,28 @@
         propertiesInfo,
         addTime,
         updateTime,
---         weekSellNumber,
+        -- weekSellNumber,
         beforeValidFlag,
         validFlag,
         favoriteTimes,
         commentScore,
         commentTimes,
---         selfRecommendFlag,
---         sysRecommendFlag,
+        -- selfRecommendFlag,
+        -- sysRecommendFlag,
         sortIndex,
         featuredFlag,
         featuredSortIndex,
         productCode,
---         synToERPFlag,
+        -- synToERPFlag,
         allAreaFlag,
         provinceIDs,
         serviceNumber,
         packageCount,
         byFlag,
         normalProductFlag,
---         wholeSaleProductFlag,
---         promotionProductFlag,
---         groupBuyProductFlag,
+        -- wholeSaleProductFlag,
+        -- promotionProductFlag,
+        -- groupBuyProductFlag,
         step,
         actFlag,
         actType,
@@ -397,7 +402,7 @@
         onlineTime,
         downlineTime,
         freePostFlag,
---         precisehKey,
+        -- precisehKey,
         visibility,
         commodityDetailsFlag,
         productType,
@@ -436,7 +441,7 @@
         #{bigTypeID},
         #{smallTypeID},
         #{tinyTypeID},
---         #{selfTypeID},
+        -- #{selfTypeID},
         #{shopID},
         #{aliasName},
         #{name},
@@ -448,28 +453,28 @@
         #{propertiesInfo},
         #{addTime},
         #{updateTime},
---         #{weekSellNumber},
+        -- #{weekSellNumber},
         #{beforeValidFlag},
         #{validFlag},
         #{favoriteTimes},
         #{commentScore},
         #{commentTimes},
---         #{selfRecommendFlag},
---         #{sysRecommendFlag},
+        -- #{selfRecommendFlag},
+        -- #{sysRecommendFlag},
         #{sortIndex},
         #{featuredFlag},
         #{featuredSortIndex},
         #{productCode},
---         #{synToERPFlag},
+        -- #{synToERPFlag},
         #{allAreaFlag},
         #{provinceIDs},
         #{serviceNumber},
         #{packageCount},
         #{byFlag},
         #{normalProductFlag},
---         #{wholeSaleProductFlag},
---         #{promotionProductFlag},
---         #{groupBuyProductFlag},
+        -- #{wholeSaleProductFlag},
+        -- #{promotionProductFlag},
+        -- #{groupBuyProductFlag},
         #{step},
         #{actFlag},
         #{actType},
@@ -477,7 +482,7 @@
         #{onlineTime},
         #{downlineTime},
         #{freePostFlag},
---         #{precisehKey},
+        -- #{precisehKey},
         #{visibility},
         #{commodityDetailsFlag},
         #{productType},
@@ -515,51 +520,51 @@
 
     <update id="update">
         UPDATE product
-        SET productID            = #{id},
-            brandID              = #{brandID},
-            tinyTypeID           = #{tinyTypeID},
+        SET productID         = #{id},
+            brandID           = #{brandID},
+            tinyTypeID        = #{tinyTypeID},
 --             selfTypeID           = #{selfTypeID},
-            shopID               = #{shopID},
-            name                 = #{name},
-            searchKey            = #{searchKey},
-            priceFlag            = #{priceFlag},
-            beautyActFlag        = #{beautyActFlag},
-            hasSkuFlag           = #{hasSkuFlag},
-            mainImage            = #{mainImage},
-            propertiesInfo       = #{propertiesInfo},
-            addTime              = #{addTime},
-            updateTime           = #{updateTime},
-            sellNumber           = #{sellNumber},
+            shopID            = #{shopID},
+            name              = #{name},
+            searchKey         = #{searchKey},
+            priceFlag         = #{priceFlag},
+            beautyActFlag     = #{beautyActFlag},
+            hasSkuFlag        = #{hasSkuFlag},
+            mainImage         = #{mainImage},
+            propertiesInfo    = #{propertiesInfo},
+            addTime           = #{addTime},
+            updateTime        = #{updateTime},
+            sellNumber        = #{sellNumber},
 --             weekSellNumber       = #{weekSellNumber},
-            beforeValidFlag      = #{beforeValidFlag},
-            validFlag            = #{validFlag},
-            favoriteTimes        = #{favoriteTimes},
-            commentScore         = #{commentScore},
-            commentTimes         = #{commentTimes},
+            beforeValidFlag   = #{beforeValidFlag},
+            validFlag         = #{validFlag},
+            favoriteTimes     = #{favoriteTimes},
+            commentScore      = #{commentScore},
+            commentTimes      = #{commentTimes},
 --             selfRecommendFlag    = #{selfRecommendFlag},
 --             sysRecommendFlag     = #{sysRecommendFlag},
-            sortIndex            = #{sortIndex},
-            featuredFlag         = #{featuredFlag},
-            featuredSortIndex    = #{featuredSortIndex},
-            productCode          = #{productCode},
+            sortIndex         = #{sortIndex},
+            featuredFlag      = #{featuredFlag},
+            featuredSortIndex = #{featuredSortIndex},
+            productCode       = #{productCode},
 --             synToERPFlag         = #{synToERPFlag},
-            allAreaFlag          = #{allAreaFlag},
-            provinceIDs          = #{provinceIDs},
-            serviceNumber        = #{serviceNumber},
-            packageCount         = #{packageCount},
-            byFlag               = #{byFlag},
-            normalProductFlag    = #{normalProductFlag},
+            allAreaFlag       = #{allAreaFlag},
+            provinceIDs       = #{provinceIDs},
+            serviceNumber     = #{serviceNumber},
+            packageCount      = #{packageCount},
+            byFlag            = #{byFlag},
+            normalProductFlag = #{normalProductFlag},
 --             wholeSaleProductFlag = #{wholeSaleProductFlag},
 --             promotionProductFlag = #{promotionProductFlag},
 --             groupBuyProductFlag  = #{groupBuyProductFlag},
-            step                 = #{step},
-            actFlag              = #{actFlag},
-            actType              = #{actType},
-            onlineTime           = #{onlineTime},
-            downlineTime         = #{downlineTime},
-            freePostFlag         = #{freePostFlag},
+            step              = #{step},
+            actFlag           = #{actFlag},
+            actType           = #{actType},
+            onlineTime        = #{onlineTime},
+            downlineTime      = #{downlineTime},
+            freePostFlag      = #{freePostFlag},
 --             precisehKey          = #{precisehKey},
-            actSort              = #{actSort},
+            actSort           = #{actSort},
             newProductType=#{newProductType}
 
         WHERE productID = #{id}
@@ -688,17 +693,6 @@
         </where>
     </select>
 
-    <select id="getProductSku" resultType="com.caimei.modules.product.entity.Sku">
-        SELECT
-        *
-        FROM
-        sku
-        <where>
-            productID = #{productId}
-            AND validFlag = 1
-        </where>
-    </select>
-
     <select id="findProductBigTypeByProductID" parameterType="java.lang.Integer" resultType="java.lang.String">
         SELECT
         tb.name
@@ -891,7 +885,7 @@
             `productCategory`,
         </if>
         `preferredFlag`,
---         `selfTypeID`,
+        -- `selfTypeID`,
         `shopID`,
         `name`,
         `aliasName`,
@@ -904,28 +898,28 @@
         `propertiesInfo`,
         `addTime`,
         `updateTime`,
---         `weekSellNumber`,
+        -- `weekSellNumber`,
         `beforeValidFlag`,
         `validFlag`,
         `favoriteTimes`,
         `commentScore`,
         `commentTimes`,
---         `selfRecommendFlag`,
---         `sysRecommendFlag`,
+        -- `selfRecommendFlag`,
+        -- `sysRecommendFlag`,
         `sortIndex`,
         `featuredFlag`,
         `featuredSortIndex`,
         `productCode`,
---         `synToERPFlag`,
+        -- `synToERPFlag`,
         `allAreaFlag`,
         `provinceIDs`,
         `serviceNumber`,
         `packageCount`,
         `byFlag`,
         `normalProductFlag`,
---         `wholeSaleProductFlag`,
---         `promotionProductFlag`,
---         `groupBuyProductFlag`,
+        -- `wholeSaleProductFlag`,
+        -- `promotionProductFlag`,
+        -- `groupBuyProductFlag`,
         `step`,
         `actFlag`,
         `actStatus`,
@@ -935,7 +929,7 @@
         `onlineTime`,
         `downlineTime`,
         `freePostFlag`,
---         `precisehKey`,
+        -- `precisehKey`,
         `tags`,
         `productType`,
         `machineType`,
@@ -956,7 +950,7 @@
             #{productCategory},
         </if>
         #{preferredFlag},
---         #{selfTypeID},
+        -- #{selfTypeID},
         #{shopID},
         #{name},
         #{aliasName},
@@ -969,28 +963,28 @@
         #{propertiesInfo},
         #{addTime},
         #{updateTime},
---         #{weekSellNumber},
+        -- #{weekSellNumber},
         #{beforeValidFlag},
         #{validFlag},
         #{favoriteTimes},
         #{commentScore},
         #{commentTimes},
---         #{selfRecommendFlag},
---         #{sysRecommendFlag},
+        -- #{selfRecommendFlag},
+        -- #{sysRecommendFlag},
         #{sortIndex},
         #{featuredFlag},
         #{featuredSortIndex},
         #{productCode},
---         #{synToERPFlag},
+        -- #{synToERPFlag},
         #{allAreaFlag},
         #{provinceIDs},
         #{serviceNumber},
         #{packageCount},
         #{byFlag},
         #{normalProductFlag},
---         #{wholeSaleProductFlag},
---         #{promotionProductFlag},
---         #{groupBuyProductFlag},
+        -- #{wholeSaleProductFlag},
+        -- #{promotionProductFlag},
+        -- #{groupBuyProductFlag},
         #{step},
         #{actFlag},
         #{actStatus},
@@ -1000,7 +994,7 @@
         #{onlineTime},
         #{downlineTime},
         #{freePostFlag},
---         #{precisehKey},
+        -- #{precisehKey},
         #{tags},
         #{productType},
         #{machineType},
@@ -1050,59 +1044,60 @@
             useGeneratedKeys="true">
         insert into cm_sku
         (productId,
-         normalPrice,
-         price,
-         ladderPriceFlag,
-         <if test="costPrice != null">
+        normalPrice,
+        price,
+        ladderPriceFlag,
+        <if test="costPrice != null">
             costprice,
-         </if>
-         <if test="organizeCostPrice != null">
+        </if>
+        <if test="organizeCostPrice != null">
             organizeCostPrice,
-         </if>
-         <if test="cmCostPrice != null">
+        </if>
+        <if test="cmCostPrice != null">
             cmCostPrice,
-         </if>
-         stock,
-         <if test="shopPercent != null">
+        </if>
+        stock,
+        <if test="shopPercent != null">
             shopPercent,
-         </if>
-         <if test="organizePercent != null">
+        </if>
+        <if test="organizePercent != null">
             organizePercent,
-         </if>
-         <if test="cmPercent != null">
+        </if>
+        <if test="cmPercent != null">
             cmPercent,
-         </if>
-         organizeId,
-         minBuyNumber,
-         unit)
+        </if>
+        organizeId,
+        minBuyNumber,
+        unit)
         values (#{productId},
-                #{normalPrice},
-                #{price},
-                #{ladderPriceFlag},
-                <if test="costPrice != null">
-                    #{costPrice},
-                </if>
-                <if test="organizeCostPrice != null">
-                    #{organizeCostPrice},
-                </if>
-                <if test="cmCostPrice != null">
-                    #{cmCostPrice},
-                </if>
-                #{stock},
-                <if test="shopPercent != null">
-                    #{shopPercent},
-                </if>
-                <if test="organizePercent != null">
-                    #{organizePercent},
-                </if>
-                <if test="cmPercent != null">
-                    #{cmPercent},
-                </if>
-                #{organizeId},
-                #{minBuyNumber},
-                #{unit})
+        #{normalPrice},
+        #{price},
+        #{ladderPriceFlag},
+        <if test="costPrice != null">
+            #{costPrice},
+        </if>
+        <if test="organizeCostPrice != null">
+            #{organizeCostPrice},
+        </if>
+        <if test="cmCostPrice != null">
+            #{cmCostPrice},
+        </if>
+        #{stock},
+        <if test="shopPercent != null">
+            #{shopPercent},
+        </if>
+        <if test="organizePercent != null">
+            #{organizePercent},
+        </if>
+        <if test="cmPercent != null">
+            #{cmPercent},
+        </if>
+        #{organizeId},
+        #{minBuyNumber},
+        #{unit})
     </insert>
-    <insert id="insertOrganizeSku" keyColumn="id" keyProperty="id" parameterType="com.caimei.modules.product.entity.CmSku"
+    <insert id="insertOrganizeSku" keyColumn="id" keyProperty="id"
+            parameterType="com.caimei.modules.product.entity.CmSku"
             useGeneratedKeys="true">
         insert into cm_mall_product_sku
         (productId,
@@ -1220,7 +1215,8 @@
         select productId
         from cm_sku cs
         where skuId = #{productId}
-        and  cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=#{productId})
+        #暂时写死0
+        and  cs.organizeId = 0 limit 1
     </select>
 
     <select id="toAddProductList" resultType="product">
@@ -1513,15 +1509,15 @@
             <if test="updateTime != null and updateTime !=''">
                 updateTime = #{updateTime},
             </if>
-<!--            <if test="weekSellNumber != null and weekSellNumber !=''">-->
-<!--                weekSellNumber = #{weekSellNumber},-->
-<!--            </if>-->
+            <!--            <if test="weekSellNumber != null and weekSellNumber !=''">-->
+            <!--                weekSellNumber = #{weekSellNumber},-->
+            <!--            </if>-->
             <if test="beforeValidFlag != null and beforeValidFlag !=''">
                 beforeValidFlag = #{beforeValidFlag},
             </if>
-<!--            <if test="validFlag != null and validFlag !=''">-->
-<!--                validFlag = #{validFlag},-->
-<!--            </if>-->
+            <!--            <if test="validFlag != null and validFlag !=''">-->
+            <!--                validFlag = #{validFlag},-->
+            <!--            </if>-->
             <if test="favoriteTimes != null and favoriteTimes !=''">
                 favoriteTimes = #{favoriteTimes},
             </if>
@@ -1531,12 +1527,12 @@
             <if test="commentTimes != null and commentTimes !=''">
                 commentTimes = #{commentTimes},
             </if>
-<!--            <if test="selfRecommendFlag != null and selfRecommendFlag !=''">-->
-<!--                selfRecommendFlag = #{selfRecommendFlag},-->
-<!--            </if>-->
-<!--            <if test="sysRecommendFlag != null and sysRecommendFlag !=''">-->
-<!--                sysRecommendFlag = #{sysRecommendFlag},-->
-<!--            </if>-->
+            <!--            <if test="selfRecommendFlag != null and selfRecommendFlag !=''">-->
+            <!--                selfRecommendFlag = #{selfRecommendFlag},-->
+            <!--            </if>-->
+            <!--            <if test="sysRecommendFlag != null and sysRecommendFlag !=''">-->
+            <!--                sysRecommendFlag = #{sysRecommendFlag},-->
+            <!--            </if>-->
             <if test="sortIndex != null and sortIndex != ''">
                 sortIndex = #{sortIndex},
             </if>
@@ -1549,9 +1545,9 @@
             <if test="productCode != null and productCode !=''">
                 productCode = #{productCode},
             </if>
-<!--            <if test="synToERPFlag != null and synToERPFlag !=''">-->
-<!--                synToERPFlag = #{synToERPFlag},-->
-<!--            </if>-->
+            <!--            <if test="synToERPFlag != null and synToERPFlag !=''">-->
+            <!--                synToERPFlag = #{synToERPFlag},-->
+            <!--            </if>-->
             <if test="allAreaFlag != null and allAreaFlag !=''">
                 allAreaFlag = #{allAreaFlag},
             </if>
@@ -1570,15 +1566,15 @@
             <if test="normalProductFlag != null and normalProductFlag !=''">
                 normalProductFlag = #{normalProductFlag},
             </if>
-<!--            <if test="wholeSaleProductFlag != null and wholeSaleProductFlag !=''">-->
-<!--                wholeSaleProductFlag = #{wholeSaleProductFlag},-->
-<!--            </if>-->
-<!--            <if test="promotionProductFlag != null and promotionProductFlag !=''">-->
-<!--                promotionProductFlag = #{promotionProductFlag},-->
-<!--            </if>-->
-<!--            <if test="groupBuyProductFlag != null and groupBuyProductFlag !=''">-->
-<!--                groupBuyProductFlag = #{groupBuyProductFlag},-->
-<!--            </if>-->
+            <!--            <if test="wholeSaleProductFlag != null and wholeSaleProductFlag !=''">-->
+            <!--                wholeSaleProductFlag = #{wholeSaleProductFlag},-->
+            <!--            </if>-->
+            <!--            <if test="promotionProductFlag != null and promotionProductFlag !=''">-->
+            <!--                promotionProductFlag = #{promotionProductFlag},-->
+            <!--            </if>-->
+            <!--            <if test="groupBuyProductFlag != null and groupBuyProductFlag !=''">-->
+            <!--                groupBuyProductFlag = #{groupBuyProductFlag},-->
+            <!--            </if>-->
             <if test="step != null and step !=''">
                 step = #{step},
             </if>
@@ -1600,9 +1596,9 @@
             <if test="freePostFlag != null and freePostFlag !=''">
                 freePostFlag = #{freePostFlag},
             </if>
-<!--            <if test="precisehKey != null and precisehKey !=''">-->
-<!--                precisehKey = #{precisehKey},-->
-<!--            </if>-->
+            <!--            <if test="precisehKey != null and precisehKey !=''">-->
+            <!--                precisehKey = #{precisehKey},-->
+            <!--            </if>-->
             <if test="visibility != null and visibility !=''">
                 visibility = #{visibility},
             </if>
@@ -1736,31 +1732,31 @@
     <update id="updateCmSku">
         update cm_sku
         set productId=#{productId},
-            ladderPriceFlag=#{ladderPriceFlag},
-            normalPrice=#{normalPrice},
-            price=#{price},
-            organizeId=#{organizeId},
-            <if test="shopPercent != null">
-                shopPercent=#{shopPercent},
-            </if>
-            <if test="organizePercent != null">
-                organizePercent=#{organizePercent},
-            </if>
-            <if test="cmPercent != null">
-                cmPercent=#{cmPercent},
-            </if>
-            <if test="costPrice != null">
-                costPrice=#{costPrice},
-            </if>
-            <if test="organizeCostPrice != null">
-                organizeCostPrice = #{organizeCostPrice},
-            </if>
-            <if test="cmCostPrice != null">
-                cmCostPrice = #{cmCostPrice},
-            </if>
-            stock=#{stock},
-            unit=#{unit},
-            minBuyNumber=#{minBuyNumber}
+        ladderPriceFlag=#{ladderPriceFlag},
+        normalPrice=#{normalPrice},
+        price=#{price},
+        organizeId=#{organizeId},
+        <if test="shopPercent != null">
+            shopPercent=#{shopPercent},
+        </if>
+        <if test="organizePercent != null">
+            organizePercent=#{organizePercent},
+        </if>
+        <if test="cmPercent != null">
+            cmPercent=#{cmPercent},
+        </if>
+        <if test="costPrice != null">
+            costPrice=#{costPrice},
+        </if>
+        <if test="organizeCostPrice != null">
+            organizeCostPrice = #{organizeCostPrice},
+        </if>
+        <if test="cmCostPrice != null">
+            cmCostPrice = #{cmCostPrice},
+        </if>
+        stock=#{stock},
+        unit=#{unit},
+        minBuyNumber=#{minBuyNumber}
         where skuId = #{skuId}
     </update>
     <update id="updateOrganizeSku">
@@ -2021,7 +2017,9 @@
                unit,
                normalPrice,
                stock,
-               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                shopPercent,
                costPrice,
                price,
@@ -2035,10 +2033,13 @@
                  left join cm_promotion_sku cps on cs.skuId = cps.skuId
                  left join cm_svip_product_sku csps on cs.skuId = csps.skuId
         where cs.productId = #{productID}
-          and  cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=#{productID})
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = #{productID})
     </select>
     <select id="getCostCheckFlag" resultType="java.lang.Integer">
-        select costCheckFlag from cm_organize_product_info where productId = #{productId} and organizeId = #{organizeId}
+        select costCheckFlag
+        from cm_organize_product_info
+        where productId = #{productId}
+          and organizeId = #{organizeId}
     </select>
     <select id="findSkuListProduct" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.skuId,
@@ -2047,7 +2048,9 @@
                unit,
                normalPrice,
                stock,
-               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                shopPercent,
                organizePercent,
                cmPercent,
@@ -2062,7 +2065,9 @@
                csps.priceType
         from cm_sku cs
                  left join cm_svip_product_sku csps on cs.skuId = csps.skuId
-        where cs.organizeId=0 and  cs.productId = #{productID}
+        where cs.organizeId = 0
+          and cs.productId = #{productID}
+        order by cs.price asc
     </select>
     <select id="findSkuOrganizeList" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.skuId,
@@ -2071,8 +2076,10 @@
                cs.unit,
                cs.normalPrice,
                cs.stock,
-               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
-               cs.shopPercent as shopPercent,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent                                                  as shopPercent,
                cs.costPrice,
                cs.organizeCostPrice,
                cs.cmCostPrice,
@@ -2082,7 +2089,8 @@
                cs.shopPercent,
                cs.cmPercent
         from cm_sku cs
-        where cs.organizeId = 4  and cs.productId = #{productID}
+        where cs.organizeId = 4
+          and cs.productId = #{productID}
     </select>
     <select id="findLadderPriceBySku" resultType="com.caimei.modules.product.entity.CmLadderPrice">
         select skuId, productId, userType, ladderNum, buyNum, buyPrice, delFlag
@@ -2113,7 +2121,8 @@
         FROM product a
         <include refid="productJoins"/>
         left join cm_sku cs on cs.productId=a.productID and copi.organizeId= cs.organizeId
-        WHERE cs.skuId = #{skuId} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+        WHERE cs.skuId = #{skuId} and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE
+        productID=cs.productId)
     </select>
     <select id="findHeHeSku" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.skuId,
@@ -2121,16 +2130,18 @@
                cs.organizeId,
                cs.unit,
                cs.stock,
-               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                cs.costPrice,
-               ifnull(cs.shopPercent, 0) as shopPercent,
-               ifnull(cs.organizePercent, 0) as organizePercent,
-               ifnull(cs.cmPercent, 0) as cmPercent,
+               ifnull(cs.shopPercent, 0)                                       as shopPercent,
+               ifnull(cs.organizePercent, 0)                                   as organizePercent,
+               ifnull(cs.cmPercent, 0)                                         as cmPercent,
                chs.price
         from cm_sku cs
                  left join cm_hehe_sku chs on cs.skuId = chs.skuId
         where cs.productId = #{productID}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
     <select id="findSkuId" resultType="java.lang.Integer">
         select skuId
@@ -2139,26 +2150,30 @@
     </select>
     <select id="findSku" resultType="com.caimei.modules.product.entity.CmSku">
         select cs.price,
-               ifnull(cs.costPrice, 0) as costPrice,
-               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               ifnull(cs.costPrice, 0)                                         as costPrice,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                cs.shopPercent,
                cs.normalPrice
         from cm_sku cs
         where cs.productId = #{productId}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
         order by cs.price asc
         limit 1
     </select>
     <select id="findOrganizeSku" resultType="com.caimei.modules.product.entity.CmSku">
         SELECT cs.price,
                ifnull(cs.costPrice, 0),
-               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
-               cs.shopPercent AS shopPercent,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
+               cs.shopPercent                                                  AS shopPercent,
                cs.normalPrice,
                cs.organizeId
         FROM cm_sku cs
         WHERE cs.productId = #{productId}
-          and cs.organizeId=4
+          and cs.organizeId = 4
         ORDER BY cs.price ASC
         LIMIT 1
     </select>
@@ -2166,13 +2181,15 @@
         select cs.skuId,
                cs.price,
                cs.costPrice,
-               (select costCheckFlag from cm_organize_product_info where productId = cs.productId and organizeId = cs.organizeId ) as costCheckFlag,
+               (select costCheckFlag
+                from cm_organize_product_info
+                where productId = cs.productId and organizeId = cs.organizeId) as costCheckFlag,
                cs.shopPercent,
                cs.unit,
                cs.organizeId
         from cm_sku cs
         where cs.skuId = #{skuId}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
     <select id="findSkuIdByPromotionsId" resultType="java.lang.Integer">
         select skuId
@@ -2185,19 +2202,21 @@
         where skuId = #{skuId}
     </select>
     <select id="findSkuByPromotion" resultType="com.caimei.modules.product.entity.CmSku">
-        SELECT cs.price, cps.skuId, cps.touchPrice
-                       , cs.unit
-                       , cs.organizeId
+        SELECT cs.price
+             , cps.skuId
+             , cps.touchPrice
+             , cs.unit
+             , cs.organizeId
         FROM cm_promotion_sku cps
                  LEFT JOIN cm_sku cs ON cps.skuId = cs.skuId
         WHERE promotionId = #{id}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
     <select id="getSkuByPromotionId" resultType="com.caimei.modules.product.entity.CmSku">
         SELECT cs.price, cpp.productId, cs.skuId, cs.unit
         FROM cm_promotions_product cpp
                  LEFT JOIN cm_sku cs ON cpp.productId = cs.productId
         WHERE promotionsId = #{id}
-          and cs.organizeId=(SELECT SUBSTRING(groundMall, 1, 1)FROM product WHERE productID=cs.productId)
+          and cs.organizeId = (SELECT SUBSTRING(groundMall, 1, 1) FROM product WHERE productID = cs.productId)
     </select>
 </mapper>

+ 112 - 93
src/main/webapp/WEB-INF/views/modules/product-new/multiPromotionForm.jsp

@@ -1,20 +1,20 @@
 <%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
-<%@ page import="java.util.*"%>
-<%@ page import="java.text.*"%>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.*" %>
 <%
-    String datetime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); //获取系统时间
-    request.setAttribute("currentTime",datetime);
+    String datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); //获取系统时间
+    request.setAttribute("currentTime", datetime);
 %>
 <html>
 <head>
     <title>促销活动管理</title>
     <meta name="decorator" content="default"/>
     <script type="text/javascript">
-        $(document).ready(function() {
+        $(document).ready(function () {
             //$("#name").focus();
             $("#inputForm").validate({
-                submitHandler: function(form){
+                submitHandler: function (form) {
                     var isSubMitFlag = true, addProductArray = [], addGiftArray = [];
                     var mode = $("input[name='mode']:checked").val();
                     var status = $("input[name='status']:checked").val();
@@ -31,12 +31,12 @@
                     }
                     if (mode == "1") {
 
-                    }else if (mode == "2") {
+                    } else if (mode == "2") {
                         if ($("#touchPrice2").val() == '') {
                             alertx("请输入满减设定价");
                             isSubMitFlag = false;
                             return false;
-                        }else if(isNaN($("#touchPrice2").val())||$("#touchPrice2").val().indexOf('0')==0){
+                        } else if (isNaN($("#touchPrice2").val()) || $("#touchPrice2").val().indexOf('0') == 0) {
                             alertx('请输入正确的满减设定价!');
                             isSubMitFlag = false;
                             return false;
@@ -45,7 +45,7 @@
                             alertx("请输入减免价格");
                             isSubMitFlag = false;
                             return false;
-                        }else if(isNaN($("#reducedPrice").val())||$("#reducedPrice").val().indexOf('0')==0){
+                        } else if (isNaN($("#reducedPrice").val()) || $("#reducedPrice").val().indexOf('0') == 0) {
                             alertx('请输入正确的减免价格!');
                             isSubMitFlag = false;
                             return false;
@@ -55,19 +55,19 @@
                             isSubMitFlag = false;
                             return false;
                         }
-                    }else if (mode == "3") {
+                    } else if (mode == "3") {
                         if ($("#touchPrice3").val() == '') {
                             alertx("请输入满赠设定价");
                             isSubMitFlag = false;
                             return false;
-                        }else if(isNaN($("#touchPrice3").val())||$("#touchPrice3").val().indexOf('0')==0){
+                        } else if (isNaN($("#touchPrice3").val()) || $("#touchPrice3").val().indexOf('0') == 0) {
                             alertx('请输入正确的满赠设定价!');
                             isSubMitFlag = false;
                             return false;
                         }
                     }
-                    if (mode=="3") {
-                        if(document.getElementById("contentTbody1").rows.length<1){
+                    if (mode == "3") {
+                        if (document.getElementById("contentTbody1").rows.length < 1) {
                             alertx("请至少选择1个赠送的商品");
                             isSubMitFlag = false;
                             return false;
@@ -86,12 +86,12 @@
                         var $this = $(this);
                         var $itemProductID = $this.find('input[name="gift"]').val();
                         var $giftNumber = $this.find('input[name="giftNumber"]').val();
-                        if ($giftNumber == null || $giftNumber == '' ) {
+                        if ($giftNumber == null || $giftNumber == '') {
                             alertx("请输入赠品数量");
                             isSubMitFlag = false;
                             return false;
                         }
-                        if ( $giftNumber <= 0 ) {
+                        if ($giftNumber <= 0) {
                             alertx("赠品数量必须大于0");
                             isSubMitFlag = false;
                             return false;
@@ -121,9 +121,9 @@
                     }
                 },
                 errorContainer: "#messageBox",
-                errorPlacement: function(error, element) {
+                errorPlacement: function (error, element) {
                     $("#messageBox").text("输入有误,请先更正。");
-                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                         error.appendTo(element.parent().parent());
                     } else {
                         error.insertAfter(element);
@@ -131,6 +131,7 @@
                 }
             });
         });
+
         //选择添加商品
         function showSelect(type) {
             var showSelectProductID = '';
@@ -149,12 +150,12 @@
                     var $itemProductID = $this.find('input[name="gift"]').val();
                     showSelectProductID += $itemProductID + ',';
                 });
-                url ="${ctx}/product/cmPromotions/findProductPage?productIds=" + showSelectProductID
+                url = "${ctx}/product/cmPromotions/findProductPage?promotionType=2&productIds=" + showSelectProductID
                 title = "选择凑单赠品";
             }
             showSelectProductID = showSelectProductID.slice(0, -1)
             console.log(showSelectProductID);
-            top.$.jBox("iframe:"+url, {
+            top.$.jBox("iframe:" + url, {
                 iframeScrolling: 'yes',
                 width: $(top.document).width() - 400,
                 height: $(top.document).height() - 160,
@@ -187,15 +188,15 @@
                                     var delGiftIds = $("#delGiftIds").val();
                                     var description = $("#description").val();
                                     //将选中商品id与原来的促销商品或赠品id拼接
-                                    if (type == 1 ) {
+                                    if (type == 1) {
                                         if (productIds != '') {
                                             items = items + ',' + productIds;
                                         }
                                         if (giftIds != '') {
                                             items1 = giftIds;
                                         }
-                                        window.location.href = "${ctx}/product/cmPromotions/form?type=2&productIds=" + items + "&giftIds=" + items1 + "&mode=" + mode + "&description=" +description+
-                                            "&delProductIds="+delProductIds+"&delGiftIds="+delGiftIds+
+                                        window.location.href = "${ctx}/product/cmPromotions/form?type=2&productIds=" + items + "&giftIds=" + items1 + "&mode=" + mode + "&description=" + description +
+                                            "&delProductIds=" + delProductIds + "&delGiftIds=" + delGiftIds +
                                             "&reducedPrice=" + reducedPrice + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
                                             "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}";
                                     }
@@ -206,9 +207,9 @@
                                         if (productIds != '') {
                                             items1 = productIds;
                                         }
-                                        window.location.href = "${ctx}/product/cmPromotions/form?type=2&productIds=" + items1 + "&giftIds=" + items + "&mode=" + mode + "&description=" +description+
-                                            "&delProductIds="+delProductIds+"&delGiftIds="+delGiftIds+
-                                            "&reducedPrice=" + reducedPrice  + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
+                                        window.location.href = "${ctx}/product/cmPromotions/form?type=2&productIds=" + items1 + "&giftIds=" + items + "&mode=" + mode + "&description=" + description +
+                                            "&delProductIds=" + delProductIds + "&delGiftIds=" + delGiftIds +
+                                            "&reducedPrice=" + reducedPrice + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
                                             "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}";
                                     }
                                     $.jBox.tip(data.msg, 'info');
@@ -227,40 +228,43 @@
             });
         }
 
-        function deleteProduct(obj,type) {
+        function deleteProduct(obj, type) {
             //将该行数据取消勾选,若存在数据库中则将其存入delProductIds中
             $(".check-item[value=" + obj + "]").prop("checked", false);
-            if (type == 1) {
-                var product=$('#product'+obj);
+            var delProductIds = $("#delProductIds").val();
+            var delGiftIds = $("#delGiftIds").val();
+            if (1 === type) {
+                if (delProductIds != '') {
+                    delProductIds = delProductIds + "," + obj;
+                } else {
+                    delProductIds = obj;
+                }
+                $("#delProductIds").val(delProductIds);
+                var product = $('#product' + obj);
                 $(product).remove();
             }
-            if (type == 2) {
-                var gift= $('#gift'+obj);
+            if (2 === type) {
+                if (delGiftIds != '') {
+                    delGiftIds = delGiftIds + "," + obj;
+                } else {
+                    delGiftIds = obj;
+                }
+                $("#delGiftIds").val(delGiftIds);
+                var gift = $('#gift' + obj);
                 $(gift).remove();
             }
 
-            $.ajax({
-                url: "${ctx}/product/cmPromotions/delPromotion",
-                data: {"id":"${cmPromotion.id || ''}","skuId":obj},
-                type: "POST",
-                async: false,
-                success: function(data){
-                    flag=data.success;
-                }
-            });
-            <%--var delProductIds = $("#delProductIds").val();--%>
-            <%--var delGiftIds = $("#delGiftIds").val();--%>
-            <%--if (storeStatus && type == 1) {--%>
-            <%--    if (delProductIds != '') {--%>
-            <%--        delProductIds = delProductIds + "," + obj;--%>
-            <%--    }else delProductIds = obj;--%>
-            <%--}--%>
-            <%--if (storeStatus && type == 2) {--%>
-            <%--    if (delGiftIds != '') {--%>
-            <%--        delGiftIds = delGiftIds + "," + obj;--%>
-            <%--    }else delGiftIds = obj;--%>
-            <%--}--%>
+            <%--$.ajax({--%>
+            <%--    url: "${ctx}/product/cmPromotions/delPromotion",--%>
+            <%--    data: {"id": "${cmPromotion.id || ''}", "skuId": obj},--%>
+            <%--    type: "POST",--%>
+            <%--    async: false,--%>
+            <%--    success: function (data) {--%>
+            <%--        flag = data.success;--%>
+            <%--    }--%>
+            <%--});--%>
             <%--window.setTimeout(function () {--%>
+            <%--    debugger;--%>
             <%--    var productItems = getCheckedItems(1);--%>
             <%--    var giftItems = getCheckedItems(2);--%>
             <%--    var mode = $("input[name='mode']:checked").val();--%>
@@ -273,15 +277,15 @@
             <%--    var delFlag1 = $("input[name='delFlag1']:checked").val();--%>
             <%--    var description = $("#description").val();--%>
             <%--    window.location.href = "${ctx}/product/cmPromotions/form?type=2&productIds=" + productItems + "&giftIds=" + giftItems +--%>
-            <%--        "&delProductIds="+delProductIds+"&delGiftIds="+delGiftIds+"&mode=" + mode + "&description=" +description+--%>
-            <%--        "&reducedPrice=" + reducedPrice  + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +--%>
+            <%--        "&delProductIds=" + delProductIds + "&delGiftIds=" + delGiftIds + "&mode=" + mode + "&description=" + description +--%>
+            <%--        "&reducedPrice=" + reducedPrice + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +--%>
             <%--        "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}";--%>
-            <%--},100)--%>
+            <%--}, 100)--%>
         }
 
         function getCheckedItems(type) {
             var items = new Array();
-            var $items = type==0? $('.check-item:checked'):type==1?$("#productCheckItem:checked"):$("#giftCheckItem:checked");
+            var $items = type == 0 ? $('.check-item:checked') : type == 1 ? $("#productCheckItem:checked") : $("#giftCheckItem:checked");
             $items.each(function () {
                 items.push($(this).val());
             });
@@ -292,9 +296,13 @@
 <body>
 <ul class="nav nav-tabs">
     <li><a href="${ctx}/product/cmPromotions/list?type=2">凑单促销</a></li>
-    <li class="active"><a href="${ctx}/product/cmPromotions/form?id=${cmPromotion.id}&type=2">${not empty cmPromotion.id?'编辑':'添加'}凑单促销</a></li>
-</ul><br/>
-<form:form id="inputForm" modelAttribute="cmPromotion" action="${ctx}/product/cmPromotions/save" method="post" class="form-horizontal">
+    <li class="active"><a
+            href="${ctx}/product/cmPromotions/form?id=${cmPromotion.id}&type=2">${not empty cmPromotion.id?'编辑':'添加'}凑单促销</a>
+    </li>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="cmPromotion" action="${ctx}/product/cmPromotions/save" method="post"
+           class="form-horizontal">
     <form:hidden path="id"/>
     <form:hidden path="type"/>
     <form:hidden path="productIds" id="productIds"/>
@@ -324,8 +332,8 @@
                 <c:forEach items="${cmPromotion.promotionProducts}" var="product">
                     <tr id="product${product.productID}">
                         <th class="hide"><input class="check-item" type="checkbox" id="productCheckItem"
-                                   name="info" ${product.storeStatus?'':'checked'}
-                                   value='${product.productID}'/></th>
+                                                name="info" checked
+                                                value='${product.productID}'/></th>
                         <td><img src="${product.mainImage}" width="50px" height="50px"></td>
                         <td>${product.name}</td>
                         <td>${product.shopName}</td>
@@ -343,22 +351,27 @@
 
     <div class="control-group" id="promotionType">
         <label>促销方式:</label>
-        <input type="radio"  id="promotionType2" name="mode" value="2" ${cmPromotion.mode == null ? "checked" :cmPromotion.mode == "2" ? "checked" : ""} />满减
-        <input type="radio" id="promotionType3"   name="mode" value="3" ${cmPromotion.mode == "3" ? "checked" : ""} />满赠
+        <input type="radio" id="promotionType2" name="mode"
+               value="2" ${cmPromotion.mode == null ? "checked" :cmPromotion.mode == "2" ? "checked" : ""} />满减
+        <input type="radio" id="promotionType3" name="mode" value="3" ${cmPromotion.mode == "3" ? "checked" : ""} />满赠
     </div>
 
     <div class="control-group">
         <label style="color: red">*</label>
         <label style="display: inline">优惠内容:</label>
-        <div id="discountContent2" style="display: ${cmPromotion.mode == null ? "inline" :cmPromotion.mode == "2" ? "inline" : "none"}">
+        <div id="discountContent2"
+             style="display: ${cmPromotion.mode == null ? "inline" :cmPromotion.mode == "2" ? "inline" : "none"}">
             <label>满</label>
-            <form:input path="touchPrice2" id="touchPrice2" htmlEscape="false" maxlength="7" class="input-xlarge" onkeyup="onlynum(this)"/>
+            <form:input path="touchPrice2" id="touchPrice2" htmlEscape="false" maxlength="7" class="input-xlarge"
+                        onkeyup="onlynum(this)"/>
             <label>减</label>
-            <form:input path="reducedPrice" id="reducedPrice" htmlEscape="false" maxlength="7" class="input-xlarge " onkeyup="onlynum(this)"/>
+            <form:input path="reducedPrice" id="reducedPrice" htmlEscape="false" maxlength="7" class="input-xlarge "
+                        onkeyup="onlynum(this)"/>
         </div>
         <div id="discountContent3" style="display: ${cmPromotion.mode == "3" ? "inline" : "none"}">
             <label>满</label>
-            <form:input path="touchPrice3" id="touchPrice3" htmlEscape="false" maxlength="7" class="input-xlarge " onkeyup="onlynum(this)"/>
+            <form:input path="touchPrice3" id="touchPrice3" htmlEscape="false" maxlength="7" class="input-xlarge "
+                        onkeyup="onlynum(this)"/>
             <label><a href="JavaScript:;" onclick="showSelect(2)">请选择赠品</a></label>
             <c:if test="${cmPromotion.giftProducts !=null and cmPromotion.giftProducts.size()>0}">
                 <table id="contentTable" class="table table-striped table-bordered table-condensed">
@@ -402,11 +415,13 @@
 
     <div class="control-group">
         <label>促销时效:</label>
-        <input type="radio" name="status" value="1" ${cmPromotion.status == null ? "checked" : cmPromotion.status == "1"?"checked":""} />永久
+        <input type="radio" name="status"
+               value="1" ${cmPromotion.status == null ? "checked" : cmPromotion.status == "1"?"checked":""} />永久
         <input type="radio" name="status" value="2" ${cmPromotion.status == "2" ? "checked" : ""} />区间有效
     </div>
 
-    <div class="control-group" id="begin" style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}" >
+    <div class="control-group" id="begin"
+         style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}">
         <label>开始时间:</label>
         <input name="beginTime" type="text" readonly="readonly" maxlength="20"
                class="input-medium Wdate required" id="beginTime"
@@ -414,7 +429,8 @@
                onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
     </div>
 
-    <div class="control-group" id="end" style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}" >
+    <div class="control-group" id="end"
+         style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}">
         <label>结束时间:</label>
         <input name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
                id="endTime"
@@ -424,46 +440,49 @@
 
     <div class="control-group" id="discount">
         <label>叠加优惠:</label>
-        <input type="radio" name="discount" value="1" ${cmPromotion.discount == null ? "checked" : cmPromotion.discount == "1"?"checked":""} />支持
+        <input type="radio" name="discount"
+               value="1" ${cmPromotion.discount == null ? "checked" : cmPromotion.discount == "1"?"checked":""} />支持
         <input type="radio" name="discount" value="2" ${cmPromotion.discount == "2" ? "checked" : ""} />不支持
     </div>
 
     <div class="control-group">
         <label>活动可见度:</label>
-        <input type="radio" name="seen" value="1" ${cmPromotion.seen == null ? "checked" : cmPromotion.seen == "1"?"checked":""}/>对所有人可见(含协销)
+        <input type="radio" name="seen"
+               value="1" ${cmPromotion.seen == null ? "checked" : cmPromotion.seen == "1"?"checked":""}/>对所有人可见(含协销)
         <input type="radio" name="seen" value="2" ${cmPromotion.seen == "2" ? "checked" : ""}/>仅对机构可见(不含协销)
     </div>
 
     <div class="control-group">
         <label style="display: inline">促销状态:</label>
-        <label style="display: inline;color: ${cmPromotion.delFlag1 == null || cmPromotion.delFlag1 == '' ?"green":cmPromotion.delFlag1 == "0"?"red":cmPromotion.delFlag1 == "1"?"purple":cmPromotion.delFlag1 == "2"?"green":"orange"}" id="promotionStatus">${cmPromotion.delFlag1 == null?"进行中": cmPromotion.delFlag1 == "0"?"已关闭":cmPromotion.delFlag1 == "1"?"未开始":cmPromotion.delFlag1 == "2"?"进行中":"已结束"}</label>
-        <input type="checkbox" name="delFlag1" value="close" ${cmPromotion.delFlag1 == null?"":cmPromotion.delFlag1 == "0" ? "checked" : ""} />关闭
+        <label style="display: inline;color: ${cmPromotion.delFlag1 == null || cmPromotion.delFlag1 == '' ?"green":cmPromotion.delFlag1 == "0"?"red":cmPromotion.delFlag1 == "1"?"purple":cmPromotion.delFlag1 == "2"?"green":"orange"}"
+               id="promotionStatus">${cmPromotion.delFlag1 == null?"进行中": cmPromotion.delFlag1 == "0"?"已关闭":cmPromotion.delFlag1 == "1"?"未开始":cmPromotion.delFlag1 == "2"?"进行中":"已结束"}</label>
+        <input type="checkbox" name="delFlag1"
+               value="close" ${cmPromotion.delFlag1 == null?"":cmPromotion.delFlag1 == "0" ? "checked" : ""} />关闭
     </div>
 
     <div class="form-actions">
         <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
-        <a href="${ctx}/product/cmPromotions/?type=2"><input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/></a>
+        <a href="${ctx}/product/cmPromotions/?type=2"><input id="btnCancel" class="btn" type="button" value="返 回"
+                                                             onclick="history.go(-1)"/></a>
     </div>
 </form:form>
 <script type="text/javascript">
-    $(function () {
-    })
 
     //促销方式修改
     $("input:radio[name='mode']").click(function () {
         var promotionType = $("input[name='mode']:checked").val();
         if ("1" == promotionType) {
-            $("#discountContent1").attr("style","display:inline");
-            $("#discountContent2").attr("style","display:none");
-            $("#discountContent3").attr("style","display:none");
-        }else if ("2" == promotionType) {
-            $("#discountContent1").attr("style","display:none");
-            $("#discountContent2").attr("style","display:inline");
-            $("#discountContent3").attr("style","display:none");
+            $("#discountContent1").attr("style", "display:inline");
+            $("#discountContent2").attr("style", "display:none");
+            $("#discountContent3").attr("style", "display:none");
+        } else if ("2" == promotionType) {
+            $("#discountContent1").attr("style", "display:none");
+            $("#discountContent2").attr("style", "display:inline");
+            $("#discountContent3").attr("style", "display:none");
         } else {
-            $("#discountContent1").attr("style","display:none");
-            $("#discountContent2").attr("style","display:none");
-            $("#discountContent3").attr("style","display:inline");
+            $("#discountContent1").attr("style", "display:none");
+            $("#discountContent2").attr("style", "display:none");
+            $("#discountContent3").attr("style", "display:inline");
         }
     })
     //促销时效修改
@@ -471,15 +490,15 @@
         var promotionStatus = $("input[name='status']:checked").val();
         var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
         if ("1" == promotionStatus) {
-            $("#begin").attr("style","display:none");
-            $("#end").attr("style","display:none");
+            $("#begin").attr("style", "display:none");
+            $("#end").attr("style", "display:none");
             if (null == promotiondelFlag1) {
                 $("#promotionStatus").text("进行中");
                 $("#promotionStatus").attr("style", "display: inline;color:green");
             }
-        }else if ("2" == promotionStatus) {
-            $("#begin").attr("style","");
-            $("#end").attr("style","");
+        } else if ("2" == promotionStatus) {
+            $("#begin").attr("style", "");
+            $("#end").attr("style", "");
             if (null == promotiondelFlag1) {
                 updateStatus();
             }
@@ -500,7 +519,7 @@
         if (promotiondelFlag1 != null) {
             $("#promotionStatus").text("已关闭");
             $("#promotionStatus").attr("style", "display: inline;color:red");
-        }else {
+        } else {
             var promotionStatus = $("input[name='status']:checked").val();
             if ("1" == promotionStatus) {
                 $("#promotionStatus").text("进行中");

+ 104 - 71
src/main/webapp/WEB-INF/views/modules/product-new/shopPromotionForm.jsp

@@ -1,20 +1,20 @@
 <%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
-<%@ page import="java.util.*"%>
-<%@ page import="java.text.*"%>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<%@ page import="java.util.*" %>
+<%@ page import="java.text.*" %>
 <%
-    String datetime=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); //获取系统时间
-    request.setAttribute("currentTime",datetime);
+    String datetime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(Calendar.getInstance().getTime()); //获取系统时间
+    request.setAttribute("currentTime", datetime);
 %>
 <html>
 <head>
     <title>促销活动管理</title>
     <meta name="decorator" content="default"/>
     <script type="text/javascript">
-        $(document).ready(function() {
+        $(document).ready(function () {
             $("#inputForm").validate({
-                submitHandler: function(form){
-                    var isSubMitFlag = true, addGiftArray = [] ,addShopId;
+                submitHandler: function (form) {
+                    var isSubMitFlag = true, addGiftArray = [], addShopId;
                     var mode = $("input[name='mode']:checked").val();
                     var status = $("input[name='status']:checked").val();
                     if (${cmPromotion.promotionShops==null or cmPromotion.promotionShops.size()==0}) {
@@ -29,12 +29,12 @@
                     }
                     if (mode == "1") {
 
-                    }else if (mode == "2") {
+                    } else if (mode == "2") {
                         if ($("#touchPrice2").val() == '') {
                             alertx("请输入满减设定价");
                             isSubMitFlag = false;
                             return false;
-                        }else if(isNaN($("#touchPrice2").val())||$("#touchPrice2").val().indexOf('0')==0){
+                        } else if (isNaN($("#touchPrice2").val()) || $("#touchPrice2").val().indexOf('0') == 0) {
                             alertx('请输入正确的满减设定价!');
                             isSubMitFlag = false;
                             return false;
@@ -43,7 +43,7 @@
                             alertx("请输入减免价格");
                             isSubMitFlag = false;
                             return false;
-                        }else if(isNaN($("#reducedPrice").val())||$("#reducedPrice").val().indexOf('0')==0){
+                        } else if (isNaN($("#reducedPrice").val()) || $("#reducedPrice").val().indexOf('0') == 0) {
                             alertx('请输入正确的减免价格!');
                             isSubMitFlag = false;
                             return false;
@@ -53,18 +53,18 @@
                             isSubMitFlag = false;
                             return false;
                         }
-                    }else if (mode == "3") {
+                    } else if (mode == "3") {
                         if ($("#touchPrice3").val() == '') {
                             alertx("请输入满赠设定价");
                             isSubMitFlag = false;
                             return false;
-                        }else if(isNaN($("#touchPrice3").val())||$("#touchPrice3").val().indexOf('0')==0){
+                        } else if (isNaN($("#touchPrice3").val()) || $("#touchPrice3").val().indexOf('0') == 0) {
                             alertx('请输入正确的满赠设定价!');
                             isSubMitFlag = false;
                             return false;
                         }
                     }
-                    if (mode=="3" &&( ${cmPromotion.giftProducts==null or cmPromotion.giftProducts.size()==0})) {
+                    if (mode == "3" && (${cmPromotion.giftProducts==null or cmPromotion.giftProducts.size()==0})) {
                         alertx("请至少选择1个赠送的商品");
                         isSubMitFlag = false;
                         return false;
@@ -79,12 +79,12 @@
                         var $this = $(this);
                         var $itemProductID = $this.find('input[name="gift"]').val();
                         var $giftNumber = $this.find('input[name="giftNumber"]').val();
-                        if ($giftNumber == null || $giftNumber == '' ) {
+                        if ($giftNumber == null || $giftNumber == '') {
                             alertx("请输入赠品数量");
                             isSubMitFlag = false;
                             return false;
                         }
-                        if ( $giftNumber <= 0 ) {
+                        if ($giftNumber <= 0) {
                             alertx("赠品数量必须大于0");
                             isSubMitFlag = false;
                             return false;
@@ -113,9 +113,9 @@
                     }
                 },
                 errorContainer: "#messageBox",
-                errorPlacement: function(error, element) {
+                errorPlacement: function (error, element) {
                     $("#messageBox").text("输入有误,请先更正。");
-                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
                         error.appendTo(element.parent().parent());
                     } else {
                         error.insertAfter(element);
@@ -123,6 +123,7 @@
                 }
             });
         });
+
         //选择添加商品
         function showSelect(type) {
             var showSelectProductID = '';
@@ -135,19 +136,19 @@
                     var $itemProductID = $this.find('input[name="info"]').val();
                     showSelectProductID += $itemProductID + ',';
                 });
-                url = "${ctx}/product/cmPromotions/findSupplierPage?shopIds=" + showSelectProductID + "&delShopIds=" +delShopIds;
+                url = "${ctx}/product/cmPromotions/findSupplierPage?shopIds=" + showSelectProductID + "&delShopIds=" + delShopIds;
                 title = '选择促销店铺';
-            } else if (type == 2){
+            } else if (type == 2) {
                 var shopId = $("#productCheckItem").val();
-                if(shopId){
+                if (shopId) {
                     $('#contentTbody1 tr').each(function (index, item) {
                         var $this = $(this);
                         var $itemProductID = $this.find('input[name="gift"]').val();
                         showSelectProductID += $itemProductID + ',';
                     });
-                    url = "${ctx}/product/cmPromotions/findProductPage?promotionType=3&productIds=" + showSelectProductID+"&shopID="+shopId;
+                    url = "${ctx}/product/cmPromotions/findProductPage?promotionType=3&productIds=" + showSelectProductID + "&shopID=" + shopId;
                     title = '选择促销赠品';
-                }else{
+                } else {
                     top.$.jBox.tip("请先勾选供应商...");
                     return false;
                 }
@@ -187,15 +188,15 @@
                                     var delShopIds = $("#delShopIds").val();
                                     var delGiftIds = $("#delGiftIds").val();
                                     //将选中商品id与原来的促销商品或赠品id拼接
-                                    if (type == 1 ) {
+                                    if (type == 1) {
                                         items = items;
                                         if (giftIds != '') {
                                             items1 = giftIds;
                                         }
                                         window.location.href = "${ctx}/product/cmPromotions/form?type=3&shopIds=" + items + "&giftIds=" + items1 + "&mode=" + mode +
-                                            "&delShopIds="+delShopIds+"&delGiftIds="+delGiftIds+
+                                            "&delShopIds=" + delShopIds + "&delGiftIds=" + delGiftIds +
                                             "&reducedPrice=" + reducedPrice + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
-                                            "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}"+
+                                            "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}" +
                                             "&searchDbFlag=0";
                                     }
                                     if (type == 2) {
@@ -206,8 +207,8 @@
                                             items1 = shopIds;
                                         }
                                         window.location.href = "${ctx}/product/cmPromotions/form?type=3&shopIds=" + items1 + "&giftIds=" + items + "&mode=" + mode +
-                                            "&delShopIds="+delShopIds+"&delGiftIds="+delGiftIds+
-                                            "&reducedPrice=" + reducedPrice  + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
+                                            "&delShopIds=" + delShopIds + "&delGiftIds=" + delGiftIds +
+                                            "&reducedPrice=" + reducedPrice + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
                                             "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}";
                                     }
                                     $.jBox.tip(data.msg, 'info');
@@ -228,23 +229,38 @@
 
         function deleteProduct(obj, type) {
             //将该行数据取消勾选,若存在数据库中则将其删除
+            var delProductIds = $("#delShopIds").val();
+            var delGiftIds = $("#delGiftIds").val();
             $(".check-item[value=" + obj + "]").prop("checked", false);
-            if (type == 3) {
-                var shop=$('#shop'+obj);
+            if (3 === type) {
+                if (delShopIds != '') {
+                    delShopIds = delShopIds + "," + obj;
+                } else {
+                    delShopIds = obj;
+                }
+                $("#delProductIds").val(delProductIds);
+                var shop = $('#shop' + obj);
                 $(shop).remove();
             }
-            if (type == 2) {
-                var gift= $('#gift'+obj);
+            if (2 === type) {
+                if (delGiftIds != '') {
+                    delGiftIds = delGiftIds + "," + obj;
+                } else {
+                    delGiftIds = obj;
+                }
+                $("#delGiftIds").val(delGiftIds);
+                var gift = $('#gift' + obj);
                 $(gift).remove();
             }
 
+
             $.ajax({
                 url: "${ctx}/product/cmPromotions/delPromotion",
-                data: {"id":"${cmPromotion.id || ''}","skuId":obj},
+                data: {"id": "${cmPromotion.id || ''}", "skuId": obj},
                 type: "POST",
                 async: false,
-                success: function(data){
-                    flag=data.success;
+                success: function (data) {
+                    flag = data.success;
                 }
             });
             <%--var delShopIds = $("#delShopIds").val();--%>
@@ -285,7 +301,7 @@
 
         function getCheckedItems(type) {
             var items = new Array();
-            var $items = type==0? $('.check-item:checked'):type==1?$("#productCheckItem:checked"):$("#giftCheckItem:checked");
+            var $items = type == 0 ? $('.check-item:checked') : type == 1 ? $("#productCheckItem:checked") : $("#giftCheckItem:checked");
             $items.each(function () {
                 items.push($(this).val());
             });
@@ -296,9 +312,13 @@
 <body>
 <ul class="nav nav-tabs">
     <li><a href="${ctx}/product/cmPromotions/list?type=3">店铺促销</a></li>
-    <li class="active"><a href="${ctx}/product/cmPromotions/form?id=${cmPromotion.id}&type=3">${not empty cmPromotion.id?'编辑':'添加'}店铺促销</a></li>
-</ul><br/>
-<form:form id="inputForm" modelAttribute="cmPromotion" action="${ctx}/product/cmPromotions/save" method="post" class="form-horizontal">
+    <li class="active"><a
+            href="${ctx}/product/cmPromotions/form?id=${cmPromotion.id}&type=3">${not empty cmPromotion.id?'编辑':'添加'}店铺促销</a>
+    </li>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="cmPromotion" action="${ctx}/product/cmPromotions/save" method="post"
+           class="form-horizontal">
     <form:hidden path="id"/>
     <form:hidden path="type"/>
     <form:hidden path="productIds" id="productIds"/>
@@ -325,8 +345,8 @@
                 <c:forEach items="${cmPromotion.promotionShops}" var="shop">
                     <tr id="shop${shop.shopID}">
                         <th class="hide"><input class="check-item" type="checkbox" id="productCheckItem"
-                                   name="info" ${shop.storeStatus?'':'checked'}
-                                   value='${shop.shopID}'/></th>
+                                                name="info" ${shop.storeStatus?'':'checked'}
+                                                value='${shop.shopID}'/></th>
                         <td>${shop.name}</td>
                         <td>${shop.sname}</td>
                         <td>${shop.linkMan}</td>
@@ -344,22 +364,27 @@
 
     <div class="control-group" id="promotionType">
         <label>促销方式:</label>
-        <input type="radio"  id="promotionType2" name="mode" value="2" ${cmPromotion.mode == null ? "checked" :cmPromotion.mode == "2" ? "checked" : ""} />满减
-        <input type="radio" id="promotionType3"   name="mode" value="3" ${cmPromotion.mode == "3" ? "checked" : ""} />满赠
+        <input type="radio" id="promotionType2" name="mode"
+               value="2" ${cmPromotion.mode == null ? "checked" :cmPromotion.mode == "2" ? "checked" : ""} />满减
+        <input type="radio" id="promotionType3" name="mode" value="3" ${cmPromotion.mode == "3" ? "checked" : ""} />满赠
     </div>
 
     <div class="control-group">
         <label style="color: red">*</label>
         <label style="display: inline">优惠内容:</label>
-        <div id="discountContent2" style="display: ${cmPromotion.mode == null ? "inline" : cmPromotion.mode == "2" ? "inline" : "none"}">
+        <div id="discountContent2"
+             style="display: ${cmPromotion.mode == null ? "inline" : cmPromotion.mode == "2" ? "inline" : "none"}">
             <label>满</label>
-            <form:input path="touchPrice2" id="touchPrice2" htmlEscape="false" maxlength="7" class="input-xlarge " onkeyup="onlynum(this)"/>
+            <form:input path="touchPrice2" id="touchPrice2" htmlEscape="false" maxlength="7" class="input-xlarge "
+                        onkeyup="onlynum(this)"/>
             <label>减</label>
-            <form:input path="reducedPrice" id="reducedPrice" htmlEscape="false" maxlength="7" class="input-xlarge " onkeyup="onlynum(this)"/>
+            <form:input path="reducedPrice" id="reducedPrice" htmlEscape="false" maxlength="7" class="input-xlarge "
+                        onkeyup="onlynum(this)"/>
         </div>
         <div id="discountContent3" style="display: ${cmPromotion.mode == "3" ? "inline" : "none"}">
             <label>满</label>
-            <form:input path="touchPrice3" id="touchPrice3" htmlEscape="false" maxlength="7" class="input-xlarge " onkeyup="onlynum(this)"/>
+            <form:input path="touchPrice3" id="touchPrice3" htmlEscape="false" maxlength="7" class="input-xlarge "
+                        onkeyup="onlynum(this)"/>
             <label><a href="JavaScript:;" onclick="showSelect(2)">请选择商品</a></label>
             <c:if test="${cmPromotion.giftProducts !=null and cmPromotion.giftProducts.size()>0}">
                 <table id="contentTable" class="table table-striped table-bordered table-condensed">
@@ -403,11 +428,13 @@
 
     <div class="control-group">
         <label>促销时效:</label>
-        <input type="radio" name="status" value="1" ${cmPromotion.status == null ? "checked" : cmPromotion.status == "1"?"checked":""} />永久
+        <input type="radio" name="status"
+               value="1" ${cmPromotion.status == null ? "checked" : cmPromotion.status == "1"?"checked":""} />永久
         <input type="radio" name="status" value="2" ${cmPromotion.status == "2" ? "checked" : ""} />区间有效
     </div>
 
-    <div class="control-group" id="begin" style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}" >
+    <div class="control-group" id="begin"
+         style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}">
         <label>开始时间:</label>
         <input name="beginTime" type="text" readonly="readonly" maxlength="20"
                class="input-medium Wdate required" id="beginTime"
@@ -415,7 +442,8 @@
                onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
     </div>
 
-    <div class="control-group" id="end" style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}" >
+    <div class="control-group" id="end"
+         style="display: ${cmPromotion.status == null ? "none" : cmPromotion.status == "1"?"none":""}">
         <label>结束时间:</label>
         <input name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
                id="endTime"
@@ -425,25 +453,30 @@
 
     <div class="control-group" id="discount">
         <label>叠加优惠:</label>
-        <input type="radio" name="discount" value="1" ${cmPromotion.discount == null ? "checked" : cmPromotion.discount == "1"?"checked":""} />支持
+        <input type="radio" name="discount"
+               value="1" ${cmPromotion.discount == null ? "checked" : cmPromotion.discount == "1"?"checked":""} />支持
         <input type="radio" name="discount" value="2" ${cmPromotion.discount == "2" ? "checked" : ""} />不支持
     </div>
 
     <div class="control-group">
         <label>活动可见度:</label>
-        <input type="radio" name="seen" value="1" ${cmPromotion.seen == null ? "checked" : cmPromotion.seen == "1"?"checked":""}/>对所有人可见(含协销)
+        <input type="radio" name="seen"
+               value="1" ${cmPromotion.seen == null ? "checked" : cmPromotion.seen == "1"?"checked":""}/>对所有人可见(含协销)
         <input type="radio" name="seen" value="2" ${cmPromotion.seen == "2" ? "checked" : ""}/>仅对机构可见(不含协销)
     </div>
 
     <div class="control-group">
         <label style="display: inline">促销状态:</label>
-        <label style="display: inline;color: ${cmPromotion.delFlag1 == null || cmPromotion.delFlag1 == '' ?"green":cmPromotion.delFlag1 == "0"?"red":cmPromotion.delFlag1 == "1"?"purple":cmPromotion.delFlag1 == "2"?"green":"orange"}" id="promotionStatus">${cmPromotion.delFlag1 == null?"进行中":cmPromotion.delFlag1 == "0"?"已关闭":cmPromotion.delFlag1 == "1"?"未开始":cmPromotion.delFlag1 == "2"?"进行中":"已结束"}</label>
-        <input type="checkbox" name="delFlag1" value="close" ${cmPromotion.delFlag1 == null?"":cmPromotion.delFlag1 == "0" ? "checked" : ""} />关闭
+        <label style="display: inline;color: ${cmPromotion.delFlag1 == null || cmPromotion.delFlag1 == '' ?"green":cmPromotion.delFlag1 == "0"?"red":cmPromotion.delFlag1 == "1"?"purple":cmPromotion.delFlag1 == "2"?"green":"orange"}"
+               id="promotionStatus">${cmPromotion.delFlag1 == null?"进行中":cmPromotion.delFlag1 == "0"?"已关闭":cmPromotion.delFlag1 == "1"?"未开始":cmPromotion.delFlag1 == "2"?"进行中":"已结束"}</label>
+        <input type="checkbox" name="delFlag1"
+               value="close" ${cmPromotion.delFlag1 == null?"":cmPromotion.delFlag1 == "0" ? "checked" : ""} />关闭
     </div>
 
     <div class="form-actions">
         <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
-        <a href="${ctx}/product/cmPromotions/?type=3"><input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/></a>
+        <a href="${ctx}/product/cmPromotions/?type=3"><input id="btnCancel" class="btn" type="button" value="返 回"
+                                                             onclick="history.go(-1)"/></a>
     </div>
 </form:form>
 <script type="text/javascript">
@@ -454,17 +487,17 @@
     $("input:radio[name='mode']").click(function () {
         var promotionType = $("input[name='mode']:checked").val();
         if ("1" == promotionType) {
-            $("#discountContent1").attr("style","display:inline");
-            $("#discountContent2").attr("style","display:none");
-            $("#discountContent3").attr("style","display:none");
-        }else if ("2" == promotionType) {
-            $("#discountContent1").attr("style","display:none");
-            $("#discountContent2").attr("style","display:inline");
-            $("#discountContent3").attr("style","display:none");
+            $("#discountContent1").attr("style", "display:inline");
+            $("#discountContent2").attr("style", "display:none");
+            $("#discountContent3").attr("style", "display:none");
+        } else if ("2" == promotionType) {
+            $("#discountContent1").attr("style", "display:none");
+            $("#discountContent2").attr("style", "display:inline");
+            $("#discountContent3").attr("style", "display:none");
         } else {
-            $("#discountContent1").attr("style","display:none");
-            $("#discountContent2").attr("style","display:none");
-            $("#discountContent3").attr("style","display:inline");
+            $("#discountContent1").attr("style", "display:none");
+            $("#discountContent2").attr("style", "display:none");
+            $("#discountContent3").attr("style", "display:inline");
         }
     })
     //促销时效修改
@@ -472,15 +505,15 @@
         var promotionStatus = $("input[name='status']:checked").val();
         var promotiondelFlag1 = $("input[name='delFlag1']:checked").val();
         if ("1" == promotionStatus) {
-            $("#begin").attr("style","display:none");
-            $("#end").attr("style","display:none");
+            $("#begin").attr("style", "display:none");
+            $("#end").attr("style", "display:none");
             if (null == promotiondelFlag1) {
                 $("#promotionStatus").text("进行中");
                 $("#promotionStatus").attr("style", "display: inline;color:green");
             }
-        }else if ("2" == promotionStatus) {
-            $("#begin").attr("style","");
-            $("#end").attr("style","");
+        } else if ("2" == promotionStatus) {
+            $("#begin").attr("style", "");
+            $("#end").attr("style", "");
             if (null == promotiondelFlag1) {
                 updateStatus();
             }
@@ -501,7 +534,7 @@
         if (promotiondelFlag1 != null) {
             $("#promotionStatus").text("已关闭");
             $("#promotionStatus").attr("style", "display: inline;color:red");
-        }else {
+        } else {
             var promotionStatus = $("input[name='status']:checked").val();
             if ("1" == promotionStatus) {
                 $("#promotionStatus").text("进行中");

+ 31 - 18
src/main/webapp/WEB-INF/views/modules/product-new/singlePromotionForm.jsp

@@ -269,31 +269,44 @@
         function deleteProduct(obj, type) {
             //将该行数据取消勾选,若存在数据库中则将其删除
             $(".check-item[value=" + obj + "]").prop("checked", false);
-            if (type == 1) {
+            var delProductIds = $("#delProductIds").val();
+            var delGiftIds = $("#delGiftIds").val();
+            if (1 === type) {
+                if (delProductIds != '') {
+                    delProductIds = delProductIds + "," + obj;
+                } else {
+                    delProductIds = obj;
+                }
+                $("#delProductIds").val(delProductIds);
                 var product = $('#product' + obj);
                 $(product).remove();
-            }
-            if (type == 2) {
+            } else if (2 === type) {
+                if (delGiftIds != '') {
+                    delGiftIds = delGiftIds + "," + obj;
+                } else {
+                    delGiftIds = obj;
+                }
+                $("#delGiftIds").val(delGiftIds);
                 var gift = $('#gift' + obj);
                 $(gift).remove();
             }
 
-            $.ajax({
-                url: "${ctx}/product/cmPromotions/delPromotion",
-                data: {"id": "${cmPromotion.id || ''}", "skuId": obj},
-                type: "POST",
-                async: false,
-                success: function (data) {
-                    flag = data.success;
-                }
-            });
+
+            <%--$.ajax({--%>
+            <%--    url: "${ctx}/product/cmPromotions/delPromotion",--%>
+            <%--    data: {"id": "${cmPromotion.id || ''}", "skuId": obj},--%>
+            <%--    type: "POST",--%>
+            <%--    async: false,--%>
+            <%--    success: function (data) {--%>
+            <%--        flag = data.success;--%>
+            <%--    }--%>
+            <%--});--%>
 
             <%--window.setTimeout(function () {--%>
             <%--    var productItems = getCheckedItems(1);--%>
             <%--    var giftItems = getCheckedItems(2);--%>
             <%--    var mode = $("input[name='mode']:checked").val();--%>
             <%--    var reducedPrice = $("#reducedPrice").val();--%>
-            <%--    var touchPrice1 = $("#touchPrice1").val();--%>
             <%--    var touchPrice2 = $("#touchPrice2").val();--%>
             <%--    var touchPrice3 = $("#touchPrice3").val();--%>
             <%--    var status = $("input[name='status']:checked").val();--%>
@@ -301,11 +314,11 @@
             <%--    var endTime = $("#endTime").val();--%>
             <%--    var delFlag1 = $("input[name='delFlag1']:checked").val();--%>
             <%--    window.location.href = "${ctx}/product/cmPromotions/form?type=1&productIds=" + productItems + "&giftIds=" + giftItems +--%>
-            <%--        "&delProductIds="+delProductIds+"&delGiftIds="+delGiftIds+ "&mode=" + mode +--%>
-            <%--        "&reducedPrice=" + reducedPrice + "&touchPrice1=" + touchPrice1 + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +--%>
+            <%--        "&delProductIds=" + delProductIds + "&delGiftIds=" + delGiftIds + "&mode=" + mode +--%>
+            <%--        "&reducedPrice=" + reducedPrice + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +--%>
             <%--        "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}" +--%>
             <%--        "&searchDbFlag=0";--%>
-            <%--},100)--%>
+            <%--}, 100)--%>
         }
 
         function getCheckedItems(type) {
@@ -363,7 +376,7 @@
                 <c:forEach items="${cmPromotion.promotionProducts}" var="product">
                     <tr id="product${product.productID}">
                         <th class="hide"><input class="check-item" type="checkbox" id="productCheckItem"
-                                                name="info" ${product.storeStatus?'':'checked'}
+                                                name="info" checked
                                                 value='${product.productID}'/></th>
                         <td><img src="${product.mainImage}" width="50px" height="50px"></td>
                         <td>${product.skuId}${product.name}</td>
@@ -452,7 +465,7 @@
                             <td>${product.skuId}</td>
                             <th class="hide"><input class="check-item" type="checkbox" id="giftCheckItem"
                                                     name="gift" ${product.storeStatus?'':'checked'}
-                                                    value='${product.skuId}'/></th>
+                                                    value='${product.productID}'/></th>
                             <td><img src="${product.mainImage}" width="50px" height="50px"></td>
                             <td>${product.name}</td>
                             <td>${product.unit}</td>