123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417 |
- <?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.caimei365.commodity.mapper.SearchMapper">
- <sql id="Search_Product_List">
- p.productID as p_id,
- p.`name` as p_name,
- p.searchKey as p_keyword,
- p.tags as p_tags,
- p.mainImage as p_image,
- p.price1 as p_price,
- p.price1TextFlag as p_price_flag,
- p.productCode as p_code,
- p.sortIndex as p_sort,
- p.unit as p_unit,
- p.sellNumber as p_sales,
- p.favoriteTimes as p_favorite,
- p.brandID as p_brand_id,
- br.name as p_brand_name,
- p.shopID as p_supplier_id,
- sh.name as p_supplier_name,
- p.bigTypeID as p_category1_id,
- b.name as p_category1_name,
- p.smallTypeID as p_category2_id,
- s.name as p_category2_name,
- p.tinyTypeID as p_category3_id,
- t.name as p_category3_name,
- p.classifyId as p_classify_id,
- c.classifyName as p_classify_name,
- p.preferredFlag as p_preferred,
- p.productCategory as p_type,
- p.validFlag as p_valid,
- IFNULL(p.visibility,3) as p_visibility,
- p.price8Text as p_act_flag
- </sql>
- <sql id="Product_Joins">
- left join tinytype as t on p.tinyTypeID = t.tinyTypeID
- left join smalltype as s on p.smallTypeID = s.smallTypeID
- left join bigtype as b on p.bigTypeID = b.bigTypeID
- left join cm_products_classify as c on p.classifyId = c.id
- left join cm_brand as br on p.brandID = br.id
- left join shop as sh on p.shopID = sh.shopID
- </sql>
- <select id="searchProductById" resultType="com.caimei365.commodity.model.search.ProductDO">
- select <include refid="Search_Product_List"/>, p.productCategory
- from product as p
- <include refid="Product_Joins"/>
- where p.validFlag in (2,3,9) and p.productCategory = 1
- and p.productID = #{productId}
- </select>
- <select id="findProductCount" resultType="java.lang.Integer">
- select count(*)
- from product
- where validFlag in (2,3,9) and productCategory = 1
- </select>
- <select id="findProductInvalidCount" resultType="java.lang.Integer">
- select count(*)
- from product
- where validFlag not in (2,3,9) or productCategory != 1
- </select>
- <select id="findProductInvalidIds" resultType="java.lang.Integer">
- select productID
- from product
- where validFlag not in (2,3,9) or productCategory != 1
- </select>
- <select id="searchProductList" resultType="com.caimei365.commodity.model.search.ProductDO">
- select <include refid="Search_Product_List"/>
- from product as p
- <include refid="Product_Joins"/>
- where p.validFlag in (2,3,9) and productCategory = 1
- order by productID desc
- </select>
- <select id="countMallProduct" resultType="java.lang.Integer">
- select COUNT(*) from cm_mall_organize_products
- where productID=#{productId} and organizeID=1
- </select>
- <select id="searchMallProductByProductId" resultType="com.caimei365.commodity.model.search.MallProductDO">
- select
- m.id as m_id,
- m.organizeID as m_organize_id,
- m.productID as m_product_id,
- m.retailPrice as m_price,
- m.classifyID as m_classify_id,
- m.delFlag as m_valid,
- c.classifyName as m_classify_name
- from cm_mall_organize_products as m
- left join cm_mall_products_classify as c on m.classifyId = c.id
- where m.productID = #{productId} and m.organizeID = 1
- limit 1
- </select>
- <select id="getMallLadderPriceFlag" resultType="java.lang.Integer">
- select ladderPriceFlag
- from cm_mall_organize_products
- where productID = #{productId} and organizeID=1
- limit 1
- </select>
- <select id="getMallLowerLadderPrice" resultType="java.lang.Double">
- select MIN(buyPrice)
- from cm_mall_product_ladder_price
- where delFlag = '0'
- and productId = #{productId}
- </select>
- <select id="findMallIdByProductId" resultType="java.lang.Integer">
- select id
- from cm_mall_organize_products
- where productID = #{productId}
- limit 1
- </select>
- <select id="findMallInvalidIdsByProductIds" resultType="java.lang.Integer">
- select id
- from cm_mall_organize_products
- where productID IN
- <foreach collection="invalidIds" open="(" separator="," close=")" item="productId">
- #{productId}
- </foreach>
- </select>
- <!-- 供应商 -->
- <sql id="Search_Supplier_List">
- s.shopID as s_id,
- s.name as s_name,
- s.logo as s_logo,
- s.authorizationCertificateImage as s_license,
- s.businessScope as s_business,
- s.townID as s_town_id,
- CONCAT(p.name, c.name) as s_address,
- s.sortIndex as s_sort,
- s.status as s_valid
- </sql>
- <sql id="Supplier_Joins">
- left join town as t on s.townId = t.townID
- left join city as c on t.cityID = c.cityID
- left join province as p on c.provinceID = p.provinceID
- </sql>
- <select id="findSupplierCount" resultType="java.lang.Integer">
- select count(*)
- from shop
- where (status = 90 or status = 9)
- and shopID != 1252
- </select>
- <select id="findSupplierInvalidCount" resultType="java.lang.Integer">
- select count(*)
- from shop
- where status not in (90,9) or shopID = 1252
- </select>
- <select id="findSupplierInvalidIds" resultType="java.lang.Integer">
- select shopID
- from shop
- where status not in (90,9) or shopID = 1252
- </select>
- <select id="searchSupplierList" resultType="com.caimei365.commodity.model.search.SupplierDO">
- select <include refid="Search_Supplier_List"/>
- from shop as s
- <include refid="Supplier_Joins"/>
- where (status = 90 or status = 9)
- and shopID != 1252
- order by s.sortIndex
- </select>
- <select id="searchSupplierById" resultType="com.caimei365.commodity.model.search.SupplierDO">
- select <include refid="Search_Supplier_List"/>
- from shop as s
- <include refid="Supplier_Joins"/>
- where (status = 90 or status = 9)
- and shopID != 1252
- and s.shopID = #{supplierId}
- </select>
- <!-- 项目仪器 -->
- <sql id="Search_Equipment_List">
- e.id as e_id,
- e.title as e_name,
- e.precisehKey as e_keyword,
- e.headImage as e_image,
- e.docBoost as e_sort
- </sql>
- <select id="findEquipmentCount" resultType="java.lang.Integer">
- select count(*)
- from cm_page
- where type = 2 and enabledStatus = 1
- </select>
- <select id="findEquipmentInvalidCount" resultType="java.lang.Integer">
- select count(*)
- from cm_page
- where type != 2 or enabledStatus != 1
- </select>
- <select id="findEquipmentInvalidIds" resultType="java.lang.Integer">
- select id
- from cm_page
- where type != 2 or enabledStatus != 1
- </select>
- <select id="searchEquipmentList" resultType="com.caimei365.commodity.model.search.EquipmentDO">
- select <include refid="Search_Equipment_List"/>
- from cm_page as e
- where e.type = 2 and e.enabledStatus = 1
- order by e.docBoost desc
- </select>
- <select id="searchEquipmentById" resultType="com.caimei365.commodity.model.search.EquipmentDO">
- select <include refid="Search_Equipment_List"/>
- from cm_page as e
- where e.id = #{equipmentId}
- and e.type = 2 and e.enabledStatus = 1
- </select>
- <!-- 文章 -->
- <sql id="Search_Article_List">
- a.id as a_id,
- a.title as a_title,
- a.guidanceImage as a_image,
- a.publisher as a_publisher,
- a.pubdate as a_publish_date,
- a.recommendContent as a_intro,
- a.infoContent as a_content,
- (IFNULL(c.pv, 0) +IFNULL(c.num, 0) + IFNULL(a.basePv, 0) + IFNULL(a.basePraise, 0)) as a_pv,
- a.label as a_label,
- a.typeId as a_type_id,
- b.name as a_type_text,
- a.priorityIndex as a_sort
- </sql>
- <sql id="Article_Joins">
- left join info_type b on a.typeId = b.id
- left join info_praise c on a.id = c.infoId
- </sql>
- <select id="findArticleCount" resultType="java.lang.Integer">
- select count(*)
- from info
- where enabledStatus = 1
- </select>
- <select id="findArticleInvalidCount" resultType="java.lang.Integer">
- select count(*)
- from info
- where enabledStatus != 1
- </select>
- <select id="findArticleInvalidIds" resultType="java.lang.Integer">
- select id
- from info
- where enabledStatus != 1
- </select>
- <select id="searchArticleList" resultType="com.caimei365.commodity.model.search.ArticleDO">
- select <include refid="Search_Article_List"/>
- from info as a
- <include refid="Article_Joins"/>
- where a.enabledStatus = 1
- order by a.priorityIndex desc
- </select>
- <select id="searchArticleById" resultType="com.caimei365.commodity.model.search.ArticleDO">
- select <include refid="Search_Article_List"/>
- from info as a
- <include refid="Article_Joins"/>
- where a.id = #{articleId}
- and a.enabledStatus = 1
- </select>
- <select id="findLabelIdsByName" resultType="java.lang.Integer">
- select id
- from info_label
- where infoLabelStatus = 1
- and name in
- <foreach collection="labelTexts" item="label" open="(" close=")" index="index" separator=",">
- #{label}
- </foreach>
- group by name
- order by clickRate desc
- </select>
- <select id="findLabelNameById" resultType="java.lang.String">
- select name
- from info_label
- where infoLabelStatus = 1
- and id = #{labelId}
- limit 1
- </select>
- <!-- 搜索容错 商品列表 -->
- <select id="queryProduct" resultType="com.caimei365.commodity.model.search.ProductListVo">
- select
- p.productID as productId,
- p.`name` as name,
- p.mainImage as image,
- br.name as brandName,
- p.unit as unit,
- p.productCode as code,
- p.price1TextFlag as priceFlag,
- p.price1 as price,
- p.shopID as shopId,
- p.searchKey as keyword,
- p.price8Text as actFlag
- from product p
- left join cm_brand as br on p.brandID = br.id
- where p.productCategory = 1
- <choose>
- <when test="identity == 1">
- and p.validFlag in (2,3,9)
- </when>
- <when test="identity == 2">
- and p.validFlag = 2
- </when>
- <when test="identity == 4">
- and p.visibility in (2,3) and p.validFlag = 2
- </when>
- <otherwise>
- and p.visibility = 3 and p.validFlag = 2
- </otherwise>
- </choose>
- <if test="shopId != null and shopId != ''">
- and p.shopID = #{shopId}
- </if>
- <if test="bigTypeId != null and bigTypeId != ''">
- and p.bigTypeID = #{bigTypeId}
- </if>
- <if test="smallTypeId != null and smallTypeId != ''">
- and p.smallTypeID = #{smallTypeId}
- </if>
- <if test="tinyTypeId != null and tinyTypeId != ''">
- and p.tinyTypeID = #{tinyTypeId}
- </if>
- <if test="classifyId != null and classifyId != ''">
- and p.classifyId = #{classifyId}
- </if>
- <if test="keyword != null and keyword != ''">
- and p.name like concat('%',#{keyword},'%')
- </if>
- <choose>
- <when test="sortField != null and sortField != ''">
- <choose>
- <when test="sortField == 'price'">
- order by p.price1
- </when>
- <when test="sortField == 'sales'">
- order by p.sellNumber
- </when>
- <when test="sortField == 'favorite'">
- order by p.favoriteTimes
- </when>
- <otherwise>
- order by p.productID
- </otherwise>
- </choose>
- </when>
- <otherwise>
- order by p.productID
- </otherwise>
- </choose>
- <choose>
- <when test="sortType == 1">
- desc
- </when>
- <otherwise>
- asc
- </otherwise>
- </choose>
- </select>
- <!-- 搜索容错 供应商列表 -->
- <select id="querySupplier" resultType="com.caimei365.commodity.model.search.ShopListVo">
- select
- s.shopID as shopId,
- s.name as name,
- s.logo as logo,
- s.authorizationCertificateImage as license,
- s.businessScope as business,
- CONCAT(p.name, c.name) as address
- from shop as s
- left join town as t on s.townId = t.townID
- left join city as c on t.cityID = c.cityID
- left join province as p on c.provinceID = p.provinceID
- where (status = 90 or status = 9)
- and shopID != 1252
- and s.name like concat('%',#{keyword},'%')
- </select>
- <!-- 搜索容错 项目仪器列表 -->
- <select id="queryEquipment" resultType="com.caimei365.commodity.model.search.EquipmentListVo">
- select
- e.id as id,
- e.title as name,
- e.precisehKey as keyword,
- e.headImage as image
- from cm_page as e
- where e.type = 2 and e.enabledStatus = 1
- and e.title like concat('%',#{keyword},'%')
- order by e.docBoost desc
- </select>
- <!-- 搜索容错 文章列表 -->
- <select id="queryArticle" resultType="com.caimei365.commodity.model.search.ArticleListVo">
- select
- a.id as articleId,
- a.title as title,
- a.guidanceImage as image,
- a.publisher as publisher,
- a.pubdate as publishDate,
- a.recommendContent as intro,
- (IFNULL(c.pv, 0) +IFNULL(c.num, 0) + IFNULL(a.basePv, 0) + IFNULL(a.basePraise, 0)) as pv,
- a.typeId as typeId,
- b.name as typeText,
- a.label as labelText,
- from info as a
- left join info_type b on a.typeId = b.id
- left join info_praise c on a.id = c.infoId
- <where>
- a.enabledStatus = 1
- <if test="articleId != null">
- and a.id = #{articleId}
- </if>
- <if test="typeId != null">
- and a.typeId = #{typeId}
- </if>
- <if test="keyword != null and keyword != ''">
- and a.title like concat ('%',#{keyword},'%')
- </if>
- <if test="labelText != null">
- and a.label like concat ('%',#{labelText},'%')
- </if>
- </where>
- <choose>
- <when test="typeId != null or labelText != null">
- order by a.id desc
- </when>
- <otherwise>
- order by a.priorityIndex desc
- </otherwise>
- </choose>
- </select>
- </mapper>
|