<?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.yeejoin.amos.boot.module.hygf.api.mapper.DealerReviewMapper">

    <select id="queryForDealerReviewPage" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.ReviewDto" >

    select
    u.sequence_nbr sequenceNbr,
    u.`name`,
    c.legal_person_name legalPersonName,
    c.credit_code creditCode,
    u.head_name headName,
    u.head_phone headPhone,
    u.register_pcd registerPcd,
        (CASE
        WHEN u.blacklist=0 THEN '否'
        ELSE '是'
        END
        ) blacklist,
        (CASE
        WHEN u.audit_status=1 THEN '审核中'
        WHEN u.audit_status=2 THEN '完成'
        WHEN u.audit_status=3 THEN '不通过'
        END
        ) auditStatus,
        d.process_instance_id processInstanceId,
        d.process_definition_id processDefinitionId,
        d.task_id  taskId,
        d.node_routing nodeRouting,
        d.node_role nodeRole,
        d.next_process_node nextProcessNode,
        d.flow_task_id flowTaskId,
        d.plan_instance_id planInstanceId,
        u.admin_user_id  adminUserId,
        (select GROUP_CONCAT(hygf_regional_companies.regional_companies_name) from hygf_regional_companies where hygf_regional_companies.unit_info_id=u.sequence_nbr ) regionalCompaniesName
        from  hygf_commerce_info c
        LEFT JOIN hygf_unit_info u on c.unit_seq=u.sequence_nbr
        LEFT JOIN hygf_dealer_review d on d.unit_info_id=u.sequence_nbr
        <where>
            u.is_delete=0

            <if test="name != null and name != ''">
                AND u.`name` like concat('%',#{name},'%')
            </if>

        </where>
        ORDER BY u.audit_status ,u.rec_date DESC


    </select>




</mapper>