ConveyCate.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class ConveyCate extends Base
  5. {
  6. public $cate = [
  7. 1=>"病人",
  8. 2=>"普通",
  9. 3=>"限时",
  10. 4=>"预约检查",
  11. 5=>"药品运送"
  12. ];
  13. public $priority = [
  14. 1=>"可延缓的",
  15. 2=>"常规",
  16. 3=>"紧急",
  17. 4=>"预约"
  18. ];
  19. protected $createTime = 'create_time';
  20. protected $updateTime = 'update_time';
  21. public $table = 'convey_cate';
  22. protected $validateName = 'ConveyCate';
  23. public function updates(){
  24. $data = request()->post();
  25. $data['org_id'] =cur_org_id();
  26. $result = validate($this->validateName)->check($data,[],'');
  27. if(true !== $result){
  28. $this->error = validate($this->validateName)->getError();
  29. return false;
  30. }
  31. $id = $data['id'];
  32. unset($data['id']);
  33. if($id > 0){
  34. $data['update_time'] = date('Y-m-d H:i:s');
  35. $ret = $this->allowField(true)->save($data,['id'=>$id]);
  36. }else{
  37. $data['create_time'] = date('Y-m-d H:i:s');
  38. $ret = $this->allowField(true)->save($data);
  39. }
  40. if(!$ret){
  41. $this->error = '操作失败';
  42. return false;
  43. }
  44. return true;
  45. }
  46. public function getList($orgId=0){
  47. if($orgId==0){
  48. $orgId = cur_org_id();
  49. }
  50. $list = $this
  51. ->where('org_id',$orgId)
  52. ->where('enable',1)
  53. ->where('del',0)
  54. ->select();
  55. foreach ($list as $k=>$v){
  56. if($v['time_id'] > 0){
  57. $time = Db::name('time')
  58. ->where('id',$v['time_id'])
  59. ->find();
  60. $list[$k]['xq_time'] = date('Y-m-d H:i');
  61. $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']);
  62. }else{
  63. $list[$k]['xq_time'] = date('Y-m-d H:i');
  64. $list[$k]['ywc_time'] = '';
  65. }
  66. $ends = $v['ends']?explode(',',$v['ends']):[];
  67. $list[$k]['ends'] = 0;
  68. if(count($ends) == 1){
  69. $list[$k]['ends'] = $ends[0];
  70. }
  71. }
  72. return $list;
  73. }
  74. public function getList1($orgId=0){
  75. if($orgId==0){
  76. $orgId = cur_org_id();
  77. }
  78. $list = $this
  79. ->where('org_id',$orgId)
  80. ->where('enable',1)
  81. ->where('del',0)
  82. ->select();
  83. foreach ($list as $k=>$v){
  84. if($v['time_id'] > 0){
  85. $time = Db::name('time')
  86. ->where('id',$v['time_id'])
  87. ->find();
  88. $list[$k]['xq_time'] = date('Y-m-d H:i');
  89. $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']);
  90. }else{
  91. $list[$k]['xq_time'] = date('Y-m-d H:i');
  92. $list[$k]['ywc_time'] = '';
  93. }
  94. $ends = $v['ends']?explode(',',$v['ends']):[];
  95. if($ends && count($ends)==1){
  96. $list[$k]['ends'] = Db::name('address')
  97. ->where('id','in',$ends)
  98. ->field('id,title')
  99. ->select();
  100. }else{
  101. $list[$k]['ends'] = [];
  102. }
  103. $list[$k]['priorityName'] = $this->priority[$v['priority']];
  104. }
  105. return $list;
  106. }
  107. public function getInfo($id){
  108. $v = $this
  109. ->where('id',$id)
  110. ->where('enable',1)
  111. ->where('del',0)
  112. ->find();
  113. $v = $v->toArray()?$v:[];
  114. if($v['time_id'] > 0){
  115. $time = Db::name('time')
  116. ->where('id',$v['time_id'])
  117. ->find();
  118. $v['xq_time'] = date('Y-m-d H:i');
  119. $v['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']);
  120. }else{
  121. $v['xq_time'] = date('Y-m-d H:i');
  122. $v['ywc_time'] = '';
  123. }
  124. $ends = $v['ends']?explode(',',$v['ends']):[];
  125. if($ends && count($ends)==1){
  126. $v['ends'] = Db::name('address')
  127. ->where('id','in',$ends)
  128. ->field('id,title')
  129. ->select();
  130. }else{
  131. $v['ends'] = null;
  132. }
  133. $v['priorityName'] = $this->priority[$v['priority']];
  134. return $v;
  135. }
  136. }