ShopDelivery.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\admin\controller\shop;
  4. use app\common\controller\Backend;
  5. use think\annotation\route\Group;
  6. use app\admin\traits\Actions;
  7. use think\annotation\route\Route;
  8. use app\common\model\ShopDelivery as ShopDeliveryModel;
  9. #[Group("shop/shop_delivery")]
  10. class ShopDelivery extends Backend
  11. {
  12. use Actions;
  13. protected function _initialize()
  14. {
  15. parent::_initialize();
  16. $this->model = new ShopDeliveryModel();
  17. $this->assign('platformList', site_config('addonsd.platform_list'));
  18. $this->relationField=['customer','user','shops', 'variety', 'specs'];
  19. }
  20. /**
  21. * 查看
  22. */
  23. #[Route('GET,JSON','index')]
  24. public function index()
  25. {
  26. if (false === $this->request->isAjax()) {
  27. return $this->fetch();
  28. }
  29. if($this->request->post('selectpage')){
  30. return $this->selectpage();
  31. }
  32. [$where, $order, $limit, $with] = $this->buildparams();
  33. $list = $this->model
  34. ->withJoin($with,'left')
  35. //如果没有使用operate filter过滤的情况下,推荐使用with关联,可以提高查询效率
  36. //->with($with)
  37. ->where($where)
  38. ->order($order)
  39. ->paginate($limit);
  40. //表格底部要有汇总:发货数量汇总 重量汇总 总价汇总
  41. $total_num = $this->model->sum('num');
  42. $this->assign('total_weigh', $this->model->sum('weigh'));
  43. $this->assign('total_price', $this->model->sum('total_price'));
  44. $result = ['total' => $list->total(), 'rows' => $list->items(), 'total_num' => $total_num];
  45. return json($result);
  46. }
  47. }