...
|
...
|
@@ -7,6 +7,7 @@ use app\mobile\model\News; |
|
|
use app\mobile\model\Exam;
|
|
|
use app\mobile\model\UserExam;
|
|
|
use app\mobile\model\CompanyUser;
|
|
|
use app\mobile\model\CompanyUserLog;
|
|
|
use app\mobile\model\Message;
|
|
|
use app\mobile\model\Statistic;
|
|
|
use think\Db;
|
...
|
...
|
@@ -87,7 +88,7 @@ class Index extends Api |
|
|
$banner_list = IndexBanner::order('createtime desc')->field('id,image,url')->select();
|
|
|
// 消息
|
|
|
$message = Message::where('user_id',$this->auth->id)->where('is_read','0')->field('id,title')->find();
|
|
|
$message = $message ?: [];
|
|
|
$message = $message ?: (Object)[];
|
|
|
$this->success('成功',compact('exam_list','banner_list','exam','message'));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -241,22 +242,38 @@ class Index extends Api |
|
|
->where('user_id',$user['id'])
|
|
|
->field('status')
|
|
|
->find();
|
|
|
if($company_user){
|
|
|
if($company_user['status'] == '0'){
|
|
|
if($company_user && $company_user['status'] == '1'){
|
|
|
$this->error('加入企业成功,请勿重复提交申请');
|
|
|
}
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
if($company_user){
|
|
|
$company_user->status = '1';
|
|
|
$company_user->save();
|
|
|
}
|
|
|
if($company_user['status'] == '1'){
|
|
|
$this->error('加入企业成功,请勿重复提交申请');
|
|
|
}
|
|
|
CompanyUser::create([
|
|
|
'user_id' => $user['id'],
|
|
|
'company_id' => $company_id,
|
|
|
'name' => $user['nickname'],
|
|
|
'mobile' => $user['mobile'],
|
|
|
'status' => '1'
|
|
|
]);
|
|
|
// 新增员工记录
|
|
|
CompanyUserLog::create([
|
|
|
'company_id' => $company_id,
|
|
|
'user_id' => $user['id'],
|
|
|
'name' => $user['nickname'],
|
|
|
'mobile' => $user['mobile'],
|
|
|
'type' => '1'
|
|
|
]);
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
CompanyUser::create([
|
|
|
'user_id' => $this->auth->id,
|
|
|
'company_id' => $company_id,
|
|
|
'name' => $user['nickname'],
|
|
|
'mobile' => $user['mobile'],
|
|
|
'status' => '1'
|
|
|
]);
|
|
|
$this->success('加入企业成功');
|
|
|
}
|
|
|
|
...
|
...
|
|