nizongfeng 2 years ago
parent
commit
71ce3b5e2c
1 changed files with 6 additions and 1 deletions
  1. +6
    -1
      addons/unishop/controller/Pay.php

+ 6
- 1
addons/unishop/controller/Pay.php View File

@@ -125,9 +125,11 @@ class Pay extends Base
Hook::add('paid_fail', 'addons\\unishop\\behavior\\Order');

$paytype = $this->request->param('type');
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/".date("d"). '.log', $paytype . PHP_EOL, FILE_APPEND);
$string = date('Y-m-d H:i:s', time()) . PHP_EOL;
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/pay_".date("d"). '.log', $string.$paytype . PHP_EOL, FILE_APPEND);
$pay = Service::checkNotify($paytype);
if (!$pay) {
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/pay_".date("d"). '.log', "签名错误" . PHP_EOL, FILE_APPEND);
echo '签名错误';
return;
}
@@ -147,11 +149,13 @@ class Pay extends Base
$orderModel = new \addons\unishop\model\Order(); //($message['out_trade_no']);
$order = $orderModel->where(['out_trade_no' => $out_trade_no])->find();
if (!$order || $order->have_paid != \addons\unishop\model\Order::PAID_NO) {
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/pay_".date("d"). '.log', "订单不存在或已完成" . PHP_EOL, FILE_APPEND);
throw new Exception('订单不存在或已完成');
}

// 条件二
if ($order->total_price > $payamount || $order->total_price < $payamount) {
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/pay_".date("d"). '.log', "金额不一". PHP_EOL, FILE_APPEND);
throw new Exception('金额不一');
}

@@ -160,6 +164,7 @@ class Pay extends Base
$payTypeString = $paytype == 'alipay' ? \addons\unishop\model\Order::PAY_ALIPAY : \addons\unishop\model\Order::PAY_WXPAY;
Hook::listen('paid_success', $order, ['pay_type' => $payTypeString]);
} catch (Exception $e) {
file_put_contents(ROOT_PATH . '/runtime/log/' . date('Ym') ."/pay_".date("d"). '.log', $e->getMessage() . PHP_EOL, FILE_APPEND);
}
$pay = new \Yansongda\Pay\Pay();
echo $pay->success();


Loading…
Cancel
Save