PaymentOrder.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App\Http\Controllers\admin;
  3. use App\Constants\HttpStatus;
  4. use App\Http\Controllers\Controller;
  5. use App\Services\PaymentOrderService;
  6. use Exception;
  7. use Illuminate\Validation\ValidationException;
  8. class PaymentOrder extends Controller
  9. {
  10. /**
  11. * @apiParam {int} [page]
  12. * @apiParam {int} [limit]
  13. * @apiParam {int=0,1,2} type 类型 0全部 1=代收,2=代付
  14. * @apiParam {String} order_no 订单号
  15. * @apiPaaram {String} member_id 会员ID
  16. * @apiParam {int=0,1,2,3} [status] 状态:0待处理 1处理中 2成功 3失败
  17. *
  18. */
  19. public function index()
  20. {
  21. try {
  22. $params = request()->validate([
  23. 'page' => ['nullable', 'integer', 'min:1'],
  24. 'limit' => ['nullable', 'integer', 'min:1'],
  25. 'type' => ['required', 'integer', 'in:0,1,2'],
  26. 'order_no' => ['nullable', 'string'],
  27. 'status' => ['nullable', 'integer', 'in:0,1,2,3'],
  28. ]);
  29. $result = PaymentOrderService::paginate($params);
  30. } catch (ValidationException $e) {
  31. return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
  32. } catch (Exception $e) {
  33. return $this->error(intval($e->getCode()));
  34. }
  35. return $this->success($result);
  36. }
  37. /**
  38. * @description: 查询订单的支付情况
  39. * @return {*}
  40. */
  41. public function check()
  42. {
  43. $id = request()->input('id');
  44. if(empty($id)){
  45. return $this->error(HttpStatus::CUSTOM_ERROR,'参数错误');
  46. }
  47. try {
  48. $result = PaymentOrderService::singlePayOrder($id);
  49. $this->success([],$result['message'] ?? '操作成功');
  50. } catch (Exception $e) {
  51. return $this->error(intval($e->getCode()));
  52. }
  53. return $this->success([],$result['message'] ?? '操作成功');
  54. }
  55. }