下单返回url
This commit is contained in:
parent
467864b4f4
commit
e63dade12e
|
@ -148,18 +148,23 @@ class OrderApiController extends BaseController
|
||||||
];
|
];
|
||||||
return $this->json($data);
|
return $this->json($data);
|
||||||
}
|
}
|
||||||
if($order->ewm_mark || $order->ewm_account)
|
if ($order->ewm_mark) {
|
||||||
{
|
if ($order->ewm_account == $pay_account) {
|
||||||
$data = [
|
$data = [
|
||||||
'error' => 1,
|
'error' => 1,
|
||||||
'msg' => '你已经提交过',
|
'msg' => '你已经提交过',
|
||||||
'backurl' => '',
|
'backurl' => '',
|
||||||
];
|
];
|
||||||
return $this->json($data);
|
return $this->json($data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//xieru
|
//xieru
|
||||||
$order->ewm_mark = $mark;
|
if (empty($order->ewm_mark)) {
|
||||||
$order->ewm_account = $pay_account;
|
$order->ewm_mark = $mark;
|
||||||
|
}
|
||||||
|
if (empty($order->ewm_account)) {
|
||||||
|
$order->ewm_account = $pay_account;
|
||||||
|
}
|
||||||
$r = $order->save();
|
$r = $order->save();
|
||||||
if ($r) {
|
if ($r) {
|
||||||
$data = [
|
$data = [
|
||||||
|
|
|
@ -53,6 +53,21 @@ class OrderController extends BaseController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 显示订单
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse|\Illuminate\View\View|void
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function showOrder(Request $request){
|
||||||
|
if($request->input('out_trade_sn')){
|
||||||
|
$pay = new ApiOrderServices();
|
||||||
|
return $pay->showOrder($request);
|
||||||
|
}else{
|
||||||
|
return abort(403,'缺少参数');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查订单
|
* 检查订单
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
|
|
@ -20,6 +20,50 @@ class ApiOrderServices
|
||||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View|void
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\JsonResponse|\Illuminate\View\View|void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
public function showOrder($request){
|
||||||
|
$out_trade_sn = $request->input('out_trade_sn');
|
||||||
|
$has_order = Order::where('out_trade_sn', $out_trade_sn)->first();
|
||||||
|
if (!empty($has_order)) {
|
||||||
|
$this->order = $has_order;
|
||||||
|
$this->pay_type = $this->order->pay_type;
|
||||||
|
$this->pay_method = $this->order->gateway_method;
|
||||||
|
|
||||||
|
//判断是否已经支持
|
||||||
|
//订单无效
|
||||||
|
if ($has_order->status == 4) {
|
||||||
|
|
||||||
|
return abort(403, '订单已取消');
|
||||||
|
}
|
||||||
|
if ($has_order->status == 3) {
|
||||||
|
|
||||||
|
return abort(403, '订单已取消');
|
||||||
|
}
|
||||||
|
//如果支付,2进行跳转
|
||||||
|
if (in_array($has_order->pay_status, [1, 2])) {
|
||||||
|
return $this->merchantReturnSend();
|
||||||
|
//进行跳转回去。
|
||||||
|
}
|
||||||
|
//判断订单是否无效,15分钟有效
|
||||||
|
if (strtotime($has_order->created_at) <= (time() - 60 * $this->timeOut)) {
|
||||||
|
return abort(403, '订单已过期');
|
||||||
|
}
|
||||||
|
//如果没有支付,则
|
||||||
|
if ($has_order->pay_status == 0) {
|
||||||
|
$this->setPayService($this->pay_type);
|
||||||
|
//指定通道
|
||||||
|
$this->pay_service->getGatewayInfo($this->order->gateway_id, $this->order->gateway_method);
|
||||||
|
$this->pay_service->payConfig($this->pay_type);
|
||||||
|
$data = $this->orderPayData();;
|
||||||
|
$this->pay_service->setOrder($this->order);
|
||||||
|
//发送支付请求
|
||||||
|
return $this->paySend($data, $this->order);
|
||||||
|
}
|
||||||
|
return $this->msg(['error' => 1, 'msg' => '提交失败']);
|
||||||
|
}else{
|
||||||
|
return abort(403,'订单不存在');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function order($request)
|
public function order($request)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace App\ServicePay;
|
||||||
|
|
||||||
use App\Models\Merchant;
|
use App\Models\Merchant;
|
||||||
use App\Models\Message;
|
use App\Models\Message;
|
||||||
|
use App\ServicePay\traits\ReturnTrait;
|
||||||
use App\ServicePay\TransCard\BaseCard;
|
use App\ServicePay\TransCard\BaseCard;
|
||||||
use App\ServicePay\TransCard\GetTransInfo;
|
use App\ServicePay\TransCard\GetTransInfo;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
@ -11,6 +12,7 @@ use Illuminate\Support\Facades\Log;
|
||||||
class GuMaPayServices implements PayApiInterface
|
class GuMaPayServices implements PayApiInterface
|
||||||
{
|
{
|
||||||
use PayTrait;
|
use PayTrait;
|
||||||
|
use ReturnTrait;
|
||||||
public $gateway_list;//当前类型的支付通道列表
|
public $gateway_list;//当前类型的支付通道列表
|
||||||
public $pay_type;//支付类型
|
public $pay_type;//支付类型
|
||||||
public $pay_method;//支付方法
|
public $pay_method;//支付方法
|
||||||
|
@ -78,9 +80,19 @@ class GuMaPayServices implements PayApiInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function pay($pay_data,$order)
|
public function pay($pay_data)
|
||||||
{
|
{
|
||||||
|
$return = request()->all();
|
||||||
|
$re_type = 'json';
|
||||||
|
if (isset($return['re_type'])) {
|
||||||
|
$re_type = $return['re_type'];
|
||||||
|
}
|
||||||
|
if (isset($return['app_id'])) {
|
||||||
|
$host = request()->getSchemeAndHttpHost();
|
||||||
|
$url = 'order/show?out_trade_sn=' . $this->order->out_trade_sn;
|
||||||
|
$url = $host . '/' . $url;
|
||||||
|
return $this->returnPayRes($re_type, '', 1, $url);
|
||||||
|
}
|
||||||
//订单开始时间,倒计时
|
//订单开始时间,倒计时
|
||||||
$time_only = ((strtotime($this->order->created_at) + $this->timeOut * 60) - time());
|
$time_only = ((strtotime($this->order->created_at) + $this->timeOut * 60) - time());
|
||||||
|
|
||||||
|
@ -98,7 +110,7 @@ class GuMaPayServices implements PayApiInterface
|
||||||
'pay_status' => $this->order->pay_status == 1 ? '已支付' : '等待支付',
|
'pay_status' => $this->order->pay_status == 1 ? '已支付' : '等待支付',
|
||||||
'only_time' =>$time_only
|
'only_time' =>$time_only
|
||||||
];
|
];
|
||||||
$lange = $order->language ?? 'zh_cn';
|
$lange = $this->order->language ?? 'zh_cn';
|
||||||
$appPath = base_path();
|
$appPath = base_path();
|
||||||
$dir = $appPath . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'order' . DIRECTORY_SEPARATOR;
|
$dir = $appPath . DIRECTORY_SEPARATOR . 'resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . 'order' . DIRECTORY_SEPARATOR;
|
||||||
$file = $lange == 'zh_cn' ? '' : $lange;
|
$file = $lange == 'zh_cn' ? '' : $lange;
|
||||||
|
|
|
@ -18,7 +18,7 @@ interface PayApiInterface
|
||||||
public function payConfig($type, $setConfig = []);
|
public function payConfig($type, $setConfig = []);
|
||||||
|
|
||||||
//统一下单支付
|
//统一下单支付
|
||||||
public function pay($pay_data,$order);
|
public function pay($pay_data);
|
||||||
|
|
||||||
//统一验证签名
|
//统一验证签名
|
||||||
public function verify();
|
public function verify();
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
namespace App\ServicePay\traits;
|
||||||
|
trait ReturnTrait{
|
||||||
|
protected function returnPayRes($re_type,$msg,$code,$url=''){
|
||||||
|
if ($code == 1) {
|
||||||
|
if ($re_type == 'json') {
|
||||||
|
return json_encode(['code' => 1, 'qrurl' => $url], 256);
|
||||||
|
} else {
|
||||||
|
return redirect()->away($url);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($re_type == 'json') {
|
||||||
|
return json_encode(['code' => 0, 'msg' => $msg], 256);
|
||||||
|
} else {
|
||||||
|
return $msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -43,6 +43,7 @@ Route::name('web.')->group(function ($route) {
|
||||||
});
|
});
|
||||||
Route::group(['prefix' => 'order'], function ($route) {
|
Route::group(['prefix' => 'order'], function ($route) {
|
||||||
$route->get('/', 'OrderController@index')->name('order.index');
|
$route->get('/', 'OrderController@index')->name('order.index');
|
||||||
|
$route->get('/show', 'OrderController@showOrder')->name('order.showOrder');
|
||||||
$route->post('/order', 'OrderController@orderPost')->name('order.orderPost');
|
$route->post('/order', 'OrderController@orderPost')->name('order.orderPost');
|
||||||
$route->post('/check', 'OrderController@orderCheck')->name('order.orderCheck');//检查订单
|
$route->post('/check', 'OrderController@orderCheck')->name('order.orderCheck');//检查订单
|
||||||
$route->post('/notify', 'OrderController@notify')->name('order.notify');//notify
|
$route->post('/notify', 'OrderController@notify')->name('order.notify');//notify
|
||||||
|
|
Loading…
Reference in New Issue