Bläddra i källkod

呵呵商城sku

zhijiezhao 2 år sedan
förälder
incheckning
1e88a5ad33
61 ändrade filer med 4071 tillägg och 3022 borttagningar
  1. 41 40
      src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java
  2. 13 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityProductDao.java
  3. 13 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheCollageProductDao.java
  4. 9 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheProductDao.java
  5. 3 0
      src/main/java/com/caimei/modules/hehe/dao/HeheDiscountActivityProductDao.java
  6. 9 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeHeActivityLadder.java
  7. 19 26
      src/main/java/com/caimei/modules/hehe/entity/CmHeheActivityProduct.java
  8. 16 4
      src/main/java/com/caimei/modules/hehe/entity/CmHeheCollageProduct.java
  9. 11 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheProduct.java
  10. 13 1
      src/main/java/com/caimei/modules/hehe/entity/HeheDiscountActivityProduct.java
  11. 39 17
      src/main/java/com/caimei/modules/hehe/service/CmHeheActivityProductService.java
  12. 82 59
      src/main/java/com/caimei/modules/hehe/service/CmHeheCollageProductService.java
  13. 24 2
      src/main/java/com/caimei/modules/hehe/service/CmHeheProductService.java
  14. 3 2
      src/main/java/com/caimei/modules/hehe/service/CmHeheUserService.java
  15. 24 3
      src/main/java/com/caimei/modules/hehe/service/HeheDiscountActivityProductService.java
  16. 1 0
      src/main/java/com/caimei/modules/hehe/web/CmHeheActivityProductController.java
  17. 13 0
      src/main/java/com/caimei/modules/hehe/web/CmHeheCollageProductController.java
  18. 9 2
      src/main/java/com/caimei/modules/hehe/web/CmHeheProductController.java
  19. 13 1
      src/main/java/com/caimei/modules/hehe/web/HeheDiscountActivityProductController.java
  20. 8 0
      src/main/java/com/caimei/modules/order/entity/LogisticsRecord.java
  21. 1 1
      src/main/java/com/caimei/modules/order/service/NewOrderService.java
  22. 1 1
      src/main/java/com/caimei/modules/product/dao/CmPromotionDao.java
  23. 5 1
      src/main/java/com/caimei/modules/product/dao/ProductDao.java
  24. 20 1
      src/main/java/com/caimei/modules/product/entity/CmSku.java
  25. 1 1
      src/main/java/com/caimei/modules/product/entity/Product.java
  26. 9 0
      src/main/java/com/caimei/modules/product/entity/RepeatPurchasePrice.java
  27. 12 6
      src/main/java/com/caimei/modules/product/service/CmPromotionService.java
  28. 20 37
      src/main/java/com/caimei/modules/product/service/ProductService.java
  29. 5 4
      src/main/java/com/caimei/modules/product/web/CmPromotionController.java
  30. 8 4
      src/main/java/com/caimei/modules/product/web/ProductNewController.java
  31. 187 188
      src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml
  32. 200 166
      src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml
  33. 157 112
      src/main/resources/mappings/modules/hehe/CmHeheCollageProductMapper.xml
  34. 297 262
      src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml
  35. 102 99
      src/main/resources/mappings/modules/hehe/HeheDiscountActivityProductMapper.xml
  36. 2 1
      src/main/resources/mappings/modules/order/CmReturnedPurchaseProductMapper.xml
  37. 1 0
      src/main/resources/mappings/modules/order/LogisticsRecordMapper.xml
  38. 507 508
      src/main/resources/mappings/modules/order/OrderProductMapper.xml
  39. 23 13
      src/main/resources/mappings/modules/product/CmPromotionMapper.xml
  40. 28 14
      src/main/resources/mappings/modules/product/ProductMapper.xml
  41. 0 10
      src/main/resources/mappings/modules/product/ProductNewMapper.xml
  42. 7 4
      src/main/resources/mappings/modules/product/RepeatPurchasePriceMapper.xml
  43. 3 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/applyRefoundForm.jsp
  44. 1 0
      src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReturnRecord.jsp
  45. 163 113
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductForm.jsp
  46. 5 19
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductList.jsp
  47. 233 190
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCollageProductForm.jsp
  48. 716 644
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductForm.jsp
  49. 11 4
      src/main/webapp/WEB-INF/views/modules/hehe/heheAddProduct.jsp
  50. 190 150
      src/main/webapp/WEB-INF/views/modules/hehe/heheDiscountActivityProductForm.jsp
  51. 487 138
      src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderDetail.jsp
  52. 1 0
      src/main/webapp/WEB-INF/views/modules/order/logisticsDetails.jsp
  53. 4 0
      src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp
  54. 2 0
      src/main/webapp/WEB-INF/views/modules/order/ship.jsp
  55. 4 0
      src/main/webapp/WEB-INF/views/modules/order/shipLogistic.jsp
  56. 128 64
      src/main/webapp/WEB-INF/views/modules/product-new/productEdit.jsp
  57. 26 5
      src/main/webapp/WEB-INF/views/modules/product-new/promotionSelectProducts.jsp
  58. 8 3
      src/main/webapp/WEB-INF/views/modules/product-new/singlePromotionForm.jsp
  59. 2 1
      src/main/webapp/WEB-INF/views/modules/product/repeatPurchasePriceHistoryList.jsp
  60. 122 99
      src/main/webapp/WEB-INF/views/modules/product/repeatPurchasePriceList.jsp
  61. 9 2
      src/main/webapp/static/modules/bulkpurchase/orderForm.js

+ 41 - 40
src/main/java/com/caimei/modules/bulkpurchase/web/PurchaseProductController.java

@@ -155,47 +155,48 @@ public class PurchaseProductController extends BaseController {
                 } else if (null != cmPromotion) {
                     p.setCmPromotion(cmPromotion);
                     p.setLadderPriceFlag(0);
-                } else {
-                    if (p.getLadderPriceFlag().equals(1)) {
-                        // 查询阶梯价格
-                        List<ProductLadderPrice> ladderPriceList = purchaseProductService.findLadderPriceList(p.getProductId());
-                        if (null != ladderPriceList && ladderPriceList.size() > 0) {
-                            p.setPrice(ladderPriceList.get(0).getBuyPrice().toString());
-                            p.setNum(ladderPriceList.get(0).getBuyNum().toString());
-                            IntStream.range(0, ladderPriceList.size()).forEach(i -> {
-                                if (i == ladderPriceList.size() - 1) {
-                                    ladderPriceList.get(i).setBuyNumRangeShow("≥" + ladderPriceList.get(i).getBuyNum());
-                                } else {
-                                    String buyNumRangeShow = ladderPriceList.get(i).getBuyNum() + "~" + (ladderPriceList.get(i + 1).getBuyNum() - 1);
-                                    ladderPriceList.get(i).setBuyNumRangeShow(buyNumRangeShow);
-                                }
-                            });
-                            p.setLadderPriceList(ladderPriceList);
-                        } else {
-                            p.setLadderPriceFlag(0);
-                        }
-                    } else {
-                        // 复购价
-                        if (null != userId) {
-                            String priceProductList = repeatPurchasePriceService.findPriceProductList(userId);
-                            boolean contains = false;
-                            if (StringUtils.isNotEmpty(priceProductList)) {
-                                contains = priceProductList.contains(String.valueOf(productId));
-                            }
-                            if (contains) {//该商品存在价格库商品---修改价格为价格库价格
-                                p.setBuyAgainPriceFlag("1");//商品是否使用复购价格购买标识 0否 1是
-                                RepeatPurchasePrice lastBuyPrice = repeatPurchasePriceService.getLastBuyPrice(null, userId, Integer.parseInt(String.valueOf(productId)));
-                                if (null != lastBuyPrice && MathUtil.compare(p.getPrice(), lastBuyPrice.getCurrentPrice()) > 0) {
-                                    discountPrice = lastBuyPrice.getCurrentPrice();
-                                    p.setDiscountPrice(discountPrice);
-                                    // 计算折扣(折扣=折后单价/单价)[取值1-100]---四舍五入保留6位百分比小数,例如12.341234%
-                                    BigDecimal discount = MathUtil.round((MathUtil.mul((MathUtil.div(discountPrice, p.getPrice(), 8)), 100)), 6);
-                                    p.setDiscount(String.valueOf(discount));
-                                }
-                            }
-                        }
-                    }
                 }
+//                else {
+//                    if (p.getLadderPriceFlag().equals(1)) {
+//                        // 查询阶梯价格
+//                        List<ProductLadderPrice> ladderPriceList = purchaseProductService.findLadderPriceList(p.getProductId());
+//                        if (null != ladderPriceList && ladderPriceList.size() > 0) {
+//                            p.setPrice(ladderPriceList.get(0).getBuyPrice().toString());
+//                            p.setNum(ladderPriceList.get(0).getBuyNum().toString());
+//                            IntStream.range(0, ladderPriceList.size()).forEach(i -> {
+//                                if (i == ladderPriceList.size() - 1) {
+//                                    ladderPriceList.get(i).setBuyNumRangeShow("≥" + ladderPriceList.get(i).getBuyNum());
+//                                } else {
+//                                    String buyNumRangeShow = ladderPriceList.get(i).getBuyNum() + "~" + (ladderPriceList.get(i + 1).getBuyNum() - 1);
+//                                    ladderPriceList.get(i).setBuyNumRangeShow(buyNumRangeShow);
+//                                }
+//                            });
+//                            p.setLadderPriceList(ladderPriceList);
+//                        } else {
+//                            p.setLadderPriceFlag(0);
+//                        }
+//                    } else {
+//                        // 复购价
+//                        if (null != userId) {
+//                            String priceProductList = repeatPurchasePriceService.findPriceProductList(userId);
+//                            boolean contains = false;
+//                            if (StringUtils.isNotEmpty(priceProductList)) {
+//                                contains = priceProductList.contains(String.valueOf(productId));
+//                            }
+//                            if (contains) {//该商品存在价格库商品---修改价格为价格库价格
+//                                p.setBuyAgainPriceFlag("1");//商品是否使用复购价格购买标识 0否 1是
+//                                RepeatPurchasePrice lastBuyPrice = repeatPurchasePriceService.getLastBuyPrice(null, userId, Integer.parseInt(String.valueOf(productId)));
+//                                if (null != lastBuyPrice && MathUtil.compare(p.getPrice(), lastBuyPrice.getCurrentPrice()) > 0) {
+//                                    discountPrice = lastBuyPrice.getCurrentPrice();
+//                                    p.setDiscountPrice(discountPrice);
+//                                    // 计算折扣(折扣=折后单价/单价)[取值1-100]---四舍五入保留6位百分比小数,例如12.341234%
+//                                    BigDecimal discount = MathUtil.round((MathUtil.mul((MathUtil.div(discountPrice, p.getPrice(), 8)), 100)), 6);
+//                                    p.setDiscount(String.valueOf(discount));
+//                                }
+//                            }
+//                        }
+//                    }
+//                }
             }
         }
         model.addAttribute("page", page);

+ 13 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityProductDao.java

@@ -2,6 +2,7 @@ package com.caimei.modules.hehe.dao;
 
 import com.caimei.modules.hehe.entity.CmHeHeActivityLadder;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.modules.product.entity.CmSku;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
@@ -66,4 +67,16 @@ public interface CmHeheActivityProductDao extends CrudDao<CmHeheActivityProduct>
     void deleteUserActivity(Integer productId);
 
     void updateProductId(@Param("newProductId") Integer newProductId, @Param("oldProductId") Integer oldProductId);
+
+    void deleteLadderBySkuId(@Param("activityId")Integer activityId, @Param("skuId")Integer skuId);
+
+    String findPrice(Integer productId);
+
+    List<CmSku> findDiscountSku(Integer productId);
+
+    CmSku findDiscountBySku(Integer skuId);
+
+    void updateDiscount(CmSku s);
+
+    void insertDiscount(CmSku s);
 }

+ 13 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheCollageProductDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.hehe.dao;
 
+import com.caimei.modules.product.entity.CmSku;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.hehe.entity.CmHeheCollageProduct;
@@ -20,4 +21,16 @@ public interface CmHeheCollageProductDao extends CrudDao<CmHeheCollageProduct> {
     Integer getProductId(Integer heheProductId);
 
     void updateProductId(@Param("newProductId") Integer newProductId, @Param("oldProductId") Integer oldProductId);
+
+    List<CmSku> findCollageSku(Integer productId);
+
+    List<CmSku> findCollageByHeHeId(Integer productId);
+
+    void insertSkuCollage(CmSku skus);
+
+    void updateSkuCollage(CmSku s);
+
+    CmSku getSkuCollage(Integer skuId);
+    //展示最低拼团价格
+    Double getCollagePrice(Integer productId);
 }

+ 9 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheProductDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.hehe.dao;
 
+import com.caimei.modules.product.entity.CmLadderPrice;
 import com.caimei.modules.product.entity.Product;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
@@ -80,4 +81,12 @@ public interface CmHeheProductDao extends CrudDao<CmHeheProduct> {
      * @return
      */
     List<Integer> findDiscountProductIds();
+
+    CmHeheProduct findProductElement(Integer productId);
+
+    void insertHeHeSkuPrice(@Param("productId")Integer productId,@Param("skuId") Integer skuId, @Param("price") Double price);
+
+    void updateHeHeSkuPrice(@Param("skuId") Integer skuId, @Param("price") Double price);
+
+    List<CmLadderPrice> findLadderList(Integer skuId);
 }

+ 3 - 0
src/main/java/com/caimei/modules/hehe/dao/HeheDiscountActivityProductDao.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.hehe.dao;
 
+import com.caimei.modules.product.entity.CmSku;
 import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import com.caimei.modules.hehe.entity.HeheDiscountActivityProduct;
@@ -15,4 +16,6 @@ import java.util.List;
 public interface HeheDiscountActivityProductDao extends CrudDao<HeheDiscountActivityProduct> {
 
     List<Integer> findDiscountProductIds();
+
+    List<CmSku> findDiscountSku(Integer productId);
 }

+ 9 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeHeActivityLadder.java

@@ -14,11 +14,20 @@ public class CmHeHeActivityLadder implements Serializable {
     private Integer id;
     private Integer activityId;     //活动id
     private Integer productId;      //对应采美商品id
+    private Integer skuId;
     private Integer ladderNum;  //第几阶梯
     private Integer buyNum;     //购买数量
     private BigDecimal buyPrice;    //购买价格
     private Date createDate;      //创建时间
 
+    public Integer getSkuId() {
+        return skuId;
+    }
+
+    public void setSkuId(Integer skuId) {
+        this.skuId = skuId;
+    }
+
     public Integer getId() {
         return id;
     }

+ 19 - 26
src/main/java/com/caimei/modules/hehe/entity/CmHeheActivityProduct.java

@@ -1,5 +1,6 @@
 package com.caimei.modules.hehe.entity;
 
+import com.caimei.modules.product.entity.CmSku;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
 
@@ -23,10 +24,25 @@ public class CmHeheActivityProduct extends DataEntity<CmHeheActivityProduct> {
     private String name;         //商品名称
     private String mainImage;       //商品图片
     private String shopName;        //供应商名称
-    private BigDecimal price;        // 售价
-    private String unit;        //包装规格
     private Integer userId;         //用户id
-    private List<CmHeHeActivityLadder> activityLadderList;  //活动阶梯
+    private List<CmSku> skus;
+    private Integer LadderFlag; //有无活动价 0无1有
+
+    public Integer getLadderFlag() {
+        return LadderFlag;
+    }
+
+    public void setLadderFlag(Integer ladderFlag) {
+        LadderFlag = ladderFlag;
+    }
+
+    public List<CmSku> getSkus() {
+        return skus;
+    }
+
+    public void setSkus(List<CmSku> skus) {
+        this.skus = skus;
+    }
 
     public CmHeheActivityProduct() {
         super();
@@ -93,22 +109,6 @@ public class CmHeheActivityProduct extends DataEntity<CmHeheActivityProduct> {
         this.shopName = shopName;
     }
 
-    public BigDecimal getPrice() {
-        return price;
-    }
-
-    public void setPrice(BigDecimal price) {
-        this.price = price;
-    }
-
-    public String getUnit() {
-        return unit;
-    }
-
-    public void setUnit(String unit) {
-        this.unit = unit;
-    }
-
     public Integer getUserId() {
         return userId;
     }
@@ -117,11 +117,4 @@ public class CmHeheActivityProduct extends DataEntity<CmHeheActivityProduct> {
         this.userId = userId;
     }
 
-    public List<CmHeHeActivityLadder> getActivityLadderList() {
-        return activityLadderList;
-    }
-
-    public void setActivityLadderList(List<CmHeHeActivityLadder> activityLadderList) {
-        this.activityLadderList = activityLadderList;
-    }
 }

+ 16 - 4
src/main/java/com/caimei/modules/hehe/entity/CmHeheCollageProduct.java

@@ -1,6 +1,9 @@
 package com.caimei.modules.hehe.entity;
 
 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;
@@ -14,17 +17,26 @@ public class CmHeheCollageProduct extends DataEntity<CmHeheCollageProduct> {
 	
 	private static final long serialVersionUID = 1L;
 	private Integer productId;		// 商品id
-	private Double price;		// 拼团价格
+	private Double price;		// 列表展示的最低拼团价格
 	private Integer limitedNum;		// 单人限购量
 	private Integer unlimitedFlag;		// 不限购买量标识:1不限制,0限制
 	private Integer memberNum;		// 拼团人数
 	private Integer status;		// 商品状态:0已下架,1已上架
 	private Date addTime;		// 添加时间
+	private List<CmSku> skus;
 
 	private String shopName;	// 供应商名称
 	private String productName;	// 商品名称
 	private String productImage;	// 商品图片
-	
+
+	public List<CmSku> getSkus() {
+		return skus;
+	}
+
+	public void setSkus(List<CmSku> skus) {
+		this.skus = skus;
+	}
+
 	public CmHeheCollageProduct() {
 		super();
 	}
@@ -40,7 +52,7 @@ public class CmHeheCollageProduct extends DataEntity<CmHeheCollageProduct> {
 	public void setProductId(Integer productId) {
 		this.productId = productId;
 	}
-	
+
 	public Double getPrice() {
 		return price;
 	}
@@ -48,7 +60,7 @@ public class CmHeheCollageProduct extends DataEntity<CmHeheCollageProduct> {
 	public void setPrice(Double price) {
 		this.price = price;
 	}
-	
+
 	public Integer getLimitedNum() {
 		return limitedNum;
 	}

+ 11 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheProduct.java

@@ -1,5 +1,7 @@
 package com.caimei.modules.hehe.entity;
 
+import com.caimei.modules.product.entity.CmSku;
+import com.caimei.modules.product.entity.Sku;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.thinkgem.jeesite.common.persistence.DataEntity;
 import org.hibernate.validator.constraints.Length;
@@ -38,6 +40,15 @@ public class CmHeheProduct extends DataEntity<CmHeheProduct> {
 
     private Integer activityId;     //活动id
     private String floorIds;        //楼层id,以,隔开
+    private List<CmSku> skus;
+
+    public List<CmSku> getSkus() {
+        return skus;
+    }
+
+    public void setSkus(List<CmSku> skus) {
+        this.skus = skus;
+    }
 
     public CmHeheProduct() {
         super();

+ 13 - 1
src/main/java/com/caimei/modules/hehe/entity/HeheDiscountActivityProduct.java

@@ -1,6 +1,9 @@
 package com.caimei.modules.hehe.entity;
 
 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;
@@ -19,10 +22,19 @@ public class HeheDiscountActivityProduct extends DataEntity<HeheDiscountActivity
 	private Integer status;		// 上架状态:0已下架,1已上架
 	private Date addTime;		// 添加时间
 
+	private List<CmSku> skus;
 	private String name;         //商品名称
 	private String mainImage;       //商品图片
 	private String shopName;        //供应商名称
-	
+
+	public List<CmSku> getSkus() {
+		return skus;
+	}
+
+	public void setSkus(List<CmSku> skus) {
+		this.skus = skus;
+	}
+
 	public HeheDiscountActivityProduct() {
 		super();
 	}

+ 39 - 17
src/main/java/com/caimei/modules/hehe/service/CmHeheActivityProductService.java

@@ -1,10 +1,14 @@
 package com.caimei.modules.hehe.service;
 
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
 import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
 import com.caimei.modules.hehe.dao.CmHeheProductDao;
 import com.caimei.modules.hehe.entity.CmHeHeActivityLadder;
 import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.utils.AppUtils;
 import com.caimei.utils.StringUtil;
 import com.thinkgem.jeesite.common.config.Global;
@@ -13,8 +17,11 @@ import com.thinkgem.jeesite.common.service.CrudService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.Assert;
 
 import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -32,10 +39,12 @@ public class CmHeheActivityProductService extends CrudService<CmHeheActivityProd
     @Autowired
     private CmHeheProductDao cmHeheProductDao;
 
+    @Autowired
+    private CmHeheProductService heheProductService;
+
     public CmHeheActivityProduct get(String id) {
         CmHeheActivityProduct activityProduct = super.get(id);
-        List<CmHeHeActivityLadder> activityLadderList = activityProductDao.findActivityLadder(activityProduct.getActivityId(), activityProduct.getProductId());
-        activityProduct.setActivityLadderList(activityLadderList);
+        activityProduct.setSkus(heheProductService.getProductSku(activityProduct.getProductId()));
         return activityProduct;
     }
 
@@ -48,11 +57,19 @@ public class CmHeheActivityProductService extends CrudService<CmHeheActivityProd
         List<CmHeheActivityProduct> productList = productPage.getList();
         String wwwServer = Global.getConfig("wwwServer");
         productList.forEach(item -> {
-            List<CmHeHeActivityLadder> activityLadderList = activityProductDao.findActivityLadder(item.getActivityId(), item.getProductId());
+            List<CmSku> productSku = heheProductService.getProductSku(item.getProductId());
+            item.setSkus(productSku);
+            Integer ladderFlag = 0;
+            for (CmSku cmSku : productSku) {
+                if (null != cmSku.getLadderPriceList() && cmSku.getLadderPriceList().size() > 0) {
+                    ladderFlag = 1;
+                    break;
+                }
+            }
+            item.setLadderFlag(ladderFlag);
             if (StringUtil.isNotBlank(item.getMainImage())) {
                 item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
             }
-            item.setActivityLadderList(activityLadderList);
         });
         return productPage;
     }
@@ -103,20 +120,25 @@ public class CmHeheActivityProductService extends CrudService<CmHeheActivityProd
     @Transactional(readOnly = false)
     public void saveActivityLadder(String params, String id) {
         CmHeheActivityProduct activityProduct = activityProductDao.get(id);
-        if (StringUtil.isNotBlank(params)) {
-            activityProductDao.deleteLadder(activityProduct.getActivityId(), activityProduct.getProductId());
-            CmHeHeActivityLadder ladder = new CmHeHeActivityLadder();
-            ladder.setActivityId(activityProduct.getActivityId());
-            ladder.setProductId(activityProduct.getProductId());
-            int ladderNum = 0;
-            String[] ladders = params.split("-");
-            for (String l : ladders) {
-                ladderNum++;
-                ladder.setLadderNum(ladderNum);
-                ladder.setBuyNum(Integer.valueOf(l.split(",")[0]));
-                ladder.setBuyPrice(new BigDecimal(l.split(",")[1]));
+        Assert.notNull(params);
+        //[{"skuId":"5010","ladder1":"1,313","ladderSize":2,"ladder2":"2,123"},{"skuId":"8273","ladder1":"3,55","ladderSize":2,"ladder2":"5,44"}]
+        JSONArray parse = (JSONArray) JSONArray.parse(params);
+        parse.forEach(p -> {
+            JSONObject json = (JSONObject) p;
+            Integer ladderSize = (Integer) json.get("ladderSize");
+            String skuId = (String) json.get("skuId");
+            activityProductDao.deleteLadderBySkuId(activityProduct.getActivityId(), Integer.valueOf(skuId));
+            for (int i = 0; i < ladderSize; i++) {
+                String o = (String) json.get("ladder" + (i + 1));
+                String[] split = o.split(",");
+                CmHeHeActivityLadder ladder = new CmHeHeActivityLadder();
+                ladder.setActivityId(activityProduct.getActivityId());
+                ladder.setSkuId(Integer.valueOf(skuId));
+                ladder.setLadderNum(i + 1);
+                ladder.setBuyNum(Integer.valueOf(split[0]));
+                ladder.setBuyPrice(new BigDecimal(split[1]));
                 activityProductDao.insertLadder(ladder);
             }
-        }
+        });
     }
 }

+ 82 - 59
src/main/java/com/caimei/modules/hehe/service/CmHeheCollageProductService.java

@@ -3,12 +3,15 @@ package com.caimei.modules.hehe.service;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.function.Consumer;
 
 import com.caimei.modules.hehe.dao.CmHeheFloorProductDao;
 import com.caimei.modules.hehe.dao.CmHeheProductDao;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.utils.AppUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -22,77 +25,97 @@ import javax.annotation.Resource;
 
 /**
  * 呵呵商城拼团商品Service
+ *
  * @author Aslee
  * @version 2021-12-14
  */
 @Service
 @Transactional(readOnly = true)
 public class CmHeheCollageProductService extends CrudService<CmHeheCollageProductDao, CmHeheCollageProduct> {
-	@Resource
-	private CmHeheFloorProductDao cmHeheFloorProductDao;
+    @Resource
+    private CmHeheFloorProductDao cmHeheFloorProductDao;
 
-	@Resource
-	private CmHeheCollageProductDao cmHeheCollageProductDao;
+    @Resource
+    private CmHeheCollageProductDao cmHeheCollageProductDao;
 
-	@Resource
-	private CmHeheProductDao cmHeheProductDao;
+    @Resource
+    private CmHeheProductDao cmHeheProductDao;
 
-	public CmHeheCollageProduct get(String id) {
-		return super.get(id);
-	}
-	
-	public List<CmHeheCollageProduct> findList(CmHeheCollageProduct cmHeheCollageProduct) {
-		return super.findList(cmHeheCollageProduct);
-	}
-	
-	public Page<CmHeheCollageProduct> findPage(Page<CmHeheCollageProduct> page, CmHeheCollageProduct cmHeheCollageProduct) {
-		Page<CmHeheCollageProduct> productPage = super.findPage(page, cmHeheCollageProduct);
-		List<CmHeheCollageProduct> productList = productPage.getList();
-		productList.forEach(product -> product.setProductImage(AppUtils.getImageURL("product", product.getProductImage(), 0, "https://www.caimei365.com/")));
-		return productPage;
-	}
-	
-	@Transactional(readOnly = false)
-	public void save(CmHeheCollageProduct cmHeheCollageProduct) {
-		if (!cmHeheCollageProduct.getIsNewRecord()) {
-			CmHeheCollageProduct dbProduct = get(cmHeheCollageProduct.getId());
-			if (!dbProduct.getProductId().equals(cmHeheCollageProduct.getProductId())) {
-				cmHeheCollageProduct.setProductId(cmHeheCollageProductDao.getProductId(cmHeheCollageProduct.getProductId()));
-			}
-		}
-		super.save(cmHeheCollageProduct);
-	}
-	
-	@Transactional(readOnly = false)
-	public void delete(CmHeheCollageProduct cmHeheCollageProduct) {
-		super.delete(cmHeheCollageProduct);
-	}
+    public CmHeheCollageProduct get(String id) {
+        CmHeheCollageProduct cmHeheCollageProduct = super.get(id);
+        cmHeheCollageProduct.setSkus(cmHeheCollageProductDao.findCollageSku(cmHeheCollageProduct.getProductId()));
+        return cmHeheCollageProduct;
+    }
+
+    public List<CmHeheCollageProduct> findList(CmHeheCollageProduct cmHeheCollageProduct) {
+        return super.findList(cmHeheCollageProduct);
+    }
+
+    public Page<CmHeheCollageProduct> findPage(Page<CmHeheCollageProduct> page, CmHeheCollageProduct cmHeheCollageProduct) {
+        Page<CmHeheCollageProduct> productPage = super.findPage(page, cmHeheCollageProduct);
+        List<CmHeheCollageProduct> productList = productPage.getList();
+        productList.forEach(product -> {
+                    product.setPrice(cmHeheCollageProductDao.getCollagePrice(product.getProductId()));
+                    product.setProductImage(AppUtils.getImageURL("product", product.getProductImage(), 0, "https://www.caimei365.com/"));
+                });
+        return productPage;
+    }
+
+    @Transactional(readOnly = false)
+    public void save(CmHeheCollageProduct cmHeheCollageProduct) {
+        if (!cmHeheCollageProduct.getIsNewRecord()) {
+            CmHeheCollageProduct dbProduct = get(cmHeheCollageProduct.getId());
+            if (!dbProduct.getProductId().equals(cmHeheCollageProduct.getProductId())) {
+                cmHeheCollageProduct.setProductId(cmHeheCollageProductDao.getProductId(cmHeheCollageProduct.getProductId()));
+            }
+            //修改拼团价
+            List<CmSku> skus = cmHeheCollageProduct.getSkus();
+            for (CmSku s : skus) {
+                CmSku price = cmHeheCollageProductDao.getSkuCollage(s.getSkuId());
+                if (null != price) {
+                    cmHeheCollageProductDao.updateSkuCollage(s);
+                } else {
+                    cmHeheCollageProductDao.insertSkuCollage(s);
+                }
+            }
+        } else {
+            //新添加保存不同sku的拼团价
+            List<CmSku> skus = cmHeheCollageProduct.getSkus();
+            skus.forEach(s -> cmHeheCollageProductDao.insertSkuCollage(s));
+        }
+        super.save(cmHeheCollageProduct);
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(CmHeheCollageProduct cmHeheCollageProduct) {
+        super.delete(cmHeheCollageProduct);
+    }
 
     public Page<Product> findProductList(Page<Product> productPage, Product product) {
-		product.setPage(productPage);
-		product.setSearchType(2);
-		// 已参与拼团商品id
-		List<Integer> productIds = cmHeheProductDao.findCollageProductIds();
-		// 已参与商品活动商品id
-		List<Integer> actProductIds = cmHeheProductDao.findActivityProductIds();
-		// 已参与限时特价活动商品id
-		List<Integer> discountProductIds = cmHeheProductDao.findDiscountProductIds();
-		productIds.addAll(actProductIds);
+        product.setPage(productPage);
+        product.setSearchType(2);
+        // 已参与拼团商品id
+        List<Integer> productIds = cmHeheProductDao.findCollageProductIds();
+        // 已参与商品活动商品id
+        List<Integer> actProductIds = cmHeheProductDao.findActivityProductIds();
+        // 已参与限时特价活动商品id
+        List<Integer> discountProductIds = cmHeheProductDao.findDiscountProductIds();
+        productIds.addAll(actProductIds);
         productIds.addAll(discountProductIds);
-		product.setIds(productIds);
-		List<Product> productList = cmHeheFloorProductDao.findAllProduct(product);
-		if (productList != null && productList.size() > 0) {
-			productList.forEach(item -> {
-				item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, "https://www.caimei365.com/"));
-				item.setProductIds(product.getProductIds());
-			});
-		}
-		productPage.setList(productList);
-		return productPage;
+        product.setIds(productIds);
+        List<Product> productList = cmHeheFloorProductDao.findAllProduct(product);
+        if (productList != null && productList.size() > 0) {
+            productList.forEach(item -> {
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, "https://www.caimei365.com/"));
+                item.setProductIds(product.getProductIds());
+            });
+        }
+        productPage.setList(productList);
+        return productPage;
     }
 
-	@Transactional(readOnly = false)
-	public void updateStatus(Integer id, Integer status) {
-		cmHeheCollageProductDao.updateStatus(id, status);
-	}
+    @Transactional(readOnly = false)
+    public void updateStatus(Integer id, Integer status) {
+        cmHeheCollageProductDao.updateStatus(id, status);
+    }
 }

+ 24 - 2
src/main/java/com/caimei/modules/hehe/service/CmHeheProductService.java

@@ -3,6 +3,9 @@ package com.caimei.modules.hehe.service;
 import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
 import com.caimei.modules.hehe.dao.CmHeheProductDao;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.modules.product.dao.ProductDao;
+import com.caimei.modules.product.entity.CmLadderPrice;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.utils.AppUtils;
 import com.caimei.utils.MathUtil;
@@ -32,6 +35,8 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
     private CmHeheProductDao cmHeheProductDao;
     @Autowired
     private CmHeheActivityProductDao activityProductDao;
+    @Autowired
+    private ProductDao productDao;
 
     public CmHeheProduct get(String id) {
         return super.get(id);
@@ -46,6 +51,11 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
         List<CmHeheProduct> list = productPage.getList();
         String wwwServer = Global.getConfig("wwwServer");
         list.forEach(p -> {
+            CmHeheProduct cp = cmHeheProductDao.findProductElement(p.getProductId());
+            p.setCostPrice(cp.getCostPrice());
+            p.setCostProportional(cp.getCostProportional());
+            p.setCostType(cp.getCostType());
+            p.setPrice(cp.getPrice());
             //比例成本
             if ("2".equals(p.getCostType())) {
                 BigDecimal costPrice = MathUtil.div(MathUtil.mul(p.getPrice(), p.getCostProportional()), 100, 2);
@@ -60,18 +70,24 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
     public void save(CmHeheProduct cmHeheProduct) {
         boolean isNewRecord = cmHeheProduct.getIsNewRecord();
         super.save(cmHeheProduct);
+        List<CmSku> skus = cmHeheProduct.getSkus();
         if (isNewRecord) {
             // 添加商品时保存商品楼层和活动
             Integer newActivityId = cmHeheProduct.getActivityId();
             if (newActivityId != null) {
                 cmHeheProductDao.addActivityProduct(cmHeheProduct.getProductId(), newActivityId);
             }
+            //保存新的呵呵price
+            skus.forEach(s -> cmHeheProductDao.insertHeHeSkuPrice(cmHeheProduct.getProductId(), s.getSkuId(), s.getPrice()));
             /*String newFloorIds = cmHeheProduct.getFloorIds();
             String[] floorIdArr = newFloorIds.split(",");
             for (int i = 0; i < floorIdArr.length; i++) {
                 String floorId = floorIdArr[i];
                 cmHeheProductDao.addFloorProduct(cmHeheProduct.getId(), floorId);
             }*/
+        } else {
+            //修改sku呵呵价格
+            skus.forEach(s -> cmHeheProductDao.updateHeHeSkuPrice(s.getSkuId(), s.getPrice()));
         }
     }
 
@@ -83,7 +99,7 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
         //删除分销者活动商品
         activityProductDao.deleteUserActivity(cmHeheProduct.getProductId());
         //删除活动阶梯
-        activityProductDao.deleteLadder(null,cmHeheProduct.getProductId());
+        activityProductDao.deleteLadder(null, cmHeheProduct.getProductId());
     }
 
     public Page<Product> findProductPage(Page<Product> productPage, Product product) {
@@ -96,13 +112,13 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
             if (StringUtil.isNotBlank(item.getMainImage())) {
                 item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
             }
+            item.setSkuList(productDao.findHeHeSku(item.getProductID()));
         });
         productPage.setList(productList);
         return productPage;
     }
 
 
-
     @Transactional(readOnly = false)
     public void updateValidFlag(CmHeheProduct cmHeheProduct) {
         if ("1".equals(cmHeheProduct.getValidFlag())) {
@@ -134,4 +150,10 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
         productPage.setList(productList);
         return productPage;
     }
+
+    public List<CmSku> getProductSku(Integer productId) {
+        List<CmSku> skuList = productDao.findSkuList(productId);
+        skuList.forEach(s -> s.setLadderPriceList(cmHeheProductDao.findLadderList(s.getSkuId())));
+        return skuList;
+    }
 }

+ 3 - 2
src/main/java/com/caimei/modules/hehe/service/CmHeheUserService.java

@@ -31,6 +31,8 @@ public class CmHeheUserService extends CrudService<CmHeheUserDao, CmHeheUser> {
     private CmHeheUserDao cmHeheUserDao;
     @Autowired
     private CmHeheActivityProductDao activityProductDao;
+    @Autowired
+    private CmHeheProductService heheProductService;
 
     public CmHeheUser get(String id) {
         return super.get(id);
@@ -81,11 +83,10 @@ public class CmHeheUserService extends CrudService<CmHeheUserDao, CmHeheUser> {
         List<CmHeheActivityProduct> productList = cmHeheUserDao.activityProductList(activityProduct);
         String wwwServer = Global.getConfig("wwwServer");
         productList.forEach(item -> {
-            List<CmHeHeActivityLadder> activityLadderList = activityProductDao.findActivityLadder(item.getActivityId(), item.getProductId());
+            item.setSkus(heheProductService.getProductSku(item.getProductId()));
             if (StringUtil.isNotBlank(item.getMainImage())) {
                 item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
             }
-            item.setActivityLadderList(activityLadderList);
         });
         productPage.setList(productList);
         return productPage;

+ 24 - 3
src/main/java/com/caimei/modules/hehe/service/HeheDiscountActivityProductService.java

@@ -6,6 +6,7 @@ import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
 import com.caimei.modules.hehe.dao.CmHeheProductDao;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
 import com.caimei.modules.hehe.entity.HeheHomeTypeProduct;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.utils.AppUtils;
 import com.caimei.utils.StringUtil;
 import com.thinkgem.jeesite.common.config.Global;
@@ -18,6 +19,8 @@ import com.thinkgem.jeesite.common.service.CrudService;
 import com.caimei.modules.hehe.entity.HeheDiscountActivityProduct;
 import com.caimei.modules.hehe.dao.HeheDiscountActivityProductDao;
 
+import static org.apache.struts2.interceptor.DateTextFieldInterceptor.DateWord.s;
+
 /**
  * 限时特价商品Service
  * @author Aslee
@@ -34,7 +37,9 @@ public class HeheDiscountActivityProductService extends CrudService<HeheDiscount
 	private CmHeheProductDao cmHeheProductDao;
 
 	public HeheDiscountActivityProduct get(String id) {
-		return super.get(id);
+		HeheDiscountActivityProduct heheDiscountActivityProduct = super.get(id);
+		heheDiscountActivityProduct.setSkus(activityProductDao.findDiscountSku(heheDiscountActivityProduct.getProductId()));
+		return heheDiscountActivityProduct;
 	}
 	
 	public List<HeheDiscountActivityProduct> findList(HeheDiscountActivityProduct heheDiscountActivityProduct) {
@@ -45,15 +50,31 @@ public class HeheDiscountActivityProductService extends CrudService<HeheDiscount
 		Page<HeheDiscountActivityProduct> productPage = super.findPage(page, heheDiscountActivityProduct);
 		List<HeheDiscountActivityProduct> list = productPage.getList();
 		String wwwServer = Global.getConfig("wwwServer");
-		list.forEach(p -> p.setMainImage(AppUtils.getImageURL("product", p.getMainImage(), 0, wwwServer)));
+		list.forEach(p -> {
+			p.setMainImage(AppUtils.getImageURL("product", p.getMainImage(), 0, wwwServer));
+			p.setDiscountPrice(activityProductDao.findPrice(p.getProductId()));
+		});
 		return productPage;
 	}
 	
 	@Transactional(readOnly = false)
 	public void save(HeheDiscountActivityProduct heheDiscountActivityProduct) {
 		super.save(heheDiscountActivityProduct);
+		//修改/保存sku的限时特价
+		List<CmSku> skus = heheDiscountActivityProduct.getSkus();
+		skus.forEach(this::saveDiscountPrice);
 	}
-	
+
+	@Transactional(readOnly = false)
+	public void saveDiscountPrice(CmSku s) {
+		CmSku discount= activityProductDao.findDiscountBySku(s.getSkuId());
+		if(null!=discount){
+			activityProductDao.updateDiscount(s);
+		}else{
+			activityProductDao.insertDiscount(s);
+		}
+	}
+
 	@Transactional(readOnly = false)
 	public void delete(HeheDiscountActivityProduct heheDiscountActivityProduct) {
 		super.delete(heheDiscountActivityProduct);

+ 1 - 0
src/main/java/com/caimei/modules/hehe/web/CmHeheActivityProductController.java

@@ -20,6 +20,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;

+ 13 - 0
src/main/java/com/caimei/modules/hehe/web/CmHeheCollageProductController.java

@@ -3,6 +3,8 @@ package com.caimei.modules.hehe.web;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.caimei.modules.hehe.dao.CmHeheCollageProductDao;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.utils.AppUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
@@ -23,6 +25,7 @@ import com.caimei.modules.hehe.entity.CmHeheCollageProduct;
 import com.caimei.modules.hehe.service.CmHeheCollageProductService;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -36,6 +39,9 @@ public class CmHeheCollageProductController extends BaseController {
 
 	@Autowired
 	private CmHeheCollageProductService cmHeheCollageProductService;
+
+	@Autowired
+	private CmHeheCollageProductDao cmHeheCollageProductDao;
 	
 	@ModelAttribute
 	public CmHeheCollageProduct get(@RequestParam(required=false) String id) {
@@ -106,4 +112,11 @@ public class CmHeheCollageProductController extends BaseController {
 		return map;
 	}
 
+	@RequestMapping(value = "getSku")
+	@ResponseBody
+	public List<CmSku> updateStatus(Integer productId) {
+		List<CmSku> collageSku = cmHeheCollageProductDao.findCollageByHeHeId(productId);
+		return collageSku;
+	}
+
 }

+ 9 - 2
src/main/java/com/caimei/modules/hehe/web/CmHeheProductController.java

@@ -1,12 +1,16 @@
 package com.caimei.modules.hehe.web;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.alibaba.fastjson.JSON;
 import com.caimei.modules.hehe.entity.CmHeheActivity;
 import com.caimei.modules.hehe.entity.CmHeheFloor;
 import com.caimei.modules.hehe.service.CmHeheActivityService;
 import com.caimei.modules.hehe.service.CmHeheFloorService;
+import com.caimei.modules.product.dao.ProductDao;
+import com.caimei.modules.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.product.service.ProductService;
 import com.google.common.collect.Maps;
@@ -75,6 +79,8 @@ public class CmHeheProductController extends BaseController {
 
     @RequestMapping(value = "form")
     public String form(CmHeheProduct cmHeheProduct, Model model) {
+        List<CmSku> skuList = productService.findHeHeSku(cmHeheProduct.getProductId());
+        cmHeheProduct.setSkus(skuList);
         model.addAttribute("cmHeheProduct", cmHeheProduct);
         CmHeheFloor cmHeheFloor = new CmHeheFloor();
         cmHeheFloor.setStatus("1");
@@ -82,7 +88,7 @@ public class CmHeheProductController extends BaseController {
         List<CmHeheFloor> floorList = cmHeheFloorService.findList(cmHeheFloor);
         String floorIds = cmHeheProduct.getFloorIds();
         if (StringUtils.isNotEmpty(floorIds)) {
-            floorList.forEach(floor->{
+            floorList.forEach(floor -> {
                 if (floorIds.contains(floor.getId())) {
                     floor.setChecked(true);
                 }
@@ -95,7 +101,7 @@ public class CmHeheProductController extends BaseController {
         List<CmHeheActivity> activityList = cmHeheActivityService.findList(cmHeheActivity);
         String activityId = cmHeheProduct.getActivityId() + "";
         if (StringUtils.isNotEmpty(activityId)) {
-            activityList.forEach(activity->{
+            activityList.forEach(activity -> {
                 if (activityId.equals(activity.getId())) {
                     activity.setChecked(true);
                 }
@@ -129,6 +135,7 @@ public class CmHeheProductController extends BaseController {
     public String findProductPage(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
         Page<Product> page = cmHeheProductService.findProductPage(new Page<Product>(request, response), product);
         model.addAttribute("page", page);
+        model.addAttribute("productList", JSON.toJSONString(page.getList()));
         return "modules/hehe/heheAddProduct";
     }
 

+ 13 - 1
src/main/java/com/caimei/modules/hehe/web/HeheDiscountActivityProductController.java

@@ -3,8 +3,10 @@ package com.caimei.modules.hehe.web;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import com.caimei.modules.hehe.dao.HeheDiscountActivityProductDao;
 import com.caimei.modules.hehe.entity.CmHeheProduct;
 import com.caimei.modules.hehe.entity.HeheDiscountActivityProduct;
+import com.caimei.modules.product.entity.CmSku;
 import com.google.common.collect.Maps;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -23,6 +25,7 @@ import com.thinkgem.jeesite.common.utils.StringUtils;
 import com.caimei.modules.hehe.entity.HeheDiscountActivityProduct;
 import com.caimei.modules.hehe.service.HeheDiscountActivityProductService;
 
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -36,7 +39,10 @@ public class HeheDiscountActivityProductController extends BaseController {
 
 	@Autowired
 	private HeheDiscountActivityProductService heheDiscountActivityProductService;
-	
+
+	@Autowired
+	private HeheDiscountActivityProductDao discountDao;
+
 	@ModelAttribute
 	public HeheDiscountActivityProduct get(@RequestParam(required=false) String id) {
 		HeheDiscountActivityProduct entity = null;
@@ -106,4 +112,10 @@ public class HeheDiscountActivityProductController extends BaseController {
 		model.addAttribute("page", page);
 		return "modules/hehe/addDiscountProduct";
 	}
+
+	@RequestMapping(value = "getSku")
+	@ResponseBody
+	public List<CmSku> updateStatus(Integer productId) {
+		return discountDao.findDiscountSku(productId);
+	}
 }

+ 8 - 0
src/main/java/com/caimei/modules/order/entity/LogisticsRecord.java

@@ -25,6 +25,7 @@ public class LogisticsRecord extends DataEntity<LogisticsRecord> {
     private String productName; //商品名称
     private String image; //商品图片
     private String sn;     //SN码
+    private String unit;   //规格
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date uploadTime;    //上传商品资质时间
     private String shopName; //供应商名称
@@ -35,6 +36,13 @@ public class LogisticsRecord extends DataEntity<LogisticsRecord> {
     private String[] files;
     private Integer recordId; //发货记录id
 
+    public String getUnit() {
+        return unit;
+    }
+
+    public void setUnit(String unit) {
+        this.unit = unit;
+    }
 
     public Integer getLogisticsBatchID() {
         return logisticsBatchID;

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

@@ -1046,7 +1046,7 @@ public class NewOrderService extends CrudService<NewOrderDao, NewOrder> {
             }
             if (o.getProductType() == 1 || o.getProductType() == 2) {
                 // 赠品订单过来售价为0,去数据库获取该商品原始售价
-                Double tempPrice = cmPromotionDao.getPresentPriceById(o.getProductID());
+                Double tempPrice = cmPromotionDao.getPresentPriceById(o.getSkuID());
                 if (null != tempPrice && tempPrice > 0) {
                     price = tempPrice;
                 }

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

@@ -94,7 +94,7 @@ public interface CmPromotionDao extends CrudDao<CmPromotion> {
      */
     CmPromotion findPromotionsByProductId(@Param("productId") Integer productId);
 
-    Double getPresentPriceById(@Param("productId") Integer productId);
+    Double getPresentPriceById(@Param("skuId") Integer skuId);
     List<Integer> findProductIdByPromotion(String promotionsId);
     List<Integer> findProductIdsByPromotion(String promotionsId);
 }

+ 5 - 1
src/main/java/com/caimei/modules/product/dao/ProductDao.java

@@ -166,7 +166,7 @@ public interface ProductDao extends CrudDao<Product> {
 
     void deleteLadderPriceByProductId(Integer productID);
 
-    void deleteLadderPriceById(Integer id);
+    void deleteLadderPriceById(Integer productId);
 
     List<Product> findActList(Product product);
 
@@ -203,4 +203,8 @@ public interface ProductDao extends CrudDao<Product> {
     List<CmSku> findSkuList(Integer productID);
 
     List<CmLadderPrice> findLadderPriceBySku(@Param("skuId") Integer skuId, @Param("productId") Integer productId);
+
+    Product getBySku(String skuId);
+
+    List<CmSku> findHeHeSku(Integer productId);
 }

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

@@ -1,6 +1,7 @@
 package com.caimei.modules.product.entity;
 
 import com.caimei.po.ProductLadderPrice;
+import com.thinkgem.jeesite.common.persistence.DataEntity;
 import lombok.Data;
 import lombok.experimental.Accessors;
 
@@ -12,7 +13,7 @@ import java.util.List;
 @SuppressWarnings("all")
 @Data
 @Accessors(fluent = true)
-public class CmSku {
+public class CmSku extends DataEntity<CmSku> {
     private Integer skuId;
     private Integer productId;
     private String unit;        // 包装规格
@@ -24,8 +25,26 @@ public class CmSku {
     private Double price;        // 机构价
     private Integer ladderPriceFlag;        // 启用阶梯价格标识 0否 1是
     private Integer minBuyNumber;        // 无阶梯价起订量
+    private Double collagePrice;   //拼团价
+    private Double discountPrice;  //限时特价
     private List<CmLadderPrice> ladderPriceList;
 
+    public Double getCollagePrice() {
+        return collagePrice;
+    }
+
+    public void setCollagePrice(Double collagePrice) {
+        this.collagePrice = collagePrice;
+    }
+
+    public Double getDiscountPrice() {
+        return discountPrice;
+    }
+
+    public void setDiscountPrice(Double discountPrice) {
+        this.discountPrice = discountPrice;
+    }
+
     public Integer getProductId() {
         return productId;
     }

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

@@ -90,7 +90,7 @@ public class Product extends DataEntity<Product> {
     private List<CmSku> skuList;
     //-----------------  虚拟字段 ----
     private Integer skuId;
-    private Integer shopType; //供应商类别,0未审核的二手供应商,普通1,新品供应商2,二手供应商3
+    private Integer shopType; //供应商类别,0未审核的二手供应商,1普通,2新品供应商,3二手供应商
     private boolean customClass = false;  //是否有自定义分类
     private String brandName;//品牌名称
     private String otherBrandName;//其他手填品牌名称

+ 9 - 0
src/main/java/com/caimei/modules/product/entity/RepeatPurchasePrice.java

@@ -28,6 +28,15 @@ public class RepeatPurchasePrice extends DataEntity<RepeatPurchasePrice> {
     private String orderId;   //
     private Integer clubId;   //
 	private String delFlag;   //删除标记 0否 其余是
+	private String unit;  //规格
+
+	public String getUnit() {
+		return unit;
+	}
+
+	public void setUnit(String unit) {
+		this.unit = unit;
+	}
 
 	public String getDelFlag() {
 		return delFlag;

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

@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
 import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
 import com.caimei.modules.cibe.entity.Shop;
 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.product.entity.CmSku;
 import com.caimei.modules.product.entity.Product;
 import com.caimei.modules.product.entity.RepeatPurchasePrice;
 import com.caimei.utils.AppUtils;
@@ -22,17 +24,16 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 @Transactional(readOnly = true)
 public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion> {
     @Autowired
     private CmPromotionDao cmPromotionDao;
-
+    @Autowired
+    private ProductDao productDao;
     @Override
     public CmPromotion get(String id) {
         return super.get(id);
@@ -225,6 +226,10 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         productList = cmPromotionDao.findAllProduct(product);
         String wwwServer = Global.getConfig("wwwServer");
         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);
+            item.setPrice(collect.get(0).getPrice());
             item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
         });
         productPage.setList(productList);
@@ -309,7 +314,8 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
         if (StringUtil.isNotBlank(cmPromotion.getGiftIds())) {
             List<HashMap> list = JSONArray.parseArray(cmPromotion.getGiftIds(), HashMap.class);
             for (HashMap map : list) {
-                String giftId = (String) map.get("productId");
+                //赠品改为skuId
+                String giftId = (String) map.get("skuId");
                 Integer number = Integer.parseInt(map.get("number").toString());
                 cmPromotionDao.insertGiftProduct(promotionId, giftId, number);
             }

+ 20 - 37
src/main/java/com/caimei/modules/product/service/ProductService.java

@@ -35,9 +35,9 @@ import java.util.*;
 public class ProductService extends CrudService<ProductDao, Product> {
 
     @Autowired
-    ProductDao productDao;
+    private ProductDao productDao;
     @Autowired
-    CmBrandDao cmBrandDao;
+    private CmBrandDao cmBrandDao;
     @Autowired
     private CmBigtypeDao cmBigtypeDao;
     @Autowired
@@ -47,7 +47,7 @@ public class ProductService extends CrudService<ProductDao, Product> {
     @Resource
     private ProductNewDao productNewDao;
     @Autowired
-    NewPageFloorDao newPageFloorDao;
+    private NewPageFloorDao newPageFloorDao;
 
     @Override
     public Product get(String id) {
@@ -374,7 +374,6 @@ public class ProductService extends CrudService<ProductDao, Product> {
 
     @Transactional(readOnly = false)
     public void saveProduct(Product product, ProductDetailInfo productDetailInfo) {
-        List<ProductLadderPrice> ladderPriceList = product.getLadderPriceList();
         // 上传商品图片
         String qualificationImg = product.getQualificationImg();
         String photoServer = Global.getConfig("photoServer");//获取文件服务器地址
@@ -453,49 +452,25 @@ public class ProductService extends CrudService<ProductDao, Product> {
         } else {
             productDao.insertProductDetailInfo(productDetailInfo);
         }
-        User user = UserUtils.getUser();
-        if ("1".equals(product.getLadderPriceFlag())) {
-            for (int i = 0; i < ladderPriceList.size(); i++) {
-                Integer buyNum = ladderPriceList.get(i).getBuyNum();
-                Double buyPrice = ladderPriceList.get(i).getBuyPrice();
-                Integer ladderId = ladderPriceList.get(i).getId();
-                String delFlag = ladderPriceList.get(i).getDelFlag();
-                if ("0".equals(delFlag) && null != buyNum && null != buyPrice && !"".equals(buyPrice)) {
-                    ladderPriceList.get(i).setProductId(product.getProductID());
-                    ladderPriceList.get(i).setLadderNum(i + 1);
-                    ladderPriceList.get(i).setUpdateDate(new Date());
-                    ladderPriceList.get(i).setUpdateBy(user.getId());
-                    if (null != ladderId) {
-                        productDao.updateLadderPrice(ladderPriceList.get(i));
-                    } else {
-                        ladderPriceList.get(i).setCreateDate(new Date());
-                        ladderPriceList.get(i).setCreateBy(user.getId());
-                        ladderPriceList.get(i).setDelFlag("0");
-                        productDao.insertLadderPrice(ladderPriceList.get(i));
-                    }
-                } else {
-                    if (null != ladderId) {
-                        productDao.deleteLadderPriceById(ladderId);
-                    } else {
-                        break;
-                    }
-                }
-            }
-        }
     }
 
     public void addSkus(Product product) {
         //保存sku
         List<CmSku> skuList = product.getSkuList();
         if (null != skuList && skuList.size() > 0) {
+            productDao.deleteLadderPriceById(product.getProductID());
             skuList.forEach(s -> {
                 s.productId(product.getProductID());
                 productDao.insertSku(s);
                 if (null != s.ladderPriceFlag() && 1 == s.ladderPriceFlag()) {
-                    s.ladderPriceList().forEach(l -> {
-                        l.skuId(s.skuId());
-                        productDao.insertCmLadderPrice(l);
-                    });
+                    List<CmLadderPrice> cmLadderPrices = s.ladderPriceList();
+                    for (int i = 0; i < cmLadderPrices.size(); i++) {
+                        if (0 == i || "0".equals(cmLadderPrices.get(i).delFlag())) {
+                            cmLadderPrices.get(i).setProductId(product.getProductID());
+                            cmLadderPrices.get(i).setSkuId(s.getSkuId());
+                            productDao.insertCmLadderPrice(cmLadderPrices.get(i));
+                        }
+                    }
                 }
             });
         }
@@ -636,4 +611,12 @@ public class ProductService extends CrudService<ProductDao, Product> {
         });
         return skus;
     }
+
+    public Product getBySku(String skuId) {
+        return productDao.getBySku(skuId);
+    }
+
+    public List<CmSku> findHeHeSku(Integer productId) {
+        return productDao.findHeHeSku(productId);
+    }
 }

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

@@ -167,16 +167,17 @@ public class CmPromotionController extends BaseController {
                 }
             }
             if (StringUtil.isNotBlank(cmPromotion.getGiftIds())) {
+                //设置页面传过来的勾选赠品skuId
                 if (cmPromotion.getGiftIds().contains(",")) {
                     String[] split = cmPromotion.getGiftIds().split(",");
-                    for (String giftId : split) {
-                        if (StringUtil.isNotBlank(giftId)) {
-                            Product product = productService.get(giftId);
+                    for (String skuId : split) {
+                        if (StringUtil.isNotBlank(skuId)) {
+                            Product product = productService.getBySku(skuId);
                             giftProducts.add(product);
                         }
                     }
                 } else {
-                    Product product = productService.get(cmPromotion.getGiftIds());
+                    Product product = productService.getBySku(cmPromotion.getGiftIds());
                     giftProducts.add(product);
                 }
             }

+ 8 - 4
src/main/java/com/caimei/modules/product/web/ProductNewController.java

@@ -503,10 +503,14 @@ public class ProductNewController extends BaseController {
             redirectAttributes.addAttribute("searchPreferredFlag", product.getSearchPreferredFlag());
             redirectAttributes.addAttribute("searchProductCategory", product.getSearchProductCategory());
         }
-        // 有数据变动时需要清除缓存
-        cleanRedisCache();
-        // 更新索引
-        coreServiceUitls.updateProductIndex(product.getProductID());
+        try {
+            // 有数据变动时需要清除缓存
+            cleanRedisCache();
+            // 更新索引
+            coreServiceUitls.updateProductIndex(product.getProductID());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         return "redirect:" + Global.getAdminPath() + "/product/new/list/";
     }
 

+ 187 - 188
src/main/resources/mappings/modules/bulkpurchase/PurchaseProductMapper.xml

@@ -2,15 +2,15 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.bulkpurchase.dao.PurchaseProductDao">
 
-	<resultMap id="resultShop" type="PurchaseProduct">
-		<result column="productID" property="productId"/>
-		<result column="name" property="purchaseProductName"/>
-		<result column="shopName" property="shopName"/>
-		<result column="shopID" property="shopId"/>
-		<result column="price" property="price"/>
-	</resultMap>
-	<sql id="purchaseProductColumns">
-		a.id AS "id",
+    <resultMap id="resultShop" type="PurchaseProduct">
+        <result column="productID" property="productId"/>
+        <result column="name" property="purchaseProductName"/>
+        <result column="shopName" property="shopName"/>
+        <result column="shopID" property="shopId"/>
+        <result column="price" property="price"/>
+    </resultMap>
+    <sql id="purchaseProductColumns">
+        a.id AS "id",
 		a.contractId AS "contractId",
 		a.productId AS "productId",
 		a.discount AS "discount",
@@ -22,193 +22,192 @@
 		a.shopFee AS "shopFee",
 		a.otherFee AS "otherFee",
 		a.cmFee AS "cmFee"
-	</sql>
+    </sql>
 
 
-	<sql id="purchaseProductJoins">
-	</sql>
+    <sql id="purchaseProductJoins">
+    </sql>
 
 
+    <select id="get" resultType="PurchaseProduct">
+        SELECT
+        <include refid="purchaseProductColumns"/>
+        FROM bp_product a
+        <include refid="purchaseProductJoins"/>
+        WHERE a.id = #{id}
+    </select>
+    <select id="findProductList" resultType="PurchaseProduct">
 
-	<select id="get" resultType="PurchaseProduct">
-		SELECT
-			<include refid="purchaseProductColumns"/>
-		FROM bp_product a
-		<include refid="purchaseProductJoins"/>
-		WHERE a.id = #{id}
-	</select>
-	<select id="findProductList" resultType="PurchaseProduct">
+    </select>
 
-	</select>
+    <select id="findList" resultType="PurchaseProduct">
+        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
+        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
+        <where>
+            <if test="purchaseProductName != null and purchaseProductName != ''">
+                AND a.name LIKE concat('%',#{purchaseProductName},'%')
+            </if>
+            <if test="productId != null and productId != ''">
+                AND a.productID = #{productId}
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND b.name like concat('%',#{shopName},'%')
+            </if>
+            and (a.validFlag=2 or a.validFlag = 9)
+            AND a.productID != 999
+            and a.productCategory = 1
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+    <select id="findAllList" resultType="PurchaseProduct">
+        SELECT
+        <include refid="purchaseProductColumns"/>
+        FROM bp_product a
+        <include refid="purchaseProductJoins"/>
+        <where>
+            a.delFlag = 0
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
 
-	<select id="findList" resultType="PurchaseProduct" >
-		SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
-		a.price,a.`productID` productId,a.productCode productNo,a.mainImage image
-		,a.costCheckFlag costCheckFlag,a.costPrice costPrice,a.costProportional costProportional, a.normalPrice AS normalPrice
-		,a.ladderPriceFlag as ladderPriceFlag
-		,a.includedTax AS includedTax, a.invoiceType AS invoiceType, a.taxPoint AS taxRate, a.supplierTaxPoint AS supplierTaxRate,
-		a.minBuyNumber AS num, 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
-		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
-		<where>
-			<if test="purchaseProductName != null and purchaseProductName != ''">
-				AND a.name LIKE concat('%',#{purchaseProductName},'%')
-			</if>
-			<if test="productId != null and productId != ''">
-				AND a.productID = #{productId}
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND b.name  like concat('%',#{shopName},'%')
-			</if>
-				and (a.validFlag=2 or a.validFlag = 9)
-			    AND a.productID != 999
-			    and a.productCategory  = 1
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	<select id="findAllList" resultType="PurchaseProduct">
-		SELECT
-			<include refid="purchaseProductColumns"/>
-		FROM bp_product a
-		<include refid="purchaseProductJoins"/>
-		<where>
-			a.delFlag = 0
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
+    <insert id="insert" parameterType="PurchaseProduct" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO bp_product(id,
+                               contractId,
+                               productId,
+                               shopId,
+                               discount,
+                               discountPrice,
+                               taxRate,
+                               addedValueTax,
+                               stipulateFlag,
+                               delFlag,
+                               shopFee,
+                               otherFee,
+                               cmFee)
+        VALUES (#{id},
+                #{contractId},
+                #{productId},
+                #{shopId},
+                #{discount},
+                #{discountPrice},
+                #{taxRate},
+                #{addedValueTax},
+                #{stipulateFlag},
+                #{delFlag},
+                #{shopFee},
+                #{otherFee},
+                #{cmFee})
+    </insert>
+    <select id="getPurchaseProductByCtId" resultMap="resultShop">
+        SELECT a.*, b.name shopName, c.name, c.price
+        FROM bp_product a
+                 LEFT JOIN shop b ON a.shopId = b.`shopID`
+                 JOIN product c ON a.productId = c.productid
+        WHERE a.`contractId` = #{contractId}
+          AND a.delFlag = 0
+          and c.productCategory = 1
+    </select>
+    <update id="update">
+        UPDATE bp_product
+        SET contractId    = #{contractId},
+            productId     = #{productId},
+            shopId        = #{shopId},
+            discount      = #{discount},
+            discountPrice = #{discountPrice},
+            taxRate       = #{taxRate},
+            addedValueTax = #{addedValueTax},
+            stipulateFlag = #{stipulateFlag},
+            delFlag       = #{delFlag},
+            shopFee       = #{shopFee},
+            otherFee      = #{otherFee},
+            cmFee         = #{cmFee}
+        WHERE id = #{id}
+    </update>
 
-	<insert id="insert" parameterType="PurchaseProduct"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO bp_product(
-			id,
-			contractId,
-			productId,
-			shopId,
-			discount,
-			discountPrice,
-			taxRate,
-			addedValueTax,
-			stipulateFlag,
-			delFlag,
-			shopFee,
-			otherFee,
-			cmFee
-		) VALUES (
-			#{id},
-			#{contractId},
-			#{productId},
-			#{shopId},
-			#{discount},
-			#{discountPrice},
-			#{taxRate},
-			#{addedValueTax},
-			#{stipulateFlag},
-			#{delFlag},
-			#{shopFee},
-			#{otherFee},
-			#{cmFee}
-		)
-	</insert>
-	<select id="getPurchaseProductByCtId" resultMap="resultShop">
-	SELECT a.* ,b.name shopName , c.name ,c.price FROM bp_product a LEFT JOIN shop b ON a.shopId=b.`shopID`  JOIN product c ON a.productId =c.productid
-  WHERE a.`contractId` =#{contractId}
-  AND a.delFlag = 0
-  and c.productCategory  = 1
-	</select>
-	<update id="update">
-		UPDATE bp_product SET
-			contractId = #{contractId},
-			productId = #{productId},
-			shopId = #{shopId},
-			discount = #{discount},
-			discountPrice = #{discountPrice},
-			taxRate = #{taxRate},
-			addedValueTax = #{addedValueTax},
-			stipulateFlag = #{stipulateFlag},
-			delFlag = #{delFlag},
-			shopFee = #{shopFee},
-			otherFee = #{otherFee},
-			cmFee = #{cmFee}
-		WHERE id = #{id}
-	</update>
-
-	<delete id="delete">
-		DELETE FROM bp_product
-		WHERE id = #{id}
-	</delete>
-	<select id="findCount" resultType="Integer">
-		SELECT count(1) FROM `bp_product` where contractId = #{contractId} AND  delFlag = 0
-	</select>
-	<select id="findSencondProductPage" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
-		SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
-		a.price,a.`productID` productId,a.productCode productNo,a.mainImage image
-		,a.costCheckFlag costCheckFlag,a.costPrice costPrice,a.costProportional costProportional, a.normalPrice
-		,a.productCategory as  "productCategory",cshd.secondHandType as  "secondHandType",a.ladderPriceFlag
-		,a.includedTax,a.invoiceType
-		FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
-		left join cm_second_hand_detail cshd on cshd.productID = a.productID
-		<where>
-			<if test="purchaseProductName != null and purchaseProductName != ''">
-				AND a.name LIKE concat('%',#{purchaseProductName},'%')
-			</if>
-			<if test="productId != null and productId != ''">
-				AND a.productID = #{productId}
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND b.name  like concat('%',#{shopName},'%')是否含税
-			</if>
-				and a.validFlag=2
-			    AND a.productID != 999
-			    and a.productCategory  = 2
-			    and cshd.sold != 1
-		</where>
-<!--		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>-->
-	</select>
-	<select id="findLadderPriceList" resultType="com.caimei.po.ProductLadderPrice">
-		SELECT *
-		FROM product_ladder_price
-		WHERE
-		productId = #{productId}
-		AND buyNum is NOT null
-		AND buyPrice is NOT null
-		AND delFlag = 0
-		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
-		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>
+    <delete id="delete">
+        DELETE
+        FROM bp_product
+        WHERE id = #{id}
+    </delete>
+    <select id="findCount" resultType="Integer">
+        SELECT count(1)
+        FROM `bp_product`
+        where contractId = #{contractId}
+          AND delFlag = 0
+    </select>
+    <select id="findSencondProductPage" resultType="com.caimei.modules.bulkpurchase.entity.PurchaseProduct">
+        SELECT b.name shopName ,b.`shopID` shopId,a.name purchaseProductName,
+        a.price,a.`productID` productId,a.productCode productNo,a.mainImage image
+        ,a.costCheckFlag costCheckFlag,a.costPrice costPrice,a.costProportional costProportional, a.normalPrice
+        ,a.productCategory as "productCategory",cshd.secondHandType as "secondHandType",a.ladderPriceFlag
+        ,a.includedTax,a.invoiceType
+        FROM product a LEFT JOIN shop b ON b.shopID=a.shopID
+        left join cm_second_hand_detail cshd on cshd.productID = a.productID
+        <where>
+            <if test="purchaseProductName != null and purchaseProductName != ''">
+                AND a.name LIKE concat('%',#{purchaseProductName},'%')
+            </if>
+            <if test="productId != null and productId != ''">
+                AND a.productID = #{productId}
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND b.name like concat('%',#{shopName},'%')是否含税
+            </if>
+            and a.validFlag=2
+            AND a.productID != 999
+            and a.productCategory = 2
+            and cshd.sold != 1
+        </where>
+        <!--		<choose>
+                    <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                        ORDER BY ${page.orderBy}
+                    </when>
+                    <otherwise>
+                    </otherwise>
+                </choose>-->
+    </select>
+    <select id="findLadderPriceList" resultType="com.caimei.po.ProductLadderPrice">
+        SELECT *
+        FROM product_ladder_price
+        WHERE productId = #{productId}
+          AND buyNum is NOT null
+          AND buyPrice is NOT null
+          AND delFlag = 0
+        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
+        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
-		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 csp.priceType,
+               if(csp.id is not null and csu.id is not null, 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>
 </mapper>

+ 200 - 166
src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml

@@ -1,181 +1,215 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.hehe.dao.CmHeheActivityProductDao">
-    
-	<sql id="cmHeheActivityProductColumns">
-		a.id AS "id",
+
+    <sql id="cmHeheActivityProductColumns">
+        a.id AS "id",
 		a.activityId AS "activityId",
 		a.productId AS "productId",
 		a.addTime AS "addTime",
 		a.delFlag AS "delFlag",
-		chp.price AS "price",
 		p.name AS "name",
 		p.mainImage AS "mainImage",
-		p.unit AS "unit",
 		s.name AS "shopName"
-	</sql>
-	
-	<sql id="cmHeheActivityProductJoins">
-		LEFT JOIN cm_hehe_product chp ON chp.productId = a.productID
+    </sql>
+
+    <sql id="cmHeheActivityProductJoins">
+        LEFT JOIN cm_hehe_product chp ON chp.productId = a.productID
 		LEFT JOIN product p ON a.productId = p.productID
 		LEFT JOIN shop s ON s.shopID = p.shopID
-	</sql>
-    
-	<select id="get" resultType="CmHeheActivityProduct">
-		SELECT 
-			<include refid="cmHeheActivityProductColumns"/>
-		FROM cm_hehe_activity_product a
-		<include refid="cmHeheActivityProductJoins"/>
-		WHERE a.id = #{id}
-	</select>
-	
-	<select id="findList" resultType="CmHeheActivityProduct">
-		SELECT 
-			<include refid="cmHeheActivityProductColumns"/>
-		FROM cm_hehe_activity_product a
-		<include refid="cmHeheActivityProductJoins"/>
-		<where>
-			a.delFlag = 0
-			AND a.activityId = #{activityId}
-			and chp.id is not null
-			<if test="name != null and name != ''">
-				AND p.name LIKE CONCAT('%',#{name},'%')
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND s.name LIKE CONCAT('%',#{shopName},'%')
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY a.addTime DESC
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="CmHeheActivityProduct">
-		SELECT 
-			<include refid="cmHeheActivityProductColumns"/>
-		FROM cm_hehe_activity_product a
-		<include refid="cmHeheActivityProductJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	
-	<insert id="insert" parameterType="CmHeheActivityProduct"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO cm_hehe_activity_product(
-			activityId,
-			productId,
-			addTime,
-			delFlag
-		) VALUES (
-			#{activityId},
-			#{productId},
-			NOW(),
-			0
-		)
-	</insert>
-	
-	<update id="update">
-		UPDATE cm_hehe_activity_product SET 	
-			activityId = #{activityId},
-			productId = #{productId},
-			addTime = #{addTime}
-		WHERE id = #{id}
-	</update>
-	
-	<update id="delete">
-		UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE id = #{id}
-	</update>
+    </sql>
+
+    <select id="get" resultType="CmHeheActivityProduct">
+        SELECT
+        <include refid="cmHeheActivityProductColumns"/>
+        FROM cm_hehe_activity_product a
+        <include refid="cmHeheActivityProductJoins"/>
+        WHERE a.id = #{id}
+    </select>
+
+    <select id="findList" resultType="CmHeheActivityProduct">
+        SELECT
+        <include refid="cmHeheActivityProductColumns"/>
+        FROM cm_hehe_activity_product a
+        <include refid="cmHeheActivityProductJoins"/>
+        <where>
+            a.delFlag = 0
+            AND a.activityId = #{activityId}
+            and chp.id is not null
+            <if test="name != null and name != ''">
+                AND p.name LIKE CONCAT('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE CONCAT('%',#{shopName},'%')
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                ORDER BY a.addTime DESC
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findAllList" resultType="CmHeheActivityProduct">
+        SELECT
+        <include refid="cmHeheActivityProductColumns"/>
+        FROM cm_hehe_activity_product a
+        <include refid="cmHeheActivityProductJoins"/>
+        <where>
+
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+
+    <insert id="insert" parameterType="CmHeheActivityProduct" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_hehe_activity_product(activityId,
+                                             productId,
+                                             addTime,
+                                             delFlag)
+        VALUES (#{activityId},
+                #{productId},
+                NOW(),
+                0)
+    </insert>
+
+    <update id="update">
+        UPDATE cm_hehe_activity_product
+        SET activityId = #{activityId},
+            productId  = #{productId},
+            addTime    = #{addTime}
+        WHERE id = #{id}
+    </update>
+
+    <update id="delete">
+        UPDATE cm_hehe_activity_product
+        SET delFlag = 1
+        WHERE id = #{id}
+    </update>
     <update id="updateProductId">
-		update cm_hehe_activity_product set productId = #{newProductId} where productId = #{oldProductId}
-	</update>
+        update cm_hehe_activity_product
+        set productId = #{newProductId}
+        where productId = #{oldProductId}
+    </update>
+
+    <update id="updateDiscount">
+        update cm_hehe_discount_activity_sku
+        set discountPrice=#{discountPrice}
+        where skuId = #{skuId}
+    </update>
+
+    <select id="findAllHeHeProduct" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
+        SELECT
+        a.id AS "id",
+        a.productId AS "productId",
+        p.name AS "name",
+        p.mainImage AS "mainImage",
+        s.name AS "shopName"
+        FROM
+        cm_hehe_product a
+        LEFT JOIN product p ON a.productId = p.productID
+        LEFT JOIN shop s ON s.shopID = p.shopID
+        WHERE
+        a.validFlag = 1
+        <if test="ids != null and ids.size() > 0 ">
+            AND a.productId NOT IN
+            <foreach collection="ids" open="(" close=")" item="id" separator=",">
+                #{id,jdbcType=INTEGER}
+            </foreach>
+        </if>
+        <if test="productId != null">
+            AND a.productId = #{productId,jdbcType=INTEGER}
+        </if>
+        <if test="name != null and name != ''">
+            AND p.name LIKE CONCAT('%',#{name,jdbcType=VARCHAR},'%')
+        </if>
+        <if test="shopName != null and shopName != ''">
+            AND s.name LIKE CONCAT('%',#{shopName,jdbcType=VARCHAR},'%')
+        </if>
+    </select>
+
+    <select id="findActivityLadder" resultType="com.caimei.modules.hehe.entity.CmHeHeActivityLadder">
+        SELECT id,
+               activityId,
+               productId,
+               ladderNum,
+               buyNum,
+               buyPrice
+        FROM cm_hehe_activity_ladder
+        WHERE activityId = #{activityId}
+          AND productId = #{productId}
+        ORDER BY ladderNum ASC
+    </select>
+
+    <insert id="insertLadder">
+        INSERT INTO `cm_hehe_activity_ladder` (`activityId`, `skuId`, `ladderNum`,
+                                               `buyNum`, `buyPrice`, `createDate`, productId)
+        VALUES (#{activityId}, #{skuId}, #{ladderNum},
+                #{buyNum}, #{buyPrice}, NOW(), (select productId from cm_sku where skuId = #{skuId}))
+    </insert>
+
+    <insert id="insertDiscount">
+        insert into cm_hehe_discount_activity_sku(skuId, productid, discountprice)
+        values (#{skuId}, (select productId from cm_sku where skuId = #{skuId}), #{discountPrice})
+    </insert>
+
+    <delete id="deleteLadder">
+        DELETE FROM cm_hehe_activity_ladder WHERE
+        productId =#{productId}
+        <if test="activityId != null">
+            AND activityId = #{activityId}
+        </if>
+    </delete>
+
+    <select id="findActivityByProductId" resultType="integer">
+        SELECT activityId
+        FROM cm_hehe_activity_product
+        WHERE productId = #{productId}
+          AND delFlag = 0
+    </select>
+
+    <select id="findPrice" resultType="java.lang.String">
+        select discountPrice
+        from cm_hehe_discount_activity_sku
+        where productId = #{productId}
+        order by discountPrice asc
+        limit 1
+    </select>
+
+    <select id="findDiscountSku" resultType="com.caimei.modules.product.entity.CmSku">
+        select chds.discountPrice, chds.productId, chds.skuId, chs.price
+        from cm_hehe_discount_activity_sku chds
+                 left join cm_hehe_sku chs on chds.skuId = chs.skuId
+        where chds.productId = #{productId}
+    </select>
+
+    <select id="findDiscountBySku" resultType="com.caimei.modules.product.entity.CmSku">
+        select discountPrice, skuId, productId
+        from cm_hehe_discount_activity_sku
+        where skuId = #{skuId}
+    </select>
+
+    <delete id="deleteUserActivity">
+        DELETE
+        FROM cm_hehe_user_activity
+        WHERE productId = #{productId}
+    </delete>
+
+    <delete id="deleteLadderBySkuId">
+        delete from cm_hehe_activity_ladder
+        WHERE skuId =#{skuId}
+        <if test="activityId != null">
+            AND activityId = #{activityId}
+        </if>
+    </delete>
+
 
-	<select id="findAllHeHeProduct" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
-		SELECT
-		a.id AS "id",
-		a.productId AS "productId",
-		a.price AS "price",
-		p.name AS "name",
-		p.mainImage AS "mainImage",
-		s.name AS "shopName"
-		FROM
-		cm_hehe_product a
-		LEFT JOIN product p ON a.productId = p.productID
-		LEFT JOIN shop s ON s.shopID = p.shopID
-		WHERE
-		a.validFlag = 1
-		<if test="ids != null and ids.size() > 0 ">
-			AND a.productId NOT IN
-			<foreach collection="ids" open="(" close=")" item="id" separator=",">
-				#{id,jdbcType=INTEGER}
-			</foreach>
-		</if>
-		<if test="productId != null">
-			AND a.productId = #{productId,jdbcType=INTEGER}
-		</if>
-		<if test="name != null and name != ''">
-			AND p.name LIKE CONCAT('%',#{name,jdbcType=VARCHAR},'%')
-		</if>
-		<if test="shopName != null and shopName != ''">
-			AND s.name LIKE CONCAT('%',#{shopName,jdbcType=VARCHAR},'%')
-		</if>
-	</select>
-
-	<select id="findActivityLadder" resultType="com.caimei.modules.hehe.entity.CmHeHeActivityLadder">
-		SELECT
-		  id,
-		  activityId,
-		  productId,
-		  ladderNum,
-		  buyNum,
-		  buyPrice
-		FROM
-		  cm_hehe_activity_ladder
-		WHERE
-		  activityId = #{activityId}
-		  AND productId = #{productId}
-		ORDER BY
-		  ladderNum ASC
-	</select>
-
-	<insert id="insertLadder">
-		INSERT INTO `cm_hehe_activity_ladder` (
-		  `activityId`, `productId`, `ladderNum`,
-		  `buyNum`, `buyPrice`, `createDate`
-		)
-		VALUES
-		  (
-			#{activityId}, #{productId}, #{ladderNum},
-			#{buyNum}, #{buyPrice}, NOW()
-		  )
-	</insert>
-
-	<delete id="deleteLadder">
-		DELETE FROM cm_hehe_activity_ladder WHERE
-		productId =#{productId}
-		<if test="activityId != null">
-			AND activityId = #{activityId}
-		</if>
-	</delete>
-
-	<select id="findActivityByProductId" resultType="integer">
-		SELECT activityId FROM cm_hehe_activity_product WHERE productId = #{productId} AND delFlag = 0
-	</select>
-
-	<delete id="deleteUserActivity">
-		DELETE FROM cm_hehe_user_activity WHERE productId = #{productId}
-	</delete>
-
-	
 </mapper>

+ 157 - 112
src/main/resources/mappings/modules/hehe/CmHeheCollageProductMapper.xml

@@ -1,11 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.hehe.dao.CmHeheCollageProductDao">
-    
-	<sql id="cmHeheCollageProductColumns">
-		a.id AS "id",
+
+    <sql id="cmHeheCollageProductColumns">
+        a.id AS "id",
 		a.productId AS "productId",
-		a.price AS "price",
 		a.limitedNum AS "limitedNum",
 		a.unlimitedFlag AS "unlimitedFlag",
 		a.memberNum AS "memberNum",
@@ -14,117 +13,163 @@
 		s.name AS shopName,
 		p.name AS productName,
 		p.mainImage AS productImage
-	</sql>
-	
-	<sql id="cmHeheCollageProductJoins">
-		left join product p on a.productId = p.productID
+    </sql>
+
+    <sql id="cmHeheCollageProductJoins">
+        left join product p on a.productId = p.productID
 		left join cm_hehe_product chp on p.productID = chp.productId
 		left join shop s on p.shopID = s.shopID
-	</sql>
-    
-	<select id="get" resultType="CmHeheCollageProduct">
-		SELECT 
-			<include refid="cmHeheCollageProductColumns"/>
-		FROM cm_hehe_collage_product a
-		<include refid="cmHeheCollageProductJoins"/>
-		WHERE a.id = #{id}
-	</select>
-	
-	<select id="findList" resultType="CmHeheCollageProduct">
-		SELECT 
-			<include refid="cmHeheCollageProductColumns"/>
-		FROM cm_hehe_collage_product a
-		<include refid="cmHeheCollageProductJoins"/>
-		<where>
-			chp.id is not null
-			<if test="id != null and id != ''">
-				AND a.id = #{id}
-			</if>
-			<if test="status != null">
-				AND a.status = #{status}
-			</if>
-			<if test="productName != null and productName != ''">
-				and p.name like concat('%',#{productName},'%')
-			</if>
-			<if test="shopName != null and shopName != ''">
-				and s.name like concat('%',#{shopName},'%')
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				order by a.addTime desc
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="CmHeheCollageProduct">
-		SELECT 
-			<include refid="cmHeheCollageProductColumns"/>
-		FROM cm_hehe_collage_product a
-		<include refid="cmHeheCollageProductJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	<select id="findReductionProductIds" resultType="java.lang.Integer">
-		select chp.id
-		from cm_hehe_reduction chap
-				 left join cm_hehe_product chp on chap.productId = chp.productId;
-	</select>
-	<select id="getProductId" resultType="java.lang.Integer">
-		select productId from cm_hehe_product where id = #{heheProductId}
-	</select>
-
-	<insert id="insert" parameterType="CmHeheCollageProduct"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO cm_hehe_collage_product(
-			productId,
-			price,
-			limitedNum,
-			unlimitedFlag,
-			memberNum,
-			status,
-			addTime
-		) VALUES (
-             (select productId from cm_hehe_product where id = #{productId}),
-			#{price},
-			#{limitedNum},
-			#{unlimitedFlag},
-			#{memberNum},
-			#{status},
-			NOW()
-		)
-	</insert>
-	
-	<update id="update">
-		UPDATE cm_hehe_collage_product SET 	
-			productId = #{productId},
-			price = #{price},
-			limitedNum = #{limitedNum},
-			unlimitedFlag = #{unlimitedFlag},
-			memberNum = #{memberNum},
-			status = #{status}
-		WHERE id = #{id}
-	</update>
-	<update id="updateStatus">
-		update cm_hehe_collage_product set status = #{status} where id = #{id}
-	</update>
+    </sql>
+
+    <select id="get" resultType="CmHeheCollageProduct">
+        SELECT
+        <include refid="cmHeheCollageProductColumns"/>
+        FROM cm_hehe_collage_product a
+        <include refid="cmHeheCollageProductJoins"/>
+        WHERE a.id = #{id}
+    </select>
+
+    <select id="findList" resultType="CmHeheCollageProduct">
+        SELECT
+        <include refid="cmHeheCollageProductColumns"/>
+        FROM cm_hehe_collage_product a
+        <include refid="cmHeheCollageProductJoins"/>
+        <where>
+            chp.id is not null
+            <if test="id != null and id != ''">
+                AND a.id = #{id}
+            </if>
+            <if test="status != null">
+                AND a.status = #{status}
+            </if>
+            <if test="productName != null and productName != ''">
+                and p.name like concat('%',#{productName},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                and s.name like concat('%',#{shopName},'%')
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by a.addTime desc
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findAllList" resultType="CmHeheCollageProduct">
+        SELECT
+        <include refid="cmHeheCollageProductColumns"/>
+        FROM cm_hehe_collage_product a
+        <include refid="cmHeheCollageProductJoins"/>
+        <where>
+
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findReductionProductIds" resultType="java.lang.Integer">
+        select chp.id
+        from cm_hehe_reduction chap
+                 left join cm_hehe_product chp on chap.productId = chp.productId;
+    </select>
+
+    <select id="getProductId" resultType="java.lang.Integer">
+        select productId
+        from cm_hehe_product
+        where id = #{heheProductId}
+    </select>
+
+    <select id="findCollageSku" resultType="com.caimei.modules.product.entity.CmSku">
+        select chs.price as 'price', chcs.collagePrice , chs.skuId
+        from cm_hehe_sku chs
+        left join cm_hehe_collage_sku chcs on chs.skuId = chcs.skuId
+        left join cm_hehe_product chp on chs.productId = chp.productId
+        where chs.productId = #{productId}
+    </select>
+
+    <select id="findCollageByHeHeId" resultType="com.caimei.modules.product.entity.CmSku">
+        select chs.price as 'price', chcs.collagePrice as 'price', chs.skuId
+        from cm_hehe_sku chs
+        left join cm_hehe_collage_sku chcs on chs.skuId = chcs.skuId
+        left join cm_hehe_product chp on chs.productId = chp.productId
+        where chp.id = #{productId}
+    </select>
+
+    <select id="getSkuCollage" resultType="com.caimei.modules.product.entity.CmSku">
+        select skuId, productId, collagePrice
+        from cm_hehe_collage_sku
+        where skuId = #{skuId}
+    </select>
+
+    <select id="getCollagePrice" resultType="java.lang.Double">
+        select collagePrice
+        from cm_hehe_collage_sku
+        where productId = #{productId}
+        order by collagePrice asc
+        limit 1
+    </select>
+
+    <insert id="insert" parameterType="CmHeheCollageProduct" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_hehe_collage_product(productId,
+                                            limitedNum,
+                                            unlimitedFlag,
+                                            memberNum,
+                                            status,
+                                            addTime)
+        VALUES ((select productId from cm_hehe_product where id = #{productId}),
+                #{limitedNum},
+                #{unlimitedFlag},
+                #{memberNum},
+                #{status},
+                NOW())
+    </insert>
+
+    <insert id="insertSkuCollage">
+        insert into cm_hehe_collage_sku(skuId, productid, collageprice)
+        values (#{skuId}, (select productId from cm_sku where skuId = #{skuId}), #{collagePrice})
+    </insert>
+
+    <update id="update">
+        UPDATE cm_hehe_collage_product
+        SET productId     = #{productId},
+            limitedNum    = #{limitedNum},
+            unlimitedFlag = #{unlimitedFlag},
+            memberNum     = #{memberNum},
+            status        = #{status}
+        WHERE id = #{id}
+    </update>
+
+    <update id="updateStatus">
+        update cm_hehe_collage_product
+        set status = #{status}
+        where id = #{id}
+    </update>
+
     <update id="updateProductId">
-		update cm_hehe_collage_product set productId = #{newProductId} where productId = #{oldProductId}
-	</update>
+        update cm_hehe_collage_product
+        set productId = #{newProductId}
+        where productId = #{oldProductId}
+    </update>
+
+    <update id="updateSkuCollage">
+        update cm_hehe_collage_sku
+        set collagePrice=#{collagePrice}
+        where skuId = #{skuId}
+    </update>
 
     <delete id="delete">
-		DELETE FROM cm_hehe_collage_product
-		WHERE id = #{id}
-	</delete>
-	
+        DELETE
+        FROM cm_hehe_collage_product
+        WHERE id = #{id}
+    </delete>
+
 </mapper>

+ 297 - 262
src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml

@@ -1,291 +1,326 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.hehe.dao.CmHeheProductDao">
-    
-	<sql id="cmHeheProductColumns">
-		a.id AS "id",
+
+    <sql id="cmHeheProductColumns">
+        a.id AS "id",
 		a.productId AS "productId",
 		ifnull(a.bigTypeId,0) AS "bigTypeId",
 		ifnull(a.smallTypeId,0) AS "smallTypeId",
 		a.validFlag AS "validFlag",
-		a.price AS "price",
 		a.includedTax AS "includedTax",
 		a.invoiceType AS "invoiceType",
 		a.clubTaxPoint AS "clubTaxPoint",
 		a.shopTaxPoint AS "shopTaxPoint",
 		a.oldProductId,
-		p.costCheckFlag AS "costType",
-		p.costPrice AS "costPrice",
-		p.costProportional AS "costProportional",
 		a.addTime AS "addTime",
 		p.name AS "name",
 		p.mainImage AS "mainImage",
 		s.name AS "shopName",
 		chap.activityId,
 		group_concat(chfp.floorId) as floorIds
-	</sql>
-	
-	<sql id="cmHeheProductJoins">
-		LEFT JOIN product p ON  a.productId = p.productID
+    </sql>
+
+    <sql id="cmHeheProductJoins">
+        LEFT JOIN product p ON  a.productId = p.productID
 		LEFT JOIN shop s ON s.shopID = p.shopID
 		left join cm_hehe_activity_product chap on a.productId = chap.productId
 		left join cm_hehe_floor_product chfp on a.productId = chfp.productId
-	</sql>
-    
-	<select id="get" resultType="CmHeheProduct">
-		SELECT 
-			<include refid="cmHeheProductColumns"/>
-		FROM cm_hehe_product a
-		<include refid="cmHeheProductJoins"/>
-		WHERE a.id = #{id}
-		group by a.id
-	</select>
-	
-	<select id="findList" resultType="CmHeheProduct">
-		SELECT 
-			<include refid="cmHeheProductColumns"/>
-		FROM cm_hehe_product a
-		<include refid="cmHeheProductJoins"/>
-		<where>
-			<if test="productId != null and productId != ''">
-				AND a.productId = #{productId}
-			</if>
-			<if test="validFlag != null and validFlag != ''">
-				AND a.validFlag = #{validFlag}
-			</if>
-			<if test="includedTax != null and includedTax != ''">
-				AND a.includedTax = #{includedTax}
-			</if>
-			<if test="invoiceType != null and invoiceType != ''">
-				AND a.invoiceType = #{invoiceType}
-			</if>
-			<if test="id != null and id != ''">
-				AND a.id = #{id}
-			</if>
-			<if test="name != null and name != ''">
-				AND p.name LIKE CONCAT('%',#{name},'%')
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND s.name LIKE CONCAT('%',#{shopName},'%')
-			</if>
-		</where>
-		group by a.id
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY addTime DESC
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="CmHeheProduct">
-		SELECT 
-			<include refid="cmHeheProductColumns"/>
-		FROM cm_hehe_product a
-		<include refid="cmHeheProductJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	
-	<insert id="insert" parameterType="CmHeheProduct"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO cm_hehe_product(
-			productId,
-			bigTypeId,
-			smallTypeId,
-			validFlag,
-			price,
-			includedTax,
-			invoiceType,
-			clubTaxPoint,
-			shopTaxPoint,
-			addTime
-		) VALUES (
-			#{productId},
-			#{bigTypeId},
-			#{smallTypeId},
-			#{validFlag},
-			#{price},
-			#{includedTax},
-			#{invoiceType},
-			#{clubTaxPoint},
-			#{shopTaxPoint},
-			NOW()
-		)
-	</insert>
-	<insert id="addActivityProduct">
-		insert into cm_hehe_activity_product (activityId, productId, addTime, delFlag)
-		values (#{activityId}, #{productId}, NOW(), 0)
-	</insert>
-	<insert id="addFloorProduct">
-		insert into cm_hehe_floor_product(floorId, productId, validFlag, recommend, sort, addTime)
-		VALUES (#{floorId}, #{productId}, 1, 0, 1, NOW())
-	</insert>
+    </sql>
+
+    <select id="get" resultType="CmHeheProduct">
+        SELECT
+        <include refid="cmHeheProductColumns"/>
+        FROM cm_hehe_product a
+        <include refid="cmHeheProductJoins"/>
+        WHERE a.id = #{id}
+        group by a.id
+    </select>
+
+    <select id="findList" resultType="CmHeheProduct">
+        SELECT
+        <include refid="cmHeheProductColumns"/>
+        FROM cm_hehe_product a
+        <include refid="cmHeheProductJoins"/>
+        <where>
+            <if test="productId != null and productId != ''">
+                AND a.productId = #{productId}
+            </if>
+            <if test="validFlag != null and validFlag != ''">
+                AND a.validFlag = #{validFlag}
+            </if>
+            <if test="includedTax != null and includedTax != ''">
+                AND a.includedTax = #{includedTax}
+            </if>
+            <if test="invoiceType != null and invoiceType != ''">
+                AND a.invoiceType = #{invoiceType}
+            </if>
+            <if test="id != null and id != ''">
+                AND a.id = #{id}
+            </if>
+            <if test="name != null and name != ''">
+                AND p.name LIKE CONCAT('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE CONCAT('%',#{shopName},'%')
+            </if>
+        </where>
+        group by a.id
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                ORDER BY addTime DESC
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findAllList" resultType="CmHeheProduct">
+        SELECT
+        <include refid="cmHeheProductColumns"/>
+        FROM cm_hehe_product a
+        <include refid="cmHeheProductJoins"/>
+        <where>
+
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+
+    <insert id="insert" parameterType="CmHeheProduct" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_hehe_product(productId,
+                                    bigTypeId,
+                                    smallTypeId,
+                                    validFlag,
+                                    includedTax,
+                                    invoiceType,
+                                    clubTaxPoint,
+                                    shopTaxPoint,
+                                    addTime)
+        VALUES (#{productId},
+                #{bigTypeId},
+                #{smallTypeId},
+                #{validFlag},
+                #{includedTax},
+                #{invoiceType},
+                #{clubTaxPoint},
+                #{shopTaxPoint},
+                NOW())
+    </insert>
+    <insert id="addActivityProduct">
+        insert into cm_hehe_activity_product (activityId, productId, addTime, delFlag)
+        values (#{activityId}, #{productId}, NOW(), 0)
+    </insert>
+    <insert id="addFloorProduct">
+        insert into cm_hehe_floor_product(floorId, productId, validFlag, recommend, sort, addTime)
+        VALUES (#{floorId}, #{productId}, 1, 0, 1, NOW())
+    </insert>
+    <insert id="insertHeHeSkuPrice">
+        insert into cm_hehe_sku(skuid, productid, price)
+        values (#{skuId}, #{productId}, #{price})
+    </insert>
+
+    <update id="update">
+        UPDATE cm_hehe_product
+        SET productId    = #{productId},
+            bigTypeId    = #{bigTypeId},
+            smallTypeId  = #{smallTypeId},
+            validFlag    = #{validFlag},
+            includedTax  = #{includedTax},
+            invoiceType  = #{invoiceType},
+            clubTaxPoint = #{clubTaxPoint},
+            shopTaxPoint = #{shopTaxPoint}
+        WHERE id = #{id}
+    </update>
+
+    <delete id="delete">
+        DELETE
+        FROM cm_hehe_product
+        WHERE id = #{id}
+    </delete>
+
+    <select id="findHeHeProductId" resultType="integer">
+        SELECT productId
+        FROM cm_hehe_product
+    </select>
+
+    <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
+        SELECT
+        a.*,s.name AS "shopName"
+        FROM product a
+        LEFT JOIN shop s on s.shopID = a.shopID
+        <where>
+            a.splitCode is not null and a.splitCode != ''
+            <if test="productID != null">
+                AND a.productID = #{productID}
+            </if>
+            <if test="name != null and name != ''">
+                AND a.name LIKE concat('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE concat('%',#{shopName},'%')
+            </if>
+            <if test="ids != null and ids.size() > 0 ">
+                AND a.productID NOT IN
+                <foreach collection="ids" open="(" close=")" item="id" separator=",">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by a.productID
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findCouponProduct" resultType="com.caimei.modules.product.entity.Product">
+        SELECT
+        a.*,s.name AS "shopName"
+        FROM cm_hehe_product
+        product a
+        LEFT JOIN shop s on s.shopID = a.shopID
+        <where>
+            <if test="productID != null">
+                AND a.productID = #{productID}
+            </if>
+            <if test="name != null and name != ''">
+                AND a.name LIKE concat('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE concat('%',#{shopName},'%')
+            </if>
+            <if test="ids != null and ids.size() > 0 ">
+                AND a.productID NOT IN
+                <foreach collection="ids" open="(" close=")" item="id" separator=",">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by a.productID
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findProductActivity" resultType="java.lang.Integer">
+        select activityId
+        from cm_hehe_activity_product
+        where productId = #{productId}
+    </select>
+
+    <select id="getNewProductId" resultType="java.lang.Integer">
+        select productId
+        from cm_hehe_product
+        where oldProductId = #{oldProductId}
+    </select>
+
+    <select id="findHeHeFloorProductIds" resultType="java.lang.Integer">
+        select i.productId
+        from new_page_floor_image i
+                 left join cm_page_centre c on i.centreId = c.id
+                 left join cm_page p on c.pageId = p.id
+        where p.type = 8
+    </select>
 
-	<update id="update">
-		UPDATE cm_hehe_product SET 	
-			productId = #{productId},
-		    bigTypeId = #{bigTypeId},
-			smallTypeId = #{smallTypeId},
-			validFlag = #{validFlag},
-			price = #{price},
-			includedTax = #{includedTax},
-			invoiceType = #{invoiceType},
-			clubTaxPoint = #{clubTaxPoint},
-			shopTaxPoint = #{shopTaxPoint}
-		WHERE id = #{id}
-	</update>
-	
-	<delete id="delete">
-		DELETE FROM cm_hehe_product
-		WHERE id = #{id}
-	</delete>
+    <select id="findAllHeheProduct" resultType="com.caimei.modules.product.entity.Product">
+        SELECT
+        a.*,s.name AS "shopName"
+        FROM cm_hehe_product chp left join product a on chp.productId = a.productID
+        LEFT JOIN shop s on s.shopID = a.shopID
+        <where>
+            chp.validFlag = 1
+            <if test="productID != null">
+                AND a.productID = #{productID}
+            </if>
+            <if test="name != null and name != ''">
+                AND a.name LIKE concat('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE concat('%',#{shopName},'%')
+            </if>
+            <if test="ids != null and ids.size() > 0 ">
+                AND a.productID NOT IN
+                <foreach collection="ids" open="(" close=")" item="id" separator=",">
+                    #{id}
+                </foreach>
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                order by a.productID
+            </otherwise>
+        </choose>
+    </select>
 
-	<select id="findHeHeProductId" resultType="integer">
-		SELECT productId FROM cm_hehe_product
-	</select>
+    <select id="findActivityProductIds" resultType="java.lang.Integer">
+        SELECT a.productId
+        FROM cm_hehe_activity_product a
+                 LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
+        WHERE a.delFlag = 0
+          AND cha.delFlag = 0
+    </select>
 
-	<select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
-		SELECT
-		a.*,s.name AS "shopName"
-		FROM product a
-		LEFT JOIN shop s on s.shopID = a.shopID
-		<where>
-			a.splitCode is not null and a.splitCode != ''
-			<if test="productID != null" >
-				AND a.productID = #{productID}
-			</if>
-			<if test="name != null and name != ''">
-				AND a.name LIKE concat('%',#{name},'%')
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND s.name LIKE concat('%',#{shopName},'%')
-			</if>
-			<if test="ids != null and ids.size() > 0 ">
-				AND a.productID NOT IN
-				<foreach collection="ids" open="(" close=")" item="id" separator=",">
-					#{id}
-				</foreach>
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				order by a.productID
-			</otherwise>
-		</choose>
-	</select>
+    <select id="findCollageProductIds" resultType="java.lang.Integer">
+        select productId
+        from cm_hehe_collage_product
+    </select>
 
-	<select id="findCouponProduct" resultType="com.caimei.modules.product.entity.Product">
-		SELECT
-		a.*,s.name AS "shopName"
-		FROM cm_hehe_product
-		     product a
-		LEFT JOIN shop s on s.shopID = a.shopID
-		<where>
-			<if test="productID != null" >
-				AND a.productID = #{productID}
-			</if>
-			<if test="name != null and name != ''">
-				AND a.name LIKE concat('%',#{name},'%')
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND s.name LIKE concat('%',#{shopName},'%')
-			</if>
-			<if test="ids != null and ids.size() > 0 ">
-				AND a.productID NOT IN
-				<foreach collection="ids" open="(" close=")" item="id" separator=",">
-					#{id}
-				</foreach>
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				order by a.productID
-			</otherwise>
-		</choose>
-	</select>
-	<select id="findProductActivity" resultType="java.lang.Integer">
-		select activityId from cm_hehe_activity_product where productId = #{productId}
-	</select>
-	<select id="getNewProductId" resultType="java.lang.Integer">
-		select productId from cm_hehe_product where oldProductId = #{oldProductId}
-	</select>
+    <select id="findDiscountProductIds" resultType="java.lang.Integer">
+        select productId
+        from hehe_discount_activity_product hdap
+                 left join cm_hehe_discount_activity chda on hdap.activityId = chda.id
+        where chda.id is not null
+    </select>
 
-	<select id="findHeHeFloorProductIds" resultType="java.lang.Integer">
-		select i.productId from new_page_floor_image i left join cm_page_centre c on i.centreId = c.id
-		left join cm_page p on c.pageId = p.id
-		where p.type = 8
-	</select>
-	<select id="findAllHeheProduct" resultType="com.caimei.modules.product.entity.Product">
-		SELECT
-			a.*,s.name AS "shopName"
-		FROM cm_hehe_product chp left join product a on chp.productId = a.productID
-				 LEFT JOIN shop s on s.shopID = a.shopID
-		<where>
-		    chp.validFlag = 1
-			<if test="productID != null" >
-				AND a.productID = #{productID}
-			</if>
-			<if test="name != null and name != ''">
-				AND a.name LIKE concat('%',#{name},'%')
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND s.name LIKE concat('%',#{shopName},'%')
-			</if>
-			<if test="ids != null and ids.size() > 0 ">
-				AND a.productID NOT IN
-				<foreach collection="ids" open="(" close=")" item="id" separator=",">
-					#{id}
-				</foreach>
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				order by a.productID
-			</otherwise>
-		</choose>
-	</select>
-	<select id="findActivityProductIds" resultType="java.lang.Integer">
-		SELECT
-			a.productId
-		FROM
-			cm_hehe_activity_product a
-			LEFT JOIN cm_hehe_activity cha ON a.activityId = cha.id
-		WHERE
-			a.delFlag = 0
-		  AND cha.delFlag = 0
-  	</select>
-	<select id="findCollageProductIds" resultType="java.lang.Integer">
-		select productId from cm_hehe_collage_product
-	</select>
-	<select id="findDiscountProductIds" resultType="java.lang.Integer">
-		select productId from hehe_discount_activity_product hdap left join cm_hehe_discount_activity chda on hdap.activityId = chda.id
-		where chda.id is not null
-	</select>
+    <select id="findProductElement" resultType="com.caimei.modules.hehe.entity.CmHeheProduct">
+        select ifnull(chs.price, 0)           as price,
+               ifnull(cs.costProportional, 0) as costProportional,
+               ifnull(cs.costCheckFlag, 0)    as costType,
+               ifnull(cs.costPrice, 0)        as costPrice
+        from cm_sku cs
+                 left join cm_hehe_sku chs on cs.skuId = chs.skuId
+        where cs.productId = #{productId}
+        order by chs.price asc
+        limit 1
+    </select>
 
-	<update id="deleteActivityProduct">
-		UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE productId = #{productId}
-	</update>
-	<update id="updateProductId">
-		update cm_hehe_product set oldProductId = #{oldProductId}, productId = #{newProductId} where productId = #{oldProductId}
-	</update>
+    <update id="deleteActivityProduct">
+        UPDATE cm_hehe_activity_product
+        SET delFlag = 1
+        WHERE productId = #{productId}
+    </update>
 
+    <update id="updateProductId">
+        update cm_hehe_product
+        set oldProductId = #{oldProductId},
+            productId    = #{newProductId}
+        where productId = #{oldProductId}
+    </update>
+    <update id="updateHeHeSkuPrice">
+        update cm_hehe_sku
+        set price=#{price}
+        where skuId = #{skuId}
+    </update>
+    <select id="findLadderList" resultType="com.caimei.modules.product.entity.CmLadderPrice">
+        select id,buyPrice,buyNum
+        from cm_hehe_activity_ladder
+        where skuId=#{skuId}
+    </select>
 </mapper>

+ 102 - 99
src/main/resources/mappings/modules/hehe/HeheDiscountActivityProductMapper.xml

@@ -1,113 +1,116 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei.modules.hehe.dao.HeheDiscountActivityProductDao">
-    
-	<sql id="heheDiscountActivityProductColumns">
-		a.id AS "id",
+
+    <sql id="heheDiscountActivityProductColumns">
+        a.id AS "id",
 		a.activityId,
 		a.productId AS "productId",
-		a.discountPrice AS "discountPrice",
 		a.status AS "status",
 		a.addTime AS "addTime",
 		p.mainImage AS "mainImage",
 		p.name AS "name",
 		s.name AS "shopName"
-	</sql>
-	
-	<sql id="heheDiscountActivityProductJoins">
-		LEFT JOIN cm_hehe_product chp ON a.productId = chp.productId
+    </sql>
+
+    <sql id="heheDiscountActivityProductJoins">
+        LEFT JOIN cm_hehe_product chp ON a.productId = chp.productId
 		LEFT JOIN product p ON a.productId = p.productID
 		LEFT JOIN shop s ON s.shopID = p.shopID
-	</sql>
-    
-	<select id="get" resultType="HeheDiscountActivityProduct">
-		SELECT 
-			<include refid="heheDiscountActivityProductColumns"/>
-		FROM hehe_discount_activity_product a
-		<include refid="heheDiscountActivityProductJoins"/>
-		WHERE a.id = #{id}
-	</select>
-	
-	<select id="findList" resultType="HeheDiscountActivityProduct">
-		SELECT 
-			<include refid="heheDiscountActivityProductColumns"/>
-		FROM hehe_discount_activity_product a
-		<include refid="heheDiscountActivityProductJoins"/>
-		<where>
-			chp.id is not null
-			<if test="activityId != null">
-				and a.activityId = #{activityId}
-			</if>
-			<if test="productId != null">
-				AND a.productId = #{productId}
-			</if>
-			<if test="status != null">
-				AND a.status = #{status}
-			</if>
-			<if test="name != null and name != ''">
-				AND p.name LIKE CONCAT('%',#{name},'%')
-			</if>
-			<if test="shopName != null and shopName != ''">
-				AND s.name LIKE CONCAT('%',#{shopName},'%')
-			</if>
-		</where>
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-				ORDER BY a.addTime DESC
-			</otherwise>
-		</choose>
-	</select>
-	
-	<select id="findAllList" resultType="HeheDiscountActivityProduct">
-		SELECT 
-			<include refid="heheDiscountActivityProductColumns"/>
-		FROM hehe_discount_activity_product a
-		<include refid="heheDiscountActivityProductJoins"/>
-		<where>
-			
-		</where>		
-		<choose>
-			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
-				ORDER BY ${page.orderBy}
-			</when>
-			<otherwise>
-			</otherwise>
-		</choose>
-	</select>
-	<select id="findDiscountProductIds" resultType="java.lang.Integer">
-		select productId from hehe_discount_activity_product;
-	</select>
+    </sql>
+
+    <select id="get" resultType="HeheDiscountActivityProduct">
+        SELECT
+        <include refid="heheDiscountActivityProductColumns"/>
+        FROM hehe_discount_activity_product a
+        <include refid="heheDiscountActivityProductJoins"/>
+        WHERE a.id = #{id}
+    </select>
+
+    <select id="findList" resultType="HeheDiscountActivityProduct">
+        SELECT
+        <include refid="heheDiscountActivityProductColumns"/>
+        FROM hehe_discount_activity_product a
+        <include refid="heheDiscountActivityProductJoins"/>
+        <where>
+            chp.id is not null
+            <if test="activityId != null">
+                and a.activityId = #{activityId}
+            </if>
+            <if test="productId != null">
+                AND a.productId = #{productId}
+            </if>
+            <if test="status != null">
+                AND a.status = #{status}
+            </if>
+            <if test="name != null and name != ''">
+                AND p.name LIKE CONCAT('%',#{name},'%')
+            </if>
+            <if test="shopName != null and shopName != ''">
+                AND s.name LIKE CONCAT('%',#{shopName},'%')
+            </if>
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+                ORDER BY a.addTime DESC
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findAllList" resultType="HeheDiscountActivityProduct">
+        SELECT
+        <include refid="heheDiscountActivityProductColumns"/>
+        FROM hehe_discount_activity_product a
+        <include refid="heheDiscountActivityProductJoins"/>
+        <where>
+
+        </where>
+        <choose>
+            <when test="page !=null and page.orderBy != null and page.orderBy != ''">
+                ORDER BY ${page.orderBy}
+            </when>
+            <otherwise>
+            </otherwise>
+        </choose>
+    </select>
+
+    <select id="findDiscountProductIds" resultType="java.lang.Integer">
+        select productId
+        from hehe_discount_activity_product;
+    </select>
+
+    <select id="findDiscountSku" resultType="com.caimei.modules.product.entity.CmSku">
+        SELECT chda.discountPrice, chs.productId, chs.skuId, chs.price
+        FROM cm_hehe_sku chs
+        LEFT JOIN cm_hehe_discount_activity_sku chda ON chda.skuId = chs.skuId
+        WHERE chs.productId = #{productId}
+    </select>
+
+    <insert id="insert" parameterType="HeheDiscountActivityProduct" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO hehe_discount_activity_product(activityId,
+                                                   productId,
+                                                   status,
+                                                   addTime)
+        VALUES (#{activityId},
+                #{productId},
+                #{status},
+                NOW())
+    </insert>
+
+    <update id="update">
+        UPDATE hehe_discount_activity_product
+        SET productId = #{productId},
+            status    = #{status}
+        WHERE id = #{id}
+    </update>
+
+    <delete id="delete">
+        DELETE
+        FROM hehe_discount_activity_product
+        WHERE id = #{id}
+    </delete>
 
-	<insert id="insert" parameterType="HeheDiscountActivityProduct"  keyProperty="id" useGeneratedKeys="true">
-		INSERT INTO hehe_discount_activity_product(
-		    activityId,
-			productId,
-			discountPrice,
-			status,
-			addTime
-		) VALUES (
-		    #{activityId},
-			#{productId},
-			#{discountPrice},
-			#{status},
-			NOW()
-		)
-	</insert>
-	
-	<update id="update">
-		UPDATE hehe_discount_activity_product SET 	
-			productId = #{productId},
-			discountPrice = #{discountPrice},
-			status = #{status}
-		WHERE id = #{id}
-	</update>
-	
-	<delete id="delete">
-		DELETE FROM hehe_discount_activity_product
-		WHERE id = #{id}
-	</delete>
-	
 </mapper>

+ 2 - 1
src/main/resources/mappings/modules/order/CmReturnedPurchaseProductMapper.xml

@@ -33,9 +33,10 @@
 			b.totalFee as totalFee,b.totalAddedValueTax as totalAddedValueTax,
 			b.taxRate as taxRate,b.addedValueTax as addedValueTax,c.mainImage as mainImage,
 			c.name as name,d.name as shopName,
-			c.unit as unit
+			cs.unit as unit
 		FROM cm_returned_purchase_product a
 		left join cm_order_product b on a.orderProductID = b.orderProductID
+		left join cm_sku cs on b.skuId = cs.skuId
 		left join product c on c.productID = a.productID
 		left join shop d on d.shopID = a.shopID
 		<where>

+ 1 - 0
src/main/resources/mappings/modules/order/LogisticsRecordMapper.xml

@@ -54,6 +54,7 @@
 			p.name AS productName,
 			p.productImage AS image,
 			p.num AS buyNum,
+		    p.productUnit as unit,
 			p.presentNum AS presentNum,
 			s.name AS shopName
 		from cm_logistics_record a

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 507 - 508
src/main/resources/mappings/modules/order/OrderProductMapper.xml


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

@@ -97,9 +97,11 @@
 
     <select id="findPromotionProduct" resultType="com.caimei.modules.product.entity.Product">
         SELECT p.*,
+               (select price from cm_sku where productId = p.productId order by price asc limit 1) as price,
                cp.reducedPrice AS "reducedPrice",
                s.name          AS "shopName"
         FROM cm_promotions cp
+
                  LEFT JOIN cm_promotions_product cpp ON cp.id = cpp.promotionsId
                  LEFT JOIN product p ON cpp.productId = p.productID
                  LEFT JOIN shop s ON s.shopID = p.shopID
@@ -108,11 +110,16 @@
     </select>
 
     <select id="findGiftProduct" resultType="com.caimei.modules.product.entity.Product">
-        SELECT p.*,
+        SELECT cpg.skuId   AS "skuId",
+               cs.unit,
+               p.name,
+               p.mainImage,
+               p.productID,
                s.name     AS "shopName",
                cpg.number AS "giftNumber"
         FROM cm_promotions cp
                  LEFT JOIN cm_promotions_gift cpg ON cp.id = cpg.promotionsId
+                 left join cm_sku cs on cpg.skuId = cs.skuId
                  LEFT JOIN product p ON cpg.productId = p.productID
                  LEFT JOIN shop s ON s.shopID = p.shopID
         WHERE cp.id = #{id}
@@ -124,19 +131,19 @@
                s.name             shopName,
                s.`shopID`         shopId,
                p.name             purchaseProductName,
-               p.`price`         price,
+               cs.`price`         price,
                p.`productID`      productId,
                p.productCode      productNo,
-               p.mainImage        image
-                ,
-               p.costCheckFlag    costCheckFlag,
-               p.costPrice        costPrice,
-               p.costProportional costProportional,
-               p.normalPrice    AS     normalPrice,
+               p.mainImage        image,
+               cs.costCheckFlag    costCheckFlag,
+               cs.costPrice        costPrice,
+               cs.costProportional costProportional,
+               cs.normalPrice    AS     normalPrice,
                cpg.number  AS     num,
                cp.discount as     discounts
         FROM cm_promotions cp
                  LEFT JOIN cm_promotions_gift cpg ON cp.id = cpg.promotionsId
+                 left join cm_sku cs on cpg.skuId = cs.skuId
                  LEFT JOIN product p ON cpg.productId = p.productID
                  LEFT JOIN shop s ON s.shopID = p.shopID
         WHERE cp.id = #{id}
@@ -152,8 +159,10 @@
 
     <select id="findAllProduct" resultType="com.caimei.modules.product.entity.Product">
         SELECT
-        p.*,
-        s.name AS "shopName"
+        p.productId as productID,
+        p.mainImage as mainImage,
+        p.name as name,
+        s.name AS shopName
         FROM
         product p
         LEFT JOIN shop s ON s.shopID = p.shopID
@@ -161,7 +170,6 @@
             p.productCategory = 1
             and p.validFlag = 2
             and p.priceFlag != 1
-            and p.stock <![CDATA[   >  ]]> 0
             <if test="productID != null">
                 AND p.productID = #{productID}
             </if>
@@ -263,11 +271,13 @@
 
     <insert id="insertGiftProduct">
         INSERT INTO cm_promotions_gift(promotionsId,
+                                       skuId,
                                        productId,
                                        number,
                                        addTime)
         VALUES (#{promotionId},
                 #{giftId},
+                (select productId from cm_sku where skuId=#{giftId}),
                 #{number},
                 now())
     </insert>
@@ -413,8 +423,8 @@
     </select>
     <select id="getPresentPriceById" resultType="java.lang.Double">
         select price
-        from product
-        where productID = #{productId}
+        from cm_sku
+        where skuId = #{skuId}
     </select>
     <select id="findProductIdByPromotion" resultType="java.lang.Integer">
         select productId

+ 28 - 14
src/main/resources/mappings/modules/product/ProductMapper.xml

@@ -21,12 +21,8 @@
 		a.searchKey AS "searchKey",
 		a.combinationID AS "combinationID",
 		a.productRemarks AS "productRemarks",
-		a.normalPrice AS "normalPrice",
-		a.price AS "price",
 		a.priceFlag AS "priceFlag",
 		a.beautyActFlag AS "beautyActFlag",
-		a.ladderPriceFlag AS "ladderPriceFlag",
-		a.stock AS "stock",
 		a.hasSkuFlag AS "hasSkuFlag",
 		a.mainImage AS "mainImage",
 		a.propertiesInfo AS "propertiesInfo",
@@ -45,13 +41,10 @@
 		a.featuredFlag AS "featuredFlag",
 		a.featuredSortIndex AS "featuredSortIndex",
 		a.productCode AS "productCode",
-		a.unit AS "unit",
 		a.synToERPFlag AS "synToERPFlag",
 		a.allAreaFlag AS "allAreaFlag",
 		a.provinceIDs AS "provinceIDs",
 		a.serviceNumber AS "serviceNumber",
-		a.maxBuyNumber AS "maxBuyNumber",
-		a.minBuyNumber AS "minBuyNumber",
 		a.packageCount AS "packageCount",
 		a.byFlag AS "byFlag",
 		a.normalProductFlag AS "normalProductFlag",
@@ -65,9 +58,6 @@
 		a.onlineTime AS "onlineTime",
 		a.downlineTime AS "downlineTime",
 		a.freePostFlag AS "freePostFlag",
-		a.costPrice AS "costPrice",
-		a.costProportional AS "costProportional",
-		a.costCheckFlag AS "costCheckFlag",
 		a.precisehKey AS "precisehKey",
 		s.name AS "shopName",
 		a.actSort AS "actSort",
@@ -97,7 +87,8 @@
 		a.qualificationNo,
 		a.productName,
 		a.qualificationTime,
-		a.qualificationLink
+		a.qualificationLink,
+        (select price from cm_sku where productId = a.productId order by price asc limit 1) as price
 
     </sql>
 
@@ -914,7 +905,7 @@
                                           buyNum, buyPrice, createBy, createDate, delFlag)
         values (#{productId}, 3, #{ladderNum},
                 #{buyNum}, #{buyPrice}, #{createBy},
-                #{createDate}, '0')
+                now(), '0')
     </insert>
 
     <insert id="insertProduct" keyColumn="productID" keyProperty="productID"
@@ -1132,7 +1123,7 @@
                                           buyNum, buyPrice, createBy, createDate, delFlag)
         values (#{skuId}, #{productId}, 3, #{ladderNum},
                 #{buyNum}, #{buyPrice}, #{createBy},
-                #{createDate}, '0')
+                now(), '0')
     </insert>
 
     <select id="getrecommendProductList" resultType="product">
@@ -1209,7 +1200,7 @@
     <delete id="deleteLadderPriceById">
         DELETE
         FROM product_ladder_price
-        where id = #{id}
+        where productId = #{productId}
     </delete>
     <delete id="deleteSkus">
         delete
@@ -2054,4 +2045,27 @@
           AND delFlag = 0
         ORDER BY ladderNum ASC
     </select>
+    <select id="getBySku" resultType="com.caimei.modules.product.entity.Product">
+        SELECT
+        <include refid="productColumns"/>
+        ,cs.unit
+        ,cs.skuId
+        FROM product a
+        <include refid="productJoins"/>
+        left join cm_sku cs on cs.productId=a.productID
+        WHERE cs.skuId = #{skuId}
+    </select>
+    <select id="findHeHeSku" resultType="com.caimei.modules.product.entity.CmSku">
+        select cs.skuId,
+               cs.productId,
+               cs.unit,
+               cs.stock,
+               cs.costCheckFlag,
+               cs.costProportional,
+               cs.costPrice,
+               chs.price
+        from cm_sku cs
+        left join cm_hehe_sku chs on cs.skuId=chs.skuId
+        where cs.productId = #{productID}
+    </select>
 </mapper>

+ 0 - 10
src/main/resources/mappings/modules/product/ProductNewMapper.xml

@@ -24,12 +24,8 @@
         a.searchKey AS "searchKey",
         a.combinationID AS "combinationID",
         a.productRemarks AS "productRemarks",
-        a.normalPrice AS "normalPrice",
-        a.price AS "price",
         a.priceFlag AS "priceFlag",
         a.beautyActFlag AS "beautyActFlag",
-        a.ladderPriceFlag AS "ladderPriceFlag",
-        a.stock AS "stock",
         a.hasSkuFlag AS "hasSkuFlag",
         a.mainImage AS "mainImage",
         a.propertiesInfo AS "propertiesInfo",
@@ -48,13 +44,10 @@
         a.featuredFlag AS "featuredFlag",
         a.featuredSortIndex AS "featuredSortIndex",
         a.productCode AS "productCode",
-        a.unit AS "unit",
         a.synToERPFlag AS "synToERPFlag",
         a.allAreaFlag AS "allAreaFlag",
         a.provinceIDs AS "provinceIDs",
         a.serviceNumber AS "serviceNumber",
-        a.maxBuyNumber AS "maxBuyNumber",
-        a.minBuyNumber AS "minBuyNumber",
         a.packageCount AS "packageCount",
         a.byFlag AS "byFlag",
         a.normalProductFlag AS "normalProductFlag",
@@ -68,9 +61,6 @@
         a.onlineTime AS "onlineTime",
         a.downlineTime AS "downlineTime",
         a.freePostFlag AS "freePostFlag",
-        a.costPrice AS "costPrice",
-        a.costProportional AS "costProportional",
-        a.costCheckFlag AS "costCheckFlag",
         a.precisehKey AS "precisehKey",
         s.name AS "shopName",
         a.actSort AS "actSort",

+ 7 - 4
src/main/resources/mappings/modules/product/RepeatPurchasePriceMapper.xml

@@ -14,7 +14,8 @@
 	</sql>
 
 	<sql id="repeatPurchasePriceJoins">
-		left join product as b on a.productId = b.productID
+		left join cm_sku cs on cs.skuId=a.skuId
+		left join product as b on cs.productId = b.productID
 		left join user as c on a.userId = c.userId
 	</sql>
 
@@ -37,6 +38,7 @@
 		c.userName AS "userName",
 		c.mobile As "mobile",
 		c.registerUserTypeID As "type",
+		cs.unit AS "unit",
 		b.name AS "productName"
 		FROM repeat_purchase_price a
 		<include refid="repeatPurchasePriceJoins"/>
@@ -57,9 +59,10 @@
 			c.bindMobile AS "bindMobile",
 			IFNULL(c.registerUserTypeID,3) As "type",
 			b.name AS "productName",
-            CASE   b.costCheckFlag
-            WHEN  1 THEN b.`costPrice`
-            WHEN  2 THEN b.`costProportional` * b.`price` / 100
+		  	cs.unit,
+            CASE   cs.costCheckFlag
+            WHEN  1 THEN cs.`costPrice`
+            WHEN  2 THEN cs.`costProportional` * cs.`price` / 100
             END   AS "costPrice"
 		FROM repeat_purchase_price a
 		<include refid="repeatPurchasePriceJoins"/>

+ 3 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/applyRefoundForm.jsp

@@ -595,6 +595,9 @@
                                     </td>
                                 </tr>
                                 <tr>
+                                    <td>
+                                        规格:${newOrderProduct.unit}
+                                    </td>
                                     <td style="width: 275px;">
                                         税率:${newOrderProduct.taxRate}%
                                     </td>

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/bulkpurchase/orderReturnRecord.jsp

@@ -644,6 +644,7 @@
                                     </td>
                                 </tr>
                                 <tr>
+                                    <td>规格:${cmReturnedPurchaseProduct.unit}</td>
                                     <td>税率:${cmReturnedPurchaseProduct.taxRate}</td>
                                     <td>税费:¥${cmReturnedPurchaseProduct.totalAddedValueTax}</td>
                                     <td colspan="2">总额:¥${cmReturnedPurchaseProduct.totalFee}</td>

+ 163 - 113
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductForm.jsp

@@ -14,30 +14,31 @@
             //$("#name").focus();
             $("#inputForm").validate({
                 submitHandler: function (form) {
-                    debugger
-                    alertx(111)
-                    if ($('input[name="activityLadderList[0].buyNum"]:visible').length>0){
-                        var buyNum = $('input[name="activityLadderList[0].buyNum"]').val();
-                        var buyPrice = $('input[name="activityLadderList[0].buyPrice"]').val();
-                        if(buyNum<=0 || buyNum == '' || buyPrice<=0 || buyPrice == ''){
-                            alertx("请输入正确的阶梯价格");
-                            return false;
+                    var size = $('#skuSize').val();
+                    for (let i = 0; i < size; i++) {
+                        if ($('input[name="skus[' + i + '].ladderPriceList[0].buyNum"]:visible').length > 0) {
+                            buyNum = $('input[name="skus[' + i + '].ladderPriceList[0].buyNum"]').val();
+                            buyPrice = $('input[name="skus[' + i + '].ladderPriceList[0].buyPrice"]').val();
+                            if (buyNum <= 0 || buyNum == '' || buyPrice <= 0 || buyPrice == '') {
+                                alertx("请输入正确的阶梯价格");
+                                return false;
+                            }
                         }
-                    }
-                    if ($('input[name="activityLadderList[1].buyNum"]:visible').length>0){
-                        var buyNum1 = $('input[name="activityLadderList[1].buyNum"]').val();
-                        var buyPrice1 = $('input[name="activityLadderList[1].buyPrice"]').val();
-                        if(buyNum1<=0 || buyNum1 == '' || buyPrice1<=0 || buyPrice1 == ''){
-                            alertx("请输入正确的阶梯价格");
-                            return false;
+                        if ($('input[name="skus[' + i + '].ladderPriceList[1].buyNum"]:visible').length > 0) {
+                            buyNum1 = $('input[name="skus[' + i + '].ladderPriceList[1].buyNum"]').val();
+                            buyPrice1 = $('input[name="skus[' + i + '].ladderPriceList[1].buyPrice"]').val();
+                            if (buyNum1 <= 0 || buyNum1 == '' || buyPrice1 <= 0 || buyPrice1 == '') {
+                                alertx("请输入正确的阶梯价格");
+                                return false;
+                            }
                         }
-                    }
-                    if ($('input[name="activityLadderList[2].buyNum"]:visible').length>0){
-                        var buyNum2 = $('input[name="activityLadderList[2].buyNum"]').val();
-                        var buyPrice2 = $('input[name="activityLadderList[2].buyPrice"]').val();
-                        if(buyNum2<=0 || buyNum2 == '' || buyPrice2<=0 || buyPrice2 == ''){
-                            alertx("请输入正确的阶梯价格");
-                            return false;
+                        if ($('input[name="skus[' + i + '].ladderPriceList[2].buyNum"]:visible').length > 0) {
+                            buyNum2 = $('input[name="skus[' + i + '].ladderPriceList[2].buyNum"]').val();
+                            buyPrice2 = $('input[name="skus[' + i + '].ladderPriceList[2].buyPrice"]').val();
+                            if (buyNum2 <= 0 || buyNum2 == '' || buyPrice2 <= 0 || buyPrice2 == '') {
+                                alertx("请输入正确的阶梯价格");
+                                return false;
+                            }
                         }
                     }
                     loading('正在提交,请稍等...');
@@ -74,88 +75,120 @@
         <label>供应商:</label>${cmHeheActivityProduct.shopName}
     </div>
     <div class="control-group">
-        <label>机构价:</label>${cmHeheActivityProduct.price}
-    </div>
-    <div class="control-group">
-        <label>活动价:</label>
-        <div id="ladderPrice1">
-            &nbsp;&nbsp;&nbsp;&nbsp;起订量:<form:input path="activityLadderList[0].buyNum" min="1" type="number"
-                                                    maxlength="11" class="short number" onblur="checkBuyNum(this, 0)"/>及以上,
-            <form:input path="activityLadderList[0].buyPrice" type="number" maxlength="11" class="short price"
-                        onblur="checkBuyPrice(this, 0)"/>元/(${cmHeheActivityProduct.unit})
-            <span class="showBtn ${null != cmHeheActivityProduct.activityLadderList[1] && null != cmHeheActivityProduct.activityLadderList[1].buyNum ? "hide" : ""}">
-                                <a class="addBtn" href="javascript:;">添加</a>
-                                <form:hidden path="activityLadderList[0].id"/>
+        <input id="skuSize" value="${cmHeheActivityProduct.skus.size()}" type="hidden">
+        <c:forEach items="${cmHeheActivityProduct.skus}" var="sku" varStatus="index">
+            <div>
+                <label>规格:规格${index.index+1}</label>
+            </div>
+            <div>
+                <label>机构价:</label><input id="price${index.index}" value="${sku.price}" class="input-medium" type="text"
+                                          style="width: 60px" disabled/>
+            </div>
+            <label>活动价:</label>
+            <div class="sku${index.index}">
+                <input id="skuId" type="hidden" value="${sku.skuId}">
+                <div id="ladderPrice1">
+                    &nbsp;&nbsp;&nbsp;&nbsp;起订量:<form:input path="skus[${index.index}].ladderPriceList[0].buyNum"
+                                                            min="1" type="number"
+                                                            maxlength="11" class="short number"
+                                                            onblur="checkBuyNum(this, 0,${index.index})"/>及以上,
+                    <form:input path="skus[${index.index}].ladderPriceList[0].buyPrice" type="number" maxlength="11"
+                                class="short price"
+                                onblur="checkBuyPrice(this, 0 ,${index.index})"/>元/(${sku.unit})
+                    <span class="showBtn ${null != sku.ladderPriceList[1] && null != sku.ladderPriceList[1].buyNum ? 'hide' : ''}">
+                                <a class="addBtn" href="javascript:;" onclick="addPrice1(${index.index})">添加</a>
+                                <form:hidden path="skus[${index.index}].ladderPriceList[0].id"/>
                             </span>
-        </div>
-        <div id="ladderPrice2" ${null == cmHeheActivityProduct.activityLadderList[1] && null == cmHeheActivityProduct.activityLadderList[1].buyNum ? "class='hide'" : ""}>
-            &nbsp;&nbsp;&nbsp;&nbsp;起订量:<form:input path="activityLadderList[1].buyNum" type="number" maxlength="11"
-                                                    class="short number" onblur="checkBuyNum(this, 1)"/>及以上,
-            <form:input path="activityLadderList[1].buyPrice" type="number" maxlength="11" class="short price"
-                        onblur="checkBuyPrice(this, 1)"/>元/(${cmHeheActivityProduct.unit})
-            <span class="showBtn ${null != cmHeheActivityProduct.activityLadderList[2] && null != cmHeheActivityProduct.activityLadderList[2].buyNum ? "hide" : ""}">
-                                <a class="delBtn" href="javascript:;">删除</a> / <a class="addBtn"
-                                                                                  href="javascript:;">添加</a>
-                                <form:hidden path="activityLadderList[1].id"/>
+                </div>
+                <div id="ladderPrice2" ${null == sku.ladderPriceList[1] && null == sku.ladderPriceList[1].buyNum ? "class='hide'" : ""}>
+                    &nbsp;&nbsp;&nbsp;&nbsp;起订量:<form:input path="skus[${index.index}].ladderPriceList[1].buyNum"
+                                                            type="number" maxlength="11"
+                                                            class="short number"
+                                                            onblur="checkBuyNum(this, 1 , ${index.index})"/>及以上,
+                    <form:input path="skus[${index.index}].ladderPriceList[1].buyPrice" type="number" maxlength="11"
+                                class="short price"
+                                onblur="checkBuyPrice(this, 1 , ${index.index})"/>元/(${sku.unit})
+                    <span class="showBtn ${null != sku.ladderPriceList[2] && null != sku.ladderPriceList[2].buyNum ? "hide" : ""}">
+                        <a class="delBtn" href="javascript:;" onclick="delPrice2(${index.index})">删除</a> /
+                        <a class="addBtn" onclick="addPrice2(${index.index})" href="javascript:;">添加</a>
+                                <form:hidden path="skus[${index.index}].ladderPriceList[1].id"/>
                             </span>
-        </div>
-        <div id="ladderPrice3" ${null == cmHeheActivityProduct.activityLadderList[2] && null == cmHeheActivityProduct.activityLadderList[2].buyNum ? "class='hide'" : ""}>
-            &nbsp;&nbsp;&nbsp;&nbsp;起订量:<form:input path="activityLadderList[2].buyNum" type="number" maxlength="11"
-                                                    class="short number" onblur="checkBuyNum(this, 2)"/>及以上,
-            <form:input path="activityLadderList[2].buyPrice" type="number" maxlength="11" class="short price"
-                        onblur="checkBuyPrice(this, 2)"/>元/(${cmHeheActivityProduct.unit})
-            <span class="showBtn"><a class="delBtn" href="javascript:;">删除</a></span>
-            <form:hidden path="activityLadderList[2].id"/>
-        </div>
+                    <input id="delFlag2" value="${sku.ladderPriceList[1].delFlag}" type="hidden"/>
+                </div>
+                <div id="ladderPrice3" ${null == sku.ladderPriceList[2] && null == sku.ladderPriceList[2].buyNum ? "class='hide'" : ""}>
+                    &nbsp;&nbsp;&nbsp;&nbsp;起订量:<form:input path="skus[${index.index}].ladderPriceList[2].buyNum"
+                                                            type="number" maxlength="11"
+                                                            class="short number"
+                                                            onblur="checkBuyNum(this, 2 ,${index.index})"/>及以上,
+                    <form:input path="skus[${index.index}].ladderPriceList[2].buyPrice" type="number" maxlength="11"
+                                class="short price"
+                                onblur="checkBuyPrice(this, 2 , ${index.index})"/>元/(${sku.unit})
+                    <span class="showBtn"><a class="delBtn" href="javascript:;"
+                                             onclick="delPrice3(${index.index})">删除</a></span>
+                    <form:hidden path="skus[${index.index}].ladderPriceList[2].id"/>
+                    <input id="delFlag3" value="${sku.ladderPriceList[2].delFlag}" type="hidden"/>
+                </div>
+            </div>
+        </c:forEach>
     </div>
 </form:form>
 
 <script>
-    // 阶梯价格点击事件
-    $("#ladderPrice1").on("click", ".addBtn", function () {
-        $("#ladderPrice2").removeClass("hide");
-        $("#delFlag2").val("0");
-        $("#ladderPrice1").find(".showBtn").addClass("hide");
-    });
-    $("#ladderPrice2").on("click", ".addBtn", function () {
-        $("#ladderPrice3").removeClass("hide");
-        $("#delFlag3").val("0");
-        $("#ladderPrice2").find(".showBtn").addClass("hide");
-    }).on("click", ".delBtn", function () {
-        $("#ladderPrice2").addClass("hide");
-        $("#ladderPrice1").find(".showBtn").removeClass("hide");
-        $("#delFlag2").val("1");
-    });
-    $("#ladderPrice3").on("click", ".delBtn", function () {
-        $("#ladderPrice3").addClass("hide");
-        $("#ladderPrice2").find(".showBtn").removeClass("hide");
-        $("#delFlag3").val("1");
-    });
+    function addPrice1(index) {
+        var skuIndex = ".sku" + index;
+        $(skuIndex).find("#ladderPrice2").removeClass("hide");
+        $(skuIndex).find("#delFlag2").val("0");
+        $(skuIndex).find("#ladderPrice1").find(".showBtn").addClass("hide");
+    }
+
+    function addPrice2(index) {
+        var skuIndex = ".sku" + index;
+        $(skuIndex).find("#ladderPrice3").removeClass("hide");
+        $(skuIndex).find("#delFlag3").val("0");
+        $(skuIndex).find("#ladderPrice2").find(".showBtn").addClass("hide");
+    }
+
+    function delPrice2(index) {
+        var skuIndex = ".sku" + index;
+        $(skuIndex).find("#ladderPrice2").addClass("hide");
+        $(skuIndex).find("#ladderPrice1").find(".showBtn").removeClass("hide");
+        $(skuIndex).find("#delFlag2").val("1");
+    }
+
+    function delPrice3(index) {
+        var skuIndex = ".sku" + index;
+        $(skuIndex).find("#ladderPrice3").addClass("hide");
+        $(skuIndex).find("#ladderPrice2").find(".showBtn").removeClass("hide");
+        $(skuIndex).find("#delFlag3").val("1");
+    }
+
 
     // 检查阶梯数量
-    function checkBuyNum(input, index) {
+    function checkBuyNum(input, index, skuIndex) {
+        var skus = ".sku" + skuIndex;
         if (index > 0) {
-            var beforeNum = $('input[name="activityLadderList[' + (index - 1) + '].buyNum"]').val() * 1;
+            var beforeNum = $(skus).find('input[name="skus[' + skuIndex + '].ladderPriceList[' + (index - 1) + '].buyNum"]').val() * 1;
             if (input.value * 1 <= beforeNum) {
                 alertx("请输入大于上一阶起订量的值");
-                $(input).val(input.value * 1 + beforeNum);
+                $(skus).find(input).val(input.value * 1 + beforeNum);
             }
         } else {
-            var minNum = $('input[name="activityLadderList[0].buyNum"]').val() * 1;
-            $('#minBuyNumber').val(minNum);
+            var minNum = $(skus).find('input[name="skus[' + skuIndex + '].ladderPriceList[0].buyNum"]').val() * 1;
+            $(skus).find('#minBuyNumber').val(minNum);
         }
     }
 
     // 检查阶梯价格
-    function checkBuyPrice(input, index) {
+    function checkBuyPrice(input, index, skuIndex) {
+        var skus = ".sku" + skuIndex;
         if (index > 0) {
-            var beforePrice = $('input[name="activityLadderList[' + (index - 1) + '].buyPrice"]').val() * 1;
+            var beforePrice = $(skus).find('input[name="skus[' + skuIndex + '].ladderPriceList[' + (index - 1) + '].buyPrice"]').val() * 1;
             if (input.value * 1 > beforePrice) {
                 $(input).val('');
                 alertx("请输入小于前一个价格的值");
             }
         } else {
-            var price = $('#price').val();
+            var price = $('#price' + skuIndex).val();
             if (input.value * 1 > price) {
                 $(input).val('');
                 alertx("第一个阶梯价格不能大于机构价");
@@ -164,42 +197,59 @@
     }
 
     function onclickSave() {
-        if ($('input[name="activityLadderList[0].buyNum"]:visible').length>0){
-            var buyNum = $('input[name="activityLadderList[0].buyNum"]').val();
-            var buyPrice = $('input[name="activityLadderList[0].buyPrice"]').val();
-            if(buyNum<=0 || buyNum == '' || buyPrice<=0 || buyPrice == ''){
-                return false;
+        var size = $('#skuSize').val();
+        var skus = new Array();
+        for (let i = 0; i < size; i++) {
+            //根据sku数量循环包装数据返回页面保存
+            var buyNum;
+            var buyPrice;
+            var buyNum1;
+            var buyPrice1;
+            var buyNum2;
+            var buyPrice2;
+            if ($('input[name="skus[' + i + '].ladderPriceList[0].buyNum"]:visible').length > 0) {
+                buyNum = $('input[name="skus[' + i + '].ladderPriceList[0].buyNum"]').val();
+                buyPrice = $('input[name="skus[' + i + '].ladderPriceList[0].buyPrice"]').val();
+                if (buyNum <= 0 || buyNum == '' || buyPrice <= 0 || buyPrice == '') {
+                    return false;
+                }
             }
-        }
-        if ($('input[name="activityLadderList[1].buyNum"]:visible').length>0){
-            var buyNum1 = $('input[name="activityLadderList[1].buyNum"]').val();
-            var buyPrice1 = $('input[name="activityLadderList[1].buyPrice"]').val();
-            if(buyNum1<=0 || buyNum1 == '' || buyPrice1<=0 || buyPrice1 == ''){
-                return false;
+            if ($('input[name="skus[' + i + '].ladderPriceList[1].buyNum"]:visible').length > 0) {
+                buyNum1 = $('input[name="skus[' + i + '].ladderPriceList[1].buyNum"]').val();
+                buyPrice1 = $('input[name="skus[' + i + '].ladderPriceList[1].buyPrice"]').val();
+                if (buyNum1 <= 0 || buyNum1 == '' || buyPrice1 <= 0 || buyPrice1 == '') {
+                    return false;
+                }
             }
-        }
-        if ($('input[name="activityLadderList[2].buyNum"]:visible').length>0){
-            var buyNum2 = $('input[name="activityLadderList[2].buyNum"]').val();
-            var buyPrice2 = $('input[name="activityLadderList[2].buyPrice"]').val();
-            if(buyNum2<=0 || buyNum2 == '' || buyPrice2<=0 || buyPrice2 == ''){
-                return false;
+            if ($('input[name="skus[' + i + '].ladderPriceList[2].buyNum"]:visible').length > 0) {
+                buyNum2 = $('input[name="skus[' + i + '].ladderPriceList[2].buyNum"]').val();
+                buyPrice2 = $('input[name="skus[' + i + '].ladderPriceList[2].buyPrice"]').val();
+                if (buyNum2 <= 0 || buyNum2 == '' || buyPrice2 <= 0 || buyPrice2 == '') {
+                    return false;
+                }
             }
+
+            var skuId = $('.sku' + i).find("#skuId").val();
+            var con={};
+            con["skuId"] = skuId;
+            con["ladder1"] = buyNum + "," + buyPrice;
+            con["ladderSize"] = 1;
+            con["ladder2"];
+            con["ladder3"];
+            var delFlag2 = $('.sku' + i).find("#delFlag2").val() * 1;
+            var delFlag3 = $('.sku' + i).find("#delFlag3").val() * 1;
+            if (0 == delFlag2 && !$('.sku' + i).find("#ladderPrice2").is(":hidden")) {
+                con["ladderSize"] = 2;
+                con["ladder2"] = buyNum1 + "," + buyPrice1;
+            }
+            if (0 == delFlag3 && !$('.sku' + i).find("#ladderPrice3").is(":hidden")) {
+                con["ladderSize"] = 3;
+                con["ladder3"] = buyNum2 + "," + buyPrice2;
+            }
+            skus[i]=con;
         }
-        var params = "";
-        var buyNum = $('input[name="activityLadderList[0].buyNum"]').val() * 1;
-        var buyPrice = $('input[name="activityLadderList[0].buyPrice"]').val() * 1;
-        params = buyNum + "," + buyPrice;
-        if (!$("#ladderPrice2").is(":hidden")) {
-            var buyNum1 = $('input[name="activityLadderList[1].buyNum"]').val() * 1;
-            var buyPrice1 = $('input[name="activityLadderList[1].buyPrice"]').val() * 1;
-            params = params + "-" + buyNum1 + "," + buyPrice1;
-        }
-        if (!$("#ladderPrice3").is(":hidden")) {
-            var buyNum2 = $('input[name="activityLadderList[2].buyNum"]').val() * 1;
-            var buyPrice2 = $('input[name="activityLadderList[2].buyPrice"]').val() * 1;
-            params = params + "-" + buyNum2 + "," + buyPrice2;
-        }
-        return params;
+        var skJ = JSON.stringify(skus);
+        return skJ;
     }
 </script>
 </body>

+ 5 - 19
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductList.jsp

@@ -29,7 +29,8 @@
 <body>
 <ul class="nav nav-tabs">
     <li><a href="${ctx}/hehe/cmHeheActivity/list">活动列表</a></li>
-    <li class="active"><a href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}">活动商品列表</a></li>
+    <li class="active"><a
+            href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}">活动商品列表</a></li>
 </ul>
 <form:form id="searchForm" modelAttribute="cmHeheActivityProduct" action="${ctx}/hehe/cmHeheActivityProduct/"
            method="post" class="breadcrumb form-search">
@@ -53,8 +54,7 @@
         <th>图片</th>
         <th>名称</th>
         <th>供应商</th>
-        <th>售价</th>
-        <th>活动价</th>
+        <th>有无活动价</th>
         <th>操作</th>
     </tr>
     </thead>
@@ -71,21 +71,7 @@
                     ${cmHeheActivityProduct.shopName}
             </td>
             <td>
-                    ${cmHeheActivityProduct.price}
-            </td>
-            <td>
-                <c:if test="${cmHeheActivityProduct.activityLadderList.size() eq 1}">
-                    <label>¥${cmHeheActivityProduct.activityLadderList[0].buyPrice}(购买数≥${cmHeheActivityProduct.activityLadderList[0].buyNum})</label><br>
-                </c:if>
-                <c:if test="${cmHeheActivityProduct.activityLadderList.size() eq 2}">
-                    <label>¥${cmHeheActivityProduct.activityLadderList[0].buyPrice}(购买数${cmHeheActivityProduct.activityLadderList[0].buyNum}-${cmHeheActivityProduct.activityLadderList[1].buyNum})</label><br>
-                    <label>¥${cmHeheActivityProduct.activityLadderList[1].buyPrice}(购买数≥${cmHeheActivityProduct.activityLadderList[1].buyNum})</label><br>
-                </c:if>
-                <c:if test="${cmHeheActivityProduct.activityLadderList.size() eq 3}">
-                    <label>¥${cmHeheActivityProduct.activityLadderList[0].buyPrice}(购买数${cmHeheActivityProduct.activityLadderList[0].buyNum}-${cmHeheActivityProduct.activityLadderList[1].buyNum})</label><br>
-                    <label>¥${cmHeheActivityProduct.activityLadderList[1].buyPrice}(购买数${cmHeheActivityProduct.activityLadderList[1].buyNum}-${cmHeheActivityProduct.activityLadderList[2].buyNum})</label><br>
-                    <label>¥${cmHeheActivityProduct.activityLadderList[2].buyPrice}(购买数≥${cmHeheActivityProduct.activityLadderList[2].buyNum})</label><br>
-                </c:if>
+                    ${0 ==cmHeheActivityProduct.ladderFlag?'无':'有'}
             </td>
             <td>
                 <a href="javascript:void(0);" onclick="showLadder(${cmHeheActivityProduct.id})">编辑</a>
@@ -170,7 +156,7 @@
                     var params = $jboxFrame[0].contentWindow.onclickSave();
                     console.log(params);
                     if (params != false) {
-                        $.post("${ctx}/hehe/cmHeheActivityProduct/saveActivityLadder?params=" + params + "&id=" + id, function (data) {
+                        $.get("${ctx}/hehe/cmHeheActivityProduct/saveActivityLadder?params=" + params + "&id=" + id, function (data) {
                             if (true == data.success) {
                                 $.jBox.tip(data.info, 'info');
                                 setTimeout(function () {

+ 233 - 190
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCollageProductForm.jsp

@@ -1,205 +1,248 @@
 <%@ 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"/>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			//$("#name").focus();
-			$("#inputForm").validate({
-				submitHandler: function(form){
-					var productId = $("#productId").val();
-					if (productId == '') {
-						alertx("请选择商品");
-						return false;
-					}
-					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"/>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    var productId = $("#productId").val();
+                    if (productId == '') {
+                        alertx("请选择商品");
+                        return false;
+                    }
+                    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}/hehe/cmHeheCollageProduct/">商品列表</a></li>
-		<li class="active"><a href="${ctx}/hehe/cmHeheCollageProduct/form?id=${cmHeheCollageProduct.id}">商品${not empty cmHeheCollageProduct.id?'编辑':'添加'}</a></li>
-	</ul><br/>
-	<form:form id="inputForm" modelAttribute="cmHeheCollageProduct" action="${ctx}/hehe/cmHeheCollageProduct/save" method="post" class="form-horizontal">
-		<form:hidden path="id"/>
-		<sys:message content="${message}"/>
-		<form:hidden path="productId"/>
-		<form:hidden path="unlimitedFlag"/>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>商品:</label>
-			<div class="controls">
-				<label class="noProd"><a href="JavaScript:;" onclick="showSelect()">请选择加入呵呵商城的商品</a></label>
-			</div>
-			<table id="contentTable" class="table table-striped table-bordered table-condensed hasProd">
-				<thead>
-				<th>商品ID</th>
-				<th>图片</th>
-				<th>商品名称</th>
-				<th>供应商</th>
-				<th>操作</th>
-				</thead>
-				<tbody id="contentTbody">
-				<tr>
-					<td id="productIdTd">${cmHeheCollageProduct.productId}</td>
-					<td><img id="productImageTd" src="${cmHeheCollageProduct.productImage}" width="50px" height="50px"></td>
-					<td id="productNameTd">${cmHeheCollageProduct.productName}</td>
-					<td id="shopNameTd">${cmHeheCollageProduct.shopName}</td>
-					<td>
-						<a href="javaScript:;"
-						   onclick="deleteProduct()">删除</a>
-					</td>
-				</tr>
-				</tbody>
-			</table>
-		</div>
-		<div class="hasProd">
-			<div class="control-group">
-				<label class="control-label"><font color="red">*</font>拼团价格:</label>
-				<div class="controls">
-					<form:input path="price" htmlEscape="false" class="input-xlarge  number required"/>
-				</div>
-			</div>
-			<div class="control-group">
-				<label class="control-label"><font color="red">*</font>单人限购量:</label>
-				<div class="controls">
-					<input type="number" id="limitedNum" name="limitedNum" onkeyup="onlynum(this)" value="${cmHeheCollageProduct.limitedNum}" min="1" required>
-					<input type="checkbox" id="unlimitedFlag" name="unlimitedFlag" class="formCheck" value="${cmHeheCollageProduct.unlimitedFlag eq 1?1:0}"
-						${cmHeheCollageProduct.unlimitedFlag eq 1 ? "checked" : ""} onclick="changeCondition()" />不限
-					<input id="limitedNumTemp" type="hidden" value="${cmHeheCollageProduct.limitedNum}">
-				</div>
-			</div>
-			<div class="control-group">
-				<label class="control-label"><font color="red">*</font>拼团人数:</label>
-				<div class="controls">
-					<form:input path="memberNum" htmlEscape="false" class="input-xlarge  digits required"/>
-				</div>
-			</div>
-		</div>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/hehe/cmHeheCollageProduct/">商品列表</a></li>
+    <li class="active"><a
+            href="${ctx}/hehe/cmHeheCollageProduct/form?id=${cmHeheCollageProduct.id}">商品${not empty cmHeheCollageProduct.id?'编辑':'添加'}</a>
+    </li>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="cmHeheCollageProduct" action="${ctx}/hehe/cmHeheCollageProduct/save"
+           method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <sys:message content="${message}"/>
+    <form:hidden path="productId"/>
+    <form:hidden path="unlimitedFlag"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品:</label>
+        <div class="controls">
+            <label class="noProd"><a href="JavaScript:;" onclick="showSelect()">请选择加入呵呵商城的商品</a></label>
+        </div>
+        <table id="contentTable" class="table table-striped table-bordered table-condensed hasProd">
+            <thead>
+            <th>商品ID</th>
+            <th>图片</th>
+            <th>商品名称</th>
+            <th>供应商</th>
+            <th>操作</th>
+            </thead>
+            <tbody id="contentTbody">
+            <tr>
+                <td id="productIdTd">${cmHeheCollageProduct.productId}</td>
+                <td><img id="productImageTd" src="${cmHeheCollageProduct.productImage}" width="50px" height="50px"></td>
+                <td id="productNameTd">${cmHeheCollageProduct.productName}</td>
+                <td id="shopNameTd">${cmHeheCollageProduct.shopName}</td>
+                <td>
+                    <a href="javaScript:;"
+                       onclick="deleteProduct()">删除</a>
+                </td>
+            </tr>
+            </tbody>
+        </table>
+    </div>
+    <div class="hasProd">
+        <div class="control-group" id="skus">
+            <c:forEach items="${cmHeheCollageProduct.skus}" var="sku" varStatus="index">
+                <label class="control-label"><font color="red">*</font>规格:规格${index.index+1}</label>
+                <input name="skus[${index.index}].skuId" value="${sku.skuId}" type="hidden">
+                <div class="controls" style="display:flex">
+                    <div>
+                        <label class="control-label"><font color="red">*</font>售价:</label>
+                        <form:input path="skus[${index.index}].price" htmlEscape="false" cssStyle="width: 80px;"
+                                    disabled="true" class="input-xlarge  number"/>
+                    </div>
+                    <div>
+                        <label class="control-label"><font color="red">*</font>拼团价格:</label>
+                        <form:input path="skus[${index.index}].collagePrice" htmlEscape="false" cssStyle="width: 90px;"
+                                    class="input-xlarge  number required"/>
+                    </div>
+                </div>
+            </c:forEach>
+        </div>
+        <div class="control-group">
+            <label class="control-label"><font color="red">*</font>单人限购量:</label>
+            <div class="controls">
+                <input type="number" id="limitedNum" name="limitedNum" onkeyup="onlynum(this)"
+                       value="${cmHeheCollageProduct.limitedNum}" min="1" required>
+                <input type="checkbox" id="unlimitedFlag" name="unlimitedFlag" class="formCheck"
+                       value="${cmHeheCollageProduct.unlimitedFlag eq 1?1:0}"
+                    ${cmHeheCollageProduct.unlimitedFlag eq 1 ? "checked" : ""} onclick="changeCondition()"/>不限
+                <input id="limitedNumTemp" type="hidden" value="${cmHeheCollageProduct.limitedNum}">
+            </div>
+        </div>
+        <div class="control-group">
+            <label class="control-label"><font color="red">*</font>拼团人数:</label>
+            <div class="controls">
+                <form:input path="memberNum" htmlEscape="false" class="input-xlarge  digits required"/>
+            </div>
+        </div>
+    </div>
 
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>商品状态:</label>
-			<div class="controls">
-				<form:select path="status" class="input-xlarge ">
-					<form:option value="1" label="已上架"/>
-					<form:option value="0" label="已下架"/>
-				</form:select>
-			</div>
-		</div>
-		<div class="form-actions">
-			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
-			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
-		</div>
-	</form:form>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品状态:</label>
+        <div class="controls">
+            <form:select path="status" class="input-xlarge ">
+                <form:option value="1" label="已上架"/>
+                <form:option value="0" label="已下架"/>
+            </form:select>
+        </div>
+    </div>
+    <div class="form-actions">
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
+        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+    </div>
+</form:form>
 <script>
-	$(function () {
-		showInfo();
-	});
+    $(function () {
+        showInfo();
+    });
 
-	function showInfo() {
-		var productId = $("#productId").val();
-		if (productId != '') {
-			$(".hasProd").show();
-			$(".noProd").hide();
-		} else {
-			$(".hasProd").hide();
-			$(".noProd").show();
-		}
-		var unlimitedFlag = $("#unlimitedFlag").val();
-		if (unlimitedFlag == '') {
-			$("#unlimitedFlag").val(0);
-			unlimitedFlag = '0';
-		}
-		if (unlimitedFlag === '1') {
-			$("#limitedNum").attr('readonly', true);
-			$("#limitedNum").attr('required', false);
-		} else {
-			$("#limitedNum").attr('readonly', false);
-			$("#limitedNum").attr('required', true);
-		}
-	}
+    function showInfo(va) {
+        var productId = $("#productId").val();
+        if (productId != '') {
+            $(".hasProd").show();
+            $(".noProd").hide();
+        } else {
+            $(".hasProd").hide();
+            $(".noProd").show();
+        }
+        var unlimitedFlag = $("#unlimitedFlag").val();
+        if (unlimitedFlag == '') {
+            $("#unlimitedFlag").val(0);
+            unlimitedFlag = '0';
+        }
+        if (unlimitedFlag === '1') {
+            $("#limitedNum").attr('readonly', true);
+            $("#limitedNum").attr('required', false);
+        } else {
+            $("#limitedNum").attr('readonly', false);
+            $("#limitedNum").attr('required', true);
+        }
+        if(null!=va && 1===va){
+            //sku填充
+            $.ajax({
+                url: "${ctx}/hehe/cmHeheCollageProduct/getSku?productId="+productId,
+                type: "GET",
+                dataType: "json",
+                data: "",
+                success: function (res) {
+                    console.log(res);
+                    var html='';
+                    for (let i = 0; i < res.length; i++) {
+                        console.log(res[i])
+                        html+='<label class="control-label"><font color="red">*</font>规格:规格'+(i+1)+'</label>';
+                        html+='<div class="controls" style="display:flex"><div>';
+                        html+='<label class="control-label"><font color="red">*</font>售价:</label>';
+                        html+="<input name='skus["+(i)+"].price' value='"+res[i].price+"' disabled='true' type='number' style='width: 90px' class='input-xlarge number'/>";
+                        html+='</div><div><label class="control-label"><font color="red">*</font>拼团价格:</label>';
+                        html+="<input name='skus["+(i)+"'].collagePrice' style='width: 90px;' type='number' class='input-xlarge number required'/>";
+                        html+='</div></div>';
+                    }
+                    $("#skus").html(html);
+                }
+            });
+        }
+    }
 
-	function changeCondition() {
-		var obj = $("#unlimitedFlag");
-		var val = obj.val();
-		if (val === '1') {
-			obj.val(0);
-			val = '0';
-		} else {
-			obj.val(1);
-			val = '1';
-		}
-		var inputObj = $("#limitedNum");
-		// 临时数据
-		var tempObj = $("#limitedNumTemp");
-		if (val === '1') {
-			inputObj.attr('readonly', true);
-			inputObj.attr('required', false);
-			tempObj.val(inputObj.val());
-			inputObj.val('');
-		} else {
-			inputObj.attr('readonly', false);
-			inputObj.attr('required', true);
-			inputObj.val(tempObj.val());
-			tempObj.val('');
-		}
-	}
+    function changeCondition() {
+        var obj = $("#unlimitedFlag");
+        var val = obj.val();
+        if (val === '1') {
+            obj.val(0);
+            val = '0';
+        } else {
+            obj.val(1);
+            val = '1';
+        }
+        var inputObj = $("#limitedNum");
+        // 临时数据
+        var tempObj = $("#limitedNumTemp");
+        if (val === '1') {
+            inputObj.attr('readonly', true);
+            inputObj.attr('required', false);
+            tempObj.val(inputObj.val());
+            inputObj.val('');
+        } else {
+            inputObj.attr('readonly', false);
+            inputObj.attr('required', true);
+            inputObj.val(tempObj.val());
+            tempObj.val('');
+        }
+    }
 
-	function showSelect() {
-		var url = "${ctx}/hehe/cmHeheCollageProduct/toAddProduct";
-		var title = '';
-		title = "选择商品";
-		top.$.jBox("iframe:" + url, {
-			iframeScrolling: 'yes',
-			width: $(top.document).width() - 400,
-			height: $(top.document).height() - 160,
-			persistent: true,
-			title: title,
-			buttons: {"确定": '1', "取消": '-1'},
-			submit: function (v, h, f) {
-				//确定
-				var $jboxFrame = top.$('#jbox-iframe');
-				var $mainFrame = top.$('#mainFrame');
-				if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
-					var items = $jboxFrame[0].contentWindow.getCheckedItems();
-					$("#productId").val(items[0].productId);
-					$("#productIdTd").text(items[0].productId);
-					$("#productImageTd").attr('src', items[0].image);
-					$("#productNameTd").text(items[0].productName);
-					$("#shopNameTd").text(items[0].shopName);
-					showInfo();
-				}
-				return true;
-			}
-		});
-	}
+    function showSelect() {
+        var url = "${ctx}/hehe/cmHeheCollageProduct/toAddProduct";
+        var title = '';
+        title = "选择商品";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 400,
+            height: $(top.document).height() - 160,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1', "取消": '-1'},
+            submit: function (v, h, f) {
+                //确定
+                var $jboxFrame = top.$('#jbox-iframe');
+                var $mainFrame = top.$('#mainFrame');
+                if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                    var items = $jboxFrame[0].contentWindow.getCheckedItems();
+                    console.log(items);
+                    $("#productId").val(items[0].productId);
+                    $("#productIdTd").text(items[0].productId);
+                    $("#productImageTd").attr('src', items[0].image);
+                    $("#productNameTd").text(items[0].productName);
+                    $("#shopNameTd").text(items[0].shopName);
+                    showInfo(1);
+                }
+                return true;
+            }
+        });
+    }
 
-	function deleteProduct() {
-		$("#productId").val('');
-		showInfo();
-	}
+    function deleteProduct() {
+        $("#productId").val('');
+        showInfo();
+    }
 
-	/**
-	 * @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, ""); //清除"数字"以外的字符
+    }
 </script>
 </body>
 </html>

+ 716 - 644
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheProductForm.jsp

@@ -1,651 +1,723 @@
 <%@ 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>
-		body {
-			font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
-			font-size: 14px;
-			line-height: 1.42857143;
-			color: #666;
-			margin: 0;
-		}
-
-		.hidden {
-			display: none !important;
-		}
-		.selectPickerWrapper * {
-			box-sizing: border-box;
-		}
-		.selectPickerWrapper {
-			position: relative;
-			/* margin: 50px; */
-			display: inline-block;
-		}
-		.select-picker-search {
-			width: 200px;
-			height: 32px;
-			line-height: 32px;
-			color: #666;
-			border-radius: 3px;
-			border: 1px solid #ddd;
-			padding: 0 10px;
-			font-size: 14px;
-			cursor: pointer;
-		}
-		.select-picker-search-checked {
-			position: relative;
-			width: 180px;
-			white-space: nowrap;
-			text-overflow: ellipsis;
-			overflow: hidden;
-			padding-right: 5px;
-		}
-		.select-picker-search-checked:after {
-			border: 5px solid transparent;
-			content: ' ';
-			height: 0;
-			position: absolute;
-			width: 0;
-			top: 12.2px;
-			border-top: 8px solid #666;
-			right: 0;
-		}
-		.select-picker-options-wrp {
-			display: none;
-			width: 200px;
-			border-radius: 2px;
-			box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
-			background-color: #fff;
-			position: absolute;
-			top: 36px;
-			left: 0;
-			z-index: 999;
-		}
-		.select-picker-options-serch input {
-			width: 160px;
-			height: 32px;
-			line-height: 32px;
-			border: 1px solid #ddd;
-			border-radius: 3px;
-			margin: 12px 0 0 10px;
-			padding-left: 8px;
-		}
-		.select-picker-options-serch input:focus {
-			border-color: #2fa4e7;
-			outline: 0;
-			-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
-			box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
-		}
-		.select-picker-options-list {
-			width: 100%;
-			padding: 8px 0;
-		}
-		.select-picker-options-list-item {
-			width: 100%;
-			line-height: 36px;
-			cursor: pointer;
-			padding: 0 12px;
-		}
-		.select-picker-options-list-item:hover {
-			background: #ebf1f5;
-		}
-		.duihao {
-			display: inline-block;
-			width: 18px;
-			height: 18px;
-			border-radius: 3px;
-			transform: translateY(4px);
-			margin-right: 6px;
-		}
-		.duihao-checked {
-			background: #2fa4e7;
-			position: relative;
-		}
-		.duihao-checked:before,
-		.duihao-checked::after {
-			content: '';
-			height: 10px;
-			width: 2px;
-			border-radius: 10px;
-			display: block;
-			background: white;
-			position: absolute;
-			top: 4px;
-			left: 10px;
-			transform: rotate(45deg);
-			-ms-transform: rotate(45deg);
-		}
-		.duihao-checked::before {
-			height: 6px;
-			transform: rotate(-45deg);
-			-ms-transform: rotate(-45deg);
-			position: absolute;
-			top: 7px;
-			left: 5px;
-		}
-		.duihao-nocheck {
-			border: 1px solid #ddd;
-		}
-
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			//$("#name").focus();
-			$("#inputForm").validate({
-				submitHandler: function (form) {
-					var productId = $('#productId').val();
-					if (productId.length == 0) {
-						alertx("请选择商品");
-						return false;
-					}
-					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);
-					}
-				}
-			});
-		});
-
-
-		/*;(function ($, window, document, undefined) {
-			//用一个自调用匿名函数把插架代码包裹起来,防止代码污染
-			$.fn.mySelect = function (options) {
-				var defaults = {
-					//defaults 使我们设置的默认参数。
-					callback: function (res) {
-						console.log(res)
-					},
-				}
-				var options = $.extend(defaults, options) //将传入参数和默认参数合并
-				var $this = $(this) //当然响应事件对象
-				var selectValues = []
-				//生成option-item并追加展示
-				var html = ''
-				html += '<div class="select-picker-search">'
-				html += '<div class="select-picker-search-checked">请选择</div>'
-				html += '</div>'
-				html += '<div class="select-picker-options-wrp">'
-				// html += '<div class="select-picker-options-serch">';
-				// html += '<input type="text" placeholder="">';
-				// html += '</div>';
-				html += '<div class="select-picker-options-list">'
-				$this.find('option').each(function () {
-					let _this = $(this)
-					html += '<div class="select-picker-options-list-item"'
-					html += 'value="' + _this.attr('value') + '">'
-					html += '<b class="duihao duihao-nocheck"></b>'
-					html += '<span>' + _this.text() + '</span>'
-					html += '</div>'
-				})
-				html += '</div>'
-				html += '</div>'
-				$this.append(html)
-				// 下拉显示隐藏
-				$this.on('click', '.select-picker-search', function (e) {
-					//功能代码部分,绑定事件
-					$(this).next('.select-picker-options-wrp').toggle()
-					// $(this).next('.select-picker-options-wrp').find('.select-picker-options-serch input').focus()
-				})
-				// 点击选中或不选
-				$this.on('click', '.select-picker-options-list-item', function () {
-					let _this = $(this)
-					if (_this.find('.duihao-nocheck').length > 0) {
-						_this.find('.duihao').removeClass('duihao-nocheck').addClass('duihao-checked')
-					} else {
-						_this.find('.duihao').addClass('duihao-nocheck').removeClass('duihao-checked')
-					}
-					// 循环遍历options中选中的项添加到选项栏中
-					var checkedArr = []
-					selectValues = []
-					$this.find('.select-picker-options-list-item').each(function () {
-						let _this = $(this)
-						if (_this.find('.duihao-checked').length > 0) {
-							checkedArr.push($.trim(_this.text()))
-							selectValues.push(_this.attr('value'))
-						}
-					})
-					if (checkedArr.length > 0) {
-						$this.find('.select-picker-search-checked').text(checkedArr.join(','))
-						// $this.find('.select-picker-search-checked').text(checkedArr.join(',')).css('color', '#fff');
-					} else {
-						$this.find('.select-picker-search-checked').text('请选择').css('color', '#757575')
-					}
-					// 回调
-					options.callback(selectValues)
-				})
-				// 前端实现下拉搜索
-				// $this.on('keyup', '.select-picker-options-serch input', function () {
-				// 	var text = $(this).val()
-				// 	var html = ''
-				// 	$this.find('option').each(function () {
-				// 		let _this = $(this)
-				// 		if (_this.text().indexOf(text) != -1) {
-				// 			html += '<div class="select-picker-options-list-item">'
-				// 			html += '<b class="duihao duihao-nocheck"></b>'
-				// 			html += '<span>' + _this.text() + '</span>'
-				// 			html += '</div>'
-				// 		}
-				// 	})
-				// 	if (html == '') {
-				// 		html += '<p style="text-align:center;">没有相关内容</p>'
-				// 	}
-				// 	$this.find('.select-picker-options-list').html('').append(html)
-				// })
-				// 点击document任意地方 下拉消失
-				$(document).click(function (event) {
-					var _con = $('.select-picker-options-wrp') // 设置目标区域
-					var _con2 = $('.select-picker-search-checked') // 设置目标区域
-					if (!_con2.is(event.target) && !_con.is(event.target) && _con.has(event.target).length === 0) {
-						// Mark 1
-						$('.select-picker-options-wrp').hide() //淡出消失
-					}
-				})
-			}
-		})(jQuery, window, document)
-
-		$(function () {
-			$('#demo1').mySelect({
-				callback: function (res) {
-					console.log(res);
-					$("#floorIds").val(res)
-				},
-			})
-		})*/
-	</script>
+    <title>呵呵商品管理</title>
+    <meta name="decorator" content="default"/>
+    <style>
+        body {
+            font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
+            font-size: 14px;
+            line-height: 1.42857143;
+            color: #666;
+            margin: 0;
+        }
+
+        .hidden {
+            display: none !important;
+        }
+
+        .selectPickerWrapper * {
+            box-sizing: border-box;
+        }
+
+        .selectPickerWrapper {
+            position: relative;
+            /* margin: 50px; */
+            display: inline-block;
+        }
+
+        .select-picker-search {
+            width: 200px;
+            height: 32px;
+            line-height: 32px;
+            color: #666;
+            border-radius: 3px;
+            border: 1px solid #ddd;
+            padding: 0 10px;
+            font-size: 14px;
+            cursor: pointer;
+        }
+
+        .select-picker-search-checked {
+            position: relative;
+            width: 180px;
+            white-space: nowrap;
+            text-overflow: ellipsis;
+            overflow: hidden;
+            padding-right: 5px;
+        }
+
+        .select-picker-search-checked:after {
+            border: 5px solid transparent;
+            content: ' ';
+            height: 0;
+            position: absolute;
+            width: 0;
+            top: 12.2px;
+            border-top: 8px solid #666;
+            right: 0;
+        }
+
+        .select-picker-options-wrp {
+            display: none;
+            width: 200px;
+            border-radius: 2px;
+            box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
+            background-color: #fff;
+            position: absolute;
+            top: 36px;
+            left: 0;
+            z-index: 999;
+        }
+
+        .select-picker-options-serch input {
+            width: 160px;
+            height: 32px;
+            line-height: 32px;
+            border: 1px solid #ddd;
+            border-radius: 3px;
+            margin: 12px 0 0 10px;
+            padding-left: 8px;
+        }
+
+        .select-picker-options-serch input:focus {
+            border-color: #2fa4e7;
+            outline: 0;
+            -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
+            box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(102, 175, 233, 0.6);
+        }
+
+        .select-picker-options-list {
+            width: 100%;
+            padding: 8px 0;
+        }
+
+        .select-picker-options-list-item {
+            width: 100%;
+            line-height: 36px;
+            cursor: pointer;
+            padding: 0 12px;
+        }
+
+        .select-picker-options-list-item:hover {
+            background: #ebf1f5;
+        }
+
+        .duihao {
+            display: inline-block;
+            width: 18px;
+            height: 18px;
+            border-radius: 3px;
+            transform: translateY(4px);
+            margin-right: 6px;
+        }
+
+        .duihao-checked {
+            background: #2fa4e7;
+            position: relative;
+        }
+
+        .duihao-checked:before,
+        .duihao-checked::after {
+            content: '';
+            height: 10px;
+            width: 2px;
+            border-radius: 10px;
+            display: block;
+            background: white;
+            position: absolute;
+            top: 4px;
+            left: 10px;
+            transform: rotate(45deg);
+            -ms-transform: rotate(45deg);
+        }
+
+        .duihao-checked::before {
+            height: 6px;
+            transform: rotate(-45deg);
+            -ms-transform: rotate(-45deg);
+            position: absolute;
+            top: 7px;
+            left: 5px;
+        }
+
+        .duihao-nocheck {
+            border: 1px solid #ddd;
+        }
+
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    var productId = $('#productId').val();
+                    if (productId.length == 0) {
+                        alertx("请选择商品");
+                        return false;
+                    }
+                    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);
+                    }
+                }
+            });
+        });
+
+
+        /*;(function ($, window, document, undefined) {
+            //用一个自调用匿名函数把插架代码包裹起来,防止代码污染
+            $.fn.mySelect = function (options) {
+                var defaults = {
+                    //defaults 使我们设置的默认参数。
+                    callback: function (res) {
+                        console.log(res)
+                    },
+                }
+                var options = $.extend(defaults, options) //将传入参数和默认参数合并
+                var $this = $(this) //当然响应事件对象
+                var selectValues = []
+                //生成option-item并追加展示
+                var html = ''
+                html += '<div class="select-picker-search">'
+                html += '<div class="select-picker-search-checked">请选择</div>'
+                html += '</div>'
+                html += '<div class="select-picker-options-wrp">'
+                // html += '<div class="select-picker-options-serch">';
+                // html += '<input type="text" placeholder="">';
+                // html += '</div>';
+                html += '<div class="select-picker-options-list">'
+                $this.find('option').each(function () {
+                    let _this = $(this)
+                    html += '<div class="select-picker-options-list-item"'
+                    html += 'value="' + _this.attr('value') + '">'
+                    html += '<b class="duihao duihao-nocheck"></b>'
+                    html += '<span>' + _this.text() + '</span>'
+                    html += '</div>'
+                })
+                html += '</div>'
+                html += '</div>'
+                $this.append(html)
+                // 下拉显示隐藏
+                $this.on('click', '.select-picker-search', function (e) {
+                    //功能代码部分,绑定事件
+                    $(this).next('.select-picker-options-wrp').toggle()
+                    // $(this).next('.select-picker-options-wrp').find('.select-picker-options-serch input').focus()
+                })
+                // 点击选中或不选
+                $this.on('click', '.select-picker-options-list-item', function () {
+                    let _this = $(this)
+                    if (_this.find('.duihao-nocheck').length > 0) {
+                        _this.find('.duihao').removeClass('duihao-nocheck').addClass('duihao-checked')
+                    } else {
+                        _this.find('.duihao').addClass('duihao-nocheck').removeClass('duihao-checked')
+                    }
+                    // 循环遍历options中选中的项添加到选项栏中
+                    var checkedArr = []
+                    selectValues = []
+                    $this.find('.select-picker-options-list-item').each(function () {
+                        let _this = $(this)
+                        if (_this.find('.duihao-checked').length > 0) {
+                            checkedArr.push($.trim(_this.text()))
+                            selectValues.push(_this.attr('value'))
+                        }
+                    })
+                    if (checkedArr.length > 0) {
+                        $this.find('.select-picker-search-checked').text(checkedArr.join(','))
+                        // $this.find('.select-picker-search-checked').text(checkedArr.join(',')).css('color', '#fff');
+                    } else {
+                        $this.find('.select-picker-search-checked').text('请选择').css('color', '#757575')
+                    }
+                    // 回调
+                    options.callback(selectValues)
+                })
+                // 前端实现下拉搜索
+                // $this.on('keyup', '.select-picker-options-serch input', function () {
+                // 	var text = $(this).val()
+                // 	var html = ''
+                // 	$this.find('option').each(function () {
+                // 		let _this = $(this)
+                // 		if (_this.text().indexOf(text) != -1) {
+                // 			html += '<div class="select-picker-options-list-item">'
+                // 			html += '<b class="duihao duihao-nocheck"></b>'
+                // 			html += '<span>' + _this.text() + '</span>'
+                // 			html += '</div>'
+                // 		}
+                // 	})
+                // 	if (html == '') {
+                // 		html += '<p style="text-align:center;">没有相关内容</p>'
+                // 	}
+                // 	$this.find('.select-picker-options-list').html('').append(html)
+                // })
+                // 点击document任意地方 下拉消失
+                $(document).click(function (event) {
+                    var _con = $('.select-picker-options-wrp') // 设置目标区域
+                    var _con2 = $('.select-picker-search-checked') // 设置目标区域
+                    if (!_con2.is(event.target) && !_con.is(event.target) && _con.has(event.target).length === 0) {
+                        // Mark 1
+                        $('.select-picker-options-wrp').hide() //淡出消失
+                    }
+                })
+            }
+        })(jQuery, window, document)
+
+        $(function () {
+            $('#demo1').mySelect({
+                callback: function (res) {
+                    console.log(res);
+                    $("#floorIds").val(res)
+                },
+            })
+        })*/
+    </script>
 </head>
 <body>
-	<ul class="nav nav-tabs">
-		<li><a href="${ctx}/hehe/cmHeheProduct/">商品列表</a></li>
-		<li class="active"><a href="${ctx}/hehe/cmHeheProduct/form?id=${cmHeheProduct.id}">${not empty cmHeheProduct.id?'编辑':'添加'}</a></li>
-	</ul><br/>
-	<form:form id="inputForm" modelAttribute="cmHeheProduct" action="${ctx}/hehe/cmHeheProduct/save" method="post" class="form-horizontal">
-		<form:hidden path="id"/>
-		<form:hidden path="productId" id="productId"/>
-		<sys:message content="${message}"/>
-<%--        <form:hidden path="floorIds"/>--%>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>商品:</label>
-			<div class="controls" id="addProduct">
-				<a href="JavaScript:;" onclick="showSelect()">请选择加入呵呵商城的商品</a>
-			</div>
-			<table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
-				<thead>
-					<tr>
-						<th>图片</th>
-						<th>商品名称</th>
-						<th>供应商</th>
-						<th>操作</th>
-					</tr>
-				</thead>
-				<tbody>
-					<tr>
-						<td><img id="mainImage" src="${cmHeheProduct.mainImage}" width="50px" height="50px"></td>
-						<td style="text-align: center" id="name">${cmHeheProduct.name}</td>
-						<td id="shopName">${cmHeheProduct.shopName}</td>
-						<td><a href="javascript:void(0);" onclick="deleteProduct()">删除</a></td>
-					</tr>
-				</tbody>
-			</table>
-		</div>
-		<div id="productInfo" hidden="hidden">
-			<div class="control-group">
-				<label class="control-label"><font color="red">*</font>售价:</label>
-				<div class="controls">
-					<input type="number" style="width:100px;" min="0" id="price" name="price" value="${cmHeheProduct.price}" required onblur="checkPrice(this)">
-				</div>
-			</div>
-			<div class="control-group">
-				<label class="control-label"><font color="red">*</font>是否含税:</label>
-				<div class="controls">
-					<form:radiobutton id="includedTax1" path="includedTax" value="1" label="含税" onclick="chageIncludedTax()"/>&nbsp;&nbsp;&nbsp;&nbsp;
-					<form:radiobutton id="includedTax0" path="includedTax" value="0" label="不含税" onclick="chageIncludedTax()"/>
-				</div>
-				<br>
-				<div class="controls">
-					<form:radiobutton id="invoiceType1" path="invoiceType" value="1" label="增值税专用发票" onclick="showTaxPoint()"/>&nbsp;&nbsp;&nbsp;&nbsp;
-					<form:radiobutton id="invoiceType2" path="invoiceType" value="2" label="增值税普通发票" onclick="showTaxPoint()"/>&nbsp;&nbsp;&nbsp;&nbsp;
-					<span id="invoiceTypeShow"><form:radiobutton id="invoiceType3" path="invoiceType" value="3" label="不能开票" onclick="showTaxPoint()"/></span>
-				</div>
-			</div>
-			<div class="control-group taxPointShow">
-				<label class="control-label"><font color="red">*</font>机构税率:</label>
-				<div class="controls">
-					<input type="number" style="width:100px;" id="clubTaxPoint" name="clubTaxPoint" value="${cmHeheProduct.clubTaxPoint}" required>%
-				</div>
-			</div>
-			<div class="control-group taxPointShow">
-				<label class="control-label"><font color="red">*</font>供应商税率:</label>
-				<div class="controls">
-					<input type="number" style="width:100px;" id="shopTaxPoint" name="shopTaxPoint" value="${cmHeheProduct.shopTaxPoint}" required>%
-				</div>
-			</div>
-			<div class="control-group">
-				<label class="control-label"><font color="red">*</font>成本价类型:</label>
-				<div class="controls" id="costType">
-						${cmHeheProduct.costType eq 1 ? '固定成本' : '比例成本'}
-				</div>
-			</div>
-			<div class="control-group" id="costPriceShow">
-				<label class="control-label"><font color="red">*</font>成本价:</label>
-				<div class="controls" id="costPrice">
-					${cmHeheProduct.costPrice}
-				</div>
-			</div>
-			<div class="control-group" id="costProportionalShow">
-				<label class="control-label"><font color="red">*</font>比例成本百分比:</label>
-				<div class="controls" id="costProportional">
-					${cmHeheProduct.costProportional}%
-				</div>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>商品分类:</label>
-			<div class="controls">
-				<form:select path="bigTypeId" class="input-small required" id="bigType" onchange="loadSmallType()">
-					<form:option value="" label="请选择"/>
-					<form:options items="${classify.bigTypeList}" itemLabel="name" itemValue="bigTypeID"
-								  htmlEscape="false"/>
-				</form:select>
-				<form:select path="smallTypeId" class="input-small required" id="smallType">
-					<form:option value="" label="请选择"/>
-					<c:forEach items="${classify.smalltypeList}" var="smallType">
-						<form:option value="${smallType.smallTypeID}" label="${smallType.name}"
-									 bigTypeId="${smallType.bigTypeID}"/>
-					</c:forEach>
-				</form:select>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>商品状态:</label>
-			<div class="controls">
-				<form:select path="validFlag" class="input-small required">
-					<form:option value="" label="请选择"/>
-					<form:option value="1" label="已上架"/>
-					<form:option value="2" label="已下架"/>
-				</form:select>
-			</div>
-		</div>
-		<c:if test="${cmHeheProduct.id eq null}">
-			<%--<div class="control-group">
-				<label class="control-label">首页楼层:</label>
-				<div class="controls" style="overflow: visible">
-					<div id="demo1" class="selectPickerWrapper">
-						<select class="hidden" multiple="multiple" id="select">
-							<c:forEach items="${floorList}" var="floor">
-								<option value="${floor.id}" checked="${floor.checked?'checked':''}">${floor.title}</option>
-							</c:forEach>
-						</select>
-					</div>
-				</div>
-			</div>--%>
-			<div class="control-group">
-				<label class="control-label">商城活动:</label>
-				<div class="controls">
-					<form:select path="activityId" class="input-small">
-						<form:option value="" label="选择活动"/>
-						<form:options items="${activityList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
-					</form:select>
-				</div>
-			</div>
-		</c:if>
-		<div class="form-actions">
-			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
-			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
-		</div>
-	</form:form>
-
-<script>
-	$(function () {
-		//初始化商品信息
-		if (${not empty cmHeheProduct.id}){
-			$('#contentTable').show();
-			$('#productInfo').show();
-			$('#addProduct').hide();
-			chageIncludedTax();
-			changeCostPriceShow(${cmHeheProduct.costType});
-			showTaxPoint();
-		}
-	});
-
-
-	//选择添加商品
-	function showSelect() {
-		var url = '';
-		var title = '';
-		url = "${ctx}/hehe/cmHeheProduct/findProductPage";
-		title = "选择商品";
-		top.$.jBox("iframe:" + url, {
-			iframeScrolling: 'yes',
-			width: $(top.document).width() - 600,
-			height: $(top.document).height() - 160,
-			persistent: true,
-			title: title,
-			buttons: {"确定": '1', "关闭": '-1'},
-			submit: function (v, h, f) {
-				//确定
-				var $jboxFrame = top.$('#jbox-iframe');
-				var $mainFrame = top.$('#mainFrame');
-				if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
-					var items = $jboxFrame[0].contentWindow.getCheckedItems(0);
-					if (items.length > 0) {
-						console.log(items);
-						$('#contentTable').show();
-						$('#productInfo').show();
-						$('#addProduct').hide();
-						var productId = items[0].productId;
-						var mainImage = items[0].mainImage;
-						var name = items[0].name;
-						var shopName = items[0].shopName;
-						var price = items[0].price;
-						var includedTax = items[0].includedTax;
-						var invoiceType = items[0].invoiceType;
-						var clubTaxPoint = items[0].clubTaxPoint;
-						var shopTaxPoint = items[0].shopTaxPoint;
-						var costType = items[0].costType;
-						var costPrice = items[0].costPrice;
-						var costProportional = items[0].costProportional;
-						$("#mainImage").attr("src", mainImage);
-						$("#shopName").text(shopName);
-						$("#productId").val(productId);
-						$("#name").text(name);
-						$("#price").val(price);
-						if (includedTax == 1) {
-							$('#includedTax1').attr('checked', true);
-						} else {
-							$('#includedTax0').attr('checked', true);
-						}
-						if (invoiceType == 1) {
-							$('#invoiceType1').attr('checked', true);
-						} else if (invoiceType == 2) {
-							$('#invoiceType2').attr('checked', true);
-						} else {
-							$('#invoiceType3').attr('checked', true);
-						}
-						$("#clubTaxPoint").val(clubTaxPoint);
-						$("#shopTaxPoint").val(shopTaxPoint);
-						if (costType == 1) {
-							$('#costType').text('固定成本');
-						} else {
-							$('#costType').text('比例成本');
-						}
-						$("#costPrice").text(costPrice);
-						$("#costProportional").text(costProportional + '%');
-						chageIncludedTax();
-						changeCostPriceShow(costType);
-						showTaxPoint();
-					} else {
-						top.$.jBox.tip("请先勾选商品...");
-						return false;
-					}
-				}
-				return true;
-			}
-		});
-	}
-
-	//是否含税显示
-	function chageIncludedTax() {
-		var includedTax = $("input[name='includedTax']:checked").val();
-		if (includedTax == 1) {
-			$('#invoiceTypeShow').hide();
-			var invoiceType = $("input[name='invoiceType']:checked").val();
-			if (invoiceType == 3) {
-				$('#invoiceType1').attr('checked', true);
-				showTaxPoint();
-			}
-		} else {
-			$('#invoiceTypeShow').show();
-		}
-	}
-
-	// 是否固定成本
-	function changeCostPriceShow(costType) {
-		if (costType == 1) {
-			$("#costPriceShow").show();
-			$("#costProportionalShow").hide();
-		} else {
-			$("#costPriceShow").hide();
-			$("#costProportionalShow").show();
-		}
-	}
-
-	//税率显示
-	function showTaxPoint() {
-		var invoiceType = $("input[name='invoiceType']:checked").val();
-		if (invoiceType == 3) {
-			$('.taxPointShow').hide();
-		} else {
-			$('.taxPointShow').show();
-		}
-	}
-
-	//删除商品
-	function deleteProduct() {
-		$('#contentTable').hide();
-		$('#productInfo').hide();
-		$('#addProduct').show();
-		$('#productId').val('');
-	}
-
-	/**
-	 * @param obj
-	 * jquery控制input只能输入数字
-	 */
-	function onlynum(obj) {
-		obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
-	}
-
-	/**
-	 * @param obj
-	 * jquery检验售价
-	 */
-	function checkPrice(obj) {
-		if (obj.value == '0') {
-			obj.value = '';
-		}
-	}
-
-	$(window).load(function () {
-		loadInitType();
-	});
-
-	// 网站分类
-	var currentBigtype = ${empty cmHeheProduct.bigTypeId?0:cmHeheProduct.bigTypeId};
-	var currentSmalltype = ${empty cmHeheProduct.smallTypeId?0:cmHeheProduct.smallTypeId};
-	var bigTypeList = [
-		<c:forEach items="${classify.bigTypeList}" var="bigType" varStatus="index">
-		<c:if test="${index.index > 0}">, </c:if>
-		{
-			bigTypeId: ${bigType.bigTypeID},
-			name: "${bigType.name}",
-			typeSort: ${bigType.typeSort}
-		}
-		</c:forEach>
-	];
-	var smalltypeList = [
-		<c:forEach items="${classify.smalltypeList}" var="smalltype" varStatus="index">
-		<c:if test="${index.index > 0}">, </c:if>
-		{
-			smallTypeId: ${smalltype.smallTypeID},
-			name: "${smalltype.name}",
-			bigTypeId: ${smalltype.bigTypeID},
-		}
-		</c:forEach>
-	];
-	
-	
-	// 初始分类
-	function loadInitType() {
-		if (currentBigtype != null && typeof (currentBigtype) != "undefined") {
-			setTimeout(function () {
-				loadBigType();
-			}, 0);
-		}
-	}
-
-	// 分类联动
-	function loadBigType() {
-		$("#bigType").html("");
-		$("#bigType").prev().find(".select2-chosen").text("请选择");
-		$("#bigType").append("<option value=''>请选择</option>");
-		$("#smallType").html("");
-		$("#smallType").prev().find(".select2-chosen").text("请选择");
-		$("#smallType").append("<option value=''>请选择</option>");
-		$("#tinyType").html("");
-		$("#tinyType").prev().find(".select2-chosen").text("请选择");
-		$("#tinyType").append("<option value=''>请选择</option>");
-		for (var i = 0; i < bigTypeList.length; i++) {
-			if (currentBigtype != null && typeof (currentBigtype) != "undefined" && currentBigtype == bigTypeList[i].bigTypeId) {
-				$("#bigType").append("<option selected value='" + bigTypeList[i].bigTypeId + "'>" + bigTypeList[i].name + "</option>");
-				$("#bigType").prev().find(".select2-chosen").text(bigTypeList[i].name);
-				setTimeout(function () {
-					loadSmallType();
-				}, 500);
-			} else {
-				$("#bigType").append("<option value='" + bigTypeList[i].bigTypeId + "'>" + bigTypeList[i].name + "</option>");
-			}
-		}
-		loadSmallType();
-	}
-
-	function loadSmallType(id) {
-		if (id) {
-			$("#bigType").val(id);
-			$("#bigType").prev().find(".select2-chosen").text($("#bigType option:selected").text());
-		}
-		var bigType = $("#bigType").val();
-		$("#smallType").html("");
-		$("#smallType").prev().find(".select2-chosen").text("请选择");
-		$("#smallType").append("<option value=''>请选择</option>");
-		$("#tinyType").html("");
-		$("#tinyType").prev().find(".select2-chosen").text("请选择");
-		$("#tinyType").append("<option value=''>请选择</option>");
-		if (typeof (bigType) != "undefined" && bigType != "") {
-			var smallTypeNum = 0;
-			for (var i = 0; i < smalltypeList.length; i++) {
-				if (bigType == smalltypeList[i].bigTypeId) {
-					smallTypeNum = smallTypeNum + 1;
-					if (currentSmalltype != null && typeof (currentSmalltype) != "undefined" && currentSmalltype == smalltypeList[i].smallTypeId) {
-						$("#smallType").append("<option selected value='" + smalltypeList[i].smallTypeId + "'>" + smalltypeList[i].name + "</option>");
-						$("#smallType").prev().find(".select2-chosen").text(smalltypeList[i].name);
-					} else {
-						$("#smallType").append("<option value='" + smalltypeList[i].smallTypeId + "'>" + smalltypeList[i].name + "</option>");
-					}
-				}
-			}
-			document.getElementById("s2id_smallType").style.cssText = "display: inline-block";
-		}
-	}
-</script>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/hehe/cmHeheProduct/">商品列表</a></li>
+    <li class="active"><a
+            href="${ctx}/hehe/cmHeheProduct/form?id=${cmHeheProduct.id}">${not empty cmHeheProduct.id?'编辑':'添加'}</a>
+    </li>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="cmHeheProduct" action="${ctx}/hehe/cmHeheProduct/save" method="post"
+           class="form-horizontal">
+<form:hidden path="id"/>
+<form:hidden path="productId" id="productId"/>
+<sys:message content="${message}"/>
+    <%--        <form:hidden path="floorIds"/>--%>
+<div class="control-group">
+    <label class="control-label"><font color="red">*</font>商品:</label>
+    <div class="controls" id="addProduct">
+        <a href="JavaScript:;" onclick="showSelect()">请选择加入呵呵商城的商品</a>
+    </div>
+    <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+        <thead>
+        <tr>
+            <th>图片</th>
+            <th>商品名称</th>
+            <th>供应商</th>
+            <th>操作</th>
+        </tr>
+        </thead>
+        <tbody>
+        <tr>
+            <td><img id="mainImage" src="${cmHeheProduct.mainImage}" width="50px" height="50px"></td>
+            <td style="text-align: center" id="name">${cmHeheProduct.name}</td>
+            <td id="shopName">${cmHeheProduct.shopName}</td>
+            <td><a href="javascript:void(0);" onclick="deleteProduct()">删除</a></td>
+        </tr>
+        </tbody>
+    </table>
+</div>
+<div id="productInfo" hidden="hidden">
+    <c:if test="${empty cmHeheProduct.skus}">
+    <div class="control-group" hidden id="skuPrice">
+        </c:if>
+        <c:if test="${not empty cmHeheProduct.skus}">
+        <div class="control-group" id="skuPrice">
+            </c:if>
+            <c:forEach items="${cmHeheProduct.skus}" var="sku" varStatus="index">
+                <div>
+                    <input type="number" style="display:none" value="${sku.skuId}" name="skus[${index.index}].skuId">
+                    <label class="control-label">
+                        <font color="red">*</font>规格:规格${index.index+1}
+                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                    </label>
+                    <div class="controls">
+                        <font color="red">*</font>售价:
+                        <input type="number" style="width:100px;" min="0" id="price" name="skus[${index.index}].price"
+                               value="${sku.price}" required onblur="checkPrice(this)">
+                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                        <label><font color="red">*</font>成本: ${sku.costCheckFlag eq 1 ? '固定成本' : '比例成本'}</label>
+                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                        <c:if test="${sku.costCheckFlag eq 1}">
+                            <label><font color="red">*</font>成本价:${sku.costPrice}</label>
+                        </c:if>
+                        <c:if test="${sku.costCheckFlag eq 2}">
+                            <label><font color="red">*</font>成本比例百分比:${sku.costProportional}</label>
+                        </c:if>
+                    </div>
+                </div>
+            </c:forEach>
+        </div>
+        <div class="control-group">
+            <label class="control-label"><font color="red">*</font>是否含税:</label>
+            <div class="controls">
+                <form:radiobutton id="includedTax1" path="includedTax" value="1" label="含税"
+                                  onclick="chageIncludedTax()"/>&nbsp;&nbsp;&nbsp;&nbsp;
+                <form:radiobutton id="includedTax0" path="includedTax" value="0" label="不含税"
+                                  onclick="chageIncludedTax()"/>
+            </div>
+            <br>
+            <div class="controls">
+                <form:radiobutton id="invoiceType1" path="invoiceType" value="1" label="增值税专用发票"
+                                  onclick="showTaxPoint()"/>&nbsp;&nbsp;&nbsp;&nbsp;
+                <form:radiobutton id="invoiceType2" path="invoiceType" value="2" label="增值税普通发票"
+                                  onclick="showTaxPoint()"/>&nbsp;&nbsp;&nbsp;&nbsp;
+                <span id="invoiceTypeShow"><form:radiobutton id="invoiceType3" path="invoiceType" value="3" label="不能开票"
+                                                             onclick="showTaxPoint()"/></span>
+            </div>
+        </div>
+        <div class="control-group taxPointShow">
+            <label class="control-label"><font color="red">*</font>机构税率:</label>
+            <div class="controls">
+                <input type="number" style="width:100px;" id="clubTaxPoint" name="clubTaxPoint"
+                       value="${cmHeheProduct.clubTaxPoint}" required>%
+            </div>
+        </div>
+        <div class="control-group taxPointShow">
+            <label class="control-label"><font color="red">*</font>供应商税率:</label>
+            <div class="controls">
+                <input type="number" style="width:100px;" id="shopTaxPoint" name="shopTaxPoint"
+                       value="${cmHeheProduct.shopTaxPoint}" required>%
+            </div>
+        </div>
+            <%--        <div class="control-group">--%>
+            <%--            <label class="control-label"><font color="red">*</font>成本价类型:</label>--%>
+            <%--            <div class="controls" id="costType">--%>
+            <%--                    ${cmHeheProduct.costType eq 1 ? '固定成本' : '比例成本'}--%>
+            <%--            </div>--%>
+            <%--        </div>--%>
+            <%--        <div class="control-group" id="costPriceShow">--%>
+            <%--            <label class="control-label"><font color="red">*</font>成本价:</label>--%>
+            <%--            <div class="controls" id="costPrice">--%>
+            <%--                    ${cmHeheProduct.costPrice}--%>
+            <%--            </div>--%>
+            <%--        </div>--%>
+            <%--        <div class="control-group" id="costProportionalShow">--%>
+            <%--            <label class="control-label"><font color="red">*</font>比例成本百分比:</label>--%>
+            <%--            <div class="controls" id="costProportional">--%>
+            <%--                    ${cmHeheProduct.costProportional}%--%>
+            <%--            </div>--%>
+            <%--        </div>--%>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品分类:</label>
+        <div class="controls">
+            <form:select path="bigTypeId" class="input-small required" id="bigType" onchange="loadSmallType()">
+                <form:option value="" label="请选择"/>
+                <form:options items="${classify.bigTypeList}" itemLabel="name" itemValue="bigTypeID"
+                              htmlEscape="false"/>
+            </form:select>
+            <form:select path="smallTypeId" class="input-small required" id="smallType">
+                <form:option value="" label="请选择"/>
+                <c:forEach items="${classify.smalltypeList}" var="smallType">
+                    <form:option value="${smallType.smallTypeID}" label="${smallType.name}"
+                                 bigTypeId="${smallType.bigTypeID}"/>
+                </c:forEach>
+            </form:select>
+        </div>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品状态:</label>
+        <div class="controls">
+            <form:select path="validFlag" class="input-small required">
+                <form:option value="" label="请选择"/>
+                <form:option value="1" label="已上架"/>
+                <form:option value="2" label="已下架"/>
+            </form:select>
+        </div>
+    </div>
+    <c:if test="${cmHeheProduct.id eq null}">
+        <%--<div class="control-group">
+            <label class="control-label">首页楼层:</label>
+            <div class="controls" style="overflow: visible">
+                <div id="demo1" class="selectPickerWrapper">
+                    <select class="hidden" multiple="multiple" id="select">
+                        <c:forEach items="${floorList}" var="floor">
+                            <option value="${floor.id}" checked="${floor.checked?'checked':''}">${floor.title}</option>
+                        </c:forEach>
+                    </select>
+                </div>
+            </div>
+        </div>--%>
+    <div class="control-group">
+        <label class="control-label">商城活动:</label>
+        <div class="controls">
+            <form:select path="activityId" class="input-small">
+                <form:option value="" label="选择活动"/>
+                <form:options items="${activityList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
+            </form:select>
+        </div>
+    </div>
+    </c:if>
+    <div class="form-actions">
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
+        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+    </div>
+    </form:form>
+
+    <script>
+        $(function () {
+            //初始化商品信息
+            if (${not empty cmHeheProduct.id}) {
+                $('#contentTable').show();
+                $('#productInfo').show();
+                $('#addProduct').hide();
+                chageIncludedTax();
+                <%--changeCostPriceShow(${cmHeheProduct.costType});--%>
+                showTaxPoint();
+            }
+        });
+
+
+        //选择添加商品
+        function showSelect() {
+            var url = '';
+            var title = '';
+            url = "${ctx}/hehe/cmHeheProduct/findProductPage";
+            title = "选择商品";
+            top.$.jBox("iframe:" + url, {
+                iframeScrolling: 'yes',
+                width: $(top.document).width() - 600,
+                height: $(top.document).height() - 160,
+                persistent: true,
+                title: title,
+                buttons: {"确定": '1', "关闭": '-1'},
+                submit: function (v, h, f) {
+                    //确定
+                    var $jboxFrame = top.$('#jbox-iframe');
+                    var $mainFrame = top.$('#mainFrame');
+                    if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                        var items = $jboxFrame[0].contentWindow.getCheckedItems(0);
+                        if (items.length > 0) {
+                            console.log(items);
+                            var skus = {};
+                            skus = items[0].skuList;
+                            var html = '';
+
+                            for (let i = 0; i < skus.length; i++) {
+                                var unit=i+1;
+                                var cost = skus[i].costCheckFlag == 1 ? '固定成本' : '比例成本';
+                                var costShow = skus[i].costCheckFlag == 1 ? '<label><font color="red">*</font>成本价:' + skus[i].costPrice + '</label>' : '<label><font color="red">*</font>成本比例百分比:' + skus[i].costProportional + '</label>';
+                                html += '<div><input type="number" style="display:none" value="' + skus[i].skuId + '" name="skus[' + i + '].skuId">';
+                                html += '<label class="control-label"><font color="red">*</font>规格:规格' + unit;
+                                html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>';
+                                html += '<div class="controls"><font color="red">*</font>售价:';
+                                html += '<input type="number" style="width:100px;" min="0" id="price" name="skus[' + i + '].price" value="' + skus[i].price + '" required onblur="checkPrice(this)">';
+                                html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+                                html += '<label><font color="red">*</font>成本: ' + cost + '</label>';
+                                html += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
+                                html += costShow + '</div></div>';
+                            }
+                            $("#skuPrice").html(html);
+                            $("#skuPrice").show();
+
+                            $('#contentTable').show();
+                            $('#productInfo').show();
+                            $('#addProduct').hide();
+                            var productId = items[0].productId;
+                            var mainImage = items[0].mainImage;
+                            var name = items[0].name;
+                            var shopName = items[0].shopName;
+                            var price = items[0].price;
+                            var includedTax = items[0].includedTax;
+                            var invoiceType = items[0].invoiceType;
+                            var clubTaxPoint = items[0].clubTaxPoint;
+                            var shopTaxPoint = items[0].shopTaxPoint;
+                            var costType = items[0].costType;
+                            var costPrice = items[0].costPrice;
+                            var costProportional = items[0].costProportional;
+                            $("#mainImage").attr("src", mainImage);
+                            $("#shopName").text(shopName);
+                            $("#productId").val(productId);
+                            $("#name").text(name);
+                            $("#price").val(price);
+                            if (includedTax == 1) {
+                                $('#includedTax1').attr('checked', true);
+                            } else {
+                                $('#includedTax0').attr('checked', true);
+                            }
+                            if (invoiceType == 1) {
+                                $('#invoiceType1').attr('checked', true);
+                            } else if (invoiceType == 2) {
+                                $('#invoiceType2').attr('checked', true);
+                            } else {
+                                $('#invoiceType3').attr('checked', true);
+                            }
+                            $("#clubTaxPoint").val(clubTaxPoint);
+                            $("#shopTaxPoint").val(shopTaxPoint);
+                            if (costType == 1) {
+                                $('#costType').text('固定成本');
+                            } else {
+                                $('#costType').text('比例成本');
+                            }
+                            $("#costPrice").text(costPrice);
+                            $("#costProportional").text(costProportional + '%');
+                            chageIncludedTax();
+                            // changeCostPriceShow(costType);
+                            showTaxPoint();
+                        } else {
+                            top.$.jBox.tip("请先勾选商品...");
+                            return false;
+                        }
+                    }
+                    return true;
+                }
+            });
+        }
+
+        //是否含税显示
+        function chageIncludedTax() {
+            var includedTax = $("input[name='includedTax']:checked").val();
+            if (includedTax == 1) {
+                $('#invoiceTypeShow').hide();
+                var invoiceType = $("input[name='invoiceType']:checked").val();
+                if (invoiceType == 3) {
+                    $('#invoiceType1').attr('checked', true);
+                    showTaxPoint();
+                }
+            } else {
+                $('#invoiceTypeShow').show();
+            }
+        }
+
+        // 是否固定成本
+        // function changeCostPriceShow(costType) {
+        //     if (costType == 1) {
+        //         $("#costPriceShow").show();
+        //         $("#costProportionalShow").hide();
+        //     } else {
+        //         $("#costPriceShow").hide();
+        //         $("#costProportionalShow").show();
+        //     }
+        // }
+
+        //税率显示
+        function showTaxPoint() {
+            var invoiceType = $("input[name='invoiceType']:checked").val();
+            if (invoiceType == 3) {
+                $('.taxPointShow').hide();
+            } else {
+                $('.taxPointShow').show();
+            }
+        }
+
+        //删除商品
+        function deleteProduct() {
+            $('#contentTable').hide();
+            $('#productInfo').hide();
+            $('#addProduct').show();
+            $('#productId').val('');
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+        /**
+         * @param obj
+         * jquery检验售价
+         */
+        function checkPrice(obj) {
+            if (obj.value == '0') {
+                obj.value = '';
+            }
+        }
+
+        $(window).load(function () {
+            loadInitType();
+        });
+
+        // 网站分类
+        var currentBigtype = ${empty cmHeheProduct.bigTypeId?0:cmHeheProduct.bigTypeId};
+        var currentSmalltype = ${empty cmHeheProduct.smallTypeId?0:cmHeheProduct.smallTypeId};
+        var bigTypeList = [
+            <c:forEach items="${classify.bigTypeList}" var="bigType" varStatus="index">
+            <c:if test="${index.index > 0}">, </c:if>
+            {
+                bigTypeId: ${bigType.bigTypeID},
+                name: "${bigType.name}",
+                typeSort: ${bigType.typeSort}
+            }
+            </c:forEach>
+        ];
+        var smalltypeList = [
+            <c:forEach items="${classify.smalltypeList}" var="smalltype" varStatus="index">
+            <c:if test="${index.index > 0}">, </c:if>
+            {
+                smallTypeId: ${smalltype.smallTypeID},
+                name: "${smalltype.name}",
+                bigTypeId: ${smalltype.bigTypeID},
+            }
+            </c:forEach>
+        ];
+
+
+        // 初始分类
+        function loadInitType() {
+            if (currentBigtype != null && typeof (currentBigtype) != "undefined") {
+                setTimeout(function () {
+                    loadBigType();
+                }, 0);
+            }
+        }
+
+        // 分类联动
+        function loadBigType() {
+            $("#bigType").html("");
+            $("#bigType").prev().find(".select2-chosen").text("请选择");
+            $("#bigType").append("<option value=''>请选择</option>");
+            $("#smallType").html("");
+            $("#smallType").prev().find(".select2-chosen").text("请选择");
+            $("#smallType").append("<option value=''>请选择</option>");
+            $("#tinyType").html("");
+            $("#tinyType").prev().find(".select2-chosen").text("请选择");
+            $("#tinyType").append("<option value=''>请选择</option>");
+            for (var i = 0; i < bigTypeList.length; i++) {
+                if (currentBigtype != null && typeof (currentBigtype) != "undefined" && currentBigtype == bigTypeList[i].bigTypeId) {
+                    $("#bigType").append("<option selected value='" + bigTypeList[i].bigTypeId + "'>" + bigTypeList[i].name + "</option>");
+                    $("#bigType").prev().find(".select2-chosen").text(bigTypeList[i].name);
+                    setTimeout(function () {
+                        loadSmallType();
+                    }, 500);
+                } else {
+                    $("#bigType").append("<option value='" + bigTypeList[i].bigTypeId + "'>" + bigTypeList[i].name + "</option>");
+                }
+            }
+            loadSmallType();
+        }
+
+        function loadSmallType(id) {
+            if (id) {
+                $("#bigType").val(id);
+                $("#bigType").prev().find(".select2-chosen").text($("#bigType option:selected").text());
+            }
+            var bigType = $("#bigType").val();
+            $("#smallType").html("");
+            $("#smallType").prev().find(".select2-chosen").text("请选择");
+            $("#smallType").append("<option value=''>请选择</option>");
+            $("#tinyType").html("");
+            $("#tinyType").prev().find(".select2-chosen").text("请选择");
+            $("#tinyType").append("<option value=''>请选择</option>");
+            if (typeof (bigType) != "undefined" && bigType != "") {
+                var smallTypeNum = 0;
+                for (var i = 0; i < smalltypeList.length; i++) {
+                    if (bigType == smalltypeList[i].bigTypeId) {
+                        smallTypeNum = smallTypeNum + 1;
+                        if (currentSmalltype != null && typeof (currentSmalltype) != "undefined" && currentSmalltype == smalltypeList[i].smallTypeId) {
+                            $("#smallType").append("<option selected value='" + smalltypeList[i].smallTypeId + "'>" + smalltypeList[i].name + "</option>");
+                            $("#smallType").prev().find(".select2-chosen").text(smalltypeList[i].name);
+                        } else {
+                            $("#smallType").append("<option value='" + smalltypeList[i].smallTypeId + "'>" + smalltypeList[i].name + "</option>");
+                        }
+                    }
+                }
+                document.getElementById("s2id_smallType").style.cssText = "display: inline-block";
+            }
+        }
+    </script>
 </body>
 </html>

+ 11 - 4
src/main/webapp/WEB-INF/views/modules/hehe/heheAddProduct.jsp

@@ -16,7 +16,7 @@
                 submitHandler: function (form) {
                     var isSubMitFlag = true;
                     var productID = $("#productID").val();
-                    if (isNaN(productID) || productID.indexOf('0') == 0 ) {
+                    if (isNaN(productID) || productID.indexOf('0') == 0) {
                         alertx("请输入正确的商品ID");
                         isSubMitFlag = false;
                         return false;
@@ -36,12 +36,13 @@
     <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
     <div class="ul-form">
         <label>商品ID:</label>
-        <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini" onkeyup="onlynum(this)"/>
+        <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini"
+                    onkeyup="onlynum(this)"/>
         <label>商品名称:</label>
         <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
         <label>供应商名称:</label>
         <form:input path="shopName" htmlEscape="false" class="input-medium" maxlength="20"/>
-        &nbsp;&nbsp;  <input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
+        &nbsp;&nbsp; <input id="btnSubmit" class="btn btn-primary" type="submit" value="搜索"/>
         <div class="clearfix"></div>
     </div>
 </form:form>
@@ -56,7 +57,7 @@
     </tr>
     <tbody>
     <c:if test="${not empty page.list}">
-        <c:forEach items="${page.list}" var="item">
+        <c:forEach items="${page.list}" var="item" varStatus="index">
             <tr id="${item.productID}" class="itemtr">
                 <th>
                     <input class="check-item" type="radio" name="info" value='${item.productID}'/>
@@ -66,6 +67,7 @@
                 <td class="name">${item.name}</td>
                 <td id="shopName">${item.shopName}</td>
                 <input type="hidden" value="${item.price}" id="price">
+                <input type="hidden" value="${index.index}" id="index">
                 <input type="hidden" value="${item.includedTax}" id="includedTax">
                 <input type="hidden" value="${item.invoiceType}" id="invoiceType">
                 <input type="hidden" value="${item.taxPoint}" id="clubTaxPoint">
@@ -100,8 +102,13 @@
         var items = new Array();
         var $items = $('.check-item:checked');
         $items.each(function () {
+            var c={};
+            c= ${productList};
+            var index= $(this).parents(".itemtr").find("#index").val();
+            var s=c[index].skuList;
             items.push({
                 productId: $(this).val(),
+                skuList: s,
                 mainImage: $(this).parents(".itemtr").find(".mainImage").attr("src"),
                 name: $(this).parents(".itemtr").find(".name").text(),
                 shopName: $(this).parents(".itemtr").find("#shopName").text(),

+ 190 - 150
src/main/webapp/WEB-INF/views/modules/hehe/heheDiscountActivityProductForm.jsp

@@ -1,162 +1,202 @@
 <%@ 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"/>
-	<script type="text/javascript">
-		$(document).ready(function() {
-			//$("#name").focus();
-			$("#inputForm").validate({
-				submitHandler: function(form){
-					var productId = $("#productId").val();
-					if (productId === '') {
-						alertx("请选择商品");
-						return false;
-					}
-					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"/>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    var productId = $("#productId").val();
+                    if (productId === '') {
+                        alertx("请选择商品");
+                        return false;
+                    }
+                    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}/hehe/heheDiscountActivityProduct/?activityId=${heheDiscountActivityProduct.activityId}">商品列表</a></li>
-		<li class="active"><a href="${ctx}/hehe/heheDiscountActivityProduct/form?id=${heheDiscountActivityProduct.id}&activityId=${heheDiscountActivityProduct.activityId}">商品${not empty heheDiscountActivityProduct.id?'编辑':'添加'}</a></li>
-	</ul><br/>
-	<form:form id="inputForm" modelAttribute="heheDiscountActivityProduct" action="${ctx}/hehe/heheDiscountActivityProduct/save" method="post" class="form-horizontal">
-		<form:hidden path="id"/>
-		<form:hidden path="activityId"/>
-		<form:hidden path="productId"/>
-		<sys:message content="${message}"/>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>商品:</label>
-			<div class="controls" id="addProduct">
-				<a href="JavaScript:;" onclick="showSelect()">请选择加入呵呵商城的商品</a>
-			</div>
-			<table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
-				<thead>
-				<tr>
-					<th>图片</th>
-					<th>商品名称</th>
-					<th>供应商</th>
-					<th>操作</th>
-				</tr>
-				</thead>
-				<tbody>
-				<tr>
-					<td><img id="mainImage" src="${heheDiscountActivityProduct.mainImage}" width="50px" height="50px"></td>
-					<td style="text-align: center" id="name">${heheDiscountActivityProduct.name}</td>
-					<td id="shopName">${heheDiscountActivityProduct.shopName}</td>
-					<td><a href="javascript:void(0);" onclick="deleteProduct()">删除</a></td>
-				</tr>
-				</tbody>
-			</table>
-		</div>
-		<div id="productInfo" hidden="hidden">
-			<div class="control-group">
-				<label class="control-label"><font color="red">*</font>限时特价:</label>
-				<div class="controls">
-					<input type="number" style="width:100px;" min="0" id="discountPrice" name="discountPrice" value="${heheDiscountActivityProduct.discountPrice}" required onblur="checkPrice(this)">
-				</div>
-			</div>
-		</div>
-		<div class="control-group">
-			<label class="control-label"><font color="red">*</font>商品状态:</label>
-			<div class="controls">
-				<form:select path="status" class="input-small required">
-					<form:option value="1" label="已上架"/>
-					<form:option value="0" label="已下架"/>
-				</form:select>
-			</div>
-		</div>
-		<div class="form-actions">
-			<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
-			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
-		</div>
-	</form:form>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/hehe/heheDiscountActivityProduct/?activityId=${heheDiscountActivityProduct.activityId}">商品列表</a>
+    </li>
+    <li class="active"><a
+            href="${ctx}/hehe/heheDiscountActivityProduct/form?id=${heheDiscountActivityProduct.id}&activityId=${heheDiscountActivityProduct.activityId}">商品${not empty heheDiscountActivityProduct.id?'编辑':'添加'}</a>
+    </li>
+</ul>
+<br/>
+<form:form id="inputForm" modelAttribute="heheDiscountActivityProduct"
+           action="${ctx}/hehe/heheDiscountActivityProduct/save" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <form:hidden path="activityId"/>
+    <form:hidden path="productId"/>
+    <sys:message content="${message}"/>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品:</label>
+        <div class="controls" id="addProduct">
+            <a href="JavaScript:;" onclick="showSelect()">请选择加入呵呵商城的商品</a>
+        </div>
+        <table id="contentTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+            <thead>
+            <tr>
+                <th>图片</th>
+                <th>商品名称</th>
+                <th>供应商</th>
+                <th>操作</th>
+            </tr>
+            </thead>
+            <tbody>
+            <tr>
+                <td><img id="mainImage" src="${heheDiscountActivityProduct.mainImage}" width="50px" height="50px"></td>
+                <td style="text-align: center" id="name">${heheDiscountActivityProduct.name}</td>
+                <td id="shopName">${heheDiscountActivityProduct.shopName}</td>
+                <td><a href="javascript:void(0);" onclick="deleteProduct()">删除</a></td>
+            </tr>
+            </tbody>
+        </table>
+    </div>
+    <div id="productInfo" hidden="hidden">
+        <c:forEach items="${heheDiscountActivityProduct.skus}" var="sku" varStatus="index">
+            <div class="control-group" style="display:flex">
+                <input type="hidden" value="${sku.skuId}" name="sku[${index.index}].skuId">
+                <label class="control-label"><font color="red">*</font>规格:规格${index.index+1}</label>
+                <label class="control-label"><font color="red">*</font>售价:</label>
+                <input type="number" style="width:100px;" disabled="true" min="0" id="price"
+                       name="sku[${index.index}].price"
+                       value="${sku.price}">
+                <label class="control-label"><font color="red">*</font>限时特价:</label>
+                <input type="number" style="width:100px;" min="0" id="discountPrice"
+                       name="sku[${index.index}].discountPrice"
+                       value="${sku.discountPrice}" required onblur="checkPrice(this)">
+            </div>
+        </c:forEach>
+    </div>
+    <div class="control-group">
+        <label class="control-label"><font color="red">*</font>商品状态:</label>
+        <div class="controls">
+            <form:select path="status" class="input-small required">
+                <form:option value="1" label="已上架"/>
+                <form:option value="0" label="已下架"/>
+            </form:select>
+        </div>
+    </div>
+    <div class="form-actions">
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
+        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+    </div>
+</form:form>
 <script>
-	$(function () {
-		//初始化商品信息
-		if (${not empty heheDiscountActivityProduct.id}){
-			$('#contentTable').show();
-			$('#productInfo').show();
-			$('#addProduct').hide();
-		}
-	});
+    $(function () {
+        //初始化商品信息
+        if (${not empty heheDiscountActivityProduct.id}) {
+            $('#contentTable').show();
+            $('#productInfo').show();
+            $('#addProduct').hide();
+        }
+    });
 
-	//选择添加商品
-	function showSelect() {
-		var url = '';
-		var title = '';
-		url = "${ctx}/hehe/heheDiscountActivityProduct/findProductPage";
-		title = "选择商品";
-		top.$.jBox("iframe:" + url, {
-			iframeScrolling: 'yes',
-			width: $(top.document).width() - 600,
-			height: $(top.document).height() - 160,
-			persistent: true,
-			title: title,
-			buttons: {"确定": '1', "关闭": '-1'},
-			submit: function (v, h, f) {
-				//确定
-				var $jboxFrame = top.$('#jbox-iframe');
-				var $mainFrame = top.$('#mainFrame');
-				if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
-					var items = $jboxFrame[0].contentWindow.getCheckedItems(0);
-					if (items.length > 0) {
-						console.log(items);
-						$('#contentTable').show();
-						$('#productInfo').show();
-						$('#addProduct').hide();
-						var productId = items[0].productId;
-						var mainImage = items[0].mainImage;
-						var name = items[0].name;
-						var shopName = items[0].shopName;
-						var price = items[0].price;
-						$("#mainImage").attr("src", mainImage);
-						$("#shopName").text(shopName);
-						$("#productId").val(productId);
-						$("#name").text(name);
-						$("#discountPrice").val(price);
-					} else {
-						top.$.jBox.tip("请先勾选商品...");
-						return false;
-					}
-				}
-				return true;
-			}
-		});
-	}
+    //选择添加商品
+    function showSelect() {
+        var url = '';
+        var title = '';
+        url = "${ctx}/hehe/heheDiscountActivityProduct/findProductPage";
+        title = "选择商品";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: $(top.document).width() - 600,
+            height: $(top.document).height() - 160,
+            persistent: true,
+            title: title,
+            buttons: {"确定": '1', "关闭": '-1'},
+            submit: function (v, h, f) {
+                //确定
+                var $jboxFrame = top.$('#jbox-iframe');
+                var $mainFrame = top.$('#mainFrame');
+                if ('1' == v && 1 == $jboxFrame.size() && 1 == $mainFrame.size()) {
+                    var items = $jboxFrame[0].contentWindow.getCheckedItems(0);
+                    if (items.length > 0) {
+                        console.log(items);
+                        $('#contentTable').show();
+                        $('#productInfo').show();
+                        $('#addProduct').hide();
+                        var productId = items[0].productId;
+                        var mainImage = items[0].mainImage;
+                        var name = items[0].name;
+                        var shopName = items[0].shopName;
+                        var price = items[0].price;
+                        $("#mainImage").attr("src", mainImage);
+                        $("#shopName").text(shopName);
+                        $("#productId").val(productId);
+                        $("#name").text(name);
+                        $("#discountPrice").val(price);
+                        getSkus(productId);
 
-	//删除商品
-	function deleteProduct() {
-		$('#contentTable').hide();
-		$('#productInfo').hide();
-		$('#addProduct').show();
-		$('#productId').val('');
-	}
+                    } else {
+                        top.$.jBox.tip("请先勾选商品...");
+                        return false;
+                    }
+                }
+                return true;
+            }
+        });
+    }
 
-	/**
-	 * @param obj
-	 * jquery检验售价
-	 */
-	function checkPrice(obj) {
-		if (obj.value == '0') {
-			obj.value = '';
-		}
-	}
+    function getSkus(productId){
+        //渲染限时特价sku
+        $.ajax({
+            url: "${ctx}/hehe/heheDiscountActivityProduct/getSku?productId=" + productId,
+            type: "GET",
+            dataType: "json",
+            data: "",
+            success: function (res) {
+                console.log(res);
+                var html = '';
+                for (let i = 0; i < res.length; i++) {
+                    console.log(res[i])
+                    html += '<div class="control-group"  style="display:flex">';
+                    html += "<input type='hidden' value='" + res[i].skuId + "' name='sku['" + i + "'].skuId'>";
+                    html += '<label class="control-label"><font color="red">*</font>规格:规格' + (i + 1) + '</label>';
+                    html += '<label class="control-label"><font color="red">*</font>售价:</label>';
+                    html += "<input name='skus[" + (i) + "].price' value='" + res[i].price + "' disabled='true' type='number' style='width: 90px' class='input-xlarge number'/>";
+                    html += '<label class="control-label"><font color="red">*</font>限时特价:</label>';
+                    html += "<input name='skus[" + (i) + "].discountPrice' value='" + res[i].discountPrice + "' style='width: 90px;' type='number' class='input-xlarge number required'/>";
+                    html += '</div>';
+                }
+                $("#productInfo").html(html);
+            }
+        });
+    }
+    //删除商品
+    function deleteProduct() {
+        $('#contentTable').hide();
+        $('#productInfo').hide();
+        $('#addProduct').show();
+        $('#productId').val('');
+    }
+
+    /**
+     * @param obj
+     * jquery检验售价
+     */
+    function checkPrice(obj) {
+        if (obj.value == '0') {
+            obj.value = '';
+        }
+    }
 </script>
 </body>
 </html>

+ 487 - 138
src/main/webapp/WEB-INF/views/modules/hehe/heheNewOrderDetail.jsp

@@ -6,69 +6,377 @@
     <meta name="decorator" content="default"/>
     <%--<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>--%>
     <style type="text/css">
-        *{margin:0;padding:0}
-        a{list-style:none;text-decoration:none}
-        body{background-color:rgb(255,255,255)}
-        h3{line-height:20px;padding:20px 0 20px 15px;border-bottom:1px solid #CCCCCC}
-        .now-status p{padding:20px}
-        .now-status span{display:inline-block;width:160px;line-height:35px;margin-right:15px;cursor:pointer;border:1px solid #CCCCCC;text-align:center;border-radius:5px}
-        .buyInfo p{padding:15px 5px 0}
-        .buyInfo p label{width:60px;display:inline-block}
-        .buyInfo p span{padding-left:10px}
-        .table th{background-color:#CCCCCC}
-        .table th,.table td{font-weight:normal;border:1px solid #CCCCCC;height:35px;text-align:center}
-        .table td .div-img{box-sizing:border-box}
-        .table td .div-img img{width:100px;height:100px;vertical-align:middle}
-        .table td .div-img span{}
-        .div-order span{width:260px;display:inline-block;margin-right:50px}
-        .text-result p{padding-top:15px}
-        .text-cost p{padding:20px 0}
-        .moeny-cost p{padding:10px 0 0 0;text-align:left}
-        .moeny-cost p label{display:inline-block}
-        .Staging table{width:100%;border-collapse:collapse;margin-top:20px}
-        .Staging table th,.Staging table td{font-weight:normal;border:1px solid #000;height:35px;text-align:center;width:10%}
-        .change-info{position:fixed;top:0%;left:50%;transform:translateX(-50%);z-index:999;width:800px;background-color:#fff;box-shadow:0px 0px 15px #ccc}
-        .item-div label{width:260px;text-align:right;display:inline-block;margin-right:50px}
-        .item-div input{width:300px;line-height:35px;height:35px;box-sizing:border-box;border:1px solid #CCCCCC;display:inline-block}
-        .item-div select{width:90px;height:35px;margin-right:10px}
-        .item-div textarea{border:1px solid #CCCCCC;margin-top:20px;width:300px;height:80px;resize:none;display:block}
-        .layer-status span{display:inline-block;width:80px;line-height:35px;background-color:#00A6C7;text-align:center;color:#fff;cursor:pointer}
-        .layer-status span:nth-of-type(1){}
-        .layer-status span:nth-of-type(2){margin-left:72px}
-        .same-style{position:fixed;top:20%;left:50%;transform:translateX(-50%);width:500px;background-color:#fff;z-index:999;box-shadow:0 0 15px #666}
-        .reason-cancel label{margin-right:20px}
-        .reason-cancel textarea{width:270px;height:80px;resize:none;vertical-align:text-top;border:1px solid #CCCCCC}
-        .order-details-heading{background:#eee}
-        .order-details-heading td{white-space:nowrap;padding:0 10px}
-        .order-rows,.order-details-heading{width:100%;border-bottom:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;color:#666;padding:10px;line-height:30px}
-        .order-details-heading{border-top:1px solid #ccc}
-        .order-details-heading span,.order-rows span{margin-right:80px}
-        .order-details-heading span{width:230px;margin-right:0px;display:inline-block}
-        .order-details-heading span label,.order-rows span label{font-weight:bold}
-        .order-rows .supplier-img{width:100px}
-        .operation-wrapper{position:relative}
-        .operation-btn{cursor:pointer}
-        .operation-block{background:#fff;width:125px;position:absolute;left:35px;top:30px;padding:10px;border:1px solid #666;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px;z-index:999;display:none}
-        .operation-block a{display:block;padding:3px 0}
-        .print-wrapper{display:inline-block}
-        .supplier-product-name,.supplier-product-alias{width:200px;line-height:20px}
-        .supplier-product-info{width:50%;display:inline-block;position:relative;top:50%;transform:translateY(30%)}
-        .supplier-product-promotionInfo{width:20%;display:inline-block;position:relative;top:50%;transform:translateY(30%)}
-        .supplier-product-item{margin-bottom:10px}
-        .supplier-product-alias{display:inline-block;margin-top:5px}
-        .supplier-name{display:inline-block;vertical-align:middle;margin:0 10px}
-        #auditBox{padding:20px;line-height:30px}
-        #auditBox p{font-size:16px;margin:0 0 0 0}
-        #auditBox .note-div{font-size:16px}
-        .downSpan{display:block;margin-left:5px;margin-bottom:-8px}
-        .upSpan{display:block;margin-left:5px;margin-top:-8px}
-        .promotionsName{margin:2px}
-        .ladderPrice>span{text-decoration:underline;color:red}
-        .ladderPrice .list{display:none;position:absolute;z-index:999;background:#FFF;white-space:nowrap;border:1px solid #EEE;padding:10px 0;color:#333}
-        .ladderPrice:hover .list{display:block}
-        .ladderPrice .list span{margin:0 20px;width:60px;text-align:center;display:inline-block}
-        .ladderPrice .list span.price{color:red}
-        .weishaIcon {background:darkorange;color:white;margin:0 0px;padding:0 3px;font-style:normal;font-size: 12px; display:inline-block;border-radius:2px}
+        * {
+            margin: 0;
+            padding: 0
+        }
+
+        a {
+            list-style: none;
+            text-decoration: none
+        }
+
+        body {
+            background-color: rgb(255, 255, 255)
+        }
+
+        h3 {
+            line-height: 20px;
+            padding: 20px 0 20px 15px;
+            border-bottom: 1px solid #CCCCCC
+        }
+
+        .now-status p {
+            padding: 20px
+        }
+
+        .now-status span {
+            display: inline-block;
+            width: 160px;
+            line-height: 35px;
+            margin-right: 15px;
+            cursor: pointer;
+            border: 1px solid #CCCCCC;
+            text-align: center;
+            border-radius: 5px
+        }
+
+        .buyInfo p {
+            padding: 15px 5px 0
+        }
+
+        .buyInfo p label {
+            width: 60px;
+            display: inline-block
+        }
+
+        .buyInfo p span {
+            padding-left: 10px
+        }
+
+        .table th {
+            background-color: #CCCCCC
+        }
+
+        .table th, .table td {
+            font-weight: normal;
+            border: 1px solid #CCCCCC;
+            height: 35px;
+            text-align: center
+        }
+
+        .table td .div-img {
+            box-sizing: border-box
+        }
+
+        .table td .div-img img {
+            width: 100px;
+            height: 100px;
+            vertical-align: middle
+        }
+
+        .table td .div-img span {
+        }
+
+        .div-order span {
+            width: 260px;
+            display: inline-block;
+            margin-right: 50px
+        }
+
+        .text-result p {
+            padding-top: 15px
+        }
+
+        .text-cost p {
+            padding: 20px 0
+        }
+
+        .moeny-cost p {
+            padding: 10px 0 0 0;
+            text-align: left
+        }
+
+        .moeny-cost p label {
+            display: inline-block
+        }
+
+        .Staging table {
+            width: 100%;
+            border-collapse: collapse;
+            margin-top: 20px
+        }
+
+        .Staging table th, .Staging table td {
+            font-weight: normal;
+            border: 1px solid #000;
+            height: 35px;
+            text-align: center;
+            width: 10%
+        }
+
+        .change-info {
+            position: fixed;
+            top: 0%;
+            left: 50%;
+            transform: translateX(-50%);
+            z-index: 999;
+            width: 800px;
+            background-color: #fff;
+            box-shadow: 0px 0px 15px #ccc
+        }
+
+        .item-div label {
+            width: 260px;
+            text-align: right;
+            display: inline-block;
+            margin-right: 50px
+        }
+
+        .item-div input {
+            width: 300px;
+            line-height: 35px;
+            height: 35px;
+            box-sizing: border-box;
+            border: 1px solid #CCCCCC;
+            display: inline-block
+        }
+
+        .item-div select {
+            width: 90px;
+            height: 35px;
+            margin-right: 10px
+        }
+
+        .item-div textarea {
+            border: 1px solid #CCCCCC;
+            margin-top: 20px;
+            width: 300px;
+            height: 80px;
+            resize: none;
+            display: block
+        }
+
+        .layer-status span {
+            display: inline-block;
+            width: 80px;
+            line-height: 35px;
+            background-color: #00A6C7;
+            text-align: center;
+            color: #fff;
+            cursor: pointer
+        }
+
+        .layer-status span:nth-of-type(1) {
+        }
+
+        .layer-status span:nth-of-type(2) {
+            margin-left: 72px
+        }
+
+        .same-style {
+            position: fixed;
+            top: 20%;
+            left: 50%;
+            transform: translateX(-50%);
+            width: 500px;
+            background-color: #fff;
+            z-index: 999;
+            box-shadow: 0 0 15px #666
+        }
+
+        .reason-cancel label {
+            margin-right: 20px
+        }
+
+        .reason-cancel textarea {
+            width: 270px;
+            height: 80px;
+            resize: none;
+            vertical-align: text-top;
+            border: 1px solid #CCCCCC
+        }
+
+        .order-details-heading {
+            background: #eee
+        }
+
+        .order-details-heading td {
+            white-space: nowrap;
+            padding: 0 10px
+        }
+
+        .order-rows, .order-details-heading {
+            width: 100%;
+            border-bottom: 1px solid #ccc;
+            border-left: 1px solid #ccc;
+            border-right: 1px solid #ccc;
+            color: #666;
+            padding: 10px;
+            line-height: 30px
+        }
+
+        .order-details-heading {
+            border-top: 1px solid #ccc
+        }
+
+        .order-details-heading span, .order-rows span {
+            margin-right: 80px
+        }
+
+        .order-details-heading span {
+            width: 230px;
+            margin-right: 0px;
+            display: inline-block
+        }
+
+        .order-details-heading span label, .order-rows span label {
+            font-weight: bold
+        }
+
+        .order-rows .supplier-img {
+            width: 100px
+        }
+
+        .operation-wrapper {
+            position: relative
+        }
+
+        .operation-btn {
+            cursor: pointer
+        }
+
+        .operation-block {
+            background: #fff;
+            width: 125px;
+            position: absolute;
+            left: 35px;
+            top: 30px;
+            padding: 10px;
+            border: 1px solid #666;
+            -webkit-border-radius: 5px;
+            -moz-border-radius: 5px;
+            border-radius: 5px;
+            z-index: 999;
+            display: none
+        }
+
+        .operation-block a {
+            display: block;
+            padding: 3px 0
+        }
+
+        .print-wrapper {
+            display: inline-block
+        }
+
+        .supplier-product-name, .supplier-product-alias {
+            width: 200px;
+            line-height: 20px
+        }
+
+        .supplier-product-info {
+            width: 50%;
+            display: inline-block;
+            position: relative;
+            top: 50%;
+            transform: translateY(30%)
+        }
+
+        .supplier-product-promotionInfo {
+            width: 20%;
+            display: inline-block;
+            position: relative;
+            top: 50%;
+            transform: translateY(30%)
+        }
+
+        .supplier-product-item {
+            margin-bottom: 10px
+        }
+
+        .supplier-product-alias {
+            display: inline-block;
+            margin-top: 5px
+        }
+
+        .supplier-name {
+            display: inline-block;
+            vertical-align: middle;
+            margin: 0 10px
+        }
+
+        #auditBox {
+            padding: 20px;
+            line-height: 30px
+        }
+
+        #auditBox p {
+            font-size: 16px;
+            margin: 0 0 0 0
+        }
+
+        #auditBox .note-div {
+            font-size: 16px
+        }
+
+        .downSpan {
+            display: block;
+            margin-left: 5px;
+            margin-bottom: -8px
+        }
+
+        .upSpan {
+            display: block;
+            margin-left: 5px;
+            margin-top: -8px
+        }
+
+        .promotionsName {
+            margin: 2px
+        }
+
+        .ladderPrice > span {
+            text-decoration: underline;
+            color: red
+        }
+
+        .ladderPrice .list {
+            display: none;
+            position: absolute;
+            z-index: 999;
+            background: #FFF;
+            white-space: nowrap;
+            border: 1px solid #EEE;
+            padding: 10px 0;
+            color: #333
+        }
+
+        .ladderPrice:hover .list {
+            display: block
+        }
+
+        .ladderPrice .list span {
+            margin: 0 20px;
+            width: 60px;
+            text-align: center;
+            display: inline-block
+        }
+
+        .ladderPrice .list span.price {
+            color: red
+        }
+
+        .weishaIcon {
+            background: darkorange;
+            color: white;
+            margin: 0 0px;
+            padding: 0 3px;
+            font-style: normal;
+            font-size: 12px;
+            display: inline-block;
+            border-radius: 2px
+        }
     </style>
     <script type="text/javascript" src="${ctxStatic}/QRCode/jquery.qrcode.min.js"></script>
     <script type="text/javascript" src="static/common/clipboard.min.js"></script>
@@ -114,38 +422,44 @@
                 <c:if test="${order.receiptStatus == 3}">
                     <font color="green">已收款</font>
                 </c:if>
-                <%--抹平明细--%>
-                    <c:if test="${order.confirmType eq 1}">
-                        <c:if test="${order.receiptOrderFlag}">
-                            <font color="red">(一款多单:少收抹平金额未知)</font>
-                        </c:if>
-                        <c:if test="${!order.receiptOrderFlag}">
-                            <font color="red">(少收抹平:
-                                ¥<fmt:formatNumber value="${order.payableAmount - (empty order.orderReceivedAmount ? 0 : order.orderReceivedAmount)}" pattern="#0.00"/>)
-                            </font>
-                        </c:if>
+                    <%--抹平明细--%>
+                <c:if test="${order.confirmType eq 1}">
+                    <c:if test="${order.receiptOrderFlag}">
+                        <font color="red">(一款多单:少收抹平金额未知)</font>
                     </c:if>
-                    <c:if test="${order.confirmType eq 2}">
-                        <c:if test="${order.receiptOrderFlag}">
-                            <font color="red">(一款多单:多收抹平金额未知)</font>
-                        </c:if>
-                        <c:if test="${!order.receiptOrderFlag}">
-                            <font color="red">(多收抹平:
-                                ¥<fmt:formatNumber value="${(empty order.orderReceivedAmount ? 0 : order.orderReceivedAmount) - order.payableAmount}" pattern="#0.00"/>)
-                            </font>
-                        </c:if>
+                    <c:if test="${!order.receiptOrderFlag}">
+                        <font color="red">(少收抹平:
+                            ¥<fmt:formatNumber
+                                    value="${order.payableAmount - (empty order.orderReceivedAmount ? 0 : order.orderReceivedAmount)}"
+                                    pattern="#0.00"/>)
+                        </font>
                     </c:if>
-                    <c:if test="${order.confirmType eq 3}">
-                        <c:if test="${order.receiptOrderFlag}">
-                             <font color="red">(一款多单:多收退余额)</font>
-                        </c:if>
-                        <c:if test="${!order.receiptOrderFlag}">
-                            <font color="red">(多收退余额&nbsp;&nbsp;${order.associationType eq 2 ? "(自动)" : ""}:
-                                ¥<fmt:formatNumber value="${(empty order.returnBalanceAmount ? 0 : order.returnBalanceAmount)}" pattern="#0.00"/>)
-                            </font>
-                        </c:if>
+                </c:if>
+                <c:if test="${order.confirmType eq 2}">
+                    <c:if test="${order.receiptOrderFlag}">
+                        <font color="red">(一款多单:多收抹平金额未知)</font>
+                    </c:if>
+                    <c:if test="${!order.receiptOrderFlag}">
+                        <font color="red">(多收抹平:
+                            ¥<fmt:formatNumber
+                                    value="${(empty order.orderReceivedAmount ? 0 : order.orderReceivedAmount) - order.payableAmount}"
+                                    pattern="#0.00"/>)
+                        </font>
                     </c:if>
-                </td>
+                </c:if>
+                <c:if test="${order.confirmType eq 3}">
+                    <c:if test="${order.receiptOrderFlag}">
+                        <font color="red">(一款多单:多收退余额)</font>
+                    </c:if>
+                    <c:if test="${!order.receiptOrderFlag}">
+                        <font color="red">(多收退余额&nbsp;&nbsp;${order.associationType eq 2 ? "(自动)" : ""}:
+                            ¥<fmt:formatNumber
+                                    value="${(empty order.returnBalanceAmount ? 0 : order.returnBalanceAmount)}"
+                                    pattern="#0.00"/>)
+                        </font>
+                    </c:if>
+                </c:if>
+            </td>
             <td>发货状态:
                 <c:if test="${order.sendOutStatus == 1}">
                     <font color="red">待发货</font>
@@ -213,12 +527,13 @@
             应收金额:<fmt:formatNumber value="${order.payableAmount}" type="currency"/>
             <span style="color: red">
                 <c:if test="${order.balancePayFee gt 0}">
-                    <a href="${ctx}/user/cmUserBalanceRecord/userBalanceRecord?userId=${order.userID}" style="color: red;text-decoration: underline">
+                    <a href="${ctx}/user/cmUserBalanceRecord/userBalanceRecord?userId=${order.userID}"
+                       style="color: red;text-decoration: underline">
                         (账户余额抵扣: <fmt:formatNumber value="${order.balancePayFee}" type="currency"/>)
                     </a>
                 </c:if>
                 <c:if test="${order.balancePayFee le 0}">
-                        (账户余额抵扣: <fmt:formatNumber value="${order.balancePayFee}" type="currency"/>)
+                    (账户余额抵扣: <fmt:formatNumber value="${order.balancePayFee}" type="currency"/>)
                 </c:if>
 
 
@@ -508,25 +823,32 @@
         <span><label>供应商:</label>${shopOrder.shopName}</span>
         <c:if test="${shopOrder.shopPromotion ne null && shopOrder.shopPromotion.type eq 3}">
             <c:if test="${shopOrder.shopPromotion.mode eq 2}">
-                <span><label style="background-color: #F60;color: white">${shopOrder.shopPromotion.name}</label> 满<fmt:formatNumber value="${shopOrder.shopPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>,减<fmt:formatNumber value="${shopOrder.shopPromotion.reducedPrice}" pattern="#,##0.00" maxFractionDigits="2"/></span>
+                <span><label
+                        style="background-color: #F60;color: white">${shopOrder.shopPromotion.name}</label> 满<fmt:formatNumber
+                        value="${shopOrder.shopPromotion.touchPrice}" pattern="#,##0.00"
+                        maxFractionDigits="2"/>,减<fmt:formatNumber value="${shopOrder.shopPromotion.reducedPrice}"
+                                                                   pattern="#,##0.00" maxFractionDigits="2"/></span>
             </c:if>
             <c:if test="${shopOrder.shopPromotion.mode eq 3}">
-                <span><label style="background-color: purple;color: white">${shopOrder.shopPromotion.name}</label> 满<fmt:formatNumber value="${shopOrder.shopPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>,赠送商品</span>
+                <span><label
+                        style="background-color: purple;color: white">${shopOrder.shopPromotion.name}</label> 满<fmt:formatNumber
+                        value="${shopOrder.shopPromotion.touchPrice}" pattern="#,##0.00"
+                        maxFractionDigits="2"/>,赠送商品</span>
             </c:if>
         </c:if>
         <div>
             <c:forEach items="${shopOrder.newOrderProducts}" var="op">
                 <div class="supplier-product-item">
-                    <%--二手订单详情--%>
+                        <%--二手订单详情--%>
                     <c:if test="${order.secondHandOrderFlag eq 1}">
                         <a href="${fns:getConfig('wwwServer')}product-${op.productID}.html" target="_blank">
-                        <img class="supplier-img" src="${op.image}"/>
+                            <img class="supplier-img" src="${op.image}"/>
                         </a>
                     </c:if>
-                    <%--正常订单详情--%>
+                        <%--正常订单详情--%>
                     <c:if test="${order.secondHandOrderFlag ne 1}">
                         <a href="${fns:getConfig('wwwServer')}product-${op.productID}.html" target="_blank">
-                         <img class="supplier-img" src="${op.image}"/>
+                            <img class="supplier-img" src="${op.image}"/>
                         </a>
                     </c:if>
                     <div class="supplier-name">
@@ -557,39 +879,44 @@
                     </div>
                     <c:if test="${op.productID ne 999}">
                         <div class="supplier-product-info">
+                            <span style="color: red">规格:${op.productUnit}</span>
                             <span>单价:
                                 <c:if test="${op.productPromotion.mode eq 1}">
-                                    <label style="text-decoration: line-through"><fmt:formatNumber value="${op.price}" type="currency"/></label></span>
-                                </c:if>
-                                <c:if test="${op.productPromotion.mode ne 1}">
-                                    <fmt:formatNumber value="${op.price}" type="currency"/>
-                                </c:if>
-                                <c:if test="${op.ladderPriceFlag eq 1 || op.isActProduct eq 1}">
-                                    <a href="javascript:;" class="ladderPrice"><span> (阶梯价格)</span>
-                                        <c:if test="${not empty op.orderProductLadderPriceList}">
-                                            <div class="list">
-                                                <p><span>起订量</span><span>价格</span></p>
-                                                <c:forEach items="${op.orderProductLadderPriceList}" var="ladderPrice">
-                                                    <p data-num="${ladderPrice.buyNum}"><span>${ladderPrice.buyNumRangeShow}</span><span class="price">${ladderPrice.buyPrice}</span></p>
-                                                </c:forEach>
-                                            </div>
-                                        </c:if>
-                                    </a>
-                                </c:if>
-                                <c:if test="${order.collageFlag eq 1}"><font color="red">(拼团价)</font></c:if>
+                                    <label style="text-decoration: line-through"><fmt:formatNumber value="${op.price}"
+                                                                                                   type="currency"/></label></span>
+                            </c:if>
+                            <c:if test="${op.productPromotion.mode ne 1}">
+                                <fmt:formatNumber value="${op.price}" type="currency"/>
+                            </c:if>
+                            <c:if test="${op.ladderPriceFlag eq 1 || op.isActProduct eq 1}">
+                                <a href="javascript:;" class="ladderPrice"><span> (阶梯价格)</span>
+                                    <c:if test="${not empty op.orderProductLadderPriceList}">
+                                        <div class="list">
+                                            <p><span>起订量</span><span>价格</span></p>
+                                            <c:forEach items="${op.orderProductLadderPriceList}" var="ladderPrice">
+                                                <p data-num="${ladderPrice.buyNum}">
+                                                    <span>${ladderPrice.buyNumRangeShow}</span><span
+                                                        class="price">${ladderPrice.buyPrice}</span></p>
+                                            </c:forEach>
+                                        </div>
+                                    </c:if>
+                                </a>
+                            </c:if>
+                            <c:if test="${order.collageFlag eq 1}"><font color="red">(拼团价)</font></c:if>
                             </span>
                             <span>折扣: ${op.discount}%</span>
                             <span>折后单价:
                                 <c:if test="${op.productPromotion.mode eq 1}">
-                                    <label style="text-decoration: line-through"><fmt:formatNumber value="${op.discountPrice}" type="currency"/></label></span>
-                                </c:if>
-                                <c:if test="${op.productPromotion.mode ne 1}">
-                                    <fmt:formatNumber value="${op.discountPrice}" type="currency"/></span>
-                                </c:if>
+                                    <label style="text-decoration: line-through"><fmt:formatNumber
+                                            value="${op.discountPrice}" type="currency"/></label></span>
+                            </c:if>
+                            <c:if test="${op.productPromotion.mode ne 1}">
+                                <fmt:formatNumber value="${op.discountPrice}" type="currency"/></span>
+                            </c:if>
                             <span>数量:  x${op.num}</span>
                             <br>
                             <span>税率:  ${(op.includedTax != '' and op.includedTax eq 0 and op.invoiceType eq 3)?'---': op.taxRate ne null?op.taxRate:0.0}%</span>
-                            <span>税费:  ${(op.includedTax eq 1 or (op.includedTax != '' and op.includedTax eq 0 and op.invoiceType eq 3))?'---': empty op.totalAddedValueTax ?0.00:(op.totalAddedValueTax)}</span>
+                            <span>税费: ${(op.includedTax eq 1 or (op.includedTax != '' and op.includedTax eq 0 and op.invoiceType eq 3))?'---': empty op.totalAddedValueTax ?0.00:(op.totalAddedValueTax)}</span>
                             <span>总额:  <fmt:formatNumber value="${op.totalFee}" type="currency"/></span>
                             <c:if test="${order.sendOutStatus == 2 || order.sendOutStatus == 3}">
                                 <span>已发/已收  ${(op.num == null ? 0 : op.num)+ (op.presentNum == null ? 0 : op.presentNum)- (op.notOutStore == null ? 0 : op.notOutStore)}/${op.receivedNum}</span>
@@ -598,29 +925,37 @@
                                 <span>退款(退货)中/已完成  ${op.returningNum}/${op.returnedNum}</span>
                             </c:if>
                             <c:if test="${op.heUserId > 0}">
-                                <span><font color="red">分销者:  ${op.heUserName}</font></span>
+                                <span><font color="red">分销者: ${op.heUserName}</font></span>
                             </c:if>
                         </div>
                         <c:if test="${op.productPromotion ne null}">
                             <c:if test="${op.productPromotion.type eq 2}">
                                 <div class="supplier-product-promotionInfo">
                                     <table>
-                                        <tr >
+                                        <tr>
                                             <td rowspan="2">
                                                 <c:if test="${op.productPromotion.mode eq 2}">
-                                                    <label style="background-color: #F60;color: white"><label class="promotionsName">${op.productPromotion.name}</label></label>
+                                                    <label style="background-color: #F60;color: white"><label
+                                                            class="promotionsName">${op.productPromotion.name}</label></label>
                                                 </c:if>
                                                 <c:if test="${op.productPromotion.mode eq 3}">
-                                                    <label style="background-color: purple;color: white"><label class="promotionsName">${op.productPromotion.name}</label></label>
+                                                    <label style="background-color: purple;color: white"><label
+                                                            class="promotionsName">${op.productPromotion.name}</label></label>
                                                 </c:if>
                                             </td>
                                             <td>
                                                 <span class="downSpan">${op.productPromotion.description}</span>
                                                 <c:if test="${op.productPromotion.mode eq 2}">
-                                                    <span class="upSpan"> 满<fmt:formatNumber value="${op.productPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>,减<fmt:formatNumber value="${op.productPromotion.reducedPrice}" pattern="#,##0.00" maxFractionDigits="2"/></span>
+                                                    <span class="upSpan"> 满<fmt:formatNumber
+                                                            value="${op.productPromotion.touchPrice}" pattern="#,##0.00"
+                                                            maxFractionDigits="2"/>,减<fmt:formatNumber
+                                                            value="${op.productPromotion.reducedPrice}"
+                                                            pattern="#,##0.00" maxFractionDigits="2"/></span>
                                                 </c:if>
                                                 <c:if test="${op.productPromotion.mode eq 3}">
-                                                    <span class="upSpan"> 满<fmt:formatNumber value="${op.productPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>,赠送商品</span>
+                                                    <span class="upSpan"> 满<fmt:formatNumber
+                                                            value="${op.productPromotion.touchPrice}" pattern="#,##0.00"
+                                                            maxFractionDigits="2"/>,赠送商品</span>
                                                 </c:if>
                                             </td>
                                         </tr>
@@ -632,16 +967,30 @@
                                     <table>
                                         <tr>
                                             <c:if test="${op.productPromotion.mode eq 1}">
-                                                <td><label style="background-color: green;color: white"><label class="promotionsName">${op.productPromotion.name}</label></label></td>
-                                                <td> 优惠价: <label style="color: red"><fmt:formatNumber value="${op.productPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/></label></td>
+                                                <td><label style="background-color: green;color: white"><label
+                                                        class="promotionsName">${op.productPromotion.name}</label></label>
+                                                </td>
+                                                <td> 优惠价: <label style="color: red"><fmt:formatNumber
+                                                        value="${op.productPromotion.touchPrice}" pattern="#,##0.00"
+                                                        maxFractionDigits="2"/></label></td>
                                             </c:if>
                                             <c:if test="${op.productPromotion.mode eq 2}">
-                                                <td><label style="background-color: #F60;color: white"><label class="promotionsName">${op.productPromotion.name}</label></label></td>
-                                                <td> 满<fmt:formatNumber value="${op.productPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>,减<fmt:formatNumber value="${op.productPromotion.reducedPrice}" pattern="#,##0.00" maxFractionDigits="2"/></td>
+                                                <td><label style="background-color: #F60;color: white"><label
+                                                        class="promotionsName">${op.productPromotion.name}</label></label>
+                                                </td>
+                                                <td> 满<fmt:formatNumber value="${op.productPromotion.touchPrice}"
+                                                                        pattern="#,##0.00"
+                                                                        maxFractionDigits="2"/>,减<fmt:formatNumber
+                                                        value="${op.productPromotion.reducedPrice}" pattern="#,##0.00"
+                                                        maxFractionDigits="2"/></td>
                                             </c:if>
                                             <c:if test="${op.productPromotion.mode eq 3}">
-                                                <td><label style="background-color: purple;color: white"><label class="promotionsName">${op.productPromotion.name}</label></label></td>
-                                                <td> 满<fmt:formatNumber value="${op.productPromotion.touchPrice}" pattern="#,##0.00" maxFractionDigits="2"/>,赠送商品</td>
+                                                <td><label style="background-color: purple;color: white"><label
+                                                        class="promotionsName">${op.productPromotion.name}</label></label>
+                                                </td>
+                                                <td> 满<fmt:formatNumber value="${op.productPromotion.touchPrice}"
+                                                                        pattern="#,##0.00" maxFractionDigits="2"/>,赠送商品
+                                                </td>
                                             </c:if>
                                         </tr>
                                     </table>
@@ -829,7 +1178,7 @@
         $.jBox.tip(msg, 'info', {timeout: 1000});
         setTimeout(function () {
             window.location.href = "${ctx}/order/detail?id=${order.orderID}"
-        },1000)
+        }, 1000)
     }
 </script>
  
@@ -916,7 +1265,7 @@
                                 'orderID': orderId,
                                 'balanceAccountsRemark': content
                             });
-                            window.location.href = "${ctx}/order/detail?id="+orderId;
+                            window.location.href = "${ctx}/order/detail?id=" + orderId;
                         }
                     }
                 });

+ 1 - 0
src/main/webapp/WEB-INF/views/modules/order/logisticsDetails.jsp

@@ -52,6 +52,7 @@
                 <table class="table">
                     <tr>
                         <td><img src="${lrs.image}"><span>${lrs.productName}</span></td>
+                        <td>规格:${lrs.unit}</td>
                         <td>购买数量(赠品):<span>${lrs.buyNum}(${lrs.presentNum})</span></td>
                         <td>本次发货:<span>${lrs.num}</span></td>
                     </tr>

+ 4 - 0
src/main/webapp/WEB-INF/views/modules/order/orderDetail.jsp

@@ -974,6 +974,10 @@
                     </div>
                     <c:if test="${op.productID ne 999}">
                         <div class="supplier-product-info">
+                            <span>
+                                规格:
+                                <label>${op.unit}</label>
+                            </span>
                             <span>单价:
                                 <c:if test="${op.svipPriceFlag eq 1 or op.productPromotion.mode eq 1}">
                                     <label style="text-decoration: line-through"><fmt:formatNumber value="${op.price}"

+ 2 - 0
src/main/webapp/WEB-INF/views/modules/order/ship.jsp

@@ -93,6 +93,7 @@
             <tr>
                 <th>选择发货商品</th>
                 <th>商品ID</th>
+                <th>规格</th>
                 <th>供应商</th>
                 <th>商品编号</th>
                 <th>商品图片</th>
@@ -113,6 +114,7 @@
                         </c:if>
                     </td>
                     <td>${orderProduct.productID}</td>
+                    <td>${orderProduct.unit}</td>
                     <td>${orderProduct.shopName}</td>
                     <td>${orderProduct.productNo}</td>
                     <td><img src="${orderProduct.image}" alt="" width="80px;height:auto;"></td>

+ 4 - 0
src/main/webapp/WEB-INF/views/modules/order/shipLogistic.jsp

@@ -72,6 +72,7 @@
                 <th>供应商</th>
                 <th>商品图片</th>
                 <th>商品名称</th>
+                <th>规格</th>
                 <th>购买数量</th>
                 <th>赠品数量</th>
                 <th>已发数量</th>
@@ -255,6 +256,9 @@ window.onload = function () {
         html+='<td>';
         html+=resdata[i].name;
         html+='</td>';
+        html+='<td>';
+        html+=resdata[i].unit;
+        html+='</td>';
         html+='<td class="buy-num">';
         html+=resdata[i].num;
         html+='</td>';

+ 128 - 64
src/main/webapp/WEB-INF/views/modules/product-new/productEdit.jsp

@@ -851,7 +851,8 @@
         </div>
         <div class="sku-item sku-ladderPriceFlag">
             <span class="red">*</span>商品展示价格:
-            <label> <input type="radio" name="ladderPriceFlag" value="0" checked/> 不使用阶梯价格 </label>
+            <label> <input type="radio" name="ladderPriceFlag" value="0" checked/> 不使用阶梯价格
+            </label>
             <b class="line">|</b>
             <label> <input type="radio" name="ladderPriceFlag" value="1"/>使用阶梯价格</label>
         </div>
@@ -859,36 +860,31 @@
             <span class="red">*</span>起订量:
             <input style="width: 40px" type="number" name="minBuyNumber" maxlength="11" class="short"/>
         </div>
+        <div><span><button class="deleteSku" onclick="deleteDiv()">删除SKU</button></span></div>
         <div class="ladderPriceBox" style="display: none;">
             <div class="ladderPrice">
                 起订量:
-                <input name="buyNum" min="1" type="number" maxlength="11" buyNum class="short number"
-                       onblur="checkBuyNum(this, 0)"/>(${product.unit})及以上,
-                <input name="buyPrice" type="number" maxlength="11" class="short price"
-                       onblur="checkBuyPrice(this, 0)"/>元/(${product.unit})
+                <input name="buyNum" min="1" type="number" maxlength="11" buyNum class="short number"/>(${product.unit})及以上,
+                <input name="buyPrice" type="number" maxlength="11" class="short price"/>元/(${product.unit})
                 <a class="addBtn" href="javascript:;">添加</a>
                 <input type="hidden" name="id"/>
                 <input class="delFlag" type="hidden" value="1" name="delFlag"/>
                 </span>
             </div>
-            <div class="ladderPrice">
+            <div class="ladderPrice" style="display: none">
                 起订量:
-                <input name="buyNum" type="number" maxlength="11" class="short number"
-                       onblur="checkBuyNum(this, 1)"/>(${product.unit})及以上,
-                <input name="buyPrice" type="number" maxlength="11" class="short price"
-                       onblur="checkBuyPrice(this, 1)"/>元/(${product.unit})
+                <input name="buyNum" type="number" maxlength="11" class="short number"/>(${product.unit})及以上,
+                <input name="buyPrice" type="number" maxlength="11" class="short price"/>元/(${product.unit})
                 <a class="delBtn" href="javascript:;">删除</a>
                 <a class="addBtn" href="javascript:;">添加</a>
                 <input type="hidden" name="id"/>
                 <input class="delFlag" type="hidden" value="1" name="delFlag"/>
                 </span>
             </div>
-            <div class="ladderPrice">
+            <div class="ladderPrice" style="display: none">
                 起订量:
-                <input name="buyNum" type="number" maxlength="11" class="short number"
-                       onblur="checkBuyNum(this, 2)"/>(${product.unit})及以上,
-                <input name="buyPrice" type="number" maxlength="11" class="short price"
-                       onblur="checkBuyPrice(this, 2)"/>元/(${product.unit})
+                <input name="buyNum" type="number" maxlength="11" class="short number"/>(${product.unit})及以上,
+                <input name="buyPrice" type="number" maxlength="11" class="short price"/>元/(${product.unit})
                 <a class="delBtn" href="javascript:;">删除</a>
                 </span>
                 <input type="hidden" name="id"/>
@@ -1066,7 +1062,7 @@
         });
 
         // 初始化sku
-        insertDefaultSkuRow()
+        insertDefaultSkuRow();
     });
     <%--// 商品可见度--%>
     <%--/*$(function() {--%>
@@ -1318,20 +1314,20 @@
 
     var step = ${product.step};
     var areaFlag = ${product.allAreaFlag};
-    var ladderPriceFlag = ${product.ladderPriceFlag};
-    var normalPrice = ${product.price};
+    <%--var ladderPriceFlag = ${product.ladderPriceFlag};--%>
+    <%--var normalPrice = ${product.price};--%>
     $(document).ready(function () {
         step * 1 > 1 ? $("#setpInput").show() : $("#setpInput").hide();
         areaFlag * 1 > 0 ? $("#allAreaInput").hide() : $("#allAreaInput").show();
-        computedPriceLevel(normalPrice);
-        if (ladderPriceFlag * 1 > 0) {
-            $("#ladderPriceBox").show();
-            $("#priceMinNumber").hide();
-        } else {
-            $("#ladderPriceBox").hide();
-            $("#priceMinNumber").show();
-        }
-        changeCostPriceShow();
+        // computedPriceLevel(normalPrice);
+        // if (ladderPriceFlag * 1 > 0) {
+        //     $("#ladderPriceBox").show();
+        //     $("#priceMinNumber").hide();
+        // } else {
+        //     $("#ladderPriceBox").hide();
+        //     $("#priceMinNumber").show();
+        // }
+        // changeCostPriceShow();
         //富文本框
         ClassicEditor.create(document.querySelector('#detailInfoEditor'), {
             ckfinder: {
@@ -1477,35 +1473,35 @@
     }
 
     // 检查阶梯数量
-    function checkBuyNum(input, index) {
-        if (index > 0) {
-            var beforeNum = $('input[name="ladderPriceList[' + (index - 1) + '].buyNum"]').val() * 1;
-            if (input.value * 1 <= beforeNum) {
-                alertx("请输入大于上一阶起订量的值");
-                $(input).val(input.value * 1 + beforeNum);
-            }
-        } else {
-            var minNum = $('input[name="ladderPriceList[0].buyNum"]').val() * 1;
-            $('#minBuyNumber').val(minNum);
-        }
-    }
+    // function checkBuyNum(input, index) {
+    //     if (index > 0) {
+    //         var beforeNum = $('input[name="ladderPriceList[' + (index - 1) + '].buyNum"]').val() * 1;
+    //         if (input.value * 1 <= beforeNum) {
+    //             alertx("请输入大于上一阶起订量的值");
+    //             $(input).val(input.value * 1 + beforeNum);
+    //         }
+    //     } else {
+    //         var minNum = $('input[name="ladderPriceList[0].buyNum"]').val() * 1;
+    //         $('#minBuyNumber').val(minNum);
+    //     }
+    // }
 
     // 检查阶梯价格
-    function checkBuyPrice(input, index) {
-        if (index > 0) {
-            var beforePrice = $('input[name="ladderPriceList[' + (index - 1) + '].buyPrice"]').val() * 1;
-            if (input.value * 1 > beforePrice) {
-                $(input).val('');
-                alertx("请输入小于前一个价格的值");
-            }
-        } else {
-            var price = $('#price').val();
-            if (input.value * 1 > price) {
-                $(input).val('');
-                alertx("第一个阶梯价格不能大于机构价");
-            }
-        }
-    }
+    // function checkBuyPrice(input, index) {
+    //     if (index > 0) {
+    //         var beforePrice = $('input[name="ladderPriceList[' + (index - 1) + '].buyPrice"]').val() * 1;
+    //         if (input.value * 1 > beforePrice) {
+    //             $(input).val('');
+    //             alertx("请输入小于前一个价格的值");
+    //         }
+    //     } else {
+    //         var price = $('#price').val();
+    //         if (input.value * 1 > price) {
+    //             $(input).val('');
+    //             alertx("第一个阶梯价格不能大于机构价");
+    //         }
+    //     }
+    // }
 
     // 是否使用阶梯价格
     function changeLadderPrice() {
@@ -1528,16 +1524,16 @@
     }
 
     // 是否固定成本
-    function changeCostPriceShow() {
-        var costCheckFlag = $("input[name='costCheckFlag']:checked").val();
-        if (costCheckFlag * 1 === 1) {
-            $("#costPriceShow").show();
-            $("#costPropShow").hide();
-        } else {
-            $("#costPriceShow").hide();
-            $("#costPropShow").show();
-        }
-    }
+    // function changeCostPriceShow() {
+    //     var costCheckFlag = $("input[name='costCheckFlag']:checked").val();
+    //     if (costCheckFlag * 1 === 1) {
+    //         $("#costPriceShow").show();
+    //         $("#costPropShow").hide();
+    //     } else {
+    //         $("#costPriceShow").hide();
+    //         $("#costPropShow").show();
+    //     }
+    // }
 
     // 全部区域
     function changeAreaFlag() {
@@ -1805,6 +1801,13 @@
         skuEventBind(current, product);
     })
 
+    function deleteDiv(){
+        var skus=document.getElementsByClassName('sku');
+        for (let i = 0; i < skus.length; i++) {
+            $(".skus").removeChild(skus[i]);
+        }
+    }
+
     function insertDefaultSkuRow() {
         console.log('skyList', skuList);
         if (skuList) {
@@ -1832,6 +1835,8 @@
         console.log(product);
         if (!product) return;
         var skuIndex = product.skuIndex;
+        var index = el.find('input[name$="index"]');
+        index.val(skuIndex);
         // 包装规格
         var unit = el.find('input[name$="unit"]');
         unit.val(product.unit)
@@ -1918,6 +1923,7 @@
     }
 
     function skuEventBind(el, product) {
+        var i = product.skuIndex;
         // 商品展示阶梯价格
         var ladderPriceFlag = el.find('input[name$="ladderPriceFlag"]');
         // 起订量
@@ -1927,6 +1933,62 @@
         var costCheckFlag = el.find('input[name$="costCheckFlag"]');
         var costPrice = el.find('input[name$="costPrice"]');
         var costProportional = el.find('input[name$="costProportional"]');
+        // 机构价
+        var clubPrice = el.find('input[name$="skuList[' + i + '].price"]');
+        //阶梯价格
+        var ladderPrice = el.find('input[name$="skuList[' + i + '].ladderPriceList[0].buyPrice"]');
+        var ladderPrice2 = el.find('input[name$="skuList[' + i + '].ladderPriceList[1].buyPrice"]');
+        var ladderPrice3 = el.find('input[name$="skuList[' + i + '].ladderPriceList[2].buyPrice"]');
+        //起订量
+        var num = el.find('input[name$="skuList[' + i + '].ladderPriceList[0].buyNum"]');
+        var num2 = el.find('input[name$="skuList[' + i + '].ladderPriceList[1].buyNum"]');
+        var num3 = el.find('input[name$="skuList[' + i + '].ladderPriceList[2].buyNum"]');
+
+        num2.on('change', function () {
+            var buyNum = num.val() * 1;
+            var buyNum2 = num2.val() * 1;
+            if (buyNum2 <= buyNum) {
+                alertx('请输入大于上一阶起订量的值');
+                num2.val('');
+            }
+        })
+
+        num3.on('change', function () {
+            var buyNum2 = num2.val() * 1;
+            var buyNum3 = num3.val() * 1;
+            if (buyNum3 <= buyNum2) {
+                alertx('请输入大于上一阶起订量的值');
+                num3.val('');
+            }
+        })
+
+        ladderPrice.on('change', function () {
+            var ldp = ladderPrice.val() * 1;
+            var price = clubPrice.val() * 1;
+            if (ldp >= price) {
+                alertx('第一个阶梯价格不能大于机构价');
+                ladderPrice.val('');
+            }
+        })
+
+        ladderPrice2.on('change', function () {
+            var ldp2 = ladderPrice2.val() * 1;
+            var ldp = ladderPrice.val() * 1;
+            if (ldp2 >= ldp) {
+                alertx('第二个阶梯价格不能大于第一个阶梯价格');
+                ladderPrice2.val('');
+            }
+        })
+
+        ladderPrice3.on('change', function () {
+            var ldp2 = ladderPrice2.val() * 1;
+            var ldp3 = ladderPrice3.val() * 1;
+            if (ldp3 >= ldp2) {
+                alertx('第三个阶梯价格不能大于第二个阶梯价格');
+                ladderPrice3.val('');
+            }
+        })
+
 
         ladderPriceFlag.on('change', function () {
             if (product && product.svipFlag == 1 && $(this).val() == 1) {
@@ -1939,12 +2001,14 @@
             if ($(this).val() == 1) {
                 ladderPriceBox.show();
                 minBuyNumber.parent('.sku-minBuyNumber').hide();
+                el.find('input[name$="skuList[' + i + '].ladderPriceList[0].delFlag"]').val(0);
             } else {
                 ladderPriceBox.hide();
                 minBuyNumber.parent('.sku-minBuyNumber').show();
             }
         })
 
+
         ladderPriceBox.find('.addBtn').on('click', function () {
             $(this).hide();
             $(this).parent('.ladderPrice').find('.delBtn').hide();

+ 26 - 5
src/main/webapp/WEB-INF/views/modules/product-new/promotionSelectProducts.jsp

@@ -23,7 +23,7 @@
                 submitHandler: function (form) {
                     var isSubMitFlag = true;
                     var productID = $("#productID").val();
-                    if (isNaN(productID) || productID.indexOf('0') == 0 ) {
+                    if (isNaN(productID) || productID.indexOf('0') == 0) {
                         alertx("请输入正确的商品ID");
                         isSubMitFlag = false;
                         return false;
@@ -34,6 +34,17 @@
                 }
             })
         });
+
+        function checkSkuValue(index) {
+            var skus = JSON.parse($("#hideSku").val());
+            var price = "price" + index;//单价
+            var chose = "#ints" + index;//选中的sku
+            var skuStr = $(chose).val();
+            var skuIndex = skuStr.split("/")[1];
+            var skuId = skuStr.split("/")[0];
+            document.getElementById(price).innerHTML = skus[skuIndex].price;
+            $("#skuId").val(skuId);
+        }
     </script>
 </head>
 <body>
@@ -47,7 +58,8 @@
     <form:hidden path="delProductIds"/>
     <div class="ul-form">
         <label>商品ID:</label>
-        <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini" onkeyup="onlynum(this)"/>
+        <form:input path="productID" id="productID" htmlEscape="false" maxlength="8" class="input-mini"
+                    onkeyup="onlynum(this)"/>
         <label>商品名称:</label>
         <form:input path="name" htmlEscape="false" class="input-medium" maxlength="20"/>
         <label>供应商名称:</label>
@@ -63,21 +75,30 @@
         <th>商品ID</th>
         <th>商品图片</th>
         <th>商品名称</th>
+        <th>规格</th>
         <th>供应商名称</th>
         <th>机构价</th>
     </tr>
     <tbody>
     <c:if test="${not empty page.list}">
-        <c:forEach items="${page.list}" var="item">
+        <c:forEach items="${page.list}" var="item" varStatus="state">
             <tr id="${item.productID}" class="itemtr">
                 <th>
-                    <input class="check-item" type="checkbox" name="info" value='${item.productID}'/>
+                    <input id="skuId" class="check-item" type="checkbox" name="info" value='${item.skuList[0].skuId}'/>
                 </th>
                 <td>${item.productID}</td>
                 <td><img src="${item.mainImage}" width="50px" height="50px"></td>
                 <td>${item.name}</td>
+                <td>
+                    <input id="hideSku" value='${fns:toJson(item.skuList)}' hidden>
+                    <select id="ints${state.index}" onchange="checkSkuValue(${state.index});">
+                        <c:forEach items="${item.skuList}" var="skus" varStatus="ind">
+                            <option value="${skus.skuId}/${ind.index}">${skus.unit}</option>
+                        </c:forEach>
+                    </select>
+                </td>
                 <td>${item.shopName}</td>
-                <td>${item.price}</td>
+                <td><label id="price${state.index}">${item.price}</label></td>
             </tr>
         </c:forEach>
     </c:if>

+ 8 - 3
src/main/webapp/WEB-INF/views/modules/product-new/singlePromotionForm.jsp

@@ -111,6 +111,7 @@
                     });
                     $('#contentTbody1 tr').each(function (index, item) {
                         var $this = $(this);
+                        //已改为skuId
                         var $itemProductID = $this.find('input[name="gift"]').val();
                         var $giftNumber = $this.find('input[name="giftNumber"]').val();
                         if ($giftNumber == null || $giftNumber == '' ) {
@@ -124,7 +125,7 @@
                             return false;
                         }
                         var obj = {
-                            productId: $itemProductID,
+                            skuId: $itemProductID,
                             number: $giftNumber
                         };
                         addGiftArray.push(obj)
@@ -142,7 +143,7 @@
                         var productItems = JSON.stringify(addProductArray);
                         var giftItems = JSON.stringify(addGiftArray);
                         $("#productIds").val(productItems);
-                        $("#giftIds").val(giftItems)
+                        $("#giftIds").val(giftItems);
                         loading('正在提交,请稍等...');
                         form.submit();
                     }
@@ -386,8 +387,10 @@
                     <thead>
                     <th style="width:20px;" class="hide"></th>
                     <th></th>
+                    <th>skuId</th>
                     <th>商品图片</th>
                     <th>商品名称</th>
+                    <th>规格</th>
                     <th>供应商</th>
                     <th>数量</th>
                     <th>操作</th>
@@ -396,11 +399,13 @@
                     <c:forEach items="${cmPromotion.giftProducts}" var="product">
                         <tr>
                             <td>赠</td>
+                            <td>${product.skuId}</td>
                             <th class="hide"><input class="check-item" type="checkbox" id="giftCheckItem"
                                                     name="gift" ${product.storeStatus?'':'checked'}
-                                                    value='${product.productID}'/></th>
+                                                    value='${product.skuId}'/></th>
                             <td><img src="${product.mainImage}" width="50px" height="50px"></td>
                             <td>${product.name}</td>
+                            <td>${product.unit}</td>
                             <td>${product.shopName}</td>
                             <td><input id="actPrice1" name="giftNumber" style="width:50px;"
                                        value="${product.giftNumber}" type="number" maxlength="7" step="1"></td>

+ 2 - 1
src/main/webapp/WEB-INF/views/modules/product/repeatPurchasePriceHistoryList.jsp

@@ -31,7 +31,8 @@
 			<b>机构名称:</b>${repeatPurchasePrice.userName}
 <%--			用户手机:${repeatPurchasePrice.mobile}--%>
 			<b>&nbsp;&nbsp;&nbsp;&nbsp;商品名称(ID):</b><a href="${wwwServer}product-${repeatPurchasePrice.productId}.html">${repeatPurchasePrice.productName}(${repeatPurchasePrice.productId})</a>
-			<b>&nbsp;&nbsp;&nbsp;&nbsp;供应商:</b><a href="${wwwServer}supplier/prolist-${repeatPurchasePrice.shopId}.html">${repeatPurchasePrice.shopName}</a>
+		<b>&nbsp;&nbsp;&nbsp;&nbsp;规格:</b>${repeatPurchasePrice.unit}
+		<b>&nbsp;&nbsp;&nbsp;&nbsp;供应商:</b><a href="${wwwServer}supplier/prolist-${repeatPurchasePrice.shopId}.html">${repeatPurchasePrice.shopName}</a>
 			<div class="clearfix"></div>
 		</div>
 	</form:form>

+ 122 - 99
src/main/webapp/WEB-INF/views/modules/product/repeatPurchasePriceList.jsp

@@ -1,108 +1,131 @@
 <%@ 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 type="text/css">
-		.table th{text-align: center;}
-		.table td{text-align: center;}
-	</style>
-	<script type="text/javascript">
-		$(document).ready(function() {
+    <title>再次购买管理</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table th {
+            text-align: center;
+        }
 
-		});
-		function page(n,s){
-			$("#pageNo").val(n);
-			$("#pageSize").val(s);
-			$("#searchForm").submit();
-        	return false;
+        .table td {
+            text-align: center;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
         };
-	</script>
+    </script>
 </head>
 <body>
-	<ul class="nav nav-tabs">
-		<li class="active"><a href="${ctx}/product/repeatPurchasePrice/">再次购买列表</a></li>
-<%--		<shiro:hasPermission name="product:repeatPurchasePrice:edit"><li><a href="${ctx}/product/repeatPurchasePrice/form">再次购买添加</a></li></shiro:hasPermission>--%>
-	</ul>
-	<form:form id="searchForm" modelAttribute="repeatPurchasePrice" action="${ctx}/product/repeatPurchasePrice/" method="post" class="breadcrumb form-search">
-		<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-		<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-		<div class="ul-form">
-			<label>商品ID:</label>
-			<form:input path="productId" htmlEscape="false" maxlength="20" class="input-medium"  onkeyup="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}"/>
-			<label>商品名称:</label>
-			<form:input path="productName" htmlEscape="false" maxlength="50" class="input-medium"/>
-			<label>机构名称:</label>
-			<form:input path="userName" htmlEscape="false" maxlength="50" class="input-medium"/>
-			<label>用户手机:</label>
-			<form:input path="mobile" htmlEscape="false" maxlength="50" class="input-medium"/>
-			<label>供应商名称:</label>
-			<form:input path="shopName" htmlEscape="false" maxlength="50" class="input-medium"/>
-			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
-			<div class="clearfix"></div>
-		</div>
-	</form:form>
-	<sys:message content="${message}"/>
-	<table id="contentTable" class="table table-striped table-bordered table-condensed">
-		<thead>
-			<tr>
-				<td>
-					机构名称
-				</td>
-				<td>
-					用户手机
-				</td>
-<%--				<td>--%>
-<%--					用户类型--%>
-<%--				</td>--%>
-				<td>
-					商品(ID)
-				</td>
-				<td>
-					供应商
-				</td>
-				<td>
-					税率
-				</td>
-				<td>
-					当前成本价<button type="button" class="tipButton" style="color: lightslategray;border-radius: 25px" onmousemove="alertx('商品的成本价跟随成本变化')">?</button>
-				</td>
-				<td>
-					复购价<button type="button" class="tipButton" style="color: lightslategray;border-radius: 25px" onmousemove="alertx('用户上一次购买此商品时商品的售价')">?</button>
-				</td>
-				<td>
-					添加时间
-				</td>
-				<%--<shiro:hasPermission name="product:repeatPurchasePrice:edit"></shiro:hasPermission>--%>
-                <th>操作</th>
-			</tr>
-		</thead>
-		<tbody>
-		<c:forEach items="${page.list}" var="repeatPurchasePrice">
-			<tr>
-				<td>${repeatPurchasePrice.userName}</td>
-				<td>${repeatPurchasePrice.mobile}</td>
-<%--				<td>${repeatPurchasePrice.type}</td>--%>
-                <td width="25%"><a href="${wwwServer}product-${repeatPurchasePrice.productId}.html">${repeatPurchasePrice.productName}(${repeatPurchasePrice.productId})</a></td>
-                <td><a href="${wwwServer}supplier/prolist-${repeatPurchasePrice.shopId}.html">${repeatPurchasePrice.shopName}</a></td>
-				<td><fmt:formatNumber value= "${repeatPurchasePrice.taxRate}" type="currency" pattern="0.00"/>%</td>
-                <td><fmt:formatNumber value= "${repeatPurchasePrice.costPrice}" type="currency" pattern="#,#00.00#"/></td>
-				<td><fmt:formatNumber value= "${repeatPurchasePrice.currentPrice}" type="currency" pattern="#,#00.00#"/></td>
-                <td>${repeatPurchasePrice.createTime}</td>
-                <td>
-					<a href="${ctx}/product/repeatPurchasePrice/getHistoryPriceList?repeatPurchasePriceId=${repeatPurchasePrice.id}">历史价格</a>&nbsp&nbsp
-					<a href="${ctx}/product/repeatPurchasePrice/delete?id=${repeatPurchasePrice.id}&repeatPurchasePriceId=${repeatPurchasePrice.id}" onclick="return confirmx('确认要删除该再次购买吗?', this.href)">删除</a>
-				</td>
-				<%--<shiro:hasPermission name="product:repeatPurchasePrice:edit"><td>--%>
-    				<%--<a href="${ctx}/product/repeatPurchasePrice/form?id=${repeatPurchasePrice.id}">编辑</a>--%>
-    				<%--<shiro:hasPermission name="product:repeatPurchasePrice:delete">--%>
-					<%--</shiro:hasPermission>--%>
-				<%--</td></shiro:hasPermission>--%>
-			</tr>
-		</c:forEach>
-		</tbody>
-	</table>
-	<div class="pagination">${page}</div>
+<ul class="nav nav-tabs">
+    <li class="active"><a href="${ctx}/product/repeatPurchasePrice/">再次购买列表</a></li>
+    <%--		<shiro:hasPermission name="product:repeatPurchasePrice:edit"><li><a href="${ctx}/product/repeatPurchasePrice/form">再次购买添加</a></li></shiro:hasPermission>--%>
+</ul>
+<form:form id="searchForm" modelAttribute="repeatPurchasePrice" action="${ctx}/product/repeatPurchasePrice/"
+           method="post" class="breadcrumb form-search">
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+        <label>商品ID:</label>
+        <form:input path="productId" htmlEscape="false" maxlength="20" class="input-medium"
+                    onkeyup="if(/\D/.test(this.value)){alert('只能输入数字');this.value='';}"/>
+        <label>商品名称:</label>
+        <form:input path="productName" htmlEscape="false" maxlength="50" class="input-medium"/>
+        <label>机构名称:</label>
+        <form:input path="userName" htmlEscape="false" maxlength="50" class="input-medium"/>
+        <label>用户手机:</label>
+        <form:input path="mobile" htmlEscape="false" maxlength="50" class="input-medium"/>
+        <label>供应商名称:</label>
+        <form:input path="shopName" htmlEscape="false" maxlength="50" class="input-medium"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <td>
+            机构名称
+        </td>
+        <td>
+            用户手机
+        </td>
+        <%--				<td>--%>
+        <%--					用户类型--%>
+        <%--				</td>--%>
+        <td>
+            商品(ID)
+        </td>
+        <td>
+            规格
+        </td>
+        <td>
+            供应商
+        </td>
+        <td>
+            税率
+        </td>
+        <td>
+            当前成本价
+            <button type="button" class="tipButton" style="color: lightslategray;border-radius: 25px"
+                    onmousemove="alertx('商品的成本价跟随成本变化')">?
+            </button>
+        </td>
+        <td>
+            复购价
+            <button type="button" class="tipButton" style="color: lightslategray;border-radius: 25px"
+                    onmousemove="alertx('用户上一次购买此商品时商品的售价')">?
+            </button>
+        </td>
+        <td>
+            添加时间
+        </td>
+        <%--<shiro:hasPermission name="product:repeatPurchasePrice:edit"></shiro:hasPermission>--%>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="repeatPurchasePrice">
+        <tr>
+            <td>${repeatPurchasePrice.userName}</td>
+            <td>${repeatPurchasePrice.mobile}</td>
+                <%--				<td>${repeatPurchasePrice.type}</td>--%>
+            <td width="25%"><a
+                    href="${wwwServer}product-${repeatPurchasePrice.productId}.html">${repeatPurchasePrice.productName}(${repeatPurchasePrice.productId})</a>
+            </td>
+            <td>${repeatPurchasePrice.unit}</td>
+            <td>
+                <a href="${wwwServer}supplier/prolist-${repeatPurchasePrice.shopId}.html">${repeatPurchasePrice.shopName}</a>
+            </td>
+            <td><fmt:formatNumber value="${repeatPurchasePrice.taxRate}" type="currency" pattern="0.00"/>%</td>
+            <td><fmt:formatNumber value="${repeatPurchasePrice.costPrice}" type="currency" pattern="#,#00.00#"/></td>
+            <td><fmt:formatNumber value="${repeatPurchasePrice.currentPrice}" type="currency" pattern="#,#00.00#"/></td>
+            <td>${repeatPurchasePrice.createTime}</td>
+            <td>
+                <a href="${ctx}/product/repeatPurchasePrice/getHistoryPriceList?repeatPurchasePriceId=${repeatPurchasePrice.id}">历史价格</a>&nbsp&nbsp
+                <a href="${ctx}/product/repeatPurchasePrice/delete?id=${repeatPurchasePrice.id}&repeatPurchasePriceId=${repeatPurchasePrice.id}"
+                   onclick="return confirmx('确认要删除该再次购买吗?', this.href)">删除</a>
+            </td>
+                <%--<shiro:hasPermission name="product:repeatPurchasePrice:edit"><td>--%>
+                <%--<a href="${ctx}/product/repeatPurchasePrice/form?id=${repeatPurchasePrice.id}">编辑</a>--%>
+                <%--<shiro:hasPermission name="product:repeatPurchasePrice:delete">--%>
+                <%--</shiro:hasPermission>--%>
+                <%--</td></shiro:hasPermission>--%>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
 </body>
 </html>

+ 9 - 2
src/main/webapp/static/modules/bulkpurchase/orderForm.js

@@ -903,12 +903,17 @@ function setProductList(data) {
 
     var skuStr = "<td>" + data.skuList[0].unit + "</td>";
     var skuIdStr = "<td>" + data.skuList[0].skuId + "</td>";
+
+    var price = data.skuList[0].price;
+    //未选择sku,默认sku[0],选择了sku,skustr不为空
     if (data.skuStr) {
         var strings = data.skuStr.split("/");
         var skuId = strings[0];
         var index = strings[1] * 1;
         skuStr = "<td>" + data.skuList[index].unit + "</td>";
         skuIdStr = "<td>" + skuId + "</td>";
+        //price
+        price = data.skuList[index].price;
     }
 
     var str =
@@ -923,9 +928,10 @@ function setProductList(data) {
         (data.productCategory == 2 ? "" : ("<td>" + data.shopName + "</td>")) +
         skuStr +
         "<td>" + data.num + (data.presentNum > 0 ? "(" + data.presentNum + ")" : "") + "</td>" +
+        //价格
         (data.svipPriceFlag == 1 ? "<td>" + data.discountPrice :
-            (data.discount * 1 === 100 && data.cmPromotion && data.cmPromotion.mode == 1 ? ("<td><del>" + data.price +
-                "</del>") : ("<td>" + data.price))) +
+            (data.discount * 1 === 100 && data.cmPromotion && data.cmPromotion.mode == 1 ? ("<td><del>" + price +
+                "</del>") : ("<td>" + price))) +
         ((data.svipPriceFlag == 1 || (data.includedTax != null && data.includedTax != '' && data.includedTax != 2)) ? "<label style='color: red'>(" : "") +
         (data.svipPriceFlag == 1 ? "超级会员价" : "") +
         ((data.svipPriceFlag == 1 && (data.includedTax != null && data.includedTax != '' && data.includedTax != 2)) ? "," : "") +
@@ -935,6 +941,7 @@ function setProductList(data) {
             "不含税-不能开票" : "") +
         ((data.svipPriceFlag == 1 || (data.includedTax != null && data.includedTax != '' && data.includedTax != 2)) ? ")</label>" : "") +
         "</td>" +
+
         "<td>" + data.discount + "</td>" +
         (data.discount * 1 === 100 && data.cmPromotion && data.cmPromotion.mode == 1 ? ("<td><del>" + data
             .discountPrice + "</del></td>") : ("<td>" + data.discountPrice +

Vissa filer visades inte eftersom för många filer har ändrats