<?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="cn.pluss.platform.mapper.DeviceBsjMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.DeviceBsj">
        <id column="snNo" property="snNo"/>
        <result column="deviceNo" property="deviceNo"/>
        <result column="imei" property="imei"/>
        <result column="iccid" property="iccid"/>
        <result column="sim" property="sim"/>
        <result column="simExpireTime" property="simExpireTime"/>
    </resultMap>

    <select id="selectLastMonthExpiredData" resultType="java.util.Map">
        SELECT ds.snNo, mbi.alias, ua.userId
        FROM tb_pluss_device_bsj dbsj
                 LEFT JOIN tb_pluss_device_stock ds ON dbsj.snNo = ds.snNo
                 LEFT JOIN tb_pluss_merchant_base_info mbi ON mbi.id = ds.actMercId
                 LEFT JOIN tb_pluss_user_app ua ON ua.userId = mbi.userId
        WHERE dbsj.simExpireTime &lt;= DATE_ADD(CURRENT_TIMESTAMP, INTERVAL 1 MONTH)
    </select>
</mapper>
