Browse Source

Merge remote-tracking branch 'origin/developerB' into developer

zhijiezhao 2 years ago
parent
commit
775ef6835a
31 changed files with 1162 additions and 549 deletions
  1. 3 0
      src/main/java/com/caimei/modules/bulkpurchase/dao/PurchaseProductDao.java
  2. 9 2
      src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java
  3. 37 13
      src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java
  4. 6 1
      src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java
  5. 9 4
      src/main/java/com/caimei/modules/order/service/NewOrderService.java
  6. 3 1
      src/main/java/com/caimei/modules/order/service/NewShopOrderService.java
  7. 8 2
      src/main/java/com/caimei/modules/order/utils/OrderUtil.java
  8. 4 1
      src/main/java/com/caimei/modules/order/web/NewOrderController.java
  9. 9 0
      src/main/java/com/caimei/modules/product/dao/CmPromotionDao.java
  10. 6 0
      src/main/java/com/caimei/modules/product/dao/ProductDao.java
  11. 12 0
      src/main/java/com/caimei/modules/product/entity/CmPromotion.java
  12. 28 1
      src/main/java/com/caimei/modules/product/entity/CmSku.java
  13. 28 17
      src/main/java/com/caimei/modules/product/service/CmPromotionService.java
  14. 9 0
      src/main/java/com/caimei/modules/product/web/CmPromotionController.java
  15. 11 0
      src/main/java/com/caimei/modules/svip/dao/CmSvipProductDao.java
  16. 22 1
      src/main/java/com/caimei/modules/svip/entity/CmSvipProduct.java
  17. 30 3
      src/main/java/com/caimei/modules/svip/service/CmSvipProductService.java
  18. 148 124
      src/main/java/com/caimei/modules/svip/web/CmSvipProductController.java
  19. 17 8
      src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml
  20. 23 0
      src/main/resources/mappings/modules/product/CmPromotionMapper.xml
  21. 27 5
      src/main/resources/mappings/modules/product/ProductMapper.xml
  22. 105 25
      src/main/resources/mappings/modules/svip/CmSvipProductMapper.xml
  23. 32 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductForm.jsp
  24. 40 9
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductList.jsp
  25. 81 31
      src/main/webapp/WEB-INF/views/modules/product-new/multiPromotionList.jsp
  26. 133 95
      src/main/webapp/WEB-INF/views/modules/product-new/singlePromotionForm.jsp
  27. 46 22
      src/main/webapp/WEB-INF/views/modules/product-new/singlePromotionList.jsp
  28. 262 179
      src/main/webapp/WEB-INF/views/modules/svip/cmSvipProductForm.jsp
  29. 9 1
      src/main/webapp/WEB-INF/views/modules/svip/cmSvipProductList.jsp
  30. 4 4
      src/main/webapp/WEB-INF/views/modules/svip/svipAddProduct.jsp
  31. 1 0
      src/main/webapp/static/modules/bulkpurchase/orderForm.js

+ 3 - 0
src/main/java/com/caimei/modules/bulkpurchase/dao/PurchaseProductDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.bulkpurchase.dao;
 
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.svip.entity.CmSvipProduct;
 import com.caimei.po.ProductLadderPrice;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
@@ -33,4 +34,6 @@ public interface PurchaseProductDao extends CrudDao<PurchaseProduct> {
     List<ProductLadderPrice> findLadderPriceList(Long productId);
 
     CmSvipProduct getSvipProduct(@Param("productId")Long productId, @Param("userId") Integer userId);
+
+    CmSku findVipSku(Long productId);
 }

+ 9 - 2
src/main/java/com/caimei/modules/bulkpurchase/web/CmRefundsProductController.java

@@ -12,6 +12,7 @@ import com.caimei.modules.order.dao.NewOrderProductDao;
 import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.service.*;
 import com.caimei.modules.product.dao.CmPromotionDao;
+import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.modules.user.dao.CmUserDao;
 import com.caimei.modules.user.entity.CmUser;
@@ -79,6 +80,8 @@ public class CmRefundsProductController extends BaseController {
     private NewOrderProductDao newOrderProductDao;
     @Resource
     private CmOfflineCollectionService cmOfflineCollectionService;
+    @Resource
+    private ProductDao productDao;
 
     @ModelAttribute
     public CmRefundsProduct get(@RequestParam(required = false) String id) {
@@ -224,7 +227,9 @@ public class CmRefundsProductController extends BaseController {
                                     isPromotions = true;
                                     //单品优惠
                                     if ("1".equals(promotions.getMode())) {
-                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - promotions.getTouchPrice()) * number;
+                                        //取对应sku的优惠价
+                                        Double touchPrice = productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - touchPrice) * number;
                                     }
                                 }
                             }
@@ -397,7 +402,9 @@ public class CmRefundsProductController extends BaseController {
                                     if (promotions != null) {
                                         //单品优惠
                                         if ("1".equals(promotions.getMode())) {
-                                            returnedPurchaseFee -= (orderProduct.getDiscountPrice() - promotions.getTouchPrice()) * number;
+                                            //取对应sku的优惠价
+                                            Double touchPrice = productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                            returnedPurchaseFee -= (orderProduct.getDiscountPrice() - touchPrice) * number;
                                         }
                                     }
                                 }

+ 37 - 13
src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java

@@ -111,6 +111,15 @@ public class PurchaseProductController extends BaseController {
                         s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
                     }
                 });
+                // 超级会员价赋值
+                if (null != skuList.get(0).getPriceType()) {
+                    p.setSvipPriceType(skuList.get(0).getPriceType());
+                    if (1 == skuList.get(0).getPriceType()) {
+                        p.setSvipDiscount(skuList.get(0).getDiscount());
+                    } else {
+                        p.setSvipDiscountPrice(skuList.get(0).getDiscountPrice());
+                    }
+                }
                 p.setSkuId(skuList.get(0).getSkuId());
                 p.setPrice(skuList.get(0).getPrice().toString());
                 if (1 == skuList.get(0).getLadderPriceFlag()) {
@@ -118,8 +127,6 @@ public class PurchaseProductController extends BaseController {
                     p.setLadderPriceList(productDao.findLadderPrice(skuList.get(0).getSkuId()));
                 }
                 p.setSkuList(skuList);
-                long productId = p.getProductId();
-                String discountPrice = p.getPrice();//默认折扣单价
                 if (priceFlag) {
                     p.setPrice(p.getNormalPrice());
                 }
@@ -153,18 +160,22 @@ public class PurchaseProductController extends BaseController {
                 // 初始化超级会员优惠
                 p.setSvipReduction(0d);
                 if (1 == p.getSvipPriceFlag()) {
-//                    if (1 == p.getSvipPriceType()) {
-//                        p.setSvipDiscountPrice(MathUtil.div(MathUtil.mul(new Double(p.getPrice()), p.getSvipDiscount()), 100, 2).doubleValue());
-//                    }
-                    // 商品的超级会员优惠=原价-超级会员优惠价
-//                    p.setSvipReduction(MathUtil.sub(p.getPrice(), p.getSvipDiscountPrice()).doubleValue());
-//                    if ("0".equals(p.getIncludedTax()) && ("1".equals(p.getInvoiceType()) || "2".equals(p.getInvoiceType()))) {
-//                        // 计算优惠的税费
-//                        BigDecimal taxReduction = MathUtil.div(MathUtil.mul(p.getSvipReduction(), p.getTaxRate()), 100);
-//                        p.setSvipReduction(MathUtil.add(p.getSvipReduction(), taxReduction).doubleValue());
-//                        p.setSvipTaxReduction(taxReduction.doubleValue());
-//                    }
+                    if (1 == p.getSvipPriceType()) {
+                        p.setSvipDiscountPrice(MathUtil.div(MathUtil.mul(new Double(p.getPrice()), p.getSvipDiscount()), 100, 2).doubleValue());
+                    }
+//                     商品的超级会员优惠=原价-超级会员优惠价
+                    p.setSvipReduction(MathUtil.sub(p.getPrice(), p.getSvipDiscountPrice()).doubleValue());
+                    if ("0".equals(p.getIncludedTax()) && ("1".equals(p.getInvoiceType()) || "2".equals(p.getInvoiceType()))) {
+                        // 计算优惠的税费
+                        BigDecimal taxReduction = MathUtil.div(MathUtil.mul(p.getSvipReduction(), p.getTaxRate()), 100);
+                        p.setSvipReduction(MathUtil.add(p.getSvipReduction(), taxReduction).doubleValue());
+                        p.setSvipTaxReduction(taxReduction.doubleValue());
+                    }
                 } else if (null != cmPromotion) {
+                    if ("1".equals(cmPromotion.getMode())) {
+                        // 优惠价取sku优惠价
+                        cmPromotion.setTouchPrice(skuList.get(0).getTouchPrice());
+                    }
                     p.setCmPromotion(cmPromotion);
                     p.setLadderPriceFlag(0);
                 }
@@ -347,6 +358,15 @@ public class PurchaseProductController extends BaseController {
                         s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
                     }
                 });
+                // 超级会员价赋值
+                if (null != skus.get(0).getPriceType()) {
+                    purchaseProduct.setPriceType(skus.get(0).getPriceType().toString());
+                    if (1 == skus.get(0).getPriceType()) {
+                        purchaseProduct.setDiscount(skus.get(0).getDiscount().toString());
+                    } else {
+                        purchaseProduct.setDiscountPrice(skus.get(0).getDiscountPrice().toString());
+                    }
+                }
                 purchaseProduct.setSkuList(skus);
                 CmSvipProduct svipProduct = purchaseProductService.getSvipProduct(purchaseProduct.getProductId(), purchaseProduct.getUserId());
                 CmPromotion productPromotion = cmPromotionService.findProductPromotion(product.getShopID().toString(), Long.parseLong(product.getProductID().toString()));
@@ -354,6 +374,10 @@ public class PurchaseProductController extends BaseController {
                     purchaseProduct.setSvipPriceFlag(1);
                     purchaseProduct.setSvipPriceType(svipProduct.getPriceType());
                 } else if (productPromotion != null) {
+                    // 优惠价的时候给赋值优惠价
+                    if("1".equals(productPromotion.getMode())){
+                        productPromotion.setTouchPrice(skus.get(0).getTouchPrice());
+                    }
                     purchaseProduct.setCmPromotion(productPromotion);
                 } else {
                     if (1 == skus.get(0).getLadderPriceFlag()) {

+ 6 - 1
src/main/java/com/caimei/modules/order/service/CmReturnedPurchaseService.java

@@ -11,6 +11,7 @@ import com.caimei.modules.order.entity.*;
 import com.caimei.modules.order.utils.*;
 import com.caimei.modules.product.dao.CmPromotionDao;
 import com.caimei.modules.product.dao.CmSecondHandDetailDao;
+import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.modules.user.dao.*;
 import com.caimei.modules.user.entity.CmUser;
@@ -65,6 +66,8 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
             .readTimeout(20, TimeUnit.SECONDS)
             .build();
 
+    @Resource
+    private ProductDao productDao;
     @Resource
     private CmReturnedPurchaseDao cmReturnedPurchaseDao;
     @Resource
@@ -222,7 +225,9 @@ public class CmReturnedPurchaseService extends CrudService<CmReturnedPurchaseDao
                                 if (promotions != null) {
                                     //单品优惠
                                     if ("1".equals(promotions.getMode())) {
-                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - promotions.getTouchPrice()) * number;
+                                        //取对应sku的优惠价
+                                        Double touchPrice = productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                        returnedPurchaseFee -= (orderProduct.getDiscountPrice() - touchPrice) * number;
                                     }
                                 }
                             }

+ 9 - 4
src/main/java/com/caimei/modules/order/service/NewOrderService.java

@@ -464,7 +464,9 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
                                     if ("1".equals(promotion.getType())) {
                                         // 优惠价
                                         if ("1".equals(promotion.getMode())) {
-                                            shopReducedPrice += (orderProduct.getPrice() - promotion.getTouchPrice()) * orderProduct.getNum();
+                                            // 单品优惠价取当前sku的优惠价
+                                            Double touchPrice=productDao.getTouchPriceBySku(orderProduct.getSkuId());
+                                            shopReducedPrice += (orderProduct.getPrice() - touchPrice) * orderProduct.getNum();
                                         }
                                         // 单品满减
                                         if ("2".equals(promotion.getMode())) {
@@ -1092,14 +1094,17 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
             if (("0".equals(product.getIncludedTax()) && ("1".equals(product.getInvoiceType()) || "2".equals(product.getInvoiceType()))) || "2".equals(product.getIncludedTax()) || "".equals(product.getIncludedTax())) {
                 BigDecimal addedValueTax = BigDecimal.ZERO;
                 if (promotions != null && "1".equals(promotions.getType()) && "1".equals(promotions.getMode())) {
-                    addedValueTax = MathUtil.div(MathUtil.mul(promotions.getTouchPrice(), o.getTaxRate()), BigDecimal.valueOf(100));
-                    price = MathUtil.add(promotions.getTouchPrice(), addedValueTax).doubleValue();
+                    //取对应sku的优惠价
+                    Double touchPrice = productDao.getTouchPriceBySku(o.getSkuId());
+                    addedValueTax = MathUtil.div(MathUtil.mul(touchPrice, o.getTaxRate()), BigDecimal.valueOf(100));
+                    price = MathUtil.add(touchPrice, addedValueTax).doubleValue();
                 } else {
                     addedValueTax = MathUtil.div(MathUtil.mul(price, o.getTaxRate()), BigDecimal.valueOf(100));
                     price = MathUtil.add(price, addedValueTax).doubleValue();
                 }
             } else if (promotions != null && "1".equals(promotions.getType()) && "1".equals(promotions.getMode())) {
-                price = promotions.getTouchPrice();
+                //取对应sku的优惠价
+                price = productDao.getTouchPriceBySku(o.getSkuId());
             }
             //通过比例成本价计算
             costPrice = MathUtil.mul(MathUtil.div(product.getCostProportional(), 100), price).floatValue();

+ 3 - 1
src/main/java/com/caimei/modules/order/service/NewShopOrderService.java

@@ -107,7 +107,9 @@ public class NewShopOrderService extends CrudService<NewShopOrderDao, NewShopOrd
                 if (bean.getOrderPromotionsId() != null) {
                     CmPromotion promotions = cmPromotionDao.findOrderPromotions(bean.getOrderPromotionsId());
                     if (promotions != null && "1".equals(promotions.getMode())) {
-                        bean.setDiscountPrice(promotions.getTouchPrice());
+                        //取对应sku的优惠价
+                        Double price = productDao.getTouchPriceBySku(bean.getSkuId());
+                        bean.setDiscountPrice(price);
                     }
                 }
                 listAll.add(bean);

+ 8 - 2
src/main/java/com/caimei/modules/order/utils/OrderUtil.java

@@ -4,14 +4,18 @@ package com.caimei.modules.order.utils;
 import com.caimei.modules.order.entity.NewOrder;
 import com.caimei.modules.order.entity.NewOrderProduct;
 import com.caimei.modules.order.entity.NewShopOrder;
+import com.caimei.modules.product.dao.ProductDao;
 import com.caimei.modules.product.entity.CmPromotion;
 import com.caimei.utils.MathUtil;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.*;
 
 public class OrderUtil {
 
+    @Resource
+    public static ProductDao productDao;
     /**
      * 获取主订单下的所有商品
      *
@@ -160,8 +164,10 @@ public class OrderUtil {
                     if ("1".equals(promotion.getType())) {
                         // 优惠价
                         if ("1".equals(promotion.getMode())) {
-                            shopReducedPrice += (o.getPrice() - promotion.getTouchPrice()) * o.getNum();
-                            productDiscount += (o.getPrice() - promotion.getTouchPrice()) * o.getNum();
+                            //取对应sku的优惠价
+                            Double price = productDao.getTouchPriceBySku(o.getSkuId());
+                            shopReducedPrice += (o.getPrice() - price) * o.getNum();
+                            productDiscount += (o.getPrice() - price) * o.getNum();
                         }
                         // 单品满减
                         if ("2".equals(promotion.getMode())) {

+ 4 - 1
src/main/java/com/caimei/modules/order/web/NewOrderController.java

@@ -447,6 +447,7 @@ public class NewOrderController extends BaseController {
                         }
                     } else {
                         if(null==o.getSkuId()){
+                            //赠品
                             o.setSkuId(productDao.findSkuIdByPromotionsId(o.getPromotionsId()));
                         }
                         o.setPreferential(0d);
@@ -574,7 +575,9 @@ public class NewOrderController extends BaseController {
                 if (o.getOrderPromotionsId() != null) {
                     CmPromotion promotions = cmPromotionDao.findOrderPromotions(o.getOrderPromotionsId());
                     if (promotions != null && "1".equals(promotions.getMode())) {
-                        o.setDiscountPrice(promotions.getTouchPrice());
+                        //取对应sku的优惠价
+                        Double price = productDao.getTouchPriceBySku(o.getSkuId());
+                        o.setDiscountPrice(price);
                     }
                 }
             });

+ 9 - 0
src/main/java/com/caimei/modules/product/dao/CmPromotionDao.java

@@ -3,6 +3,7 @@ package com.caimei.modules.product.dao;
 import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
 import com.caimei.modules.cibe.entity.Shop;
 import com.caimei.modules.product.entity.CmPromotion;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
@@ -101,4 +102,12 @@ public interface CmPromotionDao extends CrudDao<CmPromotion> {
     List<Integer> findProductIdsByPromotion(String promotionsId);
 
     void deletePromotion(@Param("id")String id,@Param("skuId") Integer skuId);
+
+    List<CmSku> getPromotionSkus(String id);
+
+    List<CmSku> getPromotionSkusByProduct(String productIds);
+
+    void deleteOldTouchPrice(String promotionId);
+
+    void insertNewTouchPrice(@Param("skuId")Integer skuId,@Param("touchPrice") Double touchPrice,@Param("promotionId")  String promotionId);
 }

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

@@ -223,4 +223,10 @@ public interface ProductDao extends CrudDao<Product> {
     void deleteProductSkus(@Param("skuIds")List<Integer> skuIds,@Param("productId")Integer productId);
 
     String findProductIdBySku(String productId);
+
+    Double getTouchPriceBySku(Integer skuId);
+
+    List<CmSku> findSkuByPromotion(String id);
+
+    List<CmSku> getSkuByPromotionId(String id);
 }

+ 12 - 0
src/main/java/com/caimei/modules/product/entity/CmPromotion.java

@@ -11,6 +11,10 @@ import java.util.List;
 
 public class CmPromotion extends DataEntity<CmPromotion> {
     private static final long serialVersionUID = 1L;
+    /**
+     * skus
+     */
+    private List<CmSku> skus;
 
     private String unit;
     /**
@@ -151,6 +155,14 @@ public class CmPromotion extends DataEntity<CmPromotion> {
      */
     private String searchDbFlag;
 
+    public List<CmSku> getSkus() {
+        return skus;
+    }
+
+    public void setSkus(List<CmSku> skus) {
+        this.skus = skus;
+    }
+
     public String getUnit() {
         return unit;
     }

+ 28 - 1
src/main/java/com/caimei/modules/product/entity/CmSku.java

@@ -16,6 +16,7 @@ import java.util.List;
 public class CmSku extends DataEntity<CmSku> {
     private Integer skuId;
     private Integer productId;
+    private Double touchPrice; //单品促销优惠价
     private String unit;        // 包装规格
     private Double normalPrice;        // 市场价
     private String stock;        // 库存
@@ -26,8 +27,34 @@ public class CmSku extends DataEntity<CmSku> {
     private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
     private Integer minBuyNumber;        // 无阶梯价起订量
     private Double collagePrice;   //拼团价
-    private Double discountPrice;  //限时特价
+    private Double discountPrice;  //限时特价(在采美超级会员商品中指超级会员价)
     private List<CmLadderPrice> ladderPriceList;
+    private Double discount;       //超级会员会员折扣
+    private Integer priceType;     //超级会员价类型:1折扣,2优惠价
+
+    public Double getTouchPrice() {
+        return touchPrice;
+    }
+
+    public void setTouchPrice(Double touchPrice) {
+        this.touchPrice = touchPrice;
+    }
+
+    public Integer getPriceType() {
+        return priceType;
+    }
+
+    public void setPriceType(Integer priceType) {
+        this.priceType = priceType;
+    }
+
+    public Double getDiscount() {
+        return discount;
+    }
+
+    public void setDiscount(Double discount) {
+        this.discount = discount;
+    }
 
     public Double getCollagePrice() {
         return collagePrice;

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

@@ -34,6 +34,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
     private CmPromotionDao cmPromotionDao;
     @Autowired
     private ProductDao productDao;
+
     @Override
     public CmPromotion get(String id) {
         return super.get(id);
@@ -50,8 +51,10 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         List<Product> giftProducts = new ArrayList<>();
         List<Shop> promotionShops = new ArrayList<>();
         if (CollectionUtils.isNotEmpty(promotionList)) {
-            for (CmPromotion promotion : promotionList
-            ) {
+            for (CmPromotion promotion : promotionList) {
+                if("1".equals(promotion.getMode())){
+                    promotion.setSkus(productDao.findSkuByPromotion(promotion.getId()));
+                }
                 if (StringUtils.isNotBlank(cmPromotion.getProductName())) {
                     promotion.setProductName(cmPromotion.getProductName());
                 }
@@ -77,13 +80,13 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
                                 //未开始
                                 promotion.setDelFlag1("1");
                             }
-                        }else {
+                        } else {
                             promotion.setDelFlag1("0");
                         }
                     }
-                }else if("1".equals(promotion.getDelFlag1())){
+                } else if ("1".equals(promotion.getDelFlag1())) {
                     promotion.setDelFlag1("0");
-                }else if("2".equals(promotion.getDelFlag1())){
+                } else if ("2".equals(promotion.getDelFlag1())) {
                     promotion.setDelFlag1("4");
                 }
                 //非店铺促销下设置促销产品
@@ -91,7 +94,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
                     //根据促销id和商品名查询
                     promotionProducts = findPromotionProduct(promotion);
                     promotion.setPromotionProducts(promotionProducts);
-                }else {
+                } else {
                     promotionShops = findPromotionShops(promotion);
                     promotion.setPromotionShops(promotionShops);
                 }
@@ -134,6 +137,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         String wwwServer = Global.getConfig("wwwServer");
         for (Product product : products) {
             if (product != null) {
+                product.setSkuList(productDao.findSkuList(product.getProductID()));
                 product.setStoreStatus(true);
                 product.setMainImage(AppUtils.getImageURL("product", product.getMainImage(), 0, wwwServer));
             }
@@ -159,7 +163,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
     /**
      * 根据促销活动id查询促销赠品(订单)
      */
-    public List<PurchaseProduct> findGiftPurchaseProduct(String id){
+    public List<PurchaseProduct> findGiftPurchaseProduct(String id) {
         List<PurchaseProduct> list = cmPromotionDao.findGiftPurchaseProduct(id);
         for (PurchaseProduct p : list) {
             if (p != null) {
@@ -186,6 +190,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         }
         return list;
     }
+
     /**
      * 查询促销可用商品
      */
@@ -216,7 +221,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
                         delList.add(Integer.parseInt(productId));
                     }
                 }
-            }else {
+            } else {
                 delList.add(Integer.parseInt(product.getDelProductIds()));
             }
         }
@@ -225,7 +230,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         //当选择促销商品时,需要排除掉相同促销类型下已参与促销的商品
         productList = cmPromotionDao.findAllProduct(product);
         String wwwServer = Global.getConfig("wwwServer");
-        productList.forEach(item ->{
+        productList.forEach(item -> {
             List<CmSku> skuList = productDao.findSkuList(item.getProductID());
             List<CmSku> collect = skuList.stream().sorted(Comparator.comparing(CmSku::getPrice)).collect(Collectors.toList());
             item.setSkuList(collect);
@@ -242,7 +247,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
     public Page findShopPage(Page<Shop> shopPage, Shop shop) {
         shop.setPage(shopPage);
         List<Integer> list = new ArrayList<>();
-        if (StringUtil.isNotBlank(shop.getShopIds()) ) {
+        if (StringUtil.isNotBlank(shop.getShopIds())) {
             if (shop.getShopIds().contains(",")) {
                 String[] split = shop.getShopIds().split(",");
                 for (String shopId : split) {
@@ -283,19 +288,19 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         }
         cmPromotion.setUpdateTime(new Date());
         if (StringUtils.isNotBlank(cmPromotion.getType()) && StringUtils.isNotBlank(cmPromotion.getMode())) {
-            if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())){
+            if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())) {
                 // 优惠价
                 cmPromotion.setName("优惠价");
-            }else{
+            } else {
                 String type = "1".equals(cmPromotion.getType()) ? "单品" : "2".equals(cmPromotion.getType()) ? "凑单" : "3".equals(cmPromotion.getType()) ? "店铺" : "优惠";
                 String mode = "2".equals(cmPromotion.getMode()) ? "满减" : "3".equals(cmPromotion.getMode()) ? "满赠" : "优惠";
                 cmPromotion.setName(type + mode);
             }
         }
-        if (cmPromotion.getIsNewRecord()){
+        if (cmPromotion.getIsNewRecord()) {
             cmPromotion.preInsert();
             cmPromotionDao.insert(cmPromotion);
-        }else{
+        } else {
             cmPromotion.preUpdate();
             cmPromotionDao.update(cmPromotion);
         }
@@ -303,6 +308,12 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         //删除数据库中该促销活动原来的商品、赠品和商店
         cmPromotionDao.deleteAllPromotionProductsAndShops(promotionId);
         cmPromotionDao.deleteAllPromotionGifts(promotionId);
+        if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())) {
+            // 单品优惠价的时候,删除优惠商品之前的优惠价(新增保存不会删除)
+            cmPromotionDao.deleteOldTouchPrice(promotionId);
+            // 保存新的sku优惠价
+            cmPromotion.getSkus().forEach(s -> cmPromotionDao.insertNewTouchPrice(s.getSkuId(), s.getTouchPrice(), promotionId));
+        }
 
         if (StringUtil.isNotBlank(cmPromotion.getProductIds())) {
             List<HashMap> list = JSONArray.parseArray(cmPromotion.getProductIds(), HashMap.class);
@@ -339,17 +350,17 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
      * 查询供应商信息
      */
     public Shop findShop(String shopId) {
-       return cmPromotionDao.findShop(shopId);
+        return cmPromotionDao.findShop(shopId);
     }
 
     /**
      * 查询产品对应的促销活动
      */
     public CmPromotion findProductPromotion(String shopId, Long productId) {
-         return cmPromotionDao.findProductPromotion(shopId, productId);
+        return cmPromotionDao.findProductPromotion(shopId, productId);
     }
 
     public void delPromotion(String id, Integer skuId) {
-        cmPromotionDao.deletePromotion(id,skuId);
+        cmPromotionDao.deletePromotion(id, skuId);
     }
 }

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

@@ -141,6 +141,15 @@ 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())){
+                    //单品优惠价的时候给优惠商品的skus赋值
+                    cmPromotion.setSkus(cmPromotionDao.getPromotionSkus(cmPromotion.getId()));
+                }else{
+                    //新增单品促销的时候没有id
+                    cmPromotion.setSkus(cmPromotionDao.getPromotionSkusByProduct(cmPromotion.getProductIds()));
+                }
+            }
             //表单选择商品或供应商后刷新时设置促销状态
             if ("close".equals(cmPromotion.getDelFlag1())) {
                 cmPromotion.setDelFlag1("0");

+ 11 - 0
src/main/java/com/caimei/modules/svip/dao/CmSvipProductDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.svip.dao;
 
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.svip.entity.CmSvipProductAdsImage;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
@@ -26,4 +27,14 @@ public interface CmSvipProductDao extends CrudDao<CmSvipProduct> {
     CmSvipProductAdsImage getAdsImage();
 
     void saveAdsImage(CmSvipProductAdsImage adsImage);
+
+    void insertSkuPrice(CmSku s);
+
+    void deleteByProductId(Integer productId);
+
+    void deleteById(String id);
+
+    CmSku getSvipSku(Integer skuId);
+
+    CmSku findSvipSku(Integer productId);
 }

+ 22 - 1
src/main/java/com/caimei/modules/svip/entity/CmSvipProduct.java

@@ -2,6 +2,9 @@ package com.caimei.modules.svip.entity;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
+
+import com.caimei.modules.product.entity.CmSku;
 import com.fasterxml.jackson.annotation.JsonFormat;
 
 import com.thinkgem.jeesite.common.persistence.DataEntity;
@@ -33,7 +36,25 @@ public class CmSvipProduct extends DataEntity<CmSvipProduct> {
 	private String costProportional;        // 比例成本百分比
 	private String costCheckFlag;        // 成本价选中标志:1固定成本 2比例成
 	private Integer svipPriceFlag;		//超级会员价标识
-	
+	private Integer status;            // 优惠状态 1已下架 0已上架
+	private List<CmSku> skus;        //商品sku
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public List<CmSku> getSkus() {
+		return skus;
+	}
+
+	public void setSkus(List<CmSku> skus) {
+		this.skus = skus;
+	}
+
 	public CmSvipProduct() {
 		super();
 	}

+ 30 - 3
src/main/java/com/caimei/modules/svip/service/CmSvipProductService.java

@@ -62,6 +62,12 @@ public class CmSvipProductService extends CrudService<CmSvipProductDao, CmSvipPr
         String wwwServer = Global.getConfig("wwwServer");
         list.forEach(product -> {
             CmSku sku = productDao.findSku(product.getProductId());
+            CmSku skuPrice = cmSvipProductDao.findSvipSku(product.getProductId());
+            if (null != skuPrice) {
+                product.setPriceType(skuPrice.getPriceType());
+                product.setDiscount(BigDecimal.valueOf(skuPrice.getDiscount()));
+                product.setDiscountPrice(BigDecimal.valueOf(skuPrice.getDiscountPrice()));
+            }
             product.setPrice(BigDecimal.valueOf(sku.getPrice()));
             if (StringUtil.isNotBlank(product.getProductImage())) {
                 product.setProductImage(AppUtils.getImageURL("product", product.getProductImage(), 0, wwwServer));
@@ -72,16 +78,31 @@ public class CmSvipProductService extends CrudService<CmSvipProductDao, CmSvipPr
 
     @Transactional(readOnly = false)
     public void save(CmSvipProduct cmSvipProduct) {
+        //保存/修改同步处理cm_svip_product_sku表数据
         if (cmSvipProduct.getIsNewRecord()) {
-            Integer priceType = null == cmSvipProduct.getDiscount() ? 2 : 1;
-            cmSvipProduct.setPriceType(priceType);
             cmSvipProduct.setSort(1);
+            cmSvipProduct.setStatus(1);
+        } else {
+            //删除旧sku价格,插入新的
+            cmSvipProductDao.deleteByProductId(cmSvipProduct.getProductId());
+        }
+        //保存不同sku的优惠折扣
+        List<CmSku> skus = cmSvipProduct.getSkus();
+        if (null != skus && skus.size() > 0) {
+            skus.forEach(s -> {
+                Integer priceType = null == s.getDiscount() || 0 == s.getDiscount() ? 2 : 1;
+                s.setPriceType(priceType);
+                s.setProductId(cmSvipProduct.getProductId());
+                cmSvipProductDao.insertSkuPrice(s);
+            });
         }
         super.save(cmSvipProduct);
     }
 
     @Transactional(readOnly = false)
     public void delete(CmSvipProduct cmSvipProduct) {
+        //同时删除sku价格
+        cmSvipProductDao.deleteById(cmSvipProduct.getId());
         super.delete(cmSvipProduct);
     }
 
@@ -95,7 +116,9 @@ public class CmSvipProductService extends CrudService<CmSvipProductDao, CmSvipPr
         String wwwServer = Global.getConfig("wwwServer");
         productList.forEach(item -> {
             CmSku sku = productDao.findSku(item.getProductID());
-            item.setPrice(sku.getPrice());
+            if (null != sku) {
+                item.setPrice(sku.getPrice());
+            }
             if (StringUtil.isNotBlank(item.getMainImage())) {
                 item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
             }
@@ -120,4 +143,8 @@ public class CmSvipProductService extends CrudService<CmSvipProductDao, CmSvipPr
     public void saveAdsImage(CmSvipProductAdsImage adsImage) {
         cmSvipProductDao.saveAdsImage(adsImage);
     }
+
+    public CmSku getSvipSku(Integer skuId) {
+        return cmSvipProductDao.getSvipSku(skuId);
+    }
 }

+ 148 - 124
src/main/java/com/caimei/modules/svip/web/CmSvipProductController.java

@@ -5,7 +5,10 @@ import javax.servlet.http.HttpServletResponse;
 
 import com.caimei.modules.live.entity.NewPageLiveAdvertisingImage;
 import com.caimei.modules.miniprogram.utils.UploadPicUtils;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.product.service.ProductService;
+import com.caimei.modules.svip.dao.CmSvipProductDao;
 import com.caimei.modules.svip.entity.CmSvipProductAdsImage;
 import com.caimei.utils.MathUtil;
 import com.google.common.collect.Maps;
@@ -27,12 +30,14 @@ import com.caimei.modules.svip.entity.CmSvipProduct;
 import com.caimei.modules.svip.service.CmSvipProductService;
 
 import java.math.BigDecimal;
+import java.util.List;
 import java.util.Map;
 
 import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
 
 /**
  * 超级会员优惠商品Controller
+ *
  * @author Aslee
  * @version 2021-09-23
  */
@@ -40,128 +45,147 @@ import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.is
 @RequestMapping(value = "${adminPath}/svip/cmSvipProduct")
 public class CmSvipProductController extends BaseController {
 
-	@Autowired
-	private CmSvipProductService cmSvipProductService;
-	
-	@ModelAttribute
-	public CmSvipProduct get(@RequestParam(required=false) String id) {
-		CmSvipProduct entity = null;
-		if (StringUtils.isNotBlank(id)){
-			entity = cmSvipProductService.get(id);
-		}
-		if (entity == null){
-			entity = new CmSvipProduct();
-		}
-		return entity;
-	}
-
-	@RequestMapping(value = {"list", ""})
-	public String list(CmSvipProduct cmSvipProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
-		Page<CmSvipProduct> page = cmSvipProductService.findPage(new Page<CmSvipProduct>(request, response), cmSvipProduct); 
-		model.addAttribute("page", page);
-		return "modules/svip/cmSvipProductList";
-	}
-
-	@RequestMapping(value = "form")
-	public String form(CmSvipProduct cmSvipProduct, Model model) {
-		model.addAttribute("cmSvipProduct", cmSvipProduct);
-		if ("2".equals(cmSvipProduct.getCostCheckFlag())) {
-			BigDecimal mul = MathUtil.mul(cmSvipProduct.getPrice(), new BigDecimal(cmSvipProduct.getCostProportional()));
-			cmSvipProduct.setCostPrice(MathUtil.mul(mul, new BigDecimal(0.01d)).toString());
-		}
-		return "modules/svip/cmSvipProductForm";
-	}
-
-	@RequestMapping(value = "save")
-	public String save(CmSvipProduct cmSvipProduct, Model model, RedirectAttributes redirectAttributes) {
-		if (!beanValidator(model, cmSvipProduct)){
-			return form(cmSvipProduct, model);
-		}
-		cmSvipProductService.save(cmSvipProduct);
-		addMessage(redirectAttributes, "保存商品成功");
-		return "redirect:"+Global.getAdminPath()+"/svip/cmSvipProduct/?repage";
-	}
-	
-	@RequestMapping(value = "delete")
-	public String delete(CmSvipProduct cmSvipProduct, RedirectAttributes redirectAttributes) {
-		cmSvipProductService.delete(cmSvipProduct);
-		addMessage(redirectAttributes, "删除商品成功");
-		return "redirect:"+Global.getAdminPath()+"/svip/cmSvipProduct/?repage";
-	}
-
-	@RequestMapping(value = "findProductPage")
-	public String findProductPage(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
-		Page<Product> page = cmSvipProductService.findProductPage(new Page<Product>(request, response), product);
-		model.addAttribute("page", page);
-		model.addAttribute("ids", product.getIds());
-		return "modules/svip/svipAddProduct";
-	}
-
-	/**
-	 * 批量更新排序值
-	 */
-	@RequestMapping(value = "batchSaveSort")
-	@ResponseBody
-	public Map<String, Object> batchSaveSort(String sortList) {
-		Map<String, Object> map = Maps.newLinkedHashMap();
-		try {
-			String[] svipProductList = sortList.split(",");
-			for (String list : svipProductList) {
-				String[] split = list.split("-");
-				if (split.length == 1 || split.length < 1) {
-					String id = split[0];
-					String sort = null;
-					cmSvipProductService.saveSort(sort, id);
-				} else {
-					String id = split[0];
-					String sort = split[1];
-					if (isInteger(sort)) {
-						if (StringUtils.equals("0", sort)) {
-							map.put("success", false);
-							map.put("msg", "排序值只能填写大于等于1的整数");
-							return map;
-						}
-						cmSvipProductService.saveSort(sort, id);
-					} else {
-						map.put("success", false);
-						map.put("msg", "排序值只能为数字");
-						return map;
-					}
-				}
-			}
-			map.put("success", true);
-			map.put("msg", "更新排序成功");
-			return map;
-		} catch (Exception e) {
-			e.printStackTrace();
-			map.put("success", false);
-			map.put("msg", "更新排序失败");
-			return map;
-		}
-	}
-
-	@RequestMapping(value = "adsImageForm")
-	public String adsImageForm(Model model){
-		CmSvipProductAdsImage cmSvipProductAdsImage = cmSvipProductService.getAdsImage();
-		model.addAttribute("adsImage", cmSvipProductAdsImage);
-		return "modules/svip/cmSvipProductAdsImageForm";
-	}
-
-	@RequestMapping(value = "saveAdsImage")
-	public String saveAdsImage(CmSvipProductAdsImage adsImage, Model model, RedirectAttributes redirectAttributes) {
-		if (StringUtils.isEmpty(adsImage.getPcImage())) {
-			model.addAttribute("errorMsg", "请上传PC端宣传图");
-			return adsImageForm(model);
-		} else if (StringUtils.isEmpty(adsImage.getAppletsImage())) {
-			model.addAttribute("errorMsg", "请上传小程序端宣传图");
-			return adsImageForm(model);
-		}
-		String pcImageUrl = UploadPicUtils.saveImageToServer(adsImage.getPcImage());
-		String appletsImageUrl = UploadPicUtils.saveImageToServer(adsImage.getAppletsImage());
-		adsImage.setPcImage(pcImageUrl);
-		adsImage.setAppletsImage(appletsImageUrl);
-		cmSvipProductService.saveAdsImage(adsImage);
-		addMessage(redirectAttributes, "保存成功");
-		return "redirect:"+Global.getAdminPath()+"/svip/cmSvipProduct/?repage";
-	}
+    @Autowired
+    private CmSvipProductService cmSvipProductService;
+
+    @Autowired
+    private ProductService productService;
+
+    @Autowired
+    private CmSvipProductDao vipDao;
+
+    @ModelAttribute
+    public CmSvipProduct get(@RequestParam(required = false) String id) {
+        CmSvipProduct entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = cmSvipProductService.get(id);
+        }
+        if (entity == null) {
+            entity = new CmSvipProduct();
+        }
+        return entity;
+    }
+
+    @RequestMapping(value = {"list", ""})
+    public String list(CmSvipProduct cmSvipProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmSvipProduct> page = cmSvipProductService.findPage(new Page<CmSvipProduct>(request, response), cmSvipProduct);
+        model.addAttribute("page", page);
+        return "modules/svip/cmSvipProductList";
+    }
+
+    @RequestMapping(value = "form")
+    public String form(CmSvipProduct cmSvipProduct, Model model) {
+        List<CmSku> skuList = productService.findSkuList(cmSvipProduct.getProductId());
+        if (null != skuList && skuList.size() > 0) {
+            skuList.forEach(s -> {
+                CmSku svipSku = cmSvipProductService.getSvipSku(s.getSkuId());
+                if (null != svipSku) {
+                    s.setDiscount(svipSku.getDiscount());
+                    s.setDiscountPrice(svipSku.getDiscountPrice());
+                    s.setPriceType(svipSku.getPriceType());
+                }
+            });
+        }
+        cmSvipProduct.setSkus(skuList);
+        model.addAttribute("cmSvipProduct", cmSvipProduct);
+        if ("2".equals(cmSvipProduct.getCostCheckFlag())) {
+            BigDecimal mul = MathUtil.mul(cmSvipProduct.getPrice(), new BigDecimal(cmSvipProduct.getCostProportional()));
+            cmSvipProduct.setCostPrice(MathUtil.mul(mul, new BigDecimal(0.01d)).toString());
+        }
+        return "modules/svip/cmSvipProductForm";
+    }
+
+    @RequestMapping(value = "save")
+    public String save(CmSvipProduct cmSvipProduct, Model model, RedirectAttributes redirectAttributes) {
+        if (!beanValidator(model, cmSvipProduct)) {
+            return form(cmSvipProduct, model);
+        }
+        //校验是否存在
+        cmSvipProductService.save(cmSvipProduct);
+        addMessage(redirectAttributes, "保存商品成功");
+        return "redirect:" + Global.getAdminPath() + "/svip/cmSvipProduct/?repage";
+    }
+
+    @RequestMapping(value = "delete")
+    public String delete(CmSvipProduct cmSvipProduct, RedirectAttributes redirectAttributes) {
+        cmSvipProductService.delete(cmSvipProduct);
+        addMessage(redirectAttributes, "删除商品成功");
+        return "redirect:" + Global.getAdminPath() + "/svip/cmSvipProduct/?repage";
+    }
+
+    @RequestMapping(value = "findProductPage")
+    public String findProductPage(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+        Page<Product> page = cmSvipProductService.findProductPage(new Page<Product>(request, response), product);
+        model.addAttribute("page", page);
+        model.addAttribute("ids", product.getIds());
+        return "modules/svip/svipAddProduct";
+    }
+
+    /**
+     * 批量更新排序值
+     */
+    @RequestMapping(value = "batchSaveSort")
+    @ResponseBody
+    public Map<String, Object> batchSaveSort(String sortList) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[] svipProductList = sortList.split(",");
+            for (String list : svipProductList) {
+                String[] split = list.split("-");
+                if (split.length == 1 || split.length < 1) {
+                    String id = split[0];
+                    String sort = null;
+                    cmSvipProductService.saveSort(sort, id);
+                } else {
+                    String id = split[0];
+                    String sort = split[1];
+                    if (isInteger(sort)) {
+                        if (StringUtils.equals("0", sort)) {
+                            map.put("success", false);
+                            map.put("msg", "排序值只能填写大于等于1的整数");
+                            return map;
+                        }
+                        cmSvipProductService.saveSort(sort, id);
+                    } else {
+                        map.put("success", false);
+                        map.put("msg", "排序值只能为数字");
+                        return map;
+                    }
+                }
+            }
+            map.put("success", true);
+            map.put("msg", "更新排序成功");
+            return map;
+        } catch (Exception e) {
+            e.printStackTrace();
+            map.put("success", false);
+            map.put("msg", "更新排序失败");
+            return map;
+        }
+    }
+
+    @RequestMapping(value = "adsImageForm")
+    public String adsImageForm(Model model) {
+        CmSvipProductAdsImage cmSvipProductAdsImage = cmSvipProductService.getAdsImage();
+        model.addAttribute("adsImage", cmSvipProductAdsImage);
+        return "modules/svip/cmSvipProductAdsImageForm";
+    }
+
+    @RequestMapping(value = "saveAdsImage")
+    public String saveAdsImage(CmSvipProductAdsImage adsImage, Model model, RedirectAttributes redirectAttributes) {
+        if (StringUtils.isEmpty(adsImage.getPcImage())) {
+            model.addAttribute("errorMsg", "请上传PC端宣传图");
+            return adsImageForm(model);
+        } else if (StringUtils.isEmpty(adsImage.getAppletsImage())) {
+            model.addAttribute("errorMsg", "请上传小程序端宣传图");
+            return adsImageForm(model);
+        }
+        String pcImageUrl = UploadPicUtils.saveImageToServer(adsImage.getPcImage());
+        String appletsImageUrl = UploadPicUtils.saveImageToServer(adsImage.getAppletsImage());
+        adsImage.setPcImage(pcImageUrl);
+        adsImage.setAppletsImage(appletsImageUrl);
+        cmSvipProductService.saveAdsImage(adsImage);
+        addMessage(redirectAttributes, "保存成功");
+        return "redirect:" + Global.getAdminPath() + "/svip/cmSvipProduct/?repage";
+    }
 }

+ 17 - 8
src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml

@@ -44,9 +44,7 @@
         SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
         a.`productID` productId,a.productCode productNo,a.mainImage image,a.includedTax AS includedTax,
         a.invoiceType AS invoiceType, a.taxPoint AS taxRate, a.supplierTaxPoint AS supplierTaxRate, a.commodityType,
-        if(csp.id is not null and csu.id is not null,1,0) as svipPriceFlag,
-        csp.priceType as svipPriceType,csp.discount as svipDiscount,
-        csp.discountPrice as svipDiscountPrice
+        if(csp.id is not null and csu.id is not null and csp.status=0,1,0) as svipPriceFlag
         FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
         left join cm_svip_product csp on a.productID = csp.productId
         left join cm_svip_user csu on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
@@ -118,7 +116,10 @@
                 #{cmFee})
     </insert>
     <select id="getPurchaseProductByCtId" resultMap="resultShop">
-        SELECT a.*, b.name shopName, c.name, c.price
+        SELECT a.*,
+               b.name                                                                                 shopName,
+               c.name,
+               (select price from cm_sku where productId = c.productID order by price asc limit 1) as "price"
         FROM bp_product a
                  LEFT JOIN shop b ON a.shopId = b.`shopID`
                  JOIN product c ON a.productId = c.productid
@@ -196,19 +197,27 @@
         ORDER BY ladderNum ASC
     </select>
     <select id="checkSvipProduct" resultType="java.lang.Integer">
-        select if(csp.id is not null and csu.id is not null, 1, 0) as svipPriceFlag
+        select if(csp.id is not null and csu.id is not null and csp.status=0, 1, 0) as svipPriceFlag
         from cm_svip_product csp
                  left join cm_svip_user csu
                            on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
         where csp.productId = #{productId};
     </select>
     <select id="getSvipProduct" resultType="com.caimei.modules.svip.entity.CmSvipProduct">
-        select csp.priceType,
-               if(csp.id is not null and csu.id is not null, 1, 0) as svipPriceFlag
+        select ccs.priceType,
+               if(csp.id is not null and csu.id is not null and csp.status=0, 1, 0) as svipPriceFlag
         from cm_svip_product csp
                  left join cm_svip_user csu
                            on csu.userId = #{userId} and csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
+        left join (select csps.productId,csps.priceType from cm_svip_product_sku csps left join cm_sku cs on csps.skuId=cs.skuId
+            where csps.productId=#{productId} order by cs.price asc limit 1) ccs on csp.productId=ccs.productId
         where csp.productId = #{productId};
-
+    </select>
+    <select id="findVipSku" resultType="com.caimei.modules.product.entity.CmSku">
+        select discountPrice,discount,priceType
+        from cm_svip_product_sku csps
+        left join cm_sku cs on csps.productId = cs.productId
+        where csps.productId=#{productId}
+        order by cs.price asc limit 1
     </select>
 </mapper>

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

@@ -324,6 +324,11 @@
                 #{seen})
     </insert>
 
+    <insert id="insertNewTouchPrice">
+        insert into cm_promotion_sku(promotionId, skuId, productId, touchPrice)
+        values (#{promotionId},#{skuId},(select productId from cm_sku where skuId=#{skuId}),#{touchPrice})
+    </insert>
+
 
     <update id="update">
         UPDATE cm_promotions
@@ -440,9 +445,27 @@
         from product
         where shopID in (select supplierId from cm_promotions_product where promotionsId = #{promotionsId})
     </select>
+    <select id="getPromotionSkus" resultType="com.caimei.modules.product.entity.CmSku">
+        SELECT DISTINCT cs.unit,cs.costCheckFlag,cs.costPrice,cs.costProportional,cps.touchPrice,cs.skuId
+        FROM cm_promotions cp
+        LEFT JOIN cm_promotions_product cpp ON cp.id=cpp.promotionsId
+        LEFT JOIN cm_sku cs ON cpp.productId=cs.productId
+        LEFT JOIN cm_promotion_sku cps ON cs.skuId=cps.skuId
+        WHERE cp.id=#{id}
+    </select>
+    <select id="getPromotionSkusByProduct" resultType="com.caimei.modules.product.entity.CmSku">
+        SELECT cs.unit,cs.costCheckFlag,cs.costPrice,cs.costProportional,cps.touchPrice,cs.skuId
+        FROM  cm_sku cs
+        LEFT JOIN cm_promotion_sku cps ON cs.skuId=cps.skuId
+        WHERE cs.productId=#{productIds}
+    </select>
     <delete id="deletePromotion">
         delete from cm_promotions_gift
         where promotionsId=#{id}
         and skuId=#{skuId}
     </delete>
+    <delete id="deleteOldTouchPrice">
+        delete from cm_promotion_sku
+        where promotionId = #{promotionId}
+    </delete>
 </mapper>

+ 27 - 5
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -2008,8 +2008,8 @@
         where shopId = #{shopID}
     </select>
     <select id="findSkuList" resultType="com.caimei.modules.product.entity.CmSku">
-        select skuId,
-               productId,
+        select cs.skuId,
+               cs.productId,
                unit,
                normalPrice,
                stock,
@@ -2018,9 +2018,15 @@
                costPrice,
                price,
                ladderPriceFlag,
-               minBuyNumber
-        from cm_sku
-        where productId = #{productID}
+               minBuyNumber,
+               cps.touchPrice,
+               csps.discount,
+               csps.discountPrice,
+               csps.priceType
+        from cm_sku cs
+        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}
     </select>
     <select id="findLadderPriceBySku" resultType="com.caimei.modules.product.entity.CmLadderPrice">
         select skuId, productId, userType, ladderNum, buyNum, buyPrice, delFlag
@@ -2087,4 +2093,20 @@
         from cm_promotions_gift
         where promotionsId = #{promotionsId}
     </select>
+    <select id="getTouchPriceBySku" resultType="java.lang.Double">
+        select touchPrice from cm_promotion_sku
+        where skuId=#{skuId}
+    </select>
+    <select id="findSkuByPromotion" resultType="com.caimei.modules.product.entity.CmSku">
+        SELECT cs.price,cps.skuId,cps.touchPrice,cs.unit
+        FROM cm_promotion_sku cps
+        LEFT JOIN cm_sku cs ON cps.skuId=cs.skuId
+        WHERE promotionId=#{id}
+    </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}
+    </select>
 </mapper>

+ 105 - 25
src/main/resources/mappings/modules/svip/CmSvipProductMapper.xml

@@ -5,11 +5,12 @@
     <sql id="cmSvipProductColumns">
         a.id AS "id",
 		a.productId AS "productId",
-		a.priceType AS "priceType",
-		a.discount AS "discount",
-		a.discountPrice AS "discountPrice",
+		ccs.priceType AS "priceType",
+		ccs.discount AS "discount",
+		ccs.discountPrice AS "discountPrice",
 		a.sort AS "sort",
 		a.addTime AS "addTime",
+        a.status as "status",
         p.mainImage as "productImage",
         p.name as "productName",
 		s.name as "shopName",
@@ -22,7 +23,31 @@
     <sql id="cmSvipProductJoins">
         left join product p on a.productId = p.productID
 		left join shop s on s.shopID = p.shopID
-	</sql>
+        LEFT JOIN (SELECT csps.priceType,csps.discount,csps.discountPrice,csps.productId
+                    FROM cm_svip_product_sku csps
+                LEFT JOIN cm_sku cs ON csps.skuId=cs.skuId
+                WHERE csps.productId = (SELECT productId FROM cm_svip_product WHERE id=
+        #{id}
+        )
+        ORDER
+        BY
+        cs
+        .
+        price
+        ASC
+        LIMIT
+        1
+        )
+        ccs
+        ON
+        a
+        .
+        productId
+        =
+        ccs
+        .
+        productId
+    </sql>
 
     <select id="get" resultType="CmSvipProduct">
         SELECT
@@ -34,9 +59,21 @@
 
     <select id="findList" resultType="CmSvipProduct">
         SELECT
-        <include refid="cmSvipProductColumns"/>
+        a.id AS "id",
+        a.productId AS "productId",
+        a.sort AS "sort",
+        a.addTime AS "addTime",
+        a.status as "status",
+        p.mainImage as "productImage",
+        p.name as "productName",
+        s.name as "shopName",
+        p.includedTax,
+        p.invoiceType,
+        p.taxPoint,
+        p.supplierTaxPoint
         FROM cm_svip_product a
-        <include refid="cmSvipProductJoins"/>
+        left join product p on a.productId = p.productID
+        left join shop s on s.shopID = p.shopID
         <where>
             <if test="productId != null and productId != ''">
                 AND a.productId = #{productId}
@@ -47,6 +84,12 @@
             <if test="shopName != null and productId != ''">
                 AND s.name like concat('%',#{shopName},'%')
             </if>
+            <if test="status !=null and status == 0">
+                and a.status=0
+            </if>
+            <if test="status !=null and status !='' and status == 1">
+                and a.status=1
+            </if>
         </where>
         <choose>
             <when test="page !=null and page.orderBy != null and page.orderBy != ''">
@@ -74,10 +117,12 @@
             </otherwise>
         </choose>
     </select>
+
     <select id="findSvipProductIds" resultType="java.lang.Integer">
         select productId
         from cm_svip_product;
     </select>
+
     <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
         SELECT
         a.productId,a.mainImage,a.name,s.name AS "shopName"
@@ -85,7 +130,7 @@
         LEFT JOIN shop s on s.shopID = a.shopID
         <where>
             a.validFlag = '2' and a.productCategory = '1'
-             and a.productID not in (
+            and a.productID not in (
             select productId from cm_promotions_product cpp left join
             cm_promotions cp on cpp.promotionsId = cp.id where cp.delFlag != '2')
             and priceFlag != '1'
@@ -115,38 +160,61 @@
             </otherwise>
         </choose>
     </select>
+
     <select id="getAdsImage" resultType="com.caimei.modules.svip.entity.CmSvipProductAdsImage">
-        select id,pcImage,appletsImage from cm_svip_product_adsimage limit 1
+        select id, pcImage, appletsImage
+        from cm_svip_product_adsimage
+        limit 1
+    </select>
+
+    <select id="getSvipSku" resultType="com.caimei.modules.product.entity.CmSku">
+        SELECT skuId,
+               priceType,
+               discount,
+               discountPrice
+        FROM cm_svip_product_sku
+        where skuId = #{skuId}
+    </select>
+    <select id="findSvipSku" resultType="com.caimei.modules.product.entity.CmSku">
+        select ifnull(discountPrice, 0) as "discountPrice",
+               ifnull(discount, 0)      as "discount",
+               ifnull(priceType, 0)     as "priceType"
+        from cm_svip_product_sku csps
+        left join cm_sku cs on cs.productId = csps.productId
+        where csps.productId = #{productId}
+        order by cs.price asc
+        limit 1
     </select>
 
     <insert id="insert" parameterType="CmSvipProduct" keyProperty="id" useGeneratedKeys="true">
         INSERT INTO cm_svip_product(productId,
-                                    priceType,
-                                    discount,
-                                    discountPrice,
                                     sort,
-                                    addTime)
+                                    addTime,
+                                    status)
         VALUES (#{productId},
-                #{priceType},
-                #{discount},
-                #{discountPrice},
                 #{sort},
-                now())
+                now(),
+                #{status})
+    </insert>
+
+    <insert id="insertSkuPrice">
+        insert into cm_svip_product_sku(skuId, productId, priceType, discount, discountPrice)
+        values (#{skuId}, #{productId}, #{priceType}, #{discount}, #{discountPrice})
     </insert>
 
     <update id="update">
         UPDATE cm_svip_product
-        SET priceType     = #{priceType},
-            discount      = #{discount},
-            discountPrice = #{discountPrice},
-            sort          = #{sort}
+        SET sort   = #{sort},
+            status = #{status}
         WHERE id = #{id}
     </update>
-	<update id="saveSort">
-		UPDATE cm_svip_product SET
-			sort = #{sort}
-		WHERE id = #{id}
-	</update>
+
+    <update id="saveSort">
+        UPDATE cm_svip_product
+        SET sort = #{sort}
+        WHERE id = #{id}
+    </update>
+
     <update id="saveAdsImage">
         update cm_svip_product_adsimage
         set pcImage      = #{pcImage},
@@ -160,4 +228,16 @@
         WHERE id = #{id}
     </delete>
 
+    <delete id="deleteByProductId">
+        delete
+        from cm_svip_product_sku
+        where productId = #{productId}
+    </delete>
+
+    <delete id="deleteById">
+        delete
+        from cm_svip_product_sku
+        where productId = (select productId from cm_svip_product where id = #{id})
+    </delete>
+
 </mapper>

+ 32 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductForm.jsp

@@ -528,6 +528,38 @@
         $checkItem["totalAddedValueTax"] = tax * num;
         $("#addedValueTax0").val(tax);
         $("#totalAddedValueTax0").val(tax * num);
+        debugger;
+        var flag = $("#svipPriceFlag0").val() * 1;
+        if (1 === flag) {
+            var type = skus[skuIndex].priceType;
+            if (1 === type) {
+                //1折扣,2优惠价
+                var discount = skus[skuIndex].discount;
+                var oldPrice = skus[skuIndex].price;
+                var discountPrice = (discount * oldPrice / 100).toFixed(2);
+                $("#svipDiscountPrice0").html(discountPrice);
+                $("#discountPrice0").val(discountPrice);
+
+                $checkItem["discount"] = discount;
+                $checkItem["discountPrice"] = discountPrice;
+                $checkItem["discountPrice"] = discountPrice;
+                $checkItem["svipReduction"] = oldPrice - discountPrice;
+                $("#svipReduction0").val(oldPrice - discountPrice);
+                base = discountPrice;
+            } else {
+                $("#svipDiscountPrice0").html(skus[skuIndex].discountPrice);
+                $("#discountPrice0").val(skus[skuIndex].discountPrice);
+                $checkItem["discountPrice"] = skus[skuIndex].discountPrice;
+                $checkItem["svipReduction"] = skus[skuIndex].price - skus[skuIndex].discountPrice;
+                $("#svipReduction0").val(skus[skuIndex].price - skus[skuIndex].discountPrice);
+                base = skus[skuIndex].discountPrice;
+            }
+        } else if (skus[skuIndex].touchPrice) {
+            base = skus[skuIndex].touchPrice;
+            $("#touchPrice0").val(skus[skuIndex].touchPrice);
+            $checkItem["touchPrice"] = skus[skuIndex].touchPrice;
+            $checkItem["cmPromotion"]["touchPrice"] = skus[skuIndex].touchPrice;
+        }
         var total = base * num;
         $("#totalFee0").val(total);
         $checkItem["totalFee"] = total;

+ 40 - 9
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderPurchaseProductList.jsp

@@ -300,13 +300,12 @@
             var totalFee = "#" + "totalFee" + ind;
             var skus = JSON.parse($("#hideSkus").val());
             var skuIndex = skuStr.split("/")[1];
-            debugger;
             console.log(skus[skuIndex].skuId);
-            $checkItem["skuId"] =skus[skuIndex].skuId;
+            $checkItem["skuId"] = skus[skuIndex].skuId;
             $("#skuId" + ind).text(skus[skuIndex].skuId);
             //页面价格赋值
             document.getElementById(price).innerHTML = skus[skuIndex].price;
-            $("#price"+ind).val(skus[skuIndex].price);
+            $("#price" + ind).val(skus[skuIndex].price);
             $(singlePrice).val(skus[skuIndex].price);
             $(totalFee).val(skus[skuIndex].price);
             var discount = $checkItem["discount"];
@@ -320,23 +319,23 @@
             var taxRate = $checkItem["taxRate"];
             var productId = $checkItem["productId"];
             var num = $checkItem["num"];
-            var includedTax=$checkItem["includedTax"];
-            var base =skus[skuIndex].price* discount / 100;
+            var includedTax = $checkItem["includedTax"];
+            var base = skus[skuIndex].price * discount / 100;
             if (productId >= 6060 && productId <= 6069) {
                 tax = 0;
-            } else if ("3"===invoiceType) {
+            } else if ("3" === invoiceType) {
                 tax = "---";
             } else {
                 tax = discountPrice * taxRate / 100;
-                if("0"===includedTax){
+                if ("0" === includedTax) {
                     base += discountPrice * taxRate / 100;
                 }
             }
-            if(1==skus[skuIndex].ladderPriceFlag){
+            if (1 == skus[skuIndex].ladderPriceFlag) {
                 $checkItem["ladderPriceFlag"] = 1;
                 $checkItem["ladderPriceList"] = skus[skuIndex].ladderPriceList;
                 $(".ladderPrice").show();
-            }else{
+            } else {
                 $checkItem["ladderPriceFlag"] = 0;
                 $checkItem["ladderPriceList"] = {};
                 $(".ladderPrice").hide();
@@ -345,6 +344,38 @@
             $checkItem["totalAddedValueTax"] = tax * num;
             $("#addedValueTax" + ind).val(tax);
             $("#totalAddedValueTax" + ind).val(tax * num);
+            debugger;
+            var flag = $("#svipPriceFlag" + ind).val() * 1;
+            if (1 === flag) {
+                var type = skus[skuIndex].priceType;
+                if (1 === type) {
+                    //1折扣,2优惠价
+                    var discount = skus[skuIndex].discount;
+                    var oldPrice = skus[skuIndex].price;
+                    var discountPrice = (discount * oldPrice / 100).toFixed(2);
+                    $("#svipDiscountPrice" + ind).html(discountPrice);
+                    $("#discountPrice" + ind).val(discountPrice);
+
+                    $checkItem["discount"] = discount;
+                    $checkItem["discountPrice"] = discountPrice;
+                    $checkItem["discountPrice"] = discountPrice;
+                    $checkItem["svipReduction"] = oldPrice - discountPrice;
+                    $("#svipReduction" + ind).val(oldPrice - discountPrice);
+                    base = discountPrice;
+                } else {
+                    $("#svipDiscountPrice" + ind).html(skus[skuIndex].discountPrice);
+                    $("#discountPrice" + ind).val(skus[skuIndex].discountPrice);
+                    $checkItem["discountPrice"] = skus[skuIndex].discountPrice;
+                    $checkItem["svipReduction"] = skus[skuIndex].price - skus[skuIndex].discountPrice;
+                    $("#svipReduction" + ind).val(skus[skuIndex].price - skus[skuIndex].discountPrice);
+                    base = skus[skuIndex].discountPrice;
+                }
+            } else if (skus[skuIndex].touchPrice) {
+                base = skus[skuIndex].touchPrice;
+                $("#touchPrice" + ind).val(skus[skuIndex].touchPrice);
+                $checkItem["touchPrice"] = skus[skuIndex].touchPrice;
+                $checkItem["cmPromotion"]["touchPrice"] = skus[skuIndex].touchPrice;
+            }
             var total = base * num;
             $("#totalFee" + ind).val(total);
             $checkItem["totalFee"] = total;

+ 81 - 31
src/main/webapp/WEB-INF/views/modules/product-new/multiPromotionList.jsp

@@ -12,6 +12,39 @@
         .table td {
             text-align: center;
         }
+        .goods-item{
+            text-align: initial !important;
+            padding: 16px 24px !important;
+        }
+        .goods-item .cm-label{
+            padding: 16px 0;
+        }
+        .goods-item .cm-wrapper{
+            display: flex;
+            align-items: center;
+            row-gap: 16px;
+            margin-bottom: 24px;
+        }
+        .goods-item .cm-info{
+            display: flex;
+            align-items: center;
+            column-gap: 36px;
+            width: 60%;
+        }
+        .goods-item .cm-info.max-width{
+            width: 100% !important;
+            margin: 16px 0;
+        }
+        .goods-item .cm-price-list{
+            display: flex;
+            align-items: center;
+            column-gap: 16px;
+
+        }
+        .shop-info-wrapper .shop-info .shop-price{
+            display: flex;
+            align-items: center;
+        }
     </style>
     <script type="text/javascript">
         $(document).ready(function () {
@@ -61,7 +94,8 @@
         </form:select>
         &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
         &nbsp;&nbsp;&nbsp;&nbsp;<input class="btn btn-primary" style="width: 90px"
-                                       onclick="window.location='${ctx}/product/cmPromotions/form?type=2'" value="新增凑单促销"/>
+                                       onclick="window.location='${ctx}/product/cmPromotions/form?type=2'"
+                                       value="新增凑单促销"/>
         <div class="clearfix"></div>
     </div>
 </form:form>
@@ -91,7 +125,7 @@
                     ${cmPromotion.description}
             </td>
             <td style="color: ${cmPromotion.mode eq 1?"green":cmPromotion.mode eq 2?"orange":"purple"}">
-                ${cmPromotion.mode eq 1?"优惠价":cmPromotion.mode eq 2?"满减":"满赠"}
+                    ${cmPromotion.mode eq 1?"优惠价":cmPromotion.mode eq 2?"满减":"满赠"}
             </td>
             <td>
                 <c:if test="${cmPromotion.mode eq 2}">
@@ -100,11 +134,12 @@
                 </c:if>
                 <c:if test="${cmPromotion.mode eq 3}">
                     满<fmt:formatNumber value="${cmPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>
-                    ,赠品:<c:if test="${cmPromotion.giftTypeNumber > 1}">${cmPromotion.giftTypeNumber}类</c:if>${cmPromotion.giftNumber}个,详见下表
+                    ,赠品:<c:if
+                        test="${cmPromotion.giftTypeNumber > 1}">${cmPromotion.giftTypeNumber}类</c:if>${cmPromotion.giftNumber}个,详见下表
                 </c:if>
             </td>
             <td>
-                ${cmPromotion.status eq 1?"永久":"区间有效"}
+                    ${cmPromotion.status eq 1?"永久":"区间有效"}
             </td>
             <td>
                 <c:if test="${cmPromotion.status eq 2}">
@@ -117,7 +152,7 @@
                 </c:if>
             </td>
             <td style="color: ${cmPromotion.delFlag1 eq 1?"purple":cmPromotion.delFlag1 eq 2?"green":cmPromotion.delFlag1 eq 3?"orange":cmPromotion.delFlag1 eq 0?"red":"black"}">
-                ${cmPromotion.delFlag1 eq 1?"未开始":cmPromotion.delFlag1 eq 2?"进行中":cmPromotion.delFlag1 eq 3?"已结束":cmPromotion.delFlag1 eq 0?"已关闭":"未知"}
+                    ${cmPromotion.delFlag1 eq 1?"未开始":cmPromotion.delFlag1 eq 2?"进行中":cmPromotion.delFlag1 eq 3?"已结束":cmPromotion.delFlag1 eq 0?"已关闭":"未知"}
             </td>
             <td>
                 <fmt:formatDate value="${cmPromotion.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
@@ -134,30 +169,45 @@
             </td>
         </tr>
         <tr>
-            <td colspan="9" style="text-align: left">
+            <td colspan="9" class="goods-item">
                 <c:if test="${cmPromotion.promotionProducts.size()>0}">
-                    <p>促销商品:</p >
+                    <div class="cm-label">促销商品:</div>
                     <c:forEach items="${cmPromotion.promotionProducts}" var="promotionProduct">
-                        <p>
-                            <img src="${promotionProduct.mainImage}" alt="图片" width="50px" height="50px">
-                            <span style="position: absolute; left: 120px;width: 550px">商品名称:${promotionProduct.name}</span>
-                            <span style="position: absolute; left: 670px;width: 430px">供应商:${promotionProduct.shopName}</span>
-                            <span style="position: absolute; left: 1100px">机构价:${promotionProduct.price}</span>
-                        </p>
+                        <div class="cm-wrapper">
+                            <div class="cm-info">
+                                <img src="${promotionProduct.mainImage}" alt="图片" width="50px" height="50px">
+                                <div class="cm-name">商品名称:${promotionProduct.name}</div>
+                                <div class="cm-shopname">供应商:${promotionProduct.shopName}</div>
+                            </div>
+                            <div class="cm-price-list">
+                                <div class="cm-label">机构价:</div>
+                                <div class="cm-sku-list">
+                                    <c:if test="${cmPromotion.mode eq 1}">
+                                        <c:forEach items="${cmPromotion.skus}" var="sku">
+                                            <div class="cm-sku-item">&nbsp;&nbsp;&nbsp;&nbsp;${sku.unit}-¥${sku.price}&nbsp;&nbsp;</div>
+                                        </c:forEach>
+                                    </c:if>
+                                    <c:if test="${cmPromotion.mode ne 1}">
+                                        <c:forEach items="${promotionProduct.skuList}" var="sku">
+                                            <div class="cm-sku-item">&nbsp;&nbsp;&nbsp;&nbsp;${sku.unit}-¥${sku.price}&nbsp;&nbsp;</div>
+                                        </c:forEach>
+                                    </c:if>
+                                </div>
+                            </div>
+                        </div>
                     </c:forEach>
                 </c:if>
                 <c:if test="${cmPromotion.giftProducts.size()>0}">
-                    <p>赠送商品:</p>
+                    <div class="cm-label">赠送商品:</div>
                     <c:forEach items="${cmPromotion.giftProducts}" var="giftProduct">
-                        <p>
+                        <div class="cm-info max-width">
                             <img src="${giftProduct.mainImage}" alt="图片" width="50px" height="50px">
-                            <span style="position: absolute; left: 120px;width: 550px">商品名称:${giftProduct.name}</span>
-                            <span style="position: absolute; left: 670px;width: 430px">供应商:${giftProduct.shopName}</span>
-                            <span style="position: absolute; left: 1100px">数量:${giftProduct.giftNumber}</span>
-                        </p>
+                            <div>商品名称:${giftProduct.name}</div>
+                            <div>供应商:${giftProduct.shopName}</div>
+                            <div>数量:${giftProduct.giftNumber}</div>
+                        </div>
                     </c:forEach>
                 </c:if>
-
             </td>
         </tr>
         <c:forEach items="${page.list}" var="cmPromotion"></c:forEach>
@@ -166,28 +216,28 @@
 </table>
 <div class="pagination">${page}</div>
 <script type="text/javascript">
-    function updateStatus(id,flag) {
+    function updateStatus(id, flag) {
         var msg = "提示信息";
-        if(flag == 'close'){
+        if (flag == 'close') {
             msg = "确定关闭该促销活动吗";
-        }else if(flag == 'open'){
+        } else if (flag == 'open') {
             msg = "确定开启该促销活动吗?";
-        }else if(flag == 'delete'){
+        } else if (flag == 'delete') {
             msg = "确定删除该促销活动吗?";
         }
-        top.$.jBox.confirm(msg,'系统提示',function(v,h,f){
-            if(v=='ok'){
-                $.post("${ctx}/product/cmPromotions/updateStatus",{'id': id,'flag': flag}, function(data) {
-                    if(true==data.success){
+        top.$.jBox.confirm(msg, '系统提示', function (v, h, f) {
+            if (v == 'ok') {
+                $.post("${ctx}/product/cmPromotions/updateStatus", {'id': id, 'flag': flag}, function (data) {
+                    if (true == data.success) {
                         $.jBox.tip(data.msg, 'info');
                         $("#searchForm").submit();
                     } else {
-                        $.jBox.tip(data.msg,'error');
+                        $.jBox.tip(data.msg, 'error');
                     }
-                },"JSON");//这里返回的类型有:json,html,xml,text
+                }, "JSON");//这里返回的类型有:json,html,xml,text
             }
             return;
-        },{buttonsFocus:1,persistent: true});
+        }, {buttonsFocus: 1, persistent: true});
     }
 </script>
 </body>

+ 133 - 95
src/main/webapp/WEB-INF/views/modules/product-new/singlePromotionForm.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();
@@ -29,36 +29,36 @@
                         return false;
                     }
                     if (mode == "1") {
-                        if ($("#touchPrice1").val() == '') {
-                            alertx("请输入优惠价");
-                            isSubMitFlag = false;
-                            return false;
-                        }else if(isNaN($("#touchPrice1").val())||$("#touchPrice1").val().indexOf('0')==0){
-                            alertx('请输入正确的优惠价!');
-                            isSubMitFlag = false;
-                            return false;
-                        }else {
-                            var price = $("#price").val();
-                            if (parseFloat($("#touchPrice1").val()) >= parseFloat(price)) {
-                                alertx('优惠价必须小于机构价'+price);
-                                isSubMitFlag = false;
-                                return false;
-                            }
-                        }
-                    }else if (mode == "2") {
+                        // if ($("#touchPrice1").val() == '') {
+                        //     alertx("请输入优惠价");
+                        //     isSubMitFlag = false;
+                        //     return false;
+                        // } else if (isNaN($("#touchPrice1").val()) || $("#touchPrice1").val().indexOf('0') == 0) {
+                        //     alertx('请输入正确的优惠价!');
+                        //     isSubMitFlag = false;
+                        //     return false;
+                        // } else {
+                        //     var price = $("#price").val();
+                        //     if (parseFloat($("#touchPrice1").val()) >= parseFloat(price)) {
+                        //         alertx('优惠价必须小于机构价' + price);
+                        //         isSubMitFlag = false;
+                        //         return false;
+                        //     }
+                        // }
+                    } else if (mode == "2") {
                         debugger
                         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;
-                        }else {
+                        } else {
                             var price = $("#price").val();
-                            if (parseFloat($("#touchPrice2").val()) <parseFloat(price)) {
-                                alertx('满减设定价需大于或等于商品机构价'+price);
+                            if (parseFloat($("#touchPrice2").val()) < parseFloat(price)) {
+                                alertx('满减设定价需大于或等于商品机构价' + price);
                                 isSubMitFlag = false;
                                 return false;
                             }
@@ -67,7 +67,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;
@@ -77,26 +77,26 @@
                             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;
-                        }else {
+                        } else {
                             var price = $("#price").val();
                             if (parseFloat($("#touchPrice3").val()) < parseFloat(price)) {
-                                alertx('满赠设定价需大于或等于商品机构价'+price);
+                                alertx('满赠设定价需大于或等于商品机构价' + price);
                                 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;
@@ -116,12 +116,12 @@
                         //已改为skuId
                         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;
@@ -151,9 +151,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);
@@ -161,6 +161,7 @@
                 }
             });
         });
+
         //选择添加商品
         function showSelect(type) {
             var showSelectProductID = '';
@@ -181,12 +182,12 @@
                     var $itemProductID = $this.find('input[name="gift"]').val();
                     showSelectProductID += $itemProductID + ',';
                 });
-                url ="${ctx}/product/cmPromotions/findProductPage?productIds=" + showSelectProductID
+                url = "${ctx}/product/cmPromotions/findProductPage?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,
@@ -209,7 +210,7 @@
                                     var giftIds = $("#giftIds").val();
                                     var mode = $("input[name='mode']:checked").val();
                                     var reducedPrice = $("#reducedPrice").val();
-                                    var touchPrice1 = $("#touchPrice1").val();
+                                    // var touchPrice1 = $("#touchPrice1").val();
                                     var touchPrice2 = $("#touchPrice2").val();
                                     var touchPrice3 = $("#touchPrice3").val();
                                     var status = $("input[name='status']:checked").val();
@@ -219,15 +220,15 @@
                                     var delProductIds = $("#delProductIds").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=1&productIds=" + items + "&giftIds=" + items1 + "&mode=" + mode +
-                                            "&delProductIds="+delProductIds+"&delGiftIds="+delGiftIds+
-                                            "&reducedPrice=" + reducedPrice + "&touchPrice1=" + touchPrice1 + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
-                                            "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}"+
+                                            "&delProductIds=" + delProductIds + "&delGiftIds=" + delGiftIds +
+                                            "&reducedPrice=" + reducedPrice + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
+                                            "&status=" + status + "&beginTime=" + beginTime + "&endTime=" + endTime + "&delFlag1=" + delFlag1 + "&id=${cmPromotion.id}" +
                                             "&searchDbFlag=0";
                                     }
                                     if (type == 2) {
@@ -238,8 +239,8 @@
                                             items1 = productIds;
                                         }
                                         window.location.href = "${ctx}/product/cmPromotions/form?type=1&productIds=" + items1 + "&giftIds=" + items + "&mode=" + mode +
-                                            "&delProductIds="+delProductIds+"&delGiftIds="+delGiftIds+
-                                            "&reducedPrice=" + reducedPrice + "&touchPrice1=" + touchPrice1 + "&touchPrice2=" + touchPrice2 + "&touchPrice3=" + touchPrice3 +
+                                            "&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');
@@ -258,25 +259,25 @@
             });
         }
 
-        function deleteProduct(obj,type) {
+        function deleteProduct(obj, type) {
             //将该行数据取消勾选,若存在数据库中则将其删除
             $(".check-item[value=" + obj + "]").prop("checked", false);
             if (type == 1) {
-                var product=$('#product'+obj);
+                var product = $('#product' + obj);
                 $(product).remove();
             }
             if (type == 2) {
-                var gift= $('#gift'+obj);
+                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;
                 }
             });
 
@@ -302,18 +303,18 @@
 
         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());
             });
             return items;
         }
 
-        function checkModes(){
+        function checkModes() {
             $("#discount").show();
         }
 
-        function checkMode(){
+        function checkMode() {
             $("#discount").hide();
         }
     </script>
@@ -321,10 +322,14 @@
 <body>
 <ul class="nav nav-tabs">
     <li><a href="${ctx}/product/cmPromotions/list?type=1">单品促销</a></li>
-    <li class="active"><a href="${ctx}/product/cmPromotions/form?id=${cmPromotion.id}&type=1">${not empty cmPromotion.id?'编辑':'添加'}单品促销</a></li>
-</ul><br/>
+    <li class="active"><a
+            href="${ctx}/product/cmPromotions/form?id=${cmPromotion.id}&type=1">${not empty cmPromotion.id?'编辑':'添加'}单品促销</a>
+    </li>
+</ul>
+<br/>
 <input hidden="hidden" id="price" value="${price}">
-<form:form id="inputForm" modelAttribute="cmPromotion" action="${ctx}/product/cmPromotions/save" method="post" class="form-horizontal">
+<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"/>
@@ -351,8 +356,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" ${product.storeStatus?'':'checked'}
+                                                value='${product.productID}'/></th>
                         <td><img src="${product.mainImage}" width="50px" height="50px"></td>
                         <td>${product.name}</td>
                         <td>${product.shopName}</td>
@@ -370,26 +375,51 @@
 
     <div class="control-group" id="promotionType">
         <label>促销方式:</label>
-        <input type="radio"  id="promotionType1" onclick="checkMode()" name="mode" value="1" ${cmPromotion.mode == null ? "checked" : cmPromotion.mode == "1"?"checked":""} />优惠价
-        <input type="radio"  id="promotionType2" onclick="checkModes()" name="mode" value="2" ${cmPromotion.mode == "2" ? "checked" : ""} />满减
-        <input type="radio" id="promotionType3"  onclick="checkModes()" name="mode" value="3" ${cmPromotion.mode == "3" ? "checked" : ""} />满赠
+        <input type="radio" id="promotionType1" onclick="checkMode()" name="mode"
+               value="1" ${cmPromotion.mode == null ? "checked" : cmPromotion.mode == "1"?"checked":""} />优惠价
+        <input type="radio" id="promotionType2" onclick="checkModes()" name="mode"
+               value="2" ${cmPromotion.mode == "2" ? "checked" : ""} />满减
+        <input type="radio" id="promotionType3" onclick="checkModes()" name="mode"
+               value="3" ${cmPromotion.mode == "3" ? "checked" : ""} />满赠
     </div>
 
     <div class="control-group">
         <label style="display: inline"><label style="color: red">*</label>优惠内容:</label>
-        <div id="discountContent1" style="display: ${cmPromotion.mode == null ? "inline" : cmPromotion.mode == "1"?"inline":"none"}" >
+        <div id="discountContent1"
+             style="display: ${cmPromotion.mode == null ? "inline" : cmPromotion.mode == "1"?"inline":"none"}">
             <label><font color="red">优惠价</font></label>
-            <form:input path="touchPrice1" id="touchPrice1" htmlEscape="false" maxlength="7" class="input-xlarge " onkeyup="onlynum(this)"/>
+                <%--            <form:input path="touchPrice1" id="touchPrice1" htmlEscape="false" maxlength="7" class="input-xlarge " onkeyup="onlynum(this)"/>--%>
+            <table>
+                <c:forEach items="${cmPromotion.skus}" var="sku" varStatus="s">
+                    <tr>
+                        <td hidden><input name="skus[${s.index}].skuId" value="${sku.skuId}"></td>
+                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;规格:${sku.unit}</td>
+                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;优惠价:<input class="required" name="skus[${s.index}].touchPrice" value="${sku.touchPrice}" type="number"/></td>
+                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;成本类型:${sku.costCheckFlag eq 1?'固定成本':'比例成本'}</td>
+                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                            <c:if test="${sku.costCheckFlag eq 1}">
+                                成本价格:¥${sku.costPrice}
+                            </c:if>
+                            <c:if test="${sku.costCheckFlag eq 2}">
+                                成本比例:${sku.costProportional}%
+                            </c:if>
+                        </td>
+                    </tr>
+                </c:forEach>
+            </table>
         </div>
         <div id="discountContent2" style="display: ${cmPromotion.mode == "2" ? "inline" : "none"}">
             <label><font color="red">满</font></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><font color="red">减</font></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><font color="red">满</font></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">
@@ -433,11 +463,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"
@@ -445,7 +477,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"
@@ -453,27 +486,32 @@
                onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
     </div>
 
-    <div class="control-group" id="discount" style="display: ${cmPromotion.mode == null ? "none" : cmPromotion.mode == "1"?"none":""}">
+    <div class="control-group" id="discount"
+         style="display: ${cmPromotion.mode == null ? "none" : cmPromotion.mode == "1"?"none":""}">
         <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" id="testStatus">促销状态:</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 == '' ?"进行中":cmPromotion.delFlag1 == "0"?"已关闭":cmPromotion.delFlag1 == "1"?"未开始":cmPromotion.delFlag1 == "2"?"进行中":"已结束"}</label>
-        <input type="checkbox" id="delFlag1" 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 == '' ?"进行中":cmPromotion.delFlag1 == "0"?"已关闭":cmPromotion.delFlag1 == "1"?"未开始":cmPromotion.delFlag1 == "2"?"进行中":"已结束"}</label>
+        <input type="checkbox" id="delFlag1" 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=1"><input id="btnCancel" class="btn" type="button" value="返 回" /></a>
+        <a href="${ctx}/product/cmPromotions/?type=1"><input id="btnCancel" class="btn" type="button" value="返 回"/></a>
     </div>
 </form:form>
 <script type="text/javascript">
@@ -484,17 +522,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");
         }
     })
     //促销时效修改
@@ -502,15 +540,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();
             }
@@ -532,7 +570,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("进行中");

+ 46 - 22
src/main/webapp/WEB-INF/views/modules/product-new/singlePromotionList.jsp

@@ -62,7 +62,8 @@
         </form:select>
         &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
         &nbsp;&nbsp;&nbsp;&nbsp;<input class="btn btn-primary" style="width: 90px"
-                                       onclick="window.location='${ctx}/product/cmPromotions/form?type=1'" value="新增单品促销"/>
+                                       onclick="window.location='${ctx}/product/cmPromotions/form?type=1'"
+                                       value="新增单品促销"/>
         <div class="clearfix"></div>
     </div>
 </form:form>
@@ -88,22 +89,31 @@
                     ${cmPromotion.id}
             </td>
             <td style="color: ${cmPromotion.mode eq 1?"green":cmPromotion.mode eq 2?"orange":"purple"}">
-                ${cmPromotion.mode eq 1?"优惠价":cmPromotion.mode eq 2?"满减":"满赠"}
+                    ${cmPromotion.mode eq 1?"优惠价":cmPromotion.mode eq 2?"满减":"满赠"}
             </td>
             <td>
                 <c:if test="${cmPromotion.mode eq 1}">
-                    优惠价:<fmt:formatNumber value="${cmPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>
+                    <%--                    优惠价:<fmt:formatNumber value="${cmPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>--%>
+                    <div style="float: left">优惠价:</div>
+                    <div style="float: left;text-align: left">
+                        <c:forEach items="${cmPromotion.skus}" var="sku">
+                            ${sku.unit}-¥${sku.touchPrice}
+                            <br>
+                        </c:forEach>
+                    </div>
                 </c:if>
                 <c:if test="${cmPromotion.mode eq 2}">
                     满<fmt:formatNumber value="${cmPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>
                     ,减<fmt:formatNumber value="${cmPromotion.reducedPrice}" pattern="#,##0.00" maxFractionDigits="2"/>
                 </c:if>
                 <c:if test="${cmPromotion.mode eq 3}">
-                    满<fmt:formatNumber value="${cmPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>,赠品:<c:if test="${cmPromotion.giftTypeNumber > 1}">${cmPromotion.giftTypeNumber}类</c:if>${cmPromotion.giftNumber}个,详见下表
+                    满<fmt:formatNumber value="${cmPromotion.touchPrice}" pattern="#,##0.00"
+                                       maxFractionDigits="2"/>,赠品:<c:if
+                        test="${cmPromotion.giftTypeNumber > 1}">${cmPromotion.giftTypeNumber}类</c:if>${cmPromotion.giftNumber}个,详见下表
                 </c:if>
             </td>
             <td>
-                ${cmPromotion.status eq 1?"永久":"区间有效"}
+                    ${cmPromotion.status eq 1?"永久":"区间有效"}
             </td>
             <td>
                 <c:if test="${cmPromotion.status eq 2}">
@@ -116,7 +126,7 @@
                 </c:if>
             </td>
             <td style="color: ${cmPromotion.delFlag1 eq 1?"purple":cmPromotion.delFlag1 eq 2?"green":cmPromotion.delFlag1 eq 3?"orange":cmPromotion.delFlag1 eq 0?"red":"black"}">
-                ${cmPromotion.delFlag1 eq 1?"未开始":cmPromotion.delFlag1 eq 2?"进行中":cmPromotion.delFlag1 eq 3?"已结束":cmPromotion.delFlag1 eq 0?"已关闭":"未知"}
+                    ${cmPromotion.delFlag1 eq 1?"未开始":cmPromotion.delFlag1 eq 2?"进行中":cmPromotion.delFlag1 eq 3?"已结束":cmPromotion.delFlag1 eq 0?"已关闭":"未知"}
             </td>
             <td>
                 <fmt:formatDate value="${cmPromotion.updateTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
@@ -135,14 +145,28 @@
         <tr>
             <td colspan="8" style="text-align: left">
                 <c:if test="${cmPromotion.promotionProducts.size()>0}">
-                    <p>促销商品:</p >
+                    <p>促销商品:</p>
                     <c:forEach items="${cmPromotion.promotionProducts}" var="promotionProduct">
-                        <p>
+                        <div>
                             <img src="${promotionProduct.mainImage}" alt="图片" width="50px" height="50px">
-                            <span style="position: absolute; left: 120px;width: 550px">商品名称:${promotionProduct.name}</span>
+                            <span style="position: absolute; left: 150px;width: 550px">商品名称:${promotionProduct.name}</span>
                             <span style="position: absolute; left: 670px;width: 430px">供应商:${promotionProduct.shopName}</span>
-                            <span style="position: absolute; left: 1100px">机构价:${promotionProduct.price}</span>
-                        </p>
+                            <span style="position: absolute; left: 1100px">
+                                <p style="float: left">机构价:</p>
+                                <div style="float:left">
+                                  <c:if test="${cmPromotion.mode eq 1}">
+                                      <c:forEach items="${cmPromotion.skus}" var="sku">
+                                          <div class="cm-sku-item">&nbsp;&nbsp;&nbsp;&nbsp;${sku.unit}-¥${sku.price}&nbsp;&nbsp;</div>
+                                      </c:forEach>
+                                  </c:if>
+                                    <c:if test="${cmPromotion.mode ne 1}">
+                                        <c:forEach items="${promotionProduct.skuList}" var="sku">
+                                            <div class="cm-sku-item">&nbsp;&nbsp;&nbsp;&nbsp;${sku.unit}-¥${sku.price}&nbsp;&nbsp;</div>
+                                        </c:forEach>
+                                    </c:if>
+                                </div>
+                            </span>
+                        </div>
                     </c:forEach>
                 </c:if>
                 <c:if test="${cmPromotion.giftProducts.size()>0}">
@@ -172,28 +196,28 @@
 </table>
 <div class="pagination">${page}</div>
 <script type="text/javascript">
-    function updateStatus(id,flag) {
+    function updateStatus(id, flag) {
         var msg = "提示信息";
-        if(flag == 'close'){
+        if (flag == 'close') {
             msg = "确定关闭该促销活动吗";
-        }else if(flag == 'open'){
+        } else if (flag == 'open') {
             msg = "确定开启该促销活动吗?";
-        }else if(flag == 'delete'){
+        } else if (flag == 'delete') {
             msg = "确定删除该促销活动吗?";
         }
-        top.$.jBox.confirm(msg,'系统提示',function(v,h,f){
-            if(v=='ok'){
-                $.post("${ctx}/product/cmPromotions/updateStatus",{'id': id,'flag': flag}, function(data) {
-                    if(true==data.success){
+        top.$.jBox.confirm(msg, '系统提示', function (v, h, f) {
+            if (v == 'ok') {
+                $.post("${ctx}/product/cmPromotions/updateStatus", {'id': id, 'flag': flag}, function (data) {
+                    if (true == data.success) {
                         $.jBox.tip(data.msg, 'info');
                         $("#searchForm").submit();
                     } else {
-                        $.jBox.tip(data.msg,'error');
+                        $.jBox.tip(data.msg, 'error');
                     }
-                },"JSON");//这里返回的类型有:json,html,xml,text
+                }, "JSON");//这里返回的类型有:json,html,xml,text
             }
             return;
-        },{buttonsFocus:1,persistent: true});
+        }, {buttonsFocus: 1, persistent: true});
     }
 </script>
 </body>

+ 262 - 179
src/main/webapp/WEB-INF/views/modules/svip/cmSvipProductForm.jsp

@@ -1,190 +1,273 @@
 <%@ page contentType="text/html;charset=UTF-8" %>
-<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
 <html>
 <head>
-	<title>商品管理</title>
-	<meta name="decorator" content="default"/>
-	<style>
-		.showLabel{
-			margin-top:3px
-		}
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			//$("#name").focus();
-			$("#inputForm").validate({
-				submitHandler: function(form){
-					loading('正在提交,请稍等...');
-					form.submit();
-				},
-				errorContainer: "#messageBox",
-				errorPlacement: function(error, element) {
-					$("#messageBox").text("输入有误,请先更正。");
-					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
-						error.appendTo(element.parent().parent());
-					} else {
-						error.insertAfter(element);
-					}
-				}
-			});
-		});
-	</script>
+    <title>商品管理</title>
+    <meta name="decorator" content="default"/>
+    <style>
+        .showLabel {
+            margin-top: 3px
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+    </script>
 </head>
 <body>
-	<ul class="nav nav-tabs">
-		<li><a href="${ctx}/svip/cmSvipProduct/">商品列表</a></li>
-		<li class="active"><a href="${ctx}/svip/cmSvipProduct/form?id=${cmSvipProduct.id}">商品${not empty cmSvipProduct.id?'编辑':'添加'}</a></li>
-	</ul><br/>
-	<form:form id="inputForm" modelAttribute="cmSvipProduct" action="${ctx}/svip/cmSvipProduct/save" method="post" class="form-horizontal">
-		<form:hidden path="id"/>
-		<sys:message content="${message}"/>
-		<div class="control-group">
-			<label class="control-label">商品ID:</label>
-			<div class="controls">
-				<label class="showLabel">${cmSvipProduct.productId}</label>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label">商品名称:</label>
-			<div class="controls">
-				<label class="showLabel">${cmSvipProduct.productName}</label>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label">供应商:</label>
-			<div class="controls">
-				<label class="showLabel">${cmSvipProduct.shopName}</label>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label">机构价:</label>
-			<div class="controls">
-				<label class="showLabel">¥${cmSvipProduct.price}</label>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label">是否含税:</label>
-			<div class="controls">
-				<label class="showLabel">${cmSvipProduct.includedTax == '1'?'含税':(cmSvipProduct.includedTax == '0'?'不含税':'未知')}
-                        ${cmSvipProduct.includedTax == '2'?'':(cmSvipProduct.invoiceType == '1'?'-开增值税专用发票':(cmSvipProduct.invoiceType == '2'?'-开增值税普通发票':'-不能开票'))}</label>
-			</div>
-		</div>
-		<div class="control-group" style="display: ${cmSvipProduct.includedTax == '2'?'none':''}">
-			<label class="control-label">机构税率:</label>
-			<div class="controls">
-                <label class="showLabel">${cmSvipProduct.taxPoint}%</label>
-            </div>
-		</div>
-		<div class="control-group" style="display: ${cmSvipProduct.includedTax == '2'?'none':''}">
-			<label class="control-label">供应商税率:</label>
-			<div class="controls">
-                <label class="showLabel">${cmSvipProduct.supplierTaxPoint}%</label>
-            </div>
-		</div>
-		<div class="control-group">
-			<label class="control-label">成本:</label>
-			<div class="controls">
-                <label class="showLabel">${cmSvipProduct.costCheckFlag eq '1'?'固定成本':'比例成本'}</label>
-            </div>
-		</div>
-		<div class="control-group" style="display: ${cmSvipProduct.costCheckFlag eq '1'?'none':''}">
-			<label class="control-label">比例成本百分比:</label>
-			<div class="controls">
-                <label class="showLabel">${cmSvipProduct.costProportional}%</label>
-            </div>
-		</div>
-		<div class="control-group">
-			<label class="control-label">成本价:</label>
-			<div class="controls">
-				<label class="showLabel">
-					<fmt:formatNumber value="${cmSvipProduct.costPrice}" type="number" pattern="#0.00"/>
-				</label>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>会员价:</label>
-			<div class="controls">
-                <form:radiobutton path="priceType" onchange="changePriceType(1)" value="1" label="折扣价"/>
-                <form:radiobutton path="priceType" onchange="changePriceType(2)" value="2" label="直接优惠价"/>
-			</div>
-		</div>
-		<div class="control-group discountInput" hidden>
-			<div class="controls">
-				<form:input path="discount" htmlEscape="false" onchange="changeDiscount(this,1)" class="input-medium required"/> %
-			</div>
-		</div>
-		<div class="control-group discountPriceInput" hidden>
-			<div class="controls">
-				<form:input path="discountPrice" htmlEscape="false" onchange="changeDiscount(this,2)" class="input-medium required"/>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>排序值:</label>
-			<div class="controls">
-				<form:input path="sort" htmlEscape="false" placeholder="请填写排序值" class="input-xlarge required"/>
-			</div>
-		</div>
-		<div class="form-actions">
-			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
-			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
-		</div>
-	</form:form>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/svip/cmSvipProduct/">商品列表</a></li>
+    <li class="active"><a
+            href="${ctx}/svip/cmSvipProduct/form?id=${cmSvipProduct.id}">商品${not empty cmSvipProduct.id?'编辑':'添加'}</a>
+    </li>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="cmSvipProduct" action="${ctx}/svip/cmSvipProduct/save" method="post"
+           class="form-horizontal">
+    <form:hidden path="id"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label">商品ID:</label>
+        <div class="controls">
+            <label class="showLabel">${cmSvipProduct.productId}</label>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">商品名称:</label>
+        <div class="controls">
+            <label class="showLabel">${cmSvipProduct.productName}</label>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label">供应商:</label>
+        <div class="controls">
+            <label class="showLabel">${cmSvipProduct.shopName}</label>
+        </div>
+    </div>
+    <%--		<div class="control-group">--%>
+    <%--			<label class="control-label">机构价:</label>--%>
+    <%--			<div class="controls">--%>
+    <%--				<label class="showLabel">¥${cmSvipProduct.price}</label>--%>
+    <%--			</div>--%>
+    <%--		</div>--%>
+    <div class="control-group">
+        <label class="control-label">是否含税:</label>
+        <div class="controls">
+            <label class="showLabel">${cmSvipProduct.includedTax == '1'?'含税':(cmSvipProduct.includedTax == '0'?'不含税':'未知')}
+                    ${cmSvipProduct.includedTax == '2'?'':(cmSvipProduct.invoiceType == '1'?'-开增值税专用发票':(cmSvipProduct.invoiceType == '2'?'-开增值税普通发票':'-不能开票'))}</label>
+        </div>
+    </div>
+    <div class="control-group" style="display: ${cmSvipProduct.includedTax == '2'?'none':''}">
+        <label class="control-label">机构税率:</label>
+        <div class="controls">
+            <label class="showLabel">${cmSvipProduct.taxPoint}%</label>
+        </div>
+    </div>
+    <div class="control-group" style="display: ${cmSvipProduct.includedTax == '2'?'none':''}">
+        <label class="control-label">供应商税率:</label>
+        <div class="controls">
+            <label class="showLabel">${cmSvipProduct.supplierTaxPoint}%</label>
+        </div>
+    </div>
+    <%--		<div class="control-group">--%>
+    <%--			<label class="control-label">成本:</label>--%>
+    <%--			<div class="controls">--%>
+    <%--                <label class="showLabel">${cmSvipProduct.costCheckFlag eq '1'?'固定成本':'比例成本'}</label>--%>
+    <%--            </div>--%>
+    <%--		</div>--%>
+    <%--		<div class="control-group" style="display: ${cmSvipProduct.costCheckFlag eq '1'?'none':''}">--%>
+    <%--			<label class="control-label">比例成本百分比:</label>--%>
+    <%--			<div class="controls">--%>
+    <%--                <label class="showLabel">${cmSvipProduct.costProportional}%</label>--%>
+    <%--            </div>--%>
+    <%--		</div>--%>
+    <%--		<div class="control-group">--%>
+    <%--			<label class="control-label">成本价:</label>--%>
+    <%--			<div class="controls">--%>
+    <%--				<label class="showLabel">--%>
+    <%--					<fmt:formatNumber value="${cmSvipProduct.costPrice}" type="number" pattern="#0.00"/>--%>
+    <%--				</label>--%>
+    <%--			</div>--%>
+    <%--		</div>--%>
+    <%--		<div class="control-group">--%>
+    <%--			<label class="control-label"><font color="red">*</font>会员价:</label>--%>
+    <%--			<div class="controls">--%>
+    <%--                <form:radiobutton path="priceType" onchange="changePriceType(1)" value="1" label="折扣价"/>--%>
+    <%--                <form:radiobutton path="priceType" onchange="changePriceType(2)" value="2" label="直接优惠价"/>--%>
+    <%--			</div>--%>
+    <%--		</div>--%>
+    <%--		<div class="control-group discountInput" hidden>--%>
+    <%--			<div class="controls">--%>
+    <%--				<form:input path="discount" htmlEscape="false" onchange="changeDiscount(this,1)" class="input-medium required"/> %--%>
+    <%--			</div>--%>
+    <%--		</div>--%>
+    <%--		<div class="control-group discountPriceInput" hidden>--%>
+    <%--			<div class="controls">--%>
+    <%--				<form:input path="discountPrice" htmlEscape="false" onchange="changeDiscount(this,2)" class="input-medium required"/>--%>
+    <%--			</div>--%>
+    <%--		</div>--%>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>排序值:</label>
+        <div class="controls">
+            <form:input path="sort" htmlEscape="false" placeholder="请填写排序值" class="input-xlarge required"/>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>优惠状态:</label>
+        <div class="controls">
+            <select name="status" id="vipStatus" class="input-medium">
+                <c:choose>
+                    <c:when test="${cmSvipProduct.status eq 1}">
+                        <option value="1">已下架</option>
+                        <option value="0">已上架</option>
+                    </c:when>
+                    <c:otherwise>
+                        <option value="0">已上架</option>
+                        <option value="1">已下架</option>
+                    </c:otherwise>
+                </c:choose>
+            </select>
+        </div>
+    </div>
+    <div class="control-group">
+        <table id="refundTable" class="table table-striped table-bordered table-condensed">
+            <tr>
+                <th>商品规格</th>
+                <th>机构价</th>
+                <th>成本类型</th>
+                <th>成本价/成本比例</th>
+                <th>会员折扣(%)</th>
+                <th>会员价</th>
+            </tr>
+            <c:forEach items="${cmSvipProduct.skus}" var="sku" varStatus="s">
+                <tr>
+                    <td hidden><input name="skus[${s.index}].skuId" value="${sku.skuId}"/></td>
+                    <td>${sku.unit}</td>
+                    <td>${sku.price}</td>
+                    <td>${1 eq sku.costCheckFlag?"固定成本":"比例成本"}</td>
+                    <td>${1 eq sku.costCheckFlag?sku.costPrice:sku.costProportional}</td>
+                    <td><input class="discount required" id="discount${sku.skuId}${s.index}"
+                               name="skus[${s.index}].discount" ${sku.priceType eq 2?'disabled':''}
+                               onchange="changeDiscount(${sku.skuId},1,${s.index})" type="number" maxlength="11"
+                               value="${sku.discount}"
+                               style="width: 100px"> %
+                    </td>
+                    <td><input class="discountPrice required" id="discountPrice${sku.skuId}${s.index}"
+                               name="skus[${s.index}].discountPrice" ${sku.priceType eq 1?'disabled':''}
+                               onchange="changeDiscount(${sku.skuId},2,${s.index})" type="number" maxlength="11"
+                               value="${sku.discountPrice}"
+                               style="width: 100px"></td>
+                </tr>
+            </c:forEach>
+        </table>
+    </div>
+    <div class="form-actions">
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
+        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+    </div>
+</form:form>
 <script>
-	$(function () {
-		var priceType = ${cmSvipProduct.priceType}
-		if (priceType == 1) {
-			$(".discountInput").show();
-		} else {
-			$(".discountPriceInput").show();
-		}
-	})
-	function changePriceType(priceType) {
-		if (priceType == 1) {
-			$(".discountInput").show();
-			$(".discountPriceInput").hide();
-		} else {
-			$(".discountInput").hide();
-			$(".discountPriceInput").show();
-		}
-	}
+    $(function () {
+        var dd = $("table input");
+        console.log(dd);
+    })
+
+    function changePriceType(priceType) {
+        if (priceType == 1) {
+            $(".discountInput").show();
+            $(".discountPriceInput").hide();
+        } else {
+            $(".discountInput").hide();
+            $(".discountPriceInput").show();
+        }
+    }
+
+    function changeDiscount(skuId, priceType, ind) {
+        debugger
+        var cd = skuId + "" + ind;
+        if (priceType == 1) {
+            var val = $("#discount" + cd).val();
+            if (val == '') {
+                $("#discountPrice" + cd).removeAttr('disabled');
+                $("#discountPrice" + cd).removeAttr('readonly');
+            } else if (val > 100 || val <= 0) {
+                $.jBox.tip("请输入0-100之间的数字", 'info');
+                $("#discount" + cd).val('');
+                $("#discountPrice" + cd).removeAttr('readonly');
+            } else {
+                val = Number(val).toFixed(2);
+                $("#discount" + cd).val(val);
+                $("#discountPrice" + cd).attr('readonly', 'readonly');
+                $("#discountPrice" + cd).attr('disabled', true);
+            }
+        } else {
+            var val = $("#discountPrice" + cd).val();
+            if (val != '' && val != undefined) {
+                val = Number(val).toFixed(2);
+                $("#discountPrice" + cd).val(val);
+                $("#discount" + cd).attr('readonly', 'readonly');
+                $("#discount" + cd).attr('disabled', true);
+            } else {
+                $("#discount" + cd).removeAttr('readonly');
+                $("#discount" + cd).removeAttr('disabled');
+            }
+        }
+    }
 
-	/**
-	 * @param obj
-	 * jquery控制input只能输入数字
-	 */
-	function onlynum(obj) {
-		obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
-	}
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
 
-	/**
-	 * 更改折扣/折扣价
-	 */
-	function changeDiscount(obj,priceType) {
-		var val = obj.value;
-		var number = Number(val).toFixed(2);
-		if (priceType == 1) {
-			if (val > 100 || val <= 0) {
-				$.jBox.tip("请输入0-100之间的数字", 'info');
-				obj.value = '';
-			}else {
-				if (number == 'NaN') {
-					$.jBox.tip("请输入正确的数字", 'info');
-					obj.value = '';
-				} else {
-					obj.value = number;
-				}
-			}
-		} else {
-			if (val != '' && val != undefined) {
-				if (number == 'NaN') {
-					$.jBox.tip("请输入正确的数字", 'info');
-					obj.value = '';
-				} else {
-					obj.value = number;
-				}
-			}
-		}
-	}
+    /**
+     * 更改折扣/折扣价
+     */
+    // function changeDiscount(obj,priceType) {
+    // 	var val = obj.value;
+    // 	var number = Number(val).toFixed(2);
+    // 	if (priceType == 1) {
+    // 		if (val > 100 || val <= 0) {
+    // 			$.jBox.tip("请输入0-100之间的数字", 'info');
+    // 			obj.value = '';
+    // 		}else {
+    // 			if (number == 'NaN') {
+    // 				$.jBox.tip("请输入正确的数字", 'info');
+    // 				obj.value = '';
+    // 			} else {
+    // 				obj.value = number;
+    // 			}
+    // 		}
+    // 	} else {
+    // 		if (val != '' && val != undefined) {
+    // 			if (number == 'NaN') {
+    // 				$.jBox.tip("请输入正确的数字", 'info');
+    // 				obj.value = '';
+    // 			} else {
+    // 				obj.value = number;
+    // 			}
+    // 		}
+    // 	}
+    // }
 </script>
 </body>
 </html>

+ 9 - 1
src/main/webapp/WEB-INF/views/modules/svip/cmSvipProductList.jsp

@@ -49,6 +49,12 @@
 				<form:input path="productName" htmlEscape="false" class="input-medium"/>
 			 <label>供应商:</label>
 				<form:input path="shopName" htmlEscape="false" class="input-medium"/>
+			<label>优惠状态:</label>
+			<form:select path="status" class="input-mini">
+				<form:option value="">请选择</form:option>
+				<form:option value="0">已上架</form:option>
+				<form:option value="1">已下架</form:option>
+			</form:select>
 			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
 			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 60px" onclick="batchSaveSort()" value="批量排序"/>
 			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 50px" onclick="showSelect()" value="添加"/>
@@ -67,6 +73,7 @@
 				<th>会员折扣</th>
 				<th>会员价</th>
 				<th>排序值</th>
+				<th>优惠状态</th>
 				<th>添加时间</th>
 				<th>操作</th>
 			</tr>
@@ -101,6 +108,7 @@
 					<input id="sort" name="sort" style="width:50px;" value="${cmSvipProduct.sort}" onkeyup="onlynum(this)"
 						   onchange="changeSort(${cmSvipProduct.id},this)">
 				</td>
+				<td><font color="${cmSvipProduct.status eq 1?"red":"green"}">${cmSvipProduct.status eq 1?"已下架":"已上架"}</font></td>
 				<td>
 					<fmt:formatDate value="${cmSvipProduct.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
 				</td>
@@ -166,7 +174,7 @@
 						//添加数据
 						for (var i = 0; i < items.length; i++) {
 							var item = items[i];
-							$.post("${ctx}/svip/cmSvipProduct/save?productId=" + item.productId + "&discount=" + item.discount + "&discountPrice=" + item.discountPrice);
+							$.post("${ctx}/svip/cmSvipProduct/save?productId=" + item.productId);
 						}
 					} else {
 						top.$.jBox.tip("请先勾选商品...");

+ 4 - 4
src/main/webapp/WEB-INF/views/modules/svip/svipAddProduct.jsp

@@ -59,8 +59,8 @@
         <th>商品名称</th>
         <th>供应商</th>
         <th>机构价</th>
-        <th style="width: 140px !important;">会员折扣</th>
-        <th style="width: 140px !important;">会员价</th>
+<%--        <th style="width: 140px !important;">会员折扣</th>--%>
+<%--        <th style="width: 140px !important;">会员价</th>--%>
     </tr>
     <tbody>
     <c:if test="${not empty page.list}">
@@ -74,8 +74,8 @@
                 <td class="productName">${item.name}</td>
                 <td>${item.shopName}</td>
                 <td>¥${item.price}</td>
-                <td><input class="discount" id="discount${item.productID}" onchange="changeDiscount(${item.productID},1)" type="number" maxlength="11" style="width: 100px"> %</td>
-                <td><input class="discountPrice" id="discountPrice${item.productID}" onchange="changeDiscount(${item.productID},2)" type="number" maxlength="11" style="width: 100px"></td>
+<%--                <td><input class="discount" id="discount${item.productID}" onchange="changeDiscount(${item.productID},1)" type="number" maxlength="11" style="width: 100px"> %</td>--%>
+<%--                <td><input class="discountPrice" id="discountPrice${item.productID}" onchange="changeDiscount(${item.productID},2)" type="number" maxlength="11" style="width: 100px"></td>--%>
             </tr>
         </c:forEach>
     </c:if>

+ 1 - 0
src/main/webapp/static/modules/bulkpurchase/orderForm.js

@@ -871,6 +871,7 @@ function setProductList(data, flag, ind) {
     var ladderPrice = '';
     // 如果存在促销活动
     if (data.cmPromotion) {
+        debugger;
         var tempId = data.cmPromotion.id * 1;
         data.promotionsId = data.cmPromotion.id;
         // 没有折扣,才享受促销优惠