<?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.fjhx.victoriatourist.mapper.jd.JdOrderMapper">
    <select id="getPage" resultType="com.fjhx.victoriatourist.entity.jd.vo.JdOrderVo">
        select
            jo.id,
            jo.code,
            jo.customer_id,
            jo.distribution_center,
            jo.country_id,
            jo.province_id,
            jo.city_id,
            jo.detailed_address,
            jo.contact_person,
            jo.contact_number,
            jo.amount,
            jo.status,
            jo.create_user,
            jo.create_time,
            jo.update_user,
            jo.update_time
        from jd_order jo
                 LEFT JOIN jd_order_details jod ON jod.jd_order_id = jo.id
                 LEFT JOIN bytesailing_item.product_info pi ON jod.product_id = pi.id
                 LEFT JOIN bytesailing_base.sys_dept de ON CAST(json_unquote(pi.victoriatourist_json -> '$.deptId') AS UNSIGNED) = de.dept_id
            ${ew.customSqlSegment}
    </select>
    <select id="getReceivePage" resultType="com.fjhx.victoriatourist.entity.jd.vo.JdOrderVo">
        SELECT
            jdo.id,
            jdo.code,
            jdo.customer_id,
            jdo.distribution_center,
            jdo.country_id,
            jdo.province_id,
            jdo.city_id,
            jdo.detailed_address,
            jdo.contact_person,
            jdo.contact_number,
            st.id stockTransferId,
            st.in_status,
            st.in_user_id,
            st.in_time
        FROM
            jd_order jdo
                JOIN stock_transfer st ON st.business_id = jdo.id
                LEFT JOIN jd_order_details jod ON jod.jd_order_id = jdo.id
                LEFT JOIN bytesailing_item.product_info pi ON jod.product_id = pi.id
            ${ew.customSqlSegment}
    </select>

</mapper>
