| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 | 
							- <?php
 
- namespace App\Service;
 
- use App\Model\Depart;
 
- use App\Model\Employee;
 
- use App\Model\EmployeeRole;
 
- use App\Model\FollowUpRecord;
 
- use Illuminate\Support\Facades\DB;
 
- use Illuminate\Support\Facades\Hash;
 
- class FollowUpRecordService extends Service
 
- {
 
-     public function followUpRecordEdit($data,$user){
 
-         list($status,$msg) = $this->followUpRecordRule($data,false);
 
-         if(!$status) return [$status,$msg];
 
-         $model = new FollowUpRecord();
 
-         $model = $model->where('id',$data['id'])->first();
 
-         $model->id_card = $data['id_card']??'';
 
-         $model->number = $data['number'] ;
 
-         $model->mobile = $data['mobile'];
 
-         $model->emp_name = $data['emp_name'];
 
-         $model->is_admin = $data['is_admin'];
 
-         if($model->is_admin == 1){
 
-             $model->account = $data['account'];
 
-             if($data['password'] !== '********'){
 
-                 $model->password   = Hash::make($data['password']);
 
-             }
 
-         }
 
-         $model->save();
 
-         return [true,'保存成功!'];
 
-     }
 
-     public function followUpRecordAdd($data,$user){
 
-         list($status,$msg) = $this->followUpRecordRule($data);
 
-         if(!$status) return [$status,$msg];
 
-         $model = new FollowUpRecord();
 
-         $model->id_card = $data['id_card']??'';
 
-         $model->number = $data['number'] ;
 
-         $model->mobile = $data['mobile'];
 
-         $model->emp_name = $data['emp_name'];
 
-         $model->state = 1;
 
-         $model->crt_id = $user['id'];
 
-         $model->is_admin = $data['is_admin'];
 
-         if($model->is_admin == 1){
 
-             $model->account = $data['account'];
 
-             $model->password = Hash::make($data['password']);
 
-         }
 
-         $model->save();
 
-         return [true,'保存成功!'];
 
-     }
 
-     public function followUpRecordDel($data,){
 
-         if($this->isEmpty($data,'id')) return [false,'ID必须!'];
 
-         FollowUpRecord::where('id',$data['id'])->update([
 
-             'del_time'=>time()
 
-         ]);
 
-         return [true,'删除成功'];
 
-     }
 
-     public function followUpRecordList($data,$user){
 
-         $model = FollowUpRecord::where('del_time',0)
 
-             ->select('number','mobile','emp_name','id','entry_time','leave_time','is_technical','is_admin','state')
 
-             ->orderBy('id','desc');
 
-         if(! empty($data['state'])) $model->where('state',$data['state']);
 
-         if(! empty($data['mobile'])) $model->where('mobile', 'LIKE', '%'.$data['mobile'].'%');
 
-         if(! isset($data['all_emp'])) $model->where('id','<>',Employee::SPECIAL_ADMIN);
 
-         $list = $this->limit($model,'',$data);
 
-         //组织数据
 
-         $list = $this->organizationData($list);
 
-         return [true, $list];
 
-     }
 
-     public function organizationData($data) {
 
-         if (empty($data['data'])) return $data;
 
-         foreach ($data['data'] as $key => $value){
 
-         }
 
-         return $data;
 
-     }
 
-     public function followUpRecordRule($data,$is_add = true){
 
-         if($this->isEmpty($data,'number')) return [false,'工号不存在!'];
 
-         if($this->isEmpty($data,'mobile')) return [false,'手机号不存在!'];
 
-         if($this->isEmpty($data,'emp_name')) return [false,'姓名不存在!'];
 
-         if(! $is_add){
 
-             if($this->isEmpty($data,'id')) return [false,'ID不能为空!'];
 
-         }else{
 
-         }
 
-         return [true,''];
 
-     }
 
- }
 
 
  |