Browse Source

[验证码短信][添加][判断一日只能发三次]

release_toaliyun_real
gongbiao 7 years ago
parent
commit
f64e460b37
4 changed files with 30 additions and 7 deletions
  1. +1
    -0
      mallinkAdmin/src/main/resources/db/migration/V201904271400__UPDATE_MSG_MODEL.sql
  2. +11
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxMsgValidationcode.java
  3. +11
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java
  4. +7
    -6
      mallinkService/src/main/resources/mapper/WxMsgValidationcodeMapper.xml

+ 1
- 0
mallinkAdmin/src/main/resources/db/migration/V201904271400__UPDATE_MSG_MODEL.sql View File

@@ -0,0 +1 @@
update wx_msg_validationcode_model set content='{s6}(动态验证码),请在5分钟内填写' where type in (1,6);

+ 11
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxMsgValidationcode.java View File

@@ -67,6 +67,17 @@ public class WxMsgValidationcode implements Serializable {
@io.swagger.annotations.ApiModelProperty(value="",name="appid")
private String appid;

@Transient
private String createtimeStr;

public String getCreatetimeStr() {
return createtimeStr;
}

public void setCreatetimeStr(String createtimeStr) {
this.createtimeStr = createtimeStr;
}

public String getPhone() {
return phone;
}


+ 11
- 1
mallinkService/src/main/java/com/iformall/service/impl/WxMsgValidationcodeServiceImpl.java View File

@@ -12,6 +12,7 @@ import com.iformall.enums.*;
import com.iformall.mapper.*;
import com.iformall.mq.MqBaseProducer;
import com.iformall.service.WxMsgValidationcodeService;
import com.iformall.utils.DateUtils;
import org.apache.commons.collections.map.HashedMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -84,7 +85,16 @@ public class WxMsgValidationcodeServiceImpl implements WxMsgValidationcodeServic
Date currentdate = new Date();
wxmsgvalidationcodelist = wxmsgvalidationcodelist.stream().filter(validationcode ->
validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList());
if(wxmsgvalidationcodelist.size()>0) return new ResultData(ErrorCode.MSG_REPEAT_SEND.getCode(),ErrorCode.MSG_REPEAT_SEND.getMessage());
if (wxmsgvalidationcodelist.size() > 0) {
return new ResultData(ErrorCode.MSG_REPEAT_SEND);
}
//2 判断是否已超过3条
String systemTime = DateUtils.getSystemTime("yyyy-MM-dd");
wxMsgValidationcode.setCreatetimeStr(systemTime);
List<WxMsgValidationcode> list = wxMsgValidationcodeMapper.findList(wxMsgValidationcode);
if (list.size() == 3) {
return new ResultData(ErrorCode.MSG_SEND_ERROR.getCode(), "验证码发送超限");
}

//验证码
int code = (int) ((Math.random() * 9 + 1) * 100000);


+ 7
- 6
mallinkService/src/main/resources/mapper/WxMsgValidationcodeMapper.xml View File

@@ -22,14 +22,15 @@
<sql id="dynamicWhereConditions">
where 1 = 1
<if test=" null != id "> and `id` = #{id} </if>
<if test=" null != phone "> and `phone` = #{phone} </if>
<if test=" null != expiretime "> and `expiretime` = #{expiretime} </if>
<if test=" null != createtime "> and `createtime` = #{createtime} </if>
<if test=" null != phone "> and `phone` = #{phone} </if>
<if test=" null != expiretime ">and `expiretime` = #{expiretime}</if>
<if test=" null != createtime ">and `createtime` = #{createtime}</if>
<if test=" null != type "> and `type` = #{type} </if>
<if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if>
<if test=" null != msg "> and `msg` = #{msg} </if>
<if test=" null != signature "> and `signature` = #{signature} </if>
<if test=" null != code "> and `code` = #{code} </if>
<if test=" null != msg "> and `msg` = #{msg} </if>
<if test=" null != signature ">and `signature` = #{signature}</if>
<if test=" null != code ">and `code` = #{code}</if>
<if test=" null != createtimeStr ">and date_format(`createtime`,'%Y-%m-%d') = #{createtimeStr}</if>
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">


Loading…
Cancel
Save