<?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.zfire.jiasm.syncdata.dao.mapper.AssignSatisfactionDownloadMapper">

    <select id="getSatisfaction" parameterType="com.zfire.jiasm.syncdata.parameter.ReAppointment" resultType="com.zfire.jiasm.syncdata.plus.entity.ItfTblAssignSatisfactionDownload">
        select b.id
        from itf_tbl_assign_satisfaction_download a
                 join order_base b on a.syn_req_id = #{request.id} and a.syn_status = 0 and a.pgid = b.pgid
                 inner join order_appraise c on b.id = c.order_base_id and c.type = 0
    </select>

    <select id="getOrderAppraise" parameterType="com.zfire.jiasm.syncdata.parameter.ReAppointment" resultType="com.zfire.jiasm.syncdata.plus.entity.OrderAppraise">
        select a.id as out_satisfaction_id,b.pgid as pid,b.id as order_base_id,
               case a.pjnr when '满意' then 'A'  when '一般' then 'B'  else 'C' end as appraise_status, a.pjnr as appraise_content,
               a.hfren as rvisit_nick_name,a.hfsj as rvisit_time,a.bmylx as negative_type,a.bmybeiz as negative_remark,a.bmysj as negative_time,
               a.sxlx as type,a.created_by as create_by,a.created_date as create_time,a.last_modified_by as update_by,a.last_modified_date as update_time
        from  itf_tbl_assign_satisfaction_download a join order_base b on a.pgid = b.pgid
        where a.syn_req_id = #{request.id} and a.syn_status = 0
    </select>


</mapper>
