|
|
@@ -35,54 +35,42 @@ class CallBackController extends \Phalcon\Mvc\Controller |
|
|
|
{ |
|
|
|
if ($this->request->isPost()) { |
|
|
|
try { |
|
|
|
$verify_result = (new EasyAlipayService())->verifyNotify($_POST); |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调", |
|
|
|
"data" => $_POST, |
|
|
|
"res" => $verify_result |
|
|
|
], 320), 'common_alipay_sync_notify', true); |
|
|
|
if ($verify_result) {//验证成功 |
|
|
|
$self_order_sn = $_POST['out_trade_no']; //商家业务订单号 |
|
|
|
$trade_no = $_POST['trade_no']; //支付宝交易号 |
|
|
|
$trade_status = $_POST['trade_status']; //交易状态 |
|
|
|
$self_order_sn = $_POST['out_trade_no']; //商家业务订单号 |
|
|
|
$trade_no = $_POST['trade_no']; //支付宝交易号 |
|
|
|
$trade_status = $_POST['trade_status']; //交易状态 |
|
|
|
|
|
|
|
//判断该笔订单是否在 |
|
|
|
$model = UserMerchantOrder::findFirst("self_trade_no = '{$self_order_sn}'"); |
|
|
|
if (!$model) { |
|
|
|
//未查到訂單 |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调失败-訂單未查到", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'common_alipay_sync_notify_not_find', true); |
|
|
|
//验证失败 |
|
|
|
echo "fail"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
//商户网站中已经做过处理 |
|
|
|
if ($model->status != IPay::PAY_STATE_FOR_WAIT) { |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调已处理", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'alipay_sync_notify_already', true); |
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
|
|
|
|
$model->return_data = json_encode($_POST); |
|
|
|
$model->trade_no = $trade_no; |
|
|
|
$model->updated_at = date("Y-m-d H:i:s"); |
|
|
|
|
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} else { |
|
|
|
//判断该笔订单是否在 |
|
|
|
$model = UserMerchantOrder::findFirst("self_trade_no = '{$self_order_sn}'"); |
|
|
|
if (!$model) { |
|
|
|
//未查到訂單 |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调驗證失败", |
|
|
|
"msg" => "异步回调失败-訂單未查到", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'alipay_sync_notify_verify_fail', true); |
|
|
|
], 320), 'common_alipay_sync_notify_not_find', true); |
|
|
|
//验证失败 |
|
|
|
echo "fail"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
//商户网站中已经做过处理 |
|
|
|
if ($model->status != IPay::PAY_STATE_FOR_WAIT) { |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调已处理", |
|
|
|
"data" => $_POST, |
|
|
|
], 320), 'alipay_sync_notify_already', true); |
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} |
|
|
|
|
|
|
|
$model->return_data = json_encode($_POST); |
|
|
|
$model->trade_no = $trade_no; |
|
|
|
$model->updated_at = date("Y-m-d H:i:s"); |
|
|
|
|
|
|
|
echo "success"; |
|
|
|
die(); |
|
|
|
} catch (\Exception $e) { |
|
|
|
logger(json_encode([ |
|
|
|
"msg" => "异步回调處理异常", |
|
|
|