<?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.ReasonOrderRepairDetailMapper">

    <select id="getItfTblWxjsWxxmJyktUpload" parameterType="com.zfire.jiasm.syncdata.parameter.OrderPar" resultType="com.zfire.jiasm.syncdata.plus.entity.ItfTblWxjsWxxmJyktUpload">
        select a.out_id as fa_order_repair_data_info_id,
               a.out_id as wxxmguid,'guangfo' as created_by,
               a.create_time as created_date,'guangfo' as last_modified_by,
               a.update_time as last_modified_date,
               b.brand_wxjsguid as wxjsguid,ifnull(a.repair_item_id,'') as wxxmh,
               a.repair_item_name as mshu,ifnull(b.repair_fees,0) as wxfy,a.number as xxyyh,
               a.xxyyguid,b.wxjsmxguid as wxjsmxguid,a.create_time as cjsj,ifnull(a.repair_item_name,'') as mshu,
               a.repair_item_name as wxxmhmc,case b.flag when 'A' then '上门' else '送修' end as smorsx
        from order_repair_detail_reason a
                 left join order_repair_detail b on b.id=a.order_repair_detail_id
        where a.id =  #{request.id}
    </select>

    <select id="getItfTblAssignFeeUpload" parameterType="com.zfire.jiasm.syncdata.parameter.OrderPar" resultType="com.zfire.jiasm.syncdata.plus.entity.ItfTblAssignFeeUpload">
        select a.out_id as fa_order_repair_data_info_id,
               a.out_id as id,'guangfo' as created_by,
               a.create_time as created_date,'guangfo' as last_modified_by,
               a.update_time as last_modified_date,1 as flag,b.repair_fees as fee,
               a.remark as mshu,d.ref_dict_code as spid
        from order_repair_detail_reason a
                 left join order_repair_detail b on b.id=a.order_repair_detail_id
                 left join order_repair_detail_reason c on c.order_repair_detail_id=a.order_repair_detail_id
                 left join sys_dict_ref d on d.dict_code = #{request.mainId} and d.brand_id = #{request.brandId} and d.dict_type='MAIN_TYPE'
        where a.id = #{request.id}
    </select>

    <select id="getItfTblWxjsPjmxJyktUpload" parameterType="com.zfire.jiasm.syncdata.parameter.OrderPar" resultType="com.zfire.jiasm.syncdata.plus.entity.ItfTblWxjsPjmxJyktUpload">
        select a.out_id as fa_order_repair_part_info_id,b.wxjsmxguid as wxjsmxguid,
               'guangfo' as created_by,a.create_time as created_date,'guangfo' as last_modified_by,
               a.update_time as last_modified_date,b.brand_wxjsguid as wxjsguid,
               a.old_part_no as jpjbh,a.old_part_name as jpjmc,0 as jpjsl,0 as jpjdj,0 as jpjje,a.new_part_no as xpjbh,
               a.new_part_name as xpjmc,a.new_part_price as xpjdj,a.new_part_count as xpjsl,a.new_part_count*a.new_part_price as xpjje,
               a.new_part_no as pjtm,'' as jgrtm,'' as xgrtm,a.repair_item_id as pjwxxmh,'' as jpjwxxmhmc
        from order_repair_detail_reason a
                 left join order_repair_detail b on b.id=a.order_repair_detail_id
        where a.id = #{request.id}
    </select>

</mapper>
