site.php
21.8 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
<?php
/**
* 大转盘抽奖模块
*
*/
defined('IN_IA') or exit('Access Denied');
class Ewei_bigwheelModuleSite extends WeModuleSite {
public $tablename = 'bigwheel_reply';
public $tablefans = 'bigwheel_fans';
public function getItemTiles() {
global $_W;
$articles = pdo_fetchall("SELECT id,rid, title FROM " . tablename('bigwheel_reply') . " WHERE weid = '{$_W['uniacid']}'");
if (!empty($articles)) {
foreach ($articles as $row) {
$urls[] = array('title' => $row['title'], 'url' => $this->createMobileUrl('index', array('id' => $row['rid'])));
}
return $urls;
}
}
public function doMobileindex() {
global $_GPC, $_W;
$id = intval($_GPC['id']);
if (empty($id)) {
message('抱歉,参数错误!', '', 'error');
}
$reply = pdo_fetch("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $id));
if ($reply == false) {
message('抱歉,活动已经结束,下次再来吧!', '', 'error');
}
//获得关键词
$keyword = pdo_fetch("select content from ".tablename('rule_keyword')." where rid=:rid and type=1",array(":rid"=>$id));
$reply['keyword']= $keyword['content'];
if (empty($_W['fans']['follow']) || $_GPC['share'] == 1) {
$isshare = 1;
$running = false;
$msg = '请先关注公众号。';
} else {
checkauth();
$fansID = $_W['member']['uid'];
$from_user = $_W['fans']['from_user'];
$fans = pdo_fetch("SELECT * FROM " . tablename($this->tablefans) . " WHERE rid = " . $id . " and fansID='" . $fansID . "' and from_user='" . $from_user . "'");
if ($fans == false) {
$insert = array(
'rid' => $id,
'fansID' => $fansID,
'from_user' => $from_user,
'todaynum' => 0,
'totalnum' => 0,
'awardnum' => 0,
'createtime' => time(),
);
$temp = pdo_insert($this->tablefans, $insert);
if ($temp == false) {
message('抱歉,刚才操作数据失败!', '', 'error');
}
//增加人数,和浏览次数
pdo_update($this->tablename, array('fansnum' => $reply['fansnum'] + 1, 'viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id']));
} else {
//增加浏览次数
pdo_update($this->tablename, array('viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id']));
}
//判断是否获奖
$award = pdo_fetchall("SELECT * FROM " . tablename('bigwheel_award') . " WHERE weid=" . $_W['uniacid'] . " and rid = " . $id . " and fansID='" . $fansID . "' and from_user='" . $from_user . "' order by id desc");
if ($award != false) {
$awardone = $award[0];
}
$running = true;
//判断是否可以刮刮
if ($awardone && empty($fans['tel'])) {
$running = false;
$msg = '请先填写用户资料';
}
//判断用户抽奖次数
$nowtime = mktime(0, 0, 0);
if ($fans['last_time'] < $nowtime) {
$fans['todaynum'] = 0;
}
//判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
if ($running && $reply['starttime'] > time()) {
$running = false;
$msg = '活动还没有开始呢!';
}
//判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
if ($running && ($reply['endtime'] + 86399) < time()) {
$running = false;
$msg = '活动已经结束了,下次再来吧!';
}
//判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
if ($running && $fans['totalnum'] >= $reply['number_times'] && $reply['number_times'] > 0) {
$running = false;
$msg = '您已经超过抽奖总限制次数,无法抽奖了!';
}
//判断当日是否超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
if ($running && $fans['todaynum'] >= $reply['most_num_times'] && $reply['most_num_times'] > 0) {
$running = false;
$msg = '您已经超过今天的抽奖次数,明天再来吧!';
}
}
$cArr = array('one', 'two', 'three', 'four', 'five', 'six');
$awardstr = '';
foreach ($cArr as $c) {
if (empty($reply['c_type_' . $c])) {
break;
}
$awardstr.='<p>' . $reply['c_type_' . $c] . ':' . $reply['c_name_' . $c];
if ($reply['show_num'] == 1) {
$awardstr.=' 奖品数量: ' . intval($reply['c_num_' . $c] - $reply['c_draw_' . $c]);
}
$awardstr.='</p>';
}
if ($reply['most_num_times'] > 0 && $reply['number_times'] > 0) {
$detail = '本次活动共可以转' . $reply['number_times'] . '次,每天可以转 ' . intval($reply['most_num_times']) . ' 次! 你共已经转了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次 ,今天转了<span id="count">' . intval($fans['todaynum']). '</span> 次.';
$Tcount = $reply['most_num_times'];
$Lcount = $reply['most_num_times'] - $fans['todaynum'];
} elseif ($reply['most_num_times'] > 0) {
$detail = '本次活动每天可以转 ' . $reply['most_num_times'] . ' 次卡!你共已经转了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次 ,今天转了<span id="count">' . intval($fans['todaynum']) . '</span> 次.';
$Tcount = $reply['most_num_times'];
$Lcount = $reply['most_num_times'] - $fans['todaynum'];
} elseif ($reply['number_times'] > 0) {
$detail = '本次活动共可以转' . $reply['number_times'] . '次卡!你共已经转了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次。';
$Tcount = $reply['number_times'];
$Lcount = $reply['number_times'] - $fans['totalnum'];
} else {
$detail = '您很幸运,本次活动没有任何限制,您可以随意转!你共已经转了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次。';
$Tcount = 10000;
$Lcount = 10000;
}
$detail .= htmlspecialchars_decode($reply['content']);
if (empty($reply['sn_rename'])) {
$reply['sn_rename'] = 'SN码';
}
if (empty($reply['tel_rename'])) {
$reply['tel_rename'] = '手机号';
}
if (empty($reply['repeat_lottery_reply'])) {
$reply['repeat_lottery_reply'] = '亲,继续努力哦!';
}
if (empty($fans['todaynum'])) {
$fans['todaynum'] = 0;
}
if (empty($fans['totalnum'])) {
$fans['totalnum'] = 0;
}
//分享信息
$sharelink = empty($reply['share_url']) ? ($_W['siteroot'] . 'app/' . $this->createMobileUrl('index', array('id' => $id, 'name' => 'bigwheel', 'share' => 1))) : $reply['share_url'];
$sharelink = str_replace('./', '', $sharelink);
$sharetitle = empty($reply['share_title']) ? '欢迎参加大转盘活动' : $reply['share_title'];
$sharedesc = empty($reply['share_desc']) ? '亲,欢迎参加大转盘抽奖活动,祝您好运哦!!' : str_replace("\r\n"," ", $reply['share_desc']);
$shareimg = tomedia($reply['start_picurl']);
include $this->template('index');
}
public function doMobilegetaward() {
global $_GPC, $_W;
$id = intval($_GPC['id']);
//开始抽奖咯
$reply = pdo_fetch("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $id));
if (empty($reply)) {
$this->message(array('success' => 2, 'msg' => '活动已经结束了,下次再来吧!...'), '');
}
if($reply['isshow'] != 1){
//活动已经暂停,请稍后...
$this->message(array("success"=>2, "msg"=>'活动暂停,请稍后...'),"");
}
if ($reply['starttime'] > time()) {
$this->message(array("success"=>2, "msg"=>'活动还没有开始呢,请等待...'),"");
}
$endtime = $reply['endtime'] + 86399;
if ($endtime < time()) {
$this->message(array("success"=>2, "msg"=>'活动已经结束了,下次再来吧!'),"");
}
//先判断有没有资格领取
if (empty($_W['fans']['follow'])) {
$this->message(array("success"=>2, "msg"=>'请先关注公众号再来参与活动!详情请查看参与方法。'),"");
}
$fansID = $_W['member']['uid'];
$from_user = $_W['fans']['from_user'];
//第一步,判断有没有已经领取奖品了,如果领取了,则不能再领取了
$fans = pdo_fetch("SELECT * FROM " . tablename($this->tablefans) . " WHERE rid = " . $id . " and fansID='" . $fansID . "' and from_user='" . $from_user . "'");
if ($fans == false) {
//不存在false的情况,如果是false,则表明是非法
$fans = array(
'rid' => $id,
'fansID' => $fansID,
'from_user' => $_W['fans']['from_user'],
'todaynum' => 0,
'totalnum' => 0,
'awardnum' => 0,
'createtime' => time(),
);
pdo_insert($this->tablefans, $fans);
$fans['id'] = pdo_insertid();
}
//更新当日次数
$nowtime = mktime(0, 0, 0);
if ($fans['last_time'] < $nowtime) {
$fans['todaynum'] = 0;
}
//判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
if ($fans['totalnum'] >= $reply['number_times'] && $reply['number_times'] > 0) {
// $this->message('', '超过抽奖总限制次数');
$this->message(array("success"=>2, "msg"=>'您超过抽奖总次数了,不能抽奖了!'),"");
}
//判断当日是否超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试
if ($fans['todaynum'] >= $reply['most_num_times'] && $reply['most_num_times'] > 0) {
//$this->message('', '超过当日限制次数');
$this->message(array("success"=>2, "msg"=>'您超过当日抽奖次数了,不能抽奖了!'),"");
}
$last_time = strtotime( date("Y-m-d",mktime(0,0,0)));
//当天抽奖次数
pdo_update('bigwheel_fans', array('todaynum' => $fans['todaynum'] + 1,'last_time'=>$last_time), array('id' => $fans['id']));
//总抽奖次数
pdo_update('bigwheel_fans', array('totalnum' => $fans['totalnum'] + 1), array('id' => $fans['id']));
$gifts = array(
"one" => array("name" => $reply['c_name_one'], "type" => $reply['c_type_one'], "probalilty" => $reply['c_rate_one'], "total" => $reply['c_num_one'], "draw" => $reply['c_draw_one']),
"two" => array("name" => $reply['c_name_two'], "type" => $reply['c_type_two'], "probalilty" => $reply['c_rate_two'], "total" => $reply['c_num_two'], "draw" => $reply['c_draw_two']),
"three" => array("name" => $reply['c_name_three'], "type" => $reply['c_type_three'], "probalilty" => $reply['c_rate_three'], "total" => $reply['c_num_three'], "draw" => $reply['c_draw_three']),
"four" => array("name" => $reply['c_name_four'], "type" => $reply['c_type_four'], "probalilty" => $reply['c_rate_four'], "total" => $reply['c_num_four'], "draw" => $reply['c_draw_four']),
"five" => array("name" => $reply['c_name_five'], "type" => $reply['c_type_five'], "probalilty" => $reply['c_rate_five'], "total" => $reply['c_num_five'], "draw" => $reply['c_draw_five']),
"six" => array("name" => $reply['c_name_six'], "type" => $reply['c_type_six'], "probalilty" => $reply['c_rate_six'], "total" => $reply['c_num_six'], "draw" => $reply['c_draw_six']),
);
$awards = array();
foreach ($gifts as $key => $gift) {
if ($gift['total'] <= $gift['draw']) {
unset($gifts[$key]);
continue;
}
if (empty($gift['probalilty'])) {
unset($gifts[$key]);
continue;
}
$gifts[$key]['random'] = mt_rand(1, 100 / $gift['probalilty']);
if (mt_rand(1, 100 / $gift['probalilty']) == mt_rand(1, 100 / $gift['probalilty'])) {
$gift['type'] = $key;
$awards[] = $gift;
}
}
$prizetype = array();
if (count($awards) > 0){
mt_srand((double) microtime() * 1000000);
$randid = mt_rand(0, count($awards) - 1);
$prizetype = $awards[$randid];
}
if ($reply['award_times'] == '0') {
$reply['award_times'] = $fans['awardnum'] + 1;
}
if( (!empty($prizetype)) && ($fans['awardnum'] < $reply['award_times']) ){
//中奖
$sn = random(16);
pdo_update('bigwheel_reply', array('c_draw_' . $prizetype['type'] => $reply['c_draw_' . $prizetype['type']] + 1), array('id' => $reply['id']));
//保存sn到award中
$insert = array(
'weid' => $_W['uniacid'],
'rid' => $id,
'fansID' => $fansID,
'from_user' => $_W['fans']['from_user'],
'name' => $reply['c_type_' . $prizetype['type']],
'description' => $prizetype['name'],
'prizetype' => $prizetype['type'],
'award_sn' => $sn,
'createtime' => time(),
'status' => 1,
);
$temp = pdo_insert('bigwheel_award', $insert);
//保存中奖人信息到fans中
pdo_update('bigwheel_fans', array('awardnum' => $fans['awardnum'] + 1), array('id' => $fans['id']));
$statusCode = array('one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5, 'six' => 6);
$data = array(
'name' => $reply['c_type_' . $prizetype['type']],
'award' => $prizetype['name'],
'sn' => $sn,
'success' => 1,
'prizetype' => $statusCode[$prizetype['type']]
);
$this->message($data);
}
$this->message();
}
public function doMobilesettel() {
global $_GPC, $_W;
$id = intval($_GPC['id']);
$fansID =$_W['member']['uid'];
$from_user = $_W['fans']['from_user'];
$fans = pdo_fetch("SELECT id FROM " . tablename($this->tablefans) . " WHERE rid = " . $id . " and fansID=" . $fansID . " and from_user='" . $from_user . "'");
if ($fans == false) {
$data = array(
'success' => 0,
'msg' => '保存数据错误!',
);
} else {
$temp = pdo_update($this->tablefans, array('tel' => $_GPC['tel']), array('rid' => $id, 'fansID' => $fansID));
if ($temp === false) {
$data = array(
'success' => 0,
'msg' => '保存数据错误!',
);
} else {
load()->model('mc');
mc_update($fansID, array('mobile' => $_GPC['tel']));
$data = array(
'success' => 1,
'msg' => '成功提交数据',
);
}
}
echo json_encode($data);
}
//json
public function message($_data = '', $_msg = '') {
if (!empty($_data['succes']) && $_data['success'] != 2) {
$this->setfans();
}
if (empty($_data)) {
$_data = array(
'name' => "谢谢参与",
'success' => 0,
);
}
if (!empty($_msg)) {
//$_data['error']='invalid';
$_data['msg'] = $_msg;
}
die(json_encode($_data));
}
public function setfans() {
global $_GPC, $_W;
//增加fans次数
//记录用户信息
$id = intval($_GPC['id']);
$fansID = $_W['fans']['fanid'];
if (empty($fansID) || empty($id))
return;
$fans = pdo_fetch("SELECT * FROM " . tablename($this->tablefans) . " WHERE rid = " . $id . " and fansID=" . $fansID . "");
$nowtime = mktime(0, 0, 0);
if ($fans['last_time'] < $nowtime) {
$fans['todaynum'] = 0;
}
$update = array(
'todaynum' => $fans['todaynum'] + 1,
'totalnum' => $fans['totalnum'] + 1,
'last_time' => time(),
);
pdo_update($this->tablefans, $update, array('id' => $fans['id']));
}
public function doWebManage() {
global $_GPC, $_W;
load()->model('reply');
$pindex = max(1, intval($_GPC['page']));
$psize = 20;
$sql = "uniacid = :weid AND `module` = :module";
$params = array();
$params[':weid'] = $_W['uniacid'];
$params[':module'] = 'ewei_bigwheel';
if (isset($_GPC['keywords'])) {
$sql .= ' AND `name` LIKE :keywords';
$params[':keywords'] = "%{$_GPC['keywords']}%";
}
$list = reply_search($sql, $params, $pindex, $psize, $total);
$pager = pagination($total, $pindex, $psize);
if (!empty($list)) {
foreach ($list as &$item) {
$condition = "`rid`={$item['id']}";
$item['keywords'] = reply_keywords_search($condition);
$bigwheel = pdo_fetch("SELECT fansnum, viewnum,starttime,endtime,isshow FROM " . tablename('bigwheel_reply') . " WHERE rid = :rid ", array(':rid' => $item['id']));
$item['fansnum'] = $bigwheel['fansnum'];
$item['viewnum'] = $bigwheel['viewnum'];
$item['starttime'] = date('Y-m-d H:i', $bigwheel['starttime']);
$endtime = $bigwheel['endtime'] + 86399;
$item['endtime'] = date('Y-m-d H:i', $endtime);
$nowtime = time();
if ($bigwheel['starttime'] > $nowtime) {
$item['status'] = '<span class="label label-warning">未开始</span>';
$item['show'] = 1;
} elseif ($endtime < $nowtime) {
$item['status'] = '<span class="label label-default ">已结束</span>';
$item['show'] = 0;
} else {
if ($bigwheel['isshow'] == 1) {
$item['status'] = '<span class="label label-success">已开始</span>';
$item['show'] = 2;
} else {
$item['status'] = '<span class="label label-default ">已暂停</span>';
$item['show'] = 1;
}
}
$item['isshow'] = $bigwheel['isshow'];
}
}
include $this->template('manage');
}
public function doWebDelete() {
global $_GPC, $_W;
$rid = intval($_GPC['rid']);
$rule = pdo_fetch("SELECT id, module FROM " . tablename('rule') . " WHERE id = :id and uniacid=:weid", array(':id' => $rid, ':weid' => $_W['uniacid']));
if (empty($rule)) {
message('抱歉,要修改的规则不存在或是已经被删除!');
}
if (pdo_delete('rule', array('id' => $rid))) {
pdo_delete('rule_keyword', array('rid' => $rid));
//删除统计相关数据
pdo_delete('stat_rule', array('rid' => $rid));
pdo_delete('stat_keyword', array('rid' => $rid));
//调用模块中的删除
$module = WeUtility::createModule($rule['module']);
if (method_exists($module, 'ruleDeleted')) {
$module->ruleDeleted($rid);
}
}
message('规则操作成功!', referer(), 'success');
}
public function doWebDeleteAll() {
global $_GPC, $_W;
foreach ($_GPC['idArr'] as $k => $rid) {
$rid = intval($rid);
if ($rid == 0)
continue;
$rule = pdo_fetch("SELECT id, module FROM " . tablename('rule') . " WHERE id = :id and uniacid=:weid", array(':id' => $rid, ':weid' => $_W['uniacid']));
if (empty($rule)) {
$this->webmessage('抱歉,要修改的规则不存在或是已经被删除!');
}
if (pdo_delete('rule', array('id' => $rid))) {
pdo_delete('rule_keyword', array('rid' => $rid));
//删除统计相关数据
pdo_delete('stat_rule', array('rid' => $rid));
pdo_delete('stat_keyword', array('rid' => $rid));
//调用模块中的删除
$module = WeUtility::createModule($rule['module']);
if (method_exists($module, 'ruleDeleted')) {
$module->ruleDeleted($rid);
}
}
}
$this->webmessage('规则操作成功!', '', 0);
}
public function doWebAwardlist() {
global $_GPC, $_W;
$rid = intval($_GPC['rid']);
if (empty($rid)) {
message('抱歉,传递的参数错误!', '', 'error');
}
$where = '';
$params = array(':rid' => $rid, ':weid' => $_W['uniacid']);
if (!empty($_GPC['status'])) {
$where.=' and a.status=:status';
$params[':status'] = $_GPC['status'];
}
if (!empty($_GPC['keywords'])) {
if (strlen($_GPC['keywords']) == 11 && is_numeric($_GPC['keywords'])) {
$members = pdo_fetchall("SELECT uid FROM ".tablename('mc_members')." WHERE mobile = :mobile", array(':mobile' => $_GPC['keywords']), 'uid');
if(!empty($members)){
$fans = pdo_fetchall("SELECT openid FROM ".tablename('mc_mapping_fans')." WHERE uid in ('".implode("','", array_keys($members))."')", array(), 'openid');
if(!empty($fans)){
$where .= " AND a.from_user IN ('".implode("','", array_keys($fans))."')";
}
}
} else {
$where.=' and (a.award_sn like :keywords)';
$params[':keywords'] = "%{$_GPC['keywords']}%";
}
}
$total = pdo_fetchcolumn("SELECT count(a.id) FROM " . tablename('bigwheel_award') . " a WHERE a.rid = :rid and a.weid=:weid " . $where . "", $params);
$pindex = max(1, intval($_GPC['page']));
$psize = 12;
$pager = pagination($total, $pindex, $psize);
$start = ($pindex - 1) * $psize;
$limit = " LIMIT {$start},{$psize}";
// $sql = 'SELECT * FROM ' . tablename('bigwheel_award').'WHERE `rid` = :rid AND `weid` = :weid';
$sql = 'SELECT `a`.*, `f`.`nickname` FROM ' . tablename('bigwheel_award') . ' AS `a` LEFT JOIN ' .
tablename('mc_mapping_fans') . ' AS `f` ON `a`.`from_user` = `f`.`openid` WHERE `a`.`rid` = :rid AND
`a`.`weid` = :weid ' . $where . ' ORDER BY `a`.`id` DESC ' . $limit;
$list = pdo_fetchall($sql, $params);
//一些参数的显示
$num1 = pdo_fetchcolumn("SELECT total_num FROM " . tablename($this->tablename) . " WHERE rid = :rid", array(':rid' => $rid));
$num2 = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('bigwheel_award') . " WHERE rid = :rid and status=1", array(':rid' => $rid));
$num3 = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('bigwheel_award') . " WHERE rid = :rid and status=2", array(':rid' => $rid));
if (empty($range)) {
$range['start'] = date('Y-m-d', strtotime('-1 month', time()));
$range['end'] = date('Y-m-d', time());
}
include $this->template('awardlist');
}
public function doWebDownload() {
require_once 'download.php';
}
public function doWebSetshow() {
global $_GPC, $_W;
$rid = intval($_GPC['rid']);
$isshow = intval($_GPC['isshow']);
if (empty($rid)) {
message('抱歉,传递的参数错误!', '', 'error');
}
$temp = pdo_update('bigwheel_reply', array('isshow' => $isshow), array('rid' => $rid));
message('状态设置成功!', referer(), 'success');
}
public function doWebSetstatus() {
global $_GPC, $_W;
$id = intval($_GPC['id']);
$status = intval($_GPC['status']);
if (empty($id)) {
message('抱歉,传递的参数错误!', '', 'error');
}
$p = array('status' => $status);
if ($status == 2) {
$p['consumetime'] = TIMESTAMP;
}
$temp = pdo_update('bigwheel_award', $p, array('id' => $id, 'weid' => $_W['uniacid']));
if ($temp == false) {
message('该用户已是该状态,无需重复操作!', '', 'error');
} else {
message('状态设置成功!', $this->createWebUrl('awardlist',array('rid'=>$_GPC['rid'])), 'success');
}
}
public function doWebGetphone() {
global $_GPC, $_W;
$rid = intval($_GPC['rid']);
$fans = $_GPC['fans'];
$tel = pdo_fetchcolumn("SELECT tel FROM " . tablename('bigwheel_fans') . " WHERE rid = " . $rid . " and from_user='" . $fans . "'");
if ($tel == false) {
echo '没有登记';
} else {
echo $tel;
}
}
public function webmessage($error, $url = '', $errno = -1) {
$data = array();
$data['errno'] = $errno;
if (!empty($url)) {
$data['url'] = $url;
}
$data['error'] = $error;
echo json_encode($data);
exit;
}
}