"病人", 2=>"普通", 3=>"限时", 4=>"预约", 5=>"药品" ]; public $priority = [ // 1=>"可延缓的", 2=>"常规", 3=>"紧急", // 4=>"预约" ]; protected $createTime = 'create_time'; protected $updateTime = 'update_time'; public $table = 'convey_cate'; protected $validateName = 'ConveyCate'; public function updates(){ $data = request()->post(); $data['org_id'] =cur_org_id(); $result = validate($this->validateName)->check($data,[],''); if(true !== $result){ $this->error = validate($this->validateName)->getError(); return false; } $id = $data['id']; unset($data['id']); if($id > 0){ $data['update_time'] = date('Y-m-d H:i:s'); $ret = $this->allowField(true)->save($data,['id'=>$id]); }else{ $data['create_time'] = date('Y-m-d H:i:s'); $ret = $this->allowField(true)->save($data); } if(!$ret){ $this->error = '操作失败'; return false; } return true; } public function getList($orgId=0){ if($orgId==0){ $orgId = cur_org_id(); } $list = $this ->where('org_id',$orgId) ->where('enable',1) ->where('del',0) ->select(); foreach ($list as $k=>$v){ if($v['time_id'] > 0){ $time = Db::name('time') ->where('id',$v['time_id']) ->find(); $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']); }else{ $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = ''; } $ends = $v['ends']?explode(',',$v['ends']):[]; $starts = $v['starts']?explode(',',$v['starts']):[]; $list[$k]['endList'] = $ends; $list[$k]['startList'] = $starts; $list[$k]['ends'] = 0; $list[$k]['starts'] = 0; if(count($ends) == 1){ $list[$k]['ends'] = $ends[0]; } if(count($starts) == 1){ $list[$k]['starts'] = $starts[0]; } } $list = model("UserConveyCate")->sortUserCates($list,is_login()); return $list; } public function getList1($orgId=0){ if($orgId==0){ $orgId = cur_org_id(); } $list = $this ->where('org_id',$orgId) ->where('enable',1) ->where('del',0) ->select(); foreach ($list as $k=>$v){ if($v['time_id'] > 0){ $time = Db::name('time') ->where('id',$v['time_id']) ->find(); $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']); }else{ $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = ''; } $starts = $v['starts']?explode(',',$v['starts']):[]; if($starts){ $list[$k]['starts'] = Db::name('address') ->where('id','in',$starts) ->field('id,title') ->select(); }else{ $list[$k]['starts'] = []; } $ends = $v['ends']?explode(',',$v['ends']):[]; // if($ends && count($ends)==1){ if($ends){ $list[$k]['ends'] = Db::name('address') ->where('id','in',$ends) ->field('id,title') ->select(); }else{ $list[$k]['ends'] = []; } $list[$k]['priorityName'] = isset($this->priority[$v['priority']])?$this->priority[$v['priority']]:""; } $userId = input('userId/d',0); $list = model("UserConveyCate")->sortUserCates($list,$userId); return $list; } public function getList2($orgId=0){ if($orgId==0){ $orgId = cur_org_id(); } $list = $this ->where('org_id',$orgId) ->where('enable',1) ->where('del',0) ->select(); $list = $list ?$list->toArray():[]; foreach ($list as $k=>$v){ if($v['time_id'] > 0){ $time = Db::name('time') ->where('id',$v['time_id']) ->find(); $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']); }else{ $list[$k]['xq_time'] = date('Y-m-d H:i'); $list[$k]['ywc_time'] = ''; } $starts = $v['starts']?explode(',',$v['starts']):[]; if($starts){ $list[$k]['starts'] = Db::name('address') ->where('id','in',$starts) ->field('id,title') ->select(); }else{ $list[$k]['starts'] = []; } $ends = $v['ends']?explode(',',$v['ends']):[]; // if($ends && count($ends)==1){ if($ends){ $list[$k]['ends'] = Db::name('address') ->where('id','in',$ends) ->field('id,title') ->select(); }else{ $list[$k]['ends'] = []; } $list[$k]['priorityName'] = isset($this->priority[$v['priority']])?$this->priority[$v['priority']]:""; } $userId = input('userId/d',0); $list = model("UserConveyCate")->sortUserCates($list,$userId); return $list; } public function getInfo($id){ $v = $this ->where('id',$id) ->where('enable',1) ->where('del',0) ->find(); $v = $v->toArray()?$v:[]; if($v['time_id'] > 0){ $time = Db::name('time') ->where('id',$v['time_id']) ->find(); $v['xq_time'] = date('Y-m-d H:i'); $v['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']); }else{ $v['xq_time'] = date('Y-m-d H:i'); $v['ywc_time'] = ''; } $ends = $v['ends']?explode(',',$v['ends']):[]; if($ends && count($ends)==1){ $v['ends'] = Db::name('address') ->where('id','in',$ends) ->field('id,title') ->select(); }else{ $v['ends'] = null; } $v['priorityName'] = isset($this->priority[$v['priority']])?$this->priority[$v['priority']]:""; return $v; } public function getList3($orgId){ $list = $this ->where('org_id',$orgId) ->where('enable',1) ->where('del',0) ->where('is_sss',1) ->select(); return $list?$list->toArray():[]; } }