PayController.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/6/16
  6. * Time: 上午11:10
  7. */
  8. namespace app\frontend\modules\remittance\controllers;
  9. use app\common\components\BaseController;
  10. use app\common\exceptions\AppException;
  11. use app\common\models\Process;
  12. use app\common\modules\payType\remittance\models\flows\RemittanceFlow;
  13. use app\frontend\models\OrderPay;
  14. use app\frontend\modules\payType\remittance\process\RemittanceProcess;
  15. use app\frontend\modules\process\controllers\Operate;
  16. class PayController extends BaseController
  17. {
  18. use Operate;
  19. public $transactionActions = ['*'];
  20. /**
  21. * @var RemittanceProcess
  22. */
  23. protected $process;
  24. protected $name = '确认支付';
  25. /**
  26. * @return Process
  27. * @throws AppException
  28. */
  29. protected function _getProcess()
  30. {
  31. $orderPayId = request()->input('order_pay_id');
  32. /**
  33. * @var OrderPay $orderPay
  34. */
  35. $orderPay = OrderPay::find($orderPayId);
  36. if (!isset($orderPay)) {
  37. throw new AppException("未找到该支付记录(id:{$orderPayId})");
  38. }
  39. $process = $orderPay->currentProcess();
  40. if (!isset($process)) {
  41. throw new AppException("未找到该流程(order_pay_id:{$orderPayId})");
  42. }
  43. return $process;
  44. }
  45. /**
  46. * @return string
  47. */
  48. protected function beforeStates()
  49. {
  50. return RemittanceFlow::STATE_WAIT_REMITTANCE;
  51. }
  52. /**
  53. * @return \Illuminate\Http\JsonResponse
  54. * @throws \Exception
  55. */
  56. public function index()
  57. {
  58. $this->validate([
  59. 'report_url' => 'required',
  60. 'amount' => 'numeric',
  61. ]);
  62. $this->toNextState();
  63. return $this->successJson();
  64. }
  65. }