From 96a54ac2da06d05a586c4d56f2541cea4d3e421a Mon Sep 17 00:00:00 2001 From: liwei Date: Tue, 17 Oct 2023 17:21:55 +0800 Subject: [PATCH] 1 --- .../Api/V1/Group/GiftController.php | 70 ++++++++++++------- app/Service/GiftService.php | 18 +++-- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/app/Controller/Api/V1/Group/GiftController.php b/app/Controller/Api/V1/Group/GiftController.php index c5415ae..ade5aac 100644 --- a/app/Controller/Api/V1/Group/GiftController.php +++ b/app/Controller/Api/V1/Group/GiftController.php @@ -98,7 +98,7 @@ class GiftController extends CController } $idnum = data_get($v, 'id_num', ''); - $is_follow = 0; + $follow_status = 1; // 关注状态 if ($user_id) { $mine_id = data_get($v, 'mine_id', 0); @@ -107,7 +107,16 @@ class GiftController extends CController ->where('to_user_id',$mine_id) ->first(); if (!empty($follow_user)) { - $is_follow = 1; + $follow_status = 2; + } + if ($follow_status == 2) { + $to_follow_user = DB::table('user_follow') + ->where('to_user_id',$user_id) + ->where('user_id',$mine_id) + ->first(); + if (!empty($to_follow_user)) { + $follow_status = 3; + } } } @@ -116,7 +125,7 @@ class GiftController extends CController $idnums[$idnum]['points'] = '0'; $idnums[$idnum]['player_id'] = $playerId; $idnums[$idnum]['head_img'] = $headImg; - $idnums[$idnum]['is_follow'] = $is_follow; + $idnums[$idnum]['follow_status'] = $follow_status; if (!isset($idnums[$idnum]['order'])) { $idnums[$idnum]['order'] = $order; } @@ -128,7 +137,7 @@ class GiftController extends CController $idnums[$k]['points'] = empty($points)? 0: $points; $idnums[$k]['player_id'] = $playerId; $idnums[$k]['head_img'] = $headImg; - $idnums[$k]['is_follow'] = $is_follow; + $idnums[$k]['follow_status'] = $follow_status; $idnums[$k]['order'] = $order; $idnums[$k]['name'] = data_get($v, 'name'); } @@ -167,18 +176,28 @@ class GiftController extends CController ->first() ->toArray(); - $is_follow = 0; + $follow_status = 1; // 关注状态 if ($user_id) { $follow_user = DB::table('user_follow') - ->where('user_id',$user_id) - ->where('to_user_id',$model['mine_id']) + ->where('user_id', $user_id) + ->where('to_user_id', $model['mine_id']) ->first(); if (!empty($follow_user)) { - $is_follow = 1; + $follow_status = 2; + } + if ($follow_status == 2) { + $to_follow_user = DB::table('user_follow') + ->where('to_user_id', $user_id) + ->where('user_id', $model['mine_id']) + ->first(); + if (!empty($to_follow_user)) { + $follow_status = 3; + } } + } - $j['is_follow'] = $is_follow; + $j['follow_status'] = $follow_status; $return[] = $j; } } else { @@ -196,18 +215,28 @@ class GiftController extends CController ->first() ->toArray(); - $is_follow = 0; + $follow_status = 1; // 关注状态 if ($user_id) { $follow_user = DB::table('user_follow') - ->where('user_id',$user_id) - ->where('to_user_id',$model['mine_id']) + ->where('user_id', $user_id) + ->where('to_user_id', $model['mine_id']) ->first(); if (!empty($follow_user)) { - $is_follow = 1; + $follow_status = 2; + } + if ($follow_status == 2) { + $to_follow_user = DB::table('user_follow') + ->where('to_user_id', $user_id) + ->where('user_id', $model['mine_id']) + ->first(); + if (!empty($to_follow_user)) { + $follow_status = 3; + } } + } - $j['is_follow'] = $is_follow; + $j['follow_status'] = $follow_status; $return[] = $j; } } @@ -250,19 +279,6 @@ class GiftController extends CController if (empty($img)) { $rows[$k]['head_img'] = 'https://cdn.rockysports.cn/%E5%BE%AE%E6%AD%A5%E8%AE%A1%E6%97%B6.png'; } - - $is_follow = 0; - // 关注状态 - if ($user_id) { - $mine_id = data_get($v, 'mine_id', 0); - $follow_user = DB::table('user_follow') - ->where('user_id',$user_id) - ->where('to_user_id',$mine_id) - ->first(); - if (!empty($follow_user)) { - $is_follow = 1; - } - } } } diff --git a/app/Service/GiftService.php b/app/Service/GiftService.php index 87e3917..529cfc3 100644 --- a/app/Service/GiftService.php +++ b/app/Service/GiftService.php @@ -107,8 +107,7 @@ class GiftService extends BaseService $headImg = 'https://cdn.rockysports.cn/%E5%BE%AE%E6%AD%A5%E8%AE%A1%E6%97%B6.png'; } $idnum = data_get($v, 'id_num', ''); - - $is_follow = 0; + $follow_status = 1; // 关注状态 if ($user_id) { $mine_id = data_get($v, 'mine_id', 0); @@ -117,7 +116,16 @@ class GiftService extends BaseService ->where('to_user_id',$mine_id) ->first(); if (!empty($follow_user)) { - $is_follow = 1; + $follow_status = 2; + } + if ($follow_status == 2) { + $to_follow_user = DB::table('user_follow') + ->where('to_user_id',$user_id) + ->where('user_id',$mine_id) + ->first(); + if (!empty($to_follow_user)) { + $follow_status = 3; + } } } if (!empty($idnum)) { @@ -125,7 +133,7 @@ class GiftService extends BaseService $idnums[$idnum]['points'] = 0; $idnums[$idnum]['player_id'] = $playerId; $idnums[$idnum]['head_img'] = $headImg; - $idnums[$idnum]['is_follow'] = $is_follow; + $idnums[$idnum]['follow_status'] = $follow_status; $idnums[$idnum]['name'] = data_get($v, 'name'); } $idnums[$idnum]['points'] += $points; @@ -133,7 +141,7 @@ class GiftService extends BaseService $idnums[$k]['points'] = empty($points)? 0: $points; $idnums[$k]['player_id'] = $playerId; $idnums[$k]['head_img'] = $headImg; - $idnums[$k]['is_follow'] = $is_follow; + $idnums[$k]['follow_status'] = $follow_status; $idnums[$k]['name'] = data_get($v, 'name'); } } -- Gitee