Repair.php 7.1 KB

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