1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\common\lib;
- use app\api\model\UsersModel;
- /**
- * VIP等级晋升控制类
- * Class Promote
- * @package app\common\lib
- */
- class Promote
- {
- public $uid = null;
- // 查询我的上级
- public function getMyBoss()
- {
- if (!empty($this->uid)) {
- // 我的推荐人手机号
- $myRecTel = UsersModel::where('user_id', $this->uid)->value('user_tjtel');
- // 我的推荐人user_id
- $myRecUserId = UsersModel::where('user_tel', $myRecTel)->value('user_id');
- // 我的上级加一个开通VIP的人数
- $addMybossVipNum = UsersModel::where('user_id', $myRecUserId)->setInc('user_vip_count',1);
- // 查询我的上级一共邀请了多少人
- $myBossInvUserNum = UsersModel::where('user_id', $myRecUserId)->value('user_member_count');
- // 我的上级邀请人数中开通VIP的人数
- $myBossInvVipUserNum = UsersModel::where('user_id', $myRecUserId)->value('user_vip_count');
- if ($myBossInvVipUserNum == 5 && $myBossInvUserNum == 50) {
- $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 2]);
- }
- if ($myBossInvVipUserNum == 20 && $myBossInvUserNum == 300) {
- $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 3]);
- }
- if ($myBossInvVipUserNum == 35 && $myBossInvUserNum == 700) {
- $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 4]);
- }
- if ($myBossInvVipUserNum == 50 && $myBossInvUserNum == 1300) {
- $upd = UsersModel::where('user_id', $myRecUserId)->update(['user_level' => 5]);
- }
- return true;
- }
- }
- }
|