<?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.quality.QualityInfoMapper">
    <select id="getPage" resultType="com.fjhx.victoriatourist.entity.quality.vo.QualityInfoVo">
        select
            qi.id,
            qi.type,
            qi.`code`,
            qi.bussiness_id,
            qi.bussiness_code,
            qi.warehouse_id,
            qi.purchase_id,
            qi.purchase_code,
            qi.`status`,
            qi.result_type,
            qi.create_user,
            qi.create_time,
            qi.update_user,
            qi.update_time
        from quality_info qi
            ${ew.customSqlSegment}
    </select>
    <select id="getPage1" resultType="com.fjhx.victoriatourist.entity.quality.vo.QualityInfoVo">
        SELECT
            asr.id,
            p.`code`                                                     purchaseCode,
            p.supply_id,
            json_unquote(sw.victoriatourist_json - > '$.deliverGoodsId') deliverGoodsId,
            json_unquote(p.victoriatourist_json - > '$.contractCode')    contractCode,
            dg.logistics_company_code,
            dg.`code`                                                    logisticsCode,
            p.create_user                                                purchaseUserId,
            p.create_time                                                purchaseTime,
            asr.quality_status
        FROM arrival_stock_records asr
                 JOIN stock_wait sw ON asr.stock_wait_id = sw.id
                 JOIN purchase p ON sw.business_id = p.id
                 JOIN deliver_goods dg ON dg.id = json_unquote(sw.victoriatourist_json - > '$.deliverGoodsId')
            ${ew.customSqlSegment}
    </select>

</mapper>
