Order.php 1.4 KB

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