From caa0fca67896fd9f32e3495a30587356216c1ac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=8B=BC?= <2468023037@qq.com> Date: Mon, 17 Feb 2025 22:24:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Evip=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/TaskController.php | 26 ++++ app/controller/api/UserController.php | 1 + app/controller/api/Vip_rewardController.php | 124 +++++++++++++++++++- app/controller/api/Vip_salaryController.php | 56 ++++++++- 4 files changed, 199 insertions(+), 8 deletions(-) diff --git a/app/controller/api/TaskController.php b/app/controller/api/TaskController.php index 039ab7f..3790df5 100644 --- a/app/controller/api/TaskController.php +++ b/app/controller/api/TaskController.php @@ -196,4 +196,30 @@ class TaskController UserRewardDao::base($user_id, 4, 50, '首次关联此手机号送50积分'); } } + + /** + * 有效下级 + */ + public static function effective_junior() + { + //获取今天在线时间超过6小时的用户 + $UserPhone = UserPhone::where('time', '>', 360)->get(); + //判断用户绑定Whatsapp首次登录 + foreach ($UserPhone as $key => $value) { + $user_id = $value->user_id; + $user = User::find($user_id); + //判断用户绑定Whatsapp首次登录 + // if ($user->bind_whatsapp == 0) { + //满足则加80积分 + UserRewardDao::base($user_id, 6, 80, '任务佣金'); + //vip_id等级加1,并更新数据库 + $user->vip_id +=1; + $user->save(); + // } + + } + //满足则加80积分 + // UserRewardDao::base($user_id, 6, 80, '任务佣金'); + + } } diff --git a/app/controller/api/UserController.php b/app/controller/api/UserController.php index 5306975..c3411af 100644 --- a/app/controller/api/UserController.php +++ b/app/controller/api/UserController.php @@ -86,6 +86,7 @@ class UserController $f = User::where('invite_code', $invitation)->first(); $f_id=$f->id; $ff_id = $f->f_id; + $f->vip_id+=1; } } $user = new User(); diff --git a/app/controller/api/Vip_rewardController.php b/app/controller/api/Vip_rewardController.php index 1492ec4..8611bf1 100644 --- a/app/controller/api/Vip_rewardController.php +++ b/app/controller/api/Vip_rewardController.php @@ -13,9 +13,10 @@ use App\model\ProjectDetailed; use App\model\ProjectRegister; use App\model\Carouselad; use App\model\VipLevel; +use App\model\UserReward; use App\Utils\ApiResponseApp; use Tinywan\Jwt\JwtToken; - +use App\dao\UserRewardDao; use hg\apidoc\annotation as Apidoc; use support\Db; @@ -119,9 +120,12 @@ class Vip_rewardController */ public function need_score(Request $request) { - $user_id = $request->data['id']; - $user = User::find($user_id); - $res['score'] = $user->money; + // $user_id = $request->data['id']; + // $user = User::find($user_id); + // $res['score'] = $user->money; + $res=[ + "score"=>80 + ]; return ApiResponseApp::success($res); } /** @@ -142,7 +146,10 @@ class Vip_rewardController */ public function check_status(Request $request) { - $data = [ + //获取当前用户 + $user_id=$request->data['id']; + $user=User::find($user_id); + $datas = [ [ "vip_id" => 1, "status" => 0, @@ -198,7 +205,112 @@ class Vip_rewardController "user_count" => 1000 ] ]; - return ApiResponseApp::success($data); + //获取该用户今天的领奖记录 + $UserRewasrds = UserReward::where('user_id', $user_id) + ->whereDate('created_at', date('Y-m-d')) + ->get(); + // 遍历每个用户记录并更新 status 字段 + foreach ($datas as &$data) { + foreach ($UserRewasrds as $UserRewasrd) { + if (strpos($UserRewasrd->memo, $data['vip_id'].'等级奖励') !== false) { + $data['status'] = 2; + break; + } + } + if ($data['status'] == 2) { + continue; + } + if ($user->vip_id >= $data['user_count']) { + $data['status'] = 1; // 满足条件时设置状态为1 + } else { + $data['status'] = 0; // 不满足条件时设置状态为0 + } + } + return ApiResponseApp::success($datas); + } + + /** + * @Apidoc\Title("1.0 领取等级奖励") + * @Apidoc\Url("api/vip_reward/receive") + * @Apidoc\Method("GET") + */ + public function receive(Request $request) + { + // 输出所有请求参数以进行调试 + $input = $request->all(); + $vip_id = $input['vip_id']; + + + $user_id=$request->data['id']; + // $user=User::find($user_id); + + + $datas = [ + [ + "vip_id" => 1, + "money" => 150, + 'new_money' => 1500, + ], + [ + "vip_id" => 2, + "money" => 380, + 'new_money' => 4000, + ], + [ + "vip_id" => 3, + "money" => 580, + 'new_money' => 6000, + ], + [ + "vip_id" => 4, + "money" => 1080, + 'new_money' => 15000, + ], + [ + "vip_id" => 5, + "money" => 2080, + 'new_money' => 40000, + ], + [ + "vip_id" => 6, + "money" => 3800, + 'new_money' => 75000, + ], + [ + "vip_id" => 7, + "money" => 10800, + 'new_money' => 75000, + ], + [ + "vip_id" => 8, + "money" => 28000, + 'new_money' => 75000, + ], + [ + "vip_id" => 9, + "money" => 58000, + 'new_money' => 75000, + ], + ]; + $money = null; + $new_money = null; + foreach ($datas as $data) { + if ($data['vip_id'] == $vip_id) { + $money = $data['money']; + $new_money = $data['new_money']; + break; + } + } + $UserReward = UserReward::where('memo', '首次VIP'.$vip_id.'等级奖励')->where('user_id', $user_id)->get(); + //判断是否有 + if ($UserReward->count() > 0) { + UserRewardDao::base($user_id, 6, $money, 'VIP'.$vip_id.'等级奖励'); + }else{ + UserRewardDao::base($user_id, 6, $new_money, '首次VIP'.$vip_id.'等级奖励'); + + } + return ApiResponseApp::success('领取成功'); + } } diff --git a/app/controller/api/Vip_salaryController.php b/app/controller/api/Vip_salaryController.php index 7b57e6d..3a0f77d 100644 --- a/app/controller/api/Vip_salaryController.php +++ b/app/controller/api/Vip_salaryController.php @@ -13,6 +13,7 @@ use App\model\ProjectDetailed; use App\model\ProjectRegister; use App\model\Carouselad; use App\model\VipLevel; +use App\dao\UserRewardDao; use App\Utils\ApiResponseApp; use Tinywan\Jwt\JwtToken; @@ -55,7 +56,10 @@ class Vip_salaryController */ public function check_status(Request $request) { - $data = [ + //获取当前用户 + $user_id=$request->data['id']; + $user=User::find($user_id); + $datas = [ [ "vip_id" => 1, "status" => 0, @@ -81,6 +85,54 @@ class Vip_salaryController "user_count" => 2000 ] ]; - return ApiResponseApp::success($data); + // 遍历每个用户记录并更新 status 字段 + foreach ($datas as &$data) { + if ($user->vip_id >= $data['user_count']) { + $data['status'] = 1; // 满足条件时设置状态为1 + } else { + $data['status'] = 0; // 不满足条件时设置状态为0 + } + } + return ApiResponseApp::success($datas); + } + /** + * @Apidoc\Title("1.0 晋升奖励") + * @Apidoc\Url("api/vip_salary/receive") + * @Apidoc\Method("GET") + */ + public function receive(Request $request) + { + $input = $request->all(); + $vip_id = $input['vip_id']; + + $user_id=$request->data['id']; + + $datas = [ + [ + "vip_id" => 1, + "money" => 50, + ], + [ + "vip_id" => 2, + "money" => 100, + ], + [ + "vip_id" => 3, + "money" => 500, + ], + [ + "vip_id" => 4, + "money" => 5000, + ] + ]; + $money = null; + foreach ($datas as &$data) { + if ($vip_id == $data['vip_id']) { + $money = $data['money']; + break; + } + } + UserRewardDao::base($user_id, 6, $money, 'VIP'.$vip_id.'晋升奖励'); + return ApiResponseApp::success('领取成功'); } }