ListController.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 2017/4/12
  6. * Time: 下午7:40
  7. */
  8. namespace app\frontend\modules\refund\controllers;
  9. use app\common\components\ApiController;
  10. use app\common\events\order\OrderRefundFrontedListEvent;
  11. use app\frontend\modules\refund\models\RefundApply;
  12. class ListController extends ApiController
  13. {
  14. // public function index(\Illuminate\Http\Request $request)
  15. // {
  16. // $this->validate([
  17. // 'pagesize' => 'sometimes|filled|integer',
  18. // 'page' => 'sometimes|filled|integer',
  19. // ]);
  20. // $query = RefundApply::defaults();
  21. // event($event = new OrderRefundFrontedListEvent($query));
  22. // $refunds = $event->getQuery()->paginate($request->query('pagesize', '20'));
  23. // return $this->successJson('成功', $refunds);
  24. // }
  25. public function index()
  26. {
  27. $refundModel = $this->refundModel();
  28. return $this->successJson('成功', $this->getData($refundModel));
  29. }
  30. public function wait()
  31. {
  32. $refundModel = $this->refundModel()
  33. ->where('status', '>', RefundApply::REJECT)
  34. ->where('status', '<', RefundApply::COMPLETE);
  35. return $this->successJson('成功', $this->getData($refundModel));
  36. }
  37. public function complete()
  38. {
  39. $refundModel = $this->refundModel()
  40. ->where('status', '>=', RefundApply::COMPLETE);
  41. return $this->successJson('成功', $this->getData($refundModel));
  42. }
  43. public function cancel()
  44. {
  45. $refundModel = $this->refundModel()
  46. ->where('status', '<', RefundApply::WAIT_CHECK);
  47. return $this->successJson('成功', $this->getData($refundModel));
  48. }
  49. /**
  50. * @return RefundApply
  51. */
  52. protected function refundModel()
  53. {
  54. return RefundApply::uniacid();
  55. }
  56. /**
  57. * @param \app\framework\Database\Eloquent\Builder $refundModel
  58. * @return mixed
  59. */
  60. protected function getData($refundModel)
  61. {
  62. $page_size = request()->input('page_size',20);
  63. $search = [
  64. 'sn' => request()->input('sn'),
  65. 'refund_id' => intval(request()->input('refund_id')),
  66. 'order_goods_id' => intval(request()->input('order_goods_id')),
  67. ];
  68. $refundModel->frontendSearch($search);
  69. // $refundModel->whereIn('id',[4,5]);
  70. event($event = new OrderRefundFrontedListEvent($refundModel));
  71. $refundList = $event->getQuery()->paginate($page_size);
  72. return $refundList;
  73. }
  74. }