|
@@ -0,0 +1,185 @@
|
|
|
+<?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="shop.alien.mapper.second.SecondRecommendMapper">
|
|
|
+ <resultMap id="BaseResultMap" type="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
|
|
|
+ <!--@mbggenerated-->
|
|
|
+ <id column="id" property="id" jdbcType="INTEGER"/>
|
|
|
+ <result column="user_id" property="userId" jdbcType="INTEGER"/>
|
|
|
+ <result column="title" property="title" jdbcType="VARCHAR"/>
|
|
|
+ <result column="description" property="description" jdbcType="VARCHAR"/>
|
|
|
+ <result column="price" property="price" jdbcType="DECIMAL"/>
|
|
|
+ <result column="position" property="position" jdbcType="VARCHAR"/>
|
|
|
+ <result column="like_count" property="likeCount" jdbcType="INTEGER"/>
|
|
|
+ <result column="collect_count" property="collectCount" jdbcType="INTEGER"/>
|
|
|
+ <result column="category_one_id" property="categoryOneId" jdbcType="INTEGER"/>
|
|
|
+ <result column="category_two_id" property="categoryTwoId" jdbcType="INTEGER"/>
|
|
|
+ <result column="label" property="label" jdbcType="VARCHAR"/>
|
|
|
+ <result column="topic" property="topic" jdbcType="VARCHAR"/>
|
|
|
+ <result column="trade_id" property="tradeId" jdbcType="INTEGER"/>
|
|
|
+ <result column="created_time" property="createdTime" jdbcType="TIMESTAMP"/>
|
|
|
+ <result column="created_user_id" property="createdUserId" jdbcType="INTEGER"/>
|
|
|
+ <result column="updated_time" property="updatedTime" jdbcType="TIMESTAMP"/>
|
|
|
+ <result column="updated_user_id" property="updatedUserId" jdbcType="INTEGER"/>
|
|
|
+ <result column="user_name" property="userName" jdbcType="VARCHAR"/>
|
|
|
+ <result column="user_image" property="userImage" jdbcType="VARCHAR"/>
|
|
|
+ <result column="goods_status" property="goodsStatus" jdbcType="INTEGER"/>
|
|
|
+ <result column="delete_flag" property="deleteFlag" jdbcType="INTEGER"/>
|
|
|
+ <result column="dist" property="dist" jdbcType="VARCHAR"/>
|
|
|
+ <result column="isLike" property="isLike" jdbcType="VARCHAR"/>
|
|
|
+ <result column="home_image" property="homeImage" jdbcType="VARCHAR"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 分页查询推荐数据 -->
|
|
|
+ <select id="getSecondRecommendByPage" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
|
|
|
+ with shieldUser as (
|
|
|
+ select g.id from second_shield s inner join second_goods g
|
|
|
+ on s.shield_id = g.user_id and g.delete_flag = '0' and goods_status = '3' and s.delete_flag = '0'
|
|
|
+ where s.user_id = #{userId} and s.shield_type = 2
|
|
|
+ )
|
|
|
+ SELECT
|
|
|
+ g.id,
|
|
|
+ g.user_id,
|
|
|
+ g.title,
|
|
|
+ g.description,
|
|
|
+ g.price,
|
|
|
+ g.position,
|
|
|
+ g.like_count,
|
|
|
+ g.collect_count,
|
|
|
+ g.category_one_id,
|
|
|
+ g.category_two_id,
|
|
|
+ g.label,
|
|
|
+ g.topic,
|
|
|
+ g.trade_id,
|
|
|
+ g.created_time,
|
|
|
+ g.created_user_id,
|
|
|
+ g.updated_time,
|
|
|
+ g.updated_user_id,
|
|
|
+ u.user_name,
|
|
|
+ u.user_image,
|
|
|
+ g.goods_status,
|
|
|
+ g.delete_flag,
|
|
|
+ ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
|
|
|
+ case when llr.id is null then '0' else '1' end likeStatus,
|
|
|
+ g.home_image
|
|
|
+ FROM
|
|
|
+ second_goods g inner join life_user u on u.id = g.user_id and u.delete_flag = 0
|
|
|
+ left join life_like_record llr on llr.dianzan_id = g.user_id and llr.huifu_id = g.id and llr.type = 6 and llr.delete_flag = 0
|
|
|
+ where g.delete_flag = 0
|
|
|
+ <if test="typeId != null and typeId != '' ">
|
|
|
+ and (g.category_one_id = #{typeId} or g.category_two_id =#{typeId} )
|
|
|
+ </if>
|
|
|
+ and not exists (select 1 from second_shield s where s.id = g.id)
|
|
|
+ and not exists (select 1 from second_shield s where s.user_id = #{userId} and s.shield_type = 1 and s.shield_id = g.id and s.delete_flag = 0)
|
|
|
+ and g.goods_status = 3
|
|
|
+ order by dist, like_count desc, created_time desc
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 分页查询关注数据concern -->
|
|
|
+ <select id="querySecondConcernByPage" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
|
|
|
+ select
|
|
|
+ g.id,
|
|
|
+ g.user_id,
|
|
|
+ g.title,
|
|
|
+ g.describe,
|
|
|
+ g.price,
|
|
|
+ ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
|
|
|
+ g.like_count,
|
|
|
+ g.collect_count,
|
|
|
+ g.label,
|
|
|
+ g.topic,
|
|
|
+ g.trade_id,
|
|
|
+ g.created_time,
|
|
|
+ g.created_user_id,
|
|
|
+ g.updated_time,
|
|
|
+ g.updated_user_id,
|
|
|
+ u.user_name,
|
|
|
+ u.user_image,
|
|
|
+ g.goods_status,
|
|
|
+ g.home_image,
|
|
|
+ case when llr.id is null then '0' else '1' end likeStatus,
|
|
|
+ case when lc.id is null then '0' else '1' end collectStatus,
|
|
|
+ (select count(1) from store_comment c where c.business_id = g.id and c.business_type = 1 and c.delete_flag = 0) as commentCount
|
|
|
+ from
|
|
|
+ life_fans f inner join life_user u on
|
|
|
+ f.followed_id = CONCAT('user_', u.user_phone) and u.delete_flag = 0
|
|
|
+ inner join second_goods g on
|
|
|
+ u.id = g.user_id
|
|
|
+ and g.goods_status = 3
|
|
|
+ and g.delete_flag = 0
|
|
|
+ left join life_like_record llr on llr.dianzan_id = #{phoneId} and llr.huifu_id = g.id and llr.type = 6 and llr.delete_flag = 0
|
|
|
+ left join life_collect lc on lc.goods_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0
|
|
|
+ where
|
|
|
+ f.fans_id = #{phoneId} and f.delete_flag = 0
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="querySecondCommentInfo" resultType="shop.alien.entity.store.StoreComment">
|
|
|
+ select
|
|
|
+ business_id,
|
|
|
+ comment_content,
|
|
|
+ created_time,
|
|
|
+ user_name,
|
|
|
+ user_image,
|
|
|
+ rn
|
|
|
+ from (
|
|
|
+ select
|
|
|
+ c.business_id,
|
|
|
+ c.comment_content,
|
|
|
+ c.created_time,
|
|
|
+ u.user_name,
|
|
|
+ u.user_image,
|
|
|
+ row_number() over (partition by c.business_id order by c.created_time desc) as rn
|
|
|
+ from
|
|
|
+ store_comment c inner join life_user u on c.user_id = u.id and u.delete_flag = 0
|
|
|
+ where c.delete_flag = 0
|
|
|
+ and business_id in
|
|
|
+ <foreach collection="ids" item="id" open="(" separator="," close=")">
|
|
|
+ ${id}
|
|
|
+ </foreach>
|
|
|
+ ) a where rn <![CDATA[ <= ]]> 2
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 分页查询推荐数据 -->
|
|
|
+ <select id="querySecondNewGoodsByPage" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
|
|
|
+ with shieldUser as (
|
|
|
+ select g.id from second_shield s inner join second_goods g
|
|
|
+ on s.shield_id = g.user_id and g.delete_flag = '0' and goods_status = '3' and s.delete_flag = '0'
|
|
|
+ where s.user_id = #{userId} and s.shield_type = 2
|
|
|
+ )
|
|
|
+ SELECT
|
|
|
+ g.id,
|
|
|
+ g.user_id,
|
|
|
+ g.title,
|
|
|
+ g.description,
|
|
|
+ g.price,
|
|
|
+ g.position,
|
|
|
+ g.like_count,
|
|
|
+ g.collect_count,
|
|
|
+ g.category_one_id,
|
|
|
+ g.category_two_id,
|
|
|
+ g.label,
|
|
|
+ g.topic,
|
|
|
+ g.trade_id,
|
|
|
+ g.created_time,
|
|
|
+ g.created_user_id,
|
|
|
+ g.updated_time,
|
|
|
+ g.updated_user_id,
|
|
|
+ u.user_name,
|
|
|
+ u.user_image,
|
|
|
+ g.goods_status,
|
|
|
+ g.delete_flag,
|
|
|
+ ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
|
|
|
+ g.home_image,
|
|
|
+ case when llr.id is null then '0' else '1' end likeStatus,
|
|
|
+ case when lc.id is null then '0' else '1' end collectStatus,
|
|
|
+ (select count(1) from store_comment c where c.business_id = g.id and c.business_type = 1 and c.delete_flag = 0) as commentCount
|
|
|
+ FROM
|
|
|
+ second_goods g inner join life_user u on u.id = g.user_id
|
|
|
+ left join life_like_record llr on llr.dianzan_id = #{phoneId} and llr.huifu_id = g.id and llr.type = 6 and llr.delete_flag = 0
|
|
|
+ left join life_collect lc on lc.goods_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0
|
|
|
+ where g.delete_flag = 0
|
|
|
+ and not exists (select 1 from shieldUser s where s.id = g.id)
|
|
|
+ and not exists (select 1 from second_shield s where s.user_id = #{userId} and s.shield_type = 1 and s.shield_id = g.id)
|
|
|
+ and g.goods_status = 3
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|