|
@@ -2,21 +2,20 @@ |
|
@@ -2,21 +2,20 @@ |
2
|
|
2
|
|
3
|
namespace app\api\controller;
|
3
|
namespace app\api\controller;
|
4
|
|
4
|
|
|
|
5
|
+use app\api\model\UserAddress;
|
|
|
6
|
+use app\api\model\UserCoupon;
|
5
|
use app\common\controller\Api;
|
7
|
use app\common\controller\Api;
|
6
|
-use app\common\library\Ems;
|
|
|
7
|
-use app\common\library\Sms;
|
|
|
8
|
use fast\Http;
|
8
|
use fast\Http;
|
9
|
-use fast\Random;
|
|
|
10
|
use think\Config;
|
9
|
use think\Config;
|
11
|
use think\Db;
|
10
|
use think\Db;
|
12
|
-use think\Validate;
|
|
|
13
|
|
11
|
|
14
|
/**
|
12
|
/**
|
15
|
- * 会员接口
|
13
|
+ * 我的页面
|
16
|
*/
|
14
|
*/
|
17
|
class User extends Api
|
15
|
class User extends Api
|
18
|
{
|
16
|
{
|
19
|
- protected $noNeedLogin = ['third'];
|
17
|
+ protected $noNeedLogin = ['*'];
|
|
|
18
|
+// protected $noNeedLogin = ['third'];
|
20
|
protected $noNeedRight = '*';
|
19
|
protected $noNeedRight = '*';
|
21
|
|
20
|
|
22
|
public function _initialize()
|
21
|
public function _initialize()
|
|
@@ -126,30 +125,288 @@ class User extends Api |
|
@@ -126,30 +125,288 @@ class User extends Api |
126
|
}
|
125
|
}
|
127
|
|
126
|
|
128
|
/**
|
127
|
/**
|
129
|
- * @ApiTitle (用户协议)
|
128
|
+ * @ApiTitle (用户优惠券)
|
130
|
* @ApiMethod (POST)
|
129
|
* @ApiMethod (POST)
|
|
|
130
|
+ * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
131
|
+ * @ApiParams (name="type", type="integer", required=true, description="0未使用1已使用2已过期")
|
131
|
* @ApiReturn ({
|
132
|
* @ApiReturn ({
|
132
|
'code':'1',
|
133
|
'code':'1',
|
133
|
- 'msg':'用户协议'
|
|
|
134
|
- 'data':'富文本'
|
134
|
+ 'msg':'返回成功'
|
|
|
135
|
+ "data": [
|
|
|
136
|
+ {
|
|
|
137
|
+ "id": 1,
|
|
|
138
|
+ "user_id": 1,
|
|
|
139
|
+ "coupon_id": 1,
|
|
|
140
|
+ "name": "手动阀手动阀",
|
|
|
141
|
+ "price": "1.00", 优惠券金额
|
|
|
142
|
+ "full_price": "10.00", 满减金额
|
|
|
143
|
+ "createtime": 111122244,
|
|
|
144
|
+ "endtime": 1641869388,
|
|
|
145
|
+ "status": "0",
|
|
|
146
|
+ "endtime_text": "2022年01月11日到期"
|
|
|
147
|
+ }
|
|
|
148
|
+ ]
|
|
|
149
|
+ })
|
|
|
150
|
+ */
|
|
|
151
|
+ public function userCoupon()
|
|
|
152
|
+ {
|
|
|
153
|
+ $type = $this->request->post('type');
|
|
|
154
|
+ if (!in_array($type,[0,1,2])) $this->error('type参数不合法');
|
|
|
155
|
+ $model = new UserCoupon();
|
|
|
156
|
+ $list = $model->where('status',$type)->where('user_id',$this->auth->id)->select();
|
|
|
157
|
+ $this->success('用户优惠券列表',$list);
|
|
|
158
|
+ }
|
|
|
159
|
+
|
|
|
160
|
+ /**
|
|
|
161
|
+ * @ApiTitle (用户地址列表)
|
|
|
162
|
+ * @ApiMethod (POST)
|
|
|
163
|
+ * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
164
|
+ * @ApiReturn ({
|
|
|
165
|
+ 'code':'1',
|
|
|
166
|
+ 'msg':'返回成功'
|
|
|
167
|
+ "data": [
|
|
|
168
|
+ {
|
|
|
169
|
+ "id": 1,
|
|
|
170
|
+ "user_id": 1,
|
|
|
171
|
+ "username": "1", 收件人
|
|
|
172
|
+ "address": "阿松大", 地址
|
|
|
173
|
+ "address_detail": "阿松大", 详细地址
|
|
|
174
|
+ "normal_status": "0", 0不默认1默认
|
|
|
175
|
+ "lng": null, 经度
|
|
|
176
|
+ "lat": null, 纬度
|
|
|
177
|
+ "createtime": null,
|
|
|
178
|
+ "mobile_hide": "135****9988" 电话号码
|
|
|
179
|
+ "mobile": "13549059988" 电话号码
|
|
|
180
|
+ }
|
|
|
181
|
+ ]
|
|
|
182
|
+ })
|
|
|
183
|
+ */
|
|
|
184
|
+ public function userAddressList()
|
|
|
185
|
+ {
|
|
|
186
|
+ $model = new UserAddress();
|
|
|
187
|
+ $list = $model->where('user_id',1)->order('normal_status','desc')->select();
|
|
|
188
|
+ $this->success('用户地址列表',$list);
|
|
|
189
|
+ }
|
|
|
190
|
+
|
|
|
191
|
+
|
|
|
192
|
+ /**
|
|
|
193
|
+ * @ApiTitle (用户修改(删除)地址)
|
|
|
194
|
+ * @ApiMethod (POST)
|
|
|
195
|
+ * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
196
|
+ * @ApiParams (name=id, type=integer, required=true, description="地址id")
|
|
|
197
|
+ * @ApiParams (name=type, type=integer, required=true, description="1修改2删除")
|
|
|
198
|
+ * @ApiParams (name=username, type=string, required=false, description="收件人")
|
|
|
199
|
+ * @ApiParams (name=mobile, type=string, required=flase, description="手机号")
|
|
|
200
|
+ * @ApiParams (name=address, type=string, required=false, description="地址")
|
|
|
201
|
+ * @ApiParams (name=address_detail, type=string, required=false, description="详细地址")
|
|
|
202
|
+ * @ApiParams (name=normal, type=integer, required=false, description="默认状态 0不默认或1默认")
|
|
|
203
|
+ * @ApiParams (name=lat, type=float, required=false, description="纬度")
|
|
|
204
|
+ * @ApiParams (name=lng, type=float, required=false, description="经度")
|
|
|
205
|
+ * @ApiReturn ({
|
|
|
206
|
+ 'code':'1',
|
|
|
207
|
+ 'msg':'SUCCESS'
|
|
|
208
|
+ "data":
|
|
|
209
|
+ })
|
|
|
210
|
+ */
|
|
|
211
|
+ public function userAddressEdit()
|
|
|
212
|
+ {
|
|
|
213
|
+ $id = $this->request->post('id');
|
|
|
214
|
+ $type = $this->request->post('type');
|
|
|
215
|
+ $username = $this->request->post('username');
|
|
|
216
|
+ $mobile = $this->request->post('mobile');
|
|
|
217
|
+ $address = $this->request->post('address');
|
|
|
218
|
+ $address_detail = $this->request->post('address_detail');
|
|
|
219
|
+ $normal = $this->request->post('normal');
|
|
|
220
|
+ $lat = $this->request->post('lat');
|
|
|
221
|
+ $lng = $this->request->post('lng');
|
|
|
222
|
+ $data = [
|
|
|
223
|
+ 'type' => $type,
|
|
|
224
|
+ 'mobile' => $mobile,
|
|
|
225
|
+ 'id' => $id,
|
|
|
226
|
+ 'normal' => $normal,
|
|
|
227
|
+ 'lat' => $lat,
|
|
|
228
|
+ 'lng' => $lng,
|
|
|
229
|
+ ];
|
|
|
230
|
+ $rule = [
|
|
|
231
|
+ 'type' => 'require|in:1,2',
|
|
|
232
|
+ 'mobile' => 'regex:^1\d{10}$',
|
|
|
233
|
+ 'id' => 'require|integer',
|
|
|
234
|
+ 'normal' => 'in:0,1',
|
|
|
235
|
+ 'lat' => 'float',
|
|
|
236
|
+ 'lng' => 'float',
|
|
|
237
|
+ ];
|
|
|
238
|
+ $msg = [
|
|
|
239
|
+ 'type' => 'type参数不合法',
|
|
|
240
|
+ 'mobile' => '电话号码格式不正确',
|
|
|
241
|
+ 'id' => '地址id不合法',
|
|
|
242
|
+ 'normal' => '默认状态参数不合法',
|
|
|
243
|
+ 'lat' => '纬度请为浮点数格式',
|
|
|
244
|
+ 'lng' => '经度请为浮点数格式',
|
|
|
245
|
+ ];
|
|
|
246
|
+ $validate = new \think\Validate();
|
|
|
247
|
+ $validate->rule($rule);
|
|
|
248
|
+ $validate->message($msg);
|
|
|
249
|
+ if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
250
|
+ $model = new UserAddress();
|
|
|
251
|
+ if ($type == 1){
|
|
|
252
|
+ $data = [
|
|
|
253
|
+ 'mobile' => $mobile,
|
|
|
254
|
+ 'normal_status' => $normal,
|
|
|
255
|
+ 'lat' => $lat,
|
|
|
256
|
+ 'lng' => $lng,
|
|
|
257
|
+ 'username' => $username,
|
|
|
258
|
+ 'address' => $address,
|
|
|
259
|
+ 'address_detail' => $address_detail,
|
|
|
260
|
+ ];
|
|
|
261
|
+ $model->where('id',$id)->isUpdate()->save($data,['id'=>$id]);
|
|
|
262
|
+ }else{
|
|
|
263
|
+ $model->where('id',$id)->delete();
|
|
|
264
|
+ }
|
|
|
265
|
+ $this->success('SUCCESS');
|
|
|
266
|
+ }
|
|
|
267
|
+
|
|
|
268
|
+
|
|
|
269
|
+ /**
|
|
|
270
|
+ * @ApiTitle (加入我们)
|
|
|
271
|
+ * @ApiMethod (POST)
|
|
|
272
|
+ * @ApiParams (name=work, type=string, required=true, description="从事行业")
|
|
|
273
|
+ * @ApiParams (name=years, type=string, required=true, description="从业时间")
|
|
|
274
|
+ * @ApiParams (name=username, type=string, required=true, description="姓名")
|
|
|
275
|
+ * @ApiParams (name=mobile, type=string, required=true, description="手机号")
|
|
|
276
|
+ * @ApiParams (name=money, type=string, required=true, description="预计可投入资金")
|
|
|
277
|
+ * @ApiParams (name=team, type=integer, required=true, description="团队拥有0没有1有")
|
|
|
278
|
+ * @ApiParams (name=city, type=string, required=true, description="意向城市")
|
|
|
279
|
+ * @ApiParams (name=content, type=string, required=true, description="自身优势")
|
|
|
280
|
+ * @ApiReturn ({
|
|
|
281
|
+ 'code':'1',
|
|
|
282
|
+ 'msg':'SUCCESS'
|
|
|
283
|
+ "data":
|
|
|
284
|
+ })
|
|
|
285
|
+ */
|
|
|
286
|
+ public function joinUs()
|
|
|
287
|
+ {
|
|
|
288
|
+ $work = $this->request->post('work');
|
|
|
289
|
+ $years = $this->request->post('years');
|
|
|
290
|
+ $username = $this->request->post('username');
|
|
|
291
|
+ $mobile = $this->request->post('mobile');
|
|
|
292
|
+ $money = $this->request->post('money');
|
|
|
293
|
+ $team = $this->request->post('team');
|
|
|
294
|
+ $city = $this->request->post('city');
|
|
|
295
|
+ $content = $this->request->post('content');
|
|
|
296
|
+ $data = [
|
|
|
297
|
+ 'work' => $work,
|
|
|
298
|
+ 'mobile' => $mobile,
|
|
|
299
|
+ 'username' => $username,
|
|
|
300
|
+ 'years' => $years,
|
|
|
301
|
+ 'money' => $money,
|
|
|
302
|
+ 'team' => $team,
|
|
|
303
|
+ 'city' => $city,
|
|
|
304
|
+ 'content' => $content,
|
|
|
305
|
+ ];
|
|
|
306
|
+ $rule = [
|
|
|
307
|
+ 'work' => 'require',
|
|
|
308
|
+ 'mobile' => 'require|regex:^1\d{10}$',
|
|
|
309
|
+ 'years' => 'require',
|
|
|
310
|
+ 'username' => 'require',
|
|
|
311
|
+ 'money' => 'require',
|
|
|
312
|
+ 'team' => 'require|in:0,1',
|
|
|
313
|
+ 'city' => 'require',
|
|
|
314
|
+ 'content' => 'require|max:100',
|
|
|
315
|
+ ];
|
|
|
316
|
+ $msg = [
|
|
|
317
|
+ 'work' => '请填写从事行业',
|
|
|
318
|
+ 'mobile' => '请正确填写电话号码',
|
|
|
319
|
+ 'years' => '请填写从业时间',
|
|
|
320
|
+ 'username' => '请输入姓名',
|
|
|
321
|
+ 'money' => '请输入可投入资金',
|
|
|
322
|
+ 'team' => '请选择是否拥有团队',
|
|
|
323
|
+ 'city' => '请填写意向城市',
|
|
|
324
|
+ 'content' => '请填写描述控制在100字以内',
|
|
|
325
|
+ ];
|
|
|
326
|
+ $validate = new \think\Validate();
|
|
|
327
|
+ $validate->rule($rule);
|
|
|
328
|
+ $validate->message($msg);
|
|
|
329
|
+ if (!$validate->check($data)) $this->error($validate->getError());
|
|
|
330
|
+ $data['createtime'] = time();
|
|
|
331
|
+ Db::name('join_us')->insert($data);
|
|
|
332
|
+ $this->success('SUCCESS');
|
|
|
333
|
+ }
|
|
|
334
|
+
|
|
|
335
|
+
|
|
|
336
|
+ /**
|
|
|
337
|
+ * @ApiTitle (帮助反馈列表)
|
|
|
338
|
+ * @ApiMethod (POST)
|
|
|
339
|
+ * @ApiHeaders (name=token, type=string, required=true, description="token")
|
|
|
340
|
+ * @ApiParams (name=page, type=integer, required=true, description="页数")
|
|
|
341
|
+ * @ApiReturn ({
|
|
|
342
|
+ 'code':'1',
|
|
|
343
|
+ 'msg':'SUCCESS'
|
|
|
344
|
+ "data":
|
|
|
345
|
+ "list": {
|
|
|
346
|
+ "total": 1,
|
|
|
347
|
+ "per_page": 15,
|
|
|
348
|
+ "current_page": 1,
|
|
|
349
|
+ "last_page": 1,
|
|
|
350
|
+ "data": [
|
|
|
351
|
+ {
|
|
|
352
|
+ "id": 1,
|
|
|
353
|
+ "title": "123", 标题
|
|
|
354
|
+ "content": "啊实打实大苏打", 内容
|
|
|
355
|
+ }
|
|
|
356
|
+ ]
|
|
|
357
|
+ },
|
|
|
358
|
+ "rider_status": 0 申请骑手状态:0=无,1=申请中,2=成功,3=拒绝
|
|
|
359
|
+ })
|
|
|
360
|
+ */
|
|
|
361
|
+ public function helpsList()
|
|
|
362
|
+ {
|
|
|
363
|
+ $page = $this->request->post('page');
|
|
|
364
|
+ if (!is_numeric($page)) $this->error('页数参数不合法');
|
|
|
365
|
+ $list = Db::name('helps')
|
|
|
366
|
+ ->order('id','desc')
|
|
|
367
|
+ ->paginate(15,false,['page'=>$page]);
|
|
|
368
|
+ $this->success('SUCCESS',['list'=>$list,'rider_status'=>0]);
|
|
|
369
|
+ }
|
|
|
370
|
+
|
|
|
371
|
+ /**
|
|
|
372
|
+ * @ApiTitle (申请成为骑手)
|
|
|
373
|
+ * @ApiMethod (POST)
|
|
|
374
|
+ * @ApiHeaders (name=token, type=string, required=true, description="token")
|
|
|
375
|
+ * @ApiReturn ({
|
|
|
376
|
+ 'code':'1',
|
|
|
377
|
+ 'msg':'SUCCESS'
|
|
|
378
|
+ "data":
|
135
|
})
|
379
|
})
|
136
|
*/
|
380
|
*/
|
137
|
- public function userAgreement()
|
381
|
+ public function riderApply()
|
138
|
{
|
382
|
{
|
139
|
- $this->success('用户协议', Config::get('site.user_agreement'));
|
383
|
+ if ($this->auth->rider > 0){
|
|
|
384
|
+ $this->error('您已申请,不可重复申请');
|
|
|
385
|
+ }
|
|
|
386
|
+ $user = $this->auth->getUser();
|
|
|
387
|
+ $user->rider = '1';
|
|
|
388
|
+ $user->save();
|
|
|
389
|
+ $this->success('SUCCESS');
|
140
|
}
|
390
|
}
|
141
|
|
391
|
|
142
|
/**
|
392
|
/**
|
143
|
- * @ApiTitle (隐私协议)
|
393
|
+ * @ApiTitle (邀请有奖)
|
144
|
* @ApiMethod (POST)
|
394
|
* @ApiMethod (POST)
|
|
|
395
|
+ * @ApiHeaders (name=token, type=string, required=true, description="token")
|
145
|
* @ApiReturn ({
|
396
|
* @ApiReturn ({
|
146
|
'code':'1',
|
397
|
'code':'1',
|
147
|
- 'msg':'隐私协议'
|
|
|
148
|
- 'data':'富文本'
|
398
|
+ 'msg':'SUCCESS'
|
|
|
399
|
+ "data":
|
149
|
})
|
400
|
})
|
150
|
*/
|
401
|
*/
|
151
|
- public function privacyAgreement()
|
402
|
+ public function inviteReward()
|
152
|
{
|
403
|
{
|
153
|
- $this->success('隐私协议', Config::get('site.privacy_agreement'));
|
404
|
+ if ($this->auth->rider > 0){
|
|
|
405
|
+ $this->error('您已申请,不可重复申请');
|
|
|
406
|
+ }
|
|
|
407
|
+ $user = $this->auth->getUser();
|
|
|
408
|
+ $user->rider = '1';
|
|
|
409
|
+ $user->save();
|
|
|
410
|
+ $this->success('SUCCESS');
|
154
|
}
|
411
|
}
|
155
|
} |
412
|
} |