53 lines
1.9 KiB
PHP
53 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Pay;
|
|
|
|
use App\Models\Order;
|
|
use App\Models\OrderInfo;
|
|
use Illuminate\Http\Request;
|
|
use App\Http\Controllers\Controller;
|
|
|
|
class ApiPayController extends BaseController
|
|
{
|
|
public $order;
|
|
public function scanOrderBack(Request $request){
|
|
//返回给商户
|
|
$order_sn=$request->input('order_sn');
|
|
if(!$order_sn)
|
|
{
|
|
return $this->msg(['error'=>1,'msg'=>'缺少参数']);
|
|
}
|
|
$this->order = Order::where('order_sn', $order_sn)->first();
|
|
if ($this->order['pay_status'] == 1) {
|
|
//判断是否是商户id
|
|
if ($this->order->merchant_id == 0) {
|
|
return redirect()->route('web.user.index');
|
|
}
|
|
//返回参数,订单编号,签名
|
|
|
|
//判断外站
|
|
//取得订单信息
|
|
$order_info = OrderInfo::where('order_id', $this->order->id)->first();
|
|
$return_url = $order_info->return_url;
|
|
$merchant = get_merchant($order_info->app_id);//取得商户
|
|
//发送回调
|
|
//发送签名过去,组装信息
|
|
$notify_data = [
|
|
'pay_money' => $this->order->pay_money,
|
|
'money' => $this->order->order_money,
|
|
'order_sn' => $this->order->order_sn,
|
|
'out_trade_sn' => $this->order->out_trade_sn,
|
|
'pay_order_sn' => $this->order->pay_order_sn,
|
|
'sign' => md5($merchant['token'] . $order_info->sign . 'pay_money=' . $this->order->pay_money . 'pay_status=' . $this->order->pay_status),
|
|
'attch' => $order_info->attach,
|
|
'return_url' => $order_info->return_url,
|
|
'pay_status' => $this->order->pay_status,
|
|
'notify_url' => $order_info->notify_url
|
|
];
|
|
return redirect()->away(arr_to_url($return_url, $notify_data));
|
|
} else {
|
|
return '未支付';
|
|
}
|
|
}
|
|
}
|