model = new ShopDeliveryModel(); $this->assign('platformList', site_config('addonsd.platform_list')); $this->relationField=['customer','user','shops', 'variety', 'specs']; } /** * 查看 */ #[Route('GET,JSON','index')] public function index() { if (false === $this->request->isAjax()) { return $this->fetch(); } if($this->request->post('selectpage')){ return $this->selectpage(); } [$where, $order, $limit, $with] = $this->buildparams(); $list = $this->model ->withJoin($with,'left') //如果没有使用operate filter过滤的情况下,推荐使用with关联,可以提高查询效率 //->with($with) ->where($where) ->order($order) ->paginate($limit); //表格底部要有汇总:发货数量汇总 重量汇总 总价汇总 $count = $this->model->field('sum(num) total_num, sum(weigh) total_weigh, sum(total_price) total_price')->select()->toArray(); $result = ['total' => $list->total(), 'rows' => $list->items(), 'total_num' => $count[0]['total_num']??0, 'total_weigh' => $count[0]['total_weigh']??0, 'total_price' => $count[0]['total_price']??0]; return json($result); } }