作者 macbook
1 个管道 的构建 通过 耗费 0 秒

ceshi

... ... @@ -417,7 +417,7 @@ class Order extends Api
// User::money($order['deposit'],$order['user_id'],'取消订单',['order_id' => $order['id']]);
// 退款
$Wecaht = new Wechat();
if(!$Wecaht->refund(\app\api\model\Order::get($order['id']),'取消订单')){
if(!$Wecaht->refund($order,'取消订单')){
(new self())->error($Wecaht->getError());
}
... ...
... ... @@ -40,13 +40,13 @@ class Wechat extends Controller
'total_fee' => $order_price * 100,
'trade_type' => 'JSAPI', // 请对应换成你的支付方式对应的值类型
'openid' => $openid,
'notify_url' => request()->domain() . '/index/notify/notify',
'notify_url' => (self::isHttps() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/index/notify/notify',
]);
if ($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS') {
return $payment->jssdk->sdkConfig($result['prepay_id']); // 返回数组
}
if ($result['return_code'] == 'FAIL' && array_key_exists('return_msg', $result)) {
$this->setError($result['return_msg']);
return false;
... ... @@ -100,7 +100,7 @@ class Wechat extends Controller
$result = $payment->refund->byOutTradeNumber($refundLog['order_sn'], $refundLog['refund_sn'], $refundLog['pay_fee'] * 100, $refundLog['refund_fee'] * 100, [
// 可在此处传入其他参数,详细参数见微信支付文档
'refund_desc' => $refund_desc,
'notify_url' => request()->domain() . '/index/notify/notifyr',
'notify_url' => (self::isHttps() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/index/notify/notifyr',
]);
\think\Log::write('refund-result' . json_encode($result));
... ... @@ -139,6 +139,20 @@ class Wechat extends Controller
}
/**
* 判断是否是https
*/
public static function isHttps() {
if ( !empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') {
return true;
} elseif ( isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https' ) {
return true;
} elseif ( !empty($_SERVER['HTTP_FRONT_END_HTTPS']) && strtolower($_SERVER['HTTP_FRONT_END_HTTPS']) !== 'off') {
return true;
}
return false;
}
/**
* 设置错误信息
*/
public function setError($error)
... ...