|
@@ -668,60 +668,97 @@
|
|
|
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
|
|
|
+ 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
|
|
|
+ WHERE
|
|
|
+ 1 = 1
|
|
|
+ AND p.`status` = 1
|
|
|
<if test="searchParam.prodName != null and searchParam.prodName != ''">
|
|
|
- and prod_name like concat('%',#{searchParam.prodName} ,'%')
|
|
|
+ AND prod_name LIKE CONCAT('%', #{searchParam.prodName}, '%')
|
|
|
</if>
|
|
|
<if test="searchParam.shopId != null">
|
|
|
- and p.shop_id = #{searchParam.shopId}
|
|
|
+ AND p.shop_id = #{searchParam.shopId}
|
|
|
</if>
|
|
|
-
|
|
|
<if test="searchParam.categoryId != null">
|
|
|
- and p.shop_category_id = #{searchParam.categoryId}
|
|
|
+ AND p.shop_category_id = #{searchParam.categoryId}
|
|
|
</if>
|
|
|
<if test="searchParam.shopCategoryId != null">
|
|
|
- and p.shop_category_id = #{searchParam.shopCategoryId}
|
|
|
+ AND p.shop_category_id = #{searchParam.shopCategoryId}
|
|
|
</if>
|
|
|
<if test="searchParam.prodType != null and searchParam.isAllProdType == null">
|
|
|
- and p.prod_type = #{searchParam.prodType}
|
|
|
+ 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
|
|
|
+ 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
|
|
|
+ <!-- 修改点:合并排序条件 -->
|
|
|
+ <choose>
|
|
|
+ <when test="searchParam.sort != null">
|
|
|
+ ORDER BY
|
|
|
+ <choose>
|
|
|
+ <when test="searchParam.sort == 0">
|
|
|
+ t.update_time
|
|
|
+ <if test="searchParam.orderBy != null">
|
|
|
+ <choose>
|
|
|
+ <when test="searchParam.orderBy == 0">ASC</when>
|
|
|
+ <when test="searchParam.orderBy == 1">DESC</when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </when>
|
|
|
+ <when test="searchParam.sort == 1">
|
|
|
+ t1.salesVolume
|
|
|
+ <if test="searchParam.orderBy != null">
|
|
|
+ <choose>
|
|
|
+ <when test="searchParam.orderBy == 0">ASC</when>
|
|
|
+ <when test="searchParam.orderBy == 1">DESC</when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ , t.prod_id DESC
|
|
|
+ </when>
|
|
|
+ <when test="searchParam.sort == 2">
|
|
|
+ t.price
|
|
|
+ <if test="searchParam.orderBy != null">
|
|
|
+ <choose>
|
|
|
+ <when test="searchParam.orderBy == 0">ASC</when>
|
|
|
+ <when test="searchParam.orderBy == 1">DESC</when>
|
|
|
+ </choose>
|
|
|
+ </if>
|
|
|
+ </when>
|
|
|
+ </choose>
|
|
|
+ </when>
|
|
|
+ <otherwise>
|
|
|
+ <!-- 默认排序(当sort未指定时) -->
|
|
|
+ ORDER BY t.update_time DESC
|
|
|
+ </otherwise>
|
|
|
+ </choose>
|
|
|
</select>
|
|
|
|
|
|
<select id="listProdByCategoryIdAndShopId" parameterType="com.yami.shop.bean.dto.ProdByCategoryIdAndShopIdDTO" resultType="com.yami.shop.bean.model.Product">
|