链街Dcat后台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.6 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <?php
  2. namespace App\Admin\Repositories;
  3. use App\Models\ImsCjdcOrderMain as Model;
  4. use Dcat\Admin\Grid;
  5. use Dcat\Admin\Repositories\EloquentRepository;
  6. class ImsCjdcOrderMain extends EloquentRepository
  7. {
  8. /**
  9. * Model.
  10. *
  11. * @var string
  12. */
  13. protected $eloquentClass = Model::class;
  14. public function get(Grid\Model $model)
  15. {
  16. $builder = new \App\Models\ImsCjdcOrderMain();
  17. $builder = $builder::leftJoin('lanzu_user','lanzu_user.id','lanzu_order_main.user_id')
  18. ->with('market')
  19. ->select('lanzu_order_main.*','lanzu_user.nick_name')
  20. ->where('type',1)
  21. ->orderBy('lanzu_order_main.id','desc');//只取线上订单数据
  22. $this->setSort($model);
  23. $this->setPaginate($model);
  24. $query = $builder;
  25. $model->getQueries()->unique()->each(function ($value) use (&$query) {
  26. if ($value['method'] == 'paginate') {
  27. $value['arguments'][1] = $this->getGridColumns();
  28. } elseif ($value['method'] == 'get') {
  29. $value['arguments'] = [$this->getGridColumns()];
  30. }
  31. $query = call_user_func_array([$query, $value['method']], $value['arguments'] ?? []);
  32. });
  33. $query = $query->toArray();
  34. //如果订单状态为配送中 将state设置为31
  35. foreach ($query['data'] as &$value){
  36. if ($value['state']==3&&$value['shipping_type']==1&&!empty($value['horseman_id'])){
  37. $value['state'] = 311;
  38. }
  39. }
  40. $query = $model->makePaginator($query['total'],$query['data']);
  41. return $query;
  42. }
  43. }