Repair.php 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. <?php
  2. namespace app\h5\controller;
  3. use app\common\model\Config;
  4. use app\hander\HelpHander;
  5. use think\Controller;
  6. use think\facade\Cookie;
  7. use think\Db;
  8. use think\Exception;
  9. class Repair extends Controller
  10. {
  11. private $addrId = 0;
  12. public function __construct()
  13. {
  14. parent::__construct();
  15. $code = input('code','','trim');
  16. //7zXfWWakNNXENJnDQIPM48OBVc9bSWNHUK55aLrGK658FqYF1HMeipH1ZAy71zmx
  17. // $code = "7zXfWWakNNXENJnDQIPM48OBVc9bSWNHUK55aLrGK658FqYF1HMeipH1ZAy71zmx";
  18. if($code){
  19. Cookie::set('code',$code);
  20. }
  21. $nCode = Cookie::get('code');
  22. if(!$nCode){
  23. $this->redirect('/h5/index/errortxt');
  24. }
  25. $arr = get_qrcode_arr($nCode);
  26. if($arr['type'] != 'address'){
  27. $this->redirect('/h5/index/errortxt');
  28. }
  29. $this->addrId = $arr['id'];
  30. }
  31. public function index(){
  32. $addr = Db::name('address')->where('id',$this->addrId)->find();
  33. $org = Db::name('org')->where('id',$addr['org_id'])->find();
  34. $this->assign('orgPhone',model('Config')->getConfig('org_phone',$addr['org_id']));
  35. $this->assign('orgName',$org['name']);
  36. $banners = model('Banner')->getList(5);
  37. $this->assign('banners',$banners);
  38. $isOff = (new Config())->getConfig('is_address_code_open',$addr['org_id']);
  39. $this->assign('isOff',$isOff);
  40. return $this->fetch();
  41. }
  42. public function add(){
  43. $mode = input('mode',0);
  44. $addr = Db::name('address')->where('id',$this->addrId)->find();
  45. if(request()->isPost()){
  46. if(in_array($mode,[1,2,3,4])){
  47. $json = [
  48. 'user_id'=>input('user_id',0),
  49. 'org_id'=>$addr['org_id'],
  50. 'dep_id'=>input('depId/d',0),
  51. 'images'=>input('images',''),
  52. 'videos'=>input('videos',''),
  53. 'voices'=>input('voices',''),
  54. 'content'=>input('content',''),
  55. 'work_type_mode'=>input('mode/d',1),
  56. 'source_type'=>input('sourceType/d',1),
  57. 'type_id'=>input('typeId/d',0),
  58. 'address_id'=>$this->addrId,
  59. 'start'=>input('start',''),
  60. 'end'=>input('end',''),
  61. 'xq_time'=>input('xqTime',''),
  62. 'ywc_time'=>input('ywcTime',''),
  63. 'type'=>input('type',''),
  64. 'device_id'=>input('deviceId',''),
  65. 'priority'=>input('priority',''),
  66. 'bed_number'=>input('bedNumber',''),
  67. 'ba_number'=>input('baNumber',''),
  68. 'p_name'=>input('pName',''),
  69. 'gender'=>input('gender',''),
  70. 'back'=>input('back',''),
  71. 'name'=>input('name',''),
  72. 'phone'=>input('phone',''),
  73. 'address'=>input('address',''),
  74. 'isSpontaneous'=>input('isSpontaneous',0),
  75. 'house_type_id'=>input('houseTypeId',0),
  76. 'sxType'=>1
  77. ];
  78. $json['images'] = $json['images'] ? implode(',',$json['images']):'';
  79. $res = model('Orders')->addSave($json);
  80. if($res){
  81. $this->success('操作成功',url('addSuccess'));
  82. }else{
  83. $this->error(model('Orders')->getError());
  84. }
  85. }else{
  86. $info = [
  87. 'orgId'=>$addr['org_id'],
  88. 'depId'=>input('depId/d',0),
  89. 'createUserId'=>0,
  90. 'hide'=>input('hide',''),
  91. 'content'=>input('content',''),
  92. 'images'=>input('images',''),
  93. 'voices'=>input('voices',''),
  94. 'videos'=>input('videos',''),
  95. 'name'=>input('name',''),
  96. 'phone'=>input('phone',''),
  97. ];
  98. $info['images'] = $info['images'] ? implode(',',$info['images']):'';
  99. $res = model('Complain')->addSave($info);
  100. if($res){
  101. $this->success('操作成功',url('addSuccess'));
  102. }else{
  103. $this->error(model('Complain')->getError());
  104. }
  105. }
  106. }else{
  107. $list = Db::name('patrol_record')
  108. ->where('org_id',$addr['org_id'])
  109. ->where('patrol_mode',4)
  110. ->where('patrol_addr_id',$addr['id'])
  111. ->order('id desc')
  112. ->limit(5)
  113. ->select();
  114. foreach ($list as $k=>$v){
  115. $list[$k]['addrName'] = Db::name('address')->where('id',$v['patrol_addr_id'])->value('title');
  116. $list[$k]['userName'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  117. $status = Db::name('patrol_task')->where('id',$v['patrol_task_id'])->value('status');
  118. $statusTxt = '';
  119. if($status == 0){
  120. $statusTxt = '待完成';
  121. }elseif ($status == 1){
  122. $statusTxt = '执行中';
  123. }elseif ($status == 2){
  124. $statusTxt = '已完成';
  125. }elseif ($status == 3){
  126. $statusTxt = '未完成';
  127. }elseif ($status == 5){
  128. $statusTxt = '中断';
  129. }elseif ($status == 6){
  130. $statusTxt = '已关闭';
  131. }
  132. $list[$k]['statusTxt'] = $statusTxt;
  133. $list[$k]['status'] = $status;
  134. $list[$k]['create_time'] = date('m-d H:i:s',strtotime($v['create_time']));
  135. }
  136. $this->assign('list',$list);
  137. }
  138. $title = '';
  139. if($mode == 1){
  140. $title = '维修';
  141. }elseif ($mode == 2){
  142. $title = '保洁';
  143. }elseif ($mode == 3){
  144. $title = '运送';
  145. }elseif ($mode == 4){
  146. $title = '安全、应急';
  147. }elseif($mode == 0){
  148. $title = '投诉';
  149. }
  150. $address = (new \app\common\model\Address())->getListByType(2,$addr['org_id']);
  151. $conveyCate = (new \app\common\model\ConveyCate());
  152. $priority = $conveyCate->priority;
  153. $order_convey = $conveyCate->getList($addr['org_id']);
  154. $order_device = (new \app\common\model\ConveyDevice())->getList($addr['org_id']);
  155. $this->assign('address', $address);
  156. $this->assign('priority', $priority);
  157. $this->assign('order_convey_type', $order_convey);
  158. $this->assign('order_device', $order_device);
  159. $this->assign('mode',$mode);
  160. $this->assign('title',$title);
  161. return $this->fetch();
  162. }
  163. public function questionnaire(){
  164. $addr = Db::name('address')->where('id',$this->addrId)->find();
  165. $list = Db::name('questionnaire')
  166. ->where('org_id',$addr['org_id'])
  167. ->where('enable',1)
  168. ->where('del',0)
  169. ->order('id desc')
  170. ->select();
  171. $strs = aes_encrypt('wj',config('app.encryption_key'));
  172. foreach ($list as $k=>$v){
  173. $url = getSite().'/h5/Wj/index?id='.$v['id'].'&code='.$strs.'&orgId='.$addr['org_id'];
  174. $list[$k]['url'] = $url;
  175. }
  176. $this->assign('list',$list);
  177. return $this->fetch();
  178. }
  179. public function video(){
  180. $addr = Db::name('address')->where('id',$this->addrId)->find();
  181. $orgId = $addr['org_id'];
  182. $list = Db::name('video')
  183. ->where(function ($query) use ($orgId) {
  184. $query->where('org_id',$orgId)
  185. ->whereOr('org_id',0);
  186. })
  187. // ->where('org_id',$addr['org_id'])
  188. ->where('enable',1)
  189. ->where('del',0)
  190. ->order('id desc')
  191. ->select();
  192. $this->assign('list',$list);
  193. return $this->fetch();
  194. }
  195. public function addSuccess(){
  196. return $this->fetch();
  197. }
  198. }