提交 ae87b20f 编写于 作者: D devil_gong

pay debug

上级 c3c0419a
......@@ -333,5 +333,25 @@ class Order extends Common
}
}
/**
* 支付状态校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-01-08
* @desc description
*/
public function PayCheck()
{
if(input('post.'))
{
$params = input('post.');
$params['user'] = $this->user;
return OrderService::OrderPayCheck($params);
} else {
$this->assign('msg', '非法访问');
return $this->fetch('public/tips_error');
}
}
}
?>
\ No newline at end of file
......@@ -19,11 +19,12 @@
<!-- conntent start -->
<div class="am-g my-content">
<div class="am-u-md-6 am-u-sm-centered">
<div class="am-panel am-radius tips-success tips-pay-success">
<div class="am-panel am-radius qrcode-pay" data-ajax-url="{{:MyUrl('index/order/paycheck', ['order_no'=>$params['order_no']])}}" data-order-no="{{$params['order_no']}}">
<div class="am-panel-bd">
<div class="name">{{:urldecode($params['name'])}}</div>
<img class="qrcode-images am-img-thumbnail" src="{{:MyUrl('index/qrcode/index', ['content'=>$params['url']])}}">
</div>
<div class="tips">扫码支付</div>
<div class="msg">{{:urldecode($params['msg'])}}</div>
</div>
</div>
</div>
......
......@@ -1355,5 +1355,49 @@ class OrderService
}
}
/**
* 支付状态校验
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-01-08
* @desc description
* @param [array] $params [输入参数]
*/
public static function OrderPayCheck($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'order_no',
'error_msg' => '订单号有误',
],
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = ParamsChecked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 获取订单状态
$where = ['order_no'=>$params['order_no'], 'user_id'=>$params['user']['id']];
$order = Db::name('Order')->where($where)->field('id,pay_status')->find();
if(empty($order))
{
return DataReturn('订单不存在', -400, ['url'=>__MY_URL__]);
}
if($order['pay_status'] == 1)
{
return DataReturn('支付成功', 0, ['url'=>MyUrl('index/order/detail', ['id'=>$order['id']])]);
}
return DataReturn('支付中', -300);
}
}
?>
\ No newline at end of file
......@@ -107,4 +107,21 @@ strong.total-price-content { color: #d2364c; font-size: 16px; }
.goods-base { margin-left: 45px; }
table.data-list td.row-status { border-left: 1px solid #eee; }
table.data-ongoing td.row-status { border-left: 1px solid #fff1f5; }
}
/**
* 订单二维码支付页面
*/
.qrcode-pay {
text-align: center;
box-shadow: none;
}
.qrcode-pay .name {
font-size: 18px;
font-weight: 500;
margin: 20px 0 10px 0;
}
.qrcode-pay .msg {
color: #F44336;
}
\ No newline at end of file
$(function()
{
// 定时查询订单是否已支付
setInterval(function()
{
// ajax请求
$.ajax({
url: $('.qrcode-pay').data('ajax-url'),
type: 'post',
dataType: "json",
timeout: 10000,
data: {"order_no": $('.qrcode-pay').data('order-no')},
success: function(result)
{
if(result.code == 0 && (result.data.url || null) != null)
{
Prompt(result.msg, 'success');
setTimeout(function()
{
window.location.href = result.data.url;
}, 1500);
} else if(result.code == -400 && (result.data.url || null) != null) {
Prompt(result.msg);
setTimeout(function()
{
window.location.href = result.data.url;
}, 1500);
} else {
if(result.code != -300)
{
Prompt(result.msg);
}
}
},
error: function(xhr, type)
{
Prompt('网络异常错误');
}
});
}, 2000);
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册