123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- <?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"/>
- <result column="user_phone" property="userPhone" jdbcType="VARCHAR"/>
- </resultMap>
- <!-- 分页查询推荐数据 -->
- <select id="getSecondRecommendByPage" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
- with shieldUser as (
- select g.id from life_blacklist lb inner join second_goods g
- on lb.blocked_id = g.user_id and g.delete_flag = '0' and g.goods_status = '3'
- where lb.delete_flag = 0 and lb.blocker_type = 2 and lb.blocked_type = 2
- and lb.blocker_id = #{userId}
- )
- 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 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 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.description,
- 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.business_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0 and lc.business_type = 1
- 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 life_blacklist lb inner join second_goods g
- on lb.blocked_id = g.user_id and g.delete_flag = '0' and g.goods_status = '3'
- where lb.delete_flag = 0 and lb.blocker_type = 2 and lb.blocked_type = 2
- and lb.blocker_id = #{userId}
- )
- 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.business_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0 and lc.business_type = 1
- 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>
- <select id="querySecondGoodsDetail" resultType="shop.alien.entity.second.vo.SecondGoodsRecommendVo">
- 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.home_image,
- g.release_time,
- lu.user_name,
- CONCAT('user_', lu.user_phone) as user_phone,
- lu.user_image,
- goods_status,
- ROUND(ST_Distance_Sphere(ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')' )), ST_GeomFromText(CONCAT('POINT(', REPLACE(g.position, ',', ' '), ')' ))) / 1000, 2) AS dist,
- (select count(1) from store_comment c where c.business_id = g.id and c.business_type = 6 and c.delete_flag = 0) as commentCount,
- case when llr.id is null then '0' else '1' end likeStatus,
- case when lc.id is null then '0' else '1' end collectStatus
- from second_goods g inner join life_user lu on g.user_id = lu.id and lu.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.business_id = g.id and lc.user_id = #{phoneId} and lc.delete_flag = 0 and lc.business_type = 1
- where g.id = #{goodsId} and g.delete_flag = 0
- </select>
- </mapper>
|