Commit a8b60061 by zhangxingmin

push

parent 232a5106
......@@ -293,6 +293,8 @@ import com.yd.util.PDFConfiguration;
import com.yd.util.SpringContextUtil;
import com.yd.util.config.ZHBErrorConfig;
import com.yd.util.deshandler.DESTypeHandler;
import com.yd.dal.entity.sms.ShortMessageSendRecord;
import com.yd.dal.service.sms.ShortMessageSendRecordService;
import lombok.extern.slf4j.Slf4j;
......@@ -394,6 +396,9 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
private SendService sendService;
@Autowired
private AclSystemMessageService aclSystemMessageService;
@Autowired
private ShortMessageSendRecordService shortMessageSendRecordService;
@Override
public PractitionerLoginResponseVO practitionerLogin(PractitionerLoginRequestVO requestVO) {
PractitionerLoginResponseVO responseVO = new PractitionerLoginResponseVO();
......@@ -458,6 +463,10 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
responseVO.setCanSeeSalaryList(practitionerInfo.getCanSeeSalaryList());
responseVO.setLoginLogId(loginLogId);
responseVO.setCommonResult(new CommonResult(true, ZHBErrorConfig.getErrorInfo("800000")));
//更新ag_sms_record表的is_use为已使用状态
updateSmsRecordIsUse(mobileNo);
// }
} else {
responseVO.setCommonResult(new CommonResult(false, ZHBErrorConfig.getErrorInfo("830001")));
......@@ -470,6 +479,25 @@ public class PractitionerServiceImpl implements com.yd.api.practitioner.service.
return responseVO;
}
/**
* 登录成功后,将 ag_sms_record 中该手机号最新未使用的验证码短信置为已使用
* @param mobileNo
*/
private void updateSmsRecordIsUse(String mobileNo) {
if (Strings.isNullOrEmpty(mobileNo)) {
return;
}
try {
ShortMessageSendRecord smsRecord = shortMessageSendRecordService.findLatestUnused(mobileNo, "1");
if (smsRecord != null && smsRecord.getId() != null) {
shortMessageSendRecordService.updateIsUse(smsRecord.getId(), 1);
}
} catch (Exception e) {
// 更新短信状态失败不应影响登录主流程
log.error("更新短信验证码使用状态失败, mobileNo={}", mobileNo, e);
}
}
private void getOpenIdUrl(PractitionerLoginResponseVO responseVO, AclCustomer customer) {
String openId = customer.getYdWechatOpenid();
if (Strings.isNullOrEmpty(openId)) {
......
......@@ -5,7 +5,7 @@ import java.util.Date;
/**
* ag_sms_record
* @author
* @author
*/
public class ShortMessageSendRecord implements Serializable {
/**
......@@ -78,6 +78,26 @@ public class ShortMessageSendRecord implements Serializable {
*/
private String templateCode;
/**
* 账号类型(0-阿里云账号;1—大汉三通行业账号;2—大汉三通营销账号)
*/
private String userType;
/**
* 短信发送状态(0—成功;1—接口处理失败;2—运营商网关失败)
*/
private String smsStatus;
/**
* 短信发送结果
*/
private String smsMessage;
/**
* 是否使用 0-未使用 1-已使用
*/
private Integer isUse;
private static final long serialVersionUID = 1L;
public Long getId() {
......@@ -192,6 +212,38 @@ public class ShortMessageSendRecord implements Serializable {
this.templateCode = templateCode;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public String getSmsStatus() {
return smsStatus;
}
public void setSmsStatus(String smsStatus) {
this.smsStatus = smsStatus;
}
public String getSmsMessage() {
return smsMessage;
}
public void setSmsMessage(String smsMessage) {
this.smsMessage = smsMessage;
}
public Integer getIsUse() {
return isUse;
}
public void setIsUse(Integer isUse) {
this.isUse = isUse;
}
@Override
public boolean equals(Object that) {
if (this == that) {
......@@ -205,19 +257,23 @@ public class ShortMessageSendRecord implements Serializable {
}
ShortMessageSendRecord other = (ShortMessageSendRecord) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getMobileNo() == null ? other.getMobileNo() == null : this.getMobileNo().equals(other.getMobileNo()))
&& (this.getBusinessType() == null ? other.getBusinessType() == null : this.getBusinessType().equals(other.getBusinessType()))
&& (this.getBusinessId() == null ? other.getBusinessId() == null : this.getBusinessId().equals(other.getBusinessId()))
&& (this.getSmsType() == null ? other.getSmsType() == null : this.getSmsType().equals(other.getSmsType()))
&& (this.getSmsContent() == null ? other.getSmsContent() == null : this.getSmsContent().equals(other.getSmsContent()))
&& (this.getVerificationCode() == null ? other.getVerificationCode() == null : this.getVerificationCode().equals(other.getVerificationCode()))
&& (this.getSendTime() == null ? other.getSendTime() == null : this.getSendTime().equals(other.getSendTime()))
&& (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
&& (this.getSendStatus() == null ? other.getSendStatus() == null : this.getSendStatus().equals(other.getSendStatus()))
&& (this.getReturnMessage() == null ? other.getReturnMessage() == null : this.getReturnMessage().equals(other.getReturnMessage()))
&& (this.getRequestId() == null ? other.getRequestId() == null : this.getRequestId().equals(other.getRequestId()))
&& (this.getBizId() == null ? other.getBizId() == null : this.getBizId().equals(other.getBizId()))
&& (this.getTemplateCode() == null ? other.getTemplateCode() == null : this.getTemplateCode().equals(other.getTemplateCode()));
&& (this.getMobileNo() == null ? other.getMobileNo() == null : this.getMobileNo().equals(other.getMobileNo()))
&& (this.getBusinessType() == null ? other.getBusinessType() == null : this.getBusinessType().equals(other.getBusinessType()))
&& (this.getBusinessId() == null ? other.getBusinessId() == null : this.getBusinessId().equals(other.getBusinessId()))
&& (this.getSmsType() == null ? other.getSmsType() == null : this.getSmsType().equals(other.getSmsType()))
&& (this.getSmsContent() == null ? other.getSmsContent() == null : this.getSmsContent().equals(other.getSmsContent()))
&& (this.getVerificationCode() == null ? other.getVerificationCode() == null : this.getVerificationCode().equals(other.getVerificationCode()))
&& (this.getSendTime() == null ? other.getSendTime() == null : this.getSendTime().equals(other.getSendTime()))
&& (this.getExpireTime() == null ? other.getExpireTime() == null : this.getExpireTime().equals(other.getExpireTime()))
&& (this.getSendStatus() == null ? other.getSendStatus() == null : this.getSendStatus().equals(other.getSendStatus()))
&& (this.getReturnMessage() == null ? other.getReturnMessage() == null : this.getReturnMessage().equals(other.getReturnMessage()))
&& (this.getRequestId() == null ? other.getRequestId() == null : this.getRequestId().equals(other.getRequestId()))
&& (this.getBizId() == null ? other.getBizId() == null : this.getBizId().equals(other.getBizId()))
&& (this.getTemplateCode() == null ? other.getTemplateCode() == null : this.getTemplateCode().equals(other.getTemplateCode()))
&& (this.getUserType() == null ? other.getUserType() == null : this.getUserType().equals(other.getUserType()))
&& (this.getSmsStatus() == null ? other.getSmsStatus() == null : this.getSmsStatus().equals(other.getSmsStatus()))
&& (this.getSmsMessage() == null ? other.getSmsMessage() == null : this.getSmsMessage().equals(other.getSmsMessage()))
&& (this.getIsUse() == null ? other.getIsUse() == null : this.getIsUse().equals(other.getIsUse()));
}
@Override
......@@ -238,6 +294,10 @@ public class ShortMessageSendRecord implements Serializable {
result = prime * result + ((getRequestId() == null) ? 0 : getRequestId().hashCode());
result = prime * result + ((getBizId() == null) ? 0 : getBizId().hashCode());
result = prime * result + ((getTemplateCode() == null) ? 0 : getTemplateCode().hashCode());
result = prime * result + ((getUserType() == null) ? 0 : getUserType().hashCode());
result = prime * result + ((getSmsStatus() == null) ? 0 : getSmsStatus().hashCode());
result = prime * result + ((getSmsMessage() == null) ? 0 : getSmsMessage().hashCode());
result = prime * result + ((getIsUse() == null) ? 0 : getIsUse().hashCode());
return result;
}
......@@ -261,8 +321,12 @@ public class ShortMessageSendRecord implements Serializable {
sb.append(", requestId=").append(requestId);
sb.append(", bizId=").append(bizId);
sb.append(", templateCode=").append(templateCode);
sb.append(", userType=").append(userType);
sb.append(", smsStatus=").append(smsStatus);
sb.append(", smsMessage=").append(smsMessage);
sb.append(", isUse=").append(isUse);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
\ No newline at end of file
}
package com.yd.dal.mapper.sms;
import org.apache.ibatis.annotations.Param;
import com.yd.dal.entity.sms.ShortMessageSendRecord;
public interface ShortMessageSendRecordMapper {
......@@ -14,4 +15,12 @@ public interface ShortMessageSendRecordMapper {
int updateByPrimaryKeySelective(ShortMessageSendRecord record);
int updateByPrimaryKey(ShortMessageSendRecord record);
}
\ No newline at end of file
ShortMessageSendRecord selectLatestUnused(@Param("mobileNo") String mobileNo,
@Param("smsType") String smsType);
int updateIsUse(@Param("id") Long id,
@Param("isUse") Integer isUse);
}
......@@ -11,5 +11,7 @@ public interface ShortMessageSendRecordService {
// ShortMessageSendRecord update(ShortMessageSendRecord shortMessageSendRecord);
// ShortMessageSendRecord findById(Long id);
ShortMessageSendRecord findLatestUnused(String mobileNo, String smsType);
}
\ No newline at end of file
void updateIsUse(Long id, Integer isUse);
}
......@@ -17,4 +17,14 @@ public class ShortMessageSendRecordServiceImpl implements ShortMessageSendRecord
public void save(ShortMessageSendRecord shortMessageSendRecord) {
shortMessageSendRecordMapper.insert(shortMessageSendRecord);
}
}
\ No newline at end of file
@Override
public ShortMessageSendRecord findLatestUnused(String mobileNo, String smsType) {
return shortMessageSendRecordMapper.selectLatestUnused(mobileNo, smsType);
}
@Override
public void updateIsUse(Long id, Integer isUse) {
shortMessageSendRecordMapper.updateIsUse(id, isUse);
}
}
......@@ -16,10 +16,17 @@
<result column="request_id" jdbcType="VARCHAR" property="requestId" />
<result column="biz_id" jdbcType="VARCHAR" property="bizId" />
<result column="template_code" jdbcType="VARCHAR" property="templateCode" />
<!-- 新增字段 -->
<result column="user_type" jdbcType="VARCHAR" property="userType" />
<result column="sms_status" jdbcType="VARCHAR" property="smsStatus" />
<result column="sms_message" jdbcType="VARCHAR" property="smsMessage" />
<result column="is_use" jdbcType="INTEGER" property="isUse" />
</resultMap>
<sql id="Base_Column_List">
id, mobile_no, business_type, business_id, sms_type, sms_content, verification_code,
send_time, expire_time, send_status, return_message, request_id, biz_id, template_code
id, mobile_no, business_type, business_id, sms_type, sms_content, verification_code,
send_time, expire_time, send_status, return_message, request_id, biz_id, template_code,
user_type, sms_status, sms_message, is_use
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
......@@ -190,4 +197,21 @@
template_code = #{templateCode,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
<select id="selectLatestUnused" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from ag_sms_record
where mobile_no = #{mobileNo,jdbcType=VARCHAR}
and sms_type = #{smsType,jdbcType=VARCHAR}
and is_use = 0
order by send_time desc
limit 1
</select>
<update id="updateIsUse">
update ag_sms_record
set is_use = #{isUse,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment