作者 郭鑫

微信支付完善

... ... @@ -10,6 +10,7 @@
// +----------------------------------------------------------------------
namespace app\portal\controller;
//use cmf\controller\HomeBaseController;
use api\portal\model\OrderModel;
use app\portal\model\MemberModel;
use app\portal\model\UserModel;
use app\portal\service\PostService;
... ... @@ -113,5 +114,23 @@ class IndexController extends CommonController
\QRcode::png($url);
}
// 检测微信支付是否完成
public function checkStatus() {
if($this->request->isAjax()) {
$order_sn = $this->request->param('order_sn');
$order_model = new OrderModel();
$status = $order_model->where(['order_sn'=>$order_sn])->value('status');
if(empty($status)) {
$this->apiResponse(0,'订单不存在');
}
if($status == 1 || $status == 9) {
$this->apiResponse(0,'未支付成功');
}
if($status == 2) {
$this->apiResponse(1,'支付成功');
}
}
}
}
... ...
... ... @@ -44,6 +44,7 @@ class NotifyController extends HomeBaseController
$orderInfo = $order_model->where(['order_sn'=>$order_sn])->find();
if($orderInfo['status'] == 1) {
$info = [
'pay_type'=>1,
'pay_time'=>time(),
'status'=>2,
'transaction_id'=>$data['transaction_id']
... ...
... ... @@ -182,6 +182,20 @@
});
$("#home-slider").show();
});
setInterval(function(){
$.ajax({
url:"{:url('checkStatus')}",
type:"POST",
data:{
order_sn:123123123123
},
dataType:"JSON",
success:function(res){
console.log(res);
}
})
},1000)
</script>
<hook name="before_body_end"/>
</body>
... ...