springCompanyRepository = $springCompanyRepository; $this->companyRepository = $companyRepository; $this->memberLogRepository = $memberLogRepository; } public function saveCompany($data){ DB::beginTransaction(); try { if (!$id = $this->springCompanyRepository->add($data)) { throw new Exception('添加公司信息失败'); } DB::commit(); return $id; }catch (Exception $e){ DB::rollback(); return false; } } public function list($key = '', $status = 99, $page = ''){ $where = array(); $where[] = array('display','=','1'); if ($key) { $where[] = array('company_name','like','%'.$key.'%'); } if($status == '1'){ $where[] = array('status','=',$status); } if($status == '0'){ $where[] = array('status','=',99); } $list = $this->springCompanyRepository->getAllCompany($where, $page); return $list; } public function registerCompany($id){ $smsService = new SmsService(); $info = $this->springCompanyRepository->getOneCompany($id); $company = $this->companyRepository->getCompanyInfo(array('short_name'=>$info['company_name'])); // if(!$company){ // $data['contact'] = $info['real_name']; // $data['mobile'] = $info['phone']; // $data['username'] = $info['phone']; // $this->companyRepository->save($data,$company['id']); // }else{ $password = uniqid(); $data['companyname'] = $info['company_name']; $data['certificate_img'] = $info['license']; $data['contact'] = $info['real_name']; $data['mobile'] = $info['phone']; $data['username'] = $info['phone']; $data['email'] = ''; $data['utype'] = 1; $data['reg_type'] = 1; $data['reg_source'] = 2; $data['landline_tel'] = ''; $data['reg_source_cn']= '手机端'; $data['reg_time'] = time(); $data['short_name'] = ''; $data['last_login_time']=time(); $data['refresh_time']=time(); $data['reg_ip']=ip2long(request()->ip()); $data['password']=Hash::make($password); $data['subsite_id']=0; $company=$this->companyRepository->create($data); $this->memberLogRepository->createLog($company, 1000, []); $this->springCompanyRepository->companyChange($id); $smsService->sendSms($info['phone'],'sms_licenseallow',array('username'=>$info['phone'],'password'=>$password,'sitename'=>'聚才网','sitedomain'=>'http://www.jucai.gov.cn')); return array('company'=>$company,'id'=>$info['id']); //} } }