Statistics.php 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  1. <?php
  2. namespace app\h5\controller;
  3. use app\common\model\WorkTypeMode;
  4. use app\hander\HelpHander;
  5. use think\App;
  6. use think\Controller;
  7. use think\Db;
  8. use think\helper\Time;
  9. class Statistics extends Controller
  10. {
  11. private $orgId = 0;
  12. public function initialize()
  13. {
  14. parent::initialize();
  15. $this->orgId = input('orgId/d',0);
  16. // halt($this->orgId);
  17. if($this->orgId <= 0){
  18. $this->redirect(url('index/errorPage'));
  19. }
  20. }
  21. protected function checkToken(){
  22. $token = input('token','','trim');
  23. if(!$token){
  24. if(request()->isAjax()){
  25. $this->error('登录信息失效');
  26. }else{
  27. $this->redirect(url('index/errorPage'));
  28. }
  29. }
  30. $user = Db::name('token')->where('token',$token)->find();
  31. if(!$user) {
  32. if(request()->isAjax()){
  33. $this->error('登录信息失效');
  34. }else{
  35. $this->redirect(url('index/errorPage'));
  36. }
  37. }
  38. return $user['user_id'];
  39. }
  40. public function orders(){
  41. $type = input('type/d',1);
  42. $mode = input('mode/d',1);
  43. if($mode == 1){
  44. $list = [
  45. ['id' => [5],'type'=>'已完成订单'],
  46. ['id' => [1],'type'=>'待处理订单'],
  47. ['id' => [4],'type'=>'已派发订单'],
  48. ['id' => [2,3],'type'=>'已取消订单'],
  49. ['id' => [6],'type'=>'已评价订单'],
  50. ['id' => [-1],'type'=>'挂起订单'],
  51. ];
  52. }else{
  53. $list = [
  54. ['id' => [5],'type'=>'已完成订单'],
  55. ['id' => [1],'type'=>'待处理订单'],
  56. ['id' => [4],'type'=>'已派发订单'],
  57. ['id' => [2,3],'type'=>'已取消订单'],
  58. ['id' => [6],'type'=>'已评价订单'],
  59. ];
  60. }
  61. $map[] = ['del','=',0];
  62. $map[] = ['org_id','=',$this->orgId];
  63. $map[] = ['work_type_mode','=',$mode];
  64. if($type == 1){ //日统计
  65. $map[] = ['create_yyyymmdd','=',date('Ymd')];
  66. }else if($type == 2){ //月统计
  67. $map[] = ['create_yyyymm','=',date('Ym')];
  68. }
  69. $allcount = 0;
  70. if($mode == 1){
  71. foreach ($list as $k=>$v){
  72. if(in_array(4,$v['id'])){
  73. $a1 = 0;
  74. $order = Db::name('orders')->where($map)->where('order_mode','in',$v['id'])->select();
  75. foreach ($order as $kk=>$vv){
  76. $todo = Db::name('todo')->where('order_id',$vv['id'])->where('pause',1)->where('todo_mode',2)->where('del',0)->find();
  77. if($todo){
  78. $a1 +=1;
  79. }
  80. }
  81. $cost = count($order)-$a1;
  82. }elseif(in_array(-1,$v['id'])){
  83. $a2 = 0;
  84. $order = Db::name('orders')->where($map)->where('order_mode',4)->select();
  85. foreach ($order as $kk=>$vv){
  86. $todo = Db::name('todo')->where('order_id',$vv['id'])->where('del',0)->where('todo_mode',2)->where('pause',1)->find();
  87. if($todo){
  88. $a2 +=1;
  89. }
  90. }
  91. $cost = $a2;
  92. }else{
  93. $cost = Db::name('orders')->where($map)->where('order_mode','in',$v['id'])->count();
  94. }
  95. $list[$k]['cost'] = $cost;
  96. $list[$k]['a'] = '1';
  97. $allcount += $list[$k]['cost'];
  98. }
  99. }else{
  100. foreach ($list as $k=>$v){
  101. $list[$k]['cost'] = Db::name('orders')->where($map)->where('order_mode','in',$v['id'])->count();
  102. $list[$k]['a'] = '1';
  103. $allcount += $list[$k]['cost'];
  104. }
  105. }
  106. $this->assign('list',$list);
  107. $this->assign('allcount',$allcount);
  108. $this->assign('orgId',$this->orgId);
  109. $this->assign('type',$type);
  110. $this->assign('mode',$mode);
  111. return $this->fetch();
  112. }
  113. public function users() {
  114. $lists = Db::name('roles')->where('id','in',(new WorkTypeMode())->workerRoles)->field('id,name')->select();
  115. $lists = $lists?$lists:[];
  116. $allcount = 0;
  117. foreach ($lists as $k=>$v){
  118. $lists[$k]['color'] = '#325699';
  119. $roleIds = model('Roles')->getRoleIds($v['id'],$this->orgId);
  120. $map = [];
  121. $map[] = ['u.del','=',0];
  122. $map[] = ['u.enable','=',1];
  123. if($roleIds){
  124. $map[] = ['ur.roles_id','in',$roleIds];
  125. }else{
  126. $map[] = ['ur.roles_id','=',-1];
  127. }
  128. $count = Db::name('user_roles')
  129. ->alias('ur')
  130. ->join('user u','u.id = ur.user_id')
  131. ->where($map)
  132. ->count();
  133. $lists[$k]['cost'] = $count;
  134. $lists[$k]['a'] = '1';
  135. $allcount += $count;
  136. }
  137. $this->assign('list',$lists);
  138. $this->assign('orgId',$this->orgId);
  139. $this->assign('allcount',$allcount);
  140. return $this->fetch();
  141. }
  142. public function comment() {
  143. $type = input('type/d',1);
  144. if($type == 1){ //日统计
  145. $map[] =['c.create_yyyymmdd','=',date('Ymd')];
  146. }else if($type == 2){ //月统计
  147. $map[] =['c.create_yyyymm','=',date('Ym')];
  148. }
  149. $map[] = ['c.org_id','=',$this->orgId];
  150. $tlist = [
  151. ['work_type_mode'=> 0,'name'=>'一键呼叫'],
  152. ['work_type_mode'=> 1,'name'=>'报修'],
  153. ['work_type_mode'=> 2,'name'=>'保洁'],
  154. ['work_type_mode'=> 3,'name'=>'运送'],
  155. ['work_type_mode'=> 4,'name'=>'安保'],
  156. ['work_type_mode'=> 15,'name'=>'品质整改']
  157. ];
  158. $list = [];
  159. foreach ($tlist as $k=>$v){
  160. $ss = Db::name('comment')
  161. ->alias('c')
  162. ->join('orders o','o.id = c.from_id')
  163. ->where('c.type',$v['work_type_mode'])
  164. ->where('o.del',0)
  165. ->where($map)
  166. ->field('count(*) as count,sum(score) as score,c.type')
  167. ->find();
  168. $list[] = array(
  169. 'year' => $v['name'],
  170. 'sales' => $ss&&$ss['count']>0?round($ss['score']/$ss['count'],1):0,
  171. 'count' => $ss['count'],
  172. 'work_type_mode'=>$ss['type']?$ss['type']:$v['work_type_mode'],
  173. );
  174. }
  175. $this->assign('list',$list);
  176. $this->assign('orgId',$this->orgId);
  177. $this->assign('type',$type);
  178. return $this->fetch();
  179. }
  180. public function daily() {
  181. $type = input('type/d',0);
  182. $map[] = ['org_id','=',$this->orgId];
  183. if($type == 0){ //日统计
  184. $map[] = ['create_yyyymmdd','=',date('Ymd')];
  185. } else if($type == 1){ //月统计
  186. $map[] = ['create_yyyymm','=',date('Ym')];
  187. }
  188. $alladdr = Db::name('daily_record')->where($map)->group('daily_id')->count();
  189. $allcount = Db::name('daily_record')->where($map)->count();
  190. $this->assign('allcount',$allcount);
  191. $this->assign('alladdr',$alladdr);
  192. $this->assign('orgId',$this->orgId);
  193. $this->assign('type',$type);
  194. return $this->fetch();
  195. }
  196. public function device() {
  197. $type = input('type/d',0);
  198. $map[] = ['org_id','=',$this->orgId];
  199. if($type == 0){ //日统计
  200. $map[] = ['create_yyyymmdd','=',date('Ymd')];
  201. } else if($type == 1){ //月统计
  202. $map[] = ['create_yyyymm','=',date('Ym')];
  203. }
  204. $device = Db::name('device_record')->where($map)->group('device_id')->count();
  205. $allcount = Db::name('device_record')->where($map)->count();
  206. $this->assign('allcount',$allcount);
  207. $this->assign('device',$device);
  208. $this->assign('orgId',$this->orgId);
  209. $this->assign('type',$type);
  210. return $this->fetch();
  211. }
  212. public function patrol() {
  213. $type = input('type/d',0);
  214. $mode = input('mode/d',1);
  215. $map[] = ['org_id','=',$this->orgId];
  216. $map[] = ['del','=',0];
  217. $map[] = ['patrol_mode','=',$mode];
  218. if($type == 0){ //日统计
  219. $map[] = ['create_yyyymmdd','=',date('Ymd')];
  220. } else if($type == 1){ //月统计
  221. $map[] = ['create_yyyymm','=',date('Ym')];
  222. }
  223. $tt = 3;
  224. if($mode == 2){
  225. $tt = 4;
  226. }else if($mode == 3){
  227. $tt = 5;
  228. }else if($mode == 4){
  229. $tt = 6;
  230. }
  231. $bluetooth = model('Address')->getListByTypeCount($tt,$this->orgId);
  232. $complete = Db::name('patrol_task')->where($map)->where('status', 2)->count();
  233. $incomplete = Db::name('patrol_task')->where($map)->where('status', 3)->count();
  234. $allcount = Db::name('patrol_task')->where($map)->count();
  235. $ratio = 0;
  236. if($allcount > 0) {
  237. $ratio = round($complete / $allcount*100,2);
  238. }
  239. $mode_name = Db::name('patrol_mode')->where('id', $mode)->field('name')->find();
  240. $this->assign('allcount',$allcount);
  241. $this->assign('bluetooth',$bluetooth);
  242. $this->assign('complete',$complete);
  243. $this->assign('incomplete',$incomplete);
  244. $this->assign('orgId',$this->orgId);
  245. $this->assign('type',$type);
  246. $this->assign('ratio',$ratio);
  247. $this->assign('mode',$mode);
  248. $this->assign('mode_name',$mode_name);
  249. return $this->fetch();
  250. }
  251. public function ordersList(){
  252. $page = input('page',1);
  253. $size = input('size',20);
  254. $type = input('type',-1);//订单状态
  255. $mode = input('mode',0);//订单类型
  256. $day = input('day',0);//日,月,总计
  257. if(!$type){
  258. $where[]=['order_mode','in',[-1]];
  259. }
  260. //全部订单
  261. if($type == -1){
  262. $where[]=['order_mode','in',[1,2,3,4,5,6]];
  263. }
  264. //已完成订单
  265. if($type == 0){
  266. $where[]=['order_mode','in',[5]];
  267. }
  268. //待处理订单
  269. if($type == 1){
  270. $where[]=['order_mode','in',[1]];
  271. }
  272. //已派发订单
  273. if($type == 2){
  274. $where[]=['order_mode','in',[4]];
  275. }
  276. //已取消订单
  277. if($type == 3){
  278. $where[]=['order_mode','in',[2,3]];
  279. }
  280. //已评价订单
  281. if($type == 4){
  282. $where[]=['order_mode','in',[6]];
  283. }
  284. if($type == 5){ //挂起订单
  285. $where[]=['order_mode','in',[4]];
  286. }
  287. if($day == 1){ //日订单
  288. $where[] = ['create_yyyymmdd','=',date('Ymd')];
  289. }else if($day == 2){ //月订单
  290. $where[] = ['create_yyyymm','=',date('Ym')];
  291. }
  292. //订单类型
  293. if(in_array($mode,array(1,2,3,4))){
  294. $where[] = ['work_type_mode','=',$mode];
  295. }else{
  296. $where[] = ['work_type_mode','>',0];
  297. }
  298. $andWhere = array(
  299. 'del' => 0,
  300. 'org_id' => $this->orgId
  301. );
  302. if($page > 1){
  303. $list = Db::name('orders')
  304. ->field('id,dep_id,work_type_mode,order_mode,user_id,create_time,org_id')
  305. ->where($where)
  306. ->where($andWhere)
  307. ->page($page,$size)
  308. ->order('id desc')
  309. ->select();
  310. foreach ($list as $k=>$v){
  311. if($type == 2 && $v['order_mode'] == 4){
  312. $list[$k]['out_content'] = Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  313. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  314. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  315. $list[$k]['dep_name'] = $dep?$dep :'' ;
  316. $todo = Db::name('todo')->where('order_id',$v['id'])->where('del',0)->where('todo_mode',2)->where('pause',1)->find();
  317. if($todo){
  318. unset($list[$k]);
  319. }
  320. }elseif($type == 5 && $v['order_mode'] == 4){
  321. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  322. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  323. $list[$k]['dep_name'] = $dep?$dep :'' ;
  324. $list[$k]['out_content'] = '挂起';
  325. $todo = Db::name('todo')->where('order_id',$v['id'])->where('del',0)->where('todo_mode',2)->where('pause',1)->find();
  326. if(!$todo){
  327. unset($list[$k]);
  328. }
  329. }else if($type == -1){
  330. if($v['order_mode'] == 4){
  331. $todo = Db::name('todo')->where('order_id',$v['id'])->where('del',0)->where('todo_mode',2)->where('pause',1)->find();
  332. $list[$k]['out_content'] = $todo ? '挂起': Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  333. }else{
  334. $list[$k]['out_content'] = Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  335. }
  336. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  337. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  338. $list[$k]['dep_name'] = $dep?$dep :'' ;
  339. }else{
  340. $list[$k]['out_content'] = Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  341. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  342. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  343. $list[$k]['dep_name'] = $dep?$dep :'' ;
  344. }
  345. }
  346. $this->success('','',array_values($list));
  347. }else{
  348. $list = Db::name('orders')
  349. ->field('id,dep_id,work_type_mode,order_mode,user_id,create_time,org_id')
  350. ->where($where)
  351. ->where($andWhere)
  352. ->page($page,$size)
  353. ->order('id desc')
  354. ->select();
  355. foreach ($list as $k=>$v){
  356. if($type == 2 && $v['order_mode'] == 4){
  357. $list[$k]['out_content'] = Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  358. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  359. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  360. $list[$k]['dep_name'] = $dep?$dep :'' ;
  361. $todo = Db::name('todo')->where('order_id',$v['id'])->where('del',0)->where('todo_mode',2)->where('pause',1)->find();
  362. if($todo){
  363. unset($list[$k]);
  364. }
  365. }elseif($type == 5 && $v['order_mode'] == 4){
  366. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  367. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  368. $list[$k]['dep_name'] = $dep?$dep :'' ;
  369. $list[$k]['out_content'] = '挂起';
  370. $todo = Db::name('todo')->where('order_id',$v['id'])->where('del',0)->where('todo_mode',2)->where('pause',1)->find();
  371. if(!$todo){
  372. unset($list[$k]);
  373. }
  374. }else if($type == -1){
  375. if($v['order_mode'] == 4){
  376. $todo = Db::name('todo')->where('order_id',$v['id'])->where('del',0)->where('todo_mode',2)->where('pause',1)->find();
  377. $list[$k]['out_content'] = $todo ? '挂起': Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  378. }else{
  379. $list[$k]['out_content'] = Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  380. }
  381. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  382. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  383. $list[$k]['dep_name'] = $dep?$dep :'' ;
  384. }else{
  385. $list[$k]['out_content'] = Db::name('order_mode')->where('id',$v['order_mode'])->value('out_content');
  386. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  387. $dep = Db::name('dep')->where('id',$v['dep_id'])->value('title');
  388. $list[$k]['dep_name'] = $dep?$dep :'' ;
  389. }
  390. }
  391. $this->assign('mode',$mode);
  392. $this->assign('orgId',$this->orgId);
  393. $this->assign('type',$type);
  394. $this->assign('day',$day);
  395. $this->assign('list',array_values($list));
  396. return $this->fetch();
  397. }
  398. }
  399. public function ordersDetails(){
  400. $id = input('id',0);
  401. $info = model('Orders')->detail($id);
  402. $info['create_time'] = date('Y-m-d H:i',strtotime($info['create_time']));
  403. $info['images'] = $info['images']?explode(',',$info['images']):[];
  404. $info['videos'] = $info['videos']?explode(',',$info['videos']):[];
  405. $this->assign('info',$info);
  406. return $this->fetch();
  407. }
  408. public function ordersSubDetails(){
  409. $id = input('id',0);
  410. $info = Db::name('todo')->where('id',$id)->find();
  411. $info['sign'] = $info['sign']?explode(',',$info['sign']):[];
  412. $info['cons'] = [];
  413. if ($info['work_type_mode'] == 1) {
  414. $todo_mate = Db::name('todo_mate')
  415. ->where('order_id',$info['order_id'])
  416. ->select();
  417. if(!empty($todo_mate)){
  418. $cons = Db::name('todo_mate_item')
  419. ->alias('a')
  420. ->join('mate_goods b','b.id = a.items_id')
  421. ->where('a.todo_mate_id','in',array_column($todo_mate,'id'))
  422. ->field('a.*,b.title')
  423. ->select();
  424. foreach ($cons as $k1=>$v1){
  425. $pInfo = Db::name('mate_goods')
  426. ->where('id',$v1['pid'])
  427. ->find();
  428. $info['cons'][] = [
  429. 'title' =>$v1['title'],
  430. 'total' =>$v1['total'],
  431. 'money' =>$v1['money'],
  432. 'total_money' =>$v1['total_money'],
  433. ];
  434. }
  435. }
  436. }
  437. $this->assign('info',$info);
  438. return $this->fetch();
  439. }
  440. public function videoPlay(){
  441. $src = input('url');
  442. $this->assign('url',$src);
  443. return $this->fetch();
  444. }
  445. //巡更任务列表
  446. public function patrolList() {
  447. $page = input('page',1);
  448. $size = input('size',20);
  449. $type = input('type',0);//巡更状态
  450. $mode = input('mode',0);//巡更类型
  451. $day = input('day',0);//日,月,总计
  452. if($type==2){
  453. $where[] = ['status','=',2];
  454. }
  455. if($type==3){
  456. $where[] = ['status','=',3];
  457. }
  458. $where[] = ['org_id','=',$this->orgId];
  459. $where[] = ['del','=',0];
  460. if($day == 0){ //日订单
  461. $where[] = ['create_yyyymmdd','=',date('Ymd')];
  462. }else if($day == 1){ //月订单
  463. $where[] = ['create_yyyymm','=',date('Ym')];
  464. }else if($day == 2){ //总订单
  465. }
  466. //订单类型
  467. if(in_array($mode,array(1,2,3,4))){
  468. $where[] = ['patrol_mode','=',$mode];
  469. }else{
  470. $where[] = ['patrol_mode','>',0];
  471. }
  472. if($page > 1){
  473. $list = Db::name('patrol_task')
  474. ->field('id,title,start_time,end_time,status,patrol_mode,org_id')
  475. ->where($where)
  476. ->order('id desc')
  477. ->page($page,$size)
  478. ->select();
  479. foreach ($list as $k=>$v){
  480. $user = Db::name('patrol_task_user')
  481. ->alias('ptu')
  482. ->join('user u','u.id=ptu.user_id')
  483. ->where('ptu.patrol_task_id',$v['id'])
  484. ->column('u.real_name');
  485. $list[$k]['real_name']=$user?implode(',',$user):'';
  486. $dep = Db::name('patrol_task_user')
  487. ->alias('ptu')
  488. ->join('user_dep ud','ud.user_id=ptu.user_id')
  489. ->join('dep d','d.id=ud.dep_id')
  490. ->where('ptu.patrol_task_id',$v['id'])
  491. ->column('d.title');
  492. $list[$k]['dep']=$dep?implode(',',$dep):'';
  493. }
  494. HelpHander::success($list);
  495. }else{
  496. $list = Db::name('patrol_task')
  497. ->field('id,title,start_time,end_time,status,patrol_mode,org_id')
  498. ->where($where)
  499. ->order('id desc')
  500. ->page($page,$size)
  501. ->select();
  502. foreach ($list as $k=>$v){
  503. $user = Db::name('patrol_task_user')
  504. ->alias('ptu')
  505. ->join('user u','u.id=ptu.user_id')
  506. ->where('ptu.patrol_task_id',$v['id'])
  507. ->column('u.real_name');
  508. $list[$k]['real_name']=$user?implode(',',$user):'';
  509. $dep = Db::name('patrol_task_user')
  510. ->alias('ptu')
  511. ->join('user_dep ud','ud.user_id=ptu.user_id')
  512. ->join('dep d','d.id=ud.dep_id')
  513. ->where('ptu.patrol_task_id',$v['id'])
  514. ->column('d.title');
  515. $list[$k]['dep']=$dep?implode(',',$dep):'';
  516. }
  517. $this->assign('list',$list);
  518. $this->assign('mode',$mode);
  519. $this->assign('type',$type);
  520. $this->assign('day',$day);
  521. $this->assign('orgId',$this->orgId);
  522. return $this->fetch();
  523. }
  524. }
  525. public function patrolDetails(){
  526. $id = input('id',0);
  527. $info = Db::name('patrol_task')
  528. ->where('id',$id)
  529. ->where('del',0)
  530. ->find();
  531. $info['interrupt_img']= $info['interrupt_img']?explode(',',$info['interrupt_img']):[];
  532. $info['patrol_type']= Db::name('patrol_mode')->where('id',$info['patrol_mode'])->value('name');
  533. //巡更人员
  534. $taskUser= Db::name('patrol_task_user')
  535. ->alias('ptu')
  536. ->join('user u','u.id=ptu.user_id')
  537. ->where('ptu.patrol_task_id',$info['id'])
  538. ->column('u.real_name');
  539. $info['patrol_user']=$taskUser?implode(',',$taskUser):'';
  540. //巡更地点
  541. $address = Db::name('patrol_task_addr')
  542. ->alias('pta')
  543. ->field('a.id,a.title,pta.id as patrol_form_id,pta.patrol_task_id')
  544. // ->join('patrol_addr_form paf','paf.id=pta.patrol_form_id')
  545. ->join('address a','a.id=pta.address_id')
  546. ->where('pta.patrol_task_id',$id)
  547. ->select();
  548. foreach ($address as $kk=>$vv){
  549. $record = Db::name('patrol_record')
  550. ->where('patrol_task_id',$vv['patrol_task_id'])
  551. ->where('patrol_addr_id',$vv['id'])
  552. ->where('patrol_addr_form_id',$vv['patrol_form_id'])
  553. ->find();
  554. $address[$kk]['status'] = $record?1:0;
  555. }
  556. $info['patrol_address']=$address?$address:[];
  557. $this->assign('info',$info);
  558. return $this->fetch();
  559. }
  560. public function patrolSonDetails(){
  561. $addrFormId = input('addrFormId',0);
  562. $id = input('id',0);
  563. $task = Db::name('patrol_task')
  564. ->field('end_time,patrol_mode')
  565. ->where('id',$id)
  566. ->where('del',0)
  567. ->find();
  568. //巡更人员
  569. $taskUser = Db::name('patrol_task_user')
  570. ->alias('ptu')
  571. ->join('user u','u.id=ptu.user_id')
  572. ->where('ptu.patrol_task_id',$id)
  573. ->column('u.real_name');
  574. $info = Db::name('patrol_record')
  575. ->field('images,content,check_json')
  576. ->where('patrol_task_id',$id)
  577. ->where('patrol_addr_form_id',$addrFormId)
  578. ->find();
  579. $info['img'] = $info['images']?explode(',',$info['images']):[];
  580. $info['forms'] =$info['check_json']?json_decode($info['check_json'],true):[];
  581. $info['patrol_user']=$taskUser?implode(',',$taskUser):'';
  582. $info['patrol_time']=$task['end_time'];
  583. $info['patrol_type']= Db::name('patrol_mode')->where('id',$task['patrol_mode'])->value('name');
  584. $this->assign('info',$info);
  585. return $this->fetch();
  586. }
  587. //用户列表
  588. public function userList(){
  589. $page = input('page',1);
  590. $size = input('size',20);
  591. $rolesId = input('rolesId',0);
  592. if($page > 1){
  593. if($rolesId == 0){
  594. $rolesIds = Db::name('roles')
  595. ->whereIn('parent_id',[4,5,6,7,8,9,10,11])
  596. ->where('org_id',$this->orgId)
  597. ->where('del',0)
  598. ->where('enable',1)
  599. ->column('id');
  600. $list = Db::name('user')
  601. ->alias('u')
  602. ->field('u.id,u.real_name,u.head_image,u.create_time,u.mobile')
  603. ->join('user_roles ur','ur.user_id=u.id')
  604. ->where('u.del',0)
  605. ->where('u.enable',1)
  606. ->whereIn('ur.roles_id',$rolesIds)
  607. ->order('u.id desc')
  608. ->page($page,$size)
  609. ->select();
  610. }else{
  611. $rolesIds = Db::name('roles')
  612. ->where('parent_id',$rolesId)
  613. ->where('org_id',$this->orgId)
  614. ->where('del',0)
  615. ->where('enable',1)
  616. ->column('id');
  617. $list = Db::name('user')
  618. ->alias('u')
  619. ->field('u.id,u.real_name,u.head_image,u.create_time,u.mobile')
  620. ->join('user_roles ur','ur.user_id=u.id')
  621. ->where('u.del',0)
  622. ->where('u.enable',1)
  623. ->whereIn('ur.roles_id',$rolesIds)
  624. ->order('u.id desc')
  625. ->page($page,$size)
  626. ->select();
  627. }
  628. HelpHander::success($list);
  629. }else{
  630. if($rolesId == 0){
  631. $rolesIds = Db::name('roles')
  632. ->whereIn('parent_id',[4,5,6,7,8,9,10,11])
  633. ->where('org_id',$this->orgId)
  634. ->where('del',0)
  635. ->where('enable',1)
  636. ->column('id');
  637. $list = Db::name('user')
  638. ->alias('u')
  639. ->field('u.id,u.real_name,u.head_image,u.create_time,u.mobile')
  640. ->join('user_roles ur','ur.user_id=u.id')
  641. ->where('u.del',0)
  642. ->where('u.enable',1)
  643. ->whereIn('ur.roles_id',$rolesIds)
  644. ->order('u.id desc')
  645. ->page($page,$size)
  646. ->select();
  647. }else{
  648. $rolesIds = Db::name('roles')
  649. ->where('parent_id',$rolesId)
  650. ->where('org_id',$this->orgId)
  651. ->where('del',0)
  652. ->where('enable',1)
  653. ->column('id');
  654. $list = Db::name('user')
  655. ->alias('u')
  656. ->field('u.id,u.real_name,u.head_image,u.create_time,u.mobile')
  657. ->join('user_roles ur','ur.user_id=u.id')
  658. ->where('u.del',0)
  659. ->where('u.enable',1)
  660. ->whereIn('ur.roles_id',$rolesIds)
  661. ->order('u.id desc')
  662. ->page($page,$size)
  663. ->select();
  664. }
  665. }
  666. $this->assign('rolesId',$rolesId);
  667. $this->assign('orgId',$this->orgId);
  668. $this->assign('list',$list);
  669. return $this->fetch();
  670. }
  671. public function commentList() {
  672. $page = input('page',1);
  673. $size = input('size',20);
  674. $day = input('day',1);//日,月,总计
  675. $mode = input('mode',0);
  676. $where[] = ['o.del','=',0];
  677. $where[] = ['o.org_id','=',$this->orgId];
  678. $where[] = ['c.type','=',$mode];
  679. if($day == 1){ //日订单
  680. $where[] = ['c.create_yyyymmdd','=',date('Ymd')];
  681. }else if($day == 2){ //月订单
  682. $where[] = ['c.create_yyyymm','=',date('Ym')];
  683. }
  684. if($page > 1){
  685. $list = Db::name('comment')
  686. ->alias('c')
  687. ->field('c.*')
  688. ->join('orders o','o.id=c.from_id')
  689. ->where($where)
  690. ->order('c.id desc')
  691. ->page($page,$size)
  692. ->select();
  693. foreach ($list as $k=>$v){
  694. $list[$k]['user_name']= Db::name('user')->where('id',$v['user_id'])->value('real_name');
  695. }
  696. HelpHander::success($list);
  697. }else{
  698. $list = Db::name('comment')
  699. ->alias('c')
  700. ->field('c.*')
  701. ->join('orders o','o.id=c.from_id')
  702. ->where($where)
  703. ->order('c.id desc')
  704. ->page($page,$size)
  705. ->select();
  706. foreach ($list as $k=>$v){
  707. $list[$k]['user_name']= Db::name('user')->where('id',$v['user_id'])->value('real_name');
  708. }
  709. }
  710. $this->assign('list',$list);
  711. $this->assign('day',$day);
  712. $this->assign('mode',$mode);
  713. $this->assign('orgId',$this->orgId);
  714. return $this->fetch();
  715. }
  716. public function commentDetails(){
  717. $id = input('id',0);
  718. $info = Db::name('comment')->where('id',$id)->find();
  719. $info['user_name'] = Db::name('user')->where('id',$info['user_id'])->value('real_name');
  720. $this->assign('info',$info);
  721. return $this->fetch();
  722. }
  723. //日常工作统计
  724. public function dailyList() {
  725. $page = input('page',1);
  726. $size = input('size',20);
  727. $day = input('day',0);//日,月,总计
  728. if($day == 0){ //日订单
  729. $where[] = ['create_yyyymmdd','=',date('Ymd')];
  730. }else if($day == 1){ //月订单
  731. $where[] = ['create_yyyymm','=',date('Ym')];
  732. }
  733. $where[] = ['org_id','=',$this->orgId];
  734. $dailyIds = Db::name('daily_record')->where($where)->group('daily_id')->column('daily_id');
  735. if($dailyIds){
  736. $map[] = ['id','in',$dailyIds];
  737. }else{
  738. $map[] = ['id','in',[0]];
  739. }
  740. if($page>1){
  741. $list = Db::name('daily')
  742. ->field('id,title,enable')
  743. ->where('org_id',$this->orgId)
  744. ->where($map)
  745. ->order('id desc')
  746. ->page($page,$size)
  747. ->select();
  748. foreach ($list as $k=>$v){
  749. $user = Db::name('daily_user')
  750. ->alias('du')
  751. ->join('user u','u.id=du.user_id')
  752. ->where('du.daily_id',$v['id'])
  753. ->where('u.del',0)
  754. ->where('u.enable',1)
  755. ->column('u.real_name');
  756. $list[$k]['work_user']=$user?implode(',',$user):'';
  757. }
  758. HelpHander::success($list);
  759. }else{
  760. $list = Db::name('daily')
  761. ->field('id,title,enable')
  762. ->where('org_id',$this->orgId)
  763. ->where($map)
  764. ->order('id desc')
  765. ->page($page,$size)
  766. ->select();
  767. foreach ($list as $k=>$v){
  768. $user = Db::name('daily_user')
  769. ->alias('du')
  770. ->join('user u','u.id=du.user_id')
  771. ->where('du.daily_id',$v['id'])
  772. ->where('u.del',0)
  773. ->where('u.enable',1)
  774. ->column('u.real_name');
  775. $list[$k]['work_user']=$user?implode(',',$user):'';
  776. }
  777. }
  778. $this->assign('list',$list);
  779. $this->assign('day',$day);
  780. $this->assign('orgId',$this->orgId);
  781. return $this->fetch();
  782. }
  783. public function dailyRecordList() {
  784. $page = input('page',1);
  785. $size = input('size',20);
  786. $day = input('day',0);//日,月,总计
  787. if($day == 0){ //日订单
  788. $where[] = ['create_yyyymmdd','=',date('Ymd')];
  789. }else if($day == 1){ //月订单
  790. $where[] = ['create_yyyymm','=',date('Ym')];
  791. }
  792. $where[] = ['org_id','=',$this->orgId];
  793. if($page>1){
  794. $list = Db::name('daily_record')
  795. ->field('id,user_id,create_time,org_id')
  796. ->where($where)
  797. ->order('id desc')
  798. ->page($page,$size)
  799. ->select();
  800. foreach ($list as $k=>$v){
  801. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  802. }
  803. HelpHander::success($list);
  804. }else{
  805. $list = Db::name('daily_record')
  806. ->field('id,user_id,create_time,org_id')
  807. ->where($where)
  808. ->order('id desc')
  809. ->page($page,$size)
  810. ->select();
  811. foreach ($list as $k=>$v){
  812. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  813. }
  814. }
  815. $this->assign('list',$list);
  816. $this->assign('day',$day);
  817. $this->assign('orgId',$this->orgId);
  818. return $this->fetch();
  819. }
  820. public function dailyRecordDetails(){
  821. $id = input('id',0);
  822. $info = Db::name('daily_record')->where('id',$id)->find();
  823. $info['img'] = $info['images']?explode(',',$info['images']):[];
  824. //任务内容
  825. $daily = Db::name('daily')->where('id',$info['daily_id'])->find();
  826. $info['daily_content'] = $daily['content'] ? $daily['content']:'';
  827. $info['daily_title'] = $daily['title'] ? $daily['title']:'';
  828. $info['user_name'] = Db::name('user')->where('id',$info['user_id'])->value('real_name');
  829. $info['forms'] = json_decode($info['check_json'],true);
  830. $this->assign('info',$info);
  831. return $this->fetch();
  832. }
  833. //设备台账统计
  834. public function deviceList() {
  835. $page = input('page',1);
  836. $size = input('size',20);
  837. $day = input('day',0);//日,月,总计
  838. if($day == 0){ //日订单
  839. $where[] = ['create_yyyymmdd','=',date('Ymd')];
  840. }else if($day == 1){ //月订单
  841. $where[] = ['create_yyyymm','=',date('Ym')];
  842. }
  843. $where[] = ['org_id','=',$this->orgId];
  844. $deviceIds = Db::name('device_record')->where($where)->group('device_id')->column('device_id');
  845. if($deviceIds){
  846. $map[] = ['id','in',$deviceIds];
  847. }else{
  848. $map[] = ['id','in',[0]];
  849. }
  850. if($page>1){
  851. $list = Db::name('device')
  852. ->field('id,title,enable')
  853. ->where('org_id',$this->orgId)
  854. ->where($map)
  855. ->order('id desc')
  856. ->page($page,$size)
  857. ->select();
  858. foreach ($list as $k=>$v){
  859. $user = Db::name('device_user')
  860. ->alias('du')
  861. ->join('user u','u.id=du.user_id')
  862. ->where('du.device_id',$v['id'])
  863. ->where('u.del',0)
  864. ->where('u.enable',1)
  865. ->column('u.real_name');
  866. $list[$k]['work_user']=$user?implode(',',$user):'';
  867. }
  868. HelpHander::success($list);
  869. }else{
  870. $list = Db::name('device')
  871. ->field('id,title,enable')
  872. ->where('org_id',$this->orgId)
  873. ->where($map)
  874. ->order('id desc')
  875. ->page($page,$size)
  876. ->select();
  877. foreach ($list as $k=>$v){
  878. $user = Db::name('device_user')
  879. ->alias('du')
  880. ->join('user u','u.id=du.user_id')
  881. ->where('du.device_id',$v['id'])
  882. ->where('u.del',0)
  883. ->where('u.enable',1)
  884. ->column('u.real_name');
  885. $list[$k]['work_user']=$user?implode(',',$user):'';
  886. }
  887. }
  888. $this->assign('list',$list);
  889. $this->assign('day',$day);
  890. $this->assign('orgId',$this->orgId);
  891. return $this->fetch();
  892. }
  893. public function deviceRecordList() {
  894. $page = input('page',1);
  895. $size = input('size',20);
  896. $day = input('day',0);//日,月,总计
  897. if($day == 0){ //日订单
  898. $where[] = ['create_yyyymmdd','=',date('Ymd')];
  899. }else if($day == 1){ //月订单
  900. $where[] = ['create_yyyymm','=',date('Ym')];
  901. }
  902. $where[] = ['org_id','=',$this->orgId];
  903. if($page>1){
  904. $list = Db::name('device_record')
  905. ->field('id,user_id,create_time,org_id')
  906. ->where($where)
  907. ->order('id desc')
  908. ->page($page,$size)
  909. ->select();
  910. foreach ($list as $k=>$v){
  911. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  912. }
  913. HelpHander::success($list);
  914. }else{
  915. $list = Db::name('device_record')
  916. ->field('id,user_id,create_time,org_id')
  917. ->where($where)
  918. ->order('id desc')
  919. ->page($page,$size)
  920. ->select();
  921. foreach ($list as $k=>$v){
  922. $list[$k]['user_name'] = Db::name('user')->where('id',$v['user_id'])->value('real_name');
  923. }
  924. }
  925. $this->assign('list',$list);
  926. $this->assign('day',$day);
  927. $this->assign('orgId',$this->orgId);
  928. return $this->fetch();
  929. }
  930. public function deviceRecordDetails(){
  931. $id = input('id',0);
  932. $info = Db::name('device_record')->where('id',$id)->find();
  933. $info['img'] = $info['images']?explode(',',$info['images']):[];
  934. //任务内容
  935. $daily = Db::name('device')->where('id',$info['device_id'])->find();
  936. $info['device_content'] = $daily['content'] ? $daily['content']:'';
  937. $info['device_title'] = $daily['title'] ? $daily['title']:'';
  938. $info['user_name'] = Db::name('user')->where('id',$info['user_id'])->value('real_name');
  939. $info['forms'] = json_decode($info['check_json'],true);
  940. $this->assign('info',$info);
  941. return $this->fetch();
  942. }
  943. public function complain(){
  944. $type = input('type',0);
  945. $week = Time::week();
  946. $sw = date('Ymd',$week[0]);
  947. $ew = date('Ymd',$week[1]);
  948. if($type == 0){
  949. $map[] = ['create_yyyymmdd','>=',$sw];
  950. $map[] = ['create_yyyymmdd','<=',$ew];
  951. }elseif ($type == 1){
  952. $map[] = ['create_yyyymm','=',date('Ym')];
  953. }
  954. $map[] = ['org_id','=',$this->orgId];
  955. $map[] = ['del','=',0];
  956. $data = [
  957. ['name'=>'已处理','status'=>2],
  958. ['name'=>'处理中','status'=>1],
  959. ['name'=>'待处理','status'=>0],
  960. ];
  961. foreach ($data as $k=>$v){
  962. $count = 0;
  963. if($v['status'] == 2){
  964. $complain = Db::name('complain')->where($map)->select();
  965. foreach ($complain as $kk=>$vv){
  966. if($vv['status'] == 1 && $vv['order_id'] > 0){
  967. $order = Db::name('orders')->where('id',$vv['order_id'])->find();
  968. if(in_array($order['order_mode'],[3,5,6])){
  969. $count +=1;
  970. }
  971. }elseif ($vv['status'] == 1 && $vv['order_id'] == 0){
  972. $count +=1;
  973. }
  974. }
  975. }elseif ($v['status'] == 1){
  976. $complain = Db::name('complain')->where($map)->select();
  977. foreach ($complain as $kk=>$vv){
  978. if($vv['status'] == 1 && $vv['order_id'] > 0){
  979. $order = Db::name('orders')->where('id',$vv['order_id'])->find();
  980. if(!in_array($order['order_mode'],[3,5,6])){
  981. $count +=1;
  982. }
  983. }
  984. }
  985. }elseif ($v['status'] == 0){
  986. $count = Db::name('complain')->where($map)->where('status',0)->count();
  987. }
  988. $data[$k]['cost'] = $count;
  989. }
  990. $count = Db::name('complain')->where($map)->count();
  991. $this->assign('list',$data);
  992. $this->assign('count',$count);
  993. $this->assign('orgId',$this->orgId);
  994. $this->assign('type',$type);
  995. return $this->fetch();
  996. }
  997. public function complainList(){
  998. $type = input('type/d',0);
  999. $status= input('status',-1);
  1000. $week = Time::week();
  1001. $sw = date('Ymd',$week[0]);
  1002. $ew = date('Ymd',$week[1]);
  1003. if($type == 0){
  1004. $map[] = ['create_yyyymmdd','>=',$sw];
  1005. $map[] = ['create_yyyymmdd','<=',$ew];
  1006. }elseif ($type == 1){
  1007. $map[] = ['create_yyyymm','=',date('Ym')];
  1008. }
  1009. $map[] = ['org_id','=',$this->orgId];
  1010. $map[] = ['del','=',0];
  1011. $list = [];
  1012. if($status == 0){
  1013. $list = Db::name('complain')->where($map)->where('status',0)->order('id desc')->select();
  1014. foreach ($list as $k=>$v){
  1015. $list[$k]['statusTxt'] = '待处理';
  1016. }
  1017. }elseif ($status == -1){
  1018. $list = Db::name('complain')->where($map)->order('id desc')->select();
  1019. foreach ($list as $k=>$v){
  1020. $statusTxt = '';
  1021. if($v['status'] == 1 && $v['order_id'] == 0){
  1022. $statusTxt = '已处理';
  1023. }elseif($v['status'] == 1 && $v['order_id'] > 0){
  1024. $order = Db::name('orders')->where('id',$v['order_id'])->find();
  1025. if(in_array($order['order_mode'],[3,5,6])){
  1026. $statusTxt = '已处理';
  1027. }else{
  1028. $statusTxt = '处理中';
  1029. }
  1030. }elseif($v['status'] == 0){
  1031. $statusTxt = '待处理';
  1032. }
  1033. $list[$k]['statusTxt'] = $statusTxt;
  1034. }
  1035. } else{
  1036. $complain = Db::name('complain')->where($map)->select();
  1037. foreach ($complain as $k=>$v){
  1038. $statusTxt = '';
  1039. if($v['status'] == 1 && $v['order_id'] == 0){
  1040. $statusTxt = '已处理';
  1041. }else if($v['status'] == 1 && $v['order_id'] > 0){
  1042. $order = Db::name('orders')->where('id',$v['order_id'])->find();
  1043. if(in_array($order['order_mode'],[3,5,6])){
  1044. $statusTxt = '已处理';
  1045. }else{
  1046. $statusTxt = '处理中';
  1047. }
  1048. }elseif($v['status'] == 0){
  1049. $statusTxt = '待处理';
  1050. }
  1051. $complain[$k]['statusTxt'] = $statusTxt;
  1052. }
  1053. foreach ($complain as $k=>$v){
  1054. if($status == 2){
  1055. if($v['status'] == 1 && $v['order_id'] > 0){
  1056. $order = Db::name('orders')->where('id',$v['order_id'])->find();
  1057. if(in_array($order['order_mode'],[3,5,6])){
  1058. $list[$k] = $v;
  1059. }
  1060. }elseif($v['status'] == 1 && $v['order_id'] == 0){
  1061. $list[$k] = $v;
  1062. }
  1063. }elseif ($status == 1){
  1064. if($v['status'] == 1 && $v['order_id'] > 0){
  1065. $order = Db::name('orders')->where('id',$v['order_id'])->find();
  1066. if(!in_array($order['order_mode'],[3,5,6])){
  1067. $list[$k] = $v;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. }
  1073. foreach ($list as $k=>$v){
  1074. if($v['hide'] == 1){
  1075. $list[$k]['user_name'] = '匿名';
  1076. }else{
  1077. $list[$k]['user_name'] = Db::name('user')->where('id',$v['create_user_id'])->value('real_name');
  1078. }
  1079. }
  1080. $this->assign('list',$list);
  1081. $this->assign('orgId',$this->orgId);
  1082. $this->assign('type',$type);
  1083. return $this->fetch();
  1084. }
  1085. public function complainDetail(){
  1086. $id = input('id',0);
  1087. $info = Db::name('complain')->where('id',$id)->find();
  1088. $info['images'] = !empty($info['images'])?explode(',',$info['images']):[];
  1089. $info['create_time'] = date('Y-m-d H:i',strtotime($info['create_time']));
  1090. $statusTxt = '';
  1091. if($info['status'] == 1 && $info['order_id'] == 0){
  1092. $statusTxt = '已处理';
  1093. }elseif($info['status'] == 1 && $info['order_id'] > 0){
  1094. $order = Db::name('orders')->where('id',$info['order_id'])->find();
  1095. if(in_array($order['order_mode'],[3,5,6])){
  1096. $statusTxt = '已处理';
  1097. }else{
  1098. $statusTxt = '处理中';
  1099. }
  1100. }elseif($info['status'] == 0){
  1101. $statusTxt = '待处理';
  1102. }
  1103. $info['statusTxt'] = $statusTxt;
  1104. if($info['hide'] == 1){
  1105. $info['user_name'] = '匿名';
  1106. $info['mobile'] = '';
  1107. }else{
  1108. $info['user_name'] = Db::name('user')->where('id',$info['create_user_id'])->value('real_name');
  1109. $info['mobile'] = Db::name('user')->where('id',$info['create_user_id'])->value('mobile');
  1110. }
  1111. $info['dep_name'] = db('dep')->where('id',$info['dep_id'])->value('title');
  1112. $this->assign('info',$info);
  1113. return $this->fetch();
  1114. }
  1115. }