123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796 |
- <?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.yami.shop.dao.ProductMapper">
- <resultMap id="BaseResultMap" type="com.yami.shop.bean.model.Product">
- <id property="prodId" column="prod_id"/>
- <result property="prodName" column="prod_name"/>
- <result property="shopId" column="shop_id"/>
- <result property="oriPrice" column="ori_price"/>
- <result property="price" column="price"/>
- <result property="brief" column="brief"/>
- <result property="content" column="content"/>
- <result property="imgs" column="imgs"/>
- <result property="status" column="status"/>
- <result property="scorePrice" column="score_price"/>
- <result property="prodType" column="prod_type"/>
- <result property="activityId" column="activity_id"/>
- <result property="categoryId" column="category_id"/>
- <result property="soldNum" column="sold_num"/>
- <result property="totalStocks" column="total_stocks"/>
- <result property="pic" column="pic"/>
- <result property="deliveryMode" column="delivery_mode"/>
- <result property="deliveryTemplateId" column="delivery_template_id"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="putawayTime" column="putaway_time"/>
- <result property="version" column="version"/>
- </resultMap>
- <resultMap id="tagProductMap" type="com.yami.shop.bean.app.dto.TagProductDto">
- <result property="id" column="id"/>
- <result property="title" column="title"/>
- <result property="seq" column="seq"/>
- <result property="style" column="style"/>
- <collection property="productDtoList" javaType="list" ofType="com.yami.shop.bean.app.dto.ProductDto">
- <result property="prodId" column="prod_id"/>
- <result property="prodName" column="prod_name"/>
- <result property="shopId" column="shop_id"/>
- <result property="price" column="price"/>
- <result property="brief" column="brief"/>
- <result property="imgs" column="imgs"/>
- <result property="oriPrice" column="ori_price"/>
- <result property="categoryId" column="category_id"/>
- <result property="totalStocks" column="total_stocks"/>
- <result property="pic" column="pic"/>
- </collection>
- </resultMap>
- <resultMap id="productAndSkuListMap" type="com.yami.shop.bean.param.ProductExportParam">
- <id property="prodId" column="prod_id"/>
- <result property="prodName" column="prod_name"/>
- <result property="shopId" column="shop_id"/>
- <result property="oriPrice" column="ori_price"/>
- <result property="transName" column="trans_name"/>
- <result property="brandName" column="brand_name"/>
- <result property="price" column="price"/>
- <result property="brief" column="brief"/>
- <result property="content" column="content"/>
- <result property="imgs" column="imgs"/>
- <result property="status" column="status"/>
- <result property="categoryName" column="category_name"/>
- <result property="shopCategoryName" column="shop_category_name"/>
- <result property="soldNum" column="sold_num"/>
- <result property="totalStocks" column="total_stocks"/>
- <result property="pic" column="pic"/>
- <result property="deliveryMode" column="delivery_mode"/>
- <result property="putawayTime" column="putaway_time"/>
- <collection property="skuList" javaType="list" ofType="com.yami.shop.bean.model.Sku">
- <id column="sku_id" jdbcType="BIGINT" property="skuId" />
- <result column="prod_id" jdbcType="BIGINT" property="prodId" />
- <result column="properties" jdbcType="VARCHAR" property="properties" />
- <result column="sku_prod_name" jdbcType="VARCHAR" property="prodName" />
- <result column="sku_ori_price" jdbcType="DECIMAL" property="oriPrice" />
- <result column="sku_price" jdbcType="DECIMAL" property="price" />
- <result column="weight" jdbcType="DECIMAL" property="weight" />
- <result column="volume" jdbcType="DECIMAL" property="volume" />
- <result column="stocks" jdbcType="INTEGER" property="stocks" />
- <result column="sku_score" jdbcType="INTEGER" property="skuScore" />
- <result column="actual_stocks" jdbcType="INTEGER" property="actualStocks" />
- <result column="status" jdbcType="TINYINT" property="status" />
- <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
- <result column="rec_time" jdbcType="TIMESTAMP" property="recTime" />
- <result column="party_code" jdbcType="VARCHAR" property="partyCode" />
- <result column="model_id" jdbcType="VARCHAR" property="modelId" />
- <result column="sku_pic" jdbcType="VARCHAR" property="pic" />
- <result column="sku_name" jdbcType="VARCHAR" property="skuName" />
- <result column="is_delete" jdbcType="INTEGER" property="isDelete"/>
- </collection>
- </resultMap>
- <resultMap id="ProdResultMap" type="com.yami.shop.bean.app.dto.ProductDto">
- <id column="prod_id" jdbcType="BIGINT" property="prodId"/>
- <result column="prod_name" jdbcType="VARCHAR" property="prodName"/>
- <result column="pic" jdbcType="VARCHAR" property="pic"/>
- </resultMap>
- <sql id="productDtoWithNoContent_SQL">
- p.`prod_id`,
- p.`shop_id`,
- p.`prod_name`,
- p.`pic`,
- p.`price`,
- p.`ori_price`,
- p.`brief`,
- p.`imgs`,
- p.`category_id`,
- p.`total_stocks`,
- p.status
- </sql>
- <sql id="prodWithNoContent_SQL">
- p.prod_id,
- p.pic,
- p.prod_name,
- p.price,
- p.brief,
- p.shop_id,
- p.status
- </sql>
- <update id="updateStocks" parameterType="com.yami.shop.bean.model.Product">
- update tz_prod set total_stocks = total_stocks - #{prod.totalStocks} ,version = version + 1 where prod_id = #{prod.prodId} and #{prod.totalStocks} <= total_stocks
- </update>
- <select id="getProductByProdNameAndShopId" resultType="com.yami.shop.bean.model.Product">
- select * from tz_prod where prod_name = #{prodName} and shop_id = #{shopId}
- </select>
- <select id="doGetById" resultType="com.yami.shop.bean.model.Product">
- SELECT
- tp.prod_id,
- MAX(tp.prod_name) AS prod_name,
- tcs.shop_id AS shop_id,
- MAX(tp.brand_id) AS brand_id,
- MAX(tp.brand_name) AS brand_name,
- MAX(tp.ori_price) AS ori_price,
- MAX(tss.shop_sku_price) AS price,
- MAX(tp.score_price) AS score_price,
- MAX(tp.brief) AS brief,
- MAX(tp.video) AS video,
- MAX(tp.pic) AS pic,
- MAX(tp.content) AS content,
- MAX(tp.imgs) AS imgs,
- MAX(tp.status) AS status,
- MAX(tp.is_delete) AS is_delete,
- MAX(tp.shop_category_id) AS shop_category_id,
- MAX(tp.category_id) AS category_id,
- MAX(tp.hb_front_category_id) AS hb_front_category_id,
- MAX(tp.sold_num) AS sold_num,
- SUM(tss.shop_sku_stocks) AS total_stocks,
- MAX(tp.delivery_mode) AS delivery_mode,
- MAX(tp.delivery_template_id) AS delivery_template_id,
- MAX(tp.create_time) AS create_time,
- MAX(tp.update_time) AS update_time,
- MAX(tp.putaway_time) AS putaway_time,
- MAX(tp.version) AS version,
- MAX(tp.prod_type) AS prod_type,
- MAX(tp.activity_id) AS activity_id,
- MAX(tp.sup_id) AS sup_id,
- MAX(tp.hb_spu_id) AS hb_spu_id,
- MAX(tp.hb_status) AS hb_status
- FROM tz_prod AS tp
- LEFT JOIN tz_shop_sku AS tss ON tp.prod_id = tss.spu_id
- LEFT JOIN tz_channel_shop AS tcs ON tss.shop_id = tcs.shop_id
- WHERE tp.prod_id = #{prodId}
- AND tcs.channel_id = #{platform}
- GROUP BY
- tp.prod_id,
- tcs.shop_id
- LIMIT 1
- </select>
- <update id="returnStock">
- <foreach collection="prodCollect" item="changeStocks" index="prodId" separator=";">
- update tz_prod set total_stocks = total_stocks + #{changeStocks} where prod_id = #{prodId}
- </foreach>
- </update>
- <select id="pageByTagId" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT
- <include refid="prodWithNoContent_SQL"/>
- FROM tz_prod p
- LEFT JOIN tz_prod_tag_reference ptr
- ON ptr.`prod_id` = p.`prod_id`
- LEFT JOIN tz_prod_tag pt
- ON pt.`id` = ptr.`tag_id`
- WHERE pt.`id` = #{tagId}
- AND p.status = 1
- ORDER BY p.`update_time` DESC
- </select>
- <select id="pageByPutawayTime" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT
- <include refid="prodWithNoContent_SQL"/>
- FROM tz_prod p
- WHERE p.`status` = 1 AND p.prod_type =0
- ORDER BY p.putaway_time DESC
- </select>
- <select id="pageByScore" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT p.*
- FROM tz_prod p
- WHERE p.`status` = 1
- and p.prod_type = 3
- ORDER BY p.putaway_time DESC
- </select>
- <select id="moreBuyProdList" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT
- <include refid="prodWithNoContent_SQL"/>
- FROM tz_prod p
- WHERE p.`status` = 1 AND p.prod_type =0
- ORDER BY p.`sold_num` DESC, p.`update_time` DESC
- </select>
- <select id="tagProdList" resultMap="tagProductMap">
- SELECT pt.*,
- <include refid="prodWithNoContent_SQL"/>
- FROM tz_prod_tag pt -- 获取分组信息
- LEFT JOIN
- (-- 分组获取各组前6个
- SELECT ptr.* FROM tz_prod_tag_reference ptr
- INNER JOIN tz_prod p3 ON p3.`prod_id` = ptr.`prod_id` AND p3.`status` =1
- WHERE
- (SELECT COUNT(0) FROM tz_prod_tag_reference prt2
- INNER JOIN tz_prod p2 ON p2.`prod_id` = prt2.`prod_id` AND p2.`status` =1
- WHERE prt2.`tag_id` = ptr.`tag_id` AND prt2.`create_time` > ptr.`create_time`)<6
- ORDER BY ptr.`tag_id`,ptr.`create_time` DESC
- )AS temp
- ON temp.`tag_id` = pt.`id`
- LEFT JOIN tz_prod p -- 获取商品详细信息
- ON p.`prod_id` = temp.`prod_id`
- ORDER BY pt.`seq` DESC
- </select>
- <select id="pageByDiscountId" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT p.*
- FROM tz_discount_prod dp
- LEFT JOIN tz_prod p ON dp.prod_id = p.prod_id AND p.prod_type =0
- WHERE p.status= 1 AND dp.discount_id = #{discountId}
- </select>
- <select id="getSearchProdDtoPageByProdName" resultType="com.yami.shop.bean.dto.SearchProdDto">
- select
- any_value(p.prod_id) as prod_id,
- any_value(p.pic) as pic,
- any_value(p.prod_name) as prod_name,
- any_value(p.price) as price,
- any_value(p.brief) as brief,
- any_value(p.shop_id) as shopId,
- count(pc.prod_comm_id) as prod_comm_number,
- count( CASE WHEN evaluate = 0 THEN prod_comm_id ELSE null END ) AS praise_number
- from
- tz_prod p
- left join tz_prod_comm pc on p.prod_id=pc.prod_id and pc.`status`=1
- where 1 = 1 and p.`status` = 1
- <if test="searchParam.prodName != null and searchParam.prodName != ''">
- and prod_name like concat('%',#{searchParam.prodName} ,'%')
- </if>
- <if test="searchParam.shopId != null">
- and p.shop_id = #{searchParam.shopId}
- </if>
- <if test="searchParam.categoryId != null">
- and p.category_id = #{searchParam.categoryId}
- </if>
- <if test="searchParam.shopCategoryId != null">
- and p.shop_category_id = #{searchParam.shopCategoryId}
- </if>
- <if test="searchParam.prodType != null and searchParam.isAllProdType == null">
- and p.prod_type = #{searchParam.prodType}
- </if>
- <if test="searchParam.isAllProdType == true">
- and p.prod_type in (0,1,2)
- </if>
- GROUP BY p.prod_id
- <if test="searchParam.sort == 0">
- ORDER BY any_value(p.update_time)
- </if>
- <if test="searchParam.sort == 1">
- ORDER BY any_value(p.sold_num)
- </if>
- <if test="searchParam.sort == 2">
- ORDER BY any_value(p.price)
- </if>
- <if test="searchParam.orderBy == 0">
- asc
- </if>
- <if test="searchParam.orderBy == 1">
- desc
- </if>
- <if test="searchParam.sort == 1">
- , any_value(p.prod_id) DESC
- </if>
- </select>
- <select id="listByShopId" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT
- <include refid="prodWithNoContent_SQL"/>
- FROM tz_prod p
- WHERE p.`status` = 1
- <if test="shopId != 0">
- AND p.shop_id = #{shopId}
- </if>
- ORDER BY p.`sold_num` DESC, p.`update_time` DESC
- </select>
- <select id="listBySuitableProdTypeAndCouponIdAndShopId" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT
- <include refid="prodWithNoContent_SQL"/>
- FROM
- tz_prod p
- WHERE p.`status` = 1
- <if test="shopId != 0">
- AND p.shop_id = #{shopId}
- </if>
- AND p.`prod_id`
- <if test="suitableProdType == 1">
- IN
- </if>
- <if test="suitableProdType == 2">
- NOT IN
- </if>
- (SELECT
- cp.`prod_id`
- FROM
- tz_coupon_prod cp
- WHERE cp.`coupon_id` = #{couponId})
- ORDER BY p.`sold_num` DESC,p.`update_time` DESC
- </select>
- <select id="collectionProds" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT
- <include refid="prodWithNoContent_SQL"/>
- FROM tz_prod p
- WHERE p.`prod_id` IN
- (SELECT uc.`prod_id` FROM tz_user_collection uc
- WHERE uc.user_id = #{userId})
- </select>
- <resultMap id="prodAndSkuListMap" type="com.yami.shop.bean.dto.ProdAndSkuListsDto">
- <result property="prodId" column="prod_id"/>
- <result property="prodName" column="prod_name"/>
- <collection property="skuDtoList" javaType="list" ofType="com.yami.shop.bean.app.dto.SkuDto">
- <result property="stocks" column="stocks"/>
- <result property="skuId" column="sku_id"/>
- <result property="price" column="price"/>
- <result property="skuName" column="sku_name"/>
- </collection>
- </resultMap>
- <select id="getProdAndSkuLists" resultMap="prodAndSkuListMap">
- SELECT
- p.`prod_id`,
- p.`prod_name`,
- s.`price`,
- s.`stocks`,
- s.`sku_id`,
- s.`sku_name`
- FROM
- tz_prod p
- LEFT JOIN tz_sku s ON s.`prod_id` = p.`prod_id`
- WHERE p.`prod_id` IN
- <foreach collection="prodIds" item="prodId" open="(" close=")" separator=",">
- #{prodId}
- </foreach>
- </select>
- <update id="updateProductToGroup">
- UPDATE tz_prod p SET p.`activity_id` = #{groupActivityId},p.`prod_type`=1 WHERE p.`prod_id` IN
- <!--UPDATE tz_prod p SET p.`activity_id` = #{groupActivityId},p.`prod_type`=1 WHERE p.`prod_id` IN-->
- <foreach collection="prodIds" item="prodId" open="(" close=")" separator=",">
- #{prodId}
- </foreach>
- </update>
- <update id="updateProductToUnGroup">
- UPDATE tz_prod p SET p.`activity_id` = NULL,p.`prod_type`=0 WHERE p.`prod_id` =#{prodId}
- <!--UPDATE tz_prod p SET p.`group_activity_id` = 0 WHERE p.`prod_id` =#{prodId}-->
- </update>
- <update id="updateToUnGroupByGroupActivityId">
- UPDATE tz_prod p SET p.`activity_id` = NULL,p.`prod_type`=0 WHERE p.`activity_id` =#{groupActivityId}
- <!--UPDATE tz_prod p SET p.`group_activity_id` = 0 WHERE p.`activity_id` =#{groupActivityId}-->
- </update>
- <select id="listByActivityId" resultType="com.yami.shop.bean.model.Product">
- SELECT * FROM tz_prod p WHERE p.`activity_id` = 4 AND p.`prod_type` = 1 AND p.`status` = 1
- <!--SELECT * FROM tz_prod p WHERE p.`group_activity_id` = #{groupActivityId} AND p.`status` = 1-->
- </select>
- <update id="updateToApply">
- update tz_prod p set p.status = 3,p.update_time=now() where p.prod_id = #{prodId}
- </update>
- <update id="updateToShopOffline">
- update tz_prod p set p.status = 0,p.update_time=now() where p.prod_id = #{prodId}
- </update>
- <update id="updateToOffline">
- update tz_prod p set p.status = 2,p.update_time=now() where p.prod_id = #{prodId}
- </update>
- <update id="updateSoldNum">
- <foreach collection="orderItems" item="orderItem" separator=";">
- update tz_prod p set p.sold_num = p.sold_num + #{orderItem.prodCount},p.update_time=now() where p.prod_id = #{orderItem.prodId}
- </foreach>
- </update>
- <update id="offlineProdByShopId">
- UPDATE tz_prod p SET p.`status` = 0 WHERE p.`shop_id` = #{shopId} AND p.`status` = 1
- </update>
- <select id="getcouponProdList" resultMap="ProdResultMap">
- SELECT prod_id,prod_name,pic FROM tz_prod
- WHERE shop_id = #{shopId}
- <if test="ids != null">
- AND prod_id NOT IN
- <foreach collection="ids" item="id" open="(" close=")" separator=",">
- #{id}
- </foreach>
- </if>
- LIMIT 0,3
- </select>
- <select id="getPageAndShopName" resultType="com.yami.shop.bean.model.Product">
- SELECT p.*,s.shop_name FROM tz_prod p
- LEFT JOIN tz_shop_detail s
- ON p.shop_id = s.shop_id
- <where>
- p.status != -1 AND prod_type = 0
- <if test="product.status != null">
- AND p.status = #{product.status}
- </if>
- <if test="product.prodName != null">
- AND p.prod_name LIKE concat('%',#{product.prodName},'%')
- </if>
- <if test="product.shopName != null">
- AND s.shop_name LIKE concat('%',#{product.shopName},'%')
- </if>
- <if test="product.categoryId != null">
- AND p.category_id = #{product.categoryId}
- </if>
- </where>
- ORDER BY putaway_time DESC
- </select>
- <select id="getProdsByOrderNumber" resultType="com.yami.shop.bean.param.ProdOrderParam">
- SELECT oi.*,p.category_id FROM tz_order_item oi
- LEFT JOIN tz_prod p ON p.`prod_id` = oi.`prod_id`
- WHERE oi.order_number = #{orderNumber}
- </select>
- <select id="listProdsByProdParam" resultMap="productAndSkuListMap">
- SELECT p.*,s.*,s.prod_name AS sku_prod_name,s.pic AS sku_pic,s.ori_price AS sku_ori_price,s.price AS sku_price,
- b.brand_name,t.trans_name,stc.category_name as shop_category_name,tc.category_name
- FROM
- tz_prod p
- LEFT JOIN
- tz_brand b ON b.`brand_id` = p.`brand_id`
- LEFT JOIN
- tz_transport t ON t.`transport_id` = p.`delivery_template_id`
- LEFT JOIN
- tz_sku s ON s.`prod_id` = p.`prod_id`
- LEFT JOIN
- tz_category tc ON tc.`category_id` = p.`category_id`
- LEFT JOIN
- tz_category stc ON stc.`category_id` = p.`shop_category_id`
- WHERE s.`is_delete` = 0 AND p.`status` = #{productParam.status} AND p.shop_id = #{productParam.shopId}
- </select>
- <select id="pageProducts" resultType="com.yami.shop.bean.model.Product">
- SELECT
- prod_name,prod_id,score_price,shop_category_id,pic,video,content,activity_id,delivery_mode,price,
- shop_id,brief,imgs,putaway_time,sold_num,total_stocks,update_time,prod_type,
- VERSION,ori_price,create_time,brand_id,delivery_template_id,category_id,STATUS
- FROM
- tz_prod p
- <where>
- shop_id = #{product.shopId} and STATUS = 1 AND prod_type = 0
- <if test="product.prodName != null">
- AND p.prod_name LIKE concat('%',#{product.prodName},'%')
- </if>
- <if test="product.isDistribution != null and product.isDistribution == 1">
- AND p.`prod_id` NOT IN (SELECT prod_id FROM `tz_distribution_prod`)
- </if>
- <if test="product.shopCategoryId != null">
- AND p.shop_category_id = #{product.shopCategoryId}
- </if>
- </where>
- ORDER BY putaway_time DESC
- </select>
- <select id="getSearchProdDtoPageByCategory" resultType="com.yami.shop.bean.dto.SearchProdDto">
- select
- any_value(p.prod_id) as prod_id,
- any_value(p.pic) as pic,
- any_value(p.prod_name) as prod_name,
- any_value(p.price) as price,
- any_value(p.brief) as brief,
- count(pc.prod_comm_id) as prod_comm_number,
- count( CASE WHEN evaluate = 0 THEN prod_comm_id ELSE null END ) AS praise_number
- from
- tz_prod p
- left join tz_prod_comm pc on p.prod_id=pc.prod_id and pc.`status`=1
- where 1 = 1 and p.`status` = 1 and prod_type = 0
- <if test="searchParam.prodName != null and searchParam.prodName != ''">
- and prod_name like concat('%',#{searchParam.prodName} ,'%')
- </if>
- <if test="searchParam.shopId != null">
- and p.shop_id = #{searchParam.shopId}
- </if>
- <if test="searchParam.categoryId != null">
- and p.category_id = #{searchParam.categoryId}
- </if>
- <if test="searchParam.shopCategoryId != null">
- and p.shop_category_id = #{searchParam.shopCategoryId}
- </if>
- <if test="searchParam.prodType != null">
- and p.prod_type = #{searchParam.prodType}
- </if>
- GROUP BY p.prod_id
- <if test="searchParam.sort == 0">
- ORDER BY any_value(p.update_time)
- </if>
- <if test="searchParam.sort == 1">
- ORDER BY any_value(p.sold_num)
- </if>
- <if test="searchParam.sort == 2">
- ORDER BY any_value(p.price)
- </if>
- <if test="searchParam.orderBy == 0">
- asc
- </if>
- <if test="searchParam.orderBy == 1">
- desc
- </if>
- <if test="searchParam.sort == 1">
- , any_value(p.prod_id) DESC
- </if>
- </select>
- <update id="updateProduct">
- UPDATE tz_prod
- SET shop_category_id=#{product.shopCategoryId}, pic=#{product.pic}, video=#{product.video}, content=#{product.content},
- delivery_mode=#{product.deliveryMode},price=#{product.price}, prod_name=#{product.prodName}, brief=#{product.brief},
- imgs=#{product.imgs}, total_stocks=#{product.totalStocks}, update_time=#{product.updateTime},ori_price=#{product.oriPrice},
- delivery_template_id=#{product.deliveryTemplateId}, category_id=#{product.categoryId}, status=#{product.status},brand_id=#{product.brandId}
- WHERE prod_id=#{product.prodId}
- </update>
- <update id="offlineProdByCategoryId">
- UPDATE
- tz_prod
- SET
- `status` = 0
- WHERE `category_id` = #{categoryId}
- </update>
- <select id="queryShop" resultType="com.yami.shop.bean.model.ShopDetail">
- select
- sd.shop_id shopId,
- shop_name shopName,
- ( 6371 * acos( cos( radians(#{lat}) ) * cos( radians( shop_lat ) ) * cos( radians( shop_lng ) - radians(#{lon}) ) + sin( radians(#{lat}) ) * sin( radians( shop_lat ) ) ) ) AS distance
- from
- tz_shop_detail sd
- right join tz_transport2 tp on tp.shop_id = sd.shop_id
- having distance <![CDATA[ <= ]]> #{distance}
- order by distance
- </select>
- <select id="pageByPutawayTimeNew" resultType="com.yami.shop.bean.app.dto.ProductDto">
- SELECT
- p.prod_id,
- p.imgs pic,
- p.prod_name,
- p.price,
- p.brief,
- p.shop_id,
- p.status
- FROM tz_prod p
- left join tz_shop_detail sd on p.shop_id = sd.shop_id
- WHERE p.`status` = 1 AND p.prod_type =0
- <if test="list != null">
- and p.shop_id in
- <foreach collection="list" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- </if>
- ORDER BY p.putaway_time DESC
- </select>
- <select id="getSearchProdDtoPageByProdNameNew" resultType="com.yami.shop.bean.dto.SearchProdDto">
- select
- any_value(p.prod_id) as prod_id,
- any_value(p.imgs) as pic,
- any_value(p.prod_name) as prod_name,
- MIN(tcp.channel_prod_price) as price,
- any_value(p.brief) as brief,
- any_value ( tss.shop_id ) AS shopId,
- any_value ( tss.self_label_id ) AS selfLabelId,
- any_value ( tss.return_label_id ) AS returnLabelId,
- any_value ( tss.hot_label_id ) AS hotLabelId,
- count(pc.prod_comm_id) as prod_comm_number,
- count( CASE WHEN evaluate = 0 THEN prod_comm_id ELSE null END ) AS praise_number,
- (6371 * acos(cos(radians(#{searchParam.lat})) * cos(radians(shop_lat)) * cos(radians(shop_lng) -
- radians(#{searchParam.lon}) ) + sin(radians(#{searchParam.lat})) * sin(radians(shop_lat)))) distance
- from
- tz_shop_sku tss
- LEFT JOIN tz_prod p ON p.prod_id = tss.spu_id
- LEFT JOIN tz_shop_detail sd ON sd.shop_id = tss.shop_id
- LEFT JOIN tz_prod_comm pc ON p.prod_id = pc.prod_id
- LEFT JOIN tz_channel_prod tcp ON tss.sku_id = tcp.sku_id
- where 1 = 1 and p.`status` = 1 and tcp.is_delete=0 and tss.shop_id in
- <foreach collection="list" item="item" separator="," open="(" close=")">
- #{item}
- </foreach>
- <if test="searchParam.prodName != null and searchParam.prodName != ''">
- and prod_name like concat('%',#{searchParam.prodName} ,'%')
- </if>
- <if test="searchParam.shopId != null">
- and tss.shop_id = #{searchParam.shopId}
- </if>
- <if test="searchParam.platform != null">
- and tcp.channel_id = #{searchParam.platform}
- </if>
- <if test="searchParam.categoryId != null">
- and p.category_id = #{searchParam.categoryId}
- </if>
- <if test="searchParam.shopCategoryId != null">
- and p.shop_category_id = #{searchParam.shopCategoryId}
- </if>
- <if test="searchParam.prodType != null and searchParam.isAllProdType == null">
- and p.prod_type = #{searchParam.prodType}
- </if>
- <if test="searchParam.isAllProdType == true">
- and p.prod_type in (0,1,2)
- </if>
- GROUP BY p.prod_id
- HAVING distance <![CDATA[<=]]> #{searchParam.distance}
- <if test="searchParam.sort == 0">
- ORDER BY any_value(p.update_time)
- </if>
- <if test="searchParam.sort == 1">
- ORDER BY any_value(p.sold_num)
- </if>
- <if test="searchParam.sort == 2">
- ORDER BY any_value(p.price)
- </if>
- <if test="searchParam.sort == 3">
- ORDER BY distance
- </if>
- <if test="searchParam.orderBy == 0">
- asc
- </if>
- <if test="searchParam.orderBy == 1">
- desc
- </if>
- <if test="searchParam.sort == 1">
- , any_value(p.prod_id) DESC
- </if>
- </select>
- <select id="getSalesVolume" resultType="java.lang.Integer">
- select ifnull(sum(oi.prod_count),0) from tz_order o
- join tz_order_item oi on oi.order_number=o.order_number
- where oi.prod_id=#{prodId} and o.hb_order_status=80
- </select>
- <select id="getSearchProdDtoPageByProdName2" resultType="com.yami.shop.bean.dto.SearchProdDto">
- select t.*,t1.salesVolume from (
- select
- any_value(p.prod_id) as prod_id,
- any_value(p.pic) as pic,
- any_value(p.prod_name) as prod_name,
- any_value(p.price) as price,
- any_value(p.brief) as brief,
- any_value(p.shop_id) as shopId,
- any_value(p.update_time) as update_time
- from
- tz_prod p
- where 1 = 1 and p.`status` = 1
- <if test="searchParam.prodName != null and searchParam.prodName != ''">
- and prod_name like concat('%',#{searchParam.prodName} ,'%')
- </if>
- <if test="searchParam.shopId != null">
- and p.shop_id = #{searchParam.shopId}
- </if>
- <if test="searchParam.categoryId != null">
- and p.shop_category_id = #{searchParam.categoryId}
- </if>
- <if test="searchParam.shopCategoryId != null">
- and p.shop_category_id = #{searchParam.shopCategoryId}
- </if>
- <if test="searchParam.prodType != null and searchParam.isAllProdType == null">
- and p.prod_type = #{searchParam.prodType}
- </if>
- <if test="searchParam.isAllProdType == true">
- and p.prod_type in (0,1,2)
- </if>
- GROUP BY p.prod_id
- ) t left JOIN (
- select oi.prod_id,ifnull(sum(oi.prod_count),0) as salesVolume from tz_order o
- join tz_order_item oi on oi.order_number=o.order_number
- where o.hb_order_status=80 GROUP BY oi.prod_id) t1 on t.prod_id = t1.prod_id
- <if test="searchParam.sort == 0">
- ORDER BY t.update_time
- </if>
- <if test="searchParam.sort == 1">
- ORDER BY t1.salesVolume
- </if>
- <if test="searchParam.sort == 2">
- ORDER BY t.price
- </if>
- <if test="searchParam.orderBy == 0">
- asc
- </if>
- <if test="searchParam.orderBy == 1">
- desc
- </if>
- <if test="searchParam.sort == 1">
- , t.prod_id DESC
- </if>
- </select>
- <select id="listProdByCategoryIdAndShopId" parameterType="com.yami.shop.bean.dto.ProdByCategoryIdAndShopIdDTO" resultType="com.yami.shop.bean.model.Product">
- SELECT
- p.*
- FROM
- tz_prod p
- INNER JOIN tz_category c ON p.shop_category_id = c.category_id
- WHERE
- c.parent_id = #{prodByCategoryIdAndShopIdDTO.categoryId}
- AND p.STATUS = 1
- AND c.STATUS = 1
- AND p.shop_id = #{prodByCategoryIdAndShopIdDTO.shopId}
- ORDER BY
- p.create_time DESC
- </select>
- <select id="listProdByCIdAndSId" parameterType="com.yami.shop.bean.dto.ProdByCategoryIdAndShopIdDTO" resultType="com.yami.shop.bean.model.Product">
- SELECT
- p.*
- FROM
- tz_prod p
- LEFT JOIN tz_category_prod tcp ON p.prod_id=tcp.prod_id
- LEFT JOIN tz_shop_category tsc ON tcp.`code`=tsc.`code`
- WHERE
- p.STATUS = 1
- AND tcp.is_delete = 0
- AND tsc.is_delete = 0
- AND p.shop_id=#{prodByCategoryIdAndShopIdDTO.shopId}
- AND tsc.id=#{prodByCategoryIdAndShopIdDTO.categoryId}
- ORDER BY
- p.create_time DESC
- </select>
- <select id="listProdByCategoryIdAndShopId2" parameterType="com.yami.shop.bean.dto.ProdByCategoryIdAndShopIdDTO" resultType="com.yami.shop.bean.model.Product">
- select t.*,t1.salesVolume from (
- SELECT
- p.*
- FROM
- tz_prod p
- INNER JOIN tz_category c ON p.shop_category_id = c.category_id
- WHERE
- c.category_id = #{prodByCategoryIdAndShopIdDTO.categoryId}
- AND p.STATUS = 1
- AND c.STATUS = 1
- AND p.shop_id = #{prodByCategoryIdAndShopIdDTO.shopId}
- ) t left join (select oi.prod_id,ifnull(sum(oi.prod_count),0) as salesVolume from tz_order o
- join tz_order_item oi on oi.order_number=o.order_number
- where o.hb_order_status=80 GROUP BY oi.prod_id) t1 on t.prod_id = t1.prod_id
- <if test="prodByCategoryIdAndShopIdDTO.sort == 0">
- ORDER BY p.update_time
- </if>
- <if test="prodByCategoryIdAndShopIdDTO.sort == 1">
- ORDER BY t1.salesVolume
- </if>
- <if test="prodByCategoryIdAndShopIdDTO.sort == 2">
- ORDER BY p.price
- </if>
- <if test="prodByCategoryIdAndShopIdDTO.orderBy == 0">
- asc
- </if>
- <if test="prodByCategoryIdAndShopIdDTO.orderBy == 1">
- desc
- </if>
- </select>
- <select id="selectByHbSpuId" resultType="com.yami.shop.bean.model.Product">
- select * from tz_prod where hb_spu_id = #{hbSpuId} AND is_delete = 0;
- </select>
- </mapper>
|