| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- declare (strict_types = 1);
- namespace app\admin\controller\shop;
- use app\common\controller\Backend;
- use think\annotation\route\Group;
- use app\admin\traits\Actions;
- use think\annotation\route\Route;
- use app\common\model\ShopDelivery as ShopDeliveryModel;
- #[Group("shop/shop_delivery")]
- class ShopDelivery extends Backend
- {
- use Actions;
- protected function _initialize()
- {
- parent::_initialize();
- $this->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);
- //表格底部要有汇总:发货数量汇总 重量汇总 总价汇总
- $total_num = $this->model->sum('num');
- $this->assign('total_weigh', $this->model->sum('weigh'));
- $this->assign('total_price', $this->model->sum('total_price'));
- $result = ['total' => $list->total(), 'rows' => $list->items(), 'total_num' => $total_num];
- return json($result);
- }
- }
|