|
|
1
|
+<?php
|
|
|
2
|
+
|
|
|
3
|
+namespace app\api\controller\v1;
|
|
|
4
|
+
|
|
|
5
|
+use app\common\controller\Api;
|
|
|
6
|
+use think\Db;
|
|
|
7
|
+use think\Exception;
|
|
|
8
|
+
|
|
|
9
|
+/**
|
|
|
10
|
+ * 用户端接口
|
|
|
11
|
+ */
|
|
|
12
|
+class Client extends Api
|
|
|
13
|
+{
|
|
|
14
|
+ protected $noNeedLogin = ['*'];
|
|
|
15
|
+ protected $noNeedRight = ['*'];
|
|
|
16
|
+ protected $postParam;
|
|
|
17
|
+ protected $store_id;
|
|
|
18
|
+ protected $store;
|
|
|
19
|
+
|
|
|
20
|
+ public function _initialize()
|
|
|
21
|
+ {
|
|
|
22
|
+ $postParam = $this->request->param();
|
|
|
23
|
+ $this->postParam = $postParam;
|
|
|
24
|
+
|
|
|
25
|
+ parent::_initialize();
|
|
|
26
|
+ $this->auth->id = 1;//测试用
|
|
|
27
|
+ $postParam = $this->request->param();
|
|
|
28
|
+ $this->postParam = $postParam;
|
|
|
29
|
+ if (empty($postParam['code'])) {
|
|
|
30
|
+ $this->error("门店code异常");
|
|
|
31
|
+ }
|
|
|
32
|
+ $this->store_id = $postParam['code'];
|
|
|
33
|
+ $store = Db::name("verification_store")->where("id", $this->store_id)->find();
|
|
|
34
|
+ if (empty($store)) {
|
|
|
35
|
+ $this->error("门店不存在,请退出登录后重试!");
|
|
|
36
|
+ }
|
|
|
37
|
+ $this->store = $store;
|
|
|
38
|
+ if (empty($this->auth->id)) {
|
|
|
39
|
+ $this->error("暂无权限!");
|
|
|
40
|
+ }
|
|
|
41
|
+
|
|
|
42
|
+ }
|
|
|
43
|
+ /**
|
|
|
44
|
+ * 1、获取活动
|
|
|
45
|
+ */
|
|
|
46
|
+ public function getactivity(){
|
|
|
47
|
+ //根据门店查询活动
|
|
|
48
|
+ $time=time();
|
|
|
49
|
+ $where["closetime"] = [">", $time];
|
|
|
50
|
+ $where["verification_store_id"] = ["=", $this->store_id];
|
|
|
51
|
+ $activity=Db::name('verification_activity')->where($where)->find();
|
|
|
52
|
+ $this->success('活动获取成功', $activity);
|
|
|
53
|
+ }
|
|
|
54
|
+ /**
|
|
|
55
|
+ * 1.1参加活动用户信息
|
|
|
56
|
+ */
|
|
|
57
|
+ public function participate_activitie(){
|
|
|
58
|
+ $activity_id=$this->postParam['id'];
|
|
|
59
|
+ $page = $this->request->post('page', 1);
|
|
|
60
|
+ $total = $this->request->post('total', 10);
|
|
|
61
|
+ $where['type']=1;
|
|
|
62
|
+ $where['verification_activity_id']=$activity_id;
|
|
|
63
|
+
|
|
|
64
|
+ $user=Db::name("verification_order")
|
|
|
65
|
+ ->where('verification_activity_id','=',$activity_id)
|
|
|
66
|
+ ->field('name')
|
|
|
67
|
+ ->paginate($total, false, ['page' => $page])
|
|
|
68
|
+ ->toArray();
|
|
|
69
|
+ if(!empty($user['data'])){
|
|
|
70
|
+ for ($i=0;$i<count($user['data']);$i++){
|
|
|
71
|
+ $sort=$i+1;
|
|
|
72
|
+ $user['data'][$i]['sort']=$sort;
|
|
|
73
|
+ $user['data'][$i]['name']=$this->substr_cut($user['data'][$i]['name']);
|
|
|
74
|
+ }
|
|
|
75
|
+ }
|
|
|
76
|
+
|
|
|
77
|
+ $this->success('查询成功',$user);
|
|
|
78
|
+ }
|
|
|
79
|
+
|
|
|
80
|
+ /**
|
|
|
81
|
+ * 1.1.1名字加*
|
|
|
82
|
+ * @param $user_name
|
|
|
83
|
+ * @return string
|
|
|
84
|
+ */
|
|
|
85
|
+ function substr_cut($user_name){
|
|
|
86
|
+ $strlen = mb_strlen($user_name, 'utf-8'); //获取字符长度
|
|
|
87
|
+ $firstStr = mb_substr($user_name, 0, 1, 'utf-8'); //查找字符第一个
|
|
|
88
|
+ $str=$firstStr . str_repeat('*', $strlen - 1); //拼接第一个+把字符串 "* " 重复 $strlen - 1 次:
|
|
|
89
|
+ return $str;
|
|
|
90
|
+ }
|
|
|
91
|
+
|
|
|
92
|
+ /**
|
|
|
93
|
+ * 2、举办活动
|
|
|
94
|
+ */
|
|
|
95
|
+ public function holdactivity(){
|
|
|
96
|
+ $verification_store_id=$this->store_id;
|
|
|
97
|
+ $name=$this->postParam['name'];
|
|
|
98
|
+ $phone=$this->postParam['phone'];
|
|
|
99
|
+ $industry=$this->postParam['industry'];
|
|
|
100
|
+ $address=$this->postParam['address'];
|
|
|
101
|
+ $verification_activity_id=$this->postParam['id'];
|
|
|
102
|
+ $user_id=$this->auth->id;
|
|
|
103
|
+ $data=[
|
|
|
104
|
+ 'verification_store_id'=>$verification_store_id,
|
|
|
105
|
+ 'name'=>$name,
|
|
|
106
|
+ 'phone'=>$phone,
|
|
|
107
|
+ 'industry'=>$industry,
|
|
|
108
|
+ 'address'=>$address,
|
|
|
109
|
+ 'verification_activity_id'=>$verification_activity_id,
|
|
|
110
|
+ 'user_id'=>$user_id
|
|
|
111
|
+ ];
|
|
|
112
|
+ $res=Db::name('verification_hold_activity')->insertGetId($data);
|
|
|
113
|
+ if($res){
|
|
|
114
|
+ $this->success("提交成功");
|
|
|
115
|
+ }else{
|
|
|
116
|
+ $this->error("提交失败");
|
|
|
117
|
+ }
|
|
|
118
|
+
|
|
|
119
|
+ }
|
|
|
120
|
+
|
|
|
121
|
+ /**
|
|
|
122
|
+ * 3、查询个人订单
|
|
|
123
|
+ */
|
|
|
124
|
+ public function myorder(){
|
|
|
125
|
+ $id=$this->auth->id;
|
|
|
126
|
+ $type=$this->postParam['type'];
|
|
|
127
|
+ $verification_store_id=$this->store_id;
|
|
|
128
|
+ $where['a.verification_store_id']=$verification_store_id;
|
|
|
129
|
+ $page = $this->request->post('page', 1);
|
|
|
130
|
+ $total = $this->request->post('total', 10);
|
|
|
131
|
+
|
|
|
132
|
+ if($type){
|
|
|
133
|
+ $where['a.type']=$type;
|
|
|
134
|
+ }
|
|
|
135
|
+ $row=Db::name('verification_order')
|
|
|
136
|
+ ->alias('a')
|
|
|
137
|
+ ->join('verification_store b','a.verification_store_id=b.id')
|
|
|
138
|
+ ->where($where)
|
|
|
139
|
+ ->paginate($total, false, ['page' => $page])
|
|
|
140
|
+ ->toArray();
|
|
|
141
|
+ }
|
|
|
142
|
+
|
|
|
143
|
+ /**
|
|
|
144
|
+ * 4、订单详情
|
|
|
145
|
+ */
|
|
|
146
|
+ public function orderinfo(){
|
|
|
147
|
+ $order_id=$this->postParam['id'];
|
|
|
148
|
+ $where['id']=$order_id;
|
|
|
149
|
+ $where['user_id']=$this->auth->id;
|
|
|
150
|
+ $order=Db::name('verification_order')->where($where)->find();
|
|
|
151
|
+ if($order){
|
|
|
152
|
+ $receivewhere['verification_order_id']=$order_id;
|
|
|
153
|
+ $receive=Db::name('cv_verification_receive')->where($receivewhere)->select();
|
|
|
154
|
+ $order['receive']=$receive;
|
|
|
155
|
+ $this->success("查询成功",$order);
|
|
|
156
|
+ }else{
|
|
|
157
|
+ $this->error("查询失败");
|
|
|
158
|
+ }
|
|
|
159
|
+ }
|
|
|
160
|
+
|
|
|
161
|
+ /**
|
|
|
162
|
+ * 5、卡卷详情
|
|
|
163
|
+ */
|
|
|
164
|
+ public function receiveinfo(){
|
|
|
165
|
+ $receive=$this->postParam['id'];
|
|
|
166
|
+ $where['id']=$receive;
|
|
|
167
|
+ $where['user_id']=$this->auth->id;
|
|
|
168
|
+ $field="a.*,b.image,b.name";
|
|
|
169
|
+ $receive=Db::name('cv_verification_receive')
|
|
|
170
|
+ ->alias('a')
|
|
|
171
|
+ ->join('verification_store b','a.verification_store_id=b.id')
|
|
|
172
|
+ ->where($where)
|
|
|
173
|
+ ->field($field)
|
|
|
174
|
+ ->find();
|
|
|
175
|
+ $this->success("查询成功",$receive);
|
|
|
176
|
+ }
|
|
|
177
|
+
|
|
|
178
|
+} |