|
|
|
@ -21,6 +21,7 @@ class PaymentService extends AbstractService
|
|
|
|
|
$order->app_id = $app->app_id;
|
|
|
|
|
$order->order_no = $this->generateOrderNo();
|
|
|
|
|
$order->out_order_no = $params['out_order_no'];
|
|
|
|
|
$order->order_name = $params['order_name'];
|
|
|
|
|
$order->amount = $params['amount'];
|
|
|
|
|
$order->currency = $params['currency'];
|
|
|
|
|
$order->redirect_url = $params['redirect_url'];
|
|
|
|
@ -64,13 +65,18 @@ class PaymentService extends AbstractService
|
|
|
|
|
throw new BusinessException('订单重复');
|
|
|
|
|
}
|
|
|
|
|
$order = $this->createOrder($app, $params);
|
|
|
|
|
$result = Api::getExchangeRate('AUD', 'CNY');
|
|
|
|
|
if (!$result->isSuccess()) {
|
|
|
|
|
throw new BusinessException('获取汇率接口失败');
|
|
|
|
|
}
|
|
|
|
|
$rate = $result->get('rate');
|
|
|
|
|
$result = Api::makeJSAPIOrder(
|
|
|
|
|
$order->order_name,
|
|
|
|
|
$order->order_no,
|
|
|
|
|
$order->currency,
|
|
|
|
|
$order->amount,
|
|
|
|
|
'http://146.70.113.165:9501/payment/notify',
|
|
|
|
|
'http://146.70.113.165:9501/payment/page?order_no=' . $order->order_no
|
|
|
|
|
'AUD',
|
|
|
|
|
intval($order->amount / $rate),
|
|
|
|
|
config('base_url') . '/payment/notify',
|
|
|
|
|
config('base_url') . '/payment/page?order_no=' . $order->order_no
|
|
|
|
|
);
|
|
|
|
|
$this->updateOrderResult($order, $result);
|
|
|
|
|
return $order;
|
|
|
|
@ -85,9 +91,9 @@ class PaymentService extends AbstractService
|
|
|
|
|
}
|
|
|
|
|
$order = Order::where('order_no', $params['out_order_no'])->where('status', Order::STATUS_WAIT_PAY)->first();
|
|
|
|
|
$order->status = Order::STATUS_PAYED;
|
|
|
|
|
$order->payed_at = date('Y-m-d');
|
|
|
|
|
$order->exchange_rate = $params['exchange_rate'];
|
|
|
|
|
$order->cny_amount = $params['cny_amount'];
|
|
|
|
|
$order->payed_at = date('Y-m-d H:i:s');
|
|
|
|
|
$order->exchange_rate = $params['exchange_rate'] ?: 0;
|
|
|
|
|
$order->cny_amount = $params['cny_amount'] ?: 0;
|
|
|
|
|
$order->save();
|
|
|
|
|
if ($order->save()) {
|
|
|
|
|
return 'SUCCESS';
|
|
|
|
|