123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <?php
- namespace app\common\model;
- use think\Db;
- class ConveyCate extends Base
- {
- public $cate = [
- 1=>"病人",
- 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'] = '';
- }
- $ends = $v['ends']?explode(',',$v['ends']):[];
- if($ends && count($ends)==1){
- $list[$k]['ends'] = Db::name('address')
- ->where('id','in',$ends)
- ->field('id,title')
- ->select();
- }else{
- $list[$k]['ends'] = [];
- }
- $list[$k]['priorityName'] = $this->priority[$v['priority']];
- }
- 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'] = $this->priority[$v['priority']];
- return $v;
- }
- }
|