ConvertModel.class.php
8.49 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<?php
/**
* ConvertModel.class.php
* 奖品申请表 Model
* @author: zhoutao
* @version: $Id$
* @copyright: vchangyi.com
*/
namespace Common\Model;
class ConvertModel extends AbstractModel
{
/** 奖品申请状态:待处理 */
const CONVERT_STATUS_ING = 1;
/** 奖品申请状态:已同意 */
const CONVERT_STATUS_AGREE = 2;
/** 奖品申请状态:已拒绝 */
const CONVERT_STATUS_DEFUSE = 3;
/** 奖品申请状态:已取消 */
const CONVERT_STATUS_CANCEL = 4;
/** @var array 奖品申请状态 */
protected $convertStatus = [
self::CONVERT_STATUS_ING => '待处理',
self::CONVERT_STATUS_AGREE => '已同意',
self::CONVERT_STATUS_DEFUSE => '已拒绝',
self::CONVERT_STATUS_CANCEL => '已取消',
];
// 构造方法
public function __construct()
{
parent::__construct();
}
/**
* 微信端查询符合条件的奖品兑换记录总数
* @param $conds
* @return array|bool
*/
public function countWxPrizeConvert($conds)
{
if (empty($conds['memUid'])) {
return false;
}
$where = ' WHERE oic.`domain`=?';
$params = array(
QY_DOMAIN,
);
$where .= ' AND oic.`uid` = ?';
$params[] = $conds['memUid'];
$sql = 'SELECT count(*) FROM oa_integral_convert oic
LEFT JOIN oa_integral_prize oip ON oic.ia_id=oip.ia_id ' . $where;
return $this->_m->result($sql, $params);
}
/**
* 管理平台查询符合条件的奖品兑换记录总数
* @param $conds
* @return array|bool
*/
public function countPrizeConvert($conds)
{
$where = ' WHERE oic.`domain`=?';
$params = array(
QY_DOMAIN,
);
// 奖品ID
if (!empty($conds['ia_id'])) {
$where .= ' AND oic.`ia_id` = ?';
$params[] = $conds['ia_id'];
}
// 兑换状态
if (!empty($conds['convert_status'])) {
$where .= ' AND oic.`convert_status` = ?';
$params[] = $conds['convert_status'];
}
// 奖品名称
if (!empty($conds['name'])) {
$where .= ' AND oip.`name` LIKE ?';
$params[] = '%' . $conds['name'] . '%';
}
// 手机
if (!empty($conds['applicant_phone'])) {
$where .= ' AND oic.`applicant_phone` LIKE ?';
$params[] = '%' . $conds['applicant_phone'] . '%';
}
// 兑换编号
if (!empty($conds['number'])) {
$where .= ' AND oic.`number` LIKE ?';
$params[] = '%' . $conds['number'] . '%';
}
// 申请开始时间
if (!empty($conds['startTime'])) {
$where .= ' AND oic.`created` >= ?';
$params[] = $conds['startTime'];
}
// 申请结束时间
if (!empty($conds['endTime'])) {
$where .= ' AND oic.`created` <= ?';
$params[] = $conds['endTime'];
}
// 如果按部门或者用户查询
if(!empty($conds['uids'])){
$where .= ' AND oic.`uid` in (?)';
$params[] = $conds['uids'];
}
$sql = 'SELECT count(*) FROM oa_integral_convert oic
LEFT JOIN oa_integral_prize oip ON oic.ia_id=oip.ia_id ' . $where;
return $this->_m->result($sql, $params);
}
/**
* 管理平台查询奖品兑换分页列表
* @param $conds
* @param null $pageOption
* @param array $orderOption
* @return array|bool
*/
public function getPrizeConvertPageList($conds, $pageOption = null, $orderOption = array())
{
$where = ' WHERE oic.`domain`=?';
$params = array(
QY_DOMAIN,
);
// 奖品ID
if (!empty($conds['ia_id'])) {
$where .= ' AND oic.`ia_id` = ?';
$params[] = $conds['ia_id'];
}
// 兑换状态
if (!empty($conds['convert_status'])) {
$where .= ' AND oic.`convert_status` = ?';
$params[] = $conds['convert_status'];
}
// 奖品名称
if (!empty($conds['name'])) {
$where .= ' AND oip.`name` LIKE ?';
$params[] = '%' . $conds['name'] . '%';
}
// 手机
if (!empty($conds['applicant_phone'])) {
$where .= ' AND oic.`applicant_phone` LIKE ?';
$params[] = '%' . $conds['applicant_phone'] . '%';
}
// 兑换编号
if (!empty($conds['number'])) {
$where .= ' AND oic.`number` LIKE ?';
$params[] = '%' . $conds['number'] . '%';
}
// 申请开始时间
if (!empty($conds['startTime'])) {
$where .= ' AND oic.`created` >= ?';
$params[] = $conds['startTime'];
}
// 申请结束时间
if (!empty($conds['endTime'])) {
$where .= ' AND oic.`created` <= ?';
$params[] = $conds['endTime'];
}
// 如果按部门或者用户查询
if(!empty($conds['uids'])){
$where .= ' AND oic.`uid` in (?)';
$params[] = $conds['uids'];
}
// 排序
$orderby = ' ORDER BY oic.`created` DESC';
// 分页参数
$limit = '';
if (!$this->_limit($limit, $pageOption)) {
return false;
}
$sql = "SELECT
oic.`ia_id`,
oic.`ic_id`,
oic.`created` AS apply_time,
oic.`updated` AS operate_time,
oic.`convert_status`,
oic.`number`,
oic.`operator`,
oic.`integral`,
oic.`uid`,
oic.`applicant_phone`,
oip.`name`
FROM oa_integral_convert oic
LEFT JOIN oa_integral_prize oip ON oic.ia_id=oip.ia_id " . $where . $orderby . $limit;
return $this->_m->fetch_array($sql, $params);
}
/**
* 微信端查询奖品兑换分页列表
* @param $conds
* @param null $pageOption
* @param array $orderOption
* @return array|bool
*/
public function getWxPrizeConvertPageList($conds, $pageOption = null, $orderOption = array())
{
if (empty($conds['memUid'])) {
return false;
}
$where = ' WHERE oic.`domain`=?';
$params = array(
QY_DOMAIN,
);
$where .= ' AND oic.`uid` = ?';
$params[] = $conds['memUid'];
// 排序
$orderby = 'ORDER BY oic.`created` DESC';
// 分页参数
$limit = '';
if (!$this->_limit($limit, $pageOption)) {
return false;
}
$sql = "SELECT
oic.`ic_id`,
oic.`created` AS apply_time,
oic.`convert_status`,
oic.`integral`,
oip.`name`,
oip.`picture`
FROM oa_integral_convert oic
LEFT JOIN oa_integral_prize oip ON oic.ia_id=oip.ia_id " .
$where . $orderby . $limit;
return $this->_m->fetch_array($sql, $params);
}
public function getWxPrizeConvertDetailByParams($conds) {
$where = ' WHERE oic.`status`<? AND oic.`domain`=?';
$params = array(
self::ST_DELETE,
QY_DOMAIN,
);
$where .= ' AND oic.`uid` = ?';
$params[] = $conds['memUid'];
if(!empty($conds['ic_id'])) {
$where .= "AND oic.`ic_id` = ? ";
$params[] = $conds['ic_id'];
}
if(!empty($conds['ucintegral_id'])) {
$where .= "AND oic.`ucintegral_id` = ? ";
$params[] = $conds['ucintegral_id'];
}
$sql = "SELECT
oic.`ic_id`,
oic.`ia_id`,
oic.`operator`,
oic.`ucintegral_id`,
oic.`convert_status`,
oic.`number`,
oic.`integral`,
oic.`uid`,
oic.`applicant_phone`,
oic.`applicant_email`,
oic.`applicant_mark`,
oic.`created`,
oip.`name`,
oip.`status` AS `prize_status`,
oip.`picture`
FROM
oa_integral_convert oic
LEFT JOIN oa_integral_prize oip ON oic.`ia_id` = oip.`ia_id` " . $where;
return $this->_m->fetch_row($sql, $params);
}
}