Repair.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. return $this->fetch();
  39. }
  40. public function add(){
  41. $mode = input('mode',0);
  42. $addr = Db::name('address')->where('id',$this->addrId)->find();
  43. if(request()->isPost()){
  44. if(in_array($mode,[1,2,4])){
  45. $json = [
  46. 'user_id'=>input('user_id',0),
  47. 'org_id'=>$addr['org_id'],
  48. 'dep_id'=>input('depId/d',0),
  49. 'images'=>input('images',''),
  50. 'videos'=>input('videos',''),
  51. 'voices'=>input('voices',''),
  52. 'content'=>input('content',''),
  53. 'work_type_mode'=>input('mode/d',1),
  54. 'source_type'=>input('sourceType/d',1),
  55. 'type_id'=>input('typeId/d',0),
  56. 'address_id'=>$this->addrId,
  57. 'start'=>input('start',''),
  58. 'end'=>input('end',''),
  59. 'xq_time'=>input('xqTime',''),
  60. 'ywc_time'=>input('ywcTime',''),
  61. 'type'=>input('type',''),
  62. 'device_id'=>input('deviceId',''),
  63. 'priority'=>input('priority',''),
  64. 'bed_number'=>input('bedNumber',''),
  65. 'ba_number'=>input('baNumber',''),
  66. 'p_name'=>input('pName',''),
  67. 'gender'=>input('gender',''),
  68. 'back'=>input('back',''),
  69. 'name'=>input('name',''),
  70. 'phone'=>input('phone',''),
  71. 'address'=>input('address',''),
  72. 'isSpontaneous'=>input('isSpontaneous',0),
  73. 'house_type_id'=>input('houseTypeId',0),
  74. 'sxType'=>1
  75. ];
  76. $json['images'] = $json['images'] ? implode(',',$json['images']):'';
  77. $res = model('Orders')->addSave($json);
  78. if($res){
  79. $this->success('操作成功',url('addSuccess'));
  80. }else{
  81. $this->error(model('Orders')->getError());
  82. }
  83. }else{
  84. $info = [
  85. 'orgId'=>$addr['org_id'],
  86. 'depId'=>input('depId/d',0),
  87. 'createUserId'=>0,
  88. 'hide'=>input('hide',''),
  89. 'content'=>input('content',''),
  90. 'images'=>input('images',''),
  91. 'voices'=>input('voices',''),
  92. 'videos'=>input('videos',''),
  93. 'name'=>input('name',''),
  94. 'phone'=>input('phone',''),
  95. ];
  96. $info['images'] = $info['images'] ? implode(',',$info['images']):'';
  97. $res = model('Complain')->addSave($info);
  98. if($res){
  99. $this->success('操作成功',url('addSuccess'));
  100. }else{
  101. $this->error(model('Complain')->getError());
  102. }
  103. }
  104. }else{
  105. $list = Db::name('patrol_record')
  106. ->where('org_id',$addr['org_id'])
  107. ->where('patrol_mode',4)
  108. ->where('patrol_addr_id',$addr['id'])
  109. ->order('id desc')
  110. ->limit(5)
  111. ->select();
  112. foreach ($list as $k=>$v){
  113. $list[$k]['addrName'] = Db::name('address')->where('id',$v['patrol_addr_id'])->value('title');
  114. $list[$k]['userName'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  115. $status = Db::name('patrol_task')->where('id',$v['patrol_task_id'])->value('status');
  116. $statusTxt = '';
  117. if($status == 0){
  118. $statusTxt = '待完成';
  119. }elseif ($status == 1){
  120. $statusTxt = '执行中';
  121. }elseif ($status == 2){
  122. $statusTxt = '已完成';
  123. }elseif ($status == 3){
  124. $statusTxt = '未完成';
  125. }elseif ($status == 5){
  126. $statusTxt = '中断';
  127. }elseif ($status == 6){
  128. $statusTxt = '已关闭';
  129. }
  130. $list[$k]['statusTxt'] = $statusTxt;
  131. $list[$k]['status'] = $status;
  132. $list[$k]['create_time'] = date('m-d H:i:s',strtotime($v['create_time']));
  133. }
  134. $this->assign('list',$list);
  135. }
  136. $title = '';
  137. if($mode == 1){
  138. $title = '维修';
  139. }elseif ($mode == 2){
  140. $title = '保洁';
  141. }elseif ($mode == 4){
  142. $title = '应急';
  143. }elseif($mode == 0){
  144. $title = '投诉';
  145. }
  146. $this->assign('mode',$mode);
  147. $this->assign('title',$title);
  148. return $this->fetch();
  149. }
  150. public function questionnaire(){
  151. $addr = Db::name('address')->where('id',$this->addrId)->find();
  152. $list = Db::name('questionnaire')
  153. ->where('org_id',$addr['org_id'])
  154. ->where('enable',1)
  155. ->where('del',0)
  156. ->order('id desc')
  157. ->select();
  158. $strs = aes_encrypt('wj',config('app.encryption_key'));
  159. foreach ($list as $k=>$v){
  160. $url = getSite().'/h5/Wj/index?id='.$v['id'].'&code='.$strs.'&orgId='.$addr['org_id'];
  161. $list[$k]['url'] = $url;
  162. }
  163. $this->assign('list',$list);
  164. return $this->fetch();
  165. }
  166. public function video(){
  167. $addr = Db::name('address')->where('id',$this->addrId)->find();
  168. $orgId = $addr['org_id'];
  169. $list = Db::name('video')
  170. ->where(function ($query) use ($orgId) {
  171. $query->where('org_id',$orgId)
  172. ->whereOr('org_id',0);
  173. })
  174. // ->where('org_id',$addr['org_id'])
  175. ->where('enable',1)
  176. ->where('del',0)
  177. ->order('id desc')
  178. ->select();
  179. $this->assign('list',$list);
  180. return $this->fetch();
  181. }
  182. public function addSuccess(){
  183. return $this->fetch();
  184. }
  185. }