Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/developerA' into developerA

Aslee 3 rokov pred
rodič
commit
87778b0d69

+ 30 - 0
src/main/java/com/caimei/modules/coupon/service/CmVipCouponService.java

@@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -35,6 +37,7 @@ public class CmVipCouponService extends CrudService<CmCouponVipDao, CmVipCoupon>
     public CmVipCoupon get(String id) {
         CmVipCoupon vipCoupon = super.get(id);
         if (null != vipCoupon) {
+            setVipCouponStatus(vipCoupon);
             List<CmCoupon> couponList = new ArrayList<>();
             List<String> bindCoupons = cmCouponVipDao.getBindCoupons(id);
             for (String s : bindCoupons) {
@@ -51,6 +54,7 @@ public class CmVipCouponService extends CrudService<CmCouponVipDao, CmVipCoupon>
         Page<CmVipCoupon> vipPage = super.findPage(page, cmVipCoupon);
         List<CmVipCoupon> cmVipCouponList = vipPage.getList();
         cmVipCouponList.forEach(vipCoupon -> {
+            setVipCouponStatus(vipCoupon);
             List<String> bindCoupons = cmCouponVipDao.getBindCoupons(vipCoupon.getId());
             List<CmCoupon> couponList = cmCouponVipDao.getCouponListByIds(bindCoupons, cmVipCoupon.getCouponType(), cmVipCoupon.getStatus());
             Date date = new Date();
@@ -78,6 +82,32 @@ public class CmVipCouponService extends CrudService<CmCouponVipDao, CmVipCoupon>
         return vipPage;
     }
 
+    /**
+     * 设置会员优惠生效状态
+     */
+    private void setVipCouponStatus(CmVipCoupon vipCoupon) {
+        if (!"2".equals(vipCoupon.getStatus())) {
+            try {
+                SimpleDateFormat df = new SimpleDateFormat("yyyy-MM");
+                String current = df.format(new Date());
+                String useTime = vipCoupon.getUseTime();
+                // 0未生效 1已生效 2已关闭 3已失效
+                if (df.parse(useTime).after(df.parse(current))) {
+                    // 未生效
+                    vipCoupon.setStatus("0");
+                } else if (df.parse(useTime).before(df.parse(current))) {
+                    // 已失效
+                    vipCoupon.setStatus("3");
+                } else {
+                    // 生效
+                    vipCoupon.setStatus("1");
+                }
+            } catch (ParseException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
     /**
      * 设置4张券的表单数据
      */

+ 15 - 0
src/main/java/com/caimei/modules/supers/service/CmSvipPackageService.java

@@ -53,9 +53,24 @@ public class CmSvipPackageService extends CrudService<CmSvipPackageDao, CmSvipPa
             }
             vip.setProportion(cmSvipPackage.getProportion());
         }
+        String price1 = strs(vip.getPrice1());
+        String price2 = strs(vip.getPrice2());
+        String price3 = strs(vip.getPrice3());
+        vip.setPrice1(price1);
+        vip.setPrice2(price2);
+        vip.setPrice3(price3);
         return vip;
     }
 
+    private static String strs(String str) {
+        if (str.indexOf(".") > 0) {
+            str = str.replaceAll("0+?$", "");//删掉尾数为0的字符
+            str = str.replaceAll("[.]$", "");//结尾如果是小数点,则去掉
+        }
+        return str;
+    }
+
+
     @Transactional(readOnly = false)
     public void save(CmSvipPackage cmSvipPackage) {
         super.save(cmSvipPackage);

+ 3 - 1
src/main/java/com/caimei/modules/utils/DateUtil.java

@@ -26,7 +26,7 @@ public class DateUtil {
     }
 
     /*
-    输入日期字符串,返回月底0点
+    输入日期字符串,返回下个月1号0点
     */
     public static Date getMaxDay(String month) {
         try {
@@ -34,6 +34,7 @@ public class DateUtil {
             calendar = Calendar.getInstance();
             calendar.setTime(nowDate);
             calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+            calendar.add(Calendar.DAY_OF_MONTH,1);
             return calendar.getTime();
         } catch (ParseException e) {
             e.printStackTrace();
@@ -50,6 +51,7 @@ public class DateUtil {
         String format = new SimpleDateFormat("yyyy-MM").format(date);
         return format;
     }
+
 //    public static void main(String[] args) throws ParseException {
 //        String month = "2020-02";
 //        System.out.println(getMinDateMonth(month));

+ 9 - 7
src/main/resources/mappings/modules/super/CmSvipHistoryMapper.xml

@@ -80,9 +80,9 @@
         select
         cs.userId,
         cs.packageId,
-        cb.name as clubName,
-        cb.linkMan1 as linkMan,
-        cb.contractMobile1 as mobile,
+        u.name as clubName,
+        u.userName as linkMan,
+        u.bindMobile as mobile,
         cs.beginTime,
         cs.price,
         cs.payWay,
@@ -92,6 +92,7 @@
         cs.endTime
         from cm_svip_history cs
         LEFT JOIN club cb ON cs.userId = cb.userId
+        left join user u on cs.userId = u.userID
         where cs.userId = #{userId}
         <if test="startPayTime != null and startPayTime != '' and endPayTime != null and endPayTime != ''">
             and (payTime between #{startPayTime} and #{endPayTime})
@@ -122,20 +123,21 @@
 
 
     <select id="superFind" resultType="com.caimei.modules.supervip.entity.CmSvipHistory">
-        SELECT cb.name as clubName, cb.linkMan1 as linkMan, cb.contractMobile1 as mobile,
+        SELECT u.name as clubName, u.username as linkMan, u.bindMobile as mobile,
         cs.userId,cs.beginTime,cs.endTime,cs.packageId
         FROM cm_svip_history cs
         LEFT JOIN club cb ON cs.userId = cb.userId
         LEFT JOIN cm_svip_user cu ON cs.userId = cu.userId
+        left join user u on cs.userId = u.userID
         <where>
             <if test="clubName != null and clubName != ''">
-                and cb.name like concat('%',#{clubName},'%')
+                and u.name like concat('%',#{clubName},'%')
             </if>
             <if test="linkMan != null and linkMan != ''">
-                and cb.linkMan1 like concat('%',#{linkMan},'%') or linkMan2 like concat('%',#{linkMan},'%')
+                and u.username like concat('%',#{linkMan},'%')
             </if>
             <if test="mobile != null and mobile != ''">
-                and cb.contractMobile1=#{mobile}
+                and u.bindMobile LIKE concat('%',#{mobile},'%')
             </if>
             <if test="startPayTime !=null and startPayTime != '' and endPayTime !=null and endPayTime!=''">
                 and (payTime between #{startPayTime} and #{endPayTime})

+ 51 - 15
src/main/webapp/WEB-INF/views/modules/super/cmSvipPackageForm.jsp

@@ -9,9 +9,24 @@
             //$("#name").focus();
             $("#inputForm").validate({
                 submitHandler: function (form) {
-                    var places = $(".input-xlarge").val();
-                    if (!(/(^[1-9]\d*$)/.test(places))) {
-                        alert("金额应为正整数,如 100");
+                    var places1 = $(".input-xlarge1").val();
+                    if (!(/(^[1-9]\d*$)/.test(places1))) {
+                        alert("套裁1售价应为正整数且不能为0,如100");
+                        return false;
+                    }
+                    var places2 = $(".input-xlarge2").val();
+                    if (!(/(^[1-9]\d*$)/.test(places2))) {
+                        alert("套裁2售价应为正整数且不能为0,如100");
+                        return false;
+                    }
+                    var places3 = $(".input-xlarge3").val();
+                    if (!(/(^[1-9]\d*$)/.test(places3))) {
+                        alert("套裁3售价应为正整数且不能为0,如100");
+                        return false;
+                    }
+                    var places4 = $(".input-xlarge4").val();
+                    if (!(/(^[1-9]\d*$)/.test(places4))) {
+                        alert("美豆比例应为正整数且不能为0,如100");
                         return false;
                     }
                     loading('正在提交,请稍等...');
@@ -29,7 +44,28 @@
             });
         });
 
-
+        function checkNum(){
+            var places1 = $(".input-xlarge1").val();
+            if (!(/(^[1-9]\d*$)/.test(places1))) {
+                alert("套裁1售价应为正整数且不能为0,如100");
+                return false;
+            }
+            var places2 = $(".input-xlarge2").val();
+            if (!(/(^[1-9]\d*$)/.test(places2))) {
+                alert("套裁2售价应为正整数且不能为0,如100");
+                return false;
+            }
+            var places3 = $(".input-xlarge3").val();
+            if (!(/(^[1-9]\d*$)/.test(places3))) {
+                alert("套裁3售价应为正整数且不能为0,如100");
+                return false;
+            }
+            var places4 = $(".input-xlarge4").val();
+            if (!(/(^[1-9]\d*$)/.test(places4))) {
+                alert("美豆比例应为正整数且不能为0,如100");
+                return false;
+            }
+        }
     </script>
 </head>
 <body>
@@ -41,40 +77,40 @@
            class="form-horizontal">
     <form:hidden path="id"/>
     <sys:message content="${message}"/>
-<%--    <div class="control-group">--%>
-<%--        <label class="control-label">套餐名称:</label>--%>
-<%--        <div class="controls">--%>
-<%--            <form:input path="name" htmlEscape="false" maxlength="50" class="input-lab"/>--%>
-<%--        </div>--%>
-<%--    </div>--%>
+    <%--    <div class="control-group">--%>
+    <%--        <label class="control-label">套餐名称:</label>--%>
+    <%--        <div class="controls">--%>
+    <%--            <form:input path="name" htmlEscape="false" maxlength="50" class="input-lab"/>--%>
+    <%--        </div>--%>
+    <%--    </div>--%>
     <div class="control-group">
         <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>套餐1:</label>
         <div class="controls">
-            12个月超级会员,售价:<form:input path="price1" htmlEscape="false" class="input-xlarge" style="width: 60px"/>
+            12个月超级会员,售价:
+            <form:input path="price1" htmlEscape="false" class="input-xlarge1" style="width: 60px" onblur="checkNum()"/>
         </div>
     </div>
     <div class="control-group">
         <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>套餐2:</label>
         <div class="controls">
-            3个月超级会员,售价:<form:input path="price2" htmlEscape="false" class="input-xlarge" style="width: 60px"/>
+            3个月超级会员,售价:<form:input path="price2" htmlEscape="false" class="input-xlarge2" style="width: 60px" onblur="checkNum()"/>
         </div>
     </div>
 
     <div class="control-group">
         <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>套餐3:</label>
         <div class="controls">
-            1个月超级会员,售价:<form:input path="price3" htmlEscape="false" class="input-xlarge" style="width: 60px"/>
+            1个月超级会员,售价:<form:input path="price3" htmlEscape="false" class="input-xlarge3" style="width: 60px" onblur="checkNum()"/>
         </div>
     </div>
     <div class="control-group">
         <label class="control-label"><span class="help-inline"><font color="red">*</font> </span>采美豆兑换套餐:</label>
         <div class="controls">
-            采美豆兑换超会员套餐比例为<form:input path="proportion" htmlEscape="false" class="input-xlarge" style="width: 30px"/>:1
+            采美豆兑换超会员套餐比例为<form:input path="proportion" htmlEscape="false" class="input-xlarge4" style="width: 30px" onblur="checkNum()"/>:1
         </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>
 </body>

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

@@ -94,26 +94,26 @@
                 </c:forEach>
             </td>
             <td>
-                <c:if test="${cmCoupon.status eq '0'}">
+                <c:if test="${vip.status eq '0'}">
                     <font color="#800080">未生效</font>
                 </c:if>
-                <c:if test="${cmCoupon.status eq '1'}">
+                <c:if test="${vip.status eq '1'}">
                     <font color="#00CC66">已生效</font>
                 </c:if>
-                <c:if test="${cmCoupon.status eq '2'}">
+                <c:if test="${vip.status eq '2'}">
                     <font color="red">已关闭</font>
                 </c:if>
-                <c:if test="${cmCoupon.status eq '3'}">
+                <c:if test="${vip.status eq '3'}">
                     <font color="#FF6600">已失效</font>
                 </c:if>
             </td>
             <td>
                 <a href="${ctx}/vip/cmCoupon/form?id=${vip.id}">编辑</a>
-                <c:if test="${cmCoupon.svipCoupons.status ne '2'}">
+                <c:if test="${vip.status ne '2'}">
                     <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'}">
+                <c:if test="${vip.status eq '2'}">
                     <a href="${ctx}/vip/cmCoupon/open?id=${vip.id}"
                        onclick="return confirmx('确定重新开启该月份的优惠券吗?', this.href)">开启</a>
                 </c:if>

+ 5 - 4
src/main/webapp/WEB-INF/views/modules/svip/cmSvipHistoryForm.jsp

@@ -107,10 +107,10 @@
                     <c:if test="${cmSvipHistory.packageId eq '3'}">1个月</c:if>
             </td>
             <td>
-                <c:if test="${cmSvipHistory.payWay eq '0'}">${cmSvipHistory.price}</c:if>
-                <c:if test="${cmSvipHistory.payWay eq '1'}">${cmSvipHistory.price}</c:if>
-                <c:if test="${cmSvipHistory.payWay eq '2'}">${cmSvipHistory.price}</c:if>
-                <c:if test="${cmSvipHistory.payWay eq '3'}">${cmSvipHistory.price}</c:if>
+                <c:if test="${cmSvipHistory.payWay eq '0'}">${cmSvipHistory.price}</c:if>
+                <c:if test="${cmSvipHistory.payWay eq '1'}">${cmSvipHistory.price}</c:if>
+                <c:if test="${cmSvipHistory.payWay eq '2'}">${cmSvipHistory.price}</c:if>
+                <c:if test="${cmSvipHistory.payWay eq '3'}">${cmSvipHistory.price}</c:if>
                 <c:if test="${cmSvipHistory.payWay eq '4'}"><fmt:formatNumber value="${cmSvipHistory.userBeans}" pattern="#" type="number"/>采美豆</c:if>
             </td>
             <td>
@@ -123,6 +123,7 @@
             <td>
                 <c:if test="${cmSvipHistory.status eq '1'}"><font color="green">已生效</font> </c:if>
                 <c:if test="${cmSvipHistory.status eq '2'}"><font color="red">已过期</font> </c:if>
+                <c:if test="${cmSvipHistory.status eq '3'}"><font color="Orange">暂未生效</font> </c:if>
             </td>
             <td><fmt:formatDate value="${cmSvipHistory.payTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
             <td><fmt:formatDate value="${cmSvipHistory.endTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>