ソースを参照

修改评论数对不上问题

zjy 4 ヶ月 前
コミット
0c5ad055bc

+ 6 - 2
alien-entity/src/main/resources/mapper/second/SecondGoodsInfoMapper.xml

@@ -117,7 +117,9 @@
             g.home_image,
             g.home_image,
             case when llr.id is null then '0' else '1' end likeStatus,
             case when llr.id is null then '0' else '1' end likeStatus,
             case when lc.id is null then '0' else '1' end collectStatus,
             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 = 7 and c.delete_flag = 0 ) as commentCount
+            (select count(1) from (SELECT id FROM store_comment c where c.business_id = g.id and c.business_type = 7 and c.delete_flag = 0 UNION ALL
+            SELECT t.id FROM store_comment t INNER JOIN (SELECT id FROM store_comment c where c.business_id = g.id and c.business_type = 7 and c.delete_flag = 0) d ON t.reply_id = d.id and business_type = 6 and delete_flag = 0) a ) as commentCount
+<!--            (SELECT count(1) FROM store_comment c where c.business_id = g.id and c.business_type = 7 and c.delete_flag = 0 ) as commentCount-->
         from
         from
             life_fans f inner join life_user u on
             life_fans f inner join life_user u on
                 f.followed_id = CONCAT('user_', u.user_phone) and u.delete_flag = 0
                 f.followed_id = CONCAT('user_', u.user_phone) and u.delete_flag = 0
@@ -198,7 +200,9 @@
             g.home_image,
             g.home_image,
             case when llr.id is null then '0' else '1' end likeStatus,
             case when llr.id is null then '0' else '1' end likeStatus,
             case when lc.id is null then '0' else '1' end collectStatus,
             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 = 7 and c.delete_flag = 0 ) as commentCount
+            (select count(1) from (SELECT id FROM store_comment c where c.business_id = g.id and c.business_type = 7 and c.delete_flag = 0 UNION ALL
+            SELECT t.id FROM store_comment t INNER JOIN (SELECT id FROM store_comment c where c.business_id = g.id and c.business_type = 7 and c.delete_flag = 0) d ON t.reply_id = d.id and business_type = 6 and delete_flag = 0) a ) as commentCount
+<!--            (SELECT count(1) FROM store_comment c where c.business_id = g.id and c.business_type = 7 and c.delete_flag = 0 ) as commentCount-->
         FROM
         FROM
             second_goods g inner join life_user u on u.id = g.user_id
             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_like_record llr on llr.dianzan_id = #{phoneId} and llr.huifu_id = g.id and llr.type = 6 and llr.delete_flag = 0