今天遇到一个问题,简单描述下:
使用邀请码注册的用户拥有24小时的免费使用时间,测试反映不能正常登录。
梳理代码没有问题,断点调试,程序查询该用户为null,遂查看该sql,也没有问题,使用该sql在mysql中查询也没有数据。最后发现是mysql数据库的时间比当前时间晚了5个小时。
sql如下:
<select id="findPubUserByPhone" resultMap="ResultMapWithBLOBs" parameterType="java.lang.String">
select *
from user
where phone=#{phone}
and enterpriseID is null
and state >=4
and now() <= invailDate
and now() >= vaildate
</select>
解决:设置mysql的系统时间解决