StatisticsLogic.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\logic;
  3. use app\common\model\AppointmentModel;
  4. use app\common\model\MealcenterModel;
  5. use app\common\model\MealOrdersModel;
  6. use app\common\model\serverappointmentmodel;
  7. use app\common\model\VisitModel;
  8. class StatisticsLogic
  9. {
  10. public function getmealcenterlist()
  11. {
  12. $page = isset($arr['page']) && is_numeric($arr['page']) && !empty($arr['page']) && $arr['page'] > 0 ? $arr['page'] : 1;
  13. $size = isset($arr['size']) && is_numeric($arr['size']) && !empty($arr['size']) && $arr['size'] > 0 ? $arr['size'] : 10;
  14. $m_mc = new MealcenterModel();
  15. $m_mo = new MealOrdersModel();
  16. $m_v = new VisitModel();
  17. $m_sa = new serverappointmentmodel();
  18. $m_a = new AppointmentModel();
  19. $where = [];
  20. $count = $m_mc->getList($where, 'count');
  21. if ($count <= 0) {
  22. return backarr(0, "无数据");
  23. }
  24. $list = $m_mc->getList($where, '*', $page, $size);
  25. foreach ($list as $key => $value) {
  26. $mocount = $m_mo->getList(['center_id' => $value['id']], 'count');
  27. $vcount = $m_v->getList(['center_id' => $value['id']], 'count');
  28. $sacount = $m_sa->getList(['center_id' => $value['id']], 'count');
  29. $acount = $m_a->getList(['center_id' => $value['id']], 'count');
  30. $value['mocount'] = empty($mocount) ? 0 : $mocount;
  31. $value['vcount'] = empty($vcount) ? 0 : $vcount;
  32. $value['sacount'] = empty($sacount) ? 0 : $sacount;
  33. $value['acount'] = empty($acount) ? 0 : $acount;
  34. $list[$key] = $value;
  35. }
  36. $restunData = [
  37. 'count' => $count,
  38. 'page' => $page,
  39. 'size' => $size,
  40. 'list' => $list,
  41. ];
  42. return backarr(1, "查询成功", $restunData);
  43. }
  44. }