OrderController.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Http\Controllers\Admin;
  12. use App\Http\Validator\OrderValidator;
  13. use App\Services\Common\OrderService;
  14. /**
  15. * 订单管理-控制器
  16. * @author laravel开发员
  17. * @since 2020/11/11
  18. * Class OrderController
  19. * @package App\Http\Controllers
  20. */
  21. class OrderController extends Backend
  22. {
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. * OrderController constructor.
  28. */
  29. public function __construct()
  30. {
  31. parent::__construct();
  32. $this->service = new OrderService();
  33. }
  34. public function index()
  35. {
  36. $params = request()->all();
  37. $pageSize = isset($params['pageSize'])? $params['pageSize'] : 10;
  38. $list = OrderService::make()->getDataList($params, $pageSize);
  39. $message = array(
  40. "msg" => '操作成功',
  41. "code" => 0,
  42. "data" => isset($list['list'])? $list['list']:[],
  43. "count" => isset($list['total'])? $list['total']:0,
  44. );
  45. return $message;
  46. }
  47. /**
  48. * 审核订单
  49. * @return array
  50. */
  51. public function confirm(OrderValidator $validator)
  52. {
  53. $params = request()->post();
  54. $params = $validator->check($params, 'confirm');
  55. if (!is_array($params)) {
  56. return message($params, false);
  57. }
  58. if(OrderService::make()->confirm($this->userId, $params)){
  59. return message(OrderService::make()->getError(), true);
  60. }else{
  61. return message(OrderService::make()->getError(), false);
  62. }
  63. }
  64. /**
  65. * 取消订单
  66. * @return array
  67. */
  68. public function cancel(OrderValidator $validator)
  69. {
  70. $params = request()->post();
  71. $params = $validator->check($params, 'cancel');
  72. if (!is_array($params)) {
  73. return message($params, false);
  74. }
  75. if(OrderService::make()->cancel($this->userId, $params)){
  76. return message(OrderService::make()->getError(), true);
  77. }else{
  78. return message(OrderService::make()->getError(), false);
  79. }
  80. }
  81. /**
  82. * 完成订单
  83. * @return array
  84. */
  85. public function complete(OrderValidator $validator)
  86. {
  87. $params = request()->post();
  88. $params = $validator->check($params, 'complete');
  89. if (!is_array($params)) {
  90. return message($params, false);
  91. }
  92. if(OrderService::make()->complete($this->userId, $params)){
  93. return message(OrderService::make()->getError(), true);
  94. }else{
  95. return message(OrderService::make()->getError(), false);
  96. }
  97. }
  98. }