<?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.bonus.core.allocation.advise.mapper.BasicsPlaintMapper">

    <select id="queryPlaints" resultType="com.bonus.core.allocation.advise.param.AppletPlaintParam">
        SELECT
            bc.complaint_id,
            bc.cust_id,
            ci.cust_name,
            bc.content,
            bc.complaint_picture,
            bc.mobile,
            bc.reply_content,
            bc.crtime,
            bc.canteen_id,
            ac.canteen_name
        FROM
            basics_complaint bc
                LEFT JOIN cust_info ci ON ci.cust_id = bc.cust_id
                LEFT JOIN alloc_canteen ac ON ac.canteen_id = bc.canteen_id
        WHERE
            bc.cust_id = #{custId}
          AND bc.source_type = #{sourceType}
    </select>
<!--&lt;!&ndash;    分页获取投诉建议&ndash;&gt;-->
<!--    <select id="selectPlaintPage" resultType="net.xnzn.core.allocation.advise.vo.BasicsComplaintPageVO">-->
<!--        select * from (-->
<!--        SELECT-->
<!--        bc.*,-->
<!--        CAST(bc.crtime as DATE) complaintDate,-->
<!--        ci.cust_name,-->
<!--        ci.cust_num,-->
<!--        cg.org_name,-->
<!--        ac.canteen_name,-->
<!--        ar.area_name,-->
<!--        ar.area_id-->
<!--        FROM-->
<!--        basics_complaint bc-->
<!--        LEFT JOIN cust_info ci ON ci.cust_id = bc.cust_id-->
<!--        LEFT JOIN cust_org cg ON ci.org_id = cg.org_id-->
<!--        LEFT JOIN alloc_canteen ac ON ac.canteen_id = bc.canteen_id-->
<!--        LEFT JOIN alloc_area ar ON ar.area_id = ac.area_id-->
<!--        <where>-->
<!--        <if test="dto.informContent != null and dto.informContent != '' ">-->
<!--          and bc.content like #{dto.informContent}-->
<!--        </if>-->
<!--        <if test="dto.canteenIds !=null and dto.canteenIds.size() >0 ">-->
<!--          and bc.canteen_id in-->
<!--            <foreach collection="dto.canteenIds" item="item" open="(" close=")" separator=",">-->
<!--                    #{item}-->
<!--                </foreach>-->
<!--            </if>-->
<!--            <if test="dto.startTime !=null and dto.endTime !=null ">-->
<!--              and  bc.crtime BETWEEN CONCAT(#{dto.startTime}, ' 00:00:00') AND CONCAT(#{dto.endTime}, ' 23:59:59')-->
<!--            </if>-->
<!--            <if test="dto.replyState != null ">-->
<!--                <if test="dto.replyState == 1 ">-->
<!--                    and bc.reply_content is null-->
<!--                </if>-->
<!--                <if test="dto.replyState == 2 ">-->
<!--                    and bc.reply_content is not null-->
<!--                </if>-->
<!--            </if>-->
<!--            <if test="dto.keyword != null and dto.keyword != ''">-->
<!--                AND (-->
<!--                ci.cust_name like concat('%', #{dto.keyword},'%')-->
<!--                or ci.cust_num like concat('%', #{dto.keyword},'%')-->
<!--                or bc.mobile like concat('%', #{dto.keyword},'%')-->
<!--                )-->
<!--            </if>-->
<!--            <if test="dto.sourceTypes !=null and dto.sourceTypes.size() >0 ">-->
<!--                and bc.source_type in-->
<!--                <foreach collection="dto.sourceTypes" item="item" open="(" close=")" separator=",">-->
<!--                    #{item}-->
<!--                </foreach>-->
<!--            </if>-->
<!--        </where>-->
<!--        ORDER BY-->
<!--            bc.uptime DESC-->
<!--            limit 9999-->
<!--        ) t-->
<!--    </select>-->
</mapper>
