| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <?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.LifeUserDynamicsMapper">
- <select id="getDynamicsList" resultType="shop.alien.entity.store.vo.LifeUserDynamicsVo">
- select dyna1.*, COUNT(dyna1.id) AS fansCount from (
- select dyna.*,COUNT(sc.id) AS commentCount, COUNT(lm.id) AS transferNum from (
- with dynamice as(
- select
- CASE
- WHEN image_path REGEXP '.mp4|.avi|.flv|.mkv|.rmvb|.wmv|.3gp|.mov' THEN 2
- WHEN image_path REGEXP '.jpg|.jpeg|.png|.bmp|.webp|.gif|.svg' THEN 1
- ELSE 0
- END AS dynamicsType,id, title, phone_id phoneId, context, image_path, address,address_name,address_context, liulan_count, dianzan_count, type, created_time, substring_index(phone_id, '_', 1) userType, substring_index(phone_id, '_', -1) phone, draft , address_province, top_status, top_time, enable_status
- from life_user_dynamics
- where delete_flag = 0 and draft = 0 order by created_time desc
- )
- select dynamice.*, user.nick_name userName, user.head_img userImage, info.id storeUserId, user.id storeOrUserId, 0 isExpert
- from dynamice
- left join store_user user on dynamice.phone = user.phone and user.delete_flag = 0
- left join store_info info on info.id = user.store_id and info.delete_flag = 0
- left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0
- where dynamice.userType = 'store'
- union
- select dynamice.*, user.user_name userName, user.user_image userImage, user.id storeUserId, user.id storeOrUserId, IF(lue.expert_code IS NOT NULL , 1, 0) AS isExpert
- from dynamice
- join life_user user on dynamice.phone = user.user_phone and user.delete_flag = 0
- left join life_user_expert lue on lue.user_id = user.id and lue.delete_flag = 0
- where dynamice.userType = 'user') dyna
- left join life_comment lc on lc.dongtai_shequ_id = dyna.id
- left join store_comment sc on sc.business_id = dyna.id and sc.business_type = 2 and sc.delete_flag = 0
- left join life_message lm on lm.business_id = dyna.id
- GROUP BY dyna.id order by dyna.created_time desc) dyna1
- left join life_fans lf1 on lf1.followed_id = dyna1.phoneId
- where 1=1
- <if test="nickName != null and nickName != ''">
- AND dyna1.userName LIKE CONCAT('%', #{nickName}, '%')
- </if>
- <if test="userType != null and userType != ''">
- AND dyna1.userType = #{userType}
- </if>
- <if test="dynamicsType != null and dynamicsType != ''">
- AND dyna1.dynamicsType = #{dynamicsType}
- </if>
- <if test="releaseStartTime != null and releaseStartTime != ''">
- AND dyna1.created_time >= #{releaseStartTime}
- </if>
- <if test="releaseEndTime != null and releaseEndTime != ''">
- AND dyna1.created_time <= #{releaseEndTime}
- </if>
- GROUP by dyna1.id order by dyna1.top_status desc, dyna1.top_time desc
- </select>
- <select id="getDynamicsDetail" resultType="shop.alien.entity.store.vo.LifeUserDynamicsVo">
- select dyna1.*, COUNT(dyna1.id) AS fansCount from (
- select dyna.*,COUNT(sc.id) AS commentCount, COUNT(lm.id) AS transferNum from (
- with dynamice as(
- select
- CASE
- WHEN image_path REGEXP '.mp4|.avi|.flv|.mkv|.rmvb|.wmv|.3gp|.mov' THEN 2
- WHEN image_path REGEXP '.jpg|.jpeg|.png|.bmp|.webp|.gif|.svg' THEN 1
- ELSE 0
- END AS dynamicsType, id, title, phone_id phoneId, context, image_path, address,address_name,address_context, liulan_count, dianzan_count, type, created_time, substring_index(phone_id, '_', 1) userType, substring_index(phone_id, '_', -1) phone, draft , address_province, top_status, top_time, enable_status
- from life_user_dynamics
- where id = #{id} and delete_flag = 0 and draft = 0 order by created_time desc
- )
- select dynamice.*, user.nick_name userName, user.head_img userImage, info.id storeUserId, user.id storeOrUserId, 0 isExpert
- from dynamice
- left join store_user user on dynamice.phone = user.phone and user.delete_flag = 0
- left join store_info info on info.id = user.store_id and info.delete_flag = 0
- left join store_img img on img.store_id = user.store_id and img.img_type = '10' and img.delete_flag = 0
- where dynamice.userType = 'store'
- union
- select dynamice.*, user.user_name userName, user.user_image userImage, user.id storeUserId, user.id storeOrUserId, IF(lue.expert_code IS NOT NULL , 1, 0) AS isExpert
- from dynamice
- join life_user user on dynamice.phone = user.user_phone and user.delete_flag = 0
- left join life_user_expert lue on lue.user_id = user.id and lue.delete_flag = 0
- where dynamice.userType = 'user') dyna
- left join life_comment lc on lc.dongtai_shequ_id = dyna.id
- left join store_comment sc on sc.business_id = dyna.id and sc.business_type = 2 and sc.delete_flag = 0
- left join life_message lm on lm.business_id = dyna.id
- GROUP BY dyna.id order by dyna.created_time desc) dyna1
- left join life_fans lf1 on lf1.followed_id = dyna1.phoneId
- GROUP by dyna1.id order by dyna1.top_status desc, dyna1.top_time desc
- </select>
- <select id="getExpertDynamicsDetail" resultType="shop.alien.entity.store.vo.LifeUserDynamicsVo">
- SELECT
- dy.id,
- dy.phone_id,
- dy.title,
- dy.context,
- dy.image_path,
- dy.address,
- dy.liulan_count,
- dy.dianzan_count,
- dy.type,
- dy.draft,
- dy.delete_flag,
- dy.created_time,
- dy.created_user_id,
- dy.updated_time,
- dy.updated_user_id,
- dy.address_name,
- dy.address_context,
- dy.address_province,
- dy.top_status,
- dy.top_time,
- dy.enable_status,
- dy.business_id,
- dy.expert_id,
- dy.transfer_count,
- dy.reality_count,
- info.score_avg as scoreAvg,
- info.store_name as storeName,
- info.id as storeId,
- info.business_section as businessSection,
- COUNT(comment.id) AS commentCount,
- works.id as workId
- FROM
- life_user_dynamics AS dy
- INNER JOIN
- life_user_expert_order AS expertOrder
- ON dy.business_id = expertOrder.id
- AND expertOrder.delete_flag = 0
- INNER JOIN
- store_info AS info
- ON expertOrder.store_id = info.id
- AND info.delete_flag = 0
- LEFT JOIN
- store_comment AS comment
- ON comment.store_id = info.id
- AND comment.delete_flag = 0
- AND comment.business_type in ( 5 )
- LEFT JOIN
- life_user_expert_works AS works
- ON dy.id = works.dynamics_id
- WHERE
- dy.id = #{id}
- AND dy.delete_flag = 0
- </select>
- <select id="getStoreDynamicslist" resultType="shop.alien.entity.store.vo.LifeUserDynamicsVo">
- select
- dyna1.*,
- COUNT(dyna1.id) AS fansCount
- from
- (
- select
- dyna.*,
- COUNT(sc.id) AS commentCount,
- COUNT(lm.id) AS transferNum
- from
- (
- with dynamice as(
- select
- CASE
- WHEN image_path REGEXP '.mp4|.avi|.flv|.mkv|.rmvb|.wmv|.3gp|.mov' THEN 2
- WHEN image_path REGEXP '.jpg|.jpeg|.png|.bmp|.webp|.gif|.svg' THEN 1
- ELSE 0
- END AS dynamicsType, id, title, phone_id phoneId, context, image_path, address, address_name, address_context, liulan_count, dianzan_count, type, created_time, substring_index(phone_id, '_', 1) userType, substring_index(phone_id, '_', -1) phone, draft , address_province, top_status, top_time, enable_status,
- business_id
- from life_user_dynamics
- where phone_id = #{phoneId} and delete_flag = 0 and draft = 0 order by created_time desc
- )
- select
- dynamice.*,
- user.nick_name userName,
- user.head_img userImage,
- info.id storeUserId,
- info.store_name storeName,
- user.id storeOrUserId,
- 0 isExpert,
- IF(llr.huifu_id IS NOT NULL or llr1.huifu_id IS NOT NULL, 1, 0) AS isLike
- from
- dynamice
- left join store_user user on
- dynamice.phone = user.phone
- and user.delete_flag = 0
- left join store_info info on
- info.id = user.store_id
- and info.delete_flag = 0
- left join store_img img on
- img.store_id = user.store_id
- and img.img_type = '10'
- and img.delete_flag = 0
- left join life_like_record llr on
- llr.huifu_id = dynamice.id
- and llr.delete_flag = 0
- and llr.dianzan_id = (
- select
- CONCAT('user_', lu1.user_phone)
- from
- life_user lu1
- where
- lu1.id = #{userId})
- left join life_like_record llr1 on
- llr1.huifu_id = dynamice.id
- and llr1.delete_flag = 0
- and llr1.dianzan_id = (
- select
- CONCAT('store_', lu2.phone)
- from
- store_user lu2
- where
- lu2.id = #{userId})
- where
- dynamice.userType = 'store') dyna
- left join life_comment lc on
- lc.dongtai_shequ_id = dyna.id
- left join store_comment sc on
- sc.business_id = dyna.id
- and sc.business_type = 2
- and sc.delete_flag = 0
- left join life_message lm on
- lm.business_id = dyna.id
- GROUP BY
- dyna.id
- order by
- dyna.created_time desc) dyna1
- left join life_fans lf1 on
- lf1.followed_id = dyna1.phoneId
- GROUP by
- dyna1.id
- order by
- dyna1.top_status desc,
- dyna1.top_time desc
- </select>
- </mapper>
|