作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

bug修改

... ... @@ -500,23 +500,22 @@ class User extends Api
*/
public function joinFactory()
{
$user = $this->auth->getUser();
$user = $this->model->get($this->auth->id);
$factory_id = $this->request->param('factory_id');
empty($factory_id) && $this->error('缺少必需参数');
$factory = Factory::get($factory_id);
empty($factory) && $this->error('工厂不存在');
$where = [
'user_id' => $user['id'],
'factory_id' => $factory_id
];
$info = FactoryUser::where($where)->order('createtime desc')->find();
if(!empty($info)){
$info['status'] == '0' && $this->error('正在审核中,请勿重复操作');
if($user['is_work'] == '1' && $user['factory_id'] == $factory_id){
$info['status'] == '1' && $this->error('已入职,请勿重复操作');
}
if($user['is_work'] == '1' && $user['factory']){
$this->error('已入职,确认入职无效');
}
$has = FactoryUser::where('user_id',$user['id'])->order('createtime desc')->find();
if(!empty($has)){
$has['status'] == '0' && $this->error('正在审核中,请勿重复操作');
}
FactoryUser::create($where);
FactoryUser::create([
'user_id' => $user['id'],
'factory_id' => $factory_id,
]);
$this->success('入职成功后,驻厂将会为您服务');
}
... ...