浏览代码

呵呵商城商品活动

plf 4 年之前
父节点
当前提交
e73edc4ff2
共有 23 个文件被更改,包括 2063 次插入14 次删除
  1. 24 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityDao.java
  2. 66 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityProductDao.java
  3. 77 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeHeActivityLadder.java
  4. 111 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheActivity.java
  5. 127 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheActivityProduct.java
  6. 10 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheProduct.java
  7. 115 0
      src/main/java/com/caimei/modules/hehe/service/CmHeheActivityProductService.java
  8. 100 0
      src/main/java/com/caimei/modules/hehe/service/CmHeheActivityService.java
  9. 5 5
      src/main/java/com/caimei/modules/hehe/service/CmHeheProductService.java
  10. 98 0
      src/main/java/com/caimei/modules/hehe/web/CmHeheActivityController.java
  11. 153 0
      src/main/java/com/caimei/modules/hehe/web/CmHeheActivityProductController.java
  12. 0 2
      src/main/java/com/caimei/modules/hehe/web/CmHeheProductController.java
  13. 1 1
      src/main/resources/config/dev/caimei.properties
  14. 124 0
      src/main/resources/mappings/modules/hehe/CmHeheActivityMapper.xml
  15. 184 0
      src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml
  16. 123 0
      src/main/webapp/WEB-INF/views/modules/hehe/addActivityProduct.jsp
  17. 229 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityForm.jsp
  18. 130 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityList.jsp
  19. 159 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductForm.jsp
  20. 225 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductList.jsp
  21. 1 1
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheImageForm.jsp
  22. 1 1
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheUserList.jsp
  23. 0 4
      src/main/webapp/WEB-INF/views/modules/hehe/heheAddProduct.jsp

+ 24 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheActivityDao.java

@@ -0,0 +1,24 @@
+package com.caimei.modules.hehe.dao;
+
+import com.caimei.modules.hehe.entity.CmHeheActivity;
+import com.thinkgem.jeesite.common.persistence.CrudDao;
+import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 呵呵商城活动DAO接口
+ *
+ * @author plf
+ * @version 2021-04-19
+ */
+@MyBatisDao
+public interface CmHeheActivityDao extends CrudDao<CmHeheActivity> {
+
+    /**
+     * 修改小程序状态
+     *
+     * @param status
+     * @param id
+     */
+    void updateStatusById(@Param("status") String status, @Param("id") Integer id);
+}

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

@@ -0,0 +1,66 @@
+package com.caimei.modules.hehe.dao;
+
+import com.caimei.modules.hehe.entity.CmHeHeActivityLadder;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.thinkgem.jeesite.common.persistence.CrudDao;
+import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
+import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 活动商品DAO接口
+ *
+ * @author plf
+ * @version 2021-04-20
+ */
+@MyBatisDao
+public interface CmHeheActivityProductDao extends CrudDao<CmHeheActivityProduct> {
+    /**
+     * 查询活动商品id
+     *
+     * @param userId
+     * @return
+     */
+    List<Integer> findActivityProductId(Integer userId);
+
+    /**
+     * 查询呵呵商城所有上架商品
+     *
+     * @param product
+     * @return
+     */
+    List<CmHeheProduct> findAllHeHeProduct(CmHeheProduct product);
+
+    /**
+     * 修改排序值
+     *
+     * @param sort
+     * @param id
+     */
+    void updateSortById(@Param("sort") String sort, @Param("id") String id);
+
+    /**
+     * 查询活动阶梯
+     *
+     * @param activityId
+     * @param productId
+     * @return
+     */
+    List<CmHeHeActivityLadder> findActivityLadder(@Param("activityId") Integer activityId, @Param("productId") Integer productId);
+
+    /**
+     * 保存活动阶梯
+     *
+     * @param ladder
+     */
+    void insertLadder(CmHeHeActivityLadder ladder);
+
+    /**
+     * 删除活动阶梯
+     * @param activityId
+     * @param productId
+     */
+    void deleteLadder(@Param("activityId") Integer activityId,@Param("productId") Integer productId);
+}

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

@@ -0,0 +1,77 @@
+package com.caimei.modules.hehe.entity;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : plf
+ * @date : 2021/4/20
+ */
+public class CmHeHeActivityLadder implements Serializable {
+    private Integer id;
+    private Integer activityId;     //活动id
+    private Integer productId;      //对应采美商品id
+    private Integer ladderNum;  //第几阶梯
+    private Integer buyNum;     //购买数量
+    private BigDecimal buyPrice;    //购买价格
+    private Date createDate;      //创建时间
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getActivityId() {
+        return activityId;
+    }
+
+    public void setActivityId(Integer activityId) {
+        this.activityId = activityId;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public Integer getLadderNum() {
+        return ladderNum;
+    }
+
+    public void setLadderNum(Integer ladderNum) {
+        this.ladderNum = ladderNum;
+    }
+
+    public Integer getBuyNum() {
+        return buyNum;
+    }
+
+    public void setBuyNum(Integer buyNum) {
+        this.buyNum = buyNum;
+    }
+
+    public BigDecimal getBuyPrice() {
+        return buyPrice;
+    }
+
+    public void setBuyPrice(BigDecimal buyPrice) {
+        this.buyPrice = buyPrice;
+    }
+
+    public Date getCreateDate() {
+        return createDate;
+    }
+
+    public void setCreateDate(Date createDate) {
+        this.createDate = createDate;
+    }
+}

+ 111 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheActivity.java

@@ -0,0 +1,111 @@
+package com.caimei.modules.hehe.entity;
+
+import org.hibernate.validator.constraints.Length;
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+/**
+ * 呵呵商城活动Entity
+ * @author plf
+ * @version 2021-04-19
+ */
+public class CmHeheActivity extends DataEntity<CmHeheActivity> {
+	
+	private static final long serialVersionUID = 1L;
+	private String name;		// 活动名称
+	private String userId;		// 分销者用户id
+	private String status;		// 小程序状态:1启用,2停用
+	private String listImage;		// 小程序列表缩略图
+	private String detailsImage;		// 小程序详情主题图
+	private Date beginTime;		// 开始时间
+	private Date endTime;		// 结束时间
+	private Date addTime;		// 创建时间
+	private Integer activityStatus;  	//活动状态:1未开始,2进行中,3已结束
+	
+	public CmHeheActivity() {
+		super();
+	}
+
+	public CmHeheActivity(String id){
+		super(id);
+	}
+
+	@Length(min=0, max=50, message="活动名称长度必须介于 0 和 50 之间")
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+	
+	public String getUserId() {
+		return userId;
+	}
+
+	public void setUserId(String userId) {
+		this.userId = userId;
+	}
+	
+	@Length(min=0, max=1, message="小程序状态长度必须介于 0 和 1 之间")
+	public String getStatus() {
+		return status;
+	}
+
+	public void setStatus(String status) {
+		this.status = status;
+	}
+	
+	public String getListImage() {
+		return listImage;
+	}
+
+	public void setListImage(String listImage) {
+		this.listImage = listImage;
+	}
+	
+	public String getDetailsImage() {
+		return detailsImage;
+	}
+
+	public void setDetailsImage(String detailsImage) {
+		this.detailsImage = detailsImage;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getBeginTime() {
+		return beginTime;
+	}
+
+	public void setBeginTime(Date beginTime) {
+		this.beginTime = beginTime;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getAddTime() {
+		return addTime;
+	}
+
+	public void setAddTime(Date addTime) {
+		this.addTime = addTime;
+	}
+
+	public Integer getActivityStatus() {
+		return activityStatus;
+	}
+
+	public void setActivityStatus(Integer activityStatus) {
+		this.activityStatus = activityStatus;
+	}
+}

+ 127 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheActivityProduct.java

@@ -0,0 +1,127 @@
+package com.caimei.modules.hehe.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 活动商品Entity
+ *
+ * @author plf
+ * @version 2021-04-20
+ */
+public class CmHeheActivityProduct extends DataEntity<CmHeheActivityProduct> {
+
+    private static final long serialVersionUID = 1L;
+    private Integer activityId;        // 呵呵活动id
+    private Integer productId;        // 对应采美商品id
+    private String sort;        // 排序值
+    private Date addTime;        // 添加时间
+    private String name;         //商品名称
+    private String mainImage;       //商品图片
+    private String shopName;        //供应商名称
+    private BigDecimal price;        // 售价
+    private String unit;        //包装规格
+    private Integer userId;         //分销者id
+    private List<CmHeHeActivityLadder> activityLadderList;  //活动阶梯
+
+    public CmHeheActivityProduct() {
+        super();
+    }
+
+    public CmHeheActivityProduct(String id) {
+        super(id);
+    }
+
+    public Integer getActivityId() {
+        return activityId;
+    }
+
+    public void setActivityId(Integer activityId) {
+        this.activityId = activityId;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public String getSort() {
+        return sort;
+    }
+
+    public void setSort(String sort) {
+        this.sort = sort;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getMainImage() {
+        return mainImage;
+    }
+
+    public void setMainImage(String mainImage) {
+        this.mainImage = mainImage;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        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;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public List<CmHeHeActivityLadder> getActivityLadderList() {
+        return activityLadderList;
+    }
+
+    public void setActivityLadderList(List<CmHeHeActivityLadder> activityLadderList) {
+        this.activityLadderList = activityLadderList;
+    }
+}

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

@@ -6,6 +6,7 @@ import org.hibernate.validator.constraints.Length;
 
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 呵呵商品Entity
@@ -32,6 +33,7 @@ public class CmHeheProduct extends DataEntity<CmHeheProduct> {
     private String name;         //商品名称
     private String mainImage;       //商品图片
     private String shopName;        //供应商名称
+    private List<Integer> ids;             //刚添加的活动id
 
     public CmHeheProduct() {
         super();
@@ -174,4 +176,12 @@ public class CmHeheProduct extends DataEntity<CmHeheProduct> {
     public void setShopName(String shopName) {
         this.shopName = shopName;
     }
+
+    public List<Integer> getIds() {
+        return ids;
+    }
+
+    public void setIds(List<Integer> ids) {
+        this.ids = ids;
+    }
 }

+ 115 - 0
src/main/java/com/caimei/modules/hehe/service/CmHeheActivityProductService.java

@@ -0,0 +1,115 @@
+package com.caimei.modules.hehe.service;
+
+import com.caimei.modules.hehe.dao.CmHeheActivityProductDao;
+import com.caimei.modules.hehe.entity.CmHeHeActivityLadder;
+import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.utils.AppUtils;
+import com.caimei.utils.StringUtil;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+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 java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 活动商品Service
+ *
+ * @author plf
+ * @version 2021-04-20
+ */
+@Service
+@Transactional(readOnly = true)
+public class CmHeheActivityProductService extends CrudService<CmHeheActivityProductDao, CmHeheActivityProduct> {
+    @Autowired
+    private CmHeheActivityProductDao activityProductDao;
+
+    public CmHeheActivityProduct get(String id) {
+        CmHeheActivityProduct activityProduct = super.get(id);
+        List<CmHeHeActivityLadder> activityLadderList = activityProductDao.findActivityLadder(activityProduct.getActivityId(), activityProduct.getProductId());
+        activityProduct.setActivityLadderList(activityLadderList);
+        return activityProduct;
+    }
+
+    public List<CmHeheActivityProduct> findList(CmHeheActivityProduct cmHeheActivityProduct) {
+        return super.findList(cmHeheActivityProduct);
+    }
+
+    public Page<CmHeheActivityProduct> findPage(Page<CmHeheActivityProduct> page, CmHeheActivityProduct cmHeheActivityProduct) {
+        Page<CmHeheActivityProduct> productPage = super.findPage(page, cmHeheActivityProduct);
+        List<CmHeheActivityProduct> productList = productPage.getList();
+        String wwwServer = Global.getConfig("wwwServer");
+        productList.forEach(item -> {
+            List<CmHeHeActivityLadder> activityLadderList = activityProductDao.findActivityLadder(item.getActivityId(), item.getProductId());
+            if (StringUtil.isNotBlank(item.getMainImage())) {
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
+            }
+            item.setActivityLadderList(activityLadderList);
+        });
+        return productPage;
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(CmHeheActivityProduct cmHeheActivityProduct) {
+        super.delete(cmHeheActivityProduct);
+    }
+
+    public Page<CmHeheProduct> findProductPage(Page<CmHeheProduct> productPage, CmHeheProduct product, Integer userId) {
+        List<Integer> productIds = activityProductDao.findActivityProductId(userId);
+        product.setIds(productIds);
+        product.setPage(productPage);
+        List<CmHeheProduct> productList = activityProductDao.findAllHeHeProduct(product);
+        String wwwServer = Global.getConfig("wwwServer");
+        productList.forEach(item -> {
+            if (StringUtil.isNotBlank(item.getMainImage())) {
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
+            }
+        });
+        productPage.setList(productList);
+        return productPage;
+    }
+
+    @Transactional(readOnly = false)
+    public void addProducts(Integer activityId, String productIds) {
+        CmHeheActivityProduct activityProduct = new CmHeheActivityProduct();
+        activityProduct.setActivityId(activityId);
+        if (StringUtil.isNotBlank(productIds)) {
+            String[] ids = productIds.split(",");
+            for (String id : ids) {
+                if (StringUtil.isNotBlank(id)) {
+                    activityProduct.setProductId(Integer.valueOf(id));
+                    activityProductDao.insert(activityProduct);
+                }
+            }
+        }
+    }
+
+    @Transactional(readOnly = false)
+    public void saveSort(String sort, String id) {
+        activityProductDao.updateSortById(sort, id);
+    }
+
+    @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]));
+                activityProductDao.insertLadder(ladder);
+            }
+        }
+    }
+}

+ 100 - 0
src/main/java/com/caimei/modules/hehe/service/CmHeheActivityService.java

@@ -0,0 +1,100 @@
+package com.caimei.modules.hehe.service;
+
+import com.caimei.dfs.image.beens.ImageUploadInfo;
+import com.caimei.modules.brand.utils.ImagePathUtils;
+import com.caimei.modules.hehe.dao.CmHeheActivityDao;
+import com.caimei.modules.hehe.entity.CmHeheActivity;
+import com.caimei.modules.sys.utils.UploadImageUtils;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
+import com.thinkgem.jeesite.common.utils.Encodes;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 呵呵商城活动Service
+ *
+ * @author plf
+ * @version 2021-04-19
+ */
+@Service
+@Transactional(readOnly = true)
+public class CmHeheActivityService extends CrudService<CmHeheActivityDao, CmHeheActivity> {
+    @Autowired
+    private CmHeheActivityDao cmHeheActivityDao;
+
+    public CmHeheActivity get(String id) {
+        return super.get(id);
+    }
+
+    public List<CmHeheActivity> findList(CmHeheActivity cmHeheActivity) {
+        return super.findList(cmHeheActivity);
+    }
+
+    public Page<CmHeheActivity> findPage(Page<CmHeheActivity> page, CmHeheActivity cmHeheActivity) {
+        Page<CmHeheActivity> activityPage = super.findPage(page, cmHeheActivity);
+        List<CmHeheActivity> activityList = activityPage.getList();
+        if (activityList != null && activityList.size() > 0) {
+            activityList.forEach(activity -> {
+                Date date = new Date();
+                if (date.compareTo(activity.getBeginTime()) < 0) {
+                    activity.setActivityStatus(1);
+                } else if (date.compareTo(activity.getEndTime()) < 1) {
+                    activity.setActivityStatus(2);
+                } else {
+                    activity.setActivityStatus(3);
+                }
+            });
+        }
+        return activityPage;
+    }
+
+    @Transactional(readOnly = false)
+    public void save(CmHeheActivity cmHeheActivity) {
+        //保存图片
+        String listImage = cmHeheActivity.getListImage();
+        String photoServer = Global.getConfig("photoServer");//获取文件服务器地址
+        if (StringUtils.isNotBlank(listImage) && !listImage.startsWith("http")) {
+            listImage = Encodes.urlDecode(listImage);
+            String realPath = UploadImageUtils.getAbsolutePath(listImage);
+            int pointerIndex = realPath.lastIndexOf(".");
+            ImageUploadInfo saveImageSerivce = new ImageUploadInfo();
+            try {
+                saveImageSerivce = ImagePathUtils.saveImageSerivce(realPath, pointerIndex, realPath);
+                cmHeheActivity.setListImage(photoServer + saveImageSerivce.getSource());
+            } catch (Exception e) {
+                logger.error("图片上传错误:" + e.toString(), e);
+            }
+        }
+        String detailsImage = cmHeheActivity.getDetailsImage();
+        if (StringUtils.isNotBlank(detailsImage) && !detailsImage.startsWith("http")) {
+            detailsImage = Encodes.urlDecode(detailsImage);
+            String realPath = UploadImageUtils.getAbsolutePath(detailsImage);
+            int pointerIndex = realPath.lastIndexOf(".");
+            ImageUploadInfo saveImageSerivce = new ImageUploadInfo();
+            try {
+                saveImageSerivce = ImagePathUtils.saveImageSerivce(realPath, pointerIndex, realPath);
+                cmHeheActivity.setDetailsImage(photoServer + saveImageSerivce.getSource());
+            } catch (Exception e) {
+                logger.error("图片上传错误:" + e.toString(), e);
+            }
+        }
+        super.save(cmHeheActivity);
+    }
+
+    @Transactional(readOnly = false)
+    public void delete(CmHeheActivity cmHeheActivity) {
+        super.delete(cmHeheActivity);
+    }
+
+    @Transactional(readOnly = false)
+    public void updateStatusById(String status, Integer id) {
+        cmHeheActivityDao.updateStatusById(status, id);
+    }
+}

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

@@ -69,7 +69,7 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
         String wwwServer = Global.getConfig("wwwServer");
         productList.forEach(item -> {
             if (StringUtil.isNotBlank(item.getMainImage())) {
-                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, "https://www.caimei365.com/"));
+                item.setMainImage(AppUtils.getImageURL("product", item.getMainImage(), 0, wwwServer));
             }
         });
         productPage.setList(productList);
@@ -83,9 +83,9 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
 
     @Transactional(readOnly = false)
     public void updateValidFlag(CmHeheProduct cmHeheProduct) {
-        if ("1".equals(cmHeheProduct.getValidFlag())){
+        if ("1".equals(cmHeheProduct.getValidFlag())) {
             cmHeheProduct.setValidFlag("2");
-        }else {
+        } else {
             cmHeheProduct.setValidFlag("1");
         }
         cmHeheProductDao.update(cmHeheProduct);
@@ -93,9 +93,9 @@ public class CmHeheProductService extends CrudService<CmHeheProductDao, CmHehePr
 
     @Transactional(readOnly = false)
     public void updateRecommend(CmHeheProduct cmHeheProduct) {
-        if ("0".equals(cmHeheProduct.getRecommend())){
+        if ("0".equals(cmHeheProduct.getRecommend())) {
             cmHeheProduct.setRecommend("1");
-        }else {
+        } else {
             cmHeheProduct.setRecommend("0");
         }
         cmHeheProductDao.update(cmHeheProduct);

+ 98 - 0
src/main/java/com/caimei/modules/hehe/web/CmHeheActivityController.java

@@ -0,0 +1,98 @@
+package com.caimei.modules.hehe.web;
+
+import com.caimei.modules.hehe.entity.CmHeheActivity;
+import com.caimei.modules.hehe.service.CmHeheActivityService;
+import com.google.common.collect.Maps;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+
+/**
+ * 呵呵商城活动Controller
+ *
+ * @author plf
+ * @version 2021-04-19
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/hehe/cmHeheActivity")
+public class CmHeheActivityController extends BaseController {
+
+    @Autowired
+    private CmHeheActivityService cmHeheActivityService;
+
+    @ModelAttribute
+    public CmHeheActivity get(@RequestParam(required = false) String id) {
+        CmHeheActivity entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = cmHeheActivityService.get(id);
+        }
+        if (entity == null) {
+            entity = new CmHeheActivity();
+        }
+        return entity;
+    }
+
+    @RequestMapping(value = {"list", ""})
+    public String list(CmHeheActivity cmHeheActivity, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmHeheActivity> page = cmHeheActivityService.findPage(new Page<CmHeheActivity>(request, response), cmHeheActivity);
+        model.addAttribute("page", page);
+        model.addAttribute("userId", cmHeheActivity.getUserId());
+        return "modules/hehe/cmHeheActivityList";
+    }
+
+    @RequestMapping(value = "form")
+    public String form(CmHeheActivity cmHeheActivity, Model model) {
+        model.addAttribute("cmHeheActivity", cmHeheActivity);
+        return "modules/hehe/cmHeheActivityForm";
+    }
+
+    @RequestMapping(value = "save")
+    public String save(CmHeheActivity cmHeheActivity, Model model, RedirectAttributes redirectAttributes) {
+        if (!beanValidator(model, cmHeheActivity)) {
+            return form(cmHeheActivity, model);
+        }
+        cmHeheActivityService.save(cmHeheActivity);
+        addMessage(redirectAttributes, "保存活动成功");
+        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivity/?userId=" + cmHeheActivity.getUserId();
+    }
+
+    @RequestMapping(value = "delete")
+    public String delete(CmHeheActivity cmHeheActivity, RedirectAttributes redirectAttributes) {
+        cmHeheActivityService.delete(cmHeheActivity);
+        addMessage(redirectAttributes, "删除活动成功");
+        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivity/?userId=" + cmHeheActivity.getUserId();
+    }
+
+    /**
+     * 启用、停用状态
+     */
+    @ResponseBody
+    @RequestMapping(value = "updateStatus")
+    public Map<String, Object> updateStatus(String status, Integer id) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            cmHeheActivityService.updateStatusById(status, id);
+            map.put("success", true);
+            map.put("msg", "修改成功");
+        } catch (Exception e) {
+            logger.debug(e.toString(), e);
+            map.put("success", false);
+            map.put("msg", "修改失败");
+        }
+        return map;
+    }
+
+}

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

@@ -0,0 +1,153 @@
+package com.caimei.modules.hehe.web;
+
+import com.caimei.modules.hehe.entity.CmHeheActivityProduct;
+import com.caimei.modules.hehe.entity.CmHeheProduct;
+import com.caimei.modules.hehe.service.CmHeheActivityProductService;
+import com.google.common.collect.Maps;
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+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.Map;
+
+import static com.caimei.modules.newhome.web.NewPageQualitySupplierController.isInteger;
+
+/**
+ * 活动商品Controller
+ *
+ * @author plf
+ * @version 2021-04-20
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/hehe/cmHeheActivityProduct")
+public class CmHeheActivityProductController extends BaseController {
+
+    @Autowired
+    private CmHeheActivityProductService cmHeheActivityProductService;
+
+    @ModelAttribute
+    public CmHeheActivityProduct get(@RequestParam(required = false) String id) {
+        CmHeheActivityProduct entity = null;
+        if (StringUtils.isNotBlank(id)) {
+            entity = cmHeheActivityProductService.get(id);
+        }
+        if (entity == null) {
+            entity = new CmHeheActivityProduct();
+        }
+        return entity;
+    }
+
+    @RequestMapping(value = {"list", ""})
+    public String list(CmHeheActivityProduct cmHeheActivityProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmHeheActivityProduct> page = cmHeheActivityProductService.findPage(new Page<CmHeheActivityProduct>(request, response), cmHeheActivityProduct);
+        model.addAttribute("page", page);
+        model.addAttribute("activityProduct", cmHeheActivityProduct);
+        return "modules/hehe/cmHeheActivityProductList";
+    }
+
+    @RequestMapping(value = "form")
+    public String form(CmHeheActivityProduct cmHeheActivityProduct, Model model) {
+        model.addAttribute("cmHeheActivityProduct", cmHeheActivityProduct);
+        return "modules/hehe/cmHeheActivityProductForm";
+    }
+
+    @RequestMapping(value = "delete")
+    public String delete(CmHeheActivityProduct cmHeheActivityProduct, RedirectAttributes redirectAttributes) {
+        cmHeheActivityProductService.delete(cmHeheActivityProduct);
+        addMessage(redirectAttributes, "删除活动商品成功");
+        return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheActivityProduct/list?activityId=" + cmHeheActivityProduct.getActivityId() + "&userId=" + cmHeheActivityProduct.getUserId();
+    }
+
+    /**
+     * 添加商品,商品数据
+     */
+    @RequestMapping(value = "findProductPage")
+    public String findProductPage(CmHeheProduct product, Integer userId, Model model, HttpServletRequest request, HttpServletResponse response) {
+        Page<CmHeheProduct> page = cmHeheActivityProductService.findProductPage(new Page<CmHeheProduct>(request, response), product, userId);
+        model.addAttribute("page", page);
+        model.addAttribute("userId", userId);
+        return "modules/hehe/addActivityProduct";
+    }
+
+    /**
+     * 添加商品
+     *
+     * @return
+     */
+    @RequestMapping(value = "addProducts")
+    @ResponseBody
+    public Map<String, Object> addProducts(Integer activityId, String productIds) {
+        cmHeheActivityProductService.addProducts(activityId, productIds);
+        HashMap<String, Object> map = new HashMap<>(2);
+        map.put("success", true);
+        map.put("info", "添加活动商品成功");
+        return map;
+    }
+
+    /**
+     * 批量更新排序值
+     */
+    @RequestMapping(value = "batchSaveSort")
+    @ResponseBody
+    public Map<String, Object> batchSaveSort(String sortList) {
+        Map<String, Object> map = Maps.newLinkedHashMap();
+        try {
+            String[] newPageLists = sortList.split(",");
+            for (String list : newPageLists) {
+                String[] split = list.split("-");
+                if (split.length == 1 || split.length < 1) {
+                    String id = split[0];
+                    String sort = null;
+                    cmHeheActivityProductService.saveSort(sort, id);
+                } else {
+                    String id = split[0];
+                    String sort = split[1];
+                    if (isInteger(sort)) {
+                        if (StringUtils.equals("0", sort)) {
+                            map.put("success", false);
+                            map.put("msg", "排序值只能填写大于等于1的整数");
+                            return map;
+                        }
+                        cmHeheActivityProductService.saveSort(sort, id);
+                    } else {
+                        map.put("success", false);
+                        map.put("msg", "排序值只能为数字");
+                        return map;
+                    }
+                }
+            }
+            map.put("success", true);
+            map.put("msg", "更新排序成功");
+            return map;
+        } catch (Exception e) {
+            map.put("success", false);
+            map.put("msg", "更新排序失败");
+            return map;
+        }
+    }
+
+    /**
+     * 保存活动阶梯
+     */
+    @ResponseBody
+    @RequestMapping(value = "saveActivityLadder")
+    public Map<String, Object> saveActivityLadder(String params, String id) {
+        Map<String, Object> map = new HashMap<>();
+        cmHeheActivityProductService.saveActivityLadder(params, id);
+        map.put("success", true);
+        map.put("info", "保存成功");
+        return map;
+    }
+}

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

@@ -85,8 +85,6 @@ 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("ids", product.getIds());
-        model.addAttribute("delProductIds", product.getDelProductIds());
         return "modules/hehe/heheAddProduct";
     }
 

+ 1 - 1
src/main/resources/config/dev/caimei.properties

@@ -148,7 +148,7 @@ photoServer=http\://192.168.2.100/
 server=http\://192.168.2.100/
 #admin2server=http\://localhost:8081/
 admin2Server=http\://admin2.caimei365.com/
-wwwServer=http\://localhost:8100/
+wwwServer=https://www.caimei365.com/
 bServer=http\://btest.365mdd.com/
 
 #CRM\u5730\u5740

+ 124 - 0
src/main/resources/mappings/modules/hehe/CmHeheActivityMapper.xml

@@ -0,0 +1,124 @@
+<?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.CmHeheActivityDao">
+    
+	<sql id="cmHeheActivityColumns">
+		a.id AS "id",
+		a.name AS "name",
+		a.userId AS "userId",
+		a.status AS "status",
+		a.listImage AS "listImage",
+		a.detailsImage AS "detailsImage",
+		a.beginTime AS "beginTime",
+		a.endTime AS "endTime",
+		a.addTime AS "addTime",
+		a.delFlag AS "delFlag"
+	</sql>
+	
+	<sql id="cmHeheActivityJoins">
+	</sql>
+    
+	<select id="get" resultType="CmHeheActivity">
+		SELECT 
+			<include refid="cmHeheActivityColumns"/>
+		FROM cm_hehe_activity a
+		<include refid="cmHeheActivityJoins"/>
+		WHERE a.id = #{id}
+	</select>
+	
+	<select id="findList" resultType="CmHeheActivity">
+		SELECT 
+			<include refid="cmHeheActivityColumns"/>
+		FROM cm_hehe_activity a
+		<include refid="cmHeheActivityJoins"/>
+		<where>
+			a.delFlag = 0
+			<if test="name != null and name != ''">
+				AND a.name LIKE concat('%',#{name},'%')
+			</if>
+			<if test="status != null and status != ''">
+				AND a.status = #{status}
+			</if>
+			<if test="userId != null">
+				AND a.userId = #{userId}
+			</if>
+			<if test="activityStatus == 1">
+				AND a.beginTime <![CDATA[ > ]]> NOW()
+			</if>
+			<if test="activityStatus == 2">
+				AND NOW() BETWEEN a.beginTime AND a.endTime
+			</if>
+			<if test="activityStatus == 3">
+				AND a.endTime <![CDATA[ < ]]> NOW()
+			</if>
+		</where>
+		<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="CmHeheActivity">
+		SELECT 
+			<include refid="cmHeheActivityColumns"/>
+		FROM cm_hehe_activity a
+		<include refid="cmHeheActivityJoins"/>
+		<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="CmHeheActivity"  keyProperty="id" useGeneratedKeys="true">
+		INSERT INTO cm_hehe_activity(
+			name,
+			userId,
+			status,
+			listImage,
+			detailsImage,
+			beginTime,
+			endTime,
+			addTime,
+			delFlag
+		) VALUES (
+			#{name},
+			#{userId},
+			#{status},
+			#{listImage},
+			#{detailsImage},
+			#{beginTime},
+			#{endTime},
+			NOW(),
+			0
+		)
+	</insert>
+	
+	<update id="update">
+		UPDATE cm_hehe_activity SET 	
+			name = #{name},
+			status = #{status},
+			listImage = #{listImage},
+			detailsImage = #{detailsImage},
+			beginTime = #{beginTime},
+			endTime = #{endTime}
+		WHERE id = #{id}
+	</update>
+	
+	<update id="delete">
+		UPDATE cm_hehe_activity SET delFlag = 1 WHERE id = #{id}
+	</update>
+
+	<update id="updateStatusById">
+		UPDATE cm_hehe_activity SET status = #{status} WHERE id = #{id}
+	</update>
+</mapper>

+ 184 - 0
src/main/resources/mappings/modules/hehe/CmHeheActivityProductMapper.xml

@@ -0,0 +1,184 @@
+<?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",
+		a.activityId AS "activityId",
+		a.productId AS "productId",
+		a.sort AS "sort",
+		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
+		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}
+			<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.sort 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,
+			sort,
+			addTime,
+			delFlag
+		) VALUES (
+			#{activityId},
+			#{productId},
+			#{sort},
+			NOW(),
+			0
+		)
+	</insert>
+	
+	<update id="update">
+		UPDATE cm_hehe_activity_product SET 	
+			activityId = #{activityId},
+			productId = #{productId},
+			sort = #{sort},
+			addTime = #{addTime}
+		WHERE id = #{id}
+	</update>
+	
+	<update id="delete">
+		UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE id = #{id}
+	</update>
+
+	<select id="findActivityProductId" resultType="integer">
+		SELECT
+		  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
+		  AND cha.userId = #{userId}
+	</select>
+
+	<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}
+			</foreach>
+		</if>
+		<if test="productId != null">
+			AND a.productId = #{productId}
+		</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>
+	</select>
+
+	<update id="updateSortById">
+		UPDATE cm_hehe_activity_product SET sort = #{sort} WHERE id =#{id}
+	</update>
+
+	<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 activityId = #{activityId} AND productId =#{productId}
+	</delete>
+	
+</mapper>

+ 123 - 0
src/main/webapp/WEB-INF/views/modules/hehe/addActivityProduct.jsp

@@ -0,0 +1,123 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>选择商品</title>
+    <meta name="decorator" content="default"/>
+    <style type="text/css">
+        .table td i {
+            margin: 0 2px;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //弹出框去滚动条
+            top.$('#jbox-content').css("overflow-y", "hidden");
+            show_title(30);
+
+            //			反选
+            $('body').on('click', 'input[name="info"]', function () {
+                var allInputLength = $('input[name="info"]').length - $('input[name="info"]:disabled').length,
+                    allInputCheckedLength = $('input[name="info"]:checked').length,
+                    checkAllEle = $('.check-all');
+//			    判断选中长度和总长度,如果相等就是全选否则取消全选
+                if (allInputLength === allInputCheckedLength) {
+                    checkAllEle.attr('checked', true);
+                } else {
+                    checkAllEle.attr('checked', false);
+                }
+            })
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+
+        function getCheckedItems() {
+            var items = new Array();
+            var $items = $('.check-item:checked');
+            $items.each(function () {
+                //通过拿到的商品ID组合键获取其它值
+                var productId = $(this).val();
+                items.push(productId);
+            });
+            return items;
+        }
+
+        function allCkbfun(ckb) {
+            var isChecked = ckb.checked;
+            $(".check-item").attr('checked', isChecked);
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字和两位小数(金额)
+         */
+        function num(obj) {
+            obj.value = obj.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
+            obj.value = obj.value.replace(/^\./g, ""); //验证第一个字符是数字
+            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个, 清除多余的
+            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
+            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数
+        }
+
+    </script>
+</head>
+<body>
+<form:form id="searchForm" modelAttribute="cmHeheProduct" action="${ctx}/hehe/cmHeheActivityProduct/findProductPage" method="post" class="breadcrumb form-search">
+    <input name="userId" type="hidden" value="${userId}"/>
+    <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" onkeyup="onlynum(this)" maxlength="9" class="input-mini"/>
+        <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="搜索"/>
+        <div class="clearfix"></div>
+    </div>
+</form:form>
+<sys:message content="${message}"/>
+<table class="table table-striped table-bordered table-condensed table-hover">
+    <tr>
+        <th style="width:20px;"><input class="check-all" type="checkbox" onclick="allCkbfun(this);"/></th>
+        <th>商品ID</th>
+        <th>商品图片</th>
+        <th>商品名称</th>
+        <th>供应商名称</th>
+    </tr>
+    <tbody>
+    <c:if test="${not empty page.list}">
+        <c:forEach items="${page.list}" var="item">
+            <tr id="${item.id}" class="itemtr">
+                <th>
+                        <input class="check-item" type="checkbox" name="info" value='${item.productId}'/>
+                </th>
+                <td>${item.productId}</td>
+                <td><img src="${item.mainImage}" width="50px" height="50px"></td>
+                <td>${item.name}</td>
+                <td>${item.shopName}</td>
+            </tr>
+        </c:forEach>
+    </c:if>
+    </tbody>
+</table>
+<c:if test="${empty  page.list}">
+    <p style="text-align: center;"><font color="#1e90ff">暂无数据……</font></p>
+</c:if>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 229 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityForm.jsp

@@ -0,0 +1,229 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
+<html>
+<head>
+	<title>呵呵商城活动管理</title>
+	<meta name="decorator" content="default"/>
+	<style>
+		.iconBox{
+			font-size: 0;
+		}
+		.controls .conList{
+			display: inline-block;
+			margin-right: 15px;
+		}
+		.conList .btn:nth-of-type(1){
+			margin-left: 25px;
+		}
+		.upload-content {
+			margin-top: -70px;
+		}
+		.upload-content .conList .btn:nth-of-type(1) {
+			width: 90px;
+			height: 100px;
+			border: 2px solid #eee;
+			background: #fff;
+			position: relative;
+		}
+		.upload-content .conList .btn:nth-of-type(1)>div {
+			position: absolute;
+			top: 50%;
+			left: 50%;
+			transform: translate(-50%, -50%);
+			color: #666;
+		}
+		.upload-content .conList .btn:nth-of-type(1) span {
+			font-size: 35px;
+		}
+		.upload-content .conList .btn:nth-of-type(1) h5 {
+			color: #666;
+		}
+		.cancel-upload {
+			background: transparent;
+			border: none;
+			box-shadow: none;
+			position: relative;
+			top: -38px;
+			left: -25px;
+			cursor: pointer;
+			z-index: 100;
+		}
+		.upload-content .conList ol li {
+			width: 114px;
+			min-height: 80px;
+			text-align: center;
+			background: #fff;
+			position: relative;
+			top: 120px;
+			margin-left: 2px;
+		}
+		.hide-pic {
+			display: none !important;
+		}
+	</style>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			//$("#name").focus();
+			$("#inputForm").validate({
+				submitHandler: function(form){
+
+					loading('正在提交,请稍等...');
+					form.submit();
+				},
+				errorContainer: "#messageBox",
+				errorPlacement: function(error, element) {
+					$("#messageBox").text("输入有误,请先更正。");
+					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
+						error.appendTo(element.parent().parent());
+					} else {
+						error.insertAfter(element);
+					}
+				}
+			});
+		});
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/hehe/cmHeheUser/">分销者列表</a></li>
+		<li><a href="${ctx}/hehe/cmHeheActivity/list?userId=${cmHeheActivity.userId}">活动列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheActivity/form?id=${cmHeheActivity.id}&userId=${cmHeheActivity.userId}">${not empty cmHeheActivity.id?'编辑':'添加'}活动</a></li>
+	</ul><br/>
+	<form:form id="inputForm" modelAttribute="cmHeheActivity" action="${ctx}/hehe/cmHeheActivity/save" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<form:hidden path="userId"/>
+		<sys:message content="${message}"/>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>活动名称:</label>
+			<div class="controls">
+				<form:input path="name" htmlEscape="false" maxlength="30" style="position:relative" placeholder="最多输入30个汉字" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="control-group iconBox">
+			<label class="control-label"><font color="red">*</font>小程序列表缩略图:</label>
+			<div class="controls upload-content" id="listImageBox">
+				<div class="conList">
+					<form:hidden id="listImage" path="listImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
+					<sys:ckfinder input="listImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+					<br>
+					<label style="margin-left: 150px">建议图片分辨率180px*180px</label>
+				</div>
+			</div>
+		</div>
+		<div class="control-group iconBox">
+			<label class="control-label"><font color="red">*</font>小程序详情主题图:</label>
+			<div class="controls upload-content" id="detailsImageBox">
+				<div class="conList">
+					<form:hidden id="detailsImage" path="detailsImage" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
+					<sys:ckfinder input="detailsImage" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
+					<br>
+					<label style="margin-left: 150px">建议图片分辨率750px*600px</label>
+				</div>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>开始时间:</label>
+			<div class="controls">
+				<input name="beginTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate " required
+					value="<fmt:formatDate value="${cmHeheActivity.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>结束时间:</label>
+			<div class="controls">
+				<input name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate " required
+					value="<fmt:formatDate value="${cmHeheActivity.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
+			</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 required">
+					<form:option value="1" label="启用"/>
+					<form:option value="2" 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 () {
+			$('.upload-content .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
+			$('.upload-content .conList .btn:nth-of-type(2)').after('<img class="cancel-upload" src="/static/images/close-btn1.png">').remove();
+			$('.upload-content .conList').find('.cancel-upload').hide();
+			var observeEle = document.getElementsByClassName('upload-content')[0];
+			var observeEle1 = document.getElementsByClassName('upload-content')[1];
+			var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
+			var MutationObserverConfig = {
+				childList: true,
+				subtree: true,
+				characterData: true
+			};
+			var observer = new MutationObserver(function (mutations) {
+				$.each(mutations, function (index, item) {
+					if (item.type === 'childList') {
+						// 在创建新的 element 时调用
+						var target = $(item.target),
+								thisWrapper = target.closest('.conList'),
+								nextEle = thisWrapper.next();
+						thisWrapper.find('li').css('z-index', 99);
+						thisWrapper.find('.cancel-upload').show();
+						if (nextEle.hasClass('hide-pic')) {
+							nextEle.removeClass('hide-pic');
+						}
+					}
+				})
+			});
+			observer.observe(observeEle, MutationObserverConfig);
+			observer.observe(observeEle1, MutationObserverConfig);
+
+			$('body').on('click', '.cancel-upload', function () {
+				var wrapper = $(this).closest('.conList');
+				wrapper.find('li').css('z-index', '-1');
+				wrapper.find('input').val('');
+				$(this).hide();
+				wrapper.removeClass("hide-pic");
+				wrapper.parent().append(wrapper.clone());
+				wrapper.remove();
+				$(".conList").each(function (i, ele) {
+					if ($(ele).find("input.input-xlarge").val()) {
+						$(ele).next().removeClass("hide-pic")
+					}
+				})
+			});
+			$(window).on("load", function () {
+				setTimeout(function () {
+					$("#listImageBox").find("input.input-xlarge").each(function (i, ele) {
+						if ($(ele).val()) {
+							$(ele).next().find("li").css("z-index", "99");
+							$(ele).parents(".conList").find(".cancel-upload").show();
+							$(ele).parents(".conList").next().removeClass("hide-pic")
+						}
+					})
+					$("#detailsImageBox").find("input.input-xlarge").each(function (i, ele) {
+						if ($(ele).val()) {
+							$(ele).next().find("li").css("z-index", "99");
+							$(ele).parents(".conList").find(".cancel-upload").show();
+							$(ele).parents(".conList").next().removeClass("hide-pic")
+						}
+					})
+				}, 200);
+			});
+		});
+
+		/**
+		 * @param obj
+		 * jquery控制input只能输入数字
+		 */
+		function onlynum(obj) {
+			obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+		}
+	</script>
+</body>
+</html>

+ 130 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityList.jsp

@@ -0,0 +1,130 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ 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() {
+			
+		});
+		function page(n,s){
+			$("#pageNo").val(n);
+			$("#pageSize").val(s);
+			$("#searchForm").submit();
+        	return false;
+        }
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/hehe/cmHeheUser/">分销者列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheActivity/list?userId=${userId}">活动列表</a></li>
+	</ul>
+	<form:form id="searchForm" modelAttribute="cmHeheActivity" action="${ctx}/hehe/cmHeheActivity/" 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}"/>
+		<input name="userId" type="hidden" value="${userId}"/>
+		<div class="ul-form">
+			 <label>活动名称:</label>
+				<form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
+			 <label>小程序状态:</label>
+				<form:select path="status" class="input-medium">
+					<form:option value="" label="全部"/>
+					<form:option value="1" label="启用"/>
+					<form:option value="2" label="停用"/>
+				</form:select>
+			<label>活动状态:</label>
+			<form:select path="activityStatus" class="input-medium">
+				<form:option value="" label="全部"/>
+				<form:option value="1" label="未开始"/>
+				<form:option value="2" label="进行中"/>
+				<form:option value="3" label="已结束"/>
+			</form:select>
+			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+			&nbsp;&nbsp;<input class="btn btn-primary" style="width: 80px" onclick="window.location='${ctx}/hehe/cmHeheActivity/form?userId=${userId}'" 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>
+				<th>活动名称</th>
+				<th>小程序状态</th>
+				<th>活动状态</th>
+				<th>开始时间</th>
+				<th>结束时间</th>
+				<th>创建时间</th>
+				<th>操作</th>
+			</tr>
+		</thead>
+		<tbody>
+		<c:forEach items="${page.list}" var="cmHeheActivity">
+			<tr>
+				<td>
+					${cmHeheActivity.name}
+				</td>
+				<td>
+					<c:if test="${cmHeheActivity.status eq 1 }">
+						<font color="green">已启用</font>
+						<a href="javascript:void(0);" onclick="updateStatus('2','${cmHeheActivity.id}');" >
+							停用
+						</a>
+					</c:if>
+					<c:if test="${cmHeheActivity.status ne 1 }">
+						<font color="red">已停用</font>
+						<a href="javascript:void(0)" onclick="updateStatus('1','${cmHeheActivity.id}');">
+							启用
+						</a>
+					</c:if>
+				</td>
+				<td>${cmHeheActivity.activityStatus eq 1 ? "未开始":cmHeheActivity.activityStatus eq 2 ? "进行中":"已结束"}</td>
+				<td>
+					<fmt:formatDate value="${cmHeheActivity.beginTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmHeheActivity.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmHeheActivity.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<a href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${cmHeheActivity.id}&userId=${userId}">商品列表</a>
+    				<a href="${ctx}/hehe/cmHeheActivity/form?id=${cmHeheActivity.id}">编辑</a>
+					<a href="${ctx}/hehe/cmHeheActivity/delete?id=${cmHeheActivity.id}" onclick="return confirmx('确认要删除该呵呵商城活动吗?', this.href)">删除</a>
+				</td>
+			</tr>
+		</c:forEach>
+		</tbody>
+	</table>
+	<div class="pagination">${page}</div>
+
+<script>
+	//状态修改
+	function updateStatus(status,id){
+		var msg='确定启用该活动吗?';
+		if('2'==status){
+			msg='确定停用该活动吗?';
+		}
+		top.$.jBox.confirm(msg,'系统提示',function(v,h,f){
+			if(v=='ok'){
+				$.post("${ctx}/hehe/cmHeheActivity/updateStatus",{'status':status,'id':id}, function(data) {
+					if(true==data.success){
+						$.jBox.tip(data.msg, 'info');
+					} else {
+						$.jBox.tip(data.msg,'error');
+					}
+					$("#searchForm").submit();
+				},"JSON");//这里返回的类型有:json,html,xml,text
+			}
+			return;
+		},{buttonsFocus:1,persistent: true});
+	}
+</script>
+</body>
+</html>

+ 159 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductForm.jsp

@@ -0,0 +1,159 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
+<html>
+<head>
+    <title>活动商品管理</title>
+    <meta name="decorator" content="default"/>
+    <style>
+        input.short {
+            width: 50px;
+        }
+    </style>
+    <script type="text/javascript">
+        $(document).ready(function () {
+            //$("#name").focus();
+            $("#inputForm").validate({
+                submitHandler: function (form) {
+                    loading('正在提交,请稍等...');
+                    form.submit();
+                },
+                errorContainer: "#messageBox",
+                errorPlacement: function (error, element) {
+                    $("#messageBox").text("输入有误,请先更正。");
+                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                        error.appendTo(element.parent().parent());
+                    } else {
+                        error.insertAfter(element);
+                    }
+                }
+            });
+        });
+
+        $(document).ready(function () {
+            //弹出框去滚动条
+            top.$('#jbox-content').css("overflow-y", "hidden");
+            show_title(30);
+        });
+    </script>
+</head>
+<body>
+<form:form id="inputForm" modelAttribute="cmHeheActivityProduct" action="" method="post" class="form-horizontal">
+    <form:hidden path="id"/>
+    <sys:message content="${message}"/>
+    <br>
+    <div class="control-group">
+        <label>商品名称:</label>${cmHeheActivityProduct.name}
+    </div>
+    <div class="control-group">
+        <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"/>
+                            </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"/>
+                            </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>
+    </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 checkBuyNum(input, index) {
+        if (index > 0) {
+            var beforeNum = $('input[name="activityLadderList[' + (index - 1) + '].buyNum"]').val() * 1;
+            if (input.value * 1 <= beforeNum) {
+                alertx("请输入大于上一阶起订量的值");
+                $(input).val(input.value * 1 + beforeNum);
+            }
+        } else {
+            var minNum = $('input[name="activityLadderList[0].buyNum"]').val() * 1;
+            $('#minBuyNumber').val(minNum);
+        }
+    }
+
+    // 检查阶梯价格
+    function checkBuyPrice(input, index) {
+        if (index > 0) {
+            var beforePrice = $('input[name="activityLadderList[' + (index - 1) + '].buyPrice"]').val() * 1;
+            if (input.value * 1 > beforePrice) {
+                $(input).val('');
+                alertx("请输入小于前一个价格的值");
+            }
+        } else {
+            var price1 = $('#price1').val();
+            if (input.value * 1 > price1) {
+                $(input).val('');
+                alertx("第一个阶梯价格不能大于机构价");
+            }
+        }
+    }
+
+    function onclickSave() {
+        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;
+    }
+</script>
+</body>
+</html>

+ 225 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheActivityProductList.jsp

@@ -0,0 +1,225 @@
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ 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 () {
+
+        });
+
+        function page(n, s) {
+            $("#pageNo").val(n);
+            $("#pageSize").val(s);
+            $("#searchForm").submit();
+            return false;
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/hehe/cmHeheUser/">分销者列表</a></li>
+    <li><a href="${ctx}/hehe/cmHeheActivity/list?userId=${activityProduct.userId}">活动列表</a></li>
+    <li class="active"><a
+            href="${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}">活动商品列表</a>
+    </li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmHeheActivityProduct" action="${ctx}/hehe/cmHeheActivityProduct/"
+           method="post" class="breadcrumb form-search">
+    <input type="hidden" name="activityId" value="${activityProduct.activityId}"/>
+    <input type="hidden" name="userId" value="${activityProduct.userId}"/>
+    <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>商品名称:</label>
+        <form:input path="name" htmlEscape="false" class="input-medium"/>
+        <label>供应商名称:</label>
+        <form:input path="shopName" htmlEscape="false" class="input-medium"/>
+        &nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+        <input class="btn btn-primary" type="button" value="一键排序" onclick="batchSaveSort()" style="margin-left: 15px"/>
+        &nbsp;&nbsp;<input class="btn btn-primary" style="width: 80px" onclick="showSelect()" 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>
+        <th>图片</th>
+        <th>名称</th>
+        <th>供应商</th>
+        <th>售价</th>
+        <th>活动价</th>
+        <th>排序</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmHeheActivityProduct">
+        <tr>
+            <input class="check-item" type="hidden" id="preferredProductSort${cmHeheActivityProduct.id}"
+                   value='${cmHeheActivityProduct.id}-${cmHeheActivityProduct.sort}'/>
+            <td>
+                <img class="mainImage" src="${cmHeheActivityProduct.mainImage}" width="50px" height="50px">
+            </td>
+            <td>
+                    ${cmHeheActivityProduct.name}
+            </td>
+            <td>
+                    ${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>
+            </td>
+            <td>
+                <input id="sort" name="sort" style="width:50px;" value="${cmHeheActivityProduct.sort}"
+                       onkeyup="onlynum(this)" onchange="changeSort(${cmHeheActivityProduct.id},this)">
+            </td>
+            <td>
+                <a href="javascript:void(0);" onclick="showLadder(${cmHeheActivityProduct.id})">编辑</a>
+                <a href="${ctx}/hehe/cmHeheActivityProduct/delete?id=${cmHeheActivityProduct.id}"
+                   onclick="return confirmx('确认要删除该商品吗?', this.href)">删除</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+
+<script>
+    //选择添加
+    function showSelect() {
+        var url = '';
+        var title = '';
+        url = "${ctx}/hehe/cmHeheActivityProduct/findProductPage";
+        title = "添加商品";
+        top.$.jBox("iframe:" + url + "?userId=${activityProduct.userId}", {
+            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);
+                        //添加数据
+                        $.post("${ctx}/hehe/cmHeheActivityProduct/addProducts?activityId=${activityProduct.activityId}&productIds=" + items, function (data) {
+                            if (true == data.success) {
+                                $.jBox.tip(data.info, 'info');
+                                setTimeout(function () {
+                                    window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}"
+                                }, 1300);
+                            } else {
+                                $.jBox.tip(data.info, 'error');
+                            }
+                        }, "JSON");//这里返回的类型有:json,html,xml,text
+                        return true;
+                    } else {
+                        top.$.jBox.tip("请先勾选商品...");
+                        return false;
+                    }
+                }
+                return true;
+            }
+        });
+    }
+
+    //修改排序值
+    function changeSort(id, sortThis) {
+        var value = sortThis.value;
+        $("#preferredProductSort" + id).val(id + "-" + value);
+    }
+
+    //批量保存排序
+    function batchSaveSort() {
+        var items = new Array();
+        var $items = $('.check-item');
+        $items.each(function () {
+            items.push($(this).val());
+        });
+        //保存批量排序
+        $.post("${ctx}/hehe/cmHeheActivityProduct/batchSaveSort?sortList=" + items, function (data) {
+            if (true == data.success) {
+                $.jBox.tip(data.msg, 'info');
+                window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}";
+            } else {
+                $.jBox.tip(data.msg, 'error');
+            }
+        }, "JSON");//这里返回的类型有:json,html,xml,text
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+
+    function showLadder(id) {
+        var url = '';
+        var title = '';
+        url = "${ctx}/hehe/cmHeheActivityProduct/form?id=" + id;
+        title = "编辑";
+        top.$.jBox("iframe:" + url, {
+            iframeScrolling: 'yes',
+            width: 550,
+            height: 450,
+            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 params = $jboxFrame[0].contentWindow.onclickSave();
+                    console.log(params);
+                    $.post("${ctx}/hehe/cmHeheActivityProduct/saveActivityLadder?params=" + params + "&id=" + id, function (data) {
+                        if (true == data.success) {
+                            $.jBox.tip(data.info, 'info');
+                            setTimeout(function () {
+                                window.location.href = "${ctx}/hehe/cmHeheActivityProduct/list?activityId=${activityProduct.activityId}&userId=${activityProduct.userId}"
+                            }, 1300);
+                        } else {
+                            $.jBox.tip(data.info, 'error');
+                        }
+                    }, "JSON");//这里返回的类型有:json,html,xml,text
+                }
+                return true;
+            }
+        });
+    }
+</script>
+</body>
+</html>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheImageForm.jsp

@@ -100,7 +100,7 @@
 			<label class="control-label"><font color="red">*</font>图片:</label>
 			<div class="controls upload-content" id="imageBox">
 				<div class="conList">
-					<form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge"/>
+					<form:hidden id="image" path="image" htmlEscape="false" maxlength="255" class="input-xlarge required"/>
 					<sys:ckfinder input="image" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>
 					<br>
 					<label style="margin-left: 20px">建议图片分辨率750px*366px</label>

+ 1 - 1
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheUserList.jsp

@@ -69,7 +69,7 @@
 				</td>
 				<td>
     				<a href="${ctx}/hehe/cmHeheUser/form?id=${cmHeheUser.id}">编辑</a>
-					<a href="">活动列表</a>
+					<a href="${ctx}/hehe/cmHeheActivity/list?userId=${cmHeheUser.id}">活动列表</a>
 				</td>
 			</tr>
 		</c:forEach>

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

@@ -34,10 +34,6 @@
            class="breadcrumb form-search">
     <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
     <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-    <form:hidden path="productIds"/>
-    <form:hidden path="promotionType"/>
-    <form:hidden path="ids"/>
-    <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)"/>