ConveyCate.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. $starts = $v['starts']?explode(',',$v['starts']):[];
  68. $list[$k]['endList'] = $ends;
  69. $list[$k]['startList'] = $starts;
  70. $list[$k]['ends'] = 0;
  71. $list[$k]['starts'] = 0;
  72. if(count($ends) == 1){
  73. $list[$k]['ends'] = $ends[0];
  74. }
  75. if(count($starts) == 1){
  76. $list[$k]['starts'] = $starts[0];
  77. }
  78. }
  79. $list = model("UserConveyCate")->sortUserCates($list,is_login());
  80. return $list;
  81. }
  82. public function getList1($orgId=0){
  83. if($orgId==0){
  84. $orgId = cur_org_id();
  85. }
  86. $list = $this
  87. ->where('org_id',$orgId)
  88. ->where('enable',1)
  89. ->where('del',0)
  90. ->select();
  91. foreach ($list as $k=>$v){
  92. if($v['time_id'] > 0){
  93. $time = Db::name('time')
  94. ->where('id',$v['time_id'])
  95. ->find();
  96. $list[$k]['xq_time'] = date('Y-m-d H:i');
  97. $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']);
  98. }else{
  99. $list[$k]['xq_time'] = date('Y-m-d H:i');
  100. $list[$k]['ywc_time'] = '';
  101. }
  102. $starts = $v['starts']?explode(',',$v['starts']):[];
  103. if($starts){
  104. $list[$k]['starts'] = Db::name('address')
  105. ->where('id','in',$starts)
  106. ->field('id,title')
  107. ->select();
  108. }else{
  109. $list[$k]['starts'] = [];
  110. }
  111. $ends = $v['ends']?explode(',',$v['ends']):[];
  112. // if($ends && count($ends)==1){
  113. if($ends){
  114. $list[$k]['ends'] = Db::name('address')
  115. ->where('id','in',$ends)
  116. ->field('id,title')
  117. ->select();
  118. }else{
  119. $list[$k]['ends'] = [];
  120. }
  121. $list[$k]['priorityName'] = isset($this->priority[$v['priority']])?$this->priority[$v['priority']]:"";
  122. }
  123. $userId = input('userId/d',0);
  124. $list = model("UserConveyCate")->sortUserCates($list,$userId);
  125. return $list;
  126. }
  127. public function getList2($orgId=0){
  128. if($orgId==0){
  129. $orgId = cur_org_id();
  130. }
  131. $list = $this
  132. ->where('org_id',$orgId)
  133. ->where('enable',1)
  134. ->where('del',0)
  135. ->select();
  136. $list = $list ?$list->toArray():[];
  137. foreach ($list as $k=>$v){
  138. if($v['time_id'] > 0){
  139. $time = Db::name('time')
  140. ->where('id',$v['time_id'])
  141. ->find();
  142. $list[$k]['xq_time'] = date('Y-m-d H:i');
  143. $list[$k]['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']);
  144. }else{
  145. $list[$k]['xq_time'] = date('Y-m-d H:i');
  146. $list[$k]['ywc_time'] = '';
  147. }
  148. $starts = $v['starts']?explode(',',$v['starts']):[];
  149. if($starts){
  150. $list[$k]['starts'] = Db::name('address')
  151. ->where('id','in',$starts)
  152. ->field('id,title')
  153. ->select();
  154. }else{
  155. $list[$k]['starts'] = [];
  156. }
  157. $ends = $v['ends']?explode(',',$v['ends']):[];
  158. // if($ends && count($ends)==1){
  159. if($ends){
  160. $list[$k]['ends'] = Db::name('address')
  161. ->where('id','in',$ends)
  162. ->field('id,title')
  163. ->select();
  164. }else{
  165. $list[$k]['ends'] = [];
  166. }
  167. $list[$k]['priorityName'] = isset($this->priority[$v['priority']])?$this->priority[$v['priority']]:"";
  168. }
  169. $userId = input('userId/d',0);
  170. $list = model("UserConveyCate")->sortUserCates($list,$userId);
  171. return $list;
  172. }
  173. public function getInfo($id){
  174. $v = $this
  175. ->where('id',$id)
  176. ->where('enable',1)
  177. ->where('del',0)
  178. ->find();
  179. $v = $v->toArray()?$v:[];
  180. if($v['time_id'] > 0){
  181. $time = Db::name('time')
  182. ->where('id',$v['time_id'])
  183. ->find();
  184. $v['xq_time'] = date('Y-m-d H:i');
  185. $v['ywc_time'] = date('Y-m-d H:i',time() + 60*$time['bz_time']);
  186. }else{
  187. $v['xq_time'] = date('Y-m-d H:i');
  188. $v['ywc_time'] = '';
  189. }
  190. $ends = $v['ends']?explode(',',$v['ends']):[];
  191. if($ends && count($ends)==1){
  192. $v['ends'] = Db::name('address')
  193. ->where('id','in',$ends)
  194. ->field('id,title')
  195. ->select();
  196. }else{
  197. $v['ends'] = null;
  198. }
  199. $v['priorityName'] = isset($this->priority[$v['priority']])?$this->priority[$v['priority']]:"";
  200. return $v;
  201. }
  202. public function getList3($orgId){
  203. $list = $this
  204. ->where('org_id',$orgId)
  205. ->where('enable',1)
  206. ->where('del',0)
  207. ->where('is_sss',1)
  208. ->select();
  209. return $list?$list->toArray():[];
  210. }
  211. }