<?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.saye.hospitalgd.mapper.ReconciliationResultMapper">


    <select id="findReconciliationResultPageList" parameterType="HashMap" resultType="HashMap">
        select DISTINCT
            trade_date,
            third_money,
            his_money,
            difference,
            third_unilateral,
            his_unilateral,
            manager_history_unilateral,
            today_unilateral,
            unilateral_num,
            pending_unilateral,
            pending_unilateral_num,
            status,
            area,
            (case status when '1' then '通过' else '不通过' end) as status_str
        from reconciliation_result
        <where>
            <if test="startTime!=null and startTime!=''">
                and trade_date &gt;=#{startTime}
            </if>
            <if test="endTime!=null and endTime!=''">
                and trade_date &lt;=#{endTime}
            </if>
        </where>
        order by trade_date desc
    </select>

    <insert id="insertReconciliationResult" parameterType="HashMap">
        insert into reconciliation_result(trade_date, third_money, his_money, difference,third_unilateral,his_unilateral, manager_history_unilateral, today_unilateral, unilateral_num, pending_unilateral, pending_unilateral_num, status, area)
        VALUES (#{trade_date},#{third_money},#{his_money},#{difference},#{third_unilateral},#{his_unilateral},#{manager_history_unilateral},#{today_unilateral},#{unilateral_num},#{pending_unilateral},#{pending_unilateral_num},#{status},#{area})
        ON DUPLICATE KEY UPDATE
            third_money=values(third_money),
            his_money=values(his_money),
            difference=values(difference),
            third_unilateral=values(third_unilateral),
            his_unilateral=values(his_unilateral),
            manager_history_unilateral=values(manager_history_unilateral),
            today_unilateral=values(today_unilateral),
            unilateral_num=values(unilateral_num),
            pending_unilateral=values(pending_unilateral),
            pending_unilateral_num=values(pending_unilateral_num),
            status=values(status),
            area=values(area)
    </insert>
</mapper>