|
@@ -16,15 +16,15 @@ class AlipayController
|
|
|
public function index(Request $request)
|
|
|
{
|
|
|
$params = $request->all();
|
|
|
- if (!isset($params['order_id'])){
|
|
|
+ if (!isset($params['order_id'])) {
|
|
|
return json_fail('参数异常');
|
|
|
}
|
|
|
- if (!isset($params['platform'])){
|
|
|
+ if (!isset($params['platform'])) {
|
|
|
return json_fail('缺少平台参数');
|
|
|
}
|
|
|
$orderId = $params['order_id'];
|
|
|
- $payDetail = PayDetail::where('join_pay_order_id',$orderId)->where('pay_status','WAITING')->first();
|
|
|
- if (!$payDetail){
|
|
|
+ $payDetail = PayDetail::where('join_pay_order_id', $orderId)->where('pay_status', 'WAITING')->first();
|
|
|
+ if (!$payDetail) {
|
|
|
return json_fail('订单异常');
|
|
|
}
|
|
|
$payData = [
|
|
@@ -38,24 +38,24 @@ class AlipayController
|
|
|
|
|
|
$payDetail->pay_prepayid = 'ALIPAY';
|
|
|
$payDetail->save();
|
|
|
- if ($params['platform'] == 'android'){
|
|
|
+ if ($params['platform'] == 'android') { // APP支付
|
|
|
$result = Pay::alipay(config('payment.alipay'))->app($payData)->getContent();
|
|
|
- }elseif ($params['platform'] == 'WeChat'){
|
|
|
+ } elseif ($params['platform'] == 'WeChat') { // 网页支付
|
|
|
$result = Pay::alipay(config('payment.alipay'))->wap($payData)->getContent();
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
Db::rollBack();
|
|
|
return json_fail("平台参数无效");
|
|
|
}
|
|
|
|
|
|
Db::commit();
|
|
|
|
|
|
- return json_success('',$result);
|
|
|
+ return json_success('', $result);
|
|
|
} catch (PayException $e) {
|
|
|
Db::rollBack();
|
|
|
return json_fail($e->getMessage());
|
|
|
} catch (\Exception $e) {
|
|
|
Db::rollBack();
|
|
|
- return json_fail('下单失败');
|
|
|
+ return json_fail('下单失败:' . $e->getMessage());
|
|
|
}
|
|
|
|
|
|
|