<?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.api.manage.dao.remind.RemindDao">
    <insert id="insertMessage" parameterType="com.api.model.remind.SysMessage">
        insert into sys_message(
        title,
        content,
        generate_date,
        send_date,
        sender,
        type
        ) values (
        #{title},
        #{content},
        #{generateDate},
        #{sendDate},
        #{sender},
        #{type}
        )
        <selectKey keyProperty="id" resultType="java.lang.Integer">
            select LAST_INSERT_ID() AS id
        </selectKey>
    </insert>

    <insert id="insertSending" parameterType="com.api.model.remind.SysSending">
        insert into sys_sending(
            message_id,
            receiver_account,
            send_status,
            send_date
        ) values (
            #{messageId},
            #{receiverAccount},
            #{sendStatus},
            #{sendDate}
        )
    </insert>
    <select id="findResidentByDailyPaymentId" parameterType="java.lang.Integer" resultType="java.lang.Integer">
        select cre.resident_id from sys_daily_payment as sdp,cpm_resident_estate as cre
        where sdp.building_unit_estate_id = cre.building_unit_estate_id and sdp.id = #{dailyPaymentId}
    </select>
</mapper>