Project.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <?php
  2. namespace app\h5\controller;
  3. use app\hander\HelpHander;
  4. use think\Controller;
  5. use think\Db;
  6. class Project extends Controller{
  7. public function workerCount(){
  8. $post = request()->post();
  9. $count = Db::name('worker')
  10. ->alias('w')
  11. ->join('user u','u.id=w.user_id')
  12. ->join('user_org uo','uo.user_id=u.id')
  13. ->where('u.del',0)
  14. ->where('u.enable',1)
  15. ->where('uo.org_id',$post['orgid'])
  16. ->count();
  17. $serverNums = Db::name('ph_todo')
  18. ->where('org_id',$post['orgid'])
  19. ->where('status',1)
  20. ->group('worker_id')
  21. ->count();
  22. $leisureNums = $count-$serverNums>0?$count-$serverNums:0;
  23. $data = [
  24. ['name'=>'服务中','bl'=>round($serverNums/$count*100,2),'value'=>$serverNums],
  25. ['name'=>'空闲中','bl'=>round($leisureNums/$count*100,2),'value'=>$leisureNums],
  26. ];
  27. HelpHander::success($data);
  28. }
  29. public function workerNums(){
  30. $post = request()->post();
  31. $count = Db::name('worker')
  32. ->alias('w')
  33. ->join('user u','u.id=w.user_id')
  34. ->join('user_org uo','uo.user_id=u.id')
  35. ->where('u.del',0)
  36. ->where('u.enable',1)
  37. ->where('uo.org_id',$post['orgid'])
  38. ->count();
  39. $serverNums = Db::name('ph_todo')
  40. ->where('org_id',$post['orgid'])
  41. ->where('status',1)
  42. ->group('worker_id')
  43. ->count();
  44. $leisureNums = $count-$serverNums>0?$count-$serverNums:0;
  45. $data = [
  46. 'count'=>$count,
  47. 'kxz'=>$leisureNums,
  48. 'fwz'=>$serverNums,
  49. ];
  50. HelpHander::success($data);
  51. }
  52. //今日订单数
  53. public function orderNums(){
  54. $post = request()->post();
  55. $day = date('Y-m-d');
  56. $start = $day.' 00:00:00';
  57. $end = $day.' 23:59:59';
  58. $orderCount = Db::name('ph_orders')->where('org_id',$post['orgid'])->count();
  59. $map[] =['create_time','>=',$start];
  60. $map[] =['create_time','<=',$end];
  61. $map[] =['org_id','=',$post['orgid']];
  62. $map1[] =['settlement_time','>=',$start];
  63. $map1[] =['settlement_time','<=',$end];
  64. $map1[] =['org_id','=',$post['orgid']];
  65. $count = Db::name('ph_orders')->where($map)->count();
  66. $serverCount = Db::name('ph_orders')->where('org_id',$post['orgid'])->where('status',1)->count();
  67. $jsCount = Db::name('ph_orders')->where($map1)->where('status',4)->count();
  68. $data = [
  69. 'count'=>$count,
  70. 'serverCount'=>$serverCount,
  71. 'jsCount'=>$jsCount,
  72. 'orderCount'=>$orderCount
  73. ];
  74. HelpHander::success($data);
  75. }
  76. public function worderList(){
  77. $post = request()->post();
  78. $worker = Db::name('worker')
  79. ->alias('w')
  80. ->field('w.id,u.real_name')
  81. ->join('user u','u.id=w.user_id')
  82. ->join('user_org uo','uo.user_id=u.id')
  83. ->where('u.del',0)
  84. ->where('u.enable',1)
  85. ->where('uo.org_id',$post['orgid'])
  86. ->select();
  87. foreach ($worker as $k=>$v){
  88. $worker[$k]['servicesNum'] =Db::name('ph_todo')
  89. ->where('worker_id',$v['id'])
  90. ->where('org_id',$post['orgid'])
  91. ->group('user_id')
  92. ->count();
  93. $worker[$k]['servicesDay'] = Db::name('ph_todo')
  94. ->where('worker_id',$v['id'])
  95. ->where('org_id',$post['orgid'])
  96. ->where('status',2)
  97. ->sum('day');
  98. }
  99. HelpHander::success($worker);
  100. }
  101. public function commentList(){
  102. $post = request()->post();
  103. $firstDay = date('Y-m-01 00:00:00', time());
  104. $lastDay = date('Y-m-d 23:59:59', strtotime("$firstDay +1 month -1 day"));
  105. $map[] = ['create_time','>',$firstDay];
  106. $map[] = ['create_time','<=',$lastDay];
  107. $map[] = ['org_id','=',$post['orgid']];
  108. $work = Db::name('worker')
  109. ->alias('w')
  110. ->field('w.id,u.real_name')
  111. ->join('user u','u.id=w.user_id')
  112. ->join('user_org uo','uo.user_id=u.id')
  113. ->where('u.del',0)
  114. ->where('u.enable',1)
  115. ->where('uo.org_id',$post['orgid'])
  116. ->select();
  117. $work = $work?$work:[];
  118. foreach ($work as $k=>$v){
  119. $jxz = Db::name('ph_todo')
  120. ->where($map)
  121. ->where('status',1)
  122. ->where('worker_id',$v['id'])
  123. ->count();
  124. $ywc = Db::name('ph_todo')
  125. ->where($map)
  126. ->where('status',2)
  127. ->where('worker_id',$v['id'])
  128. ->count();
  129. $work[$k]['jxz'] = $jxz;
  130. $work[$k]['ywc'] = $ywc;
  131. }
  132. $work = list_sort_by($work,'ywc','desc');
  133. HelpHander::success($work);
  134. }
  135. public function sevenDayOrder(){
  136. $post = request()->post();
  137. $dlist = [
  138. date('Y-m-d',strtotime('-6 days')),
  139. date('Y-m-d',strtotime('-5 days')),
  140. date('Y-m-d',strtotime('-4 days')),
  141. date('Y-m-d',strtotime('-3 days')),
  142. date('Y-m-d',strtotime('-2 days')),
  143. date('Y-m-d',strtotime('-1 days')),
  144. date('Y-m-d'),
  145. ];
  146. $xdata = [];
  147. $count2= [];
  148. $count3 = [];
  149. foreach ($dlist as $v){
  150. $tt = date('Y-m-d',strtotime($v));
  151. $st = $tt.' 00:00:00';
  152. $et = $tt.' 23:59:59';
  153. $countTwo = Db::name('ph_orders')
  154. ->where('create_time','>=',$st)
  155. ->where('create_time','<=',$et)
  156. ->where('status',1)
  157. ->where('org_id',$post['orgid'])
  158. ->count();
  159. $countThere = Db::name('ph_orders')
  160. ->where('create_time','>=',$st)
  161. ->where('create_time','<=',$et)
  162. ->where('org_id',$post['orgid'])
  163. ->count();
  164. $count2[] = $countTwo;
  165. $count3[] = $countThere;
  166. $xdata[] = date('m-d',strtotime($v));
  167. }
  168. $data = [
  169. 'xdata' => $xdata,
  170. 'count2' => $count2,
  171. 'count3' => $count3,
  172. ];
  173. HelpHander::success($data);
  174. }
  175. public function orderMessageList(){
  176. $post = request()->post();
  177. $ret = Db::name('ph_orders')
  178. ->where('org_id',$post['orgid'])
  179. ->order('id','desc')
  180. ->select();
  181. $ret = $ret?$ret:[];
  182. foreach ($ret as $k=>$v){
  183. $userInfo = Db::name('user')
  184. ->where('id',$v['user_id'])
  185. ->value('real_name');
  186. $cateInfo = Db::name('cate')
  187. ->where('id',$v['cate_id'])
  188. ->value('title');
  189. $ret[$k]['content'] = '用户'.$userInfo.$cateInfo;
  190. }
  191. HelpHander::success($ret);
  192. }
  193. }