quanwei
18 hours ago c441dea81bd86bdfb12dff35821fed51f4cc91c2
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
 
namespace app\operations\model\branch;
 
use app\common\model\branch\ActivityUser as ActivityUserModel;
 
/**
 * 用户模型
 * Class User
 * @package app\operations\model\plus\team
 */
class ActivityUser extends ActivityUserModel
{
    /**
     * 删除报名用户
     * @return mixed
     */
    public function setDelete()
    {
        return $this->transaction(function () {
            // 标记用户记录为已删除
            return $this->save([
                'is_delete' => 1
            ]);
        });
    }
 
    /**
     * 获取报名用户列表
     */
    public function getList($params = [], $is_page = true, $limit = false)
    {
        // 构建查询规则
        $model = $this->alias('auser')
            ->field('auser.*, user.nickName, user.avatarUrl')
            ->join('user', 'user.user_id = auser.user_id')
            ->with(['activity'=>['branch'],'branch'])
            ->where('auser.is_delete', '=', 0)
            ->order(['auser.create_time' => 'desc']);
        // 查询条件
        if (!empty($params['keyword'])) {
            $model = $model->where('user.nickName|auser.real_name|auser.mobile', 'like', '%' . $params['keyword'] . '%');
        }
        if (!empty($params['activity_id'])) {
            $model = $model->where('auser.activity_id', '=', $params['activity_id']);
        }
        if (!empty($params['pay_status'])) {
            if ($params['pay_status']>0){
                $model = $model->where('auser.pay_status', '=', $params['pay_status']);
            }
        }
        if (isset($params['status'])) {
            if ($params['status']>-1) {
                $model = $model->where('auser.status', '=', $params['status']);
            }
        }
        // 如果不分页
        if (!$is_page) {
            if ($limit) {
                $model = $model->limit($limit);
            }
            return $model->select();
        }
        // 获取列表数据
        return $model->paginate($params);
    }
}