<?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="cn.iocoder.yudao.module.inspection.mapper.ShopInspectionGoodsMapper">
    <delete id="deleteByList">
        delete from shop_inspection_goods where id in
        <foreach collection="list" open="(" close=")" item="item" separator=",">
            #{item}
        </foreach>
    </delete>

    <select id="selectShopInspectionGoodsListWx" parameterType="cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods" resultType="cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods">
       select * from shop_inspection_goods
        <where>
            and partner_id = 888 and id!=888
            <if test="vo.id != null "> and id = #{vo.id}</if>
            <if test="vo.title != null  and title != ''"> and title like concat('%', #{vo.title}, '%')</if>
            <if test="vo.isSpecial != null "> and is_special = #{vo.isSpecial}</if>
        </where>
        order by order_num, id desc
    </select>

    <select id="selectShopInspectionGoodsById" parameterType="Long" resultType="cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods">
        select * from shop_inspection_goods
        where id = #{id}
    </select>

    <select id="listSystem" parameterType="cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods" resultType="cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods">
        SELECT
        sig.* ,smp.partner_name,sic.category_name
        FROM
        shop_inspection_goods sig
        INNER JOIN shop_mall_partners smp ON smp.partner_id = sig.partner_id AND smp.is_banned = '0'
        INNER JOIN shop_inspection_category sic ON sic.id = sig.goods_category_id
    <where>
        <if test="vo.id != null "> and sig.id = #{vo.id}</if>
        <if test="vo.title != null  and vo.title != ''"> and sig.title like concat('%', #{vo.title}, '%')</if>
        <if test="vo.goodsCategoryId!= null "> and sig.goods_category_id = #{vo.goodsCategoryId}</if>
        <if test="vo.partnerName!= null "> and smp.partner_name like concat('%',#{vo.partnerName},'%')</if>
        <if test="vo.partnerId!= null "> and sig.partner_id = #{vo.partnerId}</if>
    </where>
        ORDER BY FIELD(sig.listing_status,1,2,3,0), create_time desc
    </select>

    <select id="listPartnerGoods" parameterType="cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods" resultType="cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods">
        SELECT
        sig.* ,smp.partner_name,sic.category_name
        FROM
        shop_inspection_goods sig
        INNER JOIN shop_mall_partners smp ON smp.partner_id = sig.partner_id AND smp.is_banned = '0'
        INNER JOIN shop_inspection_category sic ON sic.id = sig.goods_category_id
        <where>
            and sig.deleted = '0' and smp.deleted = '0' and sic.deleted = '0'
            <if test="vo.id != null "> and sig.id = #{vo.id}</if>
            <if test="vo.title != null  and vo.title != ''"> and sig.title like concat('%', #{vo.title}, '%')</if>
            <if test="vo.goodsCategoryId!= null "> and sig.goods_category_id = #{vo.goodsCategoryId}</if>
            <if test="vo.partnerName!= null "> and smp.partner_name like concat('%',#{vo.partnerName},'%')</if>
            <if test="vo.partnerId!= null "> and sig.partner_id = #{vo.partnerId}</if>
            <if test="vo.isListing != null and vo.isListing != ''">and sig.is_listing = #{vo.isListing}</if>
        </where>
        ORDER BY sig.is_listing, sig.create_time desc
    </select>
</mapper>
