Order.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace app\store\model\dealer;
  3. use app\common\model\dealer\Order as OrderModel;
  4. use app\common\service\Order as OrderService;
  5. /**
  6. * 分销商订单模型
  7. * Class Apply
  8. * @package app\store\model\dealer
  9. */
  10. class Order extends OrderModel
  11. {
  12. /**
  13. * 获取分销商订单列表
  14. * @param null $user_id
  15. * @param int $is_settled
  16. * @return \think\Paginator
  17. * @throws \think\exception\DbException
  18. */
  19. public function getList($user_id = null, $is_settled = -1)
  20. {
  21. // 检索查询条件
  22. $user_id > 1 && $this->where('first_user_id|second_user_id|third_user_id', '=', $user_id);
  23. $is_settled > -1 && $this->where('is_settled', '=', !!$is_settled);
  24. !empty($search) && $this->where('user.nickName', 'like', "%{$search}%");
  25. // 获取分销商订单列表
  26. $data = $this->with([
  27. 'dealer_first.user',
  28. 'dealer_second.user',
  29. 'dealer_third.user'
  30. ])
  31. ->order(['create_time' => 'desc'])
  32. ->paginate(10, false, [
  33. 'query' => \request()->request()
  34. ]);
  35. if ($data->isEmpty()) {
  36. return $data;
  37. }
  38. // 获取订单的主信息
  39. $with = ['goods' => ['image', 'refund'], 'address', 'user'];
  40. return OrderService::getOrderList($data, 'order_master', $with);
  41. }
  42. }