Parcourir la source

呵呵商城优惠券part1

Aslee il y a 3 ans
Parent
commit
b4d0fce8dc
29 fichiers modifiés avec 4358 ajouts et 0 suppressions
  1. 46 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheCouponDao.java
  2. 40 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheDiscountDao.java
  3. 7 0
      src/main/java/com/caimei/modules/hehe/dao/CmHeheProductDao.java
  4. 247 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheCoupon.java
  5. 104 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheCouponProduct.java
  6. 77 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheCouponUser.java
  7. 92 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheDiscount.java
  8. 104 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheDiscountProduct.java
  9. 77 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheDiscountUser.java
  10. 204 0
      src/main/java/com/caimei/modules/hehe/entity/CmHeheReceiveUser.java
  11. 191 0
      src/main/java/com/caimei/modules/hehe/service/CmHeheCouponService.java
  12. 157 0
      src/main/java/com/caimei/modules/hehe/service/CmHeheDiscountService.java
  13. 139 0
      src/main/java/com/caimei/modules/hehe/web/CmHeheCouponController.java
  14. 117 0
      src/main/java/com/caimei/modules/hehe/web/CmHeheDiscountController.java
  15. 18 0
      src/main/java/com/caimei/modules/user/entity/CmUser.java
  16. 318 0
      src/main/resources/mappings/modules/hehe/CmHeheCouponMapper.xml
  17. 176 0
      src/main/resources/mappings/modules/hehe/CmHeheDiscountMapper.xml
  18. 33 0
      src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml
  19. 618 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponForm.jsp
  20. 118 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponList.jsp
  21. 491 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountForm.jsp
  22. 114 0
      src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountList.jsp
  23. 117 0
      src/main/webapp/WEB-INF/views/modules/hehe/receiveDetailsList.jsp
  24. 115 0
      src/main/webapp/WEB-INF/views/modules/hehe/receiveUserList.jsp
  25. 134 0
      src/main/webapp/WEB-INF/views/modules/hehe/toAddCouponProduct.jsp
  26. 137 0
      src/main/webapp/WEB-INF/views/modules/hehe/toAddCouponUser.jsp
  27. 134 0
      src/main/webapp/WEB-INF/views/modules/hehe/toAddDiscountProduct.jsp
  28. 137 0
      src/main/webapp/WEB-INF/views/modules/hehe/toAddDiscountUser.jsp
  29. 96 0
      src/main/webapp/WEB-INF/views/modules/hehe/userAllCouponList.jsp

+ 46 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheCouponDao.java

@@ -0,0 +1,46 @@
+package com.caimei.modules.hehe.dao;
+
+import com.caimei.modules.hehe.entity.CmHeheCouponProduct;
+import com.caimei.modules.hehe.entity.CmHeheCouponUser;
+import com.caimei.modules.hehe.entity.CmHeheReceiveUser;
+import com.caimei.modules.user.entity.CmUser;
+import com.thinkgem.jeesite.common.persistence.CrudDao;
+import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
+import com.caimei.modules.hehe.entity.CmHeheCoupon;
+
+import java.util.List;
+
+/**
+ * 呵呵商城优惠券DAO接口
+ * @author Aslee
+ * @version 2021-10-20
+ */
+@MyBatisDao
+public interface CmHeheCouponDao extends CrudDao<CmHeheCoupon> {
+
+    List<Integer> findCouponProductIds(String id);
+
+    void insertCouponProduct(CmHeheCouponProduct a);
+
+    void updateCouponProduct(CmHeheCouponProduct a);
+
+    void deleteCouponProduct(Integer id);
+
+    List<CmHeheCouponProduct> findCouponProductList(String id);
+
+    List<CmUser> findAllUser(CmUser user);
+
+    void insertCouponUser(CmHeheCouponUser a);
+
+    List<Integer> findCouponUserIds(String id);
+
+    void deleteCouponUser(Integer id);
+
+    List<CmHeheCouponUser> findCouponUserList(String id);
+
+    List<CmHeheReceiveUser> allUserList(CmHeheReceiveUser cmHeheReceiveUser);
+
+    List<CmHeheReceiveUser> receiveUserList(CmHeheReceiveUser cmHeheReceiveUser);
+
+    List<CmHeheCoupon> receiveCouponList(CmHeheCoupon cmHeheCoupon);
+}

+ 40 - 0
src/main/java/com/caimei/modules/hehe/dao/CmHeheDiscountDao.java

@@ -0,0 +1,40 @@
+package com.caimei.modules.hehe.dao;
+
+import com.caimei.modules.hehe.entity.CmHeheCouponProduct;
+import com.caimei.modules.hehe.entity.CmHeheDiscountProduct;
+import com.caimei.modules.hehe.entity.CmHeheDiscountUser;
+import com.thinkgem.jeesite.common.persistence.CrudDao;
+import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
+import com.caimei.modules.hehe.entity.CmHeheDiscount;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * 呵呵商城内部优惠DAO接口
+ * @author Aslee
+ * @version 2021-10-25
+ */
+@MyBatisDao
+public interface CmHeheDiscountDao extends CrudDao<CmHeheDiscount> {
+
+    void updateStatus(@Param("id") Integer id, @Param("status") Integer status);
+
+    List<Integer> findDiscountProductIds(String id);
+
+    void insertDiscountProduct(CmHeheDiscountProduct a);
+
+    void updateDiscountProduct(CmHeheDiscountProduct a);
+
+    void deleteDiscountProduct(Integer id);
+
+    List<Integer> findDiscountUserIds(String id);
+
+    void insertDiscountUser(CmHeheDiscountUser a);
+
+    void deleteDiscountUser(Integer id);
+
+    List<CmHeheDiscountProduct> findDiscountProductList(String id);
+
+    List<CmHeheDiscountUser> findDiscountUserList(String id);
+}

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

@@ -39,4 +39,11 @@ public interface CmHeheProductDao extends CrudDao<CmHeheProduct> {
      * @param productId
      */
     void deleteActivityProduct(Integer productId);
+
+    /**
+     *
+     * @param product
+     * @return
+     */
+    List<Product> findCouponProduct(Product product);
 }

+ 247 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheCoupon.java

@@ -0,0 +1,247 @@
+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 Aslee
+ * @version 2021-10-20
+ */
+public class CmHeheCoupon extends DataEntity<CmHeheCoupon> {
+	
+	private static final long serialVersionUID = 1L;
+	private String name;		// 优惠券名称
+	private Double couponAmount;		// 优惠券金额(面值)
+	private Double touchPrice;		// 优惠满减条件金额
+	private Integer noThresholdFlag;		// 无门槛标记 0否 1是
+	private Date startTime;		// 上架时间
+	private Date endTime;		// 下架时间
+	private Integer startNowFlag;		// 立即上架标记 0否 1是
+	private Integer permanentFlag;		// 永久上架标记 0否 1是
+	private Integer couponType;		// 劵类型 1活动券 2专享券 3新人券 4好友分享券 5好友消费券
+	private Integer productType;		// 优惠商品:1全商城商品 2指定商品(活动券有效)
+	private Integer receivePeriod;		// 领取期限(天)
+	private Integer receiveFlag;		// 领取期限同上下架时间标记(在上下架期间内都可领取)
+	private Integer usePeriod;		// 使用期限(天)
+
+	private Integer status;			// 优惠券状态:1待上架,2已上架,3已下架
+	private String productInfo;        //商品json数据
+	private String userInfo;        //用户json数据
+	private Date receiveTime;		//领取时间
+	private Date validPeriod;		//优惠券有效期
+	private Integer useStatus;		//使用状态:1未使用,2已使用
+	private Integer validFlag;		//优惠券是否有效:0失效,1有效
+	private Date useTime;			//使用时间
+	private String orderNo;			//订单号
+	private Integer orderId;		//订单id
+	private Integer userId;			//呵呵商城用户id
+
+
+
+	public CmHeheCoupon() {
+		super();
+	}
+
+	public CmHeheCoupon(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;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getStartTime() {
+		return startTime;
+	}
+
+	public void setStartTime(Date startTime) {
+		this.startTime = startTime;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getEndTime() {
+		return endTime;
+	}
+
+	public void setEndTime(Date endTime) {
+		this.endTime = endTime;
+	}
+
+	public Double getCouponAmount() {
+		return couponAmount;
+	}
+
+	public void setCouponAmount(Double couponAmount) {
+		this.couponAmount = couponAmount;
+	}
+
+	public Double getTouchPrice() {
+		return touchPrice;
+	}
+
+	public void setTouchPrice(Double touchPrice) {
+		this.touchPrice = touchPrice;
+	}
+
+	public Integer getNoThresholdFlag() {
+		return noThresholdFlag;
+	}
+
+	public void setNoThresholdFlag(Integer noThresholdFlag) {
+		this.noThresholdFlag = noThresholdFlag;
+	}
+
+	public Integer getStartNowFlag() {
+		return startNowFlag;
+	}
+
+	public void setStartNowFlag(Integer startNowFlag) {
+		this.startNowFlag = startNowFlag;
+	}
+
+	public Integer getPermanentFlag() {
+		return permanentFlag;
+	}
+
+	public void setPermanentFlag(Integer permanentFlag) {
+		this.permanentFlag = permanentFlag;
+	}
+
+	public Integer getCouponType() {
+		return couponType;
+	}
+
+	public void setCouponType(Integer couponType) {
+		this.couponType = couponType;
+	}
+
+	public Integer getProductType() {
+		return productType;
+	}
+
+	public void setProductType(Integer productType) {
+		this.productType = productType;
+	}
+
+	public Integer getReceivePeriod() {
+		return receivePeriod;
+	}
+
+	public void setReceivePeriod(Integer receivePeriod) {
+		this.receivePeriod = receivePeriod;
+	}
+
+	public Integer getReceiveFlag() {
+		return receiveFlag;
+	}
+
+	public void setReceiveFlag(Integer receiveFlag) {
+		this.receiveFlag = receiveFlag;
+	}
+
+	public Integer getUsePeriod() {
+		return usePeriod;
+	}
+
+	public void setUsePeriod(Integer usePeriod) {
+		this.usePeriod = usePeriod;
+	}
+
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+
+	public String getProductInfo() {
+		return productInfo;
+	}
+
+	public void setProductInfo(String productInfo) {
+		this.productInfo = productInfo;
+	}
+
+	public String getUserInfo() {
+		return userInfo;
+	}
+
+	public void setUserInfo(String userInfo) {
+		this.userInfo = userInfo;
+	}
+
+	public Date getReceiveTime() {
+		return receiveTime;
+	}
+
+	public void setReceiveTime(Date receiveTime) {
+		this.receiveTime = receiveTime;
+	}
+
+	public Date getValidPeriod() {
+		return validPeriod;
+	}
+
+	public void setValidPeriod(Date validPeriod) {
+		this.validPeriod = validPeriod;
+	}
+
+	public Integer getUseStatus() {
+		return useStatus;
+	}
+
+	public void setUseStatus(Integer useStatus) {
+		this.useStatus = useStatus;
+	}
+
+	public Date getUseTime() {
+		return useTime;
+	}
+
+	public void setUseTime(Date useTime) {
+		this.useTime = useTime;
+	}
+
+	public String getOrderNo() {
+		return orderNo;
+	}
+
+	public void setOrderNo(String orderNo) {
+		this.orderNo = orderNo;
+	}
+
+	public Integer getOrderId() {
+		return orderId;
+	}
+
+	public void setOrderId(Integer orderId) {
+		this.orderId = orderId;
+	}
+
+	public Integer getUserId() {
+		return userId;
+	}
+
+	public void setUserId(Integer userId) {
+		this.userId = userId;
+	}
+
+	public Integer getValidFlag() {
+		return validFlag;
+	}
+
+	public void setValidFlag(Integer validFlag) {
+		this.validFlag = validFlag;
+	}
+}

+ 104 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheCouponProduct.java

@@ -0,0 +1,104 @@
+package com.caimei.modules.hehe.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/10/22
+ */
+public class CmHeheCouponProduct implements Serializable {
+    private Integer id;
+    private Integer couponId;       //优惠券id
+    private Integer productId;      //商品id
+    private Integer status;        //状态 0停用 1启用
+    private Integer shopId;     //供应商id(对应店铺券)
+    private Integer sort;       //排序值
+    private Date addTime;       //添加时间
+
+    private String productName;     //商品名称
+    private String image;       //商品图片
+    private String shopName;        //供应商名称
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getCouponId() {
+        return couponId;
+    }
+
+    public void setCouponId(Integer couponId) {
+        this.couponId = couponId;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+}

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

@@ -0,0 +1,77 @@
+package com.caimei.modules.hehe.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/10/22
+ */
+public class CmHeheCouponUser implements Serializable {
+    private Integer id;
+    private Integer couponId;       //优惠券id
+    private Integer userId;      //用户id(对应专享券)
+    private Date addTime;       //添加时间
+
+    private String nickName;
+    private Integer userIdentity;
+    private String mobile;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getCouponId() {
+        return couponId;
+    }
+
+    public void setCouponId(Integer couponId) {
+        this.couponId = couponId;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public Integer getUserIdentity() {
+        return userIdentity;
+    }
+
+    public void setUserIdentity(Integer userIdentity) {
+        this.userIdentity = userIdentity;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+}

+ 92 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheDiscount.java

@@ -0,0 +1,92 @@
+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 Aslee
+ * @version 2021-10-25
+ */
+public class CmHeheDiscount extends DataEntity<CmHeheDiscount> {
+	
+	private static final long serialVersionUID = 1L;
+	private String title;		// 标题
+	private Integer discount;		// 折扣率
+	private Integer status;		// 状态
+	private Integer productType;		// 优惠商品
+	private Date addTime;		// 创建时间
+
+
+	private String productInfo;        //商品json数据
+	private String userInfo;        //用户json数据
+	
+	public CmHeheDiscount() {
+		super();
+	}
+
+	public CmHeheDiscount(String id){
+		super(id);
+	}
+
+	@Length(min=0, max=30, message="标题长度必须介于 0 和 30 之间")
+	public String getTitle() {
+		return title;
+	}
+
+	public void setTitle(String title) {
+		this.title = title;
+	}
+	
+	public Integer getDiscount() {
+		return discount;
+	}
+
+	public void setDiscount(Integer discount) {
+		this.discount = discount;
+	}
+	
+	public Integer getStatus() {
+		return status;
+	}
+
+	public void setStatus(Integer status) {
+		this.status = status;
+	}
+	
+	public Integer getProductType() {
+		return productType;
+	}
+
+	public void setProductType(Integer productType) {
+		this.productType = productType;
+	}
+	
+	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+	public Date getAddTime() {
+		return addTime;
+	}
+
+	public void setAddTime(Date addTime) {
+		this.addTime = addTime;
+	}
+
+	public String getProductInfo() {
+		return productInfo;
+	}
+
+	public void setProductInfo(String productInfo) {
+		this.productInfo = productInfo;
+	}
+
+	public String getUserInfo() {
+		return userInfo;
+	}
+
+	public void setUserInfo(String userInfo) {
+		this.userInfo = userInfo;
+	}
+}

+ 104 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheDiscountProduct.java

@@ -0,0 +1,104 @@
+package com.caimei.modules.hehe.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/10/22
+ */
+public class CmHeheDiscountProduct implements Serializable {
+    private Integer id;
+    private Integer discountId;       //内部优惠id
+    private Integer productId;      //商品id
+    private Integer status;        //状态 0停用 1启用
+    private Integer shopId;     //供应商id(对应店铺券)
+    private Integer sort;       //排序值
+    private Date addTime;       //添加时间
+
+    private String productName;     //商品名称
+    private String image;       //商品图片
+    private String shopName;        //供应商名称
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getDiscountId() {
+        return discountId;
+    }
+
+    public void setDiscountId(Integer discountId) {
+        this.discountId = discountId;
+    }
+
+    public Integer getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Integer productId) {
+        this.productId = productId;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getShopId() {
+        return shopId;
+    }
+
+    public void setShopId(Integer shopId) {
+        this.shopId = shopId;
+    }
+
+    public Integer getSort() {
+        return sort;
+    }
+
+    public void setSort(Integer sort) {
+        this.sort = sort;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public String getProductName() {
+        return productName;
+    }
+
+    public void setProductName(String productName) {
+        this.productName = productName;
+    }
+
+    public String getImage() {
+        return image;
+    }
+
+    public void setImage(String image) {
+        this.image = image;
+    }
+
+    public String getShopName() {
+        return shopName;
+    }
+
+    public void setShopName(String shopName) {
+        this.shopName = shopName;
+    }
+}

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

@@ -0,0 +1,77 @@
+package com.caimei.modules.hehe.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/10/22
+ */
+public class CmHeheDiscountUser implements Serializable {
+    private Integer id;
+    private Integer discountId;       //内部优惠id
+    private Integer userId;      //用户id(对应专享券)
+    private Date addTime;       //添加时间
+
+    private String nickName;
+    private Integer userIdentity;
+    private String mobile;
+
+    public Integer getId() {
+        return id;
+    }
+
+    public void setId(Integer id) {
+        this.id = id;
+    }
+
+    public Integer getDiscountId() {
+        return discountId;
+    }
+
+    public void setDiscountId(Integer discountId) {
+        this.discountId = discountId;
+    }
+
+    public Date getAddTime() {
+        return addTime;
+    }
+
+    public void setAddTime(Date addTime) {
+        this.addTime = addTime;
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public Integer getUserIdentity() {
+        return userIdentity;
+    }
+
+    public void setUserIdentity(Integer userIdentity) {
+        this.userIdentity = userIdentity;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+}

+ 204 - 0
src/main/java/com/caimei/modules/hehe/entity/CmHeheReceiveUser.java

@@ -0,0 +1,204 @@
+package com.caimei.modules.hehe.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+import org.hibernate.validator.constraints.Length;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 优惠券管理Entity
+ *
+ * @author plf
+ * @version 2021-08-10
+ */
+public class CmHeheReceiveUser extends DataEntity<CmHeheReceiveUser> {
+
+    private static final long serialVersionUID = 1L;
+    private Integer userId;        // 呵呵商城用户Id
+    private Integer couponId;        // 优惠券id
+    private Integer orderId;        // 订单id
+    private Integer returnedId;     //退款id,订单退回时有效
+    private Integer source;        // 领取渠道:1小程序 2订单退回
+    private Integer status;        // 使用状态 1未使用 2已使用
+    private Date receiveTime;        // 领取时间
+    private Date useTime;        // 使用时间
+
+
+    private String nickName;    //微信昵称
+    private String mobile;      //手机号
+    private Integer userIdentity;       // 用户身份:1普通用户 2分销者
+    private Integer couponType;        // 劵类型 1活动券 2专享券 3新人券 4好友分享券 5好友消费券
+    private BigDecimal couponAmount;        // 优惠券金额(面值)
+    private BigDecimal touchPrice;        // 优惠满减条件金额
+    private Integer couponStatus;    // 状态 0未生效 1已生效 2已关闭 3已失效
+    private Integer receiveNum;        //领取券的总数
+    private Integer ableNum;        //可用券的数量
+    private Date validPeriod;       //优惠券有效期
+    private Integer validFlag;      //优惠券是否有效:0失效,1有效
+
+
+
+    public CmHeheReceiveUser() {
+        super();
+    }
+
+    public CmHeheReceiveUser(String id) {
+        super(id);
+    }
+
+    public Integer getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Integer userId) {
+        this.userId = userId;
+    }
+
+    public Integer getCouponId() {
+        return couponId;
+    }
+
+    public void setCouponId(Integer couponId) {
+        this.couponId = couponId;
+    }
+
+    public Integer getOrderId() {
+        return orderId;
+    }
+
+    public void setOrderId(Integer orderId) {
+        this.orderId = orderId;
+    }
+
+    public Integer getReturnedId() {
+        return returnedId;
+    }
+
+    public void setReturnedId(Integer returnedId) {
+        this.returnedId = returnedId;
+    }
+
+    public Integer getSource() {
+        return source;
+    }
+
+    public void setSource(Integer source) {
+        this.source = source;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date getReceiveTime() {
+        return receiveTime;
+    }
+
+    public void setReceiveTime(Date receiveTime) {
+        this.receiveTime = receiveTime;
+    }
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    public Date getUseTime() {
+        return useTime;
+    }
+
+    public void setUseTime(Date useTime) {
+        this.useTime = useTime;
+    }
+
+    public String getNickName() {
+        return nickName;
+    }
+
+    public void setNickName(String nickName) {
+        this.nickName = nickName;
+    }
+
+    public Integer getCouponType() {
+        return couponType;
+    }
+
+    public void setCouponType(Integer couponType) {
+        this.couponType = couponType;
+    }
+
+    public BigDecimal getCouponAmount() {
+        return couponAmount;
+    }
+
+    public void setCouponAmount(BigDecimal couponAmount) {
+        this.couponAmount = couponAmount;
+    }
+
+    public BigDecimal getTouchPrice() {
+        return touchPrice;
+    }
+
+    public void setTouchPrice(BigDecimal touchPrice) {
+        this.touchPrice = touchPrice;
+    }
+
+    public Integer getCouponStatus() {
+        return couponStatus;
+    }
+
+    public void setCouponStatus(Integer couponStatus) {
+        this.couponStatus = couponStatus;
+    }
+
+    public Integer getReceiveNum() {
+        return receiveNum;
+    }
+
+    public void setReceiveNum(Integer receiveNum) {
+        this.receiveNum = receiveNum;
+    }
+
+    public Integer getAbleNum() {
+        return ableNum;
+    }
+
+    public void setAbleNum(Integer ableNum) {
+        this.ableNum = ableNum;
+    }
+
+    public String getMobile() {
+        return mobile;
+    }
+
+    public void setMobile(String mobile) {
+        this.mobile = mobile;
+    }
+
+    public Integer getUserIdentity() {
+        return userIdentity;
+    }
+
+    public void setUserIdentity(Integer userIdentity) {
+        this.userIdentity = userIdentity;
+    }
+
+    public Date getValidPeriod() {
+        return validPeriod;
+    }
+
+    public void setValidPeriod(Date validPeriod) {
+        this.validPeriod = validPeriod;
+    }
+
+    public Integer getValidFlag() {
+        return validFlag;
+    }
+
+    public void setValidFlag(Integer validFlag) {
+        this.validFlag = validFlag;
+    }
+}

+ 191 - 0
src/main/java/com/caimei/modules/hehe/service/CmHeheCouponService.java

@@ -0,0 +1,191 @@
+package com.caimei.modules.hehe.service;
+
+import java.util.Date;
+import java.util.List;
+
+import com.alibaba.fastjson.JSON;
+import com.caimei.modules.coupon.entity.CmCoupon;
+import com.caimei.modules.coupon.entity.CmCouponAssociate;
+import com.caimei.modules.coupon.entity.CmCouponClub;
+import com.caimei.modules.hehe.dao.CmHeheFloorProductDao;
+import com.caimei.modules.hehe.dao.CmHeheProductDao;
+import com.caimei.modules.hehe.dao.CmHeheUserDao;
+import com.caimei.modules.hehe.entity.*;
+import com.caimei.modules.product.dao.ProductDao;
+import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.user.entity.CmUser;
+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;
+
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
+import com.caimei.modules.hehe.dao.CmHeheCouponDao;
+
+/**
+ * 呵呵商城优惠券Service
+ * @author Aslee
+ * @version 2021-10-20
+ */
+@Service
+@Transactional(readOnly = true)
+public class CmHeheCouponService extends CrudService<CmHeheCouponDao, CmHeheCoupon> {
+
+	@Autowired
+	private CmHeheFloorProductDao cmHeheFloorProductDao;
+
+	@Autowired
+	private CmHeheUserDao cmHeheUserDao;
+
+	@Autowired
+	private CmHeheCouponDao cmHeheCouponDao;
+
+	public CmHeheCoupon get(String id) {
+		return super.get(id);
+	}
+
+	public List<CmHeheCoupon> findList(CmHeheCoupon cmHeheCoupon) {
+		return super.findList(cmHeheCoupon);
+	}
+
+	public Page<CmHeheCoupon> findPage(Page<CmHeheCoupon> page, CmHeheCoupon cmHeheCoupon) {
+		Page<CmHeheCoupon> couponPage = super.findPage(page, cmHeheCoupon);
+		List<CmHeheCoupon> couponList = couponPage.getList();
+		couponList.forEach(this::setCouponStatus);
+		return couponPage;
+	}
+
+	@Transactional(readOnly = false)
+	public void save(CmHeheCoupon cmHeheCoupon) {
+		super.save(cmHeheCoupon);
+		Date date = new Date();
+		List<Integer> productIds = cmHeheCouponDao.findCouponProductIds(cmHeheCoupon.getId());
+		// 保存商品
+		if (StringUtils.isNotBlank(cmHeheCoupon.getProductInfo())) {
+			List<CmHeheCouponProduct> productList = JSON.parseArray(cmHeheCoupon.getProductInfo(), CmHeheCouponProduct.class);
+			productList.forEach(a -> {
+				if (a.getId() == null) {
+					a.setCouponId(Integer.valueOf(cmHeheCoupon.getId()));
+					a.setAddTime(date);
+					cmHeheCouponDao.insertCouponProduct(a);
+				} else {
+					productIds.removeIf(id -> id.equals(a.getId()));
+					cmHeheCouponDao.updateCouponProduct(a);
+				}
+			});
+		}
+		//删除商品
+		if (productIds != null && productIds.size() > 0) {
+			productIds.forEach(id -> {
+				cmHeheCouponDao.deleteCouponProduct(id);
+			});
+		}
+		List<Integer> userIds = cmHeheCouponDao.findCouponUserIds(cmHeheCoupon.getId());
+		// 保存用户
+		if (StringUtils.isNotBlank(cmHeheCoupon.getUserInfo())) {
+			List<CmHeheCouponUser> userList = JSON.parseArray(cmHeheCoupon.getUserInfo(), CmHeheCouponUser.class);
+			userList.forEach(a -> {
+				if (a.getId() == null) {
+					a.setCouponId(Integer.valueOf(cmHeheCoupon.getId()));
+					a.setAddTime(date);
+					cmHeheCouponDao.insertCouponUser(a);
+				} else {
+					userIds.removeIf(id -> id.equals(a.getId()));
+				}
+			});
+		}
+		//删除用户
+		if (userIds != null && userIds.size() > 0) {
+			userIds.forEach(id -> {
+				cmHeheCouponDao.deleteCouponUser(id);
+			});
+		}
+	}
+
+	@Transactional(readOnly = false)
+	public void delete(CmHeheCoupon cmHeheCoupon) {
+		super.delete(cmHeheCoupon);
+	}
+
+
+	public void setCouponStatus(CmHeheCoupon cmHeheCoupon) {
+		Date date = new Date();
+		if (cmHeheCoupon != null) {
+			if (date.compareTo(cmHeheCoupon.getStartTime()) < 0) {
+				cmHeheCoupon.setStatus(1);
+			} else if (date.compareTo(cmHeheCoupon.getEndTime()) > 0) {
+				cmHeheCoupon.setStatus(3);
+			} else {
+				cmHeheCoupon.setStatus(2);
+			}
+		}
+	}
+
+	public Page<Product> findProductList(Page<Product> productPage, Product product) {
+		product.setPage(productPage);
+		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());
+				if (StringUtils.isNotBlank(product.getProductIds()) && product.getProductIds().contains(item.getProductID().toString())) {
+					item.setStoreStatus(true);
+				}
+			});
+		}
+		productPage.setList(productList);
+		return productPage;
+	}
+
+	public List<CmHeheCouponProduct> findCouponProductList(CmHeheCoupon cmHeheCoupon) {
+		List<CmHeheCouponProduct> productList = cmHeheCouponDao.findCouponProductList(cmHeheCoupon.getId());
+		if (productList != null && productList.size() > 0) {
+			productList.forEach(item -> {
+				item.setImage(AppUtils.getImageURL("product", item.getImage(), 0, "https://www.caimei365.com/"));
+			});
+		}
+		return productList;
+	}
+
+	public Page<CmUser> findUserList(Page<CmUser> cmUserPage, CmUser user) {
+		user.setPage(cmUserPage);
+		List<CmUser> userList = cmHeheCouponDao.findAllUser(user);
+		if (userList != null && userList.size() > 0) {
+			userList.forEach(item -> {
+				item.setUserIds(user.getUserIds());
+				if (StringUtils.isNotBlank(user.getUserIds()) && user.getUserIds().contains(item.getId())) {
+					item.setStoreStatus(true);
+				}
+			});
+		}
+		cmUserPage.setList(userList);
+		return cmUserPage;
+	}
+
+	public List<CmHeheCouponUser> findCouponUserList(CmHeheCoupon cmHeheCoupon) {
+		return cmHeheCouponDao.findCouponUserList(cmHeheCoupon.getId());
+	}
+
+	public Page<CmHeheReceiveUser> findReceiveUserList(Page<CmHeheReceiveUser> cmHeheReceiveUserPage, CmHeheReceiveUser cmHeheReceiveUser) {
+		cmHeheReceiveUser.setPage(cmHeheReceiveUserPage);
+		List<CmHeheReceiveUser> receiveUserList = cmHeheCouponDao.receiveUserList(cmHeheReceiveUser);
+		cmHeheReceiveUserPage.setList(receiveUserList);
+		return cmHeheReceiveUserPage;
+	}
+
+	public Page<CmHeheReceiveUser> findAllUserList(Page<CmHeheReceiveUser> cmHeheReceiveUserPage, CmHeheReceiveUser cmHeheReceiveUser) {
+		cmHeheReceiveUser.setPage(cmHeheReceiveUserPage);
+		List<CmHeheReceiveUser> allUserList = cmHeheCouponDao.allUserList(cmHeheReceiveUser);
+		cmHeheReceiveUserPage.setList(allUserList);
+		return cmHeheReceiveUserPage;
+	}
+
+	public Page<CmHeheCoupon> findReceiveCouponList(Page<CmHeheCoupon> cmHeheCouponPage, CmHeheCoupon cmHeheCoupon) {
+		cmHeheCoupon.setPage(cmHeheCouponPage);
+		List<CmHeheCoupon> receiveCouponList = cmHeheCouponDao.receiveCouponList(cmHeheCoupon);
+		cmHeheCouponPage.setList(receiveCouponList);
+		return cmHeheCouponPage;
+	}
+}

+ 157 - 0
src/main/java/com/caimei/modules/hehe/service/CmHeheDiscountService.java

@@ -0,0 +1,157 @@
+package com.caimei.modules.hehe.service;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.alibaba.fastjson.JSON;
+import com.caimei.modules.hehe.dao.CmHeheCouponDao;
+import com.caimei.modules.hehe.dao.CmHeheFloorProductDao;
+import com.caimei.modules.hehe.entity.*;
+import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.user.entity.CmUser;
+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;
+
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.service.CrudService;
+import com.caimei.modules.hehe.dao.CmHeheDiscountDao;
+
+/**
+ * 呵呵商城内部优惠Service
+ * @author Aslee
+ * @version 2021-10-25
+ */
+@Service
+@Transactional(readOnly = true)
+public class CmHeheDiscountService extends CrudService<CmHeheDiscountDao, CmHeheDiscount> {
+	@Autowired
+	private CmHeheDiscountDao cmHeheDiscountDao;
+
+	@Autowired
+	private CmHeheCouponDao cmHeheCouponDao;
+
+	@Autowired
+	private CmHeheFloorProductDao cmHeheFloorProductDao;
+
+	public CmHeheDiscount get(String id) {
+		return super.get(id);
+	}
+	
+	public List<CmHeheDiscount> findList(CmHeheDiscount cmHeheDiscount) {
+		return super.findList(cmHeheDiscount);
+	}
+	
+	public Page<CmHeheDiscount> findPage(Page<CmHeheDiscount> page, CmHeheDiscount cmHeheDiscount) {
+		return super.findPage(page, cmHeheDiscount);
+	}
+	
+	@Transactional(readOnly = false)
+	public void save(CmHeheDiscount cmHeheDiscount) {
+		super.save(cmHeheDiscount);
+		Date date = new Date();
+		List<Integer> productIds = cmHeheDiscountDao.findDiscountProductIds(cmHeheDiscount.getId());
+		// 保存商品
+		if (StringUtils.isNotBlank(cmHeheDiscount.getProductInfo())) {
+			List<CmHeheDiscountProduct> productList = JSON.parseArray(cmHeheDiscount.getProductInfo(), CmHeheDiscountProduct.class);
+			productList.forEach(a -> {
+				if (a.getId() == null) {
+					a.setDiscountId(Integer.valueOf(cmHeheDiscount.getId()));
+					a.setAddTime(date);
+					cmHeheDiscountDao.insertDiscountProduct(a);
+				} else {
+					productIds.removeIf(id -> id.equals(a.getId()));
+					cmHeheDiscountDao.updateDiscountProduct(a);
+				}
+			});
+		}
+		//删除商品
+		if (productIds != null && productIds.size() > 0) {
+			productIds.forEach(id -> {
+				cmHeheDiscountDao.deleteDiscountProduct(id);
+			});
+		}
+		List<Integer> userIds = cmHeheDiscountDao.findDiscountUserIds(cmHeheDiscount.getId());
+		// 保存用户
+		if (StringUtils.isNotBlank(cmHeheDiscount.getUserInfo())) {
+			List<CmHeheDiscountUser> userList = JSON.parseArray(cmHeheDiscount.getUserInfo(), CmHeheDiscountUser.class);
+			userList.forEach(a -> {
+				if (a.getId() == null) {
+					a.setDiscountId(Integer.valueOf(cmHeheDiscount.getId()));
+					a.setAddTime(date);
+					cmHeheDiscountDao.insertDiscountUser(a);
+				} else {
+					userIds.removeIf(id -> id.equals(a.getId()));
+				}
+			});
+		}
+		//删除用户
+		if (userIds != null && userIds.size() > 0) {
+			userIds.forEach(id -> {
+				cmHeheDiscountDao.deleteDiscountUser(id);
+			});
+		}
+	}
+	
+	@Transactional(readOnly = false)
+	public void delete(CmHeheDiscount cmHeheDiscount) {
+		super.delete(cmHeheDiscount);
+	}
+
+    public Map<String, Object> updateStatus(Integer id, Integer status) {
+		HashMap<String, Object> map = new HashMap<>(2);
+		cmHeheDiscountDao.updateStatus(id, status);
+		map.put("success", true);
+		map.put("msg", 0 == status ? "停用" : "启用" + "优惠成功");
+		return map;
+	}
+
+	public Page<Product> findProductList(Page<Product> productPage, Product product) {
+		product.setPage(productPage);
+		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());
+				if (StringUtils.isNotBlank(product.getProductIds()) && product.getProductIds().contains(item.getProductID().toString())) {
+					item.setStoreStatus(true);
+				}
+			});
+		}
+		productPage.setList(productList);
+		return productPage;
+	}
+
+	public Page<CmUser> findUserList(Page<CmUser> cmUserPage, CmUser user) {
+		user.setPage(cmUserPage);
+		List<CmUser> userList = cmHeheCouponDao.findAllUser(user);
+		if (userList != null && userList.size() > 0) {
+			userList.forEach(item -> {
+				item.setUserIds(user.getUserIds());
+				if (StringUtils.isNotBlank(user.getUserIds()) && user.getUserIds().contains(item.getId())) {
+					item.setStoreStatus(true);
+				}
+			});
+		}
+		cmUserPage.setList(userList);
+		return cmUserPage;
+	}
+
+	public List<CmHeheDiscountProduct> findDiscountProductList(CmHeheDiscount cmHeheDiscount) {
+		List<CmHeheDiscountProduct> productList = cmHeheDiscountDao.findDiscountProductList(cmHeheDiscount.getId());
+		if (productList != null && productList.size() > 0) {
+			productList.forEach(item -> {
+				item.setImage(AppUtils.getImageURL("product", item.getImage(), 0, "https://www.caimei365.com/"));
+			});
+		}
+		return productList;
+	}
+
+	public List<CmHeheDiscountUser> findDiscountUserList(CmHeheDiscount cmHeheDiscount) {
+		return cmHeheDiscountDao.findDiscountUserList(cmHeheDiscount.getId());
+	}
+}

+ 139 - 0
src/main/java/com/caimei/modules/hehe/web/CmHeheCouponController.java

@@ -0,0 +1,139 @@
+package com.caimei.modules.hehe.web;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.caimei.modules.hehe.entity.*;
+import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.user.entity.CmUser;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+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.servlet.mvc.support.RedirectAttributes;
+
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.web.BaseController;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.caimei.modules.hehe.service.CmHeheCouponService;
+
+import java.util.List;
+
+/**
+ * 呵呵商城优惠券Controller
+ * @author Aslee
+ * @version 2021-10-20
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/hehe/cmHeheCoupon")
+public class CmHeheCouponController extends BaseController {
+
+	@Autowired
+	private CmHeheCouponService cmHeheCouponService;
+	
+	@ModelAttribute
+	public CmHeheCoupon get(@RequestParam(required=false) String id) {
+		CmHeheCoupon entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = cmHeheCouponService.get(id);
+		}
+		if (entity == null){
+			entity = new CmHeheCoupon();
+		}
+		return entity;
+	}
+	
+	@RequestMapping(value = {"list", ""})
+	public String list(CmHeheCoupon cmHeheCoupon, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<CmHeheCoupon> page = cmHeheCouponService.findPage(new Page<CmHeheCoupon>(request, response), cmHeheCoupon); 
+		model.addAttribute("page", page);
+		return "modules/hehe/cmHeheCouponList";
+	}
+
+	@RequestMapping(value = "form")
+	public String form(CmHeheCoupon cmHeheCoupon, Model model) {
+		model.addAttribute("cmHeheCoupon", cmHeheCoupon);
+		if (StringUtils.isNotBlank(cmHeheCoupon.getId()) && 2 == cmHeheCoupon.getProductType()) {
+			List<CmHeheCouponProduct> productList = cmHeheCouponService.findCouponProductList(cmHeheCoupon);
+			model.addAttribute("productList", productList);
+		}
+		if (StringUtils.isNotBlank(cmHeheCoupon.getId()) && 2 == cmHeheCoupon.getCouponType()) {
+			List<CmHeheCouponUser> userList = cmHeheCouponService.findCouponUserList(cmHeheCoupon);
+			model.addAttribute("userList", userList);
+		}
+		return "modules/hehe/cmHeheCouponForm";
+	}
+
+	@RequestMapping(value = "save")
+	public String save(CmHeheCoupon cmHeheCoupon, Model model, RedirectAttributes redirectAttributes) {
+		if (!beanValidator(model, cmHeheCoupon)){
+			return form(cmHeheCoupon, model);
+		}
+		cmHeheCouponService.save(cmHeheCoupon);
+		addMessage(redirectAttributes, "保存优惠券成功");
+		return "redirect:" + Global.getAdminPath() + "/hehe/cmHeheCoupon/?repage&couponType=" + cmHeheCoupon.getCouponType();
+	}
+	
+	@RequestMapping(value = "delete")
+	public String delete(CmHeheCoupon cmHeheCoupon, RedirectAttributes redirectAttributes) {
+		cmHeheCouponService.delete(cmHeheCoupon);
+		addMessage(redirectAttributes, "删除优惠券成功");
+		return "redirect:"+Global.getAdminPath()+"/hehe/cmHeheCoupon/?repage";
+	}
+
+	/**
+	 * 选择商品页面
+	 */
+	@RequestMapping(value = "toAddProduct")
+	public String toAddProduct(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+		Page<Product> page = cmHeheCouponService.findProductList(new Page<Product>(request, response), product);
+		model.addAttribute("page", page);
+		model.addAttribute("productIds", product.getProductIds());
+		return "/modules/hehe/toAddCouponProduct";
+	}
+
+	/**
+	 * 选择用户页面
+	 */
+	@RequestMapping(value = "toAddUser")
+	public String toAddProduct(CmUser user, Model model, HttpServletRequest request, HttpServletResponse response) {
+		Page<CmUser> page = cmHeheCouponService.findUserList(new Page<CmUser>(request, response), user);
+		model.addAttribute("page", page);
+		model.addAttribute("userIds", user.getUserIds());
+		return "/modules/hehe/toAddCouponUser";
+	}
+
+	/**
+	 * 单张优惠券已领取用户列表
+	 */
+	@RequestMapping(value = "receive/user/list")
+	public String receiveUserList(CmHeheReceiveUser cmHeheReceiveUser, Model model, HttpServletRequest request, HttpServletResponse response){
+		Page<CmHeheReceiveUser> page = cmHeheCouponService.findReceiveUserList(new Page<CmHeheReceiveUser>(request, response), cmHeheReceiveUser);
+		model.addAttribute("page", page);
+		return "modules/hehe/receiveUserList";
+	}
+
+	/**
+	 * 所有领过优惠券的用户列表
+	 */
+	@RequestMapping(value = "user/list")
+	public String allUserList(CmHeheReceiveUser cmHeheReceiveUser, Model model, HttpServletRequest request, HttpServletResponse response){
+		Page<CmHeheReceiveUser> page = cmHeheCouponService.findAllUserList(new Page<CmHeheReceiveUser>(request, response), cmHeheReceiveUser);
+		model.addAttribute("page", page);
+		return "modules/hehe/userAllCouponList";
+	}
+
+	/**
+	 * 用户领取详情
+	 */
+	@RequestMapping(value = "receiveDetails")
+	public String receiveDetails(CmHeheCoupon cmHeheCoupon, Model model, HttpServletRequest request, HttpServletResponse response) {
+		Page<CmHeheCoupon> page = cmHeheCouponService.findReceiveCouponList(new Page<CmHeheCoupon>(request, response), cmHeheCoupon);
+		model.addAttribute("page", page);
+		return "modules/hehe/receiveDetailsList";
+	}
+}

+ 117 - 0
src/main/java/com/caimei/modules/hehe/web/CmHeheDiscountController.java

@@ -0,0 +1,117 @@
+package com.caimei.modules.hehe.web;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.caimei.modules.hehe.entity.CmHeheDiscountProduct;
+import com.caimei.modules.hehe.entity.CmHeheDiscountUser;
+import com.caimei.modules.product.entity.Product;
+import com.caimei.modules.user.entity.CmUser;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+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.servlet.mvc.support.RedirectAttributes;
+
+import com.thinkgem.jeesite.common.config.Global;
+import com.thinkgem.jeesite.common.persistence.Page;
+import com.thinkgem.jeesite.common.web.BaseController;
+import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.caimei.modules.hehe.entity.CmHeheDiscount;
+import com.caimei.modules.hehe.service.CmHeheDiscountService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 呵呵商城内部优惠Controller
+ * @author Aslee
+ * @version 2021-10-25
+ */
+@Controller
+@RequestMapping(value = "${adminPath}/hehe/cmHeheDiscount")
+public class CmHeheDiscountController extends BaseController {
+
+	@Autowired
+	private CmHeheDiscountService cmHeheDiscountService;
+	
+	@ModelAttribute
+	public CmHeheDiscount get(@RequestParam(required=false) String id) {
+		CmHeheDiscount entity = null;
+		if (StringUtils.isNotBlank(id)){
+			entity = cmHeheDiscountService.get(id);
+		}
+		if (entity == null){
+			entity = new CmHeheDiscount();
+		}
+		return entity;
+	}
+	
+	@RequestMapping(value = {"list", ""})
+	public String list(CmHeheDiscount cmHeheDiscount, HttpServletRequest request, HttpServletResponse response, Model model) {
+		Page<CmHeheDiscount> page = cmHeheDiscountService.findPage(new Page<CmHeheDiscount>(request, response), cmHeheDiscount); 
+		model.addAttribute("page", page);
+		return "modules/hehe/cmHeheDiscountList";
+	}
+
+	@RequestMapping(value = "form")
+	public String form(CmHeheDiscount cmHeheDiscount, Model model) {
+		model.addAttribute("cmHeheDiscount", cmHeheDiscount);
+		if (StringUtils.isNotBlank(cmHeheDiscount.getId()) && 2 == cmHeheDiscount.getProductType()) {
+			List<CmHeheDiscountProduct> productList = cmHeheDiscountService.findDiscountProductList(cmHeheDiscount);
+			model.addAttribute("productList", productList);
+		}
+		if (StringUtils.isNotBlank(cmHeheDiscount.getId())) {
+			List<CmHeheDiscountUser> userList = cmHeheDiscountService.findDiscountUserList(cmHeheDiscount);
+			model.addAttribute("userList", userList);
+		}
+		return "modules/hehe/cmHeheDiscountForm";
+	}
+
+	@RequestMapping(value = "save")
+	public String save(CmHeheDiscount cmHeheDiscount, Model model, RedirectAttributes redirectAttributes) {
+		if (!beanValidator(model, cmHeheDiscount)){
+			return form(cmHeheDiscount, model);
+		}
+		cmHeheDiscountService.save(cmHeheDiscount);
+		addMessage(redirectAttributes, "保存内部优惠成功");
+		return "redirect:"+Global.getAdminPath()+"/hehe/cmHeheDiscount/?repage";
+	}
+	
+	@RequestMapping(value = "delete")
+	public String delete(CmHeheDiscount cmHeheDiscount, RedirectAttributes redirectAttributes) {
+		cmHeheDiscountService.delete(cmHeheDiscount);
+		addMessage(redirectAttributes, "删除内部优惠成功");
+		return "redirect:"+Global.getAdminPath()+"/hehe/cmHeheDiscount/?repage";
+	}
+
+	@RequestMapping(value = "updateStatus")
+	public Map<String,Object> updateStatus(Integer id, Integer status){
+		return cmHeheDiscountService.updateStatus(id, status);
+	}
+
+	/**
+	 * 选择商品页面
+	 */
+	@RequestMapping(value = "toAddProduct")
+	public String toAddProduct(Product product, Model model, HttpServletRequest request, HttpServletResponse response) {
+		Page<Product> page = cmHeheDiscountService.findProductList(new Page<Product>(request, response), product);
+		model.addAttribute("page", page);
+		model.addAttribute("productIds", product.getProductIds());
+		return "/modules/hehe/toAddDiscountProduct";
+	}
+
+	/**
+	 * 选择用户页面
+	 */
+	@RequestMapping(value = "toAddUser")
+	public String toAddProduct(CmUser user, Model model, HttpServletRequest request, HttpServletResponse response) {
+		Page<CmUser> page = cmHeheDiscountService.findUserList(new Page<CmUser>(request, response), user);
+		model.addAttribute("page", page);
+		model.addAttribute("userIds", user.getUserIds());
+		return "/modules/hehe/toAddDiscountUser";
+	}
+}

+ 18 - 0
src/main/java/com/caimei/modules/user/entity/CmUser.java

@@ -108,6 +108,8 @@ public class CmUser extends DataEntity<CmUser> {
     private String address;        // 详细地址
     private boolean pending = false; //是否有待审核提现
     private String shortName;   //机构简称
+    private String userIds;  //用户id","隔开
+    private boolean storeStatus = false; //是否存在数据库
 
     public CmUser() {
         super();
@@ -843,4 +845,20 @@ public class CmUser extends DataEntity<CmUser> {
     public void setShortName(String shortName) {
         this.shortName = shortName;
     }
+
+    public String getUserIds() {
+        return userIds;
+    }
+
+    public void setUserIds(String userIds) {
+        this.userIds = userIds;
+    }
+
+    public boolean isStoreStatus() {
+        return storeStatus;
+    }
+
+    public void setStoreStatus(boolean storeStatus) {
+        this.storeStatus = storeStatus;
+    }
 }

+ 318 - 0
src/main/resources/mappings/modules/hehe/CmHeheCouponMapper.xml

@@ -0,0 +1,318 @@
+<?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.CmHeheCouponDao">
+    
+	<sql id="cmHeheCouponColumns">
+		a.id AS "id",
+		a.name AS "name",
+		a.couponAmount AS "couponAmount",
+		a.touchPrice AS "touchPrice",
+		a.noThresholdFlag AS "noThresholdFlag",
+		a.startTime AS "startTime",
+		a.endTime AS "endTime",
+		a.startNowFlag AS "startNowFlag",
+		a.permanentFlag AS "permanentFlag",
+		a.couponType AS "couponType",
+		a.productType AS "productType",
+		a.receivePeriod AS "receivePeriod",
+		a.receiveFlag AS "receiveFlag",
+		a.usePeriod AS "usePeriod",
+		a.createDate AS "createDate",
+		a.delFlag AS "delFlag"
+	</sql>
+	
+	<sql id="cmHeheCouponJoins">
+	</sql>
+    
+	<select id="get" resultType="CmHeheCoupon">
+		SELECT 
+			<include refid="cmHeheCouponColumns"/>
+		FROM cm_hehe_coupon a
+		<include refid="cmHeheCouponJoins"/>
+		WHERE a.id = #{id}
+	</select>
+	
+	<select id="findList" resultType="CmHeheCoupon">
+		SELECT 
+			<include refid="cmHeheCouponColumns"/>
+		FROM cm_hehe_coupon a
+		<include refid="cmHeheCouponJoins"/>
+		<where>
+			AND a.delFlag = 0
+			<if test="couponType != null">
+				AND a.couponType = #{couponType}
+			</if>
+			<if test="name != null and name != ''">
+				AND a.name LIKE 
+					<if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
+					<if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
+					<if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
+			</if>
+			<if test='status == "1"'>
+				AND (NOW() <![CDATA[ < ]]> a.startTime and a.startNowFlag = 0)
+			</if>
+			<if test='status == "2"'>
+				AND (NOW() <![CDATA[ >= ]]> a.startTime OR a.startNowFlag = 1)
+				AND (NOW() <![CDATA[ <= ]]> a.endTime OR a.permanentFlag = 1)
+			</if>
+			<if test='status == "3"'>
+				AND (NOW() <![CDATA[ > ]]> a.endDate and a.permanentFlag = 0)
+			</if>
+		</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="CmHeheCoupon">
+		SELECT 
+			<include refid="cmHeheCouponColumns"/>
+		FROM cm_hehe_coupon a
+		<include refid="cmHeheCouponJoins"/>
+		<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="findCouponProductIds" resultType="java.lang.Integer">
+		SELECT id FROM cm_hehe_coupon_product WHERE couponId = #{couponId}
+	</select>
+	<select id="findCouponProductList" resultType="com.caimei.modules.hehe.entity.CmHeheCouponProduct">
+		SELECT
+			cca.id,
+			cca.couponId,
+			cca.productId,
+			cca.status,
+			cca.sort,
+			cca.addTime,
+			s.name AS shopName,
+			p.name AS productName,
+			p.mainImage AS image
+		FROM
+			cm_hehe_coupon_product cca
+			    left join cm_hehe_product chp on cca.productId = chp.id
+				LEFT JOIN product p ON chp.productId = p.productID
+				LEFT JOIN shop s ON p.shopID = s.shopID
+		WHERE
+			cca.couponId = #{couponId}
+		ORDER BY
+			- sort DESC
+	</select>
+	<select id="findAllUser" resultType="com.caimei.modules.user.entity.CmUser">
+		select id, nickName,mobile,userIdentity,openId as openID
+		from cm_hehe_user
+		<where>
+			<if test="mobile != null and mobile != ''">
+				AND mobile = #{mobile}
+			</if>
+			<if test="userIdentity != null and userIdentity != ''">
+				AND userIdentity = #{userIdentity}
+			</if>
+			<if test="nickName != null and nickName != ''">
+				AND nickName LIKE concat('%',#{nickName},'%')
+			</if>
+		</where>
+		ORDER BY addTime DESC
+	</select>
+	<select id="findCouponUserIds" resultType="java.lang.Integer">
+		SELECT id FROM cm_hehe_coupon_user WHERE couponId = #{couponId}
+	</select>
+	<select id="findCouponUserList" resultType="com.caimei.modules.hehe.entity.CmHeheCouponUser">
+		select chu.id, chu.userId, chu.couponId, chu.addTime, u.nickName, u.mobile, u.userIdentity
+		from cm_hehe_coupon_user chu
+				 left join cm_hehe_user u on chu.userId = u.id
+		where chu.couponId = #{id}
+		order by chu.addTime desc
+	</select>
+	<select id="allUserList" resultType="com.caimei.modules.hehe.entity.CmHeheReceiveUser">
+		select u.id as userId,u.nickName,u.mobile,u.userIdentity,count(rc.id) as receiveNum, count(chc.id) as ableNum
+		from cm_hehe_user u
+		    left join cm_hehe_receive_coupon rc on u.id = rc.userId and rc.delFlag = 0
+			left join cm_hehe_coupon chc on rc.couponId = chc.id
+			and NOW() <![CDATA[ < ]]> DATE_ADD(rc.receiveTime ,interval chc.usePeriod DAY)
+			and chc.delFlag = 0
+		<where>
+			<if test="nickName != null and nickName != ''">
+				and u.nickName like concat('%',#{nickName},'%')
+			</if>
+			<if test="mobile != null and mobile != ''">
+				and u.mobile like concat('%',#{mobile},'%')
+			</if>
+			<if test="userIdentity != null">
+				and u.userIdentity = #{userIdentity}
+			</if>
+		</where>
+		group by u.id
+		having receiveNum >0
+		order by count(chc.id) desc,u.id desc
+	</select>
+	<select id="receiveUserList" resultType="com.caimei.modules.hehe.entity.CmHeheReceiveUser">
+		select chu.id as userId,
+			   chu.nickName,
+			   chu.mobile,
+			   chrc.source,
+			   chrc.receiveTime,
+			   date_add(chrc.receiveTime, interval chc.usePeriod DAY)                          as validPeriod,
+			   chrc.status,
+			   if(NOW() <![CDATA[ > ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY), 0, 1) as validFlag,
+		       chrc.useTime,
+		       chrc.orderId
+		from cm_hehe_user chu
+				 left join cm_hehe_receive_coupon chrc on chu.id = chrc.userId
+				 left join cm_hehe_coupon chc on chrc.couponId = chc.id
+		<where>
+			chrc.couponId = #{couponId}
+			<if test="nickName != null and nickName != ''">
+				and chu.nickName like concat('%',#{nickName},'%')
+			</if>
+			<if test="mobile != null and mobile != ''">
+				and chu.mobile like concat('%',#{mobile},'%')
+			</if>
+			<if test="status != null">
+				<if test="status == 2">
+					and chrc.status = 2
+				</if>
+				<if test="status == 1">
+					and chrc.status = 1 and NOW() <![CDATA[ <= ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY)
+				</if>
+				<if test="status == 3">
+					and chrc.status = 1 and NOW() <![CDATA[ > ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY)
+				</if>
+			</if>
+		</where>
+		order by chrc.receiveTime desc
+	</select>
+	<select id="receiveCouponList" resultType="com.caimei.modules.hehe.entity.CmHeheCoupon">
+		select chc.name,chc.couponType,chc.couponAmount,chc.touchPrice,chrc.receiveTime,
+		       date_add(chrc.receiveTime,interval chc.usePeriod DAY) as validPeriod,chrc.status as useStatus,
+			   if(NOW() <![CDATA[ > ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY), 0, 1) as validFlag,
+				chrc.useTime,co.orderNo,co.orderID as orderId
+		from cm_hehe_coupon chc
+		left join cm_hehe_receive_coupon chrc on chc.id = chrc.couponId
+		left join cm_order co on chrc.orderId = co.orderID
+		<where>
+			chrc.userId = #{userId}
+			<if test="name != null and name !=''">
+				and chc.name like concat('%',#{name},'%')
+			</if>
+			<if test="couponType != null">
+				and chc.couponType = #{couponType}
+			</if>
+			<if test="useStatus != null">
+				<if test="useStatus == 2">
+					and chrc.status = 2
+				</if>
+				<if test="useStatus == 1">
+					and chrc.status = 1 and NOW() <![CDATA[ <= ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY)
+				</if>
+				<if test="useStatus == 3">
+					and chrc.status = 1 and NOW() <![CDATA[ > ]]> date_add(chrc.receiveTime, interval chc.usePeriod DAY)
+				</if>
+			</if>
+		</where>
+		order by chrc.receiveTime desc
+	</select>
+
+	<insert id="insert" parameterType="CmHeheCoupon"  keyProperty="id" useGeneratedKeys="true">
+		INSERT INTO cm_hehe_coupon(
+			name,
+			couponAmount,
+			touchPrice,
+			noThresholdFlag,
+			startTime,
+			endTime,
+			startNowFlag,
+			permanentFlag,
+			couponType,
+			productType,
+			receivePeriod,
+			receiveFlag,
+			usePeriod,
+			createDate,
+			delFlag
+		) VALUES (
+			#{name},
+			#{couponAmount},
+			#{touchPrice},
+			#{noThresholdFlag},
+			#{startTime},
+			#{endTime},
+			#{startNowFlag},
+			#{permanentFlag},
+			#{couponType},
+			#{productType},
+			#{receivePeriod},
+			#{receiveFlag},
+			#{usePeriod},
+			#{createDate},
+			#{delFlag}
+		)
+	</insert>
+	<insert id="insertCouponProduct">
+		INSERT INTO `cm_hehe_coupon_product` (
+			`couponId`, `productId`, `status`,
+			`sort`, `addTime`
+		)
+		VALUES
+		(
+			#{couponId}, #{productId}, #{status},
+			#{sort}, #{addTime}
+		)
+	</insert>
+	<insert id="insertCouponUser">
+		insert into cm_hehe_coupon_user (couponId, userId, addTime) values (#{couponId}, #{userId}, #{addTime})
+	</insert>
+
+	<update id="update">
+		UPDATE cm_hehe_coupon SET 	
+			name = #{name},
+			couponAmount = #{couponAmount},
+			touchPrice = #{touchPrice},
+			noThresholdFlag = #{noThresholdFlag},
+			startTime = #{startTime},
+			endTime = #{endTime},
+			startNowFlag = #{startNowFlag},
+			permanentFlag = #{permanentFlag},
+			productType = #{productType},
+			receivePeriod = #{receivePeriod},
+			receiveFlag = #{receiveFlag},
+			usePeriod = #{usePeriod}
+		WHERE id = #{id}
+	</update>
+	<update id="updateCouponProduct">
+		UPDATE
+		`cm_hehe_coupon_product`
+		<set>
+			<if test="status != null">
+				`status` = #{status},
+			</if>
+			<if test="sort != null">
+				`sort` = #{sort},
+			</if>
+		</set>
+		WHERE
+		`id` = #{id}
+	</update>
+
+	<delete id="delete">
+		DELETE FROM cm_hehe_coupon
+		WHERE id = #{id}
+	</delete>
+	<delete id="deleteCouponProduct">
+		delete from cm_hehe_coupon_product where id = #{id}
+	</delete>
+	<delete id="deleteCouponUser">
+		delete from cm_hehe_coupon_user where id = #{id}
+	</delete>
+
+</mapper>

+ 176 - 0
src/main/resources/mappings/modules/hehe/CmHeheDiscountMapper.xml

@@ -0,0 +1,176 @@
+<?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.CmHeheDiscountDao">
+    
+	<sql id="cmHeheDiscountColumns">
+		a.id AS "id",
+		a.title AS "title",
+		a.discount AS "discount",
+		a.status AS "status",
+		a.productType AS "productType",
+		a.addTime AS "addTime"
+	</sql>
+	
+	<sql id="cmHeheDiscountJoins">
+	</sql>
+    
+	<select id="get" resultType="CmHeheDiscount">
+		SELECT 
+			<include refid="cmHeheDiscountColumns"/>
+		FROM cm_hehe_discount a
+		<include refid="cmHeheDiscountJoins"/>
+		WHERE a.id = #{id}
+	</select>
+	
+	<select id="findList" resultType="CmHeheDiscount">
+		SELECT 
+			<include refid="cmHeheDiscountColumns"/>
+		FROM cm_hehe_discount a
+		<include refid="cmHeheDiscountJoins"/>
+		<where>
+			
+			<if test="title != null and title != ''">
+				AND a.title LIKE 
+					<if test="dbName == 'oracle'">'%'||#{title}||'%'</if>
+					<if test="dbName == 'mssql'">'%'+#{title}+'%'</if>
+					<if test="dbName == 'mysql'">concat('%',#{title},'%')</if>
+			</if>
+			<if test="status != null and status != ''">
+				AND a.status = #{status}
+			</if>
+		</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="CmHeheDiscount">
+		SELECT 
+			<include refid="cmHeheDiscountColumns"/>
+		FROM cm_hehe_discount a
+		<include refid="cmHeheDiscountJoins"/>
+		<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="CmHeheDiscount"  keyProperty="id" useGeneratedKeys="true">
+		INSERT INTO cm_hehe_discount(
+			title,
+			discount,
+			status,
+			productType,
+			addTime
+		) VALUES (
+			#{title},
+			#{discount},
+			#{status},
+			#{productType},
+			#{addTime}
+		)
+	</insert>
+	
+	<update id="update">
+		UPDATE cm_hehe_discount SET 	
+			title = #{title},
+			discount = #{discount},
+			status = #{status},
+			productType = #{productType}
+		WHERE id = #{id}
+	</update>
+    <update id="updateStatus">
+		update cm_hehe_discount
+		set status = #{status}
+		where id = #{id}
+	</update>
+
+    <delete id="delete">
+		DELETE FROM cm_hehe_discount
+		WHERE id = #{id}
+	</delete>
+
+
+	<select id="findDiscountProductIds" resultType="java.lang.Integer">
+		SELECT id FROM cm_hehe_discount_product WHERE discountId = #{discountId}
+	</select>
+
+	<select id="findDiscountUserIds" resultType="java.lang.Integer">
+		SELECT id FROM cm_hehe_discount_user WHERE discountId = #{discountId}
+	</select>
+
+	<insert id="insertDiscountProduct">
+		INSERT INTO `cm_hehe_discount_product` (
+			`discountId`, `productId`, `status`,
+			`sort`, `addTime`
+		)
+		VALUES
+		(
+			#{discountId}, #{productId}, #{status},
+			#{sort}, NOW()
+		)
+	</insert>
+	<insert id="insertDiscountUser">
+		insert into cm_hehe_discount_user (discountId, userId, addTime) values (#{discountId}, #{userId}, #{addTime})
+	</insert>
+
+	<update id="updateDiscountProduct">
+		UPDATE
+		`cm_hehe_discount_product`
+		<set>
+			<if test="status != null">
+				`status` = #{status},
+			</if>
+			<if test="sort != null">
+				`sort` = #{sort},
+			</if>
+		</set>
+		WHERE
+		`id` = #{id}
+	</update>
+
+	<delete id="deleteDiscountProduct">
+		delete from cm_hehe_discount_product where id = #{id}
+	</delete>
+	<delete id="deleteDiscountUser">
+		delete from cm_hehe_discount_user where id = #{id}
+	</delete>
+	<select id="findDiscountProductList" resultType="com.caimei.modules.hehe.entity.CmHeheDiscountProduct">
+		SELECT
+			cca.id,
+			cca.discountId,
+			cca.productId,
+			cca.status,
+			cca.sort,
+			cca.addTime,
+			s.name AS shopName,
+			p.name AS productName,
+			p.mainImage AS image
+		FROM
+			cm_hehe_discount_product cca
+				left join cm_hehe_product chp on cca.productId = chp.id
+				LEFT JOIN product p ON chp.productId = p.productID
+				LEFT JOIN shop s ON p.shopID = s.shopID
+		WHERE
+			cca.discountId = #{discountId}
+		ORDER BY
+			- sort DESC
+	</select>
+	<select id="findDiscountUserList" resultType="com.caimei.modules.hehe.entity.CmHeheDiscountUser">
+		select chu.id, chu.userId, chu.discountId, chu.addTime, u.nickName, u.mobile, u.userIdentity
+		from cm_hehe_discount_user chu
+				 left join cm_hehe_user u on chu.userId = u.id
+		where chu.discountId = #{id}
+		order by chu.addTime desc
+	</select>
+</mapper>

+ 33 - 0
src/main/resources/mappings/modules/hehe/CmHeheProductMapper.xml

@@ -163,6 +163,39 @@
 		</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>
+
 
 	<update id="deleteActivityProduct">
 		UPDATE cm_hehe_activity_product SET delFlag = 1 WHERE productId = #{productId}

+ 618 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponForm.jsp

@@ -0,0 +1,618 @@
+<%@ page import="java.util.Date" %>
+<%@ 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>
+		.formCheck{
+			margin-left: 20px !important;
+		}
+	</style>
+	<script type="text/javascript">
+		$(document).ready(function() {
+			//$("#name").focus();
+			$("#inputForm").validate({
+				submitHandler: function(form){
+					if (imageList.length > 0) {
+						var productInfo = JSON.stringify(imageList);
+						$('#productInfo').val(productInfo);
+					}
+					if (userList.length > 0) {
+						var userInfo = JSON.stringify(userList);
+						$("#userInfo").val(userInfo);
+					}
+					var couponAmount = $("#couponAmount").val()*1;
+					var touchPrice = $("#touchPrice").val()*1;
+					if (couponAmount >= touchPrice) {
+						alertx("优惠券金额必须小于优惠条件金额");
+						return false;
+					}
+					var startNowFlag = $("#startNowFlag").val();
+					var permanentFlag = $("#permanentFlag").val();
+					var startTime = $("#startTime").val();
+					var endTime = $("#endTime").val();
+					if (startNowFlag === 1) {
+						startTime = new Date();
+					}
+					if (permanentFlag === 0 && startTime >= endTime) {
+						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);
+					}
+				}
+			});
+		});
+
+		/**
+		 * @param obj
+		 * jquery控制input只能输入数字
+		 */
+		function onlynum(obj) {
+			obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+		}
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/hehe/cmHeheCoupon/?couponType=${cmHeheCoupon.couponType}">优惠券列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheCoupon/form?id=${cmHeheCoupon.id}&couponType=${cmHeheCoupon.couponType}">${not empty cmHeheCoupon.id?'编辑':'添加'}</a></li>
+	</ul><br/>
+	<form:form id="inputForm" modelAttribute="cmHeheCoupon" action="${ctx}/hehe/cmHeheCoupon/save" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<form:hidden path="productInfo"/>
+		<form:hidden path="userInfo"/>
+		<form:hidden path="couponType"/>
+		<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" placeholder="30个汉字以内" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>优惠券金额:</label>
+			<div class="controls">
+				<input type="number" id="couponAmount" name="couponAmount" value="${cmHeheCoupon.couponAmount}" min="0" required> 元
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>优惠条件:</label>
+			<div class="controls">
+				订单商品总额满
+				<input type="number" id="touchPrice" name="touchPrice" value="${cmHeheCoupon.touchPrice}" min="0" required> 元
+<%--				<form:checkbox path="noThresholdFlag" label="无门槛" onclick="changeCondition(this,'touchPrice')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.noThresholdFlag eq null?0:cmHeheCoupon.noThresholdFlag}"/>--%>
+				<input type="checkbox" id="noThresholdFlag" name="noThresholdFlag" class="formCheck" value="${cmHeheCoupon.noThresholdFlag eq 1?1:0}" ${cmHeheCoupon.noThresholdFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'touchPrice')" />无门槛
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>上架时间:</label>
+			<div class="controls">
+				<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
+					value="<fmt:formatDate value="${cmHeheCoupon.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
+<%--				<form:checkbox path="startNowFlag" label="立即上架" onclick="changeCondition(this,'startTime')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.startNowFlag eq null?0:cmHeheCoupon.startNowFlag}"/>--%>
+				<input type="checkbox" id="startNowFlag" name="startNowFlag" class="formCheck" value="${cmHeheCoupon.startNowFlag eq 1?1:0}" ${cmHeheCoupon.startNowFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'startTime')" />立即上架
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>下架时间:</label>
+			<div class="controls">
+				<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate required"
+					value="<fmt:formatDate value="${cmHeheCoupon.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+					onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false});"/>
+<%--				<form:checkbox path="permanentFlag" label="永久" onclick="changeCondition(this,'endTime')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.permanentFlag eq null?0:cmHeheCoupon.permanentFlag}"/>--%>
+				<input type="checkbox" id="permanentFlag" name="permanentFlag" class="formCheck" value="${cmHeheCoupon.permanentFlag eq 1?1:0}" ${cmHeheCoupon.permanentFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'endTime')" />永久
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>领取期限:</label>
+			<div class="controls">
+				<input type="number" id="receivePeriod" name="receivePeriod" onkeyup="onlynum(this)" value="${cmHeheCoupon.receivePeriod}" min="1" required> 天
+<%--				<form:checkbox path="receiveFlag" label="同上下架时间" onclick="changeCondition(this,'receivePeriod')" cssStyle="margin-left: 20px" value="${cmHeheCoupon.receiveFlag eq null?0:cmHeheCoupon.receiveFlag}"/>--%>
+				<input type="checkbox" id="receiveFlag" name="receiveFlag" class="formCheck" value="${cmHeheCoupon.receiveFlag eq 1?1:0}" ${cmHeheCoupon.receiveFlag eq 1 ? "checked" : ""} onclick="changeCondition(this,'receivePeriod')" />同上下架时间
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>使用期限:</label>
+			<div class="controls">
+				<input type="number" id="usePeriod" name="usePeriod" value="${cmHeheCoupon.usePeriod}" min="1" required> 天
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>优惠商品:</label>
+			<div class="controls">
+				<form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked ="${empty cmHeheCoupon.productType ? true:false}"/>
+				<form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()"/>
+			</div>
+		</div>
+		<div class="productData" hidden="hidden">
+			<div class="control-group">
+				<input class="btn" id="productDel" style="width: 50px" onclick="productBatchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
+				<input class="btn btn-primary" style="width: 70px" onclick="batchSaveProductSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
+				<input class="btn btn-primary" style="width: 50px" onclick="productShowSelect()" value="添加"/>
+				<br><br>
+				<table id="productTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+					<thead>
+					<tr>
+						<th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this,1);"/> 全选
+						</th>
+						<th>商品图片</th>
+						<th>商品名称</th>
+						<th>供应商</th>
+						<th>状态</th>
+						<th>排序</th>
+						<th>添加时间</th>
+						<th>操作</th>
+					</tr>
+					</thead>
+					<tbody id="productTbody"></tbody>
+				</table>
+			</div>
+		</div>
+		<c:if test="${cmHeheCoupon.couponType eq 2}">
+			<div class="control-group">
+				<label class="control-label"><font color="red">*</font>用户列表:</label>
+			</div>
+			<div class="userData">
+				<div class="control-group">
+					<input class="btn" id="userDel" style="width: 50px" onclick="userBatchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
+					<input class="btn btn-primary" style="width: 50px" onclick="userShowSelect()" value="添加"/>
+					<br><br>
+					<table id="userTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+						<thead>
+						<tr>
+							<th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this,2);"/> 全选
+							</th>
+							<th>微信昵称</th>
+							<th>手机号</th>
+							<th>身份</th>
+							<th>添加时间</th>
+							<th>操作</th>
+						</tr>
+						</thead>
+						<tbody id="userTbody"></tbody>
+					</table>
+				</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 changeCondition(obj, name) {
+		var val = obj.value;
+		if (val === '1') {
+			obj.value = '0';
+			val = '0';
+		} else {
+			obj.value = '1';
+			val = '1';
+		}
+		var inputObj = $("#" + name);
+		if (name.indexOf("Time") !== -1) {
+			//修改时间
+			if (val === '1') {
+				inputObj.attr('onclick', '');
+				inputObj.removeClass('required');
+			} else {
+				inputObj.attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+				inputObj.addClass('required');
+			}
+		}else {
+			if (val === '1') {
+				inputObj.attr('readonly', true);
+				inputObj.attr('required', false);
+			} else {
+				inputObj.attr('readonly', false);
+				inputObj.attr('required', true);
+			}
+		}
+	}
+
+	var productIds = '';
+	var imageList = [];
+
+	var userIds = '';
+	var userList = [];
+
+	$(function () {
+		<c:forEach items="${productList}" var="product" varStatus="index">
+		imageList.push({
+			id: "${product.id}",
+			productId: "${empty product.productId ? "":product.productId}",
+			image: "${product.image}",
+			productName: "${product.productName}",
+			shopName: "${product.shopName}",
+			sort: "${product.sort}",
+			status: "${product.status}",
+			addTime: "<fmt:formatDate value="${product.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+		});
+		</c:forEach>
+		<c:forEach items="${userList}" var="user" varStatus="index">
+		userList.push({
+			userId: "${user.userId}",
+			nickName: "${user.nickName}",
+			mobile: "${user.mobile}",
+			userIdentity: "${user.userIdentity}",
+			addTime: "<fmt:formatDate value="${user.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+		});
+		</c:forEach>
+
+		if (imageList.length > 0) {
+			$('#productTable').show();
+			batchSaveProductSort();
+		}
+		if (userList.length > 0) {
+			$('#userTable').show();
+			batchSaveUserSort();
+		}
+
+		initInputDisplay();
+		productShow();
+	});
+
+	//商品添加
+	function productShowSelect() {
+		var url = "${ctx}/hehe/cmHeheCoupon/toAddProduct?productIds=" + productIds;
+		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);
+					console.log(items[0]);
+					for (var i = 0; i < items.length; i++) {
+						console.log(items[i]);
+						imageList.push(items[i]);
+						$('#productTable').show();
+						$("#productDel").removeAttr("disabled");
+						batchSaveProductSort();
+					};
+				}
+				return true;
+			}
+		});
+	}
+
+	//用户添加
+	function userShowSelect() {
+		var url = "${ctx}/hehe/cmHeheCoupon/toAddUser?userIds=" + userIds;
+		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);
+					console.log(items[0]);
+					for (var i = 0; i < items.length; i++) {
+						console.log(items[i]);
+						userList.push(items[i]);
+						$('#userTable').show();
+						$("#userDel").removeAttr("disabled");
+						batchSaveUserSort();
+					};
+				}
+				return true;
+			}
+		});
+	}
+
+	function initInputDisplay() {
+		var noThresholdFlag = $("#noThresholdFlag").val();
+		var startNowFlag = $("#startNowFlag").val();
+		var permanentFlag = $("#permanentFlag").val();
+		var receiveFlag = $("#receiveFlag").val();
+
+		if (noThresholdFlag === '1') {
+			$("#touchPrice").attr('readonly', true);
+			$("#touchPrice").attr('required', false);
+		} else {
+			$("#touchPrice").attr('readonly', false);
+			$("#touchPrice").attr('required', true);
+		}
+		if (receiveFlag === '1') {
+			$("#receivePeriod").attr('readonly', true);
+			$("#receivePeriod").attr('required', false);
+		} else {
+			$("#receivePeriod").attr('readonly', false);
+			$("#receivePeriod").attr('required', true);
+		}
+		if (startNowFlag === '1') {
+			$("#startTime").attr('onclick', '');
+			$("#startTime").removeClass('required');
+		} else {
+			$("#startTime").attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+			$("#startTime").addClass('required');
+		}
+		if (permanentFlag === '1') {
+			$("#endTime").attr('onclick', '');
+			$("#endTime").removeClass('required');
+		} else {
+			$("#endTime").attr('onclick', "WdatePicker({dateFmt:'yyyy-MM-dd HH:mm',isShowClear:false})");
+			$("#endTime").addClass('required');
+		}
+	}
+
+	/**
+	 * 一键排序
+	 */
+	function batchSaveProductSort() {
+		imageList.sort(sort);
+		productInsertHtml(imageList);
+	}
+	/**
+	 * 一键排序
+	 */
+	function batchSaveUserSort() {
+		userInsertHtml(userList);
+	}
+
+	//根据sort值 从小到大排序
+	function sort(a, b) {
+		return a.sort - b.sort;
+	}
+
+	//相关图片列表数据
+	function appendProduct(data, index) {
+		var html = '<tr id ="ai' + index + '">' +
+				'<td>' +
+				'<input class="product-check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
+				'</td>' +
+				'<td>' +
+				'<img src="' + data.image + '" width="60px" border="none" title="启用">' +
+				'</td>' +
+				'<td>' +
+				data.productName +
+				'</td>' +
+				'<td>' +
+				data.shopName +
+				'</td>' +
+				'<td>' +
+				(data.status == 1 ? (
+						'<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0);" onclick="updateStatus(0,' + index + ');" >' +
+						'停用</a>'
+				) : (
+						'<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0)" onclick="updateStatus(1,' + index + ');">' +
+						'启用</a>'
+				)) +
+				'</td>' +
+				'</td>' +
+				'<td>' +
+				'<input name="sort" style="width:50px;" value="' + data.sort + '"  onkeyup="onlynum(this)"  onchange="changeSort(' + index + ',this)"></td>' +
+				'</td>' +
+				'<td>' +
+				(data.addTime == '' ? (
+						'<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
+				) : (
+						data.addTime
+				)) +
+				'</td>' +
+				'<td>' +
+				'<a href="javascript:;" onclick="productDelete(' + index + ')">删除</a>' +
+				'</td>' +
+				'</tr>';
+		return html;
+	}
+
+	//相关用户列表数据
+	function appendUser(data, index) {
+		var html = '<tr id ="ai' + index + '">' +
+				'<td>' +
+				'<input class="user-check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
+				'</td>' +
+				'<td>' +
+				data.nickName +
+				'</td>' +
+				'<td>' +
+				data.mobile +
+				'</td>' +
+				'<td>' +
+				(data.userIdentity === 1 ? '普通用户':'分销者') +
+				'</td>' +
+				'<td>' +
+				(data.addTime == '' ? (
+						'<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
+				) : (
+						data.addTime
+				)) +
+				'</td>' +
+				'<td>' +
+				'<a href="javascript:;" onclick="userDelete(' + index + ')">删除</a>' +
+				'</td>' +
+				'</tr>';
+		return html;
+	}
+
+	function productInsertHtml(list) {
+		var html = '';
+		productIds = '';
+		list.forEach(function (item, index) {
+			html += appendProduct(item, index);
+			productIds += "," + item.productId;
+		});
+		$("#productTbody").html(html);
+	}
+
+	function userInsertHtml(list) {
+		var html = '';
+		userIds = '';
+		list.forEach(function (item, index) {
+			html += appendUser(item, index);
+			userIds += "," + item.userId;
+		});
+		$("#userTbody").html(html);
+	}
+
+	function changeSort(index, sortThis) {
+		var sort = sortThis.value;
+		if (sort <= 0) {
+
+		}
+		var image = imageList[index];
+		image.sort = sort;
+	}
+
+	function updateStatus(status, index) {
+		var image = imageList[index];
+		confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+			image.status = status;
+			batchSaveProductSort();
+		})
+	}
+
+
+	function clickAllSelect(ckb, type) {
+		var isChecked = ckb.checked;
+		if (type === 1) {
+			$(".product-check-item").attr('checked', isChecked);
+		} else {
+			$(".user-check-item").attr('checked', isChecked);
+		}
+	}
+
+	/**
+	 * 商品删除操作
+	 */
+	function productDelete(index) {
+		return confirmx("确定删除吗?", function () {
+			var image = imageList[index];
+			if (image.productId != '') {
+				productIds = productIds.replace(image.productId,"");
+			}
+			imageList.splice(index, 1);
+			productInsertHtml(imageList);
+			if (imageList.length == 0) {
+				$('#productTable').hide();
+				$("#productDel").attr("disabled", "disabled");
+			}
+		});
+	}
+
+	/**
+	 * 用户删除操作
+	 */
+	function userDelete(index) {
+		return confirmx("确定删除吗?", function () {
+			var user = userList[index];
+			if (user.userId != '') {
+				userIds = userIds.replace(user.userId,"");
+			}
+			userList.splice(index, 1);
+			userInsertHtml(userList);
+			if (userList.length == 0) {
+				$('#userTable').hide();
+				$("#userDel").attr("disabled", "disabled");
+			}
+		});
+	}
+
+
+	/**
+	 * 批量删除商品
+	 */
+	function productBatchDeletion() {
+		var index = -1;
+		var i = 1;
+		return confirmx("确定删除吗?", function () {
+			$('input[name="info"]:checked').each(function () {
+				var thisIndex = $(this).val();
+				if (index >= 0 && index < thisIndex) {
+					thisIndex = thisIndex - i;
+					i++;
+				} else {
+					index = thisIndex;
+				}
+				var image = imageList[thisIndex];
+				if (image.productId != '') {
+					productIds = productIds.replace(image.productId, "");
+				}
+				imageList.splice(thisIndex, 1);
+				productInsertHtml(imageList);
+				if (imageList.length == 0) {
+					$('#productTable').hide();
+					$("#productDel").attr("disabled", "disabled");
+				}
+			});
+		});
+	}
+	/**
+	 * 批量删除用户
+	 */
+	function userBatchDeletion() {
+		var index = -1;
+		var i = 1;
+		return confirmx("确定删除吗?", function () {
+			$('input[name="info"]:checked').each(function () {
+				var thisIndex = $(this).val();
+				if (index >= 0 && index < thisIndex) {
+					thisIndex = thisIndex - i;
+					i++;
+				} else {
+					index = thisIndex;
+				}
+				var user = userList[thisIndex];
+				if (user.userId != '') {
+					userIds = userIds.replace(user.userId, "");
+				}
+				userList.splice(thisIndex, 1);
+				userInsertHtml(userList);
+				if (userList.length == 0) {
+					$('#userTable').hide();
+					$("#userDel").attr("disabled", "disabled");
+				}
+			});
+		});
+	}
+
+	function productShow() {
+		var  productType = $("input[name='productType']:checked").val();
+		if (productType == 2){
+			$(".productData").show();
+		}else {
+			$(".productData").hide();
+		}
+	}
+
+
+</script>
+</body>
+</html>

+ 118 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheCouponList.jsp

@@ -0,0 +1,118 @@
+<%@ 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 class="${cmHeheCoupon.couponType eq 1?'active':''}"><a href="${ctx}/hehe/cmHeheCoupon/?couponType=1">活动券</a></li>
+		<li class="${cmHeheCoupon.couponType eq 2?'active':''}"><a href="${ctx}/hehe/cmHeheCoupon/?couponType=2">专享券</a></li>
+		<li class="${cmHeheCoupon.couponType eq 3?'active':''}"><a href="${ctx}/hehe/cmHeheCoupon/?couponType=3">新人券</a></li>
+		<li class="${cmHeheCoupon.couponType eq 4?'active':''}"><a href="${ctx}/hehe/cmHeheCoupon/?couponType=4">好友分享券</a></li>
+		<li class="${cmHeheCoupon.couponType eq 5?'active':''}"><a href="${ctx}/hehe/cmHeheCoupon/?couponType=5">好友消费券</a></li>
+	</ul>
+	<form:form id="searchForm" modelAttribute="cmHeheCoupon" action="${ctx}/hehe/cmHeheCoupon/" 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>优惠券名称:</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:option value="3" label="已下架"/>
+				</form:select>
+			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+			<a class="btn btn-primary" href="${ctx}/hehe/cmHeheCoupon/form?couponType=${cmHeheCoupon.couponType}" style="margin-left: 15px">
+				添加${cmHeheCoupon.couponType eq 1?'活动':cmHeheCoupon.couponType eq 2?'专享':cmHeheCoupon.couponType eq 3?'新人':cmHeheCoupon.couponType eq 4?'好友分享':'好友消费'}券
+			</a>
+			<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>ID</th>
+				<th>优惠券名称</th>
+				<th>优惠券金额</th>
+				<th>优惠条件</th>
+				<th>上架时间</th>
+				<th>下架时间</th>
+				<th>领取期限</th>
+				<th>使用期限</th>
+				<th>状态</th>
+				<th>创建时间</th>
+				<th>操作</th>
+			</tr>
+		</thead>
+		<tbody>
+		<c:forEach items="${page.list}" var="cmHeheCoupon">
+			<tr>
+				<td>
+					${cmHeheCoupon.id}
+				</td>
+				<td>
+					${cmHeheCoupon.name}
+				</td>
+				<td>
+					${cmHeheCoupon.couponAmount}
+				</td>
+				<td>
+					${cmHeheCoupon.touchPrice}
+				</td>
+				<td>
+					<fmt:formatDate value="${cmHeheCoupon.startTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<c:if test="${cmHeheCoupon.permanentFlag eq 1}">永久</c:if>
+					<c:if test="${cmHeheCoupon.permanentFlag ne 1}">
+						<fmt:formatDate value="${cmHeheCoupon.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+					</c:if>
+				</td>
+				<td>
+					<c:if test="${cmHeheCoupon.receiveFlag eq 1}">同上下架时间</c:if>
+					<c:if test="${cmHeheCoupon.receiveFlag ne 1}">${cmHeheCoupon.receivePeriod}</c:if>
+				</td>
+				<td>
+					${cmHeheCoupon.usePeriod}
+				</td>
+				<td>
+					<label style="color: ${cmHeheCoupon.status eq 1?'#2FA4E7':cmHeheCoupon.status eq 2?'#FF0000':'#999999'}">
+						${cmHeheCoupon.status eq 1?'待上架':cmHeheCoupon.status eq 2?'已上架':'已下架'}
+					</label>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmHeheCoupon.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+    				<a href="${ctx}/hehe/cmHeheCoupon/form?id=${cmHeheCoupon.id}">编辑</a>
+					<a href="${ctx}/hehe/cmHeheCoupon/delete?id=${cmHeheCoupon.id}" onclick="return confirmx('确认要删除该优惠券吗?', this.href)">删除</a>
+					<a href="${ctx}/hehe/cmHeheCoupon/receive/user/list?couponId=${cmHeheCoupon.id}&couponType=${cmHeheCoupon.couponType}">领取用户</a>
+				</td>
+			</tr>
+		</c:forEach>
+		</tbody>
+	</table>
+	<div class="pagination">${page}</div>
+</body>
+</html>

+ 491 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountForm.jsp

@@ -0,0 +1,491 @@
+<%@ page import="java.util.Date" %>
+<%@ page contentType="text/html;charset=UTF-8" %>
+<%@ 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){
+					if (imageList.length > 0) {
+						var productInfo = JSON.stringify(imageList);
+						$('#productInfo').val(productInfo);
+					}
+					if (userList.length > 0) {
+						var userInfo = JSON.stringify(userList);
+						$("#userInfo").val(userInfo);
+					}
+					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);
+					}
+				}
+			});
+		});
+
+		/**
+		 * @param obj
+		 * jquery控制input只能输入数字
+		 */
+		function onlynum(obj) {
+			obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+		}
+	</script>
+</head>
+<body>
+	<ul class="nav nav-tabs">
+		<li><a href="${ctx}/hehe/cmHeheDiscount/">内部优惠列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheDiscount/form?id=${cmHeheDiscount.id}">${not empty cmHeheDiscount.id?'编辑':'添加'}</a></li>
+	</ul><br/>
+	<form:form id="inputForm" modelAttribute="cmHeheDiscount" action="${ctx}/hehe/cmHeheDiscount/save" method="post" class="form-horizontal">
+		<form:hidden path="id"/>
+		<form:hidden path="productInfo"/>
+		<form:hidden path="userInfo"/>
+		<sys:message content="${message}"/>		
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>标题:</label>
+			<div class="controls">
+				<form:input path="title" htmlEscape="false" maxlength="30" placeholder="30个汉字以内" class="input-xlarge required"/>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>折扣率:</label>
+			<div class="controls">
+				<form:input path="discount" htmlEscape="false" onkeyup="onlynum(this)" class="input-xlarge  digits required"/> %
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>状态:</label>
+			<div class="controls">
+				<form:select path="status" class="input-medium required">
+					<form:option value="1" label="启用"/>
+					<form:option value="0" label="停用"/>
+				</form:select>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>优惠商品:</label>
+			<div class="controls">
+				<form:radiobutton path="productType" value="1" label="全商城商品" onclick="productShow()" checked="${empty cmHeheDiscount.productType ? true:false}"/>
+				<form:radiobutton path="productType" value="2" label="指定商品" onclick="productShow()" />
+			</div>
+		</div>
+		<div class="productData" hidden="hidden">
+			<div class="control-group">
+				<input class="btn" id="productDel" style="width: 50px" onclick="productBatchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
+				<input class="btn btn-primary" style="width: 70px" onclick="batchSaveProductSort()" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;
+				<input class="btn btn-primary" style="width: 50px" onclick="productShowSelect()" value="添加"/>
+				<br><br>
+				<table id="productTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+					<thead>
+					<tr>
+						<th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this,1);"/> 全选
+						</th>
+						<th>商品图片</th>
+						<th>商品名称</th>
+						<th>供应商</th>
+						<th>状态</th>
+						<th>排序</th>
+						<th>添加时间</th>
+						<th>操作</th>
+					</tr>
+					</thead>
+					<tbody id="productTbody"></tbody>
+				</table>
+			</div>
+		</div>
+		<div class="control-group">
+			<label class="control-label"><font color="red">*</font>用户列表:</label>
+		</div>
+		<div class="userData">
+			<div class="control-group">
+				<input class="btn" id="userDel" style="width: 50px" onclick="userBatchDeletion()" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
+				<input class="btn btn-primary" style="width: 50px" onclick="userShowSelect()" value="添加"/>
+				<br><br>
+				<table id="userTable" class="table table-striped table-bordered table-condensed" hidden="hidden">
+					<thead>
+					<tr>
+						<th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this,2);"/> 全选
+						</th>
+						<th>微信昵称</th>
+						<th>手机号</th>
+						<th>身份</th>
+						<th>添加时间</th>
+						<th>操作</th>
+					</tr>
+					</thead>
+					<tbody id="userTbody"></tbody>
+				</table>
+			</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>
+	var productIds = '';
+	var imageList = [];
+
+	var userIds = '';
+	var userList = [];
+
+	$(function () {
+		<c:forEach items="${productList}" var="product" varStatus="index">
+		imageList.push({
+			id: "${product.id}",
+			productId: "${empty product.productId ? "":product.productId}",
+			image: "${product.image}",
+			productName: "${product.productName}",
+			shopName: "${product.shopName}",
+			sort: "${product.sort}",
+			status: "${product.status}",
+			addTime: "<fmt:formatDate value="${product.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+		});
+		</c:forEach>
+		debugger
+		<c:forEach items="${userList}" var="user" varStatus="index">
+		userList.push({
+			userId: "${user.userId}",
+			nickName: "${user.nickName}",
+			mobile: "${user.mobile}",
+			userIdentity: "${user.userIdentity}",
+			addTime: "<fmt:formatDate value="${user.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+		});
+		</c:forEach>
+
+		if (imageList.length > 0) {
+			$('#productTable').show();
+			batchSaveProductSort();
+		}
+		if (userList.length > 0) {
+			$('#userTable').show();
+			batchSaveUserSort();
+		}
+
+		productShow();
+	});
+
+
+	//商品添加
+	function productShowSelect() {
+		var url = "${ctx}/hehe/cmHeheDiscount/toAddProduct?productIds=" + productIds;
+		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);
+					console.log(items[0]);
+					for (var i = 0; i < items.length; i++) {
+						console.log(items[i]);
+						imageList.push(items[i]);
+						$('#productTable').show();
+						$("#productDel").removeAttr("disabled");
+						batchSaveProductSort();
+					};
+				}
+				return true;
+			}
+		});
+	}
+
+	//用户添加
+	function userShowSelect() {
+		debugger
+		var url = "${ctx}/hehe/cmHeheDiscount/toAddUser?userIds=" + userIds;
+		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);
+					console.log(items[0]);
+					for (var i = 0; i < items.length; i++) {
+						console.log(items[i]);
+						userList.push(items[i]);
+						$('#userTable').show();
+						$("#userDel").removeAttr("disabled");
+						batchSaveUserSort();
+					};
+				}
+				return true;
+			}
+		});
+	}
+
+
+	/**
+	 * 一键排序
+	 */
+	function batchSaveProductSort() {
+		imageList.sort(sort);
+		productInsertHtml(imageList);
+	}
+	/**
+	 * 一键排序
+	 */
+	function batchSaveUserSort() {
+		userInsertHtml(userList);
+	}
+
+	//根据sort值 从小到大排序
+	function sort(a, b) {
+		return a.sort - b.sort;
+	}
+
+	//相关图片列表数据
+	function appendProduct(data, index) {
+		var html = '<tr id ="ai' + index + '">' +
+				'<td>' +
+				'<input class="product-check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
+				'</td>' +
+				'<td>' +
+				'<img src="' + data.image + '" width="60px" border="none" title="启用">' +
+				'</td>' +
+				'<td>' +
+				data.productName +
+				'</td>' +
+				'<td>' +
+				data.shopName +
+				'</td>' +
+				'<td>' +
+				(data.status == 1 ? (
+						'<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0);" onclick="updateStatus(0,' + index + ');" >' +
+						'停用</a>'
+				) : (
+						'<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
+						'<a href="javascript:void(0)" onclick="updateStatus(1,' + index + ');">' +
+						'启用</a>'
+				)) +
+				'</td>' +
+				'</td>' +
+				'<td>' +
+				'<input name="sort" style="width:50px;" value="' + data.sort + '"  onkeyup="onlynum(this)"  onchange="changeSort(' + index + ',this)"></td>' +
+				'</td>' +
+				'<td>' +
+				(data.addTime == '' ? (
+						'<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
+				) : (
+						data.addTime
+				)) +
+				'</td>' +
+				'<td>' +
+				'<a href="javascript:;" onclick="productDelete(' + index + ')">删除</a>' +
+				'</td>' +
+				'</tr>';
+		return html;
+	}
+
+	//相关用户列表数据
+	function appendUser(data, index) {
+		var html = '<tr id ="ai' + index + '">' +
+				'<td>' +
+				'<input class="user-check-item" type="checkbox" name="info" value="' + index + '"/>' + (index + 1) +
+				'</td>' +
+				'<td>' +
+				data.nickName +
+				'</td>' +
+				'<td>' +
+				data.mobile +
+				'</td>' +
+				'<td>' +
+				(data.userIdentity === 1 ? '普通用户':'分销者') +
+				'</td>' +
+				'<td>' +
+				(data.addTime == '' ? (
+						'<fmt:formatDate value="<%=new Date()%>" pattern="yyyy-MM-dd HH:mm:ss"/>'
+				) : (
+						data.addTime
+				)) +
+				'</td>' +
+				'<td>' +
+				'<a href="javascript:;" onclick="userDelete(' + index + ')">删除</a>' +
+				'</td>' +
+				'</tr>';
+		return html;
+	}
+
+	function productInsertHtml(list) {
+		var html = '';
+		productIds = '';
+		list.forEach(function (item, index) {
+			html += appendProduct(item, index);
+			productIds += "," + item.productId;
+		});
+		$("#productTbody").html(html);
+	}
+
+	function userInsertHtml(list) {
+		var html = '';
+		userIds = '';
+		list.forEach(function (item, index) {
+			html += appendUser(item, index);
+			userIds += "," + item.userId;
+		});
+		$("#userTbody").html(html);
+	}
+
+	function changeSort(index, sortThis) {
+		var sort = sortThis.value;
+		if (sort <= 0) {
+
+		}
+		var image = imageList[index];
+		image.sort = sort;
+	}
+
+	function updateStatus(status, index) {
+		var image = imageList[index];
+		confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+			image.status = status;
+			batchSaveProductSort();
+		})
+	}
+
+
+	function clickAllSelect(ckb, type) {
+		var isChecked = ckb.checked;
+		if (type === 1) {
+			$(".product-check-item").attr('checked', isChecked);
+		} else {
+			$(".user-check-item").attr('checked', isChecked);
+		}
+	}
+
+	/**
+	 * 商品删除操作
+	 */
+	function productDelete(index) {
+		return confirmx("确定删除吗?", function () {
+			var image = imageList[index];
+			if (image.productId != '') {
+				productIds = productIds.replace(image.productId,"");
+			}
+			imageList.splice(index, 1);
+			productInsertHtml(imageList);
+			if (imageList.length == 0) {
+				$('#productTable').hide();
+				$("#productDel").attr("disabled", "disabled");
+			}
+		});
+	}
+
+	/**
+	 * 用户删除操作
+	 */
+	function userDelete(index) {
+		return confirmx("确定删除吗?", function () {
+			var user = userList[index];
+			if (user.userId != '') {
+				userIds = userIds.replace(user.userId,"");
+			}
+			userList.splice(index, 1);
+			userInsertHtml(userList);
+			if (userList.length == 0) {
+				$('#userTable').hide();
+				$("#userDel").attr("disabled", "disabled");
+			}
+		});
+	}
+
+
+	/**
+	 * 批量删除商品
+	 */
+	function productBatchDeletion() {
+		var index = -1;
+		var i = 1;
+		return confirmx("确定删除吗?", function () {
+			$('input[name="info"]:checked').each(function () {
+				var thisIndex = $(this).val();
+				if (index >= 0 && index < thisIndex) {
+					thisIndex = thisIndex - i;
+					i++;
+				} else {
+					index = thisIndex;
+				}
+				var image = imageList[thisIndex];
+				if (image.productId != '') {
+					productIds = productIds.replace(image.productId, "");
+				}
+				imageList.splice(thisIndex, 1);
+				productInsertHtml(imageList);
+				if (imageList.length == 0) {
+					$('#productTable').hide();
+					$("#productDel").attr("disabled", "disabled");
+				}
+			});
+		});
+	}
+	/**
+	 * 批量删除用户
+	 */
+	function userBatchDeletion() {
+		var index = -1;
+		var i = 1;
+		return confirmx("确定删除吗?", function () {
+			$('input[name="info"]:checked').each(function () {
+				var thisIndex = $(this).val();
+				if (index >= 0 && index < thisIndex) {
+					thisIndex = thisIndex - i;
+					i++;
+				} else {
+					index = thisIndex;
+				}
+				var user = userList[thisIndex];
+				if (user.userId != '') {
+					userIds = userIds.replace(user.userId, "");
+				}
+				userList.splice(thisIndex, 1);
+				userInsertHtml(userList);
+				if (userList.length == 0) {
+					$('#userTable').hide();
+					$("#userDel").attr("disabled", "disabled");
+				}
+			});
+		});
+	}
+
+	function productShow() {
+		var  productType = $("input[name='productType']:checked").val();
+		if (productType == 2){
+			$(".productData").show();
+		}else {
+			$(".productData").hide();
+		}
+	}
+</script>
+</body>
+</html>

+ 114 - 0
src/main/webapp/WEB-INF/views/modules/hehe/cmHeheDiscountList.jsp

@@ -0,0 +1,114 @@
+<%@ 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 class="active"><a href="${ctx}/hehe/cmHeheDiscount/">内部优惠列表</a></li>
+		<li><a href="${ctx}/hehe/cmHeheDiscount/form">内部优惠添加</a></li>
+	</ul>
+	<form:form id="searchForm" modelAttribute="cmHeheDiscount" action="${ctx}/hehe/cmHeheDiscount/" 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>标题:</label>
+				<form:input path="title" htmlEscape="false" maxlength="30" 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>
+			&nbsp;&nbsp;<input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
+			<a class="btn btn-primary" href="${ctx}/hehe/cmHeheDiscount/form" style="margin-left: 15px">
+				添加内部优惠
+			</a>
+			<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>ID</th>
+				<th>标题</th>
+				<th>折扣率</th>
+				<th>状态</th>
+				<th>创建时间</th>
+				<th>操作</th>
+			</tr>
+		</thead>
+		<tbody>
+		<c:forEach items="${page.list}" var="cmHeheDiscount">
+			<tr>
+				<td>
+					${cmHeheDiscount.id}
+				</td>
+				<td>
+					${cmHeheDiscount.title}
+				</td>
+				<td>
+					${cmHeheDiscount.discount}%
+				</td>
+				<td>
+					<font color="${cmHeheDiscount.status eq 1?'green':'red'}">
+							${cmHeheDiscount.status eq 1?'已启用':'已停用'}
+					</font>
+					<a href="javascript:void(0);" onclick="updateStatus(cmHeheDiscount.status eq 1?'0':'1','${cmHeheActivity.id}');" >
+							${cmHeheDiscount.status eq 1?'停用':'启用'}
+					</a>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmHeheDiscount.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+    				<a href="${ctx}/hehe/cmHeheDiscount/form?id=${cmHeheDiscount.id}">编辑</a>
+					<a href="${ctx}/hehe/cmHeheDiscount/delete?id=${cmHeheDiscount.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('0'==status){
+			msg='确定停用该优惠吗?';
+		}
+		top.$.jBox.confirm(msg,'系统提示',function(v,h,f){
+			if(v=='ok'){
+				$.post("${ctx}/hehe/cmHeheDiscount/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>

+ 117 - 0
src/main/webapp/WEB-INF/views/modules/hehe/receiveDetailsList.jsp

@@ -0,0 +1,117 @@
+<%@ 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/cmHeheCoupon/user/list">用户领取列表</a></li>
+		<li class="active"><a href="${ctx}/hehe/cmHeheCoupon/receiveDetails?userId=${cmHeheCoupon.userId}">查看详情</a></li>
+	</ul>
+	<form:form id="searchForm" modelAttribute="cmHeheCoupon" action="${ctx}/hehe/cmHeheCoupon/" 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}"/>
+		<form:hidden path="userId" />
+		<div class="ul-form">
+			 <label>优惠券名称:</label>
+				<form:input path="name" htmlEscape="false" maxlength="50" class="input-medium"/>
+			<label>优惠券类型:</label>
+				<form:select path="couponType" class="input-medium">
+					<form:option value="" label="全部"/>
+					<form:option value="1" label="活动券"/>
+					<form:option value="2" label="专享券"/>
+					<form:option value="3" label="新人券"/>
+					<form:option value="4" label="好友分享券"/>
+					<form:option value="5" label="好友消费券"/>
+				</form:select>
+			<label>状态:</label>
+				<form:select path="useStatus" 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="查询"/>
+			<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>
+				<th>状态</th>
+				<th>创建时间</th>
+			</tr>
+		</thead>
+		<tbody>
+		<c:forEach items="${page.list}" var="cmHeheCoupon">
+			<tr>
+				<td>
+					${cmHeheCoupon.name}
+				</td>
+				<td>
+					${cmHeheCoupon.couponType eq 1?'活动':cmHeheCoupon.couponType eq 2?'专享':cmHeheCoupon.couponType eq 3?'新人':cmHeheCoupon.couponType eq 4?'好友分享':'好友消费'}券
+				</td>
+				<td>
+					${cmHeheCoupon.couponAmount}
+				</td>
+				<td>
+					${cmHeheCoupon.touchPrice}
+				</td>
+				<td>
+					<fmt:formatDate value="${cmHeheCoupon.receiveTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<fmt:formatDate value="${cmHeheCoupon.validPeriod}" pattern="yyyy-MM-dd HH:mm:ss"/>
+				</td>
+				<td>
+					<label style="color: ${cmHeheCoupon.useStatus eq 2?'#ff0000':user.validFlag eq 1?'#2FA4E7':'#999999'}">
+							${cmHeheCoupon.useStatus eq 2?'已使用':cmHeheCoupon.validFlag eq 1?'未使用':'已失效'}
+					</label>
+				</td>
+				<td>
+					<c:if test="${cmHeheCoupon.useTime ne null}">
+						<fmt:formatDate value="${cmHeheCoupon.useTime}" pattern="yyyy-MM-dd HH:mm:ss"/>
+					</c:if>
+					<c:if test="${cmHeheCoupon.useTime eq null}">
+						----
+					</c:if>
+				</td>
+				<td>
+					<c:if test="${cmHeheCoupon.orderNo ne null}">
+						<a href="${ctx}/hehe/new/order/detail?id=${cmHeheCoupon.orderId}" style="text-decoration: underline !important;">
+								${cmHeheCoupon.orderNo}(${cmHeheCoupon.orderId})
+						</a>
+					</c:if>
+				</td>
+			</tr>
+		</c:forEach>
+		</tbody>
+	</table>
+	<div class="pagination">${page}</div>
+</body>
+</html>

+ 115 - 0
src/main/webapp/WEB-INF/views/modules/hehe/receiveUserList.jsp

@@ -0,0 +1,115 @@
+<%@ 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;
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li><a href="${ctx}/hehe/cmHeheCoupon/?couponType=${cmHeheReceiveUser.couponType}">${cmHeheReceiveUser.couponType eq 1?'活动':cmHeheReceiveUser.couponType eq 2?'专享':cmHeheReceiveUser.couponType eq 3?'新人':cmHeheReceiveUser.couponType eq 4?'好友分享':'好友消费'}券</a></li>
+    <li class="active"><a href="${ctx}/hehe/cmHeheCoupon/receive/user/list?couponType=${cmHeheReceiveUser.couponType}&couponId=${cmHeheReceiveUser.couponId}">领取用户列表</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmHeheReceiveUser" action="${ctx}/hehe/cmHeheCoupon/receive/user/list" method="post" class="breadcrumb form-search">
+    <form:hidden path="couponId"/>
+    <form:hidden path="couponType"/>
+    <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="nickName" htmlEscape="false" maxlength="20" class="input-medium"/>
+        <label>手机号:</label>
+        <form:input path="mobile" htmlEscape="false" maxlength="15" class="input-medium" onkeyup="onlynum(this)"/>
+        <label>使用状态:</label>
+        <form:select path="status" class="input-small">
+            <form:option value="" label="全部"/>
+            <form:option value="1" label="未使用"/>
+            <form:option value="2" label="已使用"/>
+            <form:option value="3" label="已失效"/>
+        </form:select>
+        <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>
+        <th>ID</th>
+        <th>微信昵称</th>
+        <th>手机号</th>
+        <th>领取渠道</th>
+        <th>领取时间</th>
+        <th>优惠券有效期</th>
+        <th>优惠券状态</th>
+        <th>使用时间</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="user" varStatus="index">
+        <tr>
+            <td>
+                    ${user.userId}
+            </td>
+            <td>
+                    ${user.nickName}
+            </td>
+            <td>
+                    ${user.mobile}
+            </td>
+            <td>
+                    ${user.source eq 1 ? "小程序":"订单退回"}
+            </td>
+            <td>
+                    <fmt:formatDate value="${user.receiveTime}" pattern="yyyy-MM-dd HH:mm:ss" />
+            </td>
+            <td>
+                    <fmt:formatDate value="${user.validPeriod}" pattern="yyyy-MM-dd HH:mm:ss" />
+            </td>
+            <td>
+                <c:if test="${user.status eq 2}">
+                    <a href="${ctx}/hehe/new/order/detail?id=${user.orderId}" style="color: #ff0000;text-decoration: underline !important;}">
+                            已使用
+                    </a>
+                </c:if>
+                <c:if test="${user.status ne 2}">
+                    <label style="color: ${user.validFlag eq 1?'#2FA4E7':'#999999'}">
+                            ${user.validFlag eq 1?'未使用':'已失效'}
+                    </label>
+                </c:if>
+            </td>
+            <td>
+                    <c:if test="${user.status eq 2}">
+                        <fmt:formatDate value="${user.useTime}" pattern="yyyy-MM-dd HH:mm:ss" />
+                    </c:if>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>

+ 134 - 0
src/main/webapp/WEB-INF/views/modules/hehe/toAddCouponProduct.jsp

@@ -0,0 +1,134 @@
+<%@ page import="java.util.Date" %>
+<%@ 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 = [];
+            var $items = $('.check-item:checked');
+            $items.each(function(){
+                var product = JSON.parse($(this).val());
+                items.push({
+                    "id": "",
+                    "productId": product.productID,
+                    "image": product.mainImage,
+                    "productName": product.name,
+                    "shopName": product.shopName,
+                    "sort": 1,
+                    "status": "1",
+                    "addTime": ""
+                })
+            });
+            return items;
+        }
+
+        function allCkbfun(ckb){
+            var isChecked = ckb.checked;
+            $(".check-item").each2(function () {
+                var attr = $(this).attr("disabled");
+                if (attr != 'disabled') {
+                    $(this).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="product" action="${ctx}/hehe/cmHeheCoupon/toAddProduct?productIds=${productIds}" 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="10" class="input-mini" onchange="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="搜索"/>
+        <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.productID}" class="itemtr">
+                    <%--已过滤添加过的商品和未上架的商品--%>
+                <th>
+                    <input class="check-item" ${item.storeStatus ? "disabled" : ""}  type="checkbox" name="info" value='${fns:toJson(item)}'/>
+                </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>

+ 137 - 0
src/main/webapp/WEB-INF/views/modules/hehe/toAddCouponUser.jsp

@@ -0,0 +1,137 @@
+<%@ page import="java.util.Date" %>
+<%@ 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 = [];
+            var $items = $('.check-item:checked');
+            $items.each(function(){
+                var user = JSON.parse($(this).val());
+                items.push({
+                    "id": '',
+                    "userId": user.id,
+                    "nickName": user.nickName,
+                    "mobile": user.mobile,
+                    "userIdentity": user.userIdentity,
+                    "openId": user.openID,
+                    "addTime": ''
+                })
+            });
+            return items;
+        }
+
+        function allCkbfun(ckb){
+            var isChecked = ckb.checked;
+            $(".check-item").each2(function () {
+                var attr = $(this).attr("disabled");
+                if (attr != 'disabled') {
+                    $(this).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="cmUser" action="${ctx}/hehe/cmHeheCoupon/toAddUser?userIds=${userIds}" 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>微信昵称:</label>
+        <form:input path="nickName" htmlEscape="false"  maxlength="30" class="input-mini"/>
+        <label>手机号:</label>
+        <form:input path="mobile" htmlEscape="false" class="input-medium" maxlength="15"/>
+        <label>身份:</label>
+        <form:select path="userIdentity" class="input-small">
+            <form:option value="" label="请选择"/>
+            <form:option value="1" label="普通用户"/>
+            <form:option value="2" label="分销者"/>
+        </form:select>
+        &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>微信昵称</th>
+        <th>手机号</th>
+        <th>身份</th>
+        <th>openID</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" ${item.storeStatus ? "disabled" : ""}  type="checkbox" name="info" value='${fns:toJson(item)}'/>
+                </th>
+                <td>${item.nickName}</td>
+                <td>${item.mobile}</td>
+                <td>${item.userIdentity eq 1?"普通用户" : "分销者"}</td>
+                <td>${item.openID}</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>

+ 134 - 0
src/main/webapp/WEB-INF/views/modules/hehe/toAddDiscountProduct.jsp

@@ -0,0 +1,134 @@
+<%@ page import="java.util.Date" %>
+<%@ 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 = [];
+            var $items = $('.check-item:checked');
+            $items.each(function(){
+                var product = JSON.parse($(this).val());
+                items.push({
+                    "id": "",
+                    "productId": product.productID,
+                    "image": product.mainImage,
+                    "productName": product.name,
+                    "shopName": product.shopName,
+                    "sort": 1,
+                    "status": "1",
+                    "addTime": ""
+                })
+            });
+            return items;
+        }
+
+        function allCkbfun(ckb){
+            var isChecked = ckb.checked;
+            $(".check-item").each2(function () {
+                var attr = $(this).attr("disabled");
+                if (attr != 'disabled') {
+                    $(this).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="product" action="${ctx}/hehe/cmHeheDiscount/toAddProduct?productIds=${productIds}" 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="10" class="input-mini" onchange="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="搜索"/>
+        <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.productID}" class="itemtr">
+                    <%--已过滤添加过的商品和未上架的商品--%>
+                <th>
+                    <input class="check-item" ${item.storeStatus ? "disabled" : ""}  type="checkbox" name="info" value='${fns:toJson(item)}'/>
+                </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>

+ 137 - 0
src/main/webapp/WEB-INF/views/modules/hehe/toAddDiscountUser.jsp

@@ -0,0 +1,137 @@
+<%@ page import="java.util.Date" %>
+<%@ 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 = [];
+            var $items = $('.check-item:checked');
+            $items.each(function(){
+                var user = JSON.parse($(this).val());
+                items.push({
+                    "id": '',
+                    "userId": user.id,
+                    "nickName": user.nickName,
+                    "mobile": user.mobile,
+                    "userIdentity": user.userIdentity,
+                    "openId": user.openID,
+                    "addTime": ''
+                })
+            });
+            return items;
+        }
+
+        function allCkbfun(ckb){
+            var isChecked = ckb.checked;
+            $(".check-item").each2(function () {
+                var attr = $(this).attr("disabled");
+                if (attr != 'disabled') {
+                    $(this).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="cmUser" action="${ctx}/hehe/cmHeheDiscount/toAddUser?userIds=${userIds}" 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>微信昵称:</label>
+        <form:input path="nickName" htmlEscape="false"  maxlength="30" class="input-mini"/>
+        <label>手机号:</label>
+        <form:input path="mobile" htmlEscape="false" class="input-medium" maxlength="15"/>
+        <label>身份:</label>
+        <form:select path="userIdentity" class="input-small">
+            <form:option value="" label="请选择"/>
+            <form:option value="1" label="普通用户"/>
+            <form:option value="2" label="分销者"/>
+        </form:select>
+        &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>微信昵称</th>
+        <th>手机号</th>
+        <th>身份</th>
+        <th>openID</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" ${item.storeStatus ? "disabled" : ""}  type="checkbox" name="info" value='${fns:toJson(item)}'/>
+                </th>
+                <td>${item.nickName}</td>
+                <td>${item.mobile}</td>
+                <td>${item.userIdentity eq 1?"普通用户" : "分销者"}</td>
+                <td>${item.openID}</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>

+ 96 - 0
src/main/webapp/WEB-INF/views/modules/hehe/userAllCouponList.jsp

@@ -0,0 +1,96 @@
+<%@ 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;
+        }
+
+        /**
+         * @param obj
+         * jquery控制input只能输入数字
+         */
+        function onlynum(obj) {
+            obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+        }
+    </script>
+</head>
+<body>
+<ul class="nav nav-tabs">
+    <li class="active"><a href="${ctx}/hehe/cmHeheCoupon/user/list">用户领取列表</a></li>
+</ul>
+<form:form id="searchForm" modelAttribute="cmHeheReceiveUser" action="${ctx}/hehe/cmHeheCoupon/user/list" 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>微信昵称:</label>
+        <form:input path="nickName" htmlEscape="false" maxlength="20" class="input-medium"/>
+        <label>手机号:</label>
+        <form:input path="mobile" htmlEscape="false" maxlength="15" class="input-medium" onkeyup="onlynum(this)"/>
+        <label>身份:</label>
+        <form:select path="userIdentity" class="input-small">
+            <form:option value="" label="全部"/>
+            <form:option value="1" label="普通用户"/>
+            <form:option value="2" label="分销者"/>
+        </form:select>
+        <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>
+        <th>ID</th>
+        <th>微信昵称</th>
+        <th>手机号</th>
+        <th>身份</th>
+        <th>领取优惠券总数</th>
+        <th>可用优惠券总数</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="user" varStatus="index">
+        <tr>
+            <td>
+                    ${user.userId}
+            </td>
+            <td>
+                    ${user.nickName}
+            </td>
+            <td>
+                    ${user.mobile}
+            </td>
+            <td>
+                    ${user.userIdentity eq 1 ? "普通用户":"分销者"}
+            </td>
+            <td>
+                    ${user.receiveNum}
+            </td>
+            <td>
+                    ${user.ableNum}
+            </td>
+            <td>
+                <a href="${ctx}/hehe/cmHeheCoupon/receiveDetails?userId=${user.userId}" >查看详情</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+</body>
+</html>