<?php
namespace app\api\controller;
use app\service\OrderService;
use app\service\PayRequestLogService;
* 订单支付异步通知
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2018-05-21T10:48:48+0800
*/
class OrderNotify extends Common
{
* 构造方法
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function __construct()
{
parent::__construct();
}
* 支付异步处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-09-12
* @desc description
*/
public function Notify()
{
$log_ret = PayRequestLogService::PayRequestLogInsert(OrderService::BusinessTypeName());
$ret = OrderService::Notify($this->data_request);
$res = ($ret['code'] == 0) ? $this->SuccessReturn() : $this->ErrorReturn();
PayRequestLogService::PayRequestLogEnd($log_ret['data'], $ret, $res);
die($res);
}
* 成功返回
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-09-12
* @desc description
*/
private function SuccessReturn()
{
$res = $this->ContentReturn('SuccessReturn');
return empty($res) ? 'success' : $res;
}
* 失败返回
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-09-12
* @desc description
*/
private function ErrorReturn()
{
$res = $this->ContentReturn('ErrorReturn');
return empty($res) ? 'error' : $res;
}
* 输出支付插件自定义内容
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-07-01
* @desc description
* @param [string] $action [操作方法]
*/
private function ContentReturn($action)
{
$payment = 'payment\\'.PAYMENT_TYPE;
if(class_exists($payment))
{
$payment_obj = new $payment();
if(method_exists($payment_obj, $action))
{
return $payment_obj->$action($this->data_request);
}
}
return '';
}
}
?>