HexiaoController.php
1.7 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
<?php
namespace app\admin\controller;
use cmf\controller\AdminBaseController;
use think\Db;
class HexiaoController extends AdminBaseController{
//核销页显示
public function index(){
return $this -> fetch();
}
//核销数据
public function hxCancel(){
$code = input('post.code');
$ma = Db::name('coupons_user') -> where('code',$code) -> find();
if($ma){
$riqi = Db::name('coupons') -> where('id',$ma['cid']) -> find();
$date =strtotime(date('y-m-d'));
$begin = strtotime($riqi['startime']);
$end = strtotime($riqi['endtime']);
if($date >= $begin && $date <= $end ){
//生日核销
/*if ($riqi['type'] == 2) {
$shegri = Db::name('members_user') -> where('id',$ma['uid']) -> find();
$nian = mb_substr($shegri['birthday'],0,4);
$yue = mb_substr($shegri['birthday'],5,2);
$riaa = mb_substr($shegri['birthday'],8,2);
$bir = $yue.$riaa;
if ($bir == date('md')) {
$update = Db::name('coupons_user') -> where('code',$code) -> update(['state' => 1]);
return 1;
}else{
return 5;
}
}else{
}*/
$shijian = time();
$update = Db::name('coupons_user') -> where('code',$code) -> update(['state' => 1,'time'=>$shijian]);
if($update){
return 1;
}else{
return 4;
}
}else{
return 3;
}
}else{
return 2;
}
}
//已核销页
public function yihexiao(){
$data = Db::name('coupons_user') -> alias('a') -> join('members_user b','a.uid=b.id','LEFT') -> where('a.state=1') -> select();
dump($data);die;
return $this -> fetch();
}
}
?>