NotifyController.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace addons\Alitopay\api\controllers;
  3. use addons\Alitopay\common\models\Order;
  4. use addons\Alitopay\common\services\ApplyService;
  5. use addons\Alitopay\common\services\OrderService;
  6. use yii\helpers\Json;
  7. use yii\web\Controller;
  8. use Yii;
  9. class NotifyController extends Controller
  10. {
  11. public function __construct ($id, $module, $config = [])
  12. {
  13. parent::__construct($id, $module, $config);
  14. }
  15. public $enableCsrfValidation = false;
  16. /**
  17. * 审核异步通知
  18. * @desc
  19. * @return bool
  20. */
  21. public function actionApply(){
  22. $data = Yii::$app->request->post();
  23. $form = new ApplyService();
  24. $data['msg_type'] = 1;
  25. $result = $form->ApplyAuthNotify($data);
  26. if($result){
  27. return 'ok';
  28. }else{
  29. echo "request_data:".$form->error;
  30. return false;
  31. }
  32. }
  33. public function actionAuth(){
  34. $data = Yii::$app->request->post();
  35. $form = new ApplyService();
  36. $data['msg_type'] = 2;
  37. $result = $form->ApplyAuthNotify($data);
  38. if($result){
  39. return 'ok';
  40. }else{
  41. echo "request_data:".$form->error;
  42. return false;
  43. }
  44. }
  45. /**
  46. * 支付异步回调
  47. * @PostMapping("actionPay")
  48. * @Middlewares({
  49. * @Middleware()
  50. * })
  51. */
  52. public function actionPay(){
  53. $order_list = $this->request->post("order_list");
  54. if(empty($order_list)){
  55. return "success";
  56. }
  57. $order_list = Json::decode($order_list);
  58. $service = new OrderService();
  59. $service->orderNotifyHandle($order_list);
  60. return "success";
  61. }
  62. }