浏览代码

超级会员优惠券

chao 3 年之前
父节点
当前提交
2525579442

+ 21 - 25
src/main/java/com/caimei/modules/coupon/dao/CmCouponVipDao.java

@@ -1,8 +1,10 @@
 package com.caimei.modules.coupon.dao;
 
+import com.caimei.modules.coupon.entity.CmCoupon;
 import com.caimei.modules.coupon.entity.CmVipCoupon;
-import com.caimei.modules.coupon.entity.SvipCouponList;
+import com.caimei.modules.coupon.entity.CmVipCouponRelation;
 import com.caimei.modules.user.entity.NewCmShop;
+import com.thinkgem.jeesite.common.persistence.CrudDao;
 import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
 import org.apache.ibatis.annotations.Param;
 
@@ -12,22 +14,15 @@ import java.util.List;
  * @author 超级会员优惠券
  */
 @MyBatisDao
-public interface CmCouponVipDao {
-
-    /**
-     * 查找所有的超级会员优惠券
-     *
-     * @return
-     */
-    List<CmVipCoupon> findAllVipCoupon(@Param("status") Integer status, @Param("useTime") String useTime, @Param("couponId") Integer couponId);
-
-    /**
-     * 在vip优惠券表添加数据
-     *
-     * @param vipCoupon
-     */
-    void addVipCoupon(CmVipCoupon vipCoupon);
-
+public interface CmCouponVipDao extends CrudDao<CmVipCoupon> {
+    void insertVipCouponMonth(CmVipCoupon cmVipCoupon);
+    void updateVipCouponMonth(CmVipCoupon cmVipCoupon);
+    void insertVipCouponRelation(CmVipCouponRelation relation);
+    void updateVipCouponRelation(CmVipCouponRelation relation);
+    List<String> getBindCoupons(String montId);
+    /** 逻辑删除关系表 */
+    void deleteByMonthId(String montId);
+    List<CmCoupon> getCouponListByIds(@Param("bindCoupons") List<String> bindCoupons,@Param("couponType") String couponType,@Param("status") String status);
     /**
      * 查供应商名称
      *
@@ -36,13 +31,14 @@ public interface CmCouponVipDao {
      */
     NewCmShop findShopName(Integer shopId);
 
-    List<CmVipCoupon> findGroup(String useTime, Integer status);
-
-    List<String> findUseTime();
-
-    List<String> findBind();
-
-    CmVipCoupon findByCoupon(@Param("couponId") Integer couponId, @Param("status") String status);
+//    List<CmVipCouponRelation> findGroup(String useTime, Integer status);
+//
+//    List<String> findUseTime();
+//
+//    List<String> findBind();
+//
+//    CmVipCouponRelation findByCoupon(@Param("couponId") Integer couponId, @Param("status") String status);
+//
+//    void updateVip(CmVipCouponRelation vipCoupon);
 
-    void updateVip(CmVipCoupon vipCoupon);
 }

+ 0 - 25
src/main/java/com/caimei/modules/coupon/dao/SvipCouponListDao.java

@@ -1,25 +0,0 @@
-package com.caimei.modules.coupon.dao;
-
-
-import com.caimei.modules.coupon.entity.CmCoupon;
-import com.caimei.modules.coupon.entity.SvipCouponList;
-import com.thinkgem.jeesite.common.persistence.CrudDao;
-import com.thinkgem.jeesite.common.persistence.annotation.MyBatisDao;
-
-import java.util.List;
-
-@MyBatisDao
-public interface SvipCouponListDao extends CrudDao<SvipCouponList> {
-
-    List<SvipCouponListDao> findList();
-
-    List<SvipCouponList> findLists();
-
-    CmCoupon findStatus(Integer couponId);
-
-    SvipCouponList findVipStatus(Integer couponId);
-
-    void updateVip(SvipCouponList coupon);
-
-    CmCoupon findCoupon(Integer couponId);
-}

+ 85 - 49
src/main/java/com/caimei/modules/coupon/entity/CmVipCoupon.java

@@ -1,94 +1,130 @@
 package com.caimei.modules.coupon.entity;
 
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.joda.time.DateTime;
+import com.thinkgem.jeesite.common.persistence.DataEntity;
 
-import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
- * vip优惠券
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/10/14
  */
-public class CmVipCoupon extends CmCoupon implements Serializable {
-
-    //生效月份 2021-10
+public class CmVipCoupon extends DataEntity<CmVipCoupon> {
+    private static final long serialVersionUID = 1L;
+    private String id;
+    /** 生效月份 */
     private String useTime;
-    //优惠券id
-    private Integer couponId;
-    //一次新建的优惠券字符串拼接结果
-    private String bindCoupon;
-
+    /**
+     * 0未生效 1已生效 2已关闭 3已失效
+     */
     private String status;
-
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    /** 一组优惠券id的String字符串,逗号隔开 */
+    private String bindCoupon;
     private Date updateTime;
+    private String delFlag;
+    /**
+     * 4张优惠券详情
+     */
+    List<CmCoupon> couponList;
+    /** 开始时间 */
+    private Date startDate;
+    /** 结束时间 */
+    private Date endDate;
+    /** 优惠券类型 */
+    private String couponType;
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    private Date createTime;
+    @Override
+    public String getId() {
+        return id;
+    }
 
-    private String delFlag;
+    @Override
+    public void setId(String id) {
+        this.id = id;
+    }
 
-    public String getBindCoupon() {
-        return bindCoupon;
+    public String getUseTime() {
+        return useTime;
     }
 
-    public void setBindCoupon(String bindCoupon) {
-        this.bindCoupon = bindCoupon;
+    public Date getUpdateTime() {
+        return updateTime;
     }
 
-    @Override
-    public String getDelFlag() {
-        return delFlag;
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
     }
 
-    @Override
-    public void setDelFlag(String delFlag) {
-        this.delFlag = delFlag;
+    public void setUseTime(String useTime) {
+        this.useTime = useTime;
     }
 
-    @Override
     public String getStatus() {
         return status;
     }
 
-    @Override
     public void setStatus(String status) {
         this.status = status;
     }
 
-    public String getUseTime() {
-        return useTime;
+//    public Integer getCouponId() {
+//        return couponId;
+//    }
+//
+//    public void setCouponId(Integer couponId) {
+//        this.couponId = couponId;
+//    }
+
+    public String getCouponType() {
+        return couponType;
     }
 
-    public void setUseTime(String useTime) {
-        this.useTime = useTime;
+    public void setCouponType(String couponType) {
+        this.couponType = couponType;
     }
 
-    public Integer getCouponId() {
-        return couponId;
+    public String getBindCoupon() {
+        return bindCoupon;
     }
 
-    public void setCouponId(Integer couponId) {
-        this.couponId = couponId;
+    public void setBindCoupon(String bindCoupon) {
+        this.bindCoupon = bindCoupon;
     }
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public Date getUpdateTime() {
-        return updateTime;
+    @Override
+    public String getDelFlag() {
+        return delFlag;
     }
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
+    @Override
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+
+    public List<CmCoupon> getCouponList() {
+        return couponList;
     }
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public Date getCreateTime() {
-        return createTime;
+    public void setCouponList(List<CmCoupon> couponList) {
+        this.couponList = couponList;
     }
 
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    public void setCreateTime(Date createTime) {
-        this.createTime = createTime;
+    public Date getStartDate() {
+        return startDate;
+    }
+
+    public void setStartDate(Date startDate) {
+        this.startDate = startDate;
+    }
+
+    public Date getEndDate() {
+        return endDate;
+    }
+
+    public void setEndDate(Date endDate) {
+        this.endDate = endDate;
     }
 }
+

+ 52 - 0
src/main/java/com/caimei/modules/coupon/entity/CmVipCouponRelation.java

@@ -0,0 +1,52 @@
+package com.caimei.modules.coupon.entity;
+
+import com.thinkgem.jeesite.common.persistence.DataEntity;
+
+import java.util.Date;
+
+/**
+ * vip优惠券月份关系
+ */
+public class CmVipCouponRelation extends DataEntity<CmVipCouponRelation> {
+    private static final long serialVersionUID = 1L;
+    //优惠券id
+    private String couponId;
+    //优惠券id
+    private String montId;
+    private Date updateTime;
+    private String delFlag;
+
+    public String getCouponId() {
+        return couponId;
+    }
+
+    public void setCouponId(String couponId) {
+        this.couponId = couponId;
+    }
+
+    public String getMontId() {
+        return montId;
+    }
+
+    public void setMontId(String montId) {
+        this.montId = montId;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String getDelFlag() {
+        return delFlag;
+    }
+
+    @Override
+    public void setDelFlag(String delFlag) {
+        this.delFlag = delFlag;
+    }
+}

+ 35 - 24
src/main/java/com/caimei/modules/coupon/entity/SvipCouponForm.java

@@ -14,6 +14,7 @@ import java.util.List;
  * @date : 2021/9/29
  */
 public class SvipCouponForm extends DataEntity<SvipCouponForm> {
+    private String id;
     /**
      * 月份
      */
@@ -59,17 +60,17 @@ public class SvipCouponForm extends DataEntity<SvipCouponForm> {
     /**
      * 优惠券Id
      */
-    private Integer couponId1;
-    private Integer couponId2;
-    private Integer couponId3;
-    private Integer couponId4;
+    private String couponId1;
+    private String couponId2;
+    private String couponId3;
+    private String couponId4;
     /**
      * 劵类型 0活动券 1品类券 3店铺券
      */
-    private Integer couponType1;
-    private Integer couponType2;
-    private Integer couponType3;
-    private Integer couponType4;
+    private String couponType1;
+    private String couponType2;
+    private String couponType3;
+    private String couponType4;
     /**
      * 优惠券金额(面值)
      */
@@ -106,6 +107,16 @@ public class SvipCouponForm extends DataEntity<SvipCouponForm> {
     private Integer shopId3;
     private Integer shopId4;
 
+    @Override
+    public String getId() {
+        return id;
+    }
+
+    @Override
+    public void setId(String id) {
+        this.id = id;
+    }
+
     public NewCmShop getShop1() {
         return shop1;
     }
@@ -305,35 +316,35 @@ public class SvipCouponForm extends DataEntity<SvipCouponForm> {
 //        this.appletsBanner1 = appletsBanner1;
 //    }
 
-    public Integer getCouponId1() {
+    public String getCouponId1() {
         return couponId1;
     }
 
-    public void setCouponId1(Integer couponId1) {
+    public void setCouponId1(String couponId1) {
         this.couponId1 = couponId1;
     }
 
-    public Integer getCouponId2() {
+    public String getCouponId2() {
         return couponId2;
     }
 
-    public void setCouponId2(Integer couponId2) {
+    public void setCouponId2(String couponId2) {
         this.couponId2 = couponId2;
     }
 
-    public Integer getCouponId3() {
+    public String getCouponId3() {
         return couponId3;
     }
 
-    public void setCouponId3(Integer couponId3) {
+    public void setCouponId3(String couponId3) {
         this.couponId3 = couponId3;
     }
 
-    public Integer getCouponId4() {
+    public String getCouponId4() {
         return couponId4;
     }
 
-    public void setCouponId4(Integer couponId4) {
+    public void setCouponId4(String couponId4) {
         this.couponId4 = couponId4;
     }
 
@@ -345,35 +356,35 @@ public class SvipCouponForm extends DataEntity<SvipCouponForm> {
         this.month = month;
     }
 
-    public Integer getCouponType1() {
+    public String getCouponType1() {
         return couponType1;
     }
 
-    public void setCouponType1(Integer couponType1) {
+    public void setCouponType1(String couponType1) {
         this.couponType1 = couponType1;
     }
 
-    public Integer getCouponType2() {
+    public String getCouponType2() {
         return couponType2;
     }
 
-    public void setCouponType2(Integer couponType2) {
+    public void setCouponType2(String couponType2) {
         this.couponType2 = couponType2;
     }
 
-    public Integer getCouponType3() {
+    public String getCouponType3() {
         return couponType3;
     }
 
-    public void setCouponType3(Integer couponType3) {
+    public void setCouponType3(String couponType3) {
         this.couponType3 = couponType3;
     }
 
-    public Integer getCouponType4() {
+    public String getCouponType4() {
         return couponType4;
     }
 
-    public void setCouponType4(Integer couponType4) {
+    public void setCouponType4(String couponType4) {
         this.couponType4 = couponType4;
     }
 

+ 0 - 1
src/main/java/com/caimei/modules/coupon/entity/SvipCouponList.java

@@ -7,7 +7,6 @@ import java.util.List;
 public class SvipCouponList extends DataEntity<SvipCouponList> {
     private String id;
     /** 生效月份 */
-
     private String useTime;
     private String status;
     /** 单张优惠券id */

+ 1 - 1
src/main/java/com/caimei/modules/coupon/service/CmCouponService.java

@@ -114,7 +114,7 @@ public class CmCouponService extends CrudService<CmCouponDao, CmCoupon> {
     }
 
 
-    private void setCouponStatus(CmCoupon cmCoupon, Date date) {
+    public void setCouponStatus(CmCoupon cmCoupon, Date date) {
         if (cmCoupon != null) {
             if (!cmCoupon.getStatus().contains("2")) {
                 if (date.compareTo(cmCoupon.getStartDate()) < 0) {

+ 304 - 342
src/main/java/com/caimei/modules/coupon/service/CmVipCouponService.java

@@ -2,18 +2,19 @@ package com.caimei.modules.coupon.service;
 
 import com.caimei.modules.coupon.dao.CmCouponDao;
 import com.caimei.modules.coupon.dao.CmCouponVipDao;
-import com.caimei.modules.coupon.dao.SvipCouponListDao;
 import com.caimei.modules.coupon.entity.*;
 import com.caimei.modules.user.entity.NewCmShop;
 import com.caimei.modules.utils.DateUtil;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.service.CrudService;
-import com.thinkgem.jeesite.common.utils.StringUtils;
+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 java.util.*;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
 
 /**
@@ -21,400 +22,361 @@ import java.util.*;
  */
 @Service
 @Transactional(readOnly = true)
-public class CmVipCouponService extends CrudService<SvipCouponListDao, SvipCouponList> {
+public class CmVipCouponService extends CrudService<CmCouponVipDao, CmVipCoupon> {
 
     @Autowired
     private CmCouponService cmCouponService;
     @Autowired
-    private CmCouponVipDao vipDao;
-    @Autowired
-    private SvipCouponListDao listDao;
+    private CmCouponVipDao cmCouponVipDao;
     @Autowired
     private CmCouponDao cmCouponDao;
 
-    @Transactional(readOnly = false)
-    public void addCoupon(SvipCouponForm svipcouponForm, Integer couponId1, String flag) {
-        String month = svipcouponForm.getMonth();
-        Date beginTime = DateUtil.getMinDay(month);
-        Date lastTime = DateUtil.getMaxDay(month);
+    @Override
+    public CmVipCoupon get(String id) {
+        CmVipCoupon vipCoupon = super.get(id);
+        if (null != vipCoupon) {
+            List<CmCoupon> couponList = new ArrayList<>();
+            List<String> bindCoupons = cmCouponVipDao.getBindCoupons(id);
+            for (String s : bindCoupons) {
+                CmCoupon cmCoupon = cmCouponService.get(s);
+                couponList.add(cmCoupon);
+            }
+            vipCoupon.setCouponList(couponList);
+        }
+        return vipCoupon;
+    }
+
+    @Override
+    public Page<CmVipCoupon> findPage(Page<CmVipCoupon> page, CmVipCoupon cmVipCoupon) {
+        Page<CmVipCoupon> vipPage = super.findPage(page, cmVipCoupon);
+        List<CmVipCoupon> cmVipCouponList = vipPage.getList();
+        cmVipCouponList.forEach(vipCoupon -> {
+            List<String> bindCoupons = cmCouponVipDao.getBindCoupons(vipCoupon.getId());
+            List<CmCoupon> couponList = cmCouponVipDao.getCouponListByIds(bindCoupons, cmVipCoupon.getCouponType(), cmVipCoupon.getStatus());
+            Date date = new Date();
+            couponList.forEach(coupon -> {
+                cmCouponService.setCouponStatus(coupon, date);
+                if ("1".equals(coupon.getCouponsMode())) {
+                    //兑换码券
+                    Integer num = cmCouponDao.findQuantityRedeemed(coupon.getId());
+                    coupon.setCodeNum(num);
+                } else {
+                    if (2 == coupon.getCouponType()) {
+                        //用户专享劵
+                        CmCouponClub couponClub = cmCouponDao.findCouponClub(coupon.getId());
+                        if (couponClub == null) {
+                            coupon.setClaimStatus("1");
+                        } else {
+                            coupon.setClaimStatus("2");
+                        }
+                        coupon.setCouponClub(couponClub);
+                    }
+                }
+            });
+            vipCoupon.setCouponList(couponList);
+        });
+        return vipPage;
+    }
 
-        // 解析SvipCouponForm -> 组装 CmCoupon 列表 保存
-        //0活动券 1品类券 3店铺券
+    /**
+     * 设置4张券的表单数据
+     */
+    public SvipCouponForm setSvipcouponForms(CmVipCoupon cmVipCoupon){
+        SvipCouponForm svipcouponForm = new SvipCouponForm();
+        svipcouponForm.setMonth(cmVipCoupon.getUseTime());
+        if (null != cmVipCoupon.getCouponList()){
+            List<CmCoupon> couponList = cmVipCoupon.getCouponList();
+            for (int i = 0; i < couponList.size(); i++) {
+                setSvipcouponForm(svipcouponForm, i, couponList.get(i));
+            }
+
+        }
+        return svipcouponForm;
+    };
+    private SvipCouponForm setSvipcouponForm(SvipCouponForm svipcouponForm, int index, CmCoupon cmCoupon){
+        if (index==0) {
+            svipcouponForm.setCouponId1(cmCoupon.getId());
+            svipcouponForm.setCouponAmount1(cmCoupon.getCouponAmount());
+            svipcouponForm.setTouchPrice1(cmCoupon.getTouchPrice());
+            svipcouponForm.setCouponType1(cmCoupon.getCouponType().toString());
+            svipcouponForm.setCategoryType1(cmCoupon.getCategoryType());
+            svipcouponForm.setProductType1(cmCoupon.getProductType());
+            svipcouponForm.setShopId1(cmCoupon.getShopId());
+            if (cmCoupon.getCouponType() == 0) {
+                // 活动券,查询活动商品
+                if ("2".equals(cmCoupon.getProductType())) {
+                    List<CmCouponAssociate> associateList = cmCouponService.findByProductType(cmCoupon);
+                    svipcouponForm.setAssociateList1(associateList);
+                }
+            }
+            if (cmCoupon.getCouponType() == 3) {
+                // 店铺券
+                NewCmShop shop = cmCouponVipDao.findShopName(cmCoupon.getShopId());
+                svipcouponForm.setShopName1(shop.getName());
+                svipcouponForm.setShop1(shop);
+            }
+        } else if (index==1){
+            svipcouponForm.setCouponId2(cmCoupon.getId());
+            svipcouponForm.setCouponAmount2(cmCoupon.getCouponAmount());
+            svipcouponForm.setTouchPrice2(cmCoupon.getTouchPrice());
+            svipcouponForm.setCouponType2(cmCoupon.getCouponType().toString());
+            svipcouponForm.setCategoryType2(cmCoupon.getCategoryType());
+            svipcouponForm.setProductType2(cmCoupon.getProductType());
+            svipcouponForm.setShopId2(cmCoupon.getShopId());
+            if (cmCoupon.getCouponType() == 0) {
+                // 活动券,查询活动商品
+                if ("2".equals(cmCoupon.getProductType())) {
+                    List<CmCouponAssociate> associateList = cmCouponService.findByProductType(cmCoupon);
+                    svipcouponForm.setAssociateList2(associateList);
+                }
+            }
+            if (cmCoupon.getCouponType() == 3) {
+                // 店铺券
+                NewCmShop shop = cmCouponVipDao.findShopName(cmCoupon.getShopId());
+                svipcouponForm.setShopName2(shop.getName());
+                svipcouponForm.setShop2(shop);
+            }
+        } else if (index==2){
+            svipcouponForm.setCouponId3(cmCoupon.getId());
+            svipcouponForm.setCouponAmount3(cmCoupon.getCouponAmount());
+            svipcouponForm.setTouchPrice3(cmCoupon.getTouchPrice());
+            svipcouponForm.setCouponType3(cmCoupon.getCouponType().toString());
+            svipcouponForm.setCategoryType3(cmCoupon.getCategoryType());
+            svipcouponForm.setProductType3(cmCoupon.getProductType());
+            svipcouponForm.setShopId3(cmCoupon.getShopId());
+            if (cmCoupon.getCouponType() == 0) {
+                // 活动券,查询活动商品
+                if ("2".equals(cmCoupon.getProductType())) {
+                    List<CmCouponAssociate> associateList = cmCouponService.findByProductType(cmCoupon);
+                    svipcouponForm.setAssociateList3(associateList);
+                }
+            }
+            if (cmCoupon.getCouponType() == 3) {
+                // 店铺券
+                NewCmShop shop = cmCouponVipDao.findShopName(cmCoupon.getShopId());
+                svipcouponForm.setShopName3(shop.getName());
+                svipcouponForm.setShop3(shop);
+            }
+        } else if (index==3){
+            svipcouponForm.setCouponId4(cmCoupon.getId());
+            svipcouponForm.setCouponAmount4(cmCoupon.getCouponAmount());
+            svipcouponForm.setTouchPrice4(cmCoupon.getTouchPrice());
+            svipcouponForm.setCouponType4(cmCoupon.getCouponType().toString());
+            svipcouponForm.setCategoryType4(cmCoupon.getCategoryType());
+            svipcouponForm.setProductType4(cmCoupon.getProductType());
+            svipcouponForm.setShopId4(cmCoupon.getShopId());
+            if (cmCoupon.getCouponType() == 0) {
+                // 活动券,查询活动商品
+                if ("2".equals(cmCoupon.getProductType())) {
+                    List<CmCouponAssociate> associateList = cmCouponService.findByProductType(cmCoupon);
+                    svipcouponForm.setAssociateList4(associateList);
+                }
+            }
+            if (cmCoupon.getCouponType() == 3) {
+                // 店铺券
+                NewCmShop shop = cmCouponVipDao.findShopName(cmCoupon.getShopId());
+                svipcouponForm.setShopName4(shop.getName());
+                svipcouponForm.setShop4(shop);
+            }
+        }
+        return svipcouponForm;
+    }
+
+    /**
+     * 保存4张券的表单数据
+     * @param svipcouponForm
+     */
+    @Transactional(readOnly = false)
+    public void saveVipCoupon(SvipCouponForm svipcouponForm){
+        CmVipCoupon cmVipCoupon = new CmVipCoupon();
+        cmVipCoupon.setId(svipcouponForm.getId());
+        cmVipCoupon.setUseTime(svipcouponForm.getMonth());
+        cmVipCoupon.setUpdateTime(new Date());
+        cmVipCoupon.setStatus("1");
+        cmVipCoupon.setDelFlag("0");
+        // 解析 svipcouponForm -> 组装 CmCoupon 列表 保存
         CmCoupon coupon1 = new CmCoupon();
         CmCoupon coupon2 = new CmCoupon();
         CmCoupon coupon3 = new CmCoupon();
         CmCoupon coupon4 = new CmCoupon();
-        if (couponId1 != null && flag.equals("0")) {
-            CmVipCoupon byCoupon = vipDao.findByCoupon(couponId1, null);
-            String bindCoupon = byCoupon.getBindCoupon();
-            String[] split = bindCoupon.split(",");
-            List<CmCoupon> cmCoupons = new ArrayList<>();
-            for (String s : split) {
-                CmCoupon coupon = cmCouponDao.get(s);
-                cmCoupons.add(coupon);
-            }
-            coupon1.setId(cmCoupons.get(0).getId());
-            coupon2.setId(cmCoupons.get(1).getId());
-            coupon3.setId(cmCoupons.get(2).getId());
-            coupon4.setId(cmCoupons.get(3).getId());
-        }
-        CmVipCoupon vipCoupon1 = new CmVipCoupon();
-        CmVipCoupon vipCoupon2 = new CmVipCoupon();
-        CmVipCoupon vipCoupon3 = new CmVipCoupon();
-        CmVipCoupon vipCoupon4 = new CmVipCoupon();
-        vipCoupon1.setUseTime(svipcouponForm.getMonth());
-        vipCoupon2.setUseTime(svipcouponForm.getMonth());
-        vipCoupon3.setUseTime(svipcouponForm.getMonth());
-        vipCoupon4.setUseTime(svipcouponForm.getMonth());
+        boolean flag = false;
+        if(StringUtils.isNotBlank(cmVipCoupon.getId())){
+            // 修改
+            coupon1.setId(svipcouponForm.getCouponId1());
+            coupon2.setId(svipcouponForm.getCouponId2());
+            coupon3.setId(svipcouponForm.getCouponId3());
+            coupon4.setId(svipcouponForm.getCouponId4());
+            cmCouponVipDao.updateVipCouponMonth(cmVipCoupon);
+        } else {
+            flag = true;
+            cmCouponVipDao.insertVipCouponMonth(cmVipCoupon);
+        }
+        Date beginTime = DateUtil.getMinDay(svipcouponForm.getMonth());
+        Date endTime = DateUtil.getMaxDay(svipcouponForm.getMonth());
+        /*
+         * 第1张券
+         */
         coupon1.setStartDate(beginTime);
-        coupon1.setEndDate(lastTime);
-        coupon2.setStartDate(beginTime);
-        coupon2.setEndDate(lastTime);
-        coupon3.setStartDate(beginTime);
-        coupon3.setEndDate(lastTime);
-        coupon4.setStartDate(beginTime);
-        coupon4.setEndDate(lastTime);
+        coupon1.setEndDate(endTime);
         coupon1.setCouponAmount(svipcouponForm.getCouponAmount1());
         coupon1.setTouchPrice(svipcouponForm.getTouchPrice1());
-        coupon2.setCouponAmount(svipcouponForm.getCouponAmount2());
-        coupon2.setTouchPrice(svipcouponForm.getTouchPrice2());
-        coupon3.setCouponAmount(svipcouponForm.getCouponAmount3());
-        coupon3.setTouchPrice(svipcouponForm.getTouchPrice3());
-        coupon4.setCouponAmount(svipcouponForm.getCouponAmount4());
-        coupon4.setTouchPrice(svipcouponForm.getTouchPrice4());
-        coupon1.setStatus("");
-        coupon2.setStatus("");
-        coupon3.setStatus("");
-        coupon4.setStatus("");
-        if (svipcouponForm.getCouponType1() == 0 && svipcouponForm.getCouponType1() != 99) {
+        coupon1.setStatus("1");
+        // 0活动券 1品类券 3店铺券
+        if ("0".equals(svipcouponForm.getCouponType1())){
             coupon1.setCouponType(0);
             coupon1.setProductType(svipcouponForm.getProductType1());
             if (svipcouponForm.getProductInfo1() != null) {
                 coupon1.setProductInfo(svipcouponForm.getProductInfo1());
             }
+        } else if ("1".equals(svipcouponForm.getCouponType1())) {
+            coupon1.setCategoryType(svipcouponForm.getCategoryType1());
+            coupon1.setCouponType(1);
+        } else if ("3".equals(svipcouponForm.getCouponType1())) {
+            coupon1.setShopId(svipcouponForm.getShopId1());
+            coupon1.setCouponType(3);
         }
-        if (svipcouponForm.getCouponType2() == 0) {
+        cmCouponService.save(coupon1);
+        /*
+         * 第2张券
+         */
+        coupon2.setStartDate(beginTime);
+        coupon2.setEndDate(endTime);
+        coupon2.setCouponAmount(svipcouponForm.getCouponAmount2());
+        coupon2.setTouchPrice(svipcouponForm.getTouchPrice2());
+        coupon2.setStatus("1");
+        // 0活动券 1品类券 3店铺券
+        if ("0".equals(svipcouponForm.getCouponType2())){
             coupon2.setCouponType(0);
             coupon2.setProductType(svipcouponForm.getProductType2());
             if (svipcouponForm.getProductInfo2() != null) {
                 coupon2.setProductInfo(svipcouponForm.getProductInfo2());
             }
+        } else if ("1".equals(svipcouponForm.getCouponType2())) {
+            coupon2.setCategoryType(svipcouponForm.getCategoryType2());
+            coupon2.setCouponType(1);
+        } else if ("3".equals(svipcouponForm.getCouponType2())) {
+            coupon2.setShopId(svipcouponForm.getShopId2());
+            coupon2.setCouponType(3);
         }
-        if (svipcouponForm.getCouponType3() == 0) {
+        cmCouponService.save(coupon2);
+        /*
+         * 第3张券
+         */
+        coupon3.setStartDate(beginTime);
+        coupon3.setEndDate(endTime);
+        coupon3.setCouponAmount(svipcouponForm.getCouponAmount3());
+        coupon3.setTouchPrice(svipcouponForm.getTouchPrice3());
+        coupon3.setStatus("1");
+        // 0活动券 1品类券 3店铺券
+        if ("0".equals(svipcouponForm.getCouponType3())){
             coupon3.setCouponType(0);
             coupon3.setProductType(svipcouponForm.getProductType3());
             if (svipcouponForm.getProductInfo3() != null) {
                 coupon3.setProductInfo(svipcouponForm.getProductInfo3());
             }
+        } else if ("1".equals(svipcouponForm.getCouponType3())) {
+            coupon3.setCategoryType(svipcouponForm.getCategoryType3());
+            coupon3.setCouponType(1);
+        } else if ("3".equals(svipcouponForm.getCouponType3())) {
+            coupon3.setShopId(svipcouponForm.getShopId3());
+            coupon3.setCouponType(3);
         }
-        if (svipcouponForm.getCouponType4() == 0) {
+        cmCouponService.save(coupon3);
+        /*
+         * 第4张券
+         */
+        coupon4.setStartDate(beginTime);
+        coupon4.setEndDate(endTime);
+        coupon4.setCouponAmount(svipcouponForm.getCouponAmount4());
+        coupon4.setTouchPrice(svipcouponForm.getTouchPrice4());
+        coupon4.setStatus("1");
+        // 0活动券 1品类券 3店铺券
+        if ("0".equals(svipcouponForm.getCouponType4())){
             coupon4.setCouponType(0);
             coupon4.setProductType(svipcouponForm.getProductType4());
             if (svipcouponForm.getProductInfo4() != null) {
                 coupon4.setProductInfo(svipcouponForm.getProductInfo4());
             }
-        }
-        if (svipcouponForm.getCouponType1() == 1) {
-            coupon1.setCategoryType(svipcouponForm.getCategoryType1());
-            coupon1.setCouponType(1);
-        }
-        if (svipcouponForm.getCouponType2() == 1) {
-            coupon2.setCategoryType(svipcouponForm.getCategoryType2());
-            coupon2.setCouponType(1);
-        }
-        if (svipcouponForm.getCouponType3() == 1) {
-            coupon3.setCategoryType(svipcouponForm.getCategoryType3());
-            coupon3.setCouponType(1);
-        }
-        if (svipcouponForm.getCouponType4() == 1) {
+        } else if ("1".equals(svipcouponForm.getCouponType4())) {
             coupon4.setCategoryType(svipcouponForm.getCategoryType4());
             coupon4.setCouponType(1);
-        }
-        if (svipcouponForm.getCouponType1() == 3) {
-            coupon1.setShopId(svipcouponForm.getShopId1());
-            coupon1.setCouponType(3);
-        }
-        if (svipcouponForm.getCouponType2() == 3) {
-            coupon2.setShopId(svipcouponForm.getShopId2());
-            coupon2.setCouponType(3);
-        }
-        if (svipcouponForm.getCouponType3() == 3) {
-            coupon3.setShopId(svipcouponForm.getShopId3());
-            coupon3.setCouponType(3);
-        }
-        if (svipcouponForm.getCouponType4() == 3) {
+        } else if ("3".equals(svipcouponForm.getCouponType4())) {
             coupon4.setShopId(svipcouponForm.getShopId4());
             coupon4.setCouponType(3);
         }
-        cmCouponService.save(coupon1);
-        cmCouponService.save(coupon2);
-        cmCouponService.save(coupon3);
         cmCouponService.save(coupon4);
-        vipCoupon1.setCouponId(Integer.valueOf(coupon1.getId()));
-        vipCoupon2.setCouponId(Integer.valueOf(coupon2.getId()));
-        vipCoupon3.setCouponId(Integer.valueOf(coupon3.getId()));
-        vipCoupon4.setCouponId(Integer.valueOf(coupon4.getId()));
-        Date date = new Date();
-        vipCoupon1.setCreateTime(date);
-        vipCoupon2.setCreateTime(date);
-        vipCoupon3.setCreateTime(date);
-        vipCoupon4.setCreateTime(date);
-        String s = vipCoupon1.getCouponId() + "," + vipCoupon2.getCouponId() + "," + vipCoupon3.getCouponId() + "," + vipCoupon4.getCouponId();
-        vipCoupon1.setBindCoupon(s);
-        vipCoupon2.setBindCoupon(s);
-        vipCoupon3.setBindCoupon(s);
-        vipCoupon4.setBindCoupon(s);
-        //0修改,1新增
-        if (flag.equals("0")) {
-            CmVipCoupon byCoupon = vipDao.findByCoupon(couponId1, null);
-            if (byCoupon != null) {
-                vipDao.updateVip(vipCoupon1);
-                vipDao.updateVip(vipCoupon2);
-                vipDao.updateVip(vipCoupon3);
-                vipDao.updateVip(vipCoupon4);
-            }
-        }
-        if (flag.equals("1")) {
-            vipDao.addVipCoupon(vipCoupon1);
-            vipDao.addVipCoupon(vipCoupon2);
-            vipDao.addVipCoupon(vipCoupon3);
-            vipDao.addVipCoupon(vipCoupon4);
-        }
-    }
-
-    @Transactional(readOnly = false)
-    public void close(Integer couponId) {
-        SvipCouponList vip = listDao.findVipStatus(couponId);
-        String bindCoupon = vip.getBindCoupon();
-        String[] split = bindCoupon.split(",");
-        SvipCouponList vipCouponList = new SvipCouponList();
-        for (String s : split) {
-            Integer ids = Integer.valueOf(s);
-            CmCoupon coupon = listDao.findCoupon(ids);
-            vipCouponList.setCouponId(ids);
-            vipCouponList.setStatus("0");
-            coupon.setStatus("2");
-            coupon.setCouponsMode("0");
-            cmCouponDao.update(coupon);
-            listDao.updateVip(vipCouponList);
+        /*
+         * vip优惠券月份关系
+         */
+        CmVipCouponRelation relation1 = new CmVipCouponRelation();
+        CmVipCouponRelation relation2 = new CmVipCouponRelation();
+        CmVipCouponRelation relation3 = new CmVipCouponRelation();
+        CmVipCouponRelation relation4 = new CmVipCouponRelation();
+        relation1.setMontId(cmVipCoupon.getId());
+        relation2.setMontId(cmVipCoupon.getId());
+        relation3.setMontId(cmVipCoupon.getId());
+        relation4.setMontId(cmVipCoupon.getId());
+        relation1.setCouponId(coupon1.getId());
+        relation2.setCouponId(coupon2.getId());
+        relation3.setCouponId(coupon3.getId());
+        relation4.setCouponId(coupon4.getId());
+        relation1.setUpdateTime(new Date());
+        relation2.setUpdateTime(new Date());
+        relation3.setUpdateTime(new Date());
+        relation4.setUpdateTime(new Date());
+        relation1.setDelFlag("0");
+        relation2.setDelFlag("0");
+        relation3.setDelFlag("0");
+        relation4.setDelFlag("0");
+        if (flag) {
+            // 新增
+            cmCouponVipDao.insertVipCouponRelation(relation1);
+            cmCouponVipDao.insertVipCouponRelation(relation2);
+            cmCouponVipDao.insertVipCouponRelation(relation3);
+            cmCouponVipDao.insertVipCouponRelation(relation4);
+        } else {
+            // 修改
+            cmCouponVipDao.updateVipCouponRelation(relation1);
+            cmCouponVipDao.updateVipCouponRelation(relation2);
+            cmCouponVipDao.updateVipCouponRelation(relation3);
+            cmCouponVipDao.updateVipCouponRelation(relation4);
         }
     }
 
+    @Override
     @Transactional(readOnly = false)
-    public void deleteById(Integer couponId) {
-        SvipCouponList vip = listDao.findVipStatus(couponId);
-        String bindCoupon = vip.getBindCoupon();
-        String[] split = bindCoupon.split(",");
-        SvipCouponList vipCouponList = new SvipCouponList();
-        for (String s : split) {
-            Integer ids = Integer.valueOf(s);
-            CmCoupon coupon = listDao.findCoupon(ids);
-            vipCouponList.setCouponId(ids);
-            vipCouponList.setDelFlag("1");
+    public void delete(CmVipCoupon cmVipCoupon) {
+        cmVipCoupon.setDelFlag("1");
+        List<CmCoupon> couponList = cmVipCoupon.getCouponList();
+        for (CmCoupon coupon : couponList) {
             coupon.setDelFlag("1");
-            coupon.setCouponsMode("0");
-            cmCouponDao.delete(coupon);
-            listDao.updateVip(vipCouponList);
+            // 逻辑删除
+            cmCouponService.delete(coupon);
         }
+        cmCouponVipDao.update(cmVipCoupon);
+        // 逻辑删除关系表
+        cmCouponVipDao.deleteByMonthId(cmVipCoupon.getId());
     }
 
-    @Override
-    public Page<SvipCouponList> findPage(Page<SvipCouponList> page, SvipCouponList svipCouponList) {
-//           0 "未生效
-//           1 "已生效"
-//           2 "已关闭"
-//           3 "已失效"
-        Page<SvipCouponList> couponPage = super.findPage(page, svipCouponList);
-        List<SvipCouponList> list = couponPage.getList();
-        List<Integer> couponIds = new ArrayList<>();
-        for (SvipCouponList svipCoupon : list) {
-            String bindCoupon = svipCoupon.getBindCoupon();
-            String[] split = bindCoupon.split(",");
-            for (String s : split) {
-                Integer in = Integer.valueOf(s);
-                couponIds.add(in);
-            }
-            SvipCouponForm form = getForm(couponIds);
-            Integer couponId1 = form.getCouponId1();
-            CmCoupon status = listDao.findStatus(couponId1);
-            Date endDate = status.getEndDate();
-            Date startDate = status.getStartDate();
-            Date now = new Date();
-            //结束>现在,开始<现在
-            if (endDate.after(now) && startDate.before(now)) {
-                form.setStatus("1");
-            }
-            //开始时间>现在
-            if (startDate.after(now)) {
-                form.setStatus("0");
-            }
-            //结束>现在
-            if (endDate.before(now)) {
-                form.setStatus("3");
-            }
-            SvipCouponList vipStatus = listDao.findVipStatus(couponId1);
-            if (vipStatus.getStatus().equals("0")) {
-                form.setStatus("2");
-            }
-            svipCoupon.setSvipCoupons(form);
-            couponIds.clear();
-        }
-
-        return page;
-    }
-
-    private SvipCouponForm getForm(List<Integer> couponIds) {
-        ArrayList<CmVipCoupon> group = new ArrayList<>();
-        SvipCouponForm form = new SvipCouponForm();
-        //根据couponId查4张优惠券,装进form
-        for (Integer couponId : couponIds) {
-            group.add(vipDao.findAllVipCoupon(null, null, couponId).get(0));
-        }
-        CmVipCoupon coupon1 = group.get(0);
-        CmVipCoupon coupon2 = group.get(1);
-        CmVipCoupon coupon3 = group.get(2);
-        CmVipCoupon coupon4 = group.get(3);
-        form.setMonth(coupon1.getUseTime());
-        form.setCouponId1(coupon1.getCouponId());
-        form.setCouponAmount1(coupon1.getCouponAmount());
-        form.setTouchPrice1(coupon1.getTouchPrice());
-        form.setCouponType1(coupon1.getCouponType());
-
-        form.setCouponId2(coupon2.getCouponId());
-        form.setCouponAmount2(coupon2.getCouponAmount());
-        form.setTouchPrice2(coupon2.getTouchPrice());
-        form.setCouponType2(coupon2.getCouponType());
-
-        form.setCouponId3(coupon3.getCouponId());
-        form.setCouponAmount3(coupon3.getCouponAmount());
-        form.setTouchPrice3(coupon3.getTouchPrice());
-        form.setCouponType3(coupon3.getCouponType());
-
-        form.setCouponId4(coupon4.getCouponId());
-        form.setCouponAmount4(coupon4.getCouponAmount());
-        form.setTouchPrice4(coupon4.getTouchPrice());
-        form.setCouponType4(coupon4.getCouponType());
-
-        //等于0的时候活动券productinfo查出来还回去
-        if (coupon1.getCouponType() == 0) {
-            form.setProductType1(coupon1.getProductType());
-            if ("2".equals(coupon1.getProductType())) {
-                List<CmCouponAssociate> associateList = new ArrayList<>();
-                Integer couponId = coupon1.getCouponId();
-                CmCoupon coupon = new CmCoupon();
-                coupon.setId(couponId.toString());
-                associateList = cmCouponService.findByProductType(coupon);
-                form.setAssociateList1(associateList);
-            }
-        }
-        if (coupon1.getCouponType() == 1) {
-            form.setCategoryType1(coupon1.getCategoryType());
-        }
-        // 塞入"shopId": "${cmCoupon.shop.shopID}",
-        //                "name": "${cmCoupon.shop.name}",
-        //                "sname": "${cmCoupon.shop.sname}",
-        //                "linkMan": "${cmCoupon.shop.linkMan}",
-        //                "contractMobile": "${cmCoupon.shop.contractMobile}"
-        if (coupon1.getCouponType() == 3) {
-            form.setShopId1(coupon1.getShopId());
-            NewCmShop shop = vipDao.findShopName(coupon1.getShopId());
-            form.setShopName1(shop.getName());
-            form.setShop1(shop);
-        }
-
-        if (coupon2.getCouponType() == 0) {
-            form.setProductType2(coupon2.getProductType());
-            if ("2".equals(coupon2.getProductType())) {
-                List<CmCouponAssociate> associateList = new ArrayList<>();
-                Integer couponId = coupon2.getCouponId();
-                CmCoupon coupon = new CmCoupon();
-                coupon.setId(couponId.toString());
-                associateList = cmCouponService.findByProductType(coupon);
-                form.setAssociateList2(associateList);
-            }
-        }
-        if (coupon2.getCouponType() == 1) {
-            form.setCategoryType2(coupon2.getCategoryType());
-        }
-        if (coupon2.getCouponType() == 3) {
-            form.setShopId2(coupon2.getShopId());
-            NewCmShop shop = vipDao.findShopName(coupon2.getShopId());
-            form.setShopName2(shop.getName());
-            form.setShop2(shop);
-        }
-
-        if (coupon3.getCouponType() == 0) {
-            form.setProductType3(coupon3.getProductType());
-            if ("2".equals(coupon3.getProductType())) {
-                List<CmCouponAssociate> associateList = new ArrayList<>();
-                Integer couponId = coupon3.getCouponId();
-                CmCoupon coupon = new CmCoupon();
-                coupon.setId(couponId.toString());
-                associateList = cmCouponService.findByProductType(coupon);
-                form.setAssociateList3(associateList);
-            }
-        }
-        if (coupon3.getCouponType() == 1) {
-            form.setCategoryType3(coupon3.getCategoryType());
-        }
-        if (coupon3.getCouponType() == 3) {
-            form.setShopId3(coupon3.getShopId());
-            NewCmShop shop = vipDao.findShopName(coupon3.getShopId());
-            form.setShopName3(shop.getName());
-            form.setShop3(shop);
-        }
-
-        if (coupon4.getCouponType() == 0) {
-            form.setProductType4(coupon4.getProductType());
-            if ("2".equals(coupon4.getProductType())) {
-                List<CmCouponAssociate> associateList = new ArrayList<>();
-                Integer couponId = coupon4.getCouponId();
-                CmCoupon coupon = new CmCoupon();
-                coupon.setId(couponId.toString());
-                associateList = cmCouponService.findByProductType(coupon);
-                form.setAssociateList4(associateList);
-            }
-        }
-        if (coupon4.getCouponType() == 1) {
-            form.setCategoryType4(coupon4.getCategoryType());
-        }
-        if (coupon4.getCouponType() == 3) {
-            form.setShopId4(coupon4.getShopId());
-            NewCmShop shop = vipDao.findShopName(coupon4.getShopId());
-            form.setShopName4(shop.getName());
-            form.setShop4(shop);
-        }
-
-        return form;
-    }
-
-    public SvipCouponForm getVipForm(Integer couponId1) {
-        CmVipCoupon byCoupon = vipDao.findByCoupon(couponId1, null);
-        ArrayList<Integer> couponIds = new ArrayList<>();
-        String[] split = byCoupon.getBindCoupon().split(",");
-        for (String s : split) {
-            Integer ids = Integer.valueOf(s);
-            couponIds.add(ids);
+    @Transactional(readOnly = false)
+    public void close(CmVipCoupon cmVipCoupon) {
+        cmVipCoupon.setStatus("2");
+        List<CmCoupon> couponList = cmVipCoupon.getCouponList();
+        for (CmCoupon coupon : couponList) {
+            coupon.setStatus("2");
+            cmCouponService.save(coupon);
         }
-        SvipCouponForm form = getForm(couponIds);
-        return form;
+        cmCouponVipDao.update(cmVipCoupon);
     }
 
     @Transactional(readOnly = false)
-    public void open(Integer couponId) {
-        SvipCouponList vip = listDao.findVipStatus(couponId);
-        String bindCoupon = vip.getBindCoupon();
-        String[] split = bindCoupon.split(",");
-        SvipCouponList vipCouponList = new SvipCouponList();
-        for (String s : split) {
-            Integer ids = Integer.valueOf(s);
-            CmCoupon coupon = listDao.findCoupon(ids);
-            vipCouponList.setCouponId(ids);
-            vipCouponList.setStatus("1");
-            coupon.setStatus("0");
-            coupon.setCouponsMode("0");
-            cmCouponDao.update(coupon);
-            listDao.updateVip(vipCouponList);
-        }
+    public void open(CmVipCoupon cmVipCoupon) {
+        cmVipCoupon.setStatus("1");
+        List<CmCoupon> couponList = cmVipCoupon.getCouponList();
+        for (CmCoupon coupon : couponList) {
+            coupon.setStatus("1");
+            cmCouponService.save(coupon);
+        }
+        cmCouponVipDao.update(cmVipCoupon);
     }
 }

+ 42 - 74
src/main/java/com/caimei/modules/coupon/web/CmVipCouponController.java

@@ -1,19 +1,12 @@
 package com.caimei.modules.coupon.web;
 
-import com.caimei.modules.coupon.dao.CmCouponVipDao;
-import com.caimei.modules.coupon.entity.CmCoupon;
 import com.caimei.modules.coupon.entity.CmVipCoupon;
 import com.caimei.modules.coupon.entity.SvipCouponForm;
-import com.caimei.modules.coupon.entity.SvipCouponList;
-import com.caimei.modules.coupon.service.CmCouponService;
 import com.caimei.modules.coupon.service.CmVipCouponService;
-import com.caimei.modules.product.service.ProductService;
-import com.caimei.modules.user.dao.CmUserDao;
-import com.caimei.modules.user.dao.NewCmClubDao;
-import com.caimei.modules.utils.DateUtil;
 import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.utils.StringUtils;
+import com.thinkgem.jeesite.common.web.BaseController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
@@ -25,7 +18,6 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.text.ParseException;
-import java.util.*;
 
 /**
  * @author zzj
@@ -33,106 +25,82 @@ import java.util.*;
  */
 @Controller
 @RequestMapping(value = "${adminPath}/vip/cmCoupon")
-public class CmVipCouponController {
-
-
-    @Autowired
-    private CmCouponService cmCouponService;
-
-    @Autowired
-    private CmVipCouponService vipCouponService;
+public class CmVipCouponController extends BaseController {
 
     @Autowired
-    private CmCouponVipDao vipDao;
+    private CmVipCouponService cmVipCouponService;
 
     @ModelAttribute
-    public SvipCouponList get(@RequestParam(required = false) String id) {
-        SvipCouponList entity = null;
+    public CmVipCoupon get(@RequestParam(required = false) String id) {
+        CmVipCoupon entity = null;
         if (StringUtils.isNotBlank(id)) {
-            entity = vipCouponService.get(id);
+            entity = cmVipCouponService.get(id);
         }
         if (entity == null) {
-            entity = new SvipCouponList();
+            entity = new CmVipCoupon();
         }
         return entity;
     }
 
-    @RequestMapping(value = "close")
-    public String close(Integer couponId1, RedirectAttributes redirectAttributes) {
-        vipCouponService.close(couponId1);
-        addMessage(redirectAttributes, "关闭优惠券成功");
-        return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon";
-    }
-
-    @RequestMapping(value = "open")
-    public String open(Integer couponId1, RedirectAttributes redirectAttributes) {
-        vipCouponService.open(couponId1);
-        addMessage(redirectAttributes, "开启优惠券成功");
-        return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon";
-    }
-
-    @RequestMapping(value = "delete")
-    public String delete(Integer couponId1, RedirectAttributes redirectAttributes) {
-        vipCouponService.deleteById(couponId1);
-        addMessage(redirectAttributes, "删除优惠券成功");
-        return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon";
-    }
-
     @RequestMapping(value = {"list", ""})
-    public String list(SvipCouponList svipCouponList, HttpServletRequest request, HttpServletResponse response, Model model) {
-        Page<SvipCouponList> page = vipCouponService.findPage(new Page<SvipCouponList>(request, response), svipCouponList);
+    public String list(CmVipCoupon cmVipCoupon, HttpServletRequest request, HttpServletResponse response, Model model) {
+        Page<CmVipCoupon> page = cmVipCouponService.findPage(new Page<CmVipCoupon>(request, response), cmVipCoupon);
         model.addAttribute("page", page);
         return "modules/svip/cmSvipCouponList";
     }
 
     @RequestMapping(value = "form")
-    public String form(Integer couponId1, SvipCouponForm svipcouponForm, Model model) {
-        if (couponId1 != null) {
-            svipcouponForm = vipCouponService.getVipForm(couponId1);
-            // 根据4个CmCoupon的Id查询CmCoupon列表,封装成解析SvipCouponForm
-            model.addAttribute("svipcouponForm", svipcouponForm);
-        }
-        return "modules/svip/cmSvipCouponForm";
-    }
-
-    @RequestMapping(value = "forms")
-    public String forms(Model model) {
-        SvipCouponForm svipcouponForm = new SvipCouponForm();
+    public String form(CmVipCoupon cmVipCoupon, Model model) {
+        model.addAttribute("cmVipCoupon", cmVipCoupon);
+        // 设置4张券的表单
+        SvipCouponForm svipcouponForm = cmVipCouponService.setSvipcouponForms(cmVipCoupon);
         model.addAttribute("svipcouponForm", svipcouponForm);
         return "modules/svip/cmSvipCouponForm";
     }
 
-
     /**
      * 保存
      *
      * @param svipcouponForm
      */
     @RequestMapping(value = "save")
-    public String save(Integer couponId1, SvipCouponForm svipcouponForm, Model model, RedirectAttributes redirectAttributes) throws ParseException {
-        if (couponId1 != null) {
-            //不为空修改
-            vipCouponService.addCoupon(svipcouponForm, couponId1, "0");
+    public String save(SvipCouponForm svipcouponForm, Model model, RedirectAttributes redirectAttributes) throws ParseException {
+        cmVipCouponService.saveVipCoupon(svipcouponForm);
+        if (StringUtils.isNotBlank(svipcouponForm.getId())) {
+            // 修改
             addMessage(redirectAttributes, "修改超级会员专属优惠券成功");
-            return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon/?repage";
         } else {
-            //couponid为空一定新增
-            List<String> useTime = vipDao.findUseTime();
-            if (useTime.contains(svipcouponForm.getMonth())) {
-                //不能新增,这个月已经有了
-                addMessage(redirectAttributes, "本月已存在优惠券,无法新增");
-                return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon/?repage";
-            } else {
-                vipCouponService.addCoupon(svipcouponForm, couponId1, "1");
-                addMessage(redirectAttributes, "新增超级会员专属优惠券成功");
-                return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon/?repage";
-            }
+            // 新增
+            addMessage(redirectAttributes, "新增超级会员专属优惠券成功");
         }
+        return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon/?repage";
+    }
+
+    @RequestMapping(value = "close")
+    public String close(CmVipCoupon cmVipCoupon, RedirectAttributes redirectAttributes) {
+        cmVipCouponService.close(cmVipCoupon);
+        addMessage(redirectAttributes, "关闭优惠券成功");
+        return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon";
+    }
+
+    @RequestMapping(value = "open")
+    public String open(CmVipCoupon cmVipCoupon, RedirectAttributes redirectAttributes) {
+        cmVipCouponService.open(cmVipCoupon);
+        addMessage(redirectAttributes, "开启优惠券成功");
+        return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon";
+    }
+
+    @RequestMapping(value = "delete")
+    public String delete(CmVipCoupon cmVipCoupon, RedirectAttributes redirectAttributes) {
+        cmVipCouponService.delete(cmVipCoupon);
+        addMessage(redirectAttributes, "删除优惠券成功");
+        return "redirect:" + Global.getAdminPath() + "/vip/cmCoupon";
     }
 
     /**
      * 添加Flash消息
      */
+    @Override
     protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
         StringBuilder sb = new StringBuilder();
         for (String message : messages) {

+ 137 - 0
src/main/resources/mappings/modules/super/CmCouponVipMapper.xml

@@ -0,0 +1,137 @@
+<?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.coupon.dao.CmCouponVipDao">
+    <sql id="cmCouponColumns">
+        a.id AS "id",
+		a.name AS "name",
+		a.couponAmount AS "couponAmount",
+		a.touchPrice AS "touchPrice",
+		a.startDate AS "startDate",
+		a.endDate AS "endDate",
+		a.status AS "status",
+		a.couponType AS "couponType",
+		a.userId AS "userId",
+		a.shopId AS "shopId",
+		a.productType AS "productType",
+		a.pcBanner AS "pcBanner",
+		a.appletsBanner AS "appletsBanner",
+		a.categoryType AS "categoryType",
+		a.couponsMode AS "couponsMode",
+		a.createDate AS "createDate",
+		a.delFlag AS "delFlag"
+    </sql>
+    <insert id="insertVipCouponMonth" parameterType="CmVipCoupon" keyProperty="id" useGeneratedKeys="true">
+        INSERT INTO cm_svip_coupon_month (useTime, updateTime, status,delFlag)
+        VALUES (#{useTime}, #{updateTime}, #{status}, #{delFlag})
+    </insert>
+    <update id="updateVipCouponMonth" parameterType="CmVipCoupon">
+        UPDATE cm_svip_coupon_month SET useTime=#{useTime}, updateTime=#{updateTime}, status=#{status}, delFlag=#{delFlag}
+        WHERE id=#{id}
+    </update>
+    <insert id="insertVipCouponRelation">
+        INSERT INTO cm_svip_coupon (couponId, montId, updateTime, delFlag)
+        VALUES (#{couponId}, #{montId}, #{updateTime}, #{delFlag})
+    </insert>
+    <update id="updateVipCouponRelation">
+        UPDATE cm_svip_coupon SET couponId=#{couponId}, montId=#{montId}, updateTime=#{updateTime}, delFlag=#{delFlag}
+        WHERE id=#{id}
+    </update>
+    <select id="get" resultType="CmVipCoupon">
+        SELECT DISTINCT id, useTime, status, updateTime, delFlag
+        FROM cm_svip_coupon_month
+        WHERE id = #{id}
+        LIMIT 1
+    </select>
+    <select id="getBindCoupons" resultType="java.lang.String">
+        SELECT couponId from cm_svip_coupon  WHERE montId = #{montId} AND delFlag=0
+    </select>
+    <select id="findList" resultType="CmVipCoupon">
+        SELECT cs.id, cs.useTime, cs.status, cs.updateTime, cs.delFlag
+        FROM cm_svip_coupon_month cs
+        <where>
+            AND cs.delFlag = 0
+            <if test="startDate!=null and startDate!=''">
+                AND cs.useTime <![CDATA[  >=  ]]> #{startDate}
+            </if>
+            <if test="endDate!=null and endDate!=''">
+                AND cs.useTime <![CDATA[   <=  ]]> #{endDate}
+            </if>
+        </where>
+        ORDER BY cs.useTime DESC
+    </select>
+    <select id="getCouponListByIds" resultType="com.caimei.modules.coupon.entity.CmCoupon">
+        SELECT
+        <include refid="cmCouponColumns"/>,
+        u.name AS "clubName",
+        s.name AS "shopName"
+        FROM cm_coupon a
+        LEFT JOIN cm_coupon_club ccc ON ccc.couponId = a.id
+        LEFT JOIN USER u ON u.userID = a.userId
+        LEFT JOIN shop s ON s.shopID = a.shopId
+        <where>
+            AND a.delFlag = 0
+            <if test="couponType != null">
+                AND a.couponType = #{couponType}
+            </if>
+            <if test='status == "0"'>
+                AND a.startDate <![CDATA[ > ]]> NOW()
+            </if>
+            <if test='status == "1"'>
+                AND a.startDate <![CDATA[ <= ]]> NOW()
+                AND a.endDate <![CDATA[ >= ]]> NOW()
+                AND a.status != '2'
+            </if>
+            <if test='status == "2"'>
+                AND a.status = '2'
+            </if>
+            <if test='status == "3"'>
+                AND a.endDate <![CDATA[ < ]]> NOW()
+            </if>
+            <if test="bindCoupons != null">
+                AND a.id IN
+                <foreach collection="bindCoupons" open="(" separator="," close=")" item="couponId">
+                    #{couponId}
+                </foreach>
+            </if>
+        </where>
+        GROUP BY a.id
+        ORDER BY createDate DESC
+    </select>
+    <delete id="deleteByMonthId">
+        UPDATE cm_svip_coupon SET delFlag=1 WHERE montId = #{montId}
+    </delete>
+    <select id="findShopName" resultType="com.caimei.modules.user.entity.NewCmShop">
+        select name,sname,linkMan,contractMobile
+        from shop
+        where shopID = #{shopId}
+    </select>
+
+<!--    <select id="findGroup" resultType="com.caimei.modules.coupon.entity.CmVipCouponRelation">-->
+<!--        select *-->
+<!--        from cm_svip_coupon cs-->
+<!--        where useTime = #{useTime}-->
+<!--        AND cs.delFlag=0-->
+<!--        <if test="status!=null and status != ''">-->
+<!--            AND cs.status=#{status}-->
+<!--        </if>-->
+<!--    </select>-->
+<!--    <select id="findUseTime" resultType="String">-->
+<!--        SELECT DISTINCT usetime-->
+<!--        FROM cm_svip_coupon-->
+<!--    </select>-->
+
+<!--    <select id="findBind" resultType="java.lang.String">-->
+<!--        SELECT DISTINCT bindCoupon-->
+<!--        FROM cm_svip_coupon-->
+<!--    </select>-->
+
+<!--    <select id="findByCoupon" resultType="com.caimei.modules.coupon.entity.CmVipCouponRelation">-->
+<!--        select useTime, status, couponId, bindCoupon-->
+<!--        from cm_svip_coupon-->
+<!--        where delFlag = 0-->
+<!--        and couponId=#{couponId}-->
+<!--        <if test="status != null and status != ''">-->
+<!--            and status=#{status}-->
+<!--        </if>-->
+<!--    </select>-->
+</mapper>

+ 0 - 198
src/main/resources/mappings/modules/super/CmSvipCouponMapper.xml

@@ -1,198 +0,0 @@
-<?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.coupon.dao.CmCouponVipDao">
-
-    <insert id="addVipCoupon">
-        insert into cm_svip_coupon (created_time, updated_time, couponId, usetime, delflag, status, bindCoupon)
-        values (#{createTime},
-                #{updateTime},
-                #{couponId},
-                #{useTime},
-                0, 1,
-                #{bindCoupon})
-    </insert>
-
-    <update id="updateVip">
-        update cm_svip_coupon
-        set
-        <if test="useTime != null and useTime != ''">
-            useTime=#{useTime},
-        </if>
-        <if test="delFlag != null and delFlag != ''">
-            delflag=#{delFlag},
-        </if>
-        <if test="status != null and status != ''">
-            status=#{status},
-        </if>
-        <if test="bindCoupon != null and bindCoupon != ''">
-            bindCoupon=#{bindCoupon},
-        </if>
-        UPDATED_TIME=now()
-        where couponId=#{couponId}
-    </update>
-
-
-    <!--    <sql id="cmCouponColumns">-->
-    <!--        a.id AS "id",-->
-    <!--		a.name AS "name",-->
-    <!--		a.couponAmount AS "couponAmount",-->
-    <!--		a.touchPrice AS "touchPrice",-->
-    <!--		a.startDate AS "startDate",-->
-    <!--		a.endDate AS "endDate",-->
-    <!--		a.status AS "status",-->
-    <!--		a.couponType AS "couponType",-->
-    <!--		a.userId AS "userId",-->
-    <!--		a.shopId AS "shopId",-->
-    <!--		a.productType AS "productType",-->
-    <!--		a.pcBanner AS "pcBanner",-->
-    <!--		a.appletsBanner AS "appletsBanner",-->
-    <!--		a.categoryType AS "categoryType",-->
-    <!--		a.couponsMode AS "couponsMode",-->
-    <!--		a.createDate AS "createDate",-->
-    <!--		a.delFlag AS "delFlag"-->
-    <!--    </sql>-->
-
-    <!--    <sql id="cmCouponJoins">-->
-    <!--    </sql>-->
-
-    <!--    SELECT-->
-    <!--    <include refid="cmCouponColumns"/>,-->
-    <!--    u.name AS "clubName",-->
-    <!--    s.name AS "shopName"-->
-    <!--    FROM cm_coupon a-->
-    <!--    LEFT JOIN cm_coupon_club ccc ON ccc.couponId = a.id-->
-    <!--    LEFT JOIN USER u ON u.userID = a.userId-->
-    <!--    LEFT JOIN shop s ON s.shopID = a.shopId-->
-    <!--    <include refid="cmCouponJoins"/>-->
-    <!--    <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="startDate != null and startDate != ''">-->
-    <!--            AND a.startDate <![CDATA[ >= ]]> #{startDate}-->
-    <!--        </if>-->
-    <!--        <if test="endDate != null and endDate != ''">-->
-    <!--            AND a.endDate <![CDATA[ <= ]]> #{endDate}-->
-    <!--        </if>-->
-    <!--        <if test='status == "0"'>-->
-    <!--            AND a.startDate <![CDATA[ > ]]> NOW()-->
-    <!--        </if>-->
-    <!--        <if test='status == "1"'>-->
-    <!--            AND a.startDate <![CDATA[ <= ]]> NOW()-->
-    <!--            AND a.endDate <![CDATA[ >= ]]> NOW()-->
-    <!--            AND a.status != '2'-->
-    <!--        </if>-->
-    <!--        <if test='status == "2"'>-->
-    <!--            AND a.status = '2'-->
-    <!--        </if>-->
-    <!--        <if test='status == "3"'>-->
-    <!--            AND a.endDate <![CDATA[ < ]]> NOW()-->
-    <!--        </if>-->
-    <!--        <if test="clubName != null and clubName != ''">-->
-    <!--            AND u.name LIKE concat('%',#{clubName},'%')-->
-    <!--        </if>-->
-    <!--        <if test='claimStatus == "1"'>-->
-    <!--            AND ccc.id IS NULL-->
-    <!--        </if>-->
-    <!--        <if test='claimStatus == "2"'>-->
-    <!--            AND ccc.id IS NOT NULL-->
-    <!--        </if>-->
-    <!--        <if test='useStatus == "1"'>-->
-    <!--            AND (ccc.status IS NULL OR ccc.status = #{useStatus})-->
-    <!--        </if>-->
-    <!--        <if test='useStatus == "2"'>-->
-    <!--            AND ccc.status = #{useStatus}-->
-    <!--        </if>-->
-    <!--        <if test="source != null and source != ''">-->
-    <!--            AND ccc.source = #{source}-->
-    <!--        </if>-->
-    <!--        <if test="shopName != null and shopName != ''">-->
-    <!--            AND s.name LIKE concat('%',#{shopName},'%')-->
-    <!--        </if>-->
-    <!--        <if test="couponsMode != null and couponsMode != ''">-->
-    <!--            AND a.couponsMode = #{couponsMode}-->
-    <!--        </if>-->
-    <!--    </where>-->
-    <!--    GROUP BY a.id-->
-    <!--    <choose>-->
-    <!--        <when test="page !=null and page.orderBy != null and page.orderBy != ''">-->
-    <!--            ORDER BY ${page.orderBy}-->
-    <!--        </when>-->
-    <!--        <otherwise>-->
-    <!--            ORDER BY createDate DESC-->
-    <!--        </otherwise>-->
-    <!--    </choose>-->
-
-
-    <select id="findAllVipCoupon" resultType="com.caimei.modules.coupon.entity.CmVipCoupon">
-        SELECT
-        cs.useTime,
-        cc.`id` AS "couponId",
-        cc.`couponAmount`,
-        cc.`touchPrice`,
-        cc.`startDate`,
-        cc.`endDate`,
-        cc.`couponType`,
-        cc.`shopId`,
-        cc.`productType`,
-        cc.`categoryType`,
-        cs.status
-        FROM cm_coupon cc
-        INNER JOIN cm_svip_coupon cs ON cs.couponId = cc.id
-        WHERE cc.delFlag = 0
-        <if test="status != null and status != ''">
-            AND cc.status = #{status}
-        </if>
-        <if test="useTime != null and useTime != ''">
-            AND cs.useTime=#{useTime}
-        </if>
-        <if test="couponId != null and couponId !=''">
-            AND cs.couponId=#{couponId}
-        </if>
-        ORDER BY cc.startDate DESC
-    </select>
-
-    <select id="findGroup" resultType="com.caimei.modules.coupon.entity.CmVipCoupon">
-        select *
-        from cm_svip_coupon cs
-        where useTime = #{useTime}
-        AND cs.delFlag=0
-        <if test="status!=null and status != ''">
-            AND cs.status=#{status}
-        </if>
-    </select>
-
-    <select id="findShopName" resultType="com.caimei.modules.user.entity.NewCmShop">
-        select name,sname,linkMan,contractMobile
-        from shop
-        where shopID = #{shopId}
-    </select>
-
-    <select id="findUseTime" resultType="String">
-        SELECT DISTINCT usetime
-        FROM cm_svip_coupon_month
-        where delFlag=0
-    </select>
-
-    <select id="findBind" resultType="java.lang.String">
-        SELECT DISTINCT bindCoupon
-        FROM cm_svip_coupon
-    </select>
-
-    <select id="findByCoupon" resultType="com.caimei.modules.coupon.entity.CmVipCoupon">
-        select useTime, status, couponId, bindCoupon
-        from cm_svip_coupon
-        where delFlag = 0
-        and couponId=#{couponId}
-        <if test="status != null and status != ''">
-            and status=#{status}
-        </if>
-    </select>
-</mapper>

+ 0 - 87
src/main/resources/mappings/modules/super/SvipCouponListDao.xml

@@ -1,87 +0,0 @@
-<?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.coupon.dao.SvipCouponListDao">
-
-    <select id="findList" resultType="com.caimei.modules.coupon.entity.SvipCouponList">
-        select cs.id, cs.useTime, cs.status, cs.couponId, cs.bindCoupon
-        from cm_svip_coupon cs
-        <if test='status == "1" or status == "0" or status =="3"'>
-            inner join cm_coupon cc on cc.id=cs.couponId
-        </if>
-        where cs.delFlag=0
-        <if test='status == "2"'>
-            AND cs.status=0
-        </if>
-        <if test='status == "1"'>
-            AND now() between cc.startDate and cc.endDate
-        </if>
-        <if test='status == "0"'>
-            AND cc.startDate > now()
-        </if>
-        <if test='status == "3"'>
-            AND now() > cc.endDate
-        </if>
-        <if test="useTime!=null and useTime!=''">
-            AND cs.useTime=#{useTime}
-        </if>
-        group by cs.bindCoupon
-    </select>
-
-    <select id="findLists" resultType="com.caimei.modules.coupon.entity.SvipCouponList">
-        select useTime, delFlag, status, couponId, bindCoupon
-        from cm_svip_coupon
-        where useTime = #{useTime}
-    </select>
-
-    <select id="findStatus" resultType="com.caimei.modules.coupon.entity.CmCoupon">
-        select startDate, endDate
-        from cm_coupon
-        where id = #{couponId}
-    </select>
-
-    <select id="findVipStatus" resultType="com.caimei.modules.coupon.entity.SvipCouponList">
-        select status, bindCoupon
-        from cm_svip_coupon
-        where couponId = #{couponId}
-    </select>
-
-    <select id="findCoupon" resultType="com.caimei.modules.coupon.entity.CmCoupon">
-        select id,
-               couponAmount,
-               touchPrice,
-               startDate,
-               endDate,
-               status,
-               couponType,
-               userId,
-               shopId,
-               productType,
-               pcBanner,
-               appletsBanner,
-               categoryType,
-               couponsMode,
-               createDate,
-               delFlag
-        from cm_coupon
-        where id = #{couponId}
-    </select>
-
-    <update id="updateVip">
-        UPDATE cm_svip_coupon
-        SET
-        <if test="useTime != null and useTime!=''">
-            useTime = #{useTime},
-        </if>
-        <if test="delFlag != null and delFlag!=''">
-            delFlag = #{delFlag},
-        </if>
-        <if test="bindCoupon != null and bindCoupon != ''">
-            bindCoupon = #{bindCoupon},
-        </if>
-        <if test="status != null and status != ''">
-            status = #{status},
-        </if>
-        UPDATED_TIME = now()
-        WHERE couponId = #{couponId}
-    </update>
-</mapper>

+ 880 - 1202
src/main/webapp/WEB-INF/views/modules/svip/cmSvipCouponForm.jsp

@@ -11,1309 +11,987 @@
             padding: 20px 20px 0;
             margin-bottom: 20px;
         }
-
         .couponType {
             margin-right: 15px;
         }
     </style>
-    <script type="text/javascript">
-        $(document).ready(function () {
-
-            $("#inputForm").validate({
-                submitHandler: function (form) {
-                    if (imageList1.length > 0) {
-                        var productInfo1 = JSON.stringify(imageList1);
-                        $('#productInfo1').val(productInfo1);
-                    }
-                    if (imageList2.length > 0) {
-                        var productInfo2 = JSON.stringify(imageList2);
-                        $('#productInfo2').val(productInfo2);
-                    }
-                    if (imageList3.length > 0) {
-                        var productInfo3 = JSON.stringify(imageList3);
-                        $('#productInfo3').val(productInfo3);
-                    }
-                    if (imageList4.length > 0) {
-                        var productInfo4 = JSON.stringify(imageList4);
-                        $('#productInfo4').val(productInfo4);
-                    }
-
-                    var couponType1 = $("#couponType1").val();
-                    var shopId1 = $("#shopId1").val();
-                    if (couponType1 == 3) {
-                        if (shopId1 == "" || shopId1 == null) {
-                            alert("店铺券供应商不能为空 !");
-                            return false;
-                        }
-                    }
-                    var month = $("#month").val();
-                    // 判断月份 ...
-                    if (month == null || month == "") {
-                        alert("请选择生效时间! ");
-                        return false;
-                    }
-
-                    var couponAmount1 = $("#couponAmount1").val() * 1;
-                    var touchPrice1 = $("#touchPrice1").val() * 1;
-                    if (couponAmount1 == "") {
-                        alertx("【优惠券1】优惠券金额不能为空");
-                        return false;
-                    }
-                    if (touchPrice1 == "") {
-                        alertx("【优惠券1】优惠条件不能为空");
-                        return false;
-                    }
-                    if (couponAmount1 >= touchPrice1) {
-                        alertx("【优惠券1】优惠券金额必须小于优惠条件金额");
-                        return false;
-                    }
-
-                    var couponAmount2 = $("#couponAmount2").val() * 1;
-                    var touchPrice2 = $("#touchPrice2").val() * 1;
-                    if (couponAmount2 == "") {
-                        alertx("【优惠券2】优惠券金额不能为空");
-                        return false;
-                    }
-                    if (touchPrice2 == "") {
-                        alertx("【优惠券2】优惠条件不能为空");
-                        return false;
-                    }
-                    if (couponAmount2 >= touchPrice2) {
-                        alertx("【优惠券2】优惠券金额必须小于优惠条件金额");
-                        return false;
-                    }
-
-                    var couponAmount3 = $("#couponAmount3").val() * 1;
-                    var touchPrice3 = $("#touchPrice3").val() * 1;
-                    if (couponAmount3 == "") {
-                        alertx("【优惠券3】优惠券金额不能为空");
-                        return false;
-                    }
-                    if (touchPrice3 == "") {
-                        alertx("【优惠券3】优惠条件不能为空");
-                        return false;
-                    }
-                    if (couponAmount3 >= touchPrice3) {
-                        alertx("【优惠券3】优惠券金额必须小于优惠条件金额");
-                        return false;
-                    }
-
-                    var couponAmount4 = $("#couponAmount4").val() * 1;
-                    var touchPrice4 = $("#touchPrice4").val() * 1;
-                    if (couponAmount4 == "") {
-                        alertx("【优惠券4】优惠券金额不能为空");
-                        return false;
-                    }
-                    if (touchPrice4 == "") {
-                        alertx("【优惠券4】优惠条件不能为空");
-                        return false;
-                    }
-                    if (couponAmount4 >= touchPrice4) {
-                        alertx("【优惠券4】优惠券金额必须小于优惠条件金额");
-                        return false;
-                    }
-
-
-                    loading('正在提交,请稍等...');
-                    form.submit();
-                },
-                errorContainer: "#messageBox",
-                errorPlacement: function (error, element) {
-                    $("#messageBox").text("输入有误,请先更正。");
-                    if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
-                        error.appendTo(element.parent().parent());
-                    } else {
-                        error.insertAfter(element);
-                    }
-                }
-
-            });
-        });
-    </script>
 </head>
 <body>
 <ul class="nav nav-tabs">
     <li class="active"><a href="${ctx}/vip/cmCoupon/">超级会员专属优惠券</a></li>
-    <li class="active"><a href="${ctx}/vip/cmCoupon/form">${not empty cmCoupon.id?'编辑':'添加'}</a>
+    <li class="active"><a href="${ctx}/vip/cmCoupon/form?id=${cmVipCoupon.id}">${not empty cmVipCoupon.id?'编辑':'添加'}</a>
     </li>
-</ul>
-<br/>
-
-<form:form id="inputForm" modelAttribute="svipcouponForm"
-           action="${ctx}/vip/cmCoupon/save?couponId1=${svipcouponForm.couponId1}" method="post"
-           class="form-horizontal">
-<sys:message content="${message}"/>
-<div class="control-group">
-    <label class="control-label"><font color="red">*</font>优惠月份:</label>
-    <div class="controls">
-        <form:input path="month" type="text" maxlength="20" class="input-medium Wdate" value="${useTime}"
-                    onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
-    </div>
-</div>
-
-<div class="coupon-wrap" id="couponWrap1">
+</ul><br>
+<form:form id="inputForm" modelAttribute="svipcouponForm" action="${ctx}/vip/cmCoupon/save?couponId1=${svipcouponForm.couponId1}" method="post" class="form-horizontal">
+    <sys:message content="${message}"/>
+    <form:hidden path="id" value="${cmVipCoupon.id}"/>
     <div class="control-group">
-        <label class="control-label"><font color="red">*</font><b>优惠券1:</b></label>
+        <label class="control-label"><font color="red">*</font>优惠月份:</label>
         <div class="controls">
-            <form:radiobutton path="couponType1" class="couponType" label="请选择" value="99"
-                              checked="true"></form:radiobutton>
-            <form:radiobutton path="couponType1" class="couponType" label="活动券" value="0"></form:radiobutton>
-            <form:radiobutton path="couponType1" class="couponType" label="品类券" value="1"
-                              onclick="cType(1)"></form:radiobutton>
-            <form:radiobutton path="couponType1" class="couponType" label="店铺券" value="3"
-                              onclick="cType(1)"></form:radiobutton>
+            <form:input path="month" type="text" maxlength="20" class="input-medium Wdate" value="${useTime}"
+                        onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
         </div>
     </div>
-    <form:hidden path="couponId1" id="couponId1"/>
-    <div class="control-group coupon-line l0" style="display:none">
-        <label class="control-label"><font color="red">*</font>供应商:</label>
-        <div class="controls">
-            <a href="javascript:void(0);" onclick="showSelectShop(1)" id="chooseShop1">请选择供应商</a>
-            <form:hidden path="shopId1"/>
-            <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
-                <thead>
-                <tr>
-                    <th>机构名称</th>
-                    <th>机构简称</th>
-                    <th>联系人</th>
-                    <th>手机号</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody class="hotSearchShop"></tbody>
-            </table>
+    <div class="coupon-wrap" id="couponWrap1">
+        <div class="control-group">
+            <label class="control-label"><font color="red">*</font><b>优惠券1:</b></label>
+            <div class="controls">
+                <form:radiobutton path="couponType1" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
+                <form:radiobutton path="couponType1" class="couponType" label="活动券" value="0"></form:radiobutton>
+                <form:radiobutton path="couponType1" class="couponType" label="品类券" value="1" onclick="cType(1)"></form:radiobutton>
+                <form:radiobutton path="couponType1" class="couponType" label="店铺券" value="3" onclick="cType(1)"></form:radiobutton>
+            </div>
         </div>
-    </div>
-
-    <div class="control-group coupon-line l1" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
-        <div class="controls">
-            <form:input path="couponAmount1" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+        <form:hidden path="couponId1" id="couponId1"/>
+        <div class="control-group coupon-line l0" ${svipcouponForm.couponType1 ne '3' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>供应商:</label>
+            <div class="controls">
+                <a href="javascript:void(0);" onclick="showSelectShop(1)" id="chooseShop1">请选择供应商</a>
+                <form:hidden path="shopId1"/>
+                <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead></thead>
+                    <tbody class="hotSearchShop"></tbody>
+                </table>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l2" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠条件:</label>
-        <div class="controls"> 订单商品总额满&nbsp;
-            <form:input path="touchPrice1" htmlEscape="false" maxlength="20" class="input-medium required"/>
+        <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId1 ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+            <div class="controls">
+                <form:input path="couponAmount1" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l3" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠品类:</label>
-        <div class="controls">
-            <form:radiobutton path="categoryType1" value="1" label="产品"
-                              checked="${empty cmCoupon.categoryType ? true:false}"/>
-            <form:radiobutton path="categoryType1" value="2" label="仪器"/>
+        <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId1 ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠条件:</label>
+            <div class="controls"> 订单商品总额满
+                <form:input path="touchPrice1" htmlEscape="false" maxlength="20" class="input-medium required"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l4" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠商品:</label>
-        <div class="controls">
-            <form:radiobutton path="productType1" value="1" label="全商城商品" onclick="productShow(value,1)"
-                              checked="${empty cmCoupon.productType ? true:false}"/>
-            <form:radiobutton path="productType1" value="2" label="指定商品" onclick="productShow(value,1)"/>
+        <div class="control-group coupon-line l3" ${svipcouponForm.couponType1 ne '1' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠品类:</label>
+            <div class="controls">
+                <form:radiobutton path="categoryType1" value="1" label="产品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="categoryType1" value="2" label="仪器"/>
+            </div>
+        </div>
+        <div class="control-group coupon-line l4" ${svipcouponForm.couponType1 ne '0' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠商品:</label>
+            <div class="controls">
+                <form:radiobutton path="productType1" value="1" label="全商城商品" onclick="productShow(value,1)" checked="${empty cmCoupon.productType ? true:false}"/>
+                <form:radiobutton path="productType1" value="2" label="指定商品" onclick="productShow(value,1)"/>
+            </div>
+        </div>
+        <div class="productData1" hidden="hidden">
+            <form:hidden path="productInfo1" id="productInfo1"/>
+            <div class="control-group">
+                <input class="btn del" style="width: 50px" onclick="batchDeletion(1)" value="删除"/>
+                <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(1)" value="添加"/>
+                <br><br>
+                <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead></thead>
+                    <tbody class="hotSearchProduct"></tbody>
+                </table>
+            </div>
         </div>
     </div>
 
-    <div class="productData1" hidden="hidden">
-        <form:hidden path="productInfo1" id="productInfo1"/>
-            <%--            <div class="control-group">--%>
-            <%--                <label class="control-label"><font color="red">*</font>网站活动页banner:</label>--%>
-            <%--                <div class="controls upload-content-image iconBox">--%>
-            <%--                    <div class="conList">--%>
-            <%--                        <form:hidden id="pcBanner" path="pcBanner1" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-            <%--                        <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-            <%--                        <br>--%>
-            <%--                    </div>--%>
-            <%--                </div>--%>
-            <%--            </div>--%>
-            <%--            <div class="control-group">--%>
-            <%--                <label class="control-label"><font color="red">*</font>小程序活动页banner:</label>--%>
-            <%--                <div class="controls upload-content-image iconBox">--%>
-            <%--                    <div class="conList">--%>
-            <%--                        <form:hidden id="appletsBanner" path="appletsBanner1" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-            <%--                        <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-            <%--                        <br>--%>
-            <%--                    </div>--%>
-            <%--                </div>--%>
-            <%--            </div>--%>
+    <div class="coupon-wrap" id="couponWrap2">
         <div class="control-group">
-            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
-                class="btn" class="del" style="width: 50px" onclick="batchDeletion(1)" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
-                <%--                <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort(1)" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;--%>
-            <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(1)" value="添加"/>
-            <br><br>
-            <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
-                <thead>
-                <tr>
-                    <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
-                    </th>
-                    <th>商品图片</th>
-                    <th>商品名称</th>
-                    <th>供应商</th>
-                    <th>网站状态</th>
-                    <th>小程序状态</th>
-                    <th>排序</th>
-                    <th>添加时间</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody class="hotSearchProduct"></tbody>
-            </table>
+            <label class="control-label"><font color="red">*</font><b>优惠券2:</b></label>
+            <div class="controls">
+                <form:radiobutton path="couponType2" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
+                <form:radiobutton path="couponType2" class="couponType" label="活动券" value="0"></form:radiobutton>
+                <form:radiobutton path="couponType2" class="couponType" label="品类券" value="1" onclick="cType(2)"></form:radiobutton>
+                <form:radiobutton path="couponType2" class="couponType" label="店铺券" value="3" onclick="cType(2)"></form:radiobutton>
+            </div>
         </div>
-    </div>
-
-</div>
-<div class="coupon-wrap" id="couponWrap2">
-    <div class="control-group">
-        <label class="control-label"><font color="red">*</font><b>优惠券2:</b></label>
-        <div class="controls">
-            <form:radiobutton path="couponType2" class="couponType" label="请选择" value="99"
-                              checked="true"></form:radiobutton>
-            <form:radiobutton path="couponType2" class="couponType" label="活动券" value="0"></form:radiobutton>
-            <form:radiobutton path="couponType2" class="couponType" label="品类券" value="1"
-                              onclick="cType(2)"></form:radiobutton>
-            <form:radiobutton path="couponType2" class="couponType" label="店铺券" value="3"
-                              onclick="cType(2)"></form:radiobutton>
+        <form:hidden path="couponId2" id="couponId2"/>
+        <div class="control-group coupon-line l0" ${svipcouponForm.couponType2 ne '3' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>供应商:</label>
+            <div class="controls">
+                <a href="javascript:void(0);" onclick="showSelectShop(2)" id="chooseShop2">请选择供应商</a>
+                <form:hidden path="shopId2"/>
+                <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead></thead>
+                    <tbody class="hotSearchShop"></tbody>
+                </table>
+            </div>
         </div>
-    </div>
-    <form:hidden path="couponId2" id="couponId2"/>
-    <div class="control-group coupon-line l0" style="display:none">
-        <label class="control-label"><font color="red">*</font>供应商:</label>
-        <div class="controls">
-            <a href="javascript:void(0);" onclick="showSelectShop(2)" id="chooseShop2">请选择供应商</a>
-            <form:hidden path="shopId2"/>
-            <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
-                <thead>
-                <tr>
-                    <th>机构名称</th>
-                    <th>机构简称</th>
-                    <th>联系人</th>
-                    <th>手机号</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody class="hotSearchShop"></tbody>
-            </table>
+        <div class="control-group coupon-line l1"  ${empty svipcouponForm.couponId2 ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+            <div class="controls">
+                <form:input path="couponAmount2" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l1" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
-        <div class="controls">
-            <form:input path="couponAmount2" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+        <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId2 ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠条件:</label>
+            <div class="controls"> 订单商品总额满
+                <form:input path="touchPrice2" htmlEscape="false" maxlength="20" class="input-medium required"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l2" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠条件:</label>
-        <div class="controls"> 订单商品总额满&nbsp;
-            <form:input path="touchPrice2" htmlEscape="false" maxlength="20" class="input-medium required"/>
+        <div class="control-group coupon-line l3" ${svipcouponForm.couponType2 ne '1' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠品类:</label>
+            <div class="controls">
+                <form:radiobutton path="categoryType2" value="1" label="产品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="categoryType2" value="2" label="仪器"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l3" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠品类:</label>
-        <div class="controls">
-            <form:radiobutton path="categoryType2" value="1" label="产品"
-                              checked="${empty cmCoupon.categoryType ? true:false}"/>
-            <form:radiobutton path="categoryType2" value="2" label="仪器"/>
+        <div class="control-group coupon-line l4" ${svipcouponForm.couponType2 ne '0' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠商品:</label>
+            <div class="controls">
+                <form:radiobutton path="productType2" value="1" label="全商城商品" onclick="productShow(value,2)" checked="${empty cmCoupon.productType ? true:false}"/>
+                <form:radiobutton path="productType2" value="2" label="指定商品" onclick="productShow(value,2)"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l4" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠商品:</label>
-        <div class="controls">
-            <form:radiobutton path="productType2" value="1" label="全商城商品" onclick="productShow(value,2)"
-                              checked="${empty cmCoupon.productType ? true:false}"/>
-            <form:radiobutton path="productType2" value="2" label="指定商品" onclick="productShow(value,2)"/>
+        <div class="productData2" hidden="hidden">
+            <form:hidden path="productInfo2" id="productInfo2"/>
+            <div class="control-group">
+                <input class="btn del" style="width: 50px" onclick="batchDeletion(2)" value="删除"/>
+                <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(2)" value="添加"/>
+                <br><br>
+                <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead></thead>
+                    <tbody class="hotSearchProduct"></tbody>
+                </table>
+            </div>
         </div>
     </div>
 
-    <div class="productData2" hidden="hidden">
-        <form:hidden path="productInfo2" id="productInfo2"/>
-            <%--            <div class="control-group">--%>
-            <%--                <label class="control-label"><font color="red">*</font>网站活动页banner:</label>--%>
-            <%--                <div class="controls upload-content-image iconBox">--%>
-            <%--                    <div class="conList">--%>
-            <%--                        <form:hidden id="pcBanner" path="pcBanner2" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-            <%--                        <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-            <%--                        <br>--%>
-            <%--                    </div>--%>
-            <%--                </div>--%>
-            <%--            </div>--%>
-            <%--            <div class="control-group">--%>
-            <%--                <label class="control-label"><font color="red">*</font>小程序活动页banner:</label>--%>
-            <%--                <div class="controls upload-content-image iconBox">--%>
-            <%--                    <div class="conList">--%>
-            <%--                        <form:hidden id="appletsBanner" path="appletsBanner2" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-            <%--                        <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-            <%--                        <br>--%>
-            <%--                    </div>--%>
-            <%--                </div>--%>
-            <%--            </div>--%>
+    <div class="coupon-wrap" id="couponWrap3">
         <div class="control-group">
-            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
-                class="btn" class="del" style="width: 50px" onclick="batchDeletion(2)" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
-                <%--                <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort(2)" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;--%>
-            <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(2)" value="添加"/>
-            <br><br>
-            <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
-                <thead>
-                <tr>
-                    <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
-                    </th>
-                    <th>商品图片</th>
-                    <th>商品名称</th>
-                    <th>供应商</th>
-                    <th>网站状态</th>
-                    <th>小程序状态</th>
-                    <th>排序</th>
-                    <th>添加时间</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody class="hotSearchProduct"></tbody>
-            </table>
+            <label class="control-label"><font color="red">*</font><b>优惠券3:</b></label>
+            <div class="controls">
+                <form:radiobutton path="couponType3" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
+                <form:radiobutton path="couponType3" class="couponType" label="活动券" value="0"></form:radiobutton>
+                <form:radiobutton path="couponType3" class="couponType" label="品类券" value="1" onclick="cType(3)"></form:radiobutton>
+                <form:radiobutton path="couponType3" class="couponType" label="店铺券" value="3" onclick="cType(3)"></form:radiobutton>
+            </div>
         </div>
-    </div>
-
-</div>
-<div class="coupon-wrap" id="couponWrap3">
-    <div class="control-group">
-        <label class="control-label"><font color="red">*</font><b>优惠券3:</b></label>
-        <div class="controls">
-            <form:radiobutton path="couponType3" class="couponType" label="请选择" value="99"
-                              checked="true"></form:radiobutton>
-            <form:radiobutton path="couponType3" class="couponType" label="活动券" value="0"></form:radiobutton>
-            <form:radiobutton path="couponType3" class="couponType" label="品类券" value="1"
-                              onclick="cType(3)"></form:radiobutton>
-            <form:radiobutton path="couponType3" class="couponType" label="店铺券" value="3"
-                              onclick="cType(3)"></form:radiobutton>
+        <form:hidden path="couponId3" id="couponId3"/>
+        <div class="control-group coupon-line l0" ${svipcouponForm.couponType3 ne '3' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>供应商:</label>
+            <div class="controls">
+                <a href="javascript:void(0);" onclick="showSelectShop(3)" id="chooseShop3">请选择供应商</a>
+                <form:hidden path="shopId3"/>
+                <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead></thead>
+                    <tbody class="hotSearchShop"></tbody>
+                </table>
+            </div>
         </div>
-    </div>
-    <form:hidden path="couponId3" id="couponId3"/>
-    <div class="control-group coupon-line l0" style="display:none">
-        <label class="control-label"><font color="red">*</font>供应商:</label>
-        <div class="controls">
-            <a href="javascript:void(0);" onclick="showSelectShop(3)" id="chooseShop3">请选择供应商</a>
-            <form:hidden path="shopId3"/>
-            <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
-                <thead>
-                <tr>
-                    <th>机构名称</th>
-                    <th>机构简称</th>
-                    <th>联系人</th>
-                    <th>手机号</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody class="hotSearchShop"></tbody>
-            </table>
+        <div class="control-group coupon-line l1"  ${empty svipcouponForm.couponId3 ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠券金额:</label>
+            <div class="controls">
+                <form:input path="couponAmount3" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l1" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠券金额:</label>
-        <div class="controls">
-            <form:input path="couponAmount3" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+        <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId3 ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠条件:</label>
+            <div class="controls"> 订单商品总额满
+                <form:input path="touchPrice3" htmlEscape="false" maxlength="20" class="input-medium required"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l2" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠条件:</label>
-        <div class="controls"> 订单商品总额满&nbsp;
-            <form:input path="touchPrice3" htmlEscape="false" maxlength="20" class="input-medium required"/>
+        <div class="control-group coupon-line l3" ${svipcouponForm.couponType3 ne '1' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠品类:</label>
+            <div class="controls">
+                <form:radiobutton path="categoryType3" value="1" label="产品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="categoryType3" value="2" label="仪器"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l3" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠品类:</label>
-        <div class="controls">
-            <form:radiobutton path="categoryType3" value="1" label="产品"
-                              checked="${empty cmCoupon.categoryType ? true:false}"/>
-            <form:radiobutton path="categoryType3" value="2" label="仪器"/>
+        <div class="control-group coupon-line l4" ${svipcouponForm.couponType3 ne '0' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠商品:</label>
+            <div class="controls">
+                <form:radiobutton path="productType3" value="1" label="全商城商品" onclick="productShow(value,3)" checked="${empty cmCoupon.productType ? true:false}"/>
+                <form:radiobutton path="productType3" value="2" label="指定商品" onclick="productShow(value,3)"/>
+            </div>
         </div>
-    </div>
-    <div class="control-group coupon-line l4" style="display:none">
-        <label class="control-label"><font color="red">*</font>优惠商品:</label>
-        <div class="controls">
-            <form:radiobutton path="productType3" value="1" label="全商城商品" onclick="productShow(value,3)"
-                              checked="${empty cmCoupon.productType ? true:false}"/>
-            <form:radiobutton path="productType3" value="2" label="指定商品" onclick="productShow(value,3)"/>
+        <div class="productData3" hidden="hidden">
+            <form:hidden path="productInfo3" id="productInfo3"/>
+            <div class="control-group">
+                <input class="btn del" style="width: 50px" onclick="batchDeletion(3)" value="删除"/>
+                <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(3)" value="添加"/>
+                <br><br>
+                <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead></thead>
+                    <tbody class="hotSearchProduct"></tbody>
+                </table>
+            </div>
         </div>
     </div>
 
-    <div class="productData3" hidden="hidden">
-        <form:hidden path="productInfo3" id="productInfo3"/>
-            <%--            <div class="control-group">--%>
-            <%--                <label class="control-label"><font color="red">*</font>网站活动页banner:</label>--%>
-            <%--                <div class="controls upload-content-image iconBox">--%>
-            <%--                    <div class="conList">--%>
-            <%--                        <form:hidden id="pcBanner" path="pcBanner3" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-            <%--                        <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-            <%--                        <br>--%>
-            <%--                    </div>--%>
-            <%--                </div>--%>
-            <%--            </div>--%>
-            <%--            <div class="control-group">--%>
-            <%--                <label class="control-label"><font color="red">*</font>小程序活动页banner:</label>--%>
-            <%--                <div class="controls upload-content-image iconBox">--%>
-            <%--                    <div class="conList">--%>
-            <%--                        <form:hidden id="appletsBanner" path="appletsBanner3" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-            <%--                        <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-            <%--                        <br>--%>
-            <%--                    </div>--%>
-            <%--                </div>--%>
-            <%--            </div>--%>
+    <div class="coupon-wrap" id="couponWrap4">
         <div class="control-group">
-            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
-                class="btn" class="del" style="width: 50px" onclick="batchDeletion(3)" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
-                <%--                <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort(3)" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;--%>
-            <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(3)" value="添加"/>
-            <br><br>
-            <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
-                <thead>
-                <tr>
-                    <th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/> 全选
-                    </th>
-                    <th>商品图片</th>
-                    <th>商品名称</th>
-                    <th>供应商</th>
-                    <th>网站状态</th>
-                    <th>小程序状态</th>
-                    <th>排序</th>
-                    <th>添加时间</th>
-                    <th>操作</th>
-                </tr>
-                </thead>
-                <tbody class="hotSearchProduct"></tbody>
-            </table>
-        </div>
-    </div>
-
-</div>
-<div class="coupon-wrap" id="couponWrap4">
-    <div class="control-group">
-        <label class="control-label"><font color="red">*</font><b>优惠券4:</b></label>
-        <div class="controls">
-            <form:radiobutton path="couponType4" class="couponType" label="请选择" value="99"
-                              checked="true"></form:radiobutton>
-            <form:radiobutton path="couponType4" class="couponType" label="活动券" value="0"></form:radiobutton>
-            <form:radiobutton path="couponType4" class="couponType" label="品类券" value="1"
-                              onclick="cType(4)"></form:radiobutton>
-            <form:radiobutton path="couponType4" class="couponType" label="店铺券" value="3"
-                              onclick="cType(4)"></form:radiobutton>
+            <label class="control-label"><font color="red">*</font><b>优惠券4:</b></label>
+            <div class="controls">
+                <form:radiobutton path="couponType4" class="couponType" label="请选择" value="" checked="true"></form:radiobutton>
+                <form:radiobutton path="couponType4" class="couponType" label="活动券" value="0"></form:radiobutton>
+                <form:radiobutton path="couponType4" class="couponType" label="品类券" value="1" onclick="cType(1)"></form:radiobutton>
+                <form:radiobutton path="couponType4" class="couponType" label="店铺券" value="3" onclick="cType(1)"></form:radiobutton>
+            </div>
         </div>
-    </div>
-        <form:hidden path="couponId4" id="couponId4"/>
-    <c:if test="${svipcouponForm.shopId4 != null}">
-    <div class="control-group coupon-line l0">
-        </c:if>
-        <div class="control-group coupon-line l0" style="display:none">
+        <form:hidden path="couponId1" id="couponId4"/>
+        <div class="control-group coupon-line l0" ${svipcouponForm.couponType4 ne '3' ? 'style="display:none"':''}>
             <label class="control-label"><font color="red">*</font>供应商:</label>
             <div class="controls">
                 <a href="javascript:void(0);" onclick="showSelectShop(4)" id="chooseShop4">请选择供应商</a>
                 <form:hidden path="shopId4"/>
                 <table class="contentTableShop table table-striped table-bordered table-condensed" hidden="hidden">
-                    <thead>
-                    <tr>
-                        <th>机构名称</th>
-                        <th>机构简称</th>
-                        <th>联系人</th>
-                        <th>手机号</th>
-                        <th>操作</th>
-                    </tr>
-                    </thead>
+                    <thead></thead>
                     <tbody class="hotSearchShop"></tbody>
                 </table>
             </div>
         </div>
-        <div class="control-group coupon-line l1" style="display:none">
+        <div class="control-group coupon-line l1" ${empty svipcouponForm.couponId4 ? 'style="display:none"':''}>
             <label class="control-label"><font color="red">*</font>优惠券金额:</label>
             <div class="controls">
                 <form:input path="couponAmount4" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
             </div>
         </div>
-        <div class="control-group coupon-line l2" style="display:none">
+        <div class="control-group coupon-line l2" ${empty svipcouponForm.couponId4 ? 'style="display:none"':''}>
             <label class="control-label"><font color="red">*</font>优惠条件:</label>
-            <div class="controls"> 订单商品总额满&nbsp;
+            <div class="controls"> 订单商品总额满
                 <form:input path="touchPrice4" htmlEscape="false" maxlength="20" class="input-medium required"/>
             </div>
         </div>
-            <c:if test="${svipcouponForm.categoryType4 eq '1' or svipcouponForm.categoryType4 eq '2'}">
-            <div class="control-group coupon-line l3" style="display:none">
-            </c:if>
-        <div class="control-group coupon-line l3" style="display:none">
+        <div class="control-group coupon-line l3" ${svipcouponForm.couponType4 ne '1' ? 'style="display:none"':''}>
             <label class="control-label"><font color="red">*</font>优惠品类:</label>
             <div class="controls">
-                <form:radiobutton path="categoryType4" value="1" label="产品"
-                                  checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="categoryType4" value="1" label="产品" checked="${empty cmCoupon.categoryType ? true:false}"/>
                 <form:radiobutton path="categoryType4" value="2" label="仪器"/>
             </div>
         </div>
-        <c:if test="${svipcouponForm.couponType4 eq '0'}">
-        <div class="control-group coupon-line l4">
-        </c:if>
-        <c:if test="${svipcouponForm.couponType4 ne '0'}">
-        <div class="control-group coupon-line l4" style="display:none">
-        </c:if>
-
-                <label class="control-label"><font color="red">*</font>优惠商品:</label>
-                <div class="controls">
-                    <form:radiobutton path="productType4" value="1" label="全商城商品" onclick="productShow(value,4)"
-                                      checked="${empty cmCoupon.productType ? true:false}"/>
-                    <form:radiobutton path="productType4" value="2" label="指定商品" onclick="productShow(value,4)"/>
-                </div>
+        <div class="control-group coupon-line l4" ${svipcouponForm.couponType4 ne '0' ? 'style="display:none"':''}>
+            <label class="control-label"><font color="red">*</font>优惠商品:</label>
+            <div class="controls">
+                <form:radiobutton path="productType4" value="1" label="全商城商品" onclick="productShow(value,4)" checked="${empty cmCoupon.productType ? true:false}"/>
+                <form:radiobutton path="productType4" value="2" label="指定商品" onclick="productShow(value,4)"/>
             </div>
-
-            <c:if test="${svipcouponForm.productType4 eq '2'}">
-            <div class="productData4">
-            </c:if>
-            <c:if test="${svipcouponForm.couponType4 eq '99'}">
-            <div class="productData4" hidden="hidden">
-            </c:if>
+        </div>
+        <div class="productData4" hidden="hidden">
             <form:hidden path="productInfo4" id="productInfo4"/>
-                        <%--            <div class="control-group">--%>
-                        <%--                <label class="control-label"><font color="red">*</font>网站活动页banner:</label>--%>
-                        <%--                <div class="controls upload-content-image iconBox">--%>
-                        <%--                    <div class="conList">--%>
-                        <%--                        <form:hidden id="pcBanner" path="pcBanner4" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-                        <%--                        <sys:ckfinder input="pcBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-                        <%--                        <br>--%>
-                        <%--                    </div>--%>
-                        <%--                </div>--%>
-                        <%--            </div>--%>
-                        <%--            <div class="control-group">--%>
-                        <%--                <label class="control-label"><font color="red">*</font>小程序活动页banner:</label>--%>
-                        <%--                <div class="controls upload-content-image iconBox">--%>
-                        <%--                    <div class="conList">--%>
-                        <%--                        <form:hidden id="appletsBanner" path="appletsBanner4" htmlEscape="false" maxlength="255" class="input-xlarge"/>--%>
-                        <%--                        <sys:ckfinder input="appletsBanner" type="images" uploadPath="/photo" selectMultiple="false" maxWidth="100" maxHeight="100"/>--%>
-                        <%--                        <br>--%>
-                        <%--                    </div>--%>
-                        <%--                </div>--%>
-                        <%--            </div>--%>
-                    <div class="control-group">
-                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input
-                            class="btn" class="del" style="width: 50px" onclick="batchDeletion(4)" value="删除"/>&nbsp;&nbsp;&nbsp;&nbsp;
-                            <%--                <input class="btn btn-primary" style="width: 70px" onclick="batchSaveSort(4)" value="一键排序"/>&nbsp;&nbsp;&nbsp;&nbsp;--%>
-                        <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(4)" value="添加"/>
-                        <br><br>
-                        <table class="contentTableProduct table table-striped table-bordered table-condensed"
-                               hidden="hidden">
-                            <thead>
-                            <tr>
-                                <th style="width:20px;"><input class="check-all" type="checkbox"
-                                                               onclick="clickAllSelect(this)"/> 全选
-                                </th>
-                                <th>商品图片</th>
-                                <th>商品名称</th>
-                                <th>供应商</th>
-                                <th>网站状态</th>
-                                <th>小程序状态</th>
-                                <th>排序</th>
-                                <th>添加时间</th>
-                                <th>操作</th>
-                            </tr>
-                            </thead>
-                            <tbody class="hotSearchProduct"></tbody>
-                        </table>
-                    </div>
-                </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 class="control-group">
+                <input class="btn del" style="width: 50px" onclick="batchDeletion(4)" value="删除"/>
+                <input class="btn btn-primary" style="width: 50px" onclick="showSelectProduct(4)" value="添加"/>
+                <br><br>
+                <table class="contentTableProduct table table-striped table-bordered table-condensed" hidden="hidden">
+                    <thead></thead>
+                    <tbody class="hotSearchProduct"></tbody>
+                </table>
             </div>
-            </form:form>
-
-
-            <script>
-
-
-                $("body").on("change", ".couponType", function () {
-                    var value = $(this).parent().find('input.couponType:checked').val() * 1;
-                    $(this).parents(".coupon-wrap").find(".coupon-line").hide();
-                    if (0 === value) {
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l4").show();
-                    } else if (1 === value) {
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l3").show();
-                    } else if (3 === value) {
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l0").show();
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
-                        $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
-                    }
-                });
-
-
-                function cType(id) {
-                    $("#couponWrap" + id).find(".productData" + id).hide();
+        </div>
+    </div>
+    <div class="form-actions">
+        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>
+        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
+    </div>
+</form:form>
+
+<script type="text/javascript">
+    $(document).ready(function () {
+        $("#inputForm").validate({
+            submitHandler: function (form) {
+                if (imageList1.length > 0) {
+                    var productInfo1 = JSON.stringify(imageList1);
+                    $('#productInfo1').val(productInfo1);
                 }
-
-                // 点击添加供应商
-                function showSelectShop(id) {
-                    var url = "${ctx}/coupon/cmCoupon/toAddShop";
-                    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);
-                                appendShopOrderHead(items, id);
-                            }
-                            return true;
-                        }
-                    });
+                if (imageList2.length > 0) {
+                    var productInfo2 = JSON.stringify(imageList2);
+                    $('#productInfo2').val(productInfo2);
                 }
-
-                $(function () {
-                    //店铺券供应商回显
-                    if (${not empty svipcouponForm.shop1}) {
-                        var shop = {
-                            "shopId": "${svipcouponForm.shop1.shopID}",
-                            "name": "${svipcouponForm.shop1.name}",
-                            "sname": "${svipcouponForm.shop1.sname}",
-                            "linkMan": "${svipcouponForm.shop1.linkMan}",
-                            "contractMobile": "${svipcouponForm.shop1.contractMobile}"
-                        }
-                        appendShopOrderHead(shop, 1);
-                    }
-                });
-
-                $(function () {
-                    //店铺券供应商回显
-                    if (${not empty svipcouponForm.shop2}) {
-                        var shop = {
-                            "shopId": "${svipcouponForm.shop2.shopID}",
-                            "name": "${svipcouponForm.shop2.name}",
-                            "sname": "${svipcouponForm.shop2.sname}",
-                            "linkMan": "${svipcouponForm.shop2.linkMan}",
-                            "contractMobile": "${svipcouponForm.shop2.contractMobile}"
-                        }
-                        appendShopOrderHead(shop, 2);
-                    }
-                });
-
-
-                $(function () {
-                    //店铺券供应商回显
-                    if (${not empty svipcouponForm.shop3}) {
-                        var shop = {
-                            "shopId": "${svipcouponForm.shop3.shopID}",
-                            "name": "${svipcouponForm.shop3.name}",
-                            "sname": "${svipcouponForm.shop3.sname}",
-                            "linkMan": "${svipcouponForm.shop3.linkMan}",
-                            "contractMobile": "${svipcouponForm.shop3.contractMobile}"
-                        }
-                        appendShopOrderHead(shop, 3);
-                    }
-                });
-
-                $(function () {
-                    //店铺券供应商回显
-                    if (${not empty svipcouponForm.shop4}) {
-                        var shop = {
-                            "shopId": "${svipcouponForm.shop4.shopID}",
-                            "name": "${svipcouponForm.shop4.name}",
-                            "sname": "${svipcouponForm.shop4.sname}",
-                            "linkMan": "${svipcouponForm.shop4.linkMan}",
-                            "contractMobile": "${svipcouponForm.shop4.contractMobile}"
-                        }
-                        appendShopOrderHead(shop, 4);
-                    }
-                });
-
-
-                // $(function () {
-                //     $('.upload-content-image .conList .btn:nth-of-type(1)').html('<div><span>+</span><h5>选择图片</h5></div>');
-                //     $('.upload-content-image .conList .btn:nth-of-type(2)').after('<img class="cancel-upload-image" src="/static/images/close-btn1.png">').remove();
-                //     $('.upload-content-image .conList').find('.cancel-upload-image').hide();
-                //     var observeEleImage = document.getElementsByClassName('upload-content-image')[0];
-                //     var observeEleImage1 = document.getElementsByClassName('upload-content-image')[1];
-                //     var MutationObserverImage = window.MutationObserver || window.WebKitMutationObserver;
-                //     var MutationObserverConfigImage = {
-                //         childList: true,
-                //         subtree: true,
-                //         characterData: true
-                //     };
-                //     var observerImage = new MutationObserverImage(function (mutations) {
-                //         $.each(mutations, function (index, item) {
-                //             if (item.type === 'childList') {
-                //                 // 在创建新的 element 时调用
-                //                 var target = $(item.target),
-                //                     thisWrapper = target.closest('.conList'),
-                //                     nextEle = thisWrapper.next();
-                //                 thisWrapper.find('li').css('z-index', 99);
-                //                 thisWrapper.find('.cancel-upload-image').show();
-                //                 if (nextEle.hasClass('hide-pic-image')) {
-                //                     nextEle.removeClass('hide-pic-image');
-                //                 }
-                //             }
-                //         })
-                //     });
-                //     observerImage.observe(observeEleImage, MutationObserverConfigImage);
-                //     observerImage.observe(observeEleImage1, MutationObserverConfigImage);
-                //
-                //     $('body').on('click', '.upload-content-image li', function () {
-                //         var index = $(this).closest('.conList').index() + 1,
-                //             str = 'remarkImage' + index + 'FinderOpen';
-                //         eval(str + '()');
-                //     });
-                //     $('body').on('click', '.cancel-upload-image', function () {
-                //         var wrapper = $(this).closest('.conList');
-                //         wrapper.find('li').css('z-index', '-1');
-                //         wrapper.find('input').val('');
-                //         $(this).hide();
-                //         wrapper.removeClass("hide-pic-image");
-                //         wrapper.parent().append(wrapper.clone());
-                //         wrapper.remove();
-                //         $(".conList").each(function (i, ele) {
-                //             if ($(ele).find("input.input-xlarge").val()) {
-                //                 $(ele).next().removeClass("hide-pic-image")
-                //             }
-                //         })
-                //     });
-                //     $(window).on("load", function () {
-                //         setTimeout(function () {
-                //             var input = $("#pcBanner");
-                //             if (input.val()) {
-                //                 input.next().find("li").css("z-index", "99");
-                //                 input.parents(".conList").find(".cancel-upload-image").show();
-                //                 input.parents(".conList").next().removeClass("hide-pic-image")
-                //             }
-                //             input = $("#appletsBanner");
-                //             if (input.val()) {
-                //                 input.next().find("li").css("z-index", "99");
-                //                 input.parents(".conList").find(".cancel-upload-image").show();
-                //                 input.parents(".conList").next().removeClass("hide-pic-image")
-                //             }
-                //         }, 500);
-                //     });
-                //     // productShow(value,id)
-                // });
-
-
-                function productShow(value, id) {
-                    if (value == 2) {
-                        $(".productData" + id).show();
-                    } else {
-                        $(".productData" + id).hide();
-                    }
+                if (imageList3.length > 0) {
+                    var productInfo3 = JSON.stringify(imageList3);
+                    $('#productInfo3').val(productInfo3);
                 }
-
-                var productIds1 = '';
-                var productIds2 = '';
-                var productIds3 = '';
-                var productIds4 = '';
-                var imageList1 = [];
-                var imageList2 = [];
-                var imageList3 = [];
-                var imageList4 = [];
-
-                //点击添加
-                function showSelectProduct(id) {
-                    var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=";
-                    if (id * 1 === 1) {
-                        url += productIds1;
-                    }
-                    if (id * 1 === 2) {
-                        url += productIds2;
-                    }
-                    if (id * 1 === 3) {
-                        url += productIds3;
-                    }
-                    if (id * 1 === 4) {
-                        url += productIds4;
-                    }
-                    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]);
-                                    if (id * 1 === 1) {
-                                        imageList1.push(items[i]);
-                                    }
-                                    if (id * 1 === 2) {
-                                        imageList2.push(items[i]);
-                                    }
-                                    if (id * 1 === 3) {
-                                        imageList3.push(items[i]);
-                                    }
-                                    if (id * 1 === 4) {
-                                        imageList4.push(items[i]);
-                                    }
-                                    $("#couponWrap" + id).find(".contentTableProduct").show();
-                                    $(".del").removeAttr("disabled");
-                                    batchSaveSort(id);
-                                }
-                                ;
-                            }
-                            return true;
-                        }
-                    });
+                if (imageList4.length > 0) {
+                    var productInfo4 = JSON.stringify(imageList4);
+                    $('#productInfo4').val(productInfo4);
                 }
-
-                //产品回显
-                $(function () {
-                    <c:forEach items="${associateList1}" var="associate" varStatus="index">
-                    imageList1.push({
-                        id: "${associate.id}",
-                        productId: "${empty associate.productId ? "":associate.productId}",
-                        image: "${associate.image}",
-                        productName: "${associate.productName}",
-                        shopName: "${associate.shopName}",
-                        sort: "${associate.sort}",
-                        pcStatus: "${associate.pcStatus}",
-                        appletsStatus: "${associate.appletsStatus}",
-                        addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
-                    });
-                    </c:forEach>
-
-                    if (imageList1.length > 0) {
-                        $('#couponWrap1').find('.contentTableProduct').show();
-                        batchSaveSort(1);
-                        showSelectProduct(1);
-                    }
-                });
-
-                $(function () {
-                    <c:forEach items="${associateList2}" var="associate" varStatus="index">
-                    imageList2.push({
-                        id: "${associate.id}",
-                        productId: "${empty associate.productId ? "":associate.productId}",
-                        image: "${associate.image}",
-                        productName: "${associate.productName}",
-                        shopName: "${associate.shopName}",
-                        sort: "${associate.sort}",
-                        pcStatus: "${associate.pcStatus}",
-                        appletsStatus: "${associate.appletsStatus}",
-                        addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
-                    });
-                    </c:forEach>
-
-                    if (imageList2.length > 0) {
-                        $('#couponWrap2').find('.contentTableProduct').show();
-                        batchSaveSort(2);
-                        showSelectProduct(2);
-                    }
-                });
-
-                $(function () {
-                    <c:forEach items="${associateList3}" var="associate" varStatus="index">
-                    imageList3.push({
-                        id: "${associate.id}",
-                        productId: "${empty associate.productId ? "":associate.productId}",
-                        image: "${associate.image}",
-                        productName: "${associate.productName}",
-                        shopName: "${associate.shopName}",
-                        sort: "${associate.sort}",
-                        pcStatus: "${associate.pcStatus}",
-                        appletsStatus: "${associate.appletsStatus}",
-                        addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
-                    });
-                    </c:forEach>
-
-                    if (imageList3.length > 0) {
-                        $('#couponWrap3').find('.contentTableProduct').show();
-                        batchSaveSort(3);
-                        showSelectProduct(3);
-                    }
-                });
-
-                $(function () {
-                    <c:forEach items="${associateList4}" var="associate" varStatus="index">
-                    imageList4.push({
-                        id: "${associate.id}",
-                        productId: "${empty associate.productId ? "":associate.productId}",
-                        image: "${associate.image}",
-                        productName: "${associate.productName}",
-                        shopName: "${associate.shopName}",
-                        sort: "${associate.sort}",
-                        pcStatus: "${associate.pcStatus}",
-                        appletsStatus: "${associate.appletsStatus}",
-                        addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
-                    });
-                    </c:forEach>
-
-                    if (imageList4.length > 0) {
-                        $('#couponWrap4').find('.contentTableProduct').show();
-                        batchSaveSort(4);
-                        showSelectProduct(4);
-                    }
-                });
-
-                //一键排序
-                function batchSaveSort(id) {
-                    if (id * 1 === 1) {
-                        imageList1.sort(sort);
-                        insertHtmlProduct(imageList1, id);
-                    }
-                    if (id * 1 === 2) {
-                        imageList2.sort(sort);
-                        insertHtmlProduct(imageList2, id);
-                    }
-                    if (id * 1 === 3) {
-                        imageList3.sort(sort);
-                        insertHtmlProduct(imageList3, id);
-                    }
-                    if (id * 1 === 4) {
-                        imageList4.sort(sort);
-                        insertHtmlProduct(imageList4, id);
+                var couponType1 = $("#couponType1").val();
+                var shopId1 = $("#shopId1").val();
+                if (couponType1 == 3) {
+                    if (shopId1 == "" || shopId1 == null) {
+                        alert("店铺券供应商不能为空 !");
+                        return false;
                     }
-
                 }
-
-                //根据sort值 从小到大排序
-                function sort(a, b) {
-                    return a.sort - b.sort;
+                var month = $("#month").val();
+                // 判断月份 ...
+                if (month == null || month == "") {
+                    alert("请选择生效时间! ");
+                    return false;
                 }
-
-                //相关图片列表数据
-                function appendProductOrderHead(data, index, id) {
-                    var html = '<tr id ="ai' + index + '">' +
-                        '<td>' +
-                        '<input class="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.pcStatus == 1 ? (
-                            '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
-                            '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ',' + id + ');" >' +
-                            '停用</a>'
-                        ) : (
-                            '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
-                            '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ',' + id + ');">' +
-                            '启用</a>'
-                        )) +
-                        '</td>' +
-                        '<td>' +
-                        (data.appletsStatus == 1 ? (
-                            '<font color="green">已启用</font>&nbsp;&nbsp;&nbsp;' +
-                            '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ',' + id + ');" >' +
-                            '停用</a>'
-                        ) : (
-                            '<font color="red">已停用</font>&nbsp;&nbsp;&nbsp;' +
-                            '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ',' + id + ');">' +
-                            '启用</a>'
-                        )) +
-                        '</td>' +
-                        '<td>' +
-                        '<input name="sort" style="width:50px;" value="' + data.sort + '"  onkeyup="onlynum(this)"  onchange="changeSort(' + index + ',this,' + id + ')"></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="delect(' + index + ',' + id + ')">删除</a>' +
-                        '</td>' +
-                        '</tr>';
-                    return html;
+                var couponAmount1 = $("#couponAmount1").val() * 1;
+                var touchPrice1 = $("#touchPrice1").val() * 1;
+                if (couponAmount1 == "") {
+                    alertx("【优惠券1】优惠券金额不能为空");
+                    return false;
                 }
-
-                function insertHtmlProduct(list, id) {
-                    var html = '';
-                    tempIds = '';
-                    if (list && list.length > 0) {
-                        list.forEach(function (item, index) {
-                            html += appendProductOrderHead(item, index, id);
-                            tempIds += "," + item.productId;
-                        });
-                    }
-                    if (id * 1 === 1) {
-                        productIds1 = tempIds;
-                    }
-                    if (id * 1 === 2) {
-                        productIds2 = tempIds;
-                    }
-                    if (id * 1 === 3) {
-                        productIds3 = tempIds;
-                    }
-                    if (id * 1 === 4) {
-                        productIds4 = tempIds;
-                    }
-                    $("#couponWrap" + id).find(".hotSearchProduct").html(html);
+                if (touchPrice1 == "") {
+                    alertx("【优惠券1】优惠条件不能为空");
+                    return false;
+                }
+                if (couponAmount1 >= touchPrice1) {
+                    alertx("【优惠券1】优惠券金额必须小于优惠条件金额");
+                    return false;
+                }
+                var couponAmount2 = $("#couponAmount2").val() * 1;
+                var touchPrice2 = $("#touchPrice2").val() * 1;
+                if (couponAmount2 == "") {
+                    alertx("【优惠券2】优惠券金额不能为空");
+                    return false;
+                }
+                if (touchPrice2 == "") {
+                    alertx("【优惠券2】优惠条件不能为空");
+                    return false;
+                }
+                if (couponAmount2 >= touchPrice2) {
+                    alertx("【优惠券2】优惠券金额必须小于优惠条件金额");
+                    return false;
+                }
+                var couponAmount3 = $("#couponAmount3").val() * 1;
+                var touchPrice3 = $("#touchPrice3").val() * 1;
+                if (couponAmount3 == "") {
+                    alertx("【优惠券3】优惠券金额不能为空");
+                    return false;
+                }
+                if (touchPrice3 == "") {
+                    alertx("【优惠券3】优惠条件不能为空");
+                    return false;
+                }
+                if (couponAmount3 >= touchPrice3) {
+                    alertx("【优惠券3】优惠券金额必须小于优惠条件金额");
+                    return false;
+                }
+                var couponAmount4 = $("#couponAmount4").val() * 1;
+                var touchPrice4 = $("#touchPrice4").val() * 1;
+                if (couponAmount4 == "") {
+                    alertx("【优惠券4】优惠券金额不能为空");
+                    return false;
                 }
+                if (touchPrice4 == "") {
+                    alertx("【优惠券4】优惠条件不能为空");
+                    return false;
+                }
+                if (couponAmount4 >= touchPrice4) {
+                    alertx("【优惠券4】优惠券金额必须小于优惠条件金额");
+                    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);
+                }
+            }
+        });
+    });
+
+    $(".contentTableShop thead").html('<tr><th>机构名称</th><th>机构简称</th><th>联系人</th><th>手机号</th><th>操作</th></tr>');
+    $(".contentTableProduct thead").html('<tr><th style="width:20px;"><input class="check-all" type="checkbox" onclick="clickAllSelect(this)"/>全选</th>' +
+        '<th>商品图片</th><th>商品名称</th><th>供应商</th><th>网站状态</th><th>小程序状态</th><th>排序</th><th>添加时间</th><th>操作</th></tr>');
+
+    $("body").on("change", ".couponType", function () {
+        var value = $(this).parent().find('input.couponType:checked').val() * 1;
+        $(this).parents(".coupon-wrap").find(".coupon-line").hide();
+        if (0 === value) {
+            $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
+            $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
+            $(this).parents(".coupon-wrap").find(".coupon-line.l4").show();
+        } else if (1 === value) {
+            $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
+            $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
+            $(this).parents(".coupon-wrap").find(".coupon-line.l3").show();
+        } else if (3 === value) {
+            $(this).parents(".coupon-wrap").find(".coupon-line.l0").show();
+            $(this).parents(".coupon-wrap").find(".coupon-line.l1").show();
+            $(this).parents(".coupon-wrap").find(".coupon-line.l2").show();
+        }
+    });
+
+    function cType(id) {
+        $("#couponWrap" + id).find(".productData" + id).hide();
+    }
+
+    // 点击添加供应商
+    function showSelectShop(id) {
+        var url = "${ctx}/coupon/cmCoupon/toAddShop";
+        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);
+                    appendShopOrderHead(items, id);
+                }
+                return true;
+            }
+        });
+    }
+
+    $(function () {
+        //店铺券供应商回显
+        if (${not empty svipcouponForm.shop1}) {
+            var shop = {
+                "shopId": "${svipcouponForm.shop1.shopID}",
+                "name": "${svipcouponForm.shop1.name}",
+                "sname": "${svipcouponForm.shop1.sname}",
+                "linkMan": "${svipcouponForm.shop1.linkMan}",
+                "contractMobile": "${svipcouponForm.shop1.contractMobile}"
+            }
+            appendShopOrderHead(shop, 1);
+        }
+        if (${not empty svipcouponForm.shop2}) {
+            var shop = {
+                "shopId": "${svipcouponForm.shop2.shopID}",
+                "name": "${svipcouponForm.shop2.name}",
+                "sname": "${svipcouponForm.shop2.sname}",
+                "linkMan": "${svipcouponForm.shop2.linkMan}",
+                "contractMobile": "${svipcouponForm.shop2.contractMobile}"
+            }
+            appendShopOrderHead(shop, 2);
+        }
+        if (${not empty svipcouponForm.shop3}) {
+            var shop = {
+                "shopId": "${svipcouponForm.shop3.shopID}",
+                "name": "${svipcouponForm.shop3.name}",
+                "sname": "${svipcouponForm.shop3.sname}",
+                "linkMan": "${svipcouponForm.shop3.linkMan}",
+                "contractMobile": "${svipcouponForm.shop3.contractMobile}"
+            }
+            appendShopOrderHead(shop, 3);
+        }
+        if (${not empty svipcouponForm.shop4}) {
+            var shop = {
+                "shopId": "${svipcouponForm.shop4.shopID}",
+                "name": "${svipcouponForm.shop4.name}",
+                "sname": "${svipcouponForm.shop4.sname}",
+                "linkMan": "${svipcouponForm.shop4.linkMan}",
+                "contractMobile": "${svipcouponForm.shop4.contractMobile}"
+            }
+            appendShopOrderHead(shop, 4);
+        }
+        //产品回显
+        if (${not empty svipcouponForm.associateList1}) {
+            <c:forEach items="${svipcouponForm.associateList1}" var="associate" varStatus="index">
+            imageList1.push({
+                id: "${associate.id}",
+                productId: "${empty associate.productId ? "":associate.productId}",
+                image: "${associate.image}",
+                productName: "${associate.productName}",
+                shopName: "${associate.shopName}",
+                sort: "${associate.sort}",
+                pcStatus: "${associate.pcStatus}",
+                appletsStatus: "${associate.appletsStatus}",
+                addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+            });
+            </c:forEach>
+            if (imageList1.length > 0) {
+                $('#couponWrap1').find('.contentTableProduct').show();
+                batchSaveSort(1);
+                showSelectProduct(1);
+            }
+        }
+        if (${not empty svipcouponForm.associateList2}) {
+            <c:forEach items="${svipcouponForm.associateList2}" var="associate" varStatus="index">
+            imageList2.push({
+                id: "${associate.id}",
+                productId: "${empty associate.productId ? "":associate.productId}",
+                image: "${associate.image}",
+                productName: "${associate.productName}",
+                shopName: "${associate.shopName}",
+                sort: "${associate.sort}",
+                pcStatus: "${associate.pcStatus}",
+                appletsStatus: "${associate.appletsStatus}",
+                addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+            });
+            </c:forEach>
+            if (imageList2.length > 0) {
+                $('#couponWrap2').find('.contentTableProduct').show();
+                batchSaveSort(2);
+                showSelectProduct(2);
+            }
+        }
+        if (${not empty svipcouponForm.associateList3}) {
+            <c:forEach items="${svipcouponForm.associateList3}" var="associate" varStatus="index">
+            imageList3.push({
+                id: "${associate.id}",
+                productId: "${empty associate.productId ? "":associate.productId}",
+                image: "${associate.image}",
+                productName: "${associate.productName}",
+                shopName: "${associate.shopName}",
+                sort: "${associate.sort}",
+                pcStatus: "${associate.pcStatus}",
+                appletsStatus: "${associate.appletsStatus}",
+                addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+            });
+            </c:forEach>
+            if (imageList3.length > 0) {
+                $('#couponWrap3').find('.contentTableProduct').show();
+                batchSaveSort(3);
+                showSelectProduct(3);
+            }
+        }
+        if (${not empty svipcouponForm.associateList4}) {
+            <c:forEach items="${svipcouponForm.associateList4}" var="associate" varStatus="index">
+            imageList4.push({
+                id: "${associate.id}",
+                productId: "${empty associate.productId ? "":associate.productId}",
+                image: "${associate.image}",
+                productName: "${associate.productName}",
+                shopName: "${associate.shopName}",
+                sort: "${associate.sort}",
+                pcStatus: "${associate.pcStatus}",
+                appletsStatus: "${associate.appletsStatus}",
+                addTime: "<fmt:formatDate value="${associate.addTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
+            });
+            </c:forEach>
+            if (imageList4.length > 0) {
+                $('#couponWrap4').find('.contentTableProduct').show();
+                batchSaveSort(4);
+                showSelectProduct(4);
+            }
+        }
+    });
 
-                function changeSort(index, sortThis, id) {
-                    var sort = sortThis.value;
-                    if (sort > 0) {
-                        var image;
+    function productShow(value, id) {
+        if (value == 2) {
+            $(".productData" + id).show();
+        } else {
+            $(".productData" + id).hide();
+        }
+    }
+
+    var productIds1 = '';
+    var productIds2 = '';
+    var productIds3 = '';
+    var productIds4 = '';
+    var imageList1 = [];
+    var imageList2 = [];
+    var imageList3 = [];
+    var imageList4 = [];
+
+    //点击添加
+    function showSelectProduct(id) {
+        var url = "${ctx}/coupon/cmCoupon/toAddProduct?productIds=";
+        if (id * 1 === 1) {
+            url += productIds1;
+        }
+        if (id * 1 === 2) {
+            url += productIds2;
+        }
+        if (id * 1 === 3) {
+            url += productIds3;
+        }
+        if (id * 1 === 4) {
+            url += productIds4;
+        }
+        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]);
                         if (id * 1 === 1) {
-                            image = imageList1[index];
+                            imageList1.push(items[i]);
                         }
                         if (id * 1 === 2) {
-                            image = imageList2[index];
+                            imageList2.push(items[i]);
                         }
                         if (id * 1 === 3) {
-                            image = imageList3[index];
+                            imageList3.push(items[i]);
                         }
                         if (id * 1 === 4) {
-                            image = imageList4[index];
-                        }
-                        if (image) {
-                            image.sort = sort;
+                            imageList4.push(items[i]);
                         }
+                        $("#couponWrap" + id).find(".contentTableProduct").show();
+                        $(".del").removeAttr("disabled");
+                        batchSaveSort(id);
                     }
+                    ;
                 }
+                return true;
+            }
+        });
+    }
 
-                function updatePcStatus(status, index, id) {
-                    var image;
-                    if (id * 1 === 1) {
-                        image = imageList1[index];
-                    }
-                    if (id * 1 === 2) {
-                        image = imageList2[index];
-                    }
-                    if (id * 1 === 3) {
-                        image = imageList3[index];
-                    }
-                    if (id * 1 === 4) {
-                        image = imageList4[index];
-                    }
-                    if (image) {
-                        confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
-                            image.pcStatus = status;
-                            batchSaveSort(id);
-                        });
-                    }
-                }
+    //一键排序
+    function batchSaveSort(id) {
+        if (id * 1 === 1) {
+            imageList1.sort(sort);
+            insertHtmlProduct(imageList1, id);
+        }
+        if (id * 1 === 2) {
+            imageList2.sort(sort);
+            insertHtmlProduct(imageList2, id);
+        }
+        if (id * 1 === 3) {
+            imageList3.sort(sort);
+            insertHtmlProduct(imageList3, id);
+        }
+        if (id * 1 === 4) {
+            imageList4.sort(sort);
+            insertHtmlProduct(imageList4, id);
+        }
 
-                function updateAppletsStatus(status, index, id) {
-                    var image;
-                    if (id * 1 === 1) {
-                        image = imageList1[index];
-                    }
-                    if (id * 1 === 2) {
-                        image = imageList2[index];
-                    }
-                    if (id * 1 === 3) {
-                        image = imageList3[index];
+    }
+
+    //根据sort值 从小到大排序
+    function sort(a, b) {
+        return a.sort - b.sort;
+    }
+
+    //相关图片列表数据
+    function appendProductOrderHead(data, index, id) {
+        var html = '<tr id ="ai' + index + '">' +
+            '<td>' +
+            '<input class="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.pcStatus == 1 ? (
+                '<font color="green">已启用</font>' +
+                '<a href="javascript:void(0);" onclick="updatePcStatus(0,' + index + ',' + id + ');" >' +
+                '停用</a>'
+            ) : (
+                '<font color="red">已停用</font>' +
+                '<a href="javascript:void(0)" onclick="updatePcStatus(1,' + index + ',' + id + ');">' +
+                '启用</a>'
+            )) +
+            '</td>' +
+            '<td>' +
+            (data.appletsStatus == 1 ? (
+                '<font color="green">已启用</font>' +
+                '<a href="javascript:void(0);" onclick="updateAppletsStatus(0,' + index + ',' + id + ');" >' +
+                '停用</a>'
+            ) : (
+                '<font color="red">已停用</font>' +
+                '<a href="javascript:void(0)" onclick="updateAppletsStatus(1,' + index + ',' + id + ');">' +
+                '启用</a>'
+            )) +
+            '</td>' +
+            '<td>' +
+            '<input name="sort" style="width:50px;" value="' + data.sort + '"  onkeyup="onlynum(this)"  onchange="changeSort(' + index + ',this,' + id + ')"></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="delect(' + index + ',' + id + ')">删除</a>' +
+            '</td>' +
+            '</tr>';
+        return html;
+    }
+
+    function insertHtmlProduct(list, id) {
+        var html = '';
+        tempIds = '';
+        if (list && list.length > 0) {
+            list.forEach(function (item, index) {
+                html += appendProductOrderHead(item, index, id);
+                tempIds += "," + item.productId;
+            });
+        }
+        if (id * 1 === 1) {
+            productIds1 = tempIds;
+        }
+        if (id * 1 === 2) {
+            productIds2 = tempIds;
+        }
+        if (id * 1 === 3) {
+            productIds3 = tempIds;
+        }
+        if (id * 1 === 4) {
+            productIds4 = tempIds;
+        }
+        $("#couponWrap" + id).find(".hotSearchProduct").html(html);
+    }
+
+    function changeSort(index, sortThis, id) {
+        var sort = sortThis.value;
+        if (sort > 0) {
+            var image;
+            if (id * 1 === 1) {
+                image = imageList1[index];
+            }
+            if (id * 1 === 2) {
+                image = imageList2[index];
+            }
+            if (id * 1 === 3) {
+                image = imageList3[index];
+            }
+            if (id * 1 === 4) {
+                image = imageList4[index];
+            }
+            if (image) {
+                image.sort = sort;
+            }
+        }
+    }
+
+    function updatePcStatus(status, index, id) {
+        var image;
+        if (id * 1 === 1) {
+            image = imageList1[index];
+        }
+        if (id * 1 === 2) {
+            image = imageList2[index];
+        }
+        if (id * 1 === 3) {
+            image = imageList3[index];
+        }
+        if (id * 1 === 4) {
+            image = imageList4[index];
+        }
+        if (image) {
+            confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+                image.pcStatus = status;
+                batchSaveSort(id);
+            });
+        }
+    }
+
+    function updateAppletsStatus(status, index, id) {
+        var image;
+        if (id * 1 === 1) {
+            image = imageList1[index];
+        }
+        if (id * 1 === 2) {
+            image = imageList2[index];
+        }
+        if (id * 1 === 3) {
+            image = imageList3[index];
+        }
+        if (id * 1 === 4) {
+            image = imageList4[index];
+        }
+        if (image) {
+            confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
+                image.appletsStatus = status;
+                batchSaveSort(id);
+            });
+        }
+    }
+
+    /**
+     * 批量删除
+     */
+    function batchDeletion(id) {
+        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, tempList;
+                if (id * 1 === 1) {
+                    image = imageList1[index];
+                    if (image.productId != '') {
+                        productIds1 = productIds1.replace(image.productId, "");
+                    }
+                    imageList1.splice(thisIndex, 1);
+                    tempList = imageList1;
+                }
+                if (id * 1 === 2) {
+                    image = imageList2[index];
+                    if (image.productId != '') {
+                        productIds2 = productIds2.replace(image.productId, "");
                     }
-                    if (id * 1 === 4) {
-                        image = imageList4[index];
+                    imageList2.splice(thisIndex, 1);
+                    tempList = imageList2;
+                }
+                if (id * 1 === 3) {
+                    image = imageList3[index];
+                    if (image.productId != '') {
+                        productIds3 = productIds3.replace(image.productId, "");
                     }
-                    if (image) {
-                        confirmx(status == 0 ? '确定停用吗?' : '确定启用吗?', function () {
-                            image.appletsStatus = status;
-                            batchSaveSort(id);
-                        });
+                    imageList3.splice(thisIndex, 1);
+                    tempList = imageList3;
+                }
+                if (id * 1 === 4) {
+                    image = imageList4[index];
+                    if (image.productId != '') {
+                        productIds4 = productIds4.replace(image.productId, "");
                     }
+                    imageList4.splice(thisIndex, 1);
+                    tempList = imageList4;
                 }
-
-                /**
-                 * 批量删除
-                 */
-                function batchDeletion(id) {
-                    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, tempList;
-                            if (id * 1 === 1) {
-                                image = imageList1[index];
-                                if (image.productId != '') {
-                                    productIds1 = productIds1.replace(image.productId, "");
-                                }
-                                imageList1.splice(thisIndex, 1);
-                                tempList = imageList1;
-                            }
-                            if (id * 1 === 2) {
-                                image = imageList2[index];
-                                if (image.productId != '') {
-                                    productIds2 = productIds2.replace(image.productId, "");
-                                }
-                                imageList2.splice(thisIndex, 1);
-                                tempList = imageList2;
-                            }
-                            if (id * 1 === 3) {
-                                image = imageList3[index];
-                                if (image.productId != '') {
-                                    productIds3 = productIds3.replace(image.productId, "");
-                                }
-                                imageList3.splice(thisIndex, 1);
-                                tempList = imageList3;
-                            }
-                            if (id * 1 === 4) {
-                                image = imageList4[index];
-                                if (image.productId != '') {
-                                    productIds4 = productIds4.replace(image.productId, "");
-                                }
-                                imageList4.splice(thisIndex, 1);
-                                tempList = imageList4;
-                            }
-                            insertHtmlProduct(tempList, id);
-                            if (tempList.length == 0) {
-                                $("#couponWrap" + id).find('.contentTableProduct').hide();
-                                $(".del").attr("disabled", "disabled");
-                            }
-                        });
-                    });
+                insertHtmlProduct(tempList, id);
+                if (tempList.length == 0) {
+                    $("#couponWrap" + id).find('.contentTableProduct').hide();
+                    $(".del").attr("disabled", "disabled");
                 }
-
-                function appendShopOrderHead(data, id) {
-                    var html = '<tr>' +
-                        '<td>' +
-                        data.name +
-                        '</td>' +
-                        '<td>' +
-                        data.sname +
-                        '</td>' +
-                        '<td>' +
-                        data.linkMan +
-                        '</td>' +
-                        '<td>' +
-                        data.contractMobile +
-                        '</td>' +
-                        '<td>' +
-                        '<a href="javascript:;" onclick="delectShop(' + id + ')">删除</a>' +
-                        '</td>' +
-                        '</tr>';
-                    $("#couponWrap" + id).find(".hotSearchShop").html(html);
-                    $("#chooseShop" + id).hide();
-                    $("#couponWrap" + id).find(".contentTableShop").show();
-                    $("#shopId" + id).val(data.shopId);
+            });
+        });
+    }
+
+    function appendShopOrderHead(data, id) {
+        var html = '<tr>' +
+            '<td>' +
+            data.name +
+            '</td>' +
+            '<td>' +
+            data.sname +
+            '</td>' +
+            '<td>' +
+            data.linkMan +
+            '</td>' +
+            '<td>' +
+            data.contractMobile +
+            '</td>' +
+            '<td>' +
+            '<a href="javascript:;" onclick="delectShop(' + id + ')">删除</a>' +
+            '</td>' +
+            '</tr>';
+        $("#couponWrap" + id).find(".hotSearchShop").html(html);
+        $("#chooseShop" + id).hide();
+        $("#couponWrap" + id).find(".contentTableShop").show();
+        $("#shopId" + id).val(data.shopId);
+    }
+
+    function delectShop(id) {
+        return confirmx("确定删除吗?", function () {
+            $("#chooseShop" + id).show();
+            $("#couponWrap" + id).find(".contentTableShop").hide();
+            $("#shopId" + id).val("");
+        });
+    }
+
+    /**
+     * 删除操作
+     */
+    function delect(index, id) {
+        return confirmx("确定删除吗?", function () {
+            var image;
+            if (id * 1 === 1) {
+                image = imageList1[index];
+                if (image.productId != '') {
+                    productIds1 = productIds1.replace(image.productId, "");
                 }
-
-                function delectShop(id) {
-                    return confirmx("确定删除吗?", function () {
-                        $("#chooseShop" + id).show();
-                        $("#couponWrap" + id).find(".contentTableShop").hide();
-                        $("#shopId" + id).val("");
-                    });
+                imageList1.splice(index, 1);
+                insertHtmlProduct(imageList1, id);
+                if (imageList1.length == 0) {
+                    $("#couponWrap" + id).find('#contentTableProduct').hide();
+                    $(".del").attr("disabled", "disabled");
                 }
-
-                /**
-                 * 删除操作
-                 */
-                function delect(index, id) {
-                    return confirmx("确定删除吗?", function () {
-                        var image;
-                        if (id * 1 === 1) {
-                            image = imageList1[index];
-                            if (image.productId != '') {
-                                productIds1 = productIds1.replace(image.productId, "");
-                            }
-                            imageList1.splice(index, 1);
-                            insertHtmlProduct(imageList1, id);
-                            if (imageList1.length == 0) {
-                                $("#couponWrap" + id).find('#contentTableProduct').hide();
-                                $(".del").attr("disabled", "disabled");
-                            }
-                        }
-                        if (id * 1 === 2) {
-                            image = imageList2[index];
-                            if (image.productId != '') {
-                                productIds2 = productIds2.replace(image.productId, "");
-                            }
-                            imageList2.splice(index, 1);
-                            insertHtmlProduct(imageList2, id);
-                            if (imageList2.length == 0) {
-                                $("#couponWrap" + id).find('#contentTableProduct').hide();
-                                $(".del").attr("disabled", "disabled");
-                            }
-                        }
-                        if (id * 1 === 3) {
-                            image = imageList3[index];
-                            if (image.productId != '') {
-                                productIds3 = productIds3.replace(image.productId, "");
-                            }
-                            imageList3.splice(index, 1);
-                            insertHtmlProduct(imageList3, id);
-                            if (imageList3.length == 0) {
-                                $("#couponWrap" + id).find('#contentTableProduct').hide();
-                                $(".del").attr("disabled", "disabled");
-                            }
-                        }
-                        if (id * 1 === 4) {
-                            image = imageList4[index];
-                            if (image.productId != '') {
-                                productIds4 = productIds4.replace(image.productId, "");
-                            }
-                            imageList4.splice(index, 1);
-                            insertHtmlProduct(imageList4, id);
-                            if (imageList4.length == 0) {
-                                $("#couponWrap" + id).find('#contentTableProduct').hide();
-                                $(".del").attr("disabled", "disabled");
-                            }
-                        }
-                    });
+            }
+            if (id * 1 === 2) {
+                image = imageList2[index];
+                if (image.productId != '') {
+                    productIds2 = productIds2.replace(image.productId, "");
                 }
-
-
-                function clickAllSelect(ckb) {
-                    var isChecked = ckb.checked;
-                    $(".check-item").attr('checked', isChecked);
+                imageList2.splice(index, 1);
+                insertHtmlProduct(imageList2, id);
+                if (imageList2.length == 0) {
+                    $("#couponWrap" + id).find('#contentTableProduct').hide();
+                    $(".del").attr("disabled", "disabled");
                 }
-
-                /**
-                 * @param obj
-                 * jquery控制input只能输入数字
-                 */
-                function onlynum(obj) {
-                    obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+            }
+            if (id * 1 === 3) {
+                image = imageList3[index];
+                if (image.productId != '') {
+                    productIds3 = productIds3.replace(image.productId, "");
                 }
-
-                $(document).ready(function () {
-                    //$("#name").focus();
-                    $("#inputForm").validate({
-                        submitHandler: function (form) {
-
-                            loading('正在提交,请稍等...');
-                            form.submit();
-                        },
-                        errorContainer: "#messageBox",
-                        errorPlacement: function (error, element) {
-                            $("#messageBox").text("输入有误,请先更正。");
-                            if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
-                                error.appendTo(element.parent().parent());
-                            } else {
-                                error.insertAfter(element);
-                            }
-                        }
-                    });
-                });
+                imageList3.splice(index, 1);
+                insertHtmlProduct(imageList3, id);
+                if (imageList3.length == 0) {
+                    $("#couponWrap" + id).find('#contentTableProduct').hide();
+                    $(".del").attr("disabled", "disabled");
+                }
+            }
+            if (id * 1 === 4) {
+                image = imageList4[index];
+                if (image.productId != '') {
+                    productIds4 = productIds4.replace(image.productId, "");
+                }
+                imageList4.splice(index, 1);
+                insertHtmlProduct(imageList4, id);
+                if (imageList4.length == 0) {
+                    $("#couponWrap" + id).find('#contentTableProduct').hide();
+                    $(".del").attr("disabled", "disabled");
+                }
+            }
+        });
+    }
+
+
+    function clickAllSelect(ckb) {
+        var isChecked = ckb.checked;
+        $(".check-item").attr('checked', isChecked);
+    }
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+
+    $(document).ready(function () {
+        //$("#name").focus();
+        $("#inputForm").validate({
+            submitHandler: function (form) {
+
+                loading('正在提交,请稍等...');
+                form.submit();
+            },
+            errorContainer: "#messageBox",
+            errorPlacement: function (error, element) {
+                $("#messageBox").text("输入有误,请先更正。");
+                if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
+                    error.appendTo(element.parent().parent());
+                } else {
+                    error.insertAfter(element);
+                }
+            }
+        });
+    });
 
 
-            </script>
+</script>
 </body>
 </html>

+ 70 - 103
src/main/webapp/WEB-INF/views/modules/svip/cmSvipCouponList.jsp

@@ -5,49 +5,61 @@
     <title>超级会员优惠券管理列表</title>
     <meta name="decorator" content="default"/>
     <style type="text/css">
-        .table th {
-            text-align: center;
-        }
-
-        .table td {
-            text-align: center;
-        }
+        .table th{text-align:center}
+        .table td{text-align:center}
+        .table td p{margin:0; text-align: left;}
+        #searchForm{line-height:40px}
+        #searchForm .ul-form{overflow:visible}
+        #searchForm{white-space:nowrap}
+        #searchForm label{margin-top:15px}
+        .ul-form{white-space:nowrap;margin-left:-10px !important}
+        .ul-form label{width:90px;text-align:right}
+        #searchForm .btn{width:128px;margin-left:20px}
+        .select-ele{width:177px}
     </style>
 </head>
 <body>
 <ul class="nav nav-tabs">
     <li class="active"><a href="${ctx}/vip/cmCoupon/">超级会员专属优惠券</a></li>
 </ul>
-<form:form id="searchForm" modelAttribute="svipCouponList" action="${ctx}/vip/cmCoupon/" method="post"
-           class="breadcrumb form-search">
-    <input type="hidden" name="couponType" value="4"/>
+<form:form id="searchForm" modelAttribute="cmVipCoupon" action="${ctx}/vip/cmCoupon" 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">
+        <div class="flex-wrap">
+            <div class="item">
+                <label class="control-label">优惠月份:</label>
+                <form:input path="startDate" type="text" maxlength="10" class="input-medium Wdate" value="${startDate}"
+                            onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
+                至
+                <form:input path="endDate" type="text" maxlength="10" class="input-medium Wdate" value="${endDate}"
+                            onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
+            </div>
+            <div class="item">
+                <label>优惠券类型:</label>
+                <form:select path="couponType" class="input-medium">
+                    <form:option value="99" label="全部"/>
+                    <form:option value="0" label="活动券"/>
+                    <form:option value="1" label="品类券"/>
+                    <form:option value="3" label="店铺券"/>
+                </form:select>
+            </div>
 
-            <%--        <label>优惠券类型:</label>--%>
-            <%--        <form:select path="couponType" class="input-medium">--%>
-            <%--            <form:option value="" label="全部"/>--%>
-            <%--            <form:option value="0" label="活动券"/>--%>
-            <%--            <form:option value="1" label="品类券"/>--%>
-            <%--            <form:option value="3" label="店铺券"/>--%>
-            <%--        </form:select>--%>
-        <label>优惠状态:</label>
-        <form:select path="status" class="input-medium required">
-            <form:option value="99" label="所有"/>
-            <form:option value="0" label="未生效"/>
-            <form:option value="1" label="已生效"/>
-            <form:option value="2" label="已关闭"/>
-            <form:option value="3" label="已失效"/>
-        </form:select>
-        <label>优惠月份:</label>
-        <form:input path="useTime" type="text" maxlength="20" class="input-medium Wdate"
-                    value="${svipCouponList.useTime}"
-                    onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
-        <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询"/>
-        <input class="btn btn-primary" style="width: 80px" onclick="window.location='${ctx}/vip/cmCoupon/forms'"
-               value="添加优惠券"/>
-        <div class="clearfix"></div>
+            <div class="item">
+                <label>优惠状态:</label>
+                <form:select path="status" class="input-medium required">
+                    <form:option value="99" label="所有"/>
+                    <form:option value="0" label="未生效"/>
+                    <form:option value="1" label="已生效"/>
+                    <form:option value="2" label="已关闭"/>
+                    <form:option value="3" label="已失效"/>
+                </form:select>
+            </div>
+            <div class="item">
+                <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" />
+                <input class="btn btn-primary" onclick="window.location='${ctx}/vip/cmCoupon/form'" value="添加优惠券"/>
+            </div>
+        </div>
     </div>
 </form:form>
 <sys:message content="${message}"/>
@@ -61,92 +73,51 @@
     </tr>
     </thead>
     <tbody>
-    <c:forEach items="${page.list}" var="cmCoupon">
-
+    <c:forEach items="${page.list}" var="vip">
         <tr>
-            
-            <td><label>${cmCoupon.svipCoupons.month}</label></td>
+            <td><label>${vip.useTime}</label></td>
             <td>
-
-                优惠券1:
-                <c:if test="${cmCoupon.svipCoupons.couponType1 eq 0}">活动券¥${cmCoupon.svipCoupons.couponAmount1},满${cmCoupon.svipCoupons.touchPrice1}可用,
-                    <c:if test="${cmCoupon.svipCoupons.productType1 eq '1'}"> 全商城商品通用</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.productType1 eq '2'}"> 仅可购买指定商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType1 eq 1}">品类券¥${cmCoupon.svipCoupons.couponAmount1},满${cmCoupon.svipCoupons.touchPrice1}可用,
-                    <c:if test="${cmCoupon.svipCoupons.categoryType1 eq '2'}">仅可购买仪器类商品</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.categoryType1 eq '1'}">仅可购买产品类商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType1 eq 3}">店铺券¥${cmCoupon.svipCoupons.couponAmount1},满${cmCoupon.svipCoupons.touchPrice1}可用,仅可购买店铺
-                    ${cmCoupon.svipCoupons.shopName1} 的商品
-                </c:if>
-                <br/>
-                优惠券2:
-                <c:if test="${cmCoupon.svipCoupons.couponType2 eq 0}">活动券¥${cmCoupon.svipCoupons.couponAmount2},满${cmCoupon.svipCoupons.touchPrice2}可用,
-                    <c:if test="${cmCoupon.svipCoupons.productType2 eq '1'}"> 全商城商品通用</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.productType2 eq '2'}"> 仅可购买指定商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType2 eq 1}">品类券¥${cmCoupon.svipCoupons.couponAmount2},满${cmCoupon.svipCoupons.touchPrice2}可用,
-                    <c:if test="${cmCoupon.svipCoupons.categoryType2 eq '2'}">仅可购买仪器类商品</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.categoryType2 eq '1'}">仅可购买产品类商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType2 eq 3}">店铺券¥${cmCoupon.svipCoupons.couponAmount2},满${cmCoupon.svipCoupons.touchPrice2}可用,仅可购买店铺
-                    ${cmCoupon.svipCoupons.shopName2} 的商品
-                </c:if>
-                <br/>
-                优惠券3:
-                <c:if test="${cmCoupon.svipCoupons.couponType3 eq 0}">活动券¥${cmCoupon.svipCoupons.couponAmount3},满${cmCoupon.svipCoupons.touchPrice3}可用,
-                    <c:if test="${cmCoupon.svipCoupons.productType3 eq '1'}"> 全商城商品通用</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.productType3 eq '2'}"> 仅可购买指定商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType3 eq 1}">品类券¥${cmCoupon.svipCoupons.couponAmount3},满${cmCoupon.svipCoupons.touchPrice3}可用,
-                    <c:if test="${cmCoupon.svipCoupons.categoryType3 eq '2'}">仅可购买仪器类商品</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.categoryType3 eq '1'}">仅可购买产品类商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType3 eq 3}">店铺券¥${cmCoupon.svipCoupons.couponAmount3},满${cmCoupon.svipCoupons.touchPrice3}可用,仅可购买店铺
-                    ${cmCoupon.svipCoupons.shopName3} 的商品
-                </c:if>
-                <br/>
-                优惠券4:
-                <c:if test="${cmCoupon.svipCoupons.couponType4 eq 0}">活动券¥${cmCoupon.svipCoupons.couponAmount4},满${cmCoupon.svipCoupons.touchPrice4}可用,
-                    <c:if test="${cmCoupon.svipCoupons.productType4 eq '1'}"> 全商城商品通用</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.productType4 eq '2'}"> 仅可购买指定商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType4 eq 1}">品类券¥${cmCoupon.svipCoupons.couponAmount4},满${cmCoupon.svipCoupons.touchPrice4}可用,
-                    <c:if test="${cmCoupon.svipCoupons.categoryType4 eq '2'}">仅可购买仪器类商品</c:if>
-                    <c:if test="${cmCoupon.svipCoupons.categoryType4 eq '1'}">仅可购买产品类商品</c:if>
-                </c:if>
-                <c:if test="${cmCoupon.svipCoupons.couponType4 eq 3}">店铺券¥${cmCoupon.svipCoupons.couponAmount4},满${cmCoupon.svipCoupons.touchPrice4}可用,仅可购买店铺
-                    ${cmCoupon.svipCoupons.shopName4} 的商品
-                </c:if>
+                <c:forEach items="${vip.couponList}" var="cmCoupon" varStatus="index">
+                <p>优惠券${index.index+1}:
+                    <b>
+                    <c:if test="${cmCoupon.couponType eq '0'}">活动券</c:if>
+                    <c:if test="${cmCoupon.couponType eq '1'}">品类券</c:if>
+                    <c:if test="${cmCoupon.couponType eq '3'}">店铺券</c:if>
+                    </b>
+                    ¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用
+                    <c:if test="${cmCoupon.productType eq '1'}">,全商城商品通用</c:if>
+                    <c:if test="${cmCoupon.productType eq '2'}">,仅可购买指定商品</c:if>
+                    <c:if test="${cmCoupon.categoryType eq '1'}">,仅可购买产品类商品</c:if>
+                    <c:if test="${cmCoupon.categoryType eq '2'}">,仅可购买仪器类商品</c:if>
+                    <c:if test="${cmCoupon.couponType eq '3'}">,仅可购买店铺“${cmCoupon.shopName}”的商品</c:if>
+                </p>
+                </c:forEach>
             </td>
-
             <td>
-                <c:if test="${cmCoupon.svipCoupons.status eq '0'}">
+                <c:if test="${cmCoupon.status eq '0'}">
                     <font color="#800080">未生效</font>
                 </c:if>
-                <c:if test="${cmCoupon.svipCoupons.status eq '1'}">
+                <c:if test="${cmCoupon.status eq '1'}">
                     <font color="#00CC66">已生效</font>
                 </c:if>
-                <c:if test="${cmCoupon.svipCoupons.status eq '2'}">
+                <c:if test="${cmCoupon.status eq '2'}">
                     <font color="red">已关闭</font>
                 </c:if>
-                <c:if test="${cmCoupon.svipCoupons.status eq '3'}">
+                <c:if test="${cmCoupon.status eq '3'}">
                     <font color="#FF6600">已失效</font>
                 </c:if>
             </td>
-
             <td>
-                <a href="${ctx}/vip/cmCoupon/form?couponId1=${cmCoupon.svipCoupons.couponId1}">编辑</a>
+                <a href="${ctx}/vip/cmCoupon/form?id=${vip.id}">编辑</a>
                 <c:if test="${cmCoupon.svipCoupons.status ne '2'}">
-                    <a href="${ctx}/vip/cmCoupon/close?couponId1=${cmCoupon.svipCoupons.couponId1}"
+                    <a href="${ctx}/vip/cmCoupon/close?id=${vip.id}"
                        onclick="return confirmx('确定关闭该该月份的优惠券吗?关闭后该月份将不赠送优惠券?', this.href)">关闭</a>
                 </c:if>
                 <c:if test="${cmCoupon.svipCoupons.status eq '2'}">
-                    <a href="${ctx}/vip/cmCoupon/open?couponId1=${cmCoupon.svipCoupons.couponId1}"
+                    <a href="${ctx}/vip/cmCoupon/open?id=${vip.id}"
                        onclick="return confirmx('确定重新开启该月份的优惠券吗?', this.href)">开启</a>
                 </c:if>
-                <a href="${ctx}/vip/cmCoupon/delete?couponId1=${cmCoupon.svipCoupons.couponId1}"
+                <a href="${ctx}/vip/cmCoupon/delete?id=${vip.id}"
                    onclick="return confirmx('确定删除该月份的优惠券吗?删除后该月份将不赠送优惠券', this.href)">删除</a>
             </td>
         </tr>
@@ -155,10 +126,6 @@
 </table>
 <div class="pagination">${page}</div>
 <script type="text/javascript">
-    $(document).ready(function () {
-
-    });
-
     function page(n, s) {
         $("#pageNo").val(n);
         $("#pageSize").val(s);