<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="com.cyksj.mapper.AccountUpdatePasswordRecordMapper">


    <select id="selectPasswordNotChangedThePastMonthAccountId" resultType="java.lang.Long">
        select a.id
        from `account` a
        where not EXISTS(select *
                         from `account_update_password_record` ar
                         where ar.account_id = a.id
                           and ar.created_time >= #{pastMonth} limit 1)
          and (select count(ur.id)
               from user_ticket_cleared_record ur
               where ur.account_id = a.id and deleted is true and source = 'self') > 0
    </select>
</mapper>