Order.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace addons\shopro\controller\commission;
  3. use think\Request;
  4. use app\admin\model\shopro\commission\Order as OrderModel;
  5. class Order extends Commission
  6. {
  7. protected $noNeedLogin = [];
  8. protected $noNeedRight = ['*'];
  9. // 分销动态
  10. public function index()
  11. {
  12. $agentId = $this->service->user->id;
  13. $type = $this->request->param('type', "all");
  14. if (!in_array($type, ['all', 'back', 'cancel', 'yes'])) {
  15. $this->error("");
  16. }
  17. $query = OrderModel
  18. ::where('agent_id', $agentId)
  19. ->with([
  20. 'buyer' => function ($query) {
  21. return $query->field(['avatar', 'nickname']);
  22. },
  23. 'order',
  24. 'rewards' => function ($query) use ($agentId) {
  25. return $query->where('agent_id', $agentId);
  26. },
  27. 'order_item'
  28. ])
  29. ->order('id desc');
  30. if ($type !== 'all') {
  31. $query->$type();
  32. }
  33. $data = $query->paginate($this->request->param('list_rows', 10));
  34. $this->success("", $data);
  35. }
  36. }