| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 | 
							- <?php
 
- namespace App\Services\Company;
 
- use App\Repositories\SpringCompanyRepository;
 
- use Illuminate\Support\Facades\DB;
 
- use App\Repositories\CompanyRepository;
 
- use Illuminate\Support\Facades\Hash;
 
- use App\Repositories\MemberLogRepository;
 
- use App\Services\Common\SmsService;
 
- class SpringCompanyService
 
- {
 
-     protected $springCompanyRepository;
 
-     protected $companyRepository;
 
-     private $memberLogRepository;
 
-     public function __construct(SpringCompanyRepository $springCompanyRepository, CompanyRepository $companyRepository, MemberLogRepository $memberLogRepository)
 
-     {
 
-         $this->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']);
 
-         //}
 
-     }
 
- }
 
 
  |