74 lines
2.5 KiB
PHP
74 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace app\home\controller;
|
|
|
|
use api\Httpcurl;
|
|
use think\facade\Config;
|
|
use think\facade\Request;
|
|
|
|
class Wechatpay extends Base
|
|
{
|
|
/**
|
|
* 微信jsapi支付结果页面
|
|
*/
|
|
public function index()
|
|
{
|
|
$order_sn = Request::instance()->param('order_sn');
|
|
if (!$order_sn) {
|
|
return $this->error('缺少订单号');
|
|
}
|
|
//获取订单信息
|
|
$order_url = Config::get('app.get_evus_detail_url');
|
|
$response = Httpcurl::request($order_url, 'post', ['order_sn'=>$order_sn,'model'=>MODEL]);
|
|
if ($response[3]) {
|
|
return $this->error('支付失败,请稍后重试', url('home/detail/index')->build());
|
|
}
|
|
$pay_result = json_decode($response[0], true);
|
|
if (empty($pay_result)) {
|
|
return $this->error('支付失败,请稍后重试', url('home/detail/index')->build());
|
|
}
|
|
if (!$pay_result['code']){
|
|
return $this->error('支付失败,请稍后重试', url('home/detail/index')->build());
|
|
}
|
|
$pay_result = $pay_result['data'];
|
|
if ($pay_result['pay_status']) {
|
|
|
|
return redirect(url('home/pay/succ', ['order_sn' => $order_sn])->build());
|
|
}else{
|
|
return $this->error('支付失败,请稍后重试', url('home/detail/index')->build());
|
|
}
|
|
|
|
}
|
|
public function esta()
|
|
{
|
|
$order_sn = Request::instance()->param('order_sn');
|
|
if (!$order_sn) {
|
|
return $this->error('缺少订单号');
|
|
}
|
|
//获取订单信息
|
|
$order_url = Config::get('app.get_order_detail_url');
|
|
$response = Httpcurl::request($order_url, 'post', ['order_sn'=>$order_sn,'model'=>ESTA_MODEL]);
|
|
if ($response[3]) {
|
|
return $this->error('支付失败,请稍后重试', url('home/esta/index')->build());
|
|
}
|
|
$pay_result = json_decode($response[0], true);
|
|
if (empty($pay_result)) {
|
|
return $this->error('支付失败,请稍后重试', url('home/esta/index')->build());
|
|
}
|
|
if (!$pay_result['code']){
|
|
return $this->error('支付失败,请稍后重试', url('home/esta/index')->build());
|
|
}
|
|
$pay_result = $pay_result['data'];
|
|
if ($pay_result['pay_status']) {
|
|
|
|
return redirect(url('home/payesta/succ', ['order_sn' => $order_sn])->build());
|
|
}else{
|
|
return $this->error('支付失败,请稍后重试', url('home/esta/index')->build());
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|