Ver código fonte

超级会员专属优惠

chao 3 anos atrás
pai
commit
78a548f1f3

+ 298 - 0
src/main/java/com/caimei/modules/coupon/entity/SvipCouponForm.java

@@ -0,0 +1,298 @@
+package com.caimei.modules.coupon.entity;
+
+import java.util.Date;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/9/29
+ */
+public class SvipCouponForm {
+    /**
+     * 月份
+     */
+    private String month;
+    /**
+     * 优惠券Id
+     */
+    private Integer couponId1;
+    private Integer couponId2;
+    private Integer couponId3;
+    private Integer couponId4;
+    /**
+     * 劵类型 0活动券 1品类券 3店铺券
+     */
+    private Integer couponType1;
+    private Integer couponType2;
+    private Integer couponType3;
+    private Integer couponType4;
+    /**
+     * 优惠券金额(面值)
+     */
+    private Double couponAmount1;
+    private Double couponAmount2;
+    private Double couponAmount3;
+    private Double couponAmount4;
+    /**
+     * 优惠满减条件金额
+     */
+    private Double touchPrice1;
+    private Double touchPrice2;
+    private Double touchPrice3;
+    private Double touchPrice4;
+    /**
+     * 优惠商品:1全商城商品 2指定商品(活动券有效)
+     */
+    private String productType1;
+    private Double productType2;
+    private Double productType3;
+    private Double productType4;
+    /**
+     * 优惠品类:1产品 2仪器(品类券有效)
+     */
+    private String categoryType1;
+    private String categoryType2;
+    private String categoryType3;
+    private String categoryType4;
+    /**
+     * 供应商id(店铺券有效)
+     */
+    private Integer shopId1;
+    private Integer shopId2;
+    private Integer shopId3;
+    private Integer shopId4;
+
+
+    public Integer getCouponId1() {
+        return couponId1;
+    }
+
+    public void setCouponId1(Integer couponId1) {
+        this.couponId1 = couponId1;
+    }
+
+    public Integer getCouponId2() {
+        return couponId2;
+    }
+
+    public void setCouponId2(Integer couponId2) {
+        this.couponId2 = couponId2;
+    }
+
+    public Integer getCouponId3() {
+        return couponId3;
+    }
+
+    public void setCouponId3(Integer couponId3) {
+        this.couponId3 = couponId3;
+    }
+
+    public Integer getCouponId4() {
+        return couponId4;
+    }
+
+    public void setCouponId4(Integer couponId4) {
+        this.couponId4 = couponId4;
+    }
+
+    public String getMonth() {
+        return month;
+    }
+
+    public void setMonth(String month) {
+        this.month = month;
+    }
+
+    public Integer getCouponType1() {
+        return couponType1;
+    }
+
+    public void setCouponType1(Integer couponType1) {
+        this.couponType1 = couponType1;
+    }
+
+    public Integer getCouponType2() {
+        return couponType2;
+    }
+
+    public void setCouponType2(Integer couponType2) {
+        this.couponType2 = couponType2;
+    }
+
+    public Integer getCouponType3() {
+        return couponType3;
+    }
+
+    public void setCouponType3(Integer couponType3) {
+        this.couponType3 = couponType3;
+    }
+
+    public Integer getCouponType4() {
+        return couponType4;
+    }
+
+    public void setCouponType4(Integer couponType4) {
+        this.couponType4 = couponType4;
+    }
+
+    public Double getCouponAmount1() {
+        return couponAmount1;
+    }
+
+    public void setCouponAmount1(Double couponAmount1) {
+        this.couponAmount1 = couponAmount1;
+    }
+
+    public Double getCouponAmount2() {
+        return couponAmount2;
+    }
+
+    public void setCouponAmount2(Double couponAmount2) {
+        this.couponAmount2 = couponAmount2;
+    }
+
+    public Double getCouponAmount3() {
+        return couponAmount3;
+    }
+
+    public void setCouponAmount3(Double couponAmount3) {
+        this.couponAmount3 = couponAmount3;
+    }
+
+    public Double getCouponAmount4() {
+        return couponAmount4;
+    }
+
+    public void setCouponAmount4(Double couponAmount4) {
+        this.couponAmount4 = couponAmount4;
+    }
+
+    public Double getTouchPrice1() {
+        return touchPrice1;
+    }
+
+    public void setTouchPrice1(Double touchPrice1) {
+        this.touchPrice1 = touchPrice1;
+    }
+
+    public Double getTouchPrice2() {
+        return touchPrice2;
+    }
+
+    public void setTouchPrice2(Double touchPrice2) {
+        this.touchPrice2 = touchPrice2;
+    }
+
+    public Double getTouchPrice3() {
+        return touchPrice3;
+    }
+
+    public void setTouchPrice3(Double touchPrice3) {
+        this.touchPrice3 = touchPrice3;
+    }
+
+    public Double getTouchPrice4() {
+        return touchPrice4;
+    }
+
+    public void setTouchPrice4(Double touchPrice4) {
+        this.touchPrice4 = touchPrice4;
+    }
+
+    public String getProductType1() {
+        return productType1;
+    }
+
+    public void setProductType1(String productType1) {
+        this.productType1 = productType1;
+    }
+
+    public Double getProductType2() {
+        return productType2;
+    }
+
+    public void setProductType2(Double productType2) {
+        this.productType2 = productType2;
+    }
+
+    public Double getProductType3() {
+        return productType3;
+    }
+
+    public void setProductType3(Double productType3) {
+        this.productType3 = productType3;
+    }
+
+    public Double getProductType4() {
+        return productType4;
+    }
+
+    public void setProductType4(Double productType4) {
+        this.productType4 = productType4;
+    }
+
+    public String getCategoryType1() {
+        return categoryType1;
+    }
+
+    public void setCategoryType1(String categoryType1) {
+        this.categoryType1 = categoryType1;
+    }
+
+    public String getCategoryType2() {
+        return categoryType2;
+    }
+
+    public void setCategoryType2(String categoryType2) {
+        this.categoryType2 = categoryType2;
+    }
+
+    public String getCategoryType3() {
+        return categoryType3;
+    }
+
+    public void setCategoryType3(String categoryType3) {
+        this.categoryType3 = categoryType3;
+    }
+
+    public String getCategoryType4() {
+        return categoryType4;
+    }
+
+    public void setCategoryType4(String categoryType4) {
+        this.categoryType4 = categoryType4;
+    }
+
+    public Integer getShopId1() {
+        return shopId1;
+    }
+
+    public void setShopId1(Integer shopId1) {
+        this.shopId1 = shopId1;
+    }
+
+    public Integer getShopId2() {
+        return shopId2;
+    }
+
+    public void setShopId2(Integer shopId2) {
+        this.shopId2 = shopId2;
+    }
+
+    public Integer getShopId3() {
+        return shopId3;
+    }
+
+    public void setShopId3(Integer shopId3) {
+        this.shopId3 = shopId3;
+    }
+
+    public Integer getShopId4() {
+        return shopId4;
+    }
+
+    public void setShopId4(Integer shopId4) {
+        this.shopId4 = shopId4;
+    }
+}

+ 35 - 6
src/main/java/com/caimei/modules/coupon/web/CmVipCouponController.java

@@ -2,12 +2,14 @@ package com.caimei.modules.coupon.web;
 
 import com.caimei.modules.coupon.entity.CmCoupon;
 import com.caimei.modules.coupon.entity.CmCouponAssociate;
+import com.caimei.modules.coupon.entity.SvipCouponForm;
 import com.caimei.modules.coupon.service.CmCouponService;
 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.user.entity.CmUser;
 import com.caimei.modules.user.entity.NewCmClub;
+import com.thinkgem.jeesite.common.config.Global;
 import com.thinkgem.jeesite.common.persistence.Page;
 import com.thinkgem.jeesite.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,6 +18,7 @@ import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.servlet.mvc.support.RedirectAttributes;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -57,18 +60,44 @@ public class CmVipCouponController {
         cmCoupon.setCouponsMode("0");
         Page<CmCoupon> page = cmCouponService.findVipPage(new Page<CmCoupon>(request, response), cmCoupon);
         model.addAttribute("page", page);
-        return "modules/svip/cmSvipCouponForm";
+        return "modules/svip/cmSvipCouponList";
     }
 
     @RequestMapping(value = "form")
-    public String form(CmCoupon cmCoupon, Model model) {
-        model.addAttribute("cmCoupon", cmCoupon);
+    public String form(SvipCouponForm svipcouponForm, Model model) {
+
+
+        // 根据4个CmCoupon的Id查询CmCoupon列表,封装成解析SvipCouponForm
+
+
+        model.addAttribute("svipcouponForm", svipcouponForm);
         return "modules/svip/cmSvipCouponForm";
     }
 
-    @RequestMapping(value = "add")
-    public String add(CmCoupon cmCoupon, Model model){
+    /**
+     * 保存
+     * @param svipcouponForm
+     */
+    @RequestMapping(value = "save")
+    public String save(SvipCouponForm svipcouponForm, Model model, RedirectAttributes redirectAttributes) {
+
 
-        return  "modules/svip/cmSvipCouponList";
+        // 解析SvipCouponForm -> 组装 CmCoupon 列表 保存
+
+
+
+        addMessage(redirectAttributes, "保存超级会员专属优惠券成功");
+        return "redirect:"+ Global.getAdminPath()+"/vip/cmCoupon/?repage";
+    }
+
+    /**
+     * 添加Flash消息
+     */
+    protected void addMessage(RedirectAttributes redirectAttributes, String... messages) {
+        StringBuilder sb = new StringBuilder();
+        for (String message : messages){
+            sb.append(message).append(messages.length>1?"<br/>":"");
+        }
+        redirectAttributes.addFlashAttribute("message", sb.toString());
     }
 }

+ 259 - 107
src/main/webapp/WEB-INF/views/modules/svip/cmSvipCouponForm.jsp

@@ -1,124 +1,276 @@
+<%@ page import="java.util.Date" %>
 <%@ page contentType="text/html;charset=UTF-8" %>
 <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
 <html>
 <head>
-    <title>超级会员优惠券管理列表</title>
+    <title>优惠券管理</title>
     <meta name="decorator" content="default"/>
-    <style type="text/css">
-        .table th {
-            text-align: center;
+    <style>
+        .coupon-wrap {
+            border: 1px solid #aaa;
+            padding: 20px 20px 0;
+            margin-bottom: 20px;
         }
-
-        .table td {
-            text-align: center;
+        .couponType {
+            margin-right:15px;
         }
     </style>
-    <script type="text/javascript">
-        $(document).ready(function () {
-
-        });
-
-        function page(n, s) {
-            $("#pageNo").val(n);
-            $("#pageSize").val(s);
-            $("#searchForm").submit();
-            return false;
-        }
-    </script>
 </head>
 <body>
 <ul class="nav nav-tabs">
     <li class="active"><a href="${ctx}/vip/cmCoupon/">超级会员专属优惠券</a></li>
+    <li class="active"><a href="${ctx}/vip/cmCoupon/form">${not empty cmCoupon.id?'编辑':'添加'}</a>
+    </li>
 </ul>
-<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/vip/cmCoupon/" method="post"
-           class="breadcrumb form-search">
-    <input type="hidden" name="couponType" value="4"/>
-    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
-    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
-    <div class="ul-form">
-
-        <label>优惠券类型:</label>
-        <form: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="" 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>
-        <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
-               value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM"/>"
-               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/add'"
-               value="添加优惠券"/>
-        <div class="clearfix"></div>
+<br/>
+<%--<font style="color: red;margin-left: 20px">品类券只适合在某种品类需要优惠时创建,适用于该品类商品和全部客户。</font><br><br>--%>
+<form:form id="inputForm" modelAttribute="svipcouponForm" action="${ctx}/vip/cmCoupon/save" method="post" class="form-horizontal">
+    <%--    <form:hidden path="id"/>--%>
+    <%--    <form:hidden path="productInfo" id="productInfo"/>--%>
+    <%--    <input type="hidden" name="couponType" value="1"/>--%>
+    <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="${startDate}"
+                        onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});"/>
+        </div>
+    </div>
+    <div class="coupon-wrap">
+        <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="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"></form:radiobutton>
+                <form:radiobutton path="couponType1" class="couponType" label="店铺券" value="3"></form:radiobutton>
+            </div>
+        </div>
+        <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:;">请选择供应商</a>
+                <form:hidden path="shopId1"/>
+            </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"/>
+            </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>
+        </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>
+        </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="全商城商品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="productType1" value="2" label="指定商品"/>
+            </div>
+        </div>
+    </div>
+    <div class="coupon-wrap">
+        <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"></form:radiobutton>
+                <form:radiobutton path="couponType2" class="couponType" label="店铺券" value="3"></form:radiobutton>
+            </div>
+        </div>
+        <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:;">请选择供应商</a>
+                <form:hidden path="shopId2"/>
+            </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>
+        </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>
+        </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>
+        </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="全商城商品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="productType2" value="2" label="指定商品"/>
+            </div>
+        </div>
+    </div>
+    <div class="coupon-wrap">
+        <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"></form:radiobutton>
+                <form:radiobutton path="couponType3" class="couponType" label="店铺券" value="3"></form:radiobutton>
+            </div>
+        </div>
+        <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:;">请选择供应商</a>
+                <form:hidden path="shopId3"/>
+            </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>
+        </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>
+        </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>
+        </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="全商城商品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="productType3" value="2" label="指定商品"/>
+            </div>
+        </div>
+    </div>
+    <div class="coupon-wrap">
+        <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"></form:radiobutton>
+                <form:radiobutton path="couponType4" class="couponType" label="店铺券" value="3"></form:radiobutton>
+            </div>
+        </div>
+        <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:;">请选择供应商</a>
+                <form:hidden path="shopId4"/>
+            </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="couponAmount4" htmlEscape="false" maxlength="20" class="input-xlarge required"/>
+            </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="touchPrice4" htmlEscape="false" maxlength="20" class="input-medium required"/>
+            </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="categoryType4" value="1" label="产品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="categoryType4" value="2" label="仪器"/>
+            </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="productType4" value="1" label="全商城商品" checked="${empty cmCoupon.categoryType ? true:false}"/>
+                <form:radiobutton path="productType4" value="2" label="指定商品"/>
+            </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>
 </form:form>
-<sys:message content="${message}"/>
-<table id="contentTable" class="table table-striped table-bordered table-condensed">
-    <thead>
-    <tr>
-        <th>优惠月份</th>
-        <th>优惠券</th>
-        <th>优惠状态</th>
-        <th>操作</th>
-    </tr>
-    </thead>
-    <tbody>
-    <c:forEach items="${page.list}" var="cmCoupon">
-        <tr>
-            <td><fmt:formatDate value="${cmCoupon.startDate}" type="date" pattern="yyyy-MM"/></td>
-            <td>
-                <c:if test="${cmCoupon.couponType eq 0 && cmCoupon.productType eq '1'}">优惠券1:活动券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,
-                全商城商品通用
-                </c:if>
-                <br/>
-                <c:if test="${cmCoupon.couponType eq 1}">优惠券2:品类券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,
-                <c:if test="${cmCoupon.categoryType eq '2'}">仅可购买仪器类商品</c:if>
-                <c:if test="${cmCoupon.categoryType eq '1'}">仅可购买产品类商品</c:if>
-                </c:if>
-                <br/>
-                <c:if test="${cmCoupon.couponType eq 3}">优惠券3:店铺券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,仅可购买店铺
-                    ${cmCoupon.shopId}的商品
-                </c:if>
-                <br/>
-                <c:if test="${cmCoupon.couponType eq 0 && cmCoupon.productType eq '2'}">优惠券4:活动券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,
-                仅可购买指定商品
-                </c:if>
-            </td>
-            <td>
-                <c:if test="${cmCoupon.status eq 0}">
-                    <font color="#800080">未生效</font>
-                </c:if>
-                <c:if test="${cmCoupon.status eq 1}">
-                    <font color="#00CC66">已生效</font>
-                </c:if>
-                <c:if test="${cmCoupon.status eq 2}">
-                    <font color="red">已关闭</font>
-                </c:if>
-                <c:if test="${cmCoupon.status eq 3}">
-                    <font color="#FF6600">已失效</font>
-                </c:if>
-            </td>
-            <td>
-                <a href="${ctx}/vip/cmCoupon/form?id=${cmCoupon.id}">编辑</a>
-                <a href="${ctx}/vip/cmCoupon/close?id=${cmCoupon.id}"
-                   onclick="return confirmx('确定关闭该该月份的优惠券吗?关闭后该月份将不赠送优惠券?', this.href)">关闭</a>
-                <a href="${ctx}/vip/cmCoupon/delete?id=${cmCoupon.id}"
-                   onclick="return confirmx('确定删除该月份的优惠券吗?删除后该月份将不赠送优惠券', this.href)">删除</a>
-            </td>
-        </tr>
-    </c:forEach>
-    </tbody>
-</table>
-<div class="pagination">${page}</div>
+<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();
+        }
+    });
+
+    /**
+     * @param obj
+     * jquery控制input只能输入数字
+     */
+    function onlynum(obj) {
+        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
+    }
+
+    $(document).ready(function () {
+        //$("#name").focus();
+        $("#inputForm").validate({
+            submitHandler: function (form) {
+                var couponAmount1 = $("#couponAmount1").val() * 1;
+                var touchPrice1 = $("#touchPrice1").val() * 1;
+                if (couponAmount1 >= touchPrice1) {
+                    alertx("【优惠券1】优惠券金额必须小于优惠条件金额");
+                    return false;
+                }
+                var month = $("#month").val();
+                // 判断月份 ...
+
+                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>
 </body>
 </html>

+ 97 - 177
src/main/webapp/WEB-INF/views/modules/svip/cmSvipCouponList.jsp

@@ -1,199 +1,119 @@
-<%@ page import="java.util.Date" %>
 <%@ page contentType="text/html;charset=UTF-8" %>
 <%@ include file="/WEB-INF/views/include/taglib.jsp" %>
 <html>
 <head>
-    <title>优惠券管理</title>
+    <title>超级会员优惠券管理列表</title>
     <meta name="decorator" content="default"/>
-
+    <style type="text/css">
+        .table th { text-align: center; }
+        .table td { text-align: center; }
+    </style>
 </head>
 <body>
 <ul class="nav nav-tabs">
-    <li><a href="${ctx}/vip/cmCoupon/">专属优惠券</a></li>
-    <li class="active"><a
-            href="${ctx}/vip/cmCoupon/add">${not empty cmCoupon.id?'编辑':'添加'}</a>
-    </li>
+    <li class="active"><a href="${ctx}/vip/cmCoupon/">超级会员专属优惠券</a></li>
 </ul>
-<br/>
-<%--<font style="color: red;margin-left: 20px">品类券只适合在某种品类需要优惠时创建,适用于该品类商品和全部客户。</font><br><br>--%>
-<form:form id="inputForm" modelAttribute="cmCoupon" action="${ctx}/vip/cmCoupon/add" method="post"
-           class="form-horizontal">
-    <%--    <form:hidden path="id"/>--%>
-    <%--    <form:hidden path="productInfo" id="productInfo"/>--%>
-    <%--    <input type="hidden" name="couponType" value="1"/>--%>
-    <sys:message content="${message}"/>
-    <div class="control-group">
-        <label class="control-label"><font color="red">*</font>优惠月份:</label>
-        <div class="controls">
-            <input name="startDate" id="startDate" type="text" required readonly="readonly" maxlength="20"
-                   class="input-medium Wdate "
-                   value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM"/>"
-                   onclick="WdatePicker({dateFmt:'yyyy-MM',isShowClear:false});" onblur="dateShow()"/>
-        </div>
-    </div>
-    <div class="coupon-wrap">
-        <div class="control-group">
-            <label>优惠券1:</label>
-            <form:select path="couponType" class="input-medium coupon-select" onchange="changeCoupon($this)">
-                <form:option value="" label="全部"/>
-                <form:option value="0" label="活动券"/>
-                <form:option value="1" label="品类券"/>
-                <form:option value="3" label="店铺券"/>
-            </form:select>
-        </div>
-
-        <div class="control-group coupon-line" style="display:none">
-            <label class="control-label"><font color="red">*</font>优惠券金额:</label>
-            <div class="controls">
-                <input type="number" id="couponAmount" name="couponAmount" value="${cmCoupon.couponAmount}" min="0"
-                       required>
-            </div>
-        </div>
-
-        <div class="control-group coupon-line" style="display:none">
-            <label class="control-label"><font color="red">*</font>优惠条件:</label>
-            <div class="controls">
-                订单商品总额满&nbsp;&nbsp;&nbsp;&nbsp;<input type="number" name="touchPrice" id="touchPrice"
-                                                      value="${cmCoupon.touchPrice}" min="0" required>
-            </div>
-        </div>
-        <div class="control-group coupon-line" style="display:none">
-            <label class="control-label"><font color="red">*</font>优惠商品:</label>
-            <div class="controls">
-                <form:radiobutton path="categoryType" value="1" label="产品"
-                                  checked="${empty cmCoupon.categoryType ? true:false}"/>
-                <form:radiobutton path="categoryType" value="2" label="仪器"/>
-            </div>
-        </div>
-    </div>
-
-
-    <div class="control-group">
-        <label>优惠券2:</label>
-        <form:select path="couponType" class="input-medium" onchange="changeVal()">
+<form:form id="searchForm" modelAttribute="cmCoupon" action="${ctx}/vip/cmCoupon/" method="post"
+           class="breadcrumb form-search">
+    <input type="hidden" name="couponType" value="4"/>
+    <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
+    <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
+    <div class="ul-form">
+
+        <label>优惠券类型:</label>
+        <form: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>
-    </div>
-
-    <div class="control-group">
-        <label>优惠券3:</label>
-        <form:select path="couponType" class="input-medium" onchange="changeVal()">
-            <form:option value="" label="全部"/>
-            <form:option value="0" label="活动券"/>
-            <form:option value="1" label="品类券"/>
-            <form:option value="3" label="店铺券"/>
+        <label>优惠状态:</label>
+        <form:select path="status" class="input-medium required">
+            <form:option value="" 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="control-group">
-        <label>优惠券4:</label>
-        <form:select path="couponType" class="input-medium" onchange="changeVal()">
-            <form:option value="" label="全部"/>
-            <form:option value="0" label="活动券"/>
-            <form:option value="1" label="品类券"/>
-            <form:option value="3" label="店铺券"/>
-        </form:select>
-    </div>
-
-
-    <div class="control-group">
-
-    </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)"/>
+        <label>优惠月份:</label>
+        <input name="startDate" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
+               value="<fmt:formatDate value="${cmCoupon.startDate}" pattern="yyyy-MM"/>"
+               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/form'"
+               value="添加优惠券"/>
+        <div class="clearfix"></div>
     </div>
 </form:form>
-<script>
-    function statusShow() {
-        var status = $("input[name='status']:checked").val();
-        if (status == 2) {
-            $("#initializeShow").hide();
-            $("#closeShow").show();
-        } else {
-            $("#initializeShow").show();
-            $("#closeShow").hide();
-            $("#hiddenStatus").val(0);
-        }
-    }
-
-    function dateShow() {
-        var startDate = $("#startDate").val();
-        var startMs = new Date(startDate).getTime();
-        var endDate = $("#endDate").val();
-        var endMs = new Date(endDate).getTime();
-        var nowMs = new Date().getTime();
-        if (nowMs < startMs) {
-            $("#initializeShow").html("<font color=\"#800080\">未生效</font>");
-        } else if (nowMs > endMs) {
-            $("#initializeShow").html("<font color=\"#FF6600\">已失效</font>");
-        } else {
-            $("#initializeShow").html("<font color=\"#00CC66\">已生效</font>");
-        }
-    }
-
-    /**
-     * @param obj
-     * jquery控制input只能输入数字
-     */
-    function onlynum(obj) {
-        obj.value = obj.value.replace(/[^\d]/g, ""); //清除"数字"以外的字符
-    }
-
+<sys:message content="${message}"/>
+<table id="contentTable" class="table table-striped table-bordered table-condensed">
+    <thead>
+    <tr>
+        <th>优惠月份</th>
+        <th>优惠券</th>
+        <th>优惠状态</th>
+        <th>操作</th>
+    </tr>
+    </thead>
+    <tbody>
+    <c:forEach items="${page.list}" var="cmCoupon">
+        <tr>
+            <td><fmt:formatDate value="${cmCoupon.startDate}" type="date" pattern="yyyy-MM"/></td>
+            <td>
+                <c:if test="${cmCoupon.couponType eq 0 && cmCoupon.productType eq '1'}">优惠券1:活动券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,
+                    全商城商品通用
+                </c:if>
+                <br/>
+                <c:if test="${cmCoupon.couponType eq 1}">优惠券2:品类券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,
+                    <c:if test="${cmCoupon.categoryType eq '2'}">仅可购买仪器类商品</c:if>
+                    <c:if test="${cmCoupon.categoryType eq '1'}">仅可购买产品类商品</c:if>
+                </c:if>
+                <br/>
+                <c:if test="${cmCoupon.couponType eq 3}">优惠券3:店铺券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,仅可购买店铺
+                    ${cmCoupon.shopId}的商品
+                </c:if>
+                <br/>
+                <c:if test="${cmCoupon.couponType eq 0 && cmCoupon.productType eq '2'}">优惠券4:活动券¥${cmCoupon.couponAmount},满${cmCoupon.touchPrice}可用,
+                    仅可购买指定商品
+                </c:if>
+            </td>
+            <td>
+                <c:if test="${cmCoupon.status eq 0}">
+                    <font color="#800080">未生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 1}">
+                    <font color="#00CC66">已生效</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 2}">
+                    <font color="red">已关闭</font>
+                </c:if>
+                <c:if test="${cmCoupon.status eq 3}">
+                    <font color="#FF6600">已失效</font>
+                </c:if>
+            </td>
+            <td>
+                <a href="${ctx}/vip/cmCoupon/form?id=${cmCoupon.id}">编辑</a>
+                <a href="${ctx}/vip/cmCoupon/close?id=${cmCoupon.id}"
+                   onclick="return confirmx('确定关闭该该月份的优惠券吗?关闭后该月份将不赠送优惠券?', this.href)">关闭</a>
+                <a href="${ctx}/vip/cmCoupon/delete?id=${cmCoupon.id}"
+                   onclick="return confirmx('确定删除该月份的优惠券吗?删除后该月份将不赠送优惠券', this.href)">删除</a>
+            </td>
+        </tr>
+    </c:forEach>
+    </tbody>
+</table>
+<div class="pagination">${page}</div>
+<script type="text/javascript">
     $(document).ready(function () {
-        //$("#name").focus();
-        $("#inputForm").validate({
-            submitHandler: function (form) {
-                var couponAmount = $("#couponAmount").val() * 1;
-                var touchPrice = $("#touchPrice").val() * 1;
-                if (couponAmount >= touchPrice) {
-                    alertx("优惠券金额必须小于优惠条件金额");
-                    return false;
-                }
-                var startDate = $("#startDate").val();
-                var endDate = $("#endDate").val();
-                if (startDate >= endDate) {
-                    alertx("结束时间不能早于开始时间");
-                    return false;
-                }
-                loading('正在提交,请稍等...');
-                form.submit();
-            },
-            errorContainer: "#messageBox",
-            errorPlacement: function (error, element) {
-                $("#messageBox").text("输入有误,请先更正。");
-                if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")) {
-                    error.appendTo(element.parent().parent());
-                } else {
-                    error.insertAfter(element);
-                }
-            }
-        });
+
     });
-    /*        function changeCoupon(el) {
-        var value = $(this).val()*1;
-        alert(el)
-        if (1 === value) {
-        $(this).parents(".coupon-wrap").find(".coupon-line").show();
-    }
-    }*/
-    // $("body").on("change", "select.coupon-select", function(){
-    //     var value = $(this).val()*1;
-    //         alert(value)
-    //     if (1 === value) {
-    //         $(this).parents(".coupon-wrap").find(".coupon-line").show();
-    //     }
-    // });
-    function changeCoupon(){
-        alert(this.val());
-        (".coupon-line").show();
-    }
 
+    function page(n, s) {
+        $("#pageNo").val(n);
+        $("#pageSize").val(s);
+        $("#searchForm").submit();
+        return false;
+    }
 </script>
 </body>
-</html>
+</html>