Browse Source

fix:曲目首页统计

liujunchi 3 years ago
parent
commit
6e48909167

+ 5 - 5
cooleshow-user/user-biz/src/main/resources/config/mybatis/MusicSheetMapper.xml

@@ -485,16 +485,16 @@
 
     <select id="selectPayMusicSheet" resultType="com.yonge.cooleshow.biz.dal.vo.HomeMusicSheetVo$MusicSheetSmall">
 
-        select distinct
+        select
             ms.id_ as musicSheetId,
             ms.music_sheet_name_ as musicSheetName,
-            count(1) as num
+            sum(if(mspr.id_ is not null,1,0)) as num
         from music_sheet ms
-        left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = ms.id_
+                 left join music_sheet_purchase_record mspr on mspr.music_sheet_id_ = ms.id_
             and state_ = 1 and audit_status_ = 'PASS' and del_flag_ = 0 and mspr.order_status_ = 'PAID'
 
-            group by ms.id_, ms.music_sheet_name_
-            order by  count(ms.id_)
+        group by ms.id_, ms.music_sheet_name_
+        order by  sum(if(mspr.id_ is not null,1,0)) desc,ms.id_ desc
         limit 5
 
     </select>