diff --git a/application/index/controller/Order.php b/application/index/controller/Order.php index 1368c4441..119a4ca5c 100755 --- a/application/index/controller/Order.php +++ b/application/index/controller/Order.php @@ -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 diff --git a/application/index/view/default/order/qrcode_pay.html b/application/index/view/default/order/qrcode_pay.html index 500c7f2fe..8fb637abb 100644 --- a/application/index/view/default/order/qrcode_pay.html +++ b/application/index/view/default/order/qrcode_pay.html @@ -19,11 +19,12 @@
-
+
+
{{:urldecode($params['name'])}}
-
扫码支付
+
{{:urldecode($params['msg'])}}
diff --git a/application/service/OrderService.php b/application/service/OrderService.php index 4099fd292..bdb80b8c4 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -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 diff --git a/public/static/index/default/css/order.css b/public/static/index/default/css/order.css index 0f5170331..bbd80e756 100755 --- a/public/static/index/default/css/order.css +++ b/public/static/index/default/css/order.css @@ -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 diff --git a/public/static/index/default/js/order.qrcodepay.js b/public/static/index/default/js/order.qrcodepay.js new file mode 100644 index 000000000..a91349444 --- /dev/null +++ b/public/static/index/default/js/order.qrcodepay.js @@ -0,0 +1,41 @@ +$(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