1
|
-<?php
|
|
|
2
|
-namespace app\mobile\controller;
|
|
|
3
|
-
|
|
|
4
|
-use think\Validate;
|
|
|
5
|
-use think\Db;
|
|
|
6
|
-use think\Exception;
|
|
|
7
|
-use think\exception\PDOException;
|
|
|
8
|
-use app\common\controller\Api;
|
|
|
9
|
-use app\common\library\Sms as Smslib;
|
|
|
10
|
-use app\mobile\controller\Sms;
|
|
|
11
|
-use app\mobile\model\Company;
|
|
|
12
|
-use app\mobile\model\CompanyUser;
|
|
|
13
|
-use app\mobile\model\Agreement;
|
|
|
14
|
-use app\mobile\model\Exam;
|
|
|
15
|
-use app\mobile\model\CourseOrder;
|
|
|
16
|
-use app\mobile\model\CourseAppraise;
|
|
|
17
|
-use app\mobile\model\SecretOrder;
|
|
|
18
|
-use app\mobile\model\ScoreSpec;
|
|
|
19
|
-use app\mobile\model\ScoreOrder;
|
|
|
20
|
-use app\mobile\model\QuestionCollect;
|
|
|
21
|
-use app\mobile\model\CourseCollect;
|
|
|
22
|
-use app\mobile\model\QuestionNote;
|
|
|
23
|
-use app\mobile\model\Message;
|
|
|
24
|
-use app\mobile\model\Feedback;
|
|
|
25
|
-use app\mobile\model\Problem;
|
|
|
26
|
-use addons\epay\library\Service;
|
|
|
27
|
-
|
|
|
28
|
-/**
|
|
|
29
|
- * 我的接口
|
|
|
30
|
- * @ApiWeigh (66)
|
|
|
31
|
- */
|
|
|
32
|
-class User extends Api
|
|
|
33
|
-{
|
|
|
34
|
- protected $noNeedLogin = ['registerUser','agreementUser','registerCompany','agreementCompany','login','resetpwd','exam','noLogin'];
|
|
|
35
|
- protected $noNeedRight = ['*'];
|
|
|
36
|
-
|
|
|
37
|
- public function _initialize()
|
|
|
38
|
- {
|
|
|
39
|
- parent::_initialize();
|
|
|
40
|
- }
|
|
|
41
|
-
|
|
|
42
|
- /**
|
|
|
43
|
- * @ApiWeigh (99)
|
|
|
44
|
- * @ApiTitle (注册-个人)
|
|
|
45
|
- * @ApiSummary (注册-个人)
|
|
|
46
|
- * @param string $mobile 手机号
|
|
|
47
|
- * @param string $code 验证码
|
|
|
48
|
- * @param string $password 密码
|
|
|
49
|
- */
|
|
|
50
|
- public function registerUser()
|
|
|
51
|
- {
|
|
|
52
|
- $mobile = $this->request->param('mobile');
|
|
|
53
|
- $code = $this->request->param('code');
|
|
|
54
|
- $password = $this->request->param('password');
|
|
|
55
|
-
|
|
|
56
|
- empty($mobile) && $this->error('请输入手机号');
|
|
|
57
|
- empty($code) && $this->error('请输入验证码');
|
|
|
58
|
- empty($password) && $this->error('请输入密码');
|
|
|
59
|
- !Validate::regex($mobile, "^1\d{10}$") && $this->error('手机号格式不正确');
|
|
|
60
|
- $ret = Sms::check($mobile, $code, 'register');
|
|
|
61
|
- !$ret && $this->error('验证码不正确');
|
|
|
62
|
-
|
|
|
63
|
- $ret = $this->auth->register($username=$mobile, $password, $email='', $mobile, []);
|
|
|
64
|
- if ($ret) {
|
|
|
65
|
- $data = ['userinfo' => $this->auth->getUserinfo()];
|
|
|
66
|
- $this->success('注册成功', $data);
|
|
|
67
|
- } else {
|
|
|
68
|
- $this->error($this->auth->getError());
|
|
|
69
|
- }
|
|
|
70
|
- }
|
|
|
71
|
-
|
|
|
72
|
- /**
|
|
|
73
|
- * @ApiWeigh (97)
|
|
|
74
|
- * @ApiTitle (注册协议-个人)
|
|
|
75
|
- * @ApiSummary (注册协议-个人)
|
|
|
76
|
- * @ApiMethod (POST)
|
|
|
77
|
- *
|
|
|
78
|
- * @ApiReturn({
|
|
|
79
|
- "code": 1,
|
|
|
80
|
- "msg": "成功",
|
|
|
81
|
- "time": "1599017563",
|
|
|
82
|
- "data": "用户协议内容" //协议内容
|
|
|
83
|
- })
|
|
|
84
|
- */
|
|
|
85
|
- public function agreementUser()
|
|
|
86
|
- {
|
|
|
87
|
- $content = Db::name('mobile_config')->where('id',1)->value('user_agreement');
|
|
|
88
|
- $this->success('成功', $content);
|
|
|
89
|
- }
|
|
|
90
|
-
|
|
|
91
|
- /**
|
|
|
92
|
- * @ApiWeigh (95)
|
|
|
93
|
- * @ApiTitle (注册-公司)
|
|
|
94
|
- * @ApiSummary (注册-公司)
|
|
|
95
|
- * @param string $name 公司名称
|
|
|
96
|
- * @param string $address 公司地址
|
|
|
97
|
- * @param string $license 公司执照
|
|
|
98
|
- * @param string $legal_person 法人名称
|
|
|
99
|
- * @param string $mobile 手机号
|
|
|
100
|
- * @param string $code 验证码
|
|
|
101
|
- * @param string $password 密码
|
|
|
102
|
- */
|
|
|
103
|
- public function registerCompany()
|
|
|
104
|
- {
|
|
|
105
|
- $name = $this->request->param('name');
|
|
|
106
|
- $address = $this->request->param('address');
|
|
|
107
|
- $license = $this->request->param('license');
|
|
|
108
|
- $legal_person = $this->request->param('legal_person');
|
|
|
109
|
- $mobile = $this->request->param('mobile');
|
|
|
110
|
- $code = $this->request->param('code');
|
|
|
111
|
- $password = $this->request->param('password');
|
|
|
112
|
-
|
|
|
113
|
- empty($name) && $this->error('请输入公司名称');
|
|
|
114
|
- empty($address) && $this->error('请输入地址');
|
|
|
115
|
- empty($license) && $this->error('请上传执照');
|
|
|
116
|
- empty($legal_person) && $this->error('请输入法人名称');
|
|
|
117
|
- empty($mobile) && $this->error('请输入手机号');
|
|
|
118
|
- empty($code) && $this->error('请输入验证码');
|
|
|
119
|
- empty($password) && $this->error('请输入密码');
|
|
|
120
|
- !Validate::regex($mobile, "^1\d{10}$") && $this->error('手机号格式不正确');
|
|
|
121
|
- $ret = Sms::check($mobile, $code, 'register');
|
|
|
122
|
- !$ret && $this->error('验证码不正确');
|
|
|
123
|
-
|
|
|
124
|
- Db::startTrans();
|
|
|
125
|
- try {
|
|
|
126
|
- $ret = $this->auth->register($username='', $password, $email='', $mobile, ['group_id'=>1]);
|
|
|
127
|
- if (!$ret) {
|
|
|
128
|
- $this->error($this->auth->getError());
|
|
|
129
|
- }
|
|
|
130
|
- $company = Company::create([
|
|
|
131
|
- 'user_id' => $this->auth->id,
|
|
|
132
|
- 'name' => $name,
|
|
|
133
|
- 'address' => $address,
|
|
|
134
|
- 'license' => $license,
|
|
|
135
|
- 'legal_person' => $legal_person
|
|
|
136
|
- ]);
|
|
|
137
|
- // 添加企业邀请码
|
|
|
138
|
- $this->setInviteCode($company['id']);
|
|
|
139
|
- Db::commit();
|
|
|
140
|
- } catch (PDOException $e) {
|
|
|
141
|
- Db::rollback();
|
|
|
142
|
- $this->auth->logout();
|
|
|
143
|
- $this->error($e->getMessage());
|
|
|
144
|
- } catch (Exception $e) {
|
|
|
145
|
- Db::rollback();
|
|
|
146
|
- $this->auth->logout();
|
|
|
147
|
- $this->error($e->getMessage());
|
|
|
148
|
- }
|
|
|
149
|
- $this->success('注册成功', ['userinfo' => $this->auth->getUserinfo()]);
|
|
|
150
|
- }
|
|
|
151
|
-
|
|
|
152
|
- /**
|
|
|
153
|
- * @ApiWeigh (93)
|
|
|
154
|
- * @ApiTitle (注册协议-公司)
|
|
|
155
|
- * @ApiSummary (注册协议-公司)
|
|
|
156
|
- * @ApiMethod (POST)
|
|
|
157
|
- *
|
|
|
158
|
- * @ApiReturn({
|
|
|
159
|
- "code": 1,
|
|
|
160
|
- "msg": "成功",
|
|
|
161
|
- "time": "1599017563",
|
|
|
162
|
- "data": "用户协议内容" //协议内容
|
|
|
163
|
- })
|
|
|
164
|
- */
|
|
|
165
|
- public function agreementCompany()
|
|
|
166
|
- {
|
|
|
167
|
- $content = Db::name('mobile_config')->where('id',1)->value('company_agreement');
|
|
|
168
|
- $this->success('成功', $content);
|
|
|
169
|
- }
|
|
|
170
|
-
|
|
|
171
|
- /**
|
|
|
172
|
- * @ApiWeigh (91)
|
|
|
173
|
- * @ApiTitle (登录)
|
|
|
174
|
- * @ApiSummary (登录)
|
|
|
175
|
- * @param string $mobile 手机号
|
|
|
176
|
- * @param string $password 密码
|
|
|
177
|
- */
|
|
|
178
|
- public function login()
|
|
|
179
|
- {
|
|
|
180
|
- $mobile = $this->request->param('mobile');
|
|
|
181
|
- $password = $this->request->param('password');
|
|
|
182
|
-
|
|
|
183
|
- empty($mobile) && $this->error('请输入手机号');
|
|
|
184
|
- empty($password) && $this->error('请输入密码');
|
|
|
185
|
- !Validate::regex($mobile, "^1\d{10}$") && $this->error('手机号格式不正确');
|
|
|
186
|
-
|
|
|
187
|
- $ret = $this->auth->login($mobile, $password);
|
|
|
188
|
- if ($ret) {
|
|
|
189
|
- $data = ['userinfo' => $this->auth->getUserinfo()];
|
|
|
190
|
- $this->success('登录成功', $data);
|
|
|
191
|
- } else {
|
|
|
192
|
- $this->error($this->auth->getError());
|
|
|
193
|
- }
|
|
|
194
|
- }
|
|
|
195
|
-
|
|
|
196
|
- /**
|
|
|
197
|
- * @ApiWeigh (89)
|
|
|
198
|
- * @ApiTitle (忘记密码)
|
|
|
199
|
- * @ApiSummary (忘记密码)
|
|
|
200
|
- *
|
|
|
201
|
- * @param string $mobile 手机号
|
|
|
202
|
- * @param string $newpassword 新密码
|
|
|
203
|
- * @param string $code 验证码
|
|
|
204
|
- */
|
|
|
205
|
- public function resetpwd()
|
|
|
206
|
- {
|
|
|
207
|
- $mobile = $this->request->request("mobile");
|
|
|
208
|
- $code = $this->request->request("code");
|
|
|
209
|
- $newpassword = $this->request->request("newpassword");
|
|
|
210
|
-
|
|
|
211
|
- empty($mobile) && $this->error('请输入手机号');
|
|
|
212
|
- empty($newpassword) && $this->error('请输入密码');
|
|
|
213
|
- !Validate::regex($mobile, "^1\d{10}$") && $this->error('手机号格式不正确');
|
|
|
214
|
- $user = \app\common\model\User::getByMobile($mobile);
|
|
|
215
|
- !$user && $this->error('用户不存在');
|
|
|
216
|
- $ret = Sms::check($mobile, $code, 'resetpwd');
|
|
|
217
|
- !$ret && $this->error('验证码不正确');
|
|
|
218
|
-
|
|
|
219
|
- Smslib::flush($mobile, 'resetpwd');
|
|
|
220
|
- //模拟一次登录
|
|
|
221
|
- $this->auth->direct($user->id);
|
|
|
222
|
- $ret = $this->auth->changepwd($newpassword, '', true);
|
|
|
223
|
- if ($ret) {
|
|
|
224
|
- $this->success('重置密码成功');
|
|
|
225
|
- } else {
|
|
|
226
|
- $this->error($this->auth->getError());
|
|
|
227
|
- }
|
|
|
228
|
- }
|
|
|
229
|
-
|
|
|
230
|
- /**
|
|
|
231
|
- * @ApiWeigh (87)
|
|
|
232
|
- * @ApiTitle (选择参加的考试)
|
|
|
233
|
- * @ApiSummary (选择参加的考试)
|
|
|
234
|
- * @ApiMethod (POST)
|
|
|
235
|
- *
|
|
|
236
|
- * @ApiReturn({
|
|
|
237
|
- "code": 1,
|
|
|
238
|
- "msg": "成功",
|
|
|
239
|
- "time": "1599018234",
|
|
|
240
|
- "data": [{
|
|
|
241
|
- "id": 1, //一级ID
|
|
|
242
|
- "pid": 0,
|
|
|
243
|
- "name": "建筑工程", //一级名称
|
|
|
244
|
- "nickname": "", //一级昵称
|
|
|
245
|
- "children": [{ //二级
|
|
|
246
|
- "id": 3, //二级ID
|
|
|
247
|
- "pid": 1, //父ID
|
|
|
248
|
- "name": "一级建造师", //二级名称
|
|
|
249
|
- "nickname": "" //二级昵称
|
|
|
250
|
- }]
|
|
|
251
|
- }]
|
|
|
252
|
- })
|
|
|
253
|
- */
|
|
|
254
|
- public function exam()
|
|
|
255
|
- {
|
|
|
256
|
- $list = Exam::where('pid',0)->field('id,pid,name,nickname')->select();
|
|
|
257
|
- foreach($list as &$v){
|
|
|
258
|
- $v['children'] = Exam::where('pid',$v['id'])->field('id,pid,name,nickname')->select();
|
|
|
259
|
- }
|
|
|
260
|
- $this->success('成功', $list);
|
|
|
261
|
- }
|
|
|
262
|
-
|
|
|
263
|
- /**
|
|
|
264
|
- * @ApiWeigh (85)
|
|
|
265
|
- * @ApiTitle (暂不登录提示)
|
|
|
266
|
- * @ApiSummary (暂不登录提示)
|
|
|
267
|
- * @ApiMethod (POST)
|
|
|
268
|
- *
|
|
|
269
|
- * @ApiReturn({
|
|
|
270
|
- "code": 1,
|
|
|
271
|
- "msg": "成功",
|
|
|
272
|
- "time": "1599017563",
|
|
|
273
|
- "data": "暂不登录提示内容" //暂不登录提示内容
|
|
|
274
|
- })
|
|
|
275
|
- */
|
|
|
276
|
- public function noLogin()
|
|
|
277
|
- {
|
|
|
278
|
- $content = Db::name('mobile_config')->where('id',1)->value('no_login');
|
|
|
279
|
- $this->success('成功', $content);
|
|
|
280
|
- }
|
|
|
281
|
-
|
|
|
282
|
- /**
|
|
|
283
|
- * @ApiWeigh (83)
|
|
|
284
|
- * @ApiTitle (我的-首页)
|
|
|
285
|
- * @ApiSummary (我的-首页)
|
|
|
286
|
- * @ApiMethod (POST)
|
|
|
287
|
- *
|
|
|
288
|
- * @ApiReturn({
|
|
|
289
|
- "code": 1,
|
|
|
290
|
- "msg": "成功",
|
|
|
291
|
- "time": "1599017563",
|
|
|
292
|
- "data": "暂不登录提示内容" //暂不登录提示内容
|
|
|
293
|
- })
|
|
|
294
|
- */
|
|
|
295
|
- public function index()
|
|
|
296
|
- {
|
|
|
297
|
- $user = $this->auth->getUser();
|
|
|
298
|
- $this->success('成功', $user);
|
|
|
299
|
- }
|
|
|
300
|
-
|
|
|
301
|
- /**
|
|
|
302
|
- * @ApiWeigh (81)
|
|
|
303
|
- * @ApiTitle (我的-修改会员个人信息)
|
|
|
304
|
- * @ApiSummary (我的-修改会员个人信息)
|
|
|
305
|
- *
|
|
|
306
|
- * @param string $image 头像地址
|
|
|
307
|
- * @param string $username 用户名
|
|
|
308
|
- * @param string $nickname 真实姓名
|
|
|
309
|
- */
|
|
|
310
|
- public function profile()
|
|
|
311
|
- {
|
|
|
312
|
- $user = $this->auth->getUser();
|
|
|
313
|
- $username = $this->request->param('username');
|
|
|
314
|
- $nickname = $this->request->param('nickname');
|
|
|
315
|
- $image = $this->request->param('image', '', 'trim,strip_tags,htmlspecialchars');
|
|
|
316
|
- if($username || $nickname || $image) {
|
|
|
317
|
- if ($username) {
|
|
|
318
|
- $user->username = $username;
|
|
|
319
|
- }
|
|
|
320
|
- if ($nickname) {
|
|
|
321
|
- $user->nickname = $nickname;
|
|
|
322
|
- }
|
|
|
323
|
- if ($image) {
|
|
|
324
|
- $user->image = $image;
|
|
|
325
|
- }
|
|
|
326
|
- $user->save();
|
|
|
327
|
- }
|
|
|
328
|
- $this->success();
|
|
|
329
|
- }
|
|
|
330
|
-
|
|
|
331
|
- /**
|
|
|
332
|
- * @ApiWeigh (79)
|
|
|
333
|
- * @ApiTitle (修改手机号-第一步)
|
|
|
334
|
- * @ApiSummary (修改手机号-第一步)
|
|
|
335
|
- * @param string $code 验证码
|
|
|
336
|
- */
|
|
|
337
|
- public function changemobile1()
|
|
|
338
|
- {
|
|
|
339
|
- $user = $this->auth->getUser();
|
|
|
340
|
- $code = $this->request->param('code');
|
|
|
341
|
- !$code && $this->error(__('请输入验证码'));
|
|
|
342
|
- $ret = Sms::check($user['mobile'], $code, 'changemobile1');
|
|
|
343
|
- !$ret && $this->error('验证码不正确');
|
|
|
344
|
- Smslib::flush($user['mobile'], 'changemobile1');
|
|
|
345
|
- $this->success();
|
|
|
346
|
- }
|
|
|
347
|
-
|
|
|
348
|
- /**
|
|
|
349
|
- * @ApiWeigh (77)
|
|
|
350
|
- * @ApiTitle (修改手机号-第二步)
|
|
|
351
|
- * @ApiSummary (修改手机号-第二步)
|
|
|
352
|
- *
|
|
|
353
|
- * @param string $mobile 新手机号
|
|
|
354
|
- * @param string $code 验证码
|
|
|
355
|
- */
|
|
|
356
|
- public function changemobile2()
|
|
|
357
|
- {
|
|
|
358
|
- $user = $this->auth->getUser();
|
|
|
359
|
- $mobile = $this->request->param('mobile');
|
|
|
360
|
- $code = $this->request->param('code');
|
|
|
361
|
- if (!$mobile || !$code) {
|
|
|
362
|
- $this->error(__('Invalid parameters'));
|
|
|
363
|
- }
|
|
|
364
|
- if (!Validate::regex($mobile, "^1\d{10}$")) {
|
|
|
365
|
- $this->error(__('Mobile is incorrect'));
|
|
|
366
|
- }
|
|
|
367
|
- if (\app\common\model\User::where('mobile', $mobile)->where('id', '<>', $user->id)->find()) {
|
|
|
368
|
- $this->error(__('Mobile already exists'));
|
|
|
369
|
- }
|
|
|
370
|
- $result = Sms::check($mobile, $code, 'changemobile2');
|
|
|
371
|
- if (!$result) {
|
|
|
372
|
- $this->error(__('Captcha is incorrect'));
|
|
|
373
|
- }
|
|
|
374
|
- $verification = $user->verification;
|
|
|
375
|
- $verification->mobile = 1;
|
|
|
376
|
- $user->verification = $verification;
|
|
|
377
|
- $user->mobile = $mobile;
|
|
|
378
|
- $user->save();
|
|
|
379
|
-
|
|
|
380
|
- Smslib::flush($mobile, 'changemobile2');
|
|
|
381
|
- $this->success();
|
|
|
382
|
- }
|
|
|
383
|
-
|
|
|
384
|
- /**
|
|
|
385
|
- * @ApiWeigh (75)
|
|
|
386
|
- * @ApiTitle (加入企业)
|
|
|
387
|
- * @ApiSummary (加入企业)
|
|
|
388
|
- *
|
|
|
389
|
- * @param string $company_id 企业ID
|
|
|
390
|
- * @param string $name 姓名
|
|
|
391
|
- * @param string $mobile 手机号
|
|
|
392
|
- * @param string $invite_code 验证码
|
|
|
393
|
- */
|
|
|
394
|
- public function joinCompany()
|
|
|
395
|
- {
|
|
|
396
|
- $company_id = $this->request->param('company_id');
|
|
|
397
|
- $name = $this->request->param('name');
|
|
|
398
|
- $mobile = $this->request->param('mobile');
|
|
|
399
|
- $invite_code = $this->request->param('invite_code');
|
|
|
400
|
- // 验证传参
|
|
|
401
|
- empty($company_id) && $this->error('缺少必需参数');
|
|
|
402
|
- empty($name) && $this->error('请填写姓名');
|
|
|
403
|
- empty($mobile) && $this->error('请填写联系方式');
|
|
|
404
|
- empty($invite_code) && $this->error('请填写邀请码');
|
|
|
405
|
- !Validate::regex($mobile, "^1\d{10}$") && $this->error(__('Mobile is incorrect'));
|
|
|
406
|
- // 验证邀请码
|
|
|
407
|
- $company = Company::where('invite_code',$invite_code)
|
|
|
408
|
- ->where('id',$company_id)
|
|
|
409
|
- ->field('id')
|
|
|
410
|
- ->find();
|
|
|
411
|
- empty($company) && $this->error('邀请码错误,请输入正确的邀请码');
|
|
|
412
|
- // 验证申请状态
|
|
|
413
|
- $company_user = CompanyUser::where('company_id',$company['id'])->field('status')->find();
|
|
|
414
|
- if($company_user){
|
|
|
415
|
- if($company_user['status'] == '0'){
|
|
|
416
|
- $this->error('正在申请中,请勿重复提交申请');
|
|
|
417
|
- }
|
|
|
418
|
- if($company_user['status'] == '1'){
|
|
|
419
|
- $this->error('加入企业成功,请勿重复提交申请');
|
|
|
420
|
- }
|
|
|
421
|
- }
|
|
|
422
|
- CompanyUser::create([
|
|
|
423
|
- 'user_id' => $this->auth->id,
|
|
|
424
|
- 'company_id' => $company_id,
|
|
|
425
|
- 'name' => $name,
|
|
|
426
|
- 'mobile' => $mobile
|
|
|
427
|
- ]);
|
|
|
428
|
- $this->success('已成功提交,请提醒企业管理员及时审核');
|
|
|
429
|
- }
|
|
|
430
|
-
|
|
|
431
|
- /**
|
|
|
432
|
- * 更新企业邀请码
|
|
|
433
|
- * @param string $company_id 企业ID
|
|
|
434
|
- */
|
|
|
435
|
- private function setInviteCode($company_id){
|
|
|
436
|
- $code = mt_rand(100000,999999);
|
|
|
437
|
- $find = Company::where('invite_code',$code)->field('id')->find();
|
|
|
438
|
- if(!$find){
|
|
|
439
|
- Company::where('id',$company_id)->setField('invite_code',$code);
|
|
|
440
|
- return true;
|
|
|
441
|
- }else{
|
|
|
442
|
- $this->setInviteCode($company_id);
|
|
|
443
|
- }
|
|
|
444
|
- }
|
|
|
445
|
-
|
|
|
446
|
- /**
|
|
|
447
|
- * @ApiWeigh (73)
|
|
|
448
|
- * @ApiTitle (我的课程)
|
|
|
449
|
- * @ApiSummary (我的课程)
|
|
|
450
|
- * @ApiMethod (POST)
|
|
|
451
|
- *
|
|
|
452
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
453
|
- *
|
|
|
454
|
- * @ApiReturn({
|
|
|
455
|
- "code": 1,
|
|
|
456
|
- "msg": "成功",
|
|
|
457
|
- "time": "1600081718",
|
|
|
458
|
- "data": [{
|
|
|
459
|
- "id": 9, //课程订单ID
|
|
|
460
|
- "pay_price": "50.00", //实际支付金额
|
|
|
461
|
- "course": { //课程信息
|
|
|
462
|
- "title": "测试课程", //课程标题
|
|
|
463
|
- "cover": "" //课程封面图
|
|
|
464
|
- },
|
|
|
465
|
- "is_have_qi": 0 //是否有企字:0=否,1=是
|
|
|
466
|
- }]
|
|
|
467
|
- })
|
|
|
468
|
- */
|
|
|
469
|
- public function myCourse(){
|
|
|
470
|
- // 我加入的企业购买的课程
|
|
|
471
|
- $company_course_list = CourseOrder::alias('co')
|
|
|
472
|
- ->join('mobile_company_user cu','cu.company_id = co.company_id')
|
|
|
473
|
- ->where('cu.user_id',$this->auth->id)
|
|
|
474
|
- ->where('cu.status','1')
|
|
|
475
|
- ->field('co.id,co.company_id,co.people_num')
|
|
|
476
|
- ->select();
|
|
|
477
|
- // 查询我是否可以享受企业课程(按企业审核时间排队,没在队伍里就无法享受企业课程)
|
|
|
478
|
- $course_id_arr = [];
|
|
|
479
|
- foreach ($company_course_list as $v) {
|
|
|
480
|
- $user_id_arr = CompanyUser::where('company_id',$v['company_id'])
|
|
|
481
|
- ->where('status','1')
|
|
|
482
|
- ->order('updatetime asc')
|
|
|
483
|
- ->limit($v['people_num'])
|
|
|
484
|
- ->column('user_id');
|
|
|
485
|
- if(in_array($this->auth->id,$user_id_arr)){
|
|
|
486
|
- $course_id_arr[] = $v['id'];
|
|
|
487
|
- }
|
|
|
488
|
- }
|
|
|
489
|
- // 查找所有课程
|
|
|
490
|
- $list = CourseOrder::with(['course'])
|
|
|
491
|
- ->where(function($query)use($course_id_arr){
|
|
|
492
|
- $query->where('user_id', $this->auth->id)->whereor('id', 'in', $course_id_arr);
|
|
|
493
|
- })
|
|
|
494
|
- ->where('pay_status','1')
|
|
|
495
|
- ->select();
|
|
|
496
|
- foreach ($list as $v) {
|
|
|
497
|
- $v['is_have_qi'] = in_array($v['id'], $course_id_arr) ? 1 : 0;
|
|
|
498
|
- $v->visible(['id','pay_price','course'])->append(['is_have_qi']);
|
|
|
499
|
- $v->getRelation('course')->visible(['cover','title']);
|
|
|
500
|
- }
|
|
|
501
|
- $this->success('成功',$list);
|
|
|
502
|
- }
|
|
|
503
|
-
|
|
|
504
|
- /**
|
|
|
505
|
- * @ApiWeigh (71)
|
|
|
506
|
- * @ApiTitle (我的课程-评价页面)
|
|
|
507
|
- * @ApiSummary (我的课程-评价页面)
|
|
|
508
|
- * @ApiMethod (POST)
|
|
|
509
|
- *
|
|
|
510
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
511
|
- * @ApiParams (name="course_order_id", type="int", required=true, description="课程订单ID")
|
|
|
512
|
- *
|
|
|
513
|
- * @ApiReturn({
|
|
|
514
|
- "code": 1,
|
|
|
515
|
- "msg": "成功",
|
|
|
516
|
- "time": "1600084253",
|
|
|
517
|
- "data": {
|
|
|
518
|
- "id": 10, //课程订单ID
|
|
|
519
|
- "pay_price": "50.00", //实际支付金额
|
|
|
520
|
- "course": { //课程信息
|
|
|
521
|
- "title": "测试课程", //课程标题
|
|
|
522
|
- "cover": "" //课程封面图
|
|
|
523
|
- },
|
|
|
524
|
- "is_have_qi": 0 //是否有企字:0=否,1=是
|
|
|
525
|
- }
|
|
|
526
|
- })
|
|
|
527
|
- */
|
|
|
528
|
- public function appraiseView(){
|
|
|
529
|
- $course_order_id = $this->request->param('course_order_id');
|
|
|
530
|
- empty($course_order_id) && $this->error('缺少必需参数');
|
|
|
531
|
- $info = CourseOrder::get($course_order_id,['course']);
|
|
|
532
|
- empty($info) && $this->error('课程订单不存在');
|
|
|
533
|
- $user_id_arr = CompanyUser::where('company_id',$info['company_id'])
|
|
|
534
|
- ->where('status','1')
|
|
|
535
|
- ->order('updatetime asc')
|
|
|
536
|
- ->limit($info['people_num'])
|
|
|
537
|
- ->column('user_id');
|
|
|
538
|
- $info['is_have_qi'] = in_array($this->auth->id,$user_id_arr) ? 1 : 0;
|
|
|
539
|
- $info->visible(['id','pay_price','course'])->append(['is_have_qi']);
|
|
|
540
|
- $info->getRelation('course')->visible(['cover','title']);
|
|
|
541
|
- $this->success('成功',$info);
|
|
|
542
|
- }
|
|
|
543
|
-
|
|
|
544
|
- /**
|
|
|
545
|
- * @ApiWeigh (69)
|
|
|
546
|
- * @ApiTitle (我的课程-评价)
|
|
|
547
|
- * @ApiSummary (我的课程-评价)
|
|
|
548
|
- * @ApiMethod (POST)
|
|
|
549
|
- *
|
|
|
550
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
551
|
- * @ApiParams (name="course_order_id", type="int", required=true, description="课程订单ID")
|
|
|
552
|
- * @ApiParams (name="star", type="int", required=true, description="评价星数")
|
|
|
553
|
- * @ApiParams (name="content", type="int", required=true, description="评价内容")
|
|
|
554
|
- *
|
|
|
555
|
- * @ApiReturn({
|
|
|
556
|
- "code": 1,
|
|
|
557
|
- "msg": "成功",
|
|
|
558
|
- "time": "1600084253",
|
|
|
559
|
- "data": null
|
|
|
560
|
- })
|
|
|
561
|
- */
|
|
|
562
|
- public function appraise(){
|
|
|
563
|
- $course_order_id = $this->request->param('course_order_id');
|
|
|
564
|
- $star = $this->request->param('star');
|
|
|
565
|
- $content = $this->request->param('content');
|
|
|
566
|
- empty($course_order_id) && $this->error('缺少必需参数');
|
|
|
567
|
- empty($star) && $this->error('请选择星数');
|
|
|
568
|
- empty($content) && $this->error('请填写评价内容');
|
|
|
569
|
- $info = CourseOrder::get($course_order_id,['course']);
|
|
|
570
|
- empty($info) && $this->error('课程订单不存在');
|
|
|
571
|
- CourseAppraise::create([
|
|
|
572
|
- 'user_id' => $this->auth->id,
|
|
|
573
|
- 'course_id' => $info['course_id'],
|
|
|
574
|
- 'course_order_id' => $info['id'],
|
|
|
575
|
- 'star' => $star,
|
|
|
576
|
- 'content' => $content
|
|
|
577
|
- ]);
|
|
|
578
|
- $this->success('评价成功');
|
|
|
579
|
- }
|
|
|
580
|
-
|
|
|
581
|
- /**
|
|
|
582
|
- * @ApiWeigh (67)
|
|
|
583
|
- * @ApiTitle (我的密卷)
|
|
|
584
|
- * @ApiSummary (我的密卷)
|
|
|
585
|
- * @ApiMethod (POST)
|
|
|
586
|
- *
|
|
|
587
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
588
|
- *
|
|
|
589
|
- * @ApiReturn({
|
|
|
590
|
- "code": 1,
|
|
|
591
|
- "msg": "成功",
|
|
|
592
|
- "time": "1600081718",
|
|
|
593
|
- "data": [{
|
|
|
594
|
- "id": 9, //密卷订单ID
|
|
|
595
|
- "pay_price": "50.00", //实际支付金额
|
|
|
596
|
- "secret": { //密卷信息
|
|
|
597
|
- "title": "测试密卷", //密卷标题
|
|
|
598
|
- "do_num": "" //做过人数
|
|
|
599
|
- },
|
|
|
600
|
- "is_have_qi": 0 //是否有企字:0=否,1=是
|
|
|
601
|
- }]
|
|
|
602
|
- })
|
|
|
603
|
- */
|
|
|
604
|
- public function mySecret(){
|
|
|
605
|
- // 我加入的企业购买的密卷
|
|
|
606
|
- $company_secret_list = SecretOrder::alias('a')
|
|
|
607
|
- ->join('mobile_company_user b','b.company_id = a.company_id')
|
|
|
608
|
- ->where('b.user_id',$this->auth->id)
|
|
|
609
|
- ->where('b.status','1')
|
|
|
610
|
- ->field('a.id,a.company_id,a.people_num')
|
|
|
611
|
- ->select();
|
|
|
612
|
- // 查询我是否可以享受企业密卷(按企业审核时间排队,没在队伍里就无法享受企业密卷)
|
|
|
613
|
- $secret_id_arr = [];
|
|
|
614
|
- foreach ($company_secret_list as $v) {
|
|
|
615
|
- $user_id_arr = CompanyUser::where('company_id',$v['company_id'])
|
|
|
616
|
- ->where('status','1')
|
|
|
617
|
- ->order('updatetime asc')
|
|
|
618
|
- ->limit($v['people_num'])
|
|
|
619
|
- ->column('user_id');
|
|
|
620
|
- if(in_array($this->auth->id,$user_id_arr)){
|
|
|
621
|
- $secret_id_arr[] = $v['id'];
|
|
|
622
|
- }
|
|
|
623
|
- }
|
|
|
624
|
- // 查找所有密卷
|
|
|
625
|
- $list = SecretOrder::with(['secret'])
|
|
|
626
|
- ->where(function($query)use($secret_id_arr){
|
|
|
627
|
- $query->where('user_id', $this->auth->id)->whereor('id', 'in', $secret_id_arr);
|
|
|
628
|
- })
|
|
|
629
|
- ->where('pay_status','1')
|
|
|
630
|
- ->select();
|
|
|
631
|
- foreach ($list as $v) {
|
|
|
632
|
- $v['is_have_qi'] = in_array($v['id'], $secret_id_arr) ? 1 : 0;
|
|
|
633
|
- $v->visible(['id','pay_price','secret'])->append(['is_have_qi']);
|
|
|
634
|
- $v->getRelation('secret')->visible(['cover','title']);
|
|
|
635
|
- }
|
|
|
636
|
- $this->success('成功',$list);
|
|
|
637
|
- }
|
|
|
638
|
-
|
|
|
639
|
- /**
|
|
|
640
|
- * @ApiWeigh (65)
|
|
|
641
|
- * @ApiTitle (我的积分)
|
|
|
642
|
- * @ApiSummary (我的积分)
|
|
|
643
|
- * @ApiMethod (POST)
|
|
|
644
|
- *
|
|
|
645
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
646
|
- *
|
|
|
647
|
- * @ApiReturn({
|
|
|
648
|
- "code": 1,
|
|
|
649
|
- "msg": "成功",
|
|
|
650
|
- "time": "1600135095",
|
|
|
651
|
- "data": {
|
|
|
652
|
- "id": 16, //用户ID
|
|
|
653
|
- "score": 0, //当前积分
|
|
|
654
|
- "url": "/u/16",
|
|
|
655
|
- "max_score": 0 //累计积分
|
|
|
656
|
- }
|
|
|
657
|
- })
|
|
|
658
|
- */
|
|
|
659
|
- public function myScore(){
|
|
|
660
|
- $user = $this->auth->getUser();
|
|
|
661
|
- $user['max_score'] = db('user_score_log')->where('user_id',$user['id'])->max('after');
|
|
|
662
|
- $user = $user->visible(['id','score'])->append(['max_score'])->toArray();
|
|
|
663
|
- $this->success('成功',$user);
|
|
|
664
|
- }
|
|
|
665
|
-
|
|
|
666
|
- /**
|
|
|
667
|
- * @ApiWeigh (63)
|
|
|
668
|
- * @ApiTitle (积分说明)
|
|
|
669
|
- * @ApiSummary (积分说明)
|
|
|
670
|
- * @ApiMethod (POST)
|
|
|
671
|
- *
|
|
|
672
|
- * @ApiReturn({
|
|
|
673
|
- "code": 1,
|
|
|
674
|
- "msg": "成功",
|
|
|
675
|
- "time": "1599017563",
|
|
|
676
|
- "data": "积分说明" //积分说明内容
|
|
|
677
|
- })
|
|
|
678
|
- */
|
|
|
679
|
- public function scoreIntro()
|
|
|
680
|
- {
|
|
|
681
|
- $content = Db::name('mobile_config')->where('id',1)->value('user_score_intro');
|
|
|
682
|
- $this->success('成功', $content);
|
|
|
683
|
- }
|
|
|
684
|
-
|
|
|
685
|
- /**
|
|
|
686
|
- * @ApiWeigh (61)
|
|
|
687
|
- * @ApiTitle (积分记录)
|
|
|
688
|
- * @ApiSummary (积分记录)
|
|
|
689
|
- * @ApiMethod (POST)
|
|
|
690
|
- *
|
|
|
691
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
692
|
- * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
693
|
- * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
694
|
- *
|
|
|
695
|
- * @ApiReturn({
|
|
|
696
|
- "code": 1,
|
|
|
697
|
- "msg": "成功",
|
|
|
698
|
- "time": "1599017563",
|
|
|
699
|
- "data": "积分说明" //积分说明内容
|
|
|
700
|
- })
|
|
|
701
|
- */
|
|
|
702
|
- public function scoreLog()
|
|
|
703
|
- {
|
|
|
704
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
705
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
706
|
- $list = \app\common\model\ScoreLog::where('user_id',$this->auth->id)
|
|
|
707
|
- ->order('createtime desc')
|
|
|
708
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
709
|
- ->each(function($v){
|
|
|
710
|
- $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
|
|
|
711
|
- })->toArray();
|
|
|
712
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
713
|
- }
|
|
|
714
|
-
|
|
|
715
|
- /**
|
|
|
716
|
- * @ApiWeigh (59)
|
|
|
717
|
- * @ApiTitle (海报分享)
|
|
|
718
|
- * @ApiSummary (海报分享)
|
|
|
719
|
- * @ApiMethod (POST)
|
|
|
720
|
- *
|
|
|
721
|
- * @ApiReturn({
|
|
|
722
|
- "code": 1,
|
|
|
723
|
- "msg": "成功",
|
|
|
724
|
- "time": "1599017563",
|
|
|
725
|
- "data": "积分说明" //积分说明内容
|
|
|
726
|
- })
|
|
|
727
|
- */
|
|
|
728
|
- public function share()
|
|
|
729
|
- {
|
|
|
730
|
- $content = Db::name('mobile_config')->where('id',1)->value('user_score_intro');
|
|
|
731
|
- $this->success('成功', $content);
|
|
|
732
|
- }
|
|
|
733
|
-
|
|
|
734
|
- /**
|
|
|
735
|
- * @ApiWeigh (57)
|
|
|
736
|
- * @ApiTitle (充值积分-套餐)
|
|
|
737
|
- * @ApiSummary (充值积分-套餐)
|
|
|
738
|
- * @ApiMethod (POST)
|
|
|
739
|
- *
|
|
|
740
|
- * @ApiReturn({
|
|
|
741
|
- "code": 1,
|
|
|
742
|
- "msg": "成功",
|
|
|
743
|
- "time": "1599017563",
|
|
|
744
|
- "data": "积分说明" //积分说明内容
|
|
|
745
|
- })
|
|
|
746
|
- */
|
|
|
747
|
- public function scoreSpec()
|
|
|
748
|
- {
|
|
|
749
|
- $list = ScoreSpec::select();
|
|
|
750
|
- $score_recharge_price = Db::name('mobile_config')->where('id',1)->value('score_recharge_price');
|
|
|
751
|
- $this->success('成功', compact('list','score_recharge_price'));
|
|
|
752
|
- }
|
|
|
753
|
-
|
|
|
754
|
- /**
|
|
|
755
|
- * @ApiWeigh (55)
|
|
|
756
|
- * @ApiTitle (积分充值预览)
|
|
|
757
|
- * @ApiSummary (积分充值预览)
|
|
|
758
|
- * @ApiMethod (POST)
|
|
|
759
|
- *
|
|
|
760
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
761
|
- * @ApiParams (name="score_spec_id", type="int", required=false, description="套餐ID")
|
|
|
762
|
- * @ApiParams (name="score", type="int", required=false, description="自定义积分")
|
|
|
763
|
- *
|
|
|
764
|
- * @ApiReturn({
|
|
|
765
|
- "code": 1,
|
|
|
766
|
- "msg": "成功",
|
|
|
767
|
- "time": "1599046220",
|
|
|
768
|
- "data": {
|
|
|
769
|
- "id": 1, //试卷ID
|
|
|
770
|
- "title": "测试试卷", //试卷标题
|
|
|
771
|
- "year": 2015, //年费(单位:年)
|
|
|
772
|
- "time": 100, //答题时间(单位:分)
|
|
|
773
|
- "pass_score": 80, //合格分数
|
|
|
774
|
- "description": "这个还行", //试卷描述
|
|
|
775
|
- "do_num": 10, //回答人数
|
|
|
776
|
- "full_score": 100 //试卷分数(单位:分)
|
|
|
777
|
- }
|
|
|
778
|
- })
|
|
|
779
|
- */
|
|
|
780
|
- public function scoreRechargeView()
|
|
|
781
|
- {
|
|
|
782
|
- $param = $this->request->param();
|
|
|
783
|
- $model = new ScoreOrder;
|
|
|
784
|
- if(!$order = $model->payView($this->auth->getUser(),$param)){
|
|
|
785
|
- $this->error($model->getError(),null,$this->model->getCode());
|
|
|
786
|
- }
|
|
|
787
|
- $this->success(__('成功'),$order);
|
|
|
788
|
- }
|
|
|
789
|
-
|
|
|
790
|
- /**
|
|
|
791
|
- * @ApiWeigh (53)
|
|
|
792
|
- * @ApiTitle (充值积分)
|
|
|
793
|
- * @ApiSummary (充值积分)
|
|
|
794
|
- * @ApiMethod (POST)
|
|
|
795
|
- *
|
|
|
796
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
797
|
- * @ApiParams (name="score_spec_id", type="int", required=false, description="积分套餐ID")
|
|
|
798
|
- * @ApiParams (name="score", type="int", required=false, description="自定义积分")
|
|
|
799
|
- * @ApiParams (name="pay_type", type="string", required=true, description="支付方式:wechat=微信,alipay=支付宝")
|
|
|
800
|
- *
|
|
|
801
|
- * @ApiReturn({
|
|
|
802
|
- "code": 1,
|
|
|
803
|
- "msg": "成功",
|
|
|
804
|
- "time": "1599017563",
|
|
|
805
|
- "data": "积分说明" //积分说明内容
|
|
|
806
|
- })
|
|
|
807
|
- */
|
|
|
808
|
- public function scoreRecharge()
|
|
|
809
|
- {
|
|
|
810
|
- $param = $this->request->param();
|
|
|
811
|
- $model = new ScoreOrder;
|
|
|
812
|
- if(!$order = $model->payView($this->auth->getUser(),$param)){
|
|
|
813
|
- $this->error($model->getError(),null,$this->model->getCode());
|
|
|
814
|
- }
|
|
|
815
|
- if (!$param['pay_type'] || !in_array($param['pay_type'], ['alipay', 'wechat'])) {
|
|
|
816
|
- $this->error("请选择支付方式");
|
|
|
817
|
- }
|
|
|
818
|
- // 创建订单
|
|
|
819
|
- $model->add($this->auth->getUser(), $order, $param['pay_type']);
|
|
|
820
|
- //回调链接
|
|
|
821
|
- $notifyurl = $this->request->root(true) . '/mobile/notify/notifyScore/paytype/' . $param['pay_type'];
|
|
|
822
|
- $payment = Service::submitOrder($model['pay_price'], $model['order_sn'], $param['pay_type'], '积分', $notifyurl, null, 'app');
|
|
|
823
|
- $this->success('成功',$payment);
|
|
|
824
|
- }
|
|
|
825
|
-
|
|
|
826
|
- /**
|
|
|
827
|
- * @ApiWeigh (51)
|
|
|
828
|
- * @ApiTitle (我的收藏-题目)
|
|
|
829
|
- * @ApiSummary (我的收藏-题目)
|
|
|
830
|
- * @ApiMethod (POST)
|
|
|
831
|
- *
|
|
|
832
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
833
|
- * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
834
|
- * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
835
|
- *
|
|
|
836
|
- * @ApiReturn({
|
|
|
837
|
- "code": 1,
|
|
|
838
|
- "msg": "成功",
|
|
|
839
|
- "time": "1600162242",
|
|
|
840
|
- "data": {
|
|
|
841
|
- "total": 1, // 题目总数
|
|
|
842
|
- "list": [{
|
|
|
843
|
- "id": 1,
|
|
|
844
|
- "user_id": 16, //用户ID
|
|
|
845
|
- "question_id": 1, //题目ID
|
|
|
846
|
- "createtime": "2020.09.03 19:25", //收藏时间
|
|
|
847
|
- "question": { //题目信息
|
|
|
848
|
- "title": "测定混凝土立方体抗压强度时,标准试件的尺寸是( )㎜。", //题目
|
|
|
849
|
- "type": "1" //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
|
|
|
850
|
- }
|
|
|
851
|
- }]
|
|
|
852
|
- }
|
|
|
853
|
- })
|
|
|
854
|
- */
|
|
|
855
|
- public function collectQuestionList()
|
|
|
856
|
- {
|
|
|
857
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
858
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
859
|
- $data = QuestionCollect::with(['question'])
|
|
|
860
|
- ->where('user_id',$this->auth->id)
|
|
|
861
|
- ->order('createtime desc')
|
|
|
862
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
863
|
- ->each(function($v){
|
|
|
864
|
- $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
|
|
|
865
|
- $v->getRelation('question')->visible(['title','type']);
|
|
|
866
|
- })->toArray();
|
|
|
867
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
868
|
- }
|
|
|
869
|
-
|
|
|
870
|
- /**
|
|
|
871
|
- * @ApiWeigh (49)
|
|
|
872
|
- * @ApiTitle (我的收藏-课程)
|
|
|
873
|
- * @ApiSummary (我的收藏-课程)
|
|
|
874
|
- * @ApiMethod (POST)
|
|
|
875
|
- *
|
|
|
876
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
877
|
- * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
878
|
- * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
879
|
- *
|
|
|
880
|
- * @ApiReturn({
|
|
|
881
|
- "code": 1,
|
|
|
882
|
- "msg": "成功",
|
|
|
883
|
- "time": "1600164731",
|
|
|
884
|
- "data": {
|
|
|
885
|
- "total": 1, //数据总数
|
|
|
886
|
- "list": [{
|
|
|
887
|
- "id": 1,
|
|
|
888
|
- "user_id": 16, //用户ID
|
|
|
889
|
- "course_id": 1, //课程ID
|
|
|
890
|
- "createtime": "2020.09.03 19:25", //收藏时间
|
|
|
891
|
- "course": { //课程信息
|
|
|
892
|
- "title": "测试课程", //课程标题
|
|
|
893
|
- "cover": "", //课程封面图
|
|
|
894
|
- "current_price": "50.00", //现价
|
|
|
895
|
- "original_price": "100.00" //原价
|
|
|
896
|
- }
|
|
|
897
|
- }]
|
|
|
898
|
- }
|
|
|
899
|
- })
|
|
|
900
|
- */
|
|
|
901
|
- public function collectCourseList()
|
|
|
902
|
- {
|
|
|
903
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
904
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
905
|
- $data = CourseCollect::with(['course'])
|
|
|
906
|
- ->where('user_id',$this->auth->id)
|
|
|
907
|
- ->order('createtime desc')
|
|
|
908
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
909
|
- ->each(function($v){
|
|
|
910
|
- $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
|
|
|
911
|
- $v->getRelation('course')->visible(['cover','title','current_price','original_price','study_num']);
|
|
|
912
|
- })->toArray();
|
|
|
913
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
914
|
- }
|
|
|
915
|
-
|
|
|
916
|
- /**
|
|
|
917
|
- * @ApiWeigh (47)
|
|
|
918
|
- * @ApiTitle (我的收藏-笔记)
|
|
|
919
|
- * @ApiSummary (我的收藏-笔记)
|
|
|
920
|
- * @ApiMethod (POST)
|
|
|
921
|
- *
|
|
|
922
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
923
|
- * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
924
|
- * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
925
|
- *
|
|
|
926
|
- * @ApiReturn({
|
|
|
927
|
- "code": 1,
|
|
|
928
|
- "msg": "成功",
|
|
|
929
|
- "time": "1600165190",
|
|
|
930
|
- "data": {
|
|
|
931
|
- "total": 1, //数据总数
|
|
|
932
|
- "list": [{
|
|
|
933
|
- "id": 3, //笔记ID
|
|
|
934
|
- "user_id": 16, //用户ID
|
|
|
935
|
- "question_id": 5, //题目ID
|
|
|
936
|
- "content": "这就是街舞", //笔记内容
|
|
|
937
|
- "createtime": "2020.09.10 19:15", //收藏时间
|
|
|
938
|
- "updatetime": 1599736531,
|
|
|
939
|
- "question": { //题目信息
|
|
|
940
|
- "title": "测试多选", //题目标题
|
|
|
941
|
- "type": "2" //题目类型:1=单选题,2=多选题,3=判断题,4=简答题
|
|
|
942
|
- }
|
|
|
943
|
- }]
|
|
|
944
|
- }
|
|
|
945
|
- })
|
|
|
946
|
- */
|
|
|
947
|
- public function collectNoteList()
|
|
|
948
|
- {
|
|
|
949
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
950
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
951
|
- $data = QuestionNote::with(['question'])
|
|
|
952
|
- ->where('user_id',$this->auth->id)
|
|
|
953
|
- ->order('createtime desc')
|
|
|
954
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
955
|
- ->each(function($v){
|
|
|
956
|
- $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
|
|
|
957
|
- $v->getRelation('question')->visible(['title','type']);
|
|
|
958
|
- })->toArray();
|
|
|
959
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
960
|
- }
|
|
|
961
|
-
|
|
|
962
|
- /**
|
|
|
963
|
- * @ApiWeigh (45)
|
|
|
964
|
- * @ApiTitle (我的收藏-笔记-删除)
|
|
|
965
|
- * @ApiSummary (我的收藏-笔记-删除)
|
|
|
966
|
- * @ApiMethod (POST)
|
|
|
967
|
- *
|
|
|
968
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
969
|
- * @ApiParams (name="question_note_id", type="inter", required=false, description="当前页(默认1)")
|
|
|
970
|
- *
|
|
|
971
|
- * @ApiReturn({
|
|
|
972
|
- "code": 1,
|
|
|
973
|
- "msg": "删除成功",
|
|
|
974
|
- "time": "1600165190",
|
|
|
975
|
- "data": null
|
|
|
976
|
- })
|
|
|
977
|
- */
|
|
|
978
|
- public function noteDelete()
|
|
|
979
|
- {
|
|
|
980
|
- $question_note_id = $this->request->param('question_note_id');
|
|
|
981
|
- empty($question_note_id) && $this->error('缺少必需参数');
|
|
|
982
|
- $info = QuestionNote::get($question_note_id);
|
|
|
983
|
- empty($info) && $this->error('笔记信息不存在');
|
|
|
984
|
- $info->delete();
|
|
|
985
|
- $this->success('删除成功');
|
|
|
986
|
- }
|
|
|
987
|
-
|
|
|
988
|
- /**
|
|
|
989
|
- * @ApiWeigh (43)
|
|
|
990
|
- * @ApiTitle (消息)
|
|
|
991
|
- * @ApiSummary (消息)
|
|
|
992
|
- * @ApiMethod (POST)
|
|
|
993
|
- *
|
|
|
994
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
995
|
- * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
996
|
- * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
997
|
- *
|
|
|
998
|
- * @ApiReturn({
|
|
|
999
|
- "code": 1,
|
|
|
1000
|
- "msg": "成功",
|
|
|
1001
|
- "time": "1600167138",
|
|
|
1002
|
- "data": {
|
|
|
1003
|
- "total": 1, //数据总数
|
|
|
1004
|
- "list": [{
|
|
|
1005
|
- "id": 7, //消息ID
|
|
|
1006
|
- "title": "这是个消息", //消息标题
|
|
|
1007
|
- "createtime": "2020.09.12 20:45" //发送时间
|
|
|
1008
|
- }]
|
|
|
1009
|
- }
|
|
|
1010
|
- })
|
|
|
1011
|
- */
|
|
|
1012
|
- public function messageList()
|
|
|
1013
|
- {
|
|
|
1014
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
1015
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
1016
|
- $data = Message::where('user_id',$this->auth->id)
|
|
|
1017
|
- ->order('createtime desc')
|
|
|
1018
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
1019
|
- ->each(function($v){
|
|
|
1020
|
- $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
|
|
|
1021
|
- $v->visible(['id','title','createtime']);
|
|
|
1022
|
- })->toArray();
|
|
|
1023
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
1024
|
- }
|
|
|
1025
|
-
|
|
|
1026
|
- /**
|
|
|
1027
|
- * @ApiWeigh (43)
|
|
|
1028
|
- * @ApiTitle (消息-详情)
|
|
|
1029
|
- * @ApiSummary (消息-详情)
|
|
|
1030
|
- * @ApiMethod (POST)
|
|
|
1031
|
- *
|
|
|
1032
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
1033
|
- * @ApiParams (name="message_id", type="inter", required=true, description="消息ID")
|
|
|
1034
|
- *
|
|
|
1035
|
- * @ApiReturn({
|
|
|
1036
|
- "code": 1,
|
|
|
1037
|
- "msg": "成功",
|
|
|
1038
|
- "time": "1600167441",
|
|
|
1039
|
- "data": {
|
|
|
1040
|
- "id": 7, //消息ID
|
|
|
1041
|
- "user_id": 16, //用户ID
|
|
|
1042
|
- "title": "这是个消息", //消息标题
|
|
|
1043
|
- "content": "这个消息还不错Q", //消息内容
|
|
|
1044
|
- "is_read": "1", //是否已读:0=否,1=是
|
|
|
1045
|
- "createtime": 1599914736,
|
|
|
1046
|
- "updatetime": 1600167441
|
|
|
1047
|
- }
|
|
|
1048
|
- })
|
|
|
1049
|
- */
|
|
|
1050
|
- public function messageInfo()
|
|
|
1051
|
- {
|
|
|
1052
|
- $message_id = $this->request->param('message_id');
|
|
|
1053
|
- empty($message_id) && $this->error('缺少必需参数');
|
|
|
1054
|
- $info = Message::get($message_id);
|
|
|
1055
|
- empty($info) && $this->error('消息不存在');
|
|
|
1056
|
- $info->save(['is_read'=>'1']);
|
|
|
1057
|
- $this->success('成功', $info);
|
|
|
1058
|
- }
|
|
|
1059
|
-
|
|
|
1060
|
- /**
|
|
|
1061
|
- * @ApiWeigh (41)
|
|
|
1062
|
- * @ApiTitle (意见反馈-错误类型)
|
|
|
1063
|
- * @ApiSummary (意见反馈-错误类型)
|
|
|
1064
|
- * @ApiMethod (POST)
|
|
|
1065
|
- *
|
|
|
1066
|
- * @ApiReturn({
|
|
|
1067
|
- "code": 1,
|
|
|
1068
|
- "msg": "成功",
|
|
|
1069
|
- "time": "1600167441",
|
|
|
1070
|
- "data": {
|
|
|
1071
|
- "id": 7, //消息ID
|
|
|
1072
|
- "user_id": 16, //用户ID
|
|
|
1073
|
- "title": "这是个消息", //消息标题
|
|
|
1074
|
- "content": "这个消息还不错Q", //消息内容
|
|
|
1075
|
- "is_read": "1", //是否已读:0=否,1=是
|
|
|
1076
|
- "createtime": 1599914736,
|
|
|
1077
|
- "updatetime": 1600167441
|
|
|
1078
|
- }
|
|
|
1079
|
- })
|
|
|
1080
|
- */
|
|
|
1081
|
- public function feedbackWrong()
|
|
|
1082
|
- {
|
|
|
1083
|
- $list = Db::name('mobile_feedback_wrong')->field('id,name')->select();
|
|
|
1084
|
- $this->success('成功', $list);
|
|
|
1085
|
- }
|
|
|
1086
|
-
|
|
|
1087
|
- /**
|
|
|
1088
|
- * @ApiWeigh (39)
|
|
|
1089
|
- * @ApiTitle (意见反馈)
|
|
|
1090
|
- * @ApiSummary (意见反馈)
|
|
|
1091
|
- * @ApiMethod (POST)
|
|
|
1092
|
- *
|
|
|
1093
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
1094
|
- * @ApiParams (name="feedback_wrong_id", type="inter", required=true, description="错误类型ID")
|
|
|
1095
|
- * @ApiParams (name="content", type="string", required=true, description="反馈内容")
|
|
|
1096
|
- *
|
|
|
1097
|
- * @ApiReturn({
|
|
|
1098
|
- "code": 1,
|
|
|
1099
|
- "msg": "成功",
|
|
|
1100
|
- "time": "1600167441",
|
|
|
1101
|
- "data": {
|
|
|
1102
|
- "id": 7, //消息ID
|
|
|
1103
|
- "user_id": 16, //用户ID
|
|
|
1104
|
- "title": "这是个消息", //消息标题
|
|
|
1105
|
- "content": "这个消息还不错Q", //消息内容
|
|
|
1106
|
- "is_read": "1", //是否已读:0=否,1=是
|
|
|
1107
|
- "createtime": 1599914736,
|
|
|
1108
|
- "updatetime": 1600167441
|
|
|
1109
|
- }
|
|
|
1110
|
- })
|
|
|
1111
|
- */
|
|
|
1112
|
- public function feedback()
|
|
|
1113
|
- {
|
|
|
1114
|
- $feedback_wrong_id = $this->request->param('feedback_wrong_id');
|
|
|
1115
|
- $content = $this->request->param('content');
|
|
|
1116
|
- empty($feedback_wrong_id) && $this->error('请选择错误类型');
|
|
|
1117
|
- empty($content) && $this->error('请填写反馈内容');
|
|
|
1118
|
- Feedback::create([
|
|
|
1119
|
- 'user_id' => $this->auth->id,
|
|
|
1120
|
- 'feedback_wrong_id' => $feedback_wrong_id,
|
|
|
1121
|
- 'content' => $content
|
|
|
1122
|
- ]);
|
|
|
1123
|
- $this->success('反馈成功');
|
|
|
1124
|
- }
|
|
|
1125
|
-
|
|
|
1126
|
- /**
|
|
|
1127
|
- * @ApiWeigh (37)
|
|
|
1128
|
- * @ApiTitle (我的帖子)
|
|
|
1129
|
- * @ApiSummary (我的帖子)
|
|
|
1130
|
- * @ApiMethod (POST)
|
|
|
1131
|
- *
|
|
|
1132
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
1133
|
- * @ApiParams (name="feedback_wrong_id", type="inter", required=true, description="错误类型ID")
|
|
|
1134
|
- * @ApiParams (name="content", type="string", required=true, description="反馈内容")
|
|
|
1135
|
- *
|
|
|
1136
|
- * @ApiReturn({
|
|
|
1137
|
- "code": 1,
|
|
|
1138
|
- "msg": "成功",
|
|
|
1139
|
- "time": "1600167441",
|
|
|
1140
|
- "data": {
|
|
|
1141
|
- "id": 7, //消息ID
|
|
|
1142
|
- "user_id": 16, //用户ID
|
|
|
1143
|
- "title": "这是个消息", //消息标题
|
|
|
1144
|
- "content": "这个消息还不错Q", //消息内容
|
|
|
1145
|
- "is_read": "1", //是否已读:0=否,1=是
|
|
|
1146
|
- "createtime": 1599914736,
|
|
|
1147
|
- "updatetime": 1600167441
|
|
|
1148
|
- }
|
|
|
1149
|
- })
|
|
|
1150
|
- */
|
|
|
1151
|
- public function topicList()
|
|
|
1152
|
- {
|
|
|
1153
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
1154
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
1155
|
- $data = Topic::with(['user'])
|
|
|
1156
|
- ->where('user_id',$this->auth->id)
|
|
|
1157
|
- ->order('createtime desc')
|
|
|
1158
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
1159
|
- ->each(function($v){
|
|
|
1160
|
- $v->visible(['id','title','content','createtime','agree_num','download_num','user']);
|
|
|
1161
|
- $v->createtime = date('Y.m.d H:i',$v['createtime']);
|
|
|
1162
|
- $v->getRelation('user')->visible(['user_id','avatar','nickname']);
|
|
|
1163
|
- })->toArray();
|
|
|
1164
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
1165
|
- }
|
|
|
1166
|
-
|
|
|
1167
|
- /**
|
|
|
1168
|
- * @ApiWeigh (35)
|
|
|
1169
|
- * @ApiTitle (我的帖子-@我的)
|
|
|
1170
|
- * @ApiSummary (我的帖子-@我的)
|
|
|
1171
|
- * @ApiMethod (POST)
|
|
|
1172
|
- *
|
|
|
1173
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
1174
|
- *
|
|
|
1175
|
- * @ApiReturn({
|
|
|
1176
|
- "code": 1,
|
|
|
1177
|
- "msg": "成功",
|
|
|
1178
|
- "time": "1600167441",
|
|
|
1179
|
- "data": {
|
|
|
1180
|
- "id": 7, //消息ID
|
|
|
1181
|
- "user_id": 16, //用户ID
|
|
|
1182
|
- "title": "这是个消息", //消息标题
|
|
|
1183
|
- "content": "这个消息还不错Q", //消息内容
|
|
|
1184
|
- "is_read": "1", //是否已读:0=否,1=是
|
|
|
1185
|
- "createtime": 1599914736,
|
|
|
1186
|
- "updatetime": 1600167441
|
|
|
1187
|
- }
|
|
|
1188
|
- })
|
|
|
1189
|
- */
|
|
|
1190
|
- public function topicCueMe()
|
|
|
1191
|
- {
|
|
|
1192
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
1193
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
1194
|
- $data = Topic::with(['user'])
|
|
|
1195
|
- ->where('user_id',$this->auth->id)
|
|
|
1196
|
- ->order('createtime desc')
|
|
|
1197
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
1198
|
- ->each(function($v){
|
|
|
1199
|
- $v->visible(['id','title','content','createtime','agree_num','download_num','user']);
|
|
|
1200
|
- $v->createtime = date('Y.m.d H:i',$v['createtime']);
|
|
|
1201
|
- $v->getRelation('user')->visible(['user_id','avatar','nickname']);
|
|
|
1202
|
- })->toArray();
|
|
|
1203
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
1204
|
- }
|
|
|
1205
|
-
|
|
|
1206
|
- /**
|
|
|
1207
|
- * @ApiWeigh (10)
|
|
|
1208
|
- * @ApiTitle (常见问题)
|
|
|
1209
|
- * @ApiSummary (常见问题)
|
|
|
1210
|
- * @ApiMethod (POST)
|
|
|
1211
|
- *
|
|
|
1212
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
1213
|
- * @ApiParams (name="page", type="inter", required=false, description="当前页(默认1)")
|
|
|
1214
|
- * @ApiParams (name="page_num", type="inter", required=false, description="每页显示数据个数(默认10)")
|
|
|
1215
|
- *
|
|
|
1216
|
- * @ApiReturn({
|
|
|
1217
|
- "code": 1,
|
|
|
1218
|
- "msg": "成功",
|
|
|
1219
|
- "time": "1600167138",
|
|
|
1220
|
- "data": {
|
|
|
1221
|
- "total": 1, //数据总数
|
|
|
1222
|
- "list": [{
|
|
|
1223
|
- "id": 7, //消息ID
|
|
|
1224
|
- "title": "这是个消息", //消息标题
|
|
|
1225
|
- "createtime": "2020.09.12 20:45" //发送时间
|
|
|
1226
|
- }]
|
|
|
1227
|
- }
|
|
|
1228
|
- })
|
|
|
1229
|
- */
|
|
|
1230
|
- public function problemList()
|
|
|
1231
|
- {
|
|
|
1232
|
- $page = $this->request->param('page', 1, 'intval');
|
|
|
1233
|
- $page_num = $this->request->param('page_num', 10, 'intval');
|
|
|
1234
|
- $data = Problem::where('user_id',$this->auth->id)
|
|
|
1235
|
- ->order('createtime desc')
|
|
|
1236
|
- ->paginate($page_num,false,['page'=>$page])
|
|
|
1237
|
- ->each(function($v){
|
|
|
1238
|
- $v['createtime'] = date('Y.m.d H:i',$v['createtime']);
|
|
|
1239
|
- $v->visible(['id','title','createtime']);
|
|
|
1240
|
- })->toArray();
|
|
|
1241
|
- $this->success('成功', ['total'=>$data['total'],'list'=>$data['data']]);
|
|
|
1242
|
- }
|
|
|
1243
|
-
|
|
|
1244
|
- /**
|
|
|
1245
|
- * @ApiWeigh (9)
|
|
|
1246
|
- * @ApiTitle (常见问题-详情)
|
|
|
1247
|
- * @ApiSummary (常见问题-详情)
|
|
|
1248
|
- * @ApiMethod (POST)
|
|
|
1249
|
- *
|
|
|
1250
|
- * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
|
|
|
1251
|
- * @ApiParams (name="problem_id", type="inter", required=true, description="问题ID")
|
|
|
1252
|
- *
|
|
|
1253
|
- * @ApiReturn({
|
|
|
1254
|
- "code": 1,
|
|
|
1255
|
- "msg": "成功",
|
|
|
1256
|
- "time": "1600167441",
|
|
|
1257
|
- "data": {
|
|
|
1258
|
- "id": 7, //消息ID
|
|
|
1259
|
- "user_id": 16, //用户ID
|
|
|
1260
|
- "title": "这是个消息", //消息标题
|
|
|
1261
|
- "content": "这个消息还不错Q", //消息内容
|
|
|
1262
|
- "is_read": "1", //是否已读:0=否,1=是
|
|
|
1263
|
- "createtime": 1599914736,
|
|
|
1264
|
- "updatetime": 1600167441
|
|
|
1265
|
- }
|
|
|
1266
|
- })
|
|
|
1267
|
- */
|
|
|
1268
|
- public function problemInfo()
|
|
|
1269
|
- {
|
|
|
1270
|
- $problem_id = $this->request->param('problem_id');
|
|
|
1271
|
- empty($problem_id) && $this->error('缺少必需参数');
|
|
|
1272
|
- $info = Problem::get($problem_id);
|
|
|
1273
|
- empty($info) && $this->error('问题不存在');
|
|
|
1274
|
- $this->success('成功', $info);
|
|
|
1275
|
- }
|
|
|
1276
|
-} |
|
|