Browse Source

新增排行榜周榜日榜

warrior 3 weeks ago
parent
commit
e4d4ae7fd7

+ 28 - 11
projects/live-app/src/modules/tabs/my/my.component.html

@@ -1,9 +1,11 @@
 <ion-content class="content">
-  <div 
-  [ngClass]="{
-    'header': true,
-    'pad-top-ios': deviceSer.isIOS
-  }" [style.background-image]="'url(img/bg.png)'">
+  <div
+    [ngClass]="{
+      header: true,
+      'pad-top-ios': deviceSer.isIOS
+    }"
+    [style.background-image]="'url(img/bg.png)'"
+  >
     <div class="user-dateil">
       @if(!loading){
       <app-avatar
@@ -61,8 +63,12 @@
           </div>
         </div>
         <div class="user-footer">
-          <div class="row" (click)="toUrl('user/friends')">{{ profile?.get('degreeNumber') || userObj.fans }} 粉丝</div>
-          <div class="row" (click)="toUrl('user/friends')">{{  userObj.follow }} 关注</div>
+          <div class="row" (click)="toUrl('user/friends')">
+            {{ profile?.get("degreeNumber") || userObj.fans }} 粉丝
+          </div>
+          <div class="row" (click)="toUrl('user/friends')">
+            {{ userObj.follow }} 关注
+          </div>
           <div class="row">{{ userObj.friendly_degree }} 亲密度</div>
         </div>
       </div>
@@ -101,10 +107,18 @@
     </div>
     }
   </div>
-  <div class="order" [style.background-image]="'url(img/用户榜底.png)'" (click)="toUrl('user/ranking')">
+  <div
+    class="order"
+    [style.background-image]="'url(img/用户榜底.png)'"
+    (click)="toUrl('user/ranking')"
+  >
     <div class="title">
       <div class="link">排行榜</div>
-      <!-- <div class="link" (click)="toUrl('user/ranking')">更多</div> -->
+      <div class="btns">
+        <div class="btn" (click)="changeTop($event)">总部</div>
+        <div class="btn" (click)="changeTop($event, 'day')">日榜</div>
+        <div class="btn" (click)="changeTop($event, 'week')">周榜</div>
+      </div>
     </div>
     <div class="ladder">
       <div class="top-block">
@@ -165,12 +179,15 @@
       <div class="row-left">
         <span class="row-index">4</span>
         <img [src]="item.avatar" alt="" class="row-avatar" />
-        <div class="row-name">{{ item?.nickname }} <span style="color: #ff7d0a;">{{item.credit}}</span> </div>
+        <div class="row-name">
+          {{ item?.nickname }}
+          <span style="color: #ff7d0a">{{ item.credit }}</span>
+        </div>
       </div>
       <div class="row-right">
         <div class="row-tpis">距离第一名</div>
         <div class="row-tpis-num">
-          {{ orderList[0].credit  - item.credit}}
+          {{ orderList[0].credit - item.credit }}
         </div>
       </div>
     </div>

+ 9 - 0
projects/live-app/src/modules/tabs/my/my.component.scss

@@ -319,6 +319,15 @@
       color: #7d7d7d;
       font-size: 14px;
     }
+    .btns{
+      display: flex;
+      .btn{
+        margin-left: 4px;
+      }
+      .btn:hover{
+        color: #ec760c;
+      }
+    }
   }
   .setting {
     width: 92.3077vw;

+ 6 - 1
projects/live-app/src/modules/tabs/my/my.component.ts

@@ -89,7 +89,7 @@ export class MyComponent implements OnInit {
     this.getAgreement();
     const data = await this.aiServ.getFansAndFollow(this.user.id);
     // console.log(data);
-    this.orderList = await this.aiServ.getOrderAnchor();
+    this.orderList = await this.aiServ.getOrderAnchor(null,10);
     console.log(this.orderList);
     const { fans, follow } = data.data[0];
     this.userObj = { fans, follow, friendly_degree: 0 };
@@ -254,4 +254,9 @@ export class MyComponent implements OnInit {
     }
     this.router.navigate([url]);
   }
+
+  async changeTop(e:any, type?:string){
+    e.cancelBubble = true;
+    this.orderList = await this.aiServ.getOrderAnchor(null,10,type);
+  }
 }

+ 8 - 0
projects/live-app/src/modules/user/ranking/ranking.component.html

@@ -16,6 +16,14 @@
   </ion-segment>
 
   <div class="order" [style.background-image]="'url(img/用户榜底.png)'">
+    <div class="title">
+      <div class="link"></div>
+      <div class="btns">
+        <div class="btn" (click)="changeTop($event)">总部</div>
+        <div class="btn" (click)="changeTop($event, 'day')">日榜</div>
+        <div class="btn" (click)="changeTop($event, 'week')">周榜</div>
+      </div>
+    </div>
     <div class="ladder">
       <div class="top-block">
         <div class="top2">

+ 15 - 0
projects/live-app/src/modules/user/ranking/ranking.component.scss

@@ -132,5 +132,20 @@
         }
       }
     }
+    .title{
+      display: flex;
+      justify-content: space-between;
+      color: #7d7d7d;
+      font-size: 14px;
+    }
+    .btns{
+      display: flex;
+      .btn{
+        margin-left: 4px;
+      }
+      .btn:hover{
+        color: #ec760c;
+      }
+    }
   }
 }

+ 4 - 1
projects/live-app/src/modules/user/ranking/ranking.component.ts

@@ -33,5 +33,8 @@ export class RankingComponent implements OnInit {
     // this.orderList = []
     this.orderList = await this.aiServ.getOrderAnchor(this.active)
   }
-  
+  async changeTop(e:any, type?:string){
+    e.cancelBubble = true;
+    this.orderList = await this.aiServ.getOrderAnchor(null,null,type);
+  }
 }

+ 32 - 4
projects/live-app/src/services/aichart.service.ts

@@ -236,8 +236,8 @@ export class AiChatService {
     return data.data;
   }
   /* 获取好友列表 */
-  async getFriends(uid: string,val?:string): Promise<any> {
-    let where = val ? `WHERE u.nickname LIKE '%${val}%'` : ''
+  async getFriends(uid: string, val?: string): Promise<any> {
+    let where = val ? `WHERE u.nickname LIKE '%${val}%'` : '';
     let rejectsSql = `SELECT invited FROM "EventLog" WHERE "isDeleted" IS NOT TRUE AND "user" = '${uid}' AND "isAward" = TRUE `;
     let data: any = await this.http.customSQL(rejectsSql);
     let list = data.data;
@@ -257,7 +257,11 @@ export class AiChatService {
       GROUP BY fid,"channel",deadline) AS f
     LEFT JOIN "_User" AS u
     ON u."objectId" = f.fid 
-    ${notInclude.length > 0 ? `WHERE u."objectId" NOT IN (${notInclude}) AND u.nickname LIKE '%${val}%'` : where}
+    ${
+      notInclude.length > 0
+        ? `WHERE u."objectId" NOT IN (${notInclude}) AND u.nickname LIKE '%${val}%'`
+        : where
+    }
     `;
     return this.http.customSQL(sql);
   }
@@ -335,13 +339,34 @@ export class AiChatService {
     return data?.data;
   }
 
-  async getOrderAnchor(type?: string, limit?: number) {
+  async getOrderAnchor(type?: string, limit?: number, range?: string) {
+    let startTime;
+    let date = new Date();
+    switch (range) {
+      case 'day':
+        startTime =
+          date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
+        break;
+      case 'week':
+        date.setDate(date.getDate() - date.getDay() + 1);
+        date = new Date();
+        startTime =
+          date.getFullYear() +
+          '-' +
+          (date.getMonth() + 1) +
+          '-' +
+          date.getDate();
+        break;
+      default:
+        break;
+    }
     let sql = `SELECT us."objectId",us."nickname",us."avatar",ROUND(SUM("credit")::numeric, 2) AS credit
       FROM (
         SELECT COALESCE(SUM(llog.gold ),0) AS "credit",llog."toUser" AS uid
         FROM "LoveRender" AS llog
         WHERE llog.company = '${this.company}'
         AND llog."isDeleted" IS NOT TRUE
+        ${range ? `AND llog."createdAt" >= '${startTime}'` : ''}
         GROUP BY llog."toUser"
         UNION
         SELECT SUM(lalog.duration / 60 * lalog.unit) "credit","Room"."user" AS uid
@@ -350,6 +375,7 @@ export class AiChatService {
         ON lalog."room" = "Room"."objectId"
         WHERE lalog.company = '${this.company}'
         AND lalog."isDeleted" IS NOT TRUE
+        ${range ? `AND lalog."createdAt" >= '${startTime}'` : ''}
         GROUP BY "Room"."user"
       ) AS tbl
       LEFT JOIN "_User" us
@@ -363,12 +389,14 @@ export class AiChatService {
           FROM "LoveRender" AS llog
           WHERE llog.company = '${this.company}'
           AND llog."isDeleted" IS NOT TRUE
+          ${range ? `AND llog."createdAt" >= '${startTime}'` : ''}
           GROUP BY llog."fromUser"
           UNION
           SELECT SUM(lalog.duration / 60 * lalog.unit) "credit",lalog."user" AS uid
           FROM "LiveActiveLog" AS lalog
           WHERE lalog.company = '${this.company}'
           AND lalog."isDeleted" IS NOT TRUE
+          ${range ? `AND lalog."createdAt" >= '${startTime}'` : ''}
           GROUP BY lalog."user"
         ) AS tbl
           LEFT JOIN "_User" us