request->param(); $ReportModel = new \addons\qingdong\model\Report(); //$where = []; if($param['type']==1){ $where['create_id'] = ['=',$this->auth->id]; }elseif($param['type']==2){ $where['staff_id'] = ['=',$this->auth->id] ; }else{ $where = []; } $list = $ReportModel->with('staff')->where($where)->select(); $this->success('报备列表',$list); } //添加 public function addReport(){ $param = $this->request->param(); $ReportModel = new \addons\qingdong\model\Report(); if(empty($param['business_name']) || empty($param['business_city']) || empty($param['company_name']) || empty($param['contacts_name']) || empty($param['contacts_mobile'])){ $this->error('信息不完整,请完善填写信息'); } $data = [ 'business_name'=>$param['business_name'], 'business_city'=>$param['business_city'], 'company_name'=>$param['company_name'], 'contacts_name'=>$param['contacts_name'], 'contacts_mobile'=>$param['contacts_mobile'], 'create_id'=>$this->auth->id, 'status'=>1 ]; $res = $ReportModel->save($data); if($res){ $this->success('添加成功'); } $this->error('添加失败'); } //审批 public function approve(){ $param = $this->request->param(); $ReportModel = new \addons\qingdong\model\Report(); $cusModel = new \addons\qingdong\model\Customer(); $busModel = new \addons\qingdong\model\Business(); $find = $ReportModel->where('id',$param['id'])->find(); if($param['type'] == 1 && $find){ $cus_data = [ 'name'=> $find['company_name'], 'main_zxfpre'=>$find['contacts_name'], 'mobile'=>$find['contacts_mobile'], 'create_staff_id'=>$find['staff_id'], 'owner_staff_id'=>$find['staff_id'], 'receivetime'=>time(), 'follow'=>'初次接触', 'source'=>'行业活动', 'industry'=>'普通客户', 'level'=>5 ]; $result = $cusModel::createCustomer($cus_data); $bus_data = [ 'customer_id'=>$result, 'name'=>$find['business_name'], 'create_staff_id'=>$find['staff_id'], 'owner_staff_id'=>$find['staff_id'], ]; $busModel::createBusiness($bus_data); $find->status = 2; $find->save(); }elseif ($param['type'] == 2 && $find){ $find->status = 3; $find->save(); }else{ $this->error('参数错误'); } $this->success('操作成功'); } }