|
@@ -7,6 +7,7 @@ use app\mobile\model\News; |
|
@@ -7,6 +7,7 @@ use app\mobile\model\News; |
7
|
use app\mobile\model\Exam;
|
7
|
use app\mobile\model\Exam;
|
8
|
use app\mobile\model\UserExam;
|
8
|
use app\mobile\model\UserExam;
|
9
|
use app\mobile\model\CompanyUser;
|
9
|
use app\mobile\model\CompanyUser;
|
|
|
10
|
+use app\mobile\model\CompanyUserLog;
|
10
|
use app\mobile\model\Message;
|
11
|
use app\mobile\model\Message;
|
11
|
use app\mobile\model\Statistic;
|
12
|
use app\mobile\model\Statistic;
|
12
|
use think\Db;
|
13
|
use think\Db;
|
|
@@ -87,7 +88,7 @@ class Index extends Api |
|
@@ -87,7 +88,7 @@ class Index extends Api |
87
|
$banner_list = IndexBanner::order('createtime desc')->field('id,image,url')->select();
|
88
|
$banner_list = IndexBanner::order('createtime desc')->field('id,image,url')->select();
|
88
|
// 消息
|
89
|
// 消息
|
89
|
$message = Message::where('user_id',$this->auth->id)->where('is_read','0')->field('id,title')->find();
|
90
|
$message = Message::where('user_id',$this->auth->id)->where('is_read','0')->field('id,title')->find();
|
90
|
- $message = $message ?: [];
|
91
|
+ $message = $message ?: (Object)[];
|
91
|
$this->success('成功',compact('exam_list','banner_list','exam','message'));
|
92
|
$this->success('成功',compact('exam_list','banner_list','exam','message'));
|
92
|
}
|
93
|
}
|
93
|
|
94
|
|
|
@@ -241,22 +242,38 @@ class Index extends Api |
|
@@ -241,22 +242,38 @@ class Index extends Api |
241
|
->where('user_id',$user['id'])
|
242
|
->where('user_id',$user['id'])
|
242
|
->field('status')
|
243
|
->field('status')
|
243
|
->find();
|
244
|
->find();
|
|
|
245
|
+ if($company_user && $company_user['status'] == '1'){
|
|
|
246
|
+ $this->error('加入企业成功,请勿重复提交申请');
|
|
|
247
|
+ }
|
|
|
248
|
+ Db::startTrans();
|
|
|
249
|
+ try {
|
244
|
if($company_user){
|
250
|
if($company_user){
|
245
|
- if($company_user['status'] == '0'){
|
|
|
246
|
$company_user->status = '1';
|
251
|
$company_user->status = '1';
|
247
|
$company_user->save();
|
252
|
$company_user->save();
|
248
|
}
|
253
|
}
|
249
|
- if($company_user['status'] == '1'){
|
|
|
250
|
- $this->error('加入企业成功,请勿重复提交申请');
|
|
|
251
|
- }
|
|
|
252
|
- }
|
|
|
253
|
CompanyUser::create([
|
254
|
CompanyUser::create([
|
254
|
- 'user_id' => $this->auth->id,
|
255
|
+ 'user_id' => $user['id'],
|
255
|
'company_id' => $company_id,
|
256
|
'company_id' => $company_id,
|
256
|
'name' => $user['nickname'],
|
257
|
'name' => $user['nickname'],
|
257
|
'mobile' => $user['mobile'],
|
258
|
'mobile' => $user['mobile'],
|
258
|
'status' => '1'
|
259
|
'status' => '1'
|
259
|
]);
|
260
|
]);
|
|
|
261
|
+ // 新增员工记录
|
|
|
262
|
+ CompanyUserLog::create([
|
|
|
263
|
+ 'company_id' => $company_id,
|
|
|
264
|
+ 'user_id' => $user['id'],
|
|
|
265
|
+ 'name' => $user['nickname'],
|
|
|
266
|
+ 'mobile' => $user['mobile'],
|
|
|
267
|
+ 'type' => '1'
|
|
|
268
|
+ ]);
|
|
|
269
|
+ Db::commit();
|
|
|
270
|
+ } catch (PDOException $e) {
|
|
|
271
|
+ Db::rollback();
|
|
|
272
|
+ $this->error($e->getMessage());
|
|
|
273
|
+ } catch (Exception $e) {
|
|
|
274
|
+ Db::rollback();
|
|
|
275
|
+ $this->error($e->getMessage());
|
|
|
276
|
+ }
|
260
|
$this->success('加入企业成功');
|
277
|
$this->success('加入企业成功');
|
261
|
}
|
278
|
}
|
262
|
|
279
|
|