RecordService.class.php
2.18 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* Created by PhpStorm.
* User: yingcai
* Date: 2018/3/23
* Time: 下午4:06
*/
namespace Common\Service;
use Common\Common\User;
use Common\Model\RecordModel;
class RecordService extends AbstractService
{
// 构造方法
public function __construct()
{
$this->_d = new RecordModel();
parent::__construct();
}
/**
* 组织查询条件
*
* @param array $params 传入参数
* @return array
*/
public function get_where($params = [])
{
$where = [
'is_prize' => $params['type'],
'ac_id' => $params['ac_id'],
];
if (!empty($params['username'])) {
// 用户姓名不为空
$where['username like ?'] = '%' . $params['username'] . '%';
}
if (!empty($params['dp_id'])) {
// 用户组织ID不为空
$conds = [
'dpIdList' => is_array($params['dp_id']) ? $params['dp_id'] : [$params['dp_id']],
'departmentChildrenFlag' => 1, // 递归查询用户
'memSubscribeStatus' => 1 // 已关注用户
];
// 递归获取用户列表
$user_list = User::instance()->listUsersAll($conds);
$uids = array_column($user_list, 'memUid');
if (empty($uids)) {
$where['uid'] = ' ';
} else {
$where['uid'] = $uids;
}
}
if (!empty($params['mobile'])) {
// 用户手机号不为空
$where['mobile like ?'] = '%' . $params['mobile'] . '%';
}
return $where;
}
/**
* 查询总条数
* @param array $params
* @return int|mixed
*/
public function count_by_where($params = [])
{
return $this->_d->count_by_where($params);
}
/**
* 查询列表数据
* @param array $params 查询参数
* @param array $page_option 分页参数
* @param string $fields 查询字段
* @return array|bool
*/
public function list_by_where($params = [], $page_option = [], $fields = '*')
{
return $this->_d->list_by_where($params, $page_option, $fields);
}
}