From 005d6061c8f8ce36ce07e6fd4c76810863cec081 Mon Sep 17 00:00:00 2001 From: Stormeye Wu Date: Wed, 3 Jul 2019 06:58:17 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=96=B2=E5=8A=B3=E5=BA=A6][=E4=BF=AE?= =?UTF-8?q?=E6=94=B9]:=E6=B7=BB=E5=8A=A0=E6=98=AF=E5=90=A6=E5=90=AF?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/V201907030811__CHANGE_PUSH_LIMIT.sql | 2 ++ .../java/com/iformall/domain/po/PushLimit.java | 8 +++++--- .../service/impl/PushLimitServiceImpl.java | 14 ++++++++++++++ .../src/main/resources/mapper/PushLimitMapper.xml | 6 +++++- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 mallinkAdmin/src/main/resources/db/migration/V201907030811__CHANGE_PUSH_LIMIT.sql diff --git a/mallinkAdmin/src/main/resources/db/migration/V201907030811__CHANGE_PUSH_LIMIT.sql b/mallinkAdmin/src/main/resources/db/migration/V201907030811__CHANGE_PUSH_LIMIT.sql new file mode 100644 index 000000000..d30482c11 --- /dev/null +++ b/mallinkAdmin/src/main/resources/db/migration/V201907030811__CHANGE_PUSH_LIMIT.sql @@ -0,0 +1,2 @@ +ALTER TABLE `push_limit` +ADD COLUMN `enable` TINYINT(2) '0' DEFAULT '0' COMMENT '是否启用,0:Enable,1:Disable'; \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java b/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java index ec0434f29..fb2377951 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/PushLimit.java @@ -22,7 +22,7 @@ public class PushLimit implements Serializable { @Transient protected String sortColumns; - @io.swagger.annotations.ApiModelProperty(value="",name="tenantId") + @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") private String tenantId; @io.swagger.annotations.ApiModelProperty(value="每人每天可接收短信数",name="msgAmount") private Integer msgAmount; @@ -34,10 +34,12 @@ public class PushLimit implements Serializable { private String timeStart; @io.swagger.annotations.ApiModelProperty(value="发券,发短信结束时间",name="timeEnd") private String timeEnd; - @io.swagger.annotations.ApiModelProperty(value="",name="createTime") + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") private Date createTime; - @io.swagger.annotations.ApiModelProperty(value="",name="updateTime") + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") private Date updateTime; + @io.swagger.annotations.ApiModelProperty(value="是否启用,0:Enable,1:Disable",name="enable") + private Integer enable; public static enum Field { diff --git a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java index 0536af391..50f1e170c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/PushLimitServiceImpl.java @@ -3,6 +3,7 @@ package com.iformall.service.impl; import com.iformall.common.ErrorCode; import com.iformall.common.IdWorker; import com.iformall.domain.po.PushLimit; +import com.iformall.enums.EnumEnableType; import com.iformall.exception.MallinkException; import com.iformall.mapper.PushLimitMapper; import com.iformall.mapper.WxCouponActionLogMapper; @@ -62,6 +63,7 @@ public class PushLimitServiceImpl implements PushLimitService { pushLimit.setCouponDay(10); pushLimit.setTimeStart("8:00"); pushLimit.setTimeEnd("23:00"); + pushLimit.setEnable(EnumEnableType.Enable.getCode()); Date curDate = new Date(); pushLimit.setCreateTime(curDate); pushLimit.setUpdateTime(curDate); @@ -92,6 +94,10 @@ public class PushLimitServiceImpl implements PushLimitService { Date curDate = new Date(); // 1. get tenant limit PushLimit pushLimit = getPushLimit(tenantId); + // 1.1 疲劳度是否启用 + if(pushLimit.getEnable().equals(EnumEnableType.Disable.getCode())) { + return true; + } // 2. check time boolean isInDate = DateUtils.isInDate(curDate, pushLimit.getTimeStart(), pushLimit.getTimeEnd()); if (!isInDate) { @@ -106,6 +112,10 @@ public class PushLimitServiceImpl implements PushLimitService { Date curDate = new Date(); // 1. get tenant limit PushLimit pushLimit = getPushLimit(tenantId); + // 1.1 疲劳度是否启用 + if(pushLimit.getEnable().equals(EnumEnableType.Disable.getCode())) { + return true; + } // 2. check time boolean isInDate = DateUtils.isInDate(curDate, pushLimit.getTimeStart(), pushLimit.getTimeEnd()); if (!isInDate) { @@ -121,6 +131,10 @@ public class PushLimitServiceImpl implements PushLimitService { Date curDate = new Date(); // 1. get tenant limit PushLimit pushLimit = getPushLimit(tenantId); + // 1.1 疲劳度是否启用 + if(pushLimit.getEnable().equals(EnumEnableType.Disable.getCode())) { + return true; + } // 2. check time 是否在给定的时间段内 boolean isInDate = DateUtils.isInDate(curDate, pushLimit.getTimeStart(), pushLimit.getTimeEnd()); if (!isInDate) { diff --git a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml index b2c8bb3c0..776892faf 100644 --- a/mallinkService/src/main/resources/mapper/PushLimitMapper.xml +++ b/mallinkService/src/main/resources/mapper/PushLimitMapper.xml @@ -11,10 +11,11 @@ + - `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`time_start`,`time_end`,`create_time`,`update_time` + `id`,`tenant_id`,`msg_amount`,`coupon_amount`,`coupon_day`,`time_start`,`time_end`,`create_time`,`update_time`,`enable` @@ -55,6 +56,9 @@ and `update_time` = #{updateTime} + + and `enable` = #{enable} + and id in