StatisticsLogic.php 1.6 KB

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