quanwei
2 days ago 73b874c72ad55eb9eef21c36160ac0de58f0189e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
 
namespace app\job\model\plus\vip;
 
use app\common\model\plus\vip\User as UserModel;
 
/**
 * VIP用户模型
 */
class User extends UserModel
{
    /**
     * 获取需要升级的用户列表
     */
    public function getUpgradeList()
    {
        return $this->where('is_delete', '=', 0)
            ->where('is_upgrade', '=', 1)
            ->select();
    }
 
    /**
     * 获取需要降级的用户列表
     */
    public function getDowngradeList()
    {
        return $this->where('is_delete', '=', 0)
            ->where('is_downgrade', '=', 1)
            ->select();
    }
 
    /**
     * 批量处理用户等级变更
     */
    public function processGradeChange($ids, $is_upgrade = true)
    {
        $field = $is_upgrade ? 'is_upgrade' : 'is_downgrade';
        return $this->where('user_id', 'in', $ids)
            ->save([$field => 0]);
    }
}