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

    <select id="getAzsyktInfo" parameterType="com.zfire.jiasm.syncdata.parameter.OrderPar" resultType="com.zfire.jiasm.syncdata.plus.entity.OrderInstallDetail">
        select b.websit_id,b.id as order_base_id,p.id as order_product_id,b.worker_id,b.worker_name,b.worker_mobile,b.worker_idcard,
               IFNULL(a.njtm, '') as inside_code,IFNULL(a.kjmm, '') as inside_password,IFNULL(a.wjtm, '') as out_code,
               case when a.dnorsj = 1 then 'PC' else 'MOBILE' end as source,
               case a.aznr when '更换内机' then 'INSIDE' when '更换外机' then 'OUT' else 'INSIDE_OUT' end as type,IFNULL(a.beiz, '') as remark,
               case a.stat when 1120 then '1' when 1100 then '1' when 1110 then '2' end as status,a.jxno as inside_number,a.jxno as out_number,
               b.main_id,b.main_name,p.small_id,p.small_name,p.series_id,p.series_name,p.product_id,p.product_name,b.province_id,b.province,
               b.city_id,b.city,b.area_id,b.area,b.street_id,b.street,b.lat,b.lng,a.sjcjgps as lat_lng_address,
               if(length(a.sjcjgps)>100,left(a.sjcjgps,100),a.sjcjgps) as gps_address,0 as is_sync,IFNULL(a.jsdwxtbh, '') as settle_websit_id,
               a.zjssj as settle_time,a.last_modified_date as update_time,b.sale_type as sales_type,b.sale_websit_id as sales_websit_id,
               p.inside_num,p.out_num,a.pgguid,a.pgwcmxid,0 as detail_source,'NO' as is_cj_send,'NO' as is_wg_send,
               if(length(p.id)>50,left(p.id,50),p.id) as pgmxid,
               a.czren as operator_account,a.czren as operator_name,a.czwd as operator_websit_id,b.worker_id as main_worker_id,
               b.worker_name as main_worker_name,a.cjren as create_by,a.cjdt as create_time,a.last_modified_by as update_by,
               case a.installenvironment when 1 then 'YES' else 'NO' end as is_special,a.flbz as assist_remark,
               IFNULL(a.wcsj,a.czsj) as first_time,'' as buy_certificate_picture,'' as after_buy_certificate_picture
        from itf_tbl_az_wgmx_sykt_download a
                 left join order_base b on a.pgguid = b.pgguid
                 left join order_product p on a.pgguid = p.pgguid and b.id = p.order_base_id and a.pgmxid = p.pgmxid
        where a.syn_req_id = #{request.synReqId} and a.syn_status = 0 limit 1;
    </select>


</mapper>
