From 7b0dae7b17a0a7d7e4929b39eb11c8046ff5a869 Mon Sep 17 00:00:00 2001 From: xurongyao Date: Sat, 15 Sep 2018 20:04:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extend/service/RoutineService.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/extend/service/RoutineService.php b/extend/service/RoutineService.php index 8e9cd435..6fccfa3c 100644 --- a/extend/service/RoutineService.php +++ b/extend/service/RoutineService.php @@ -27,10 +27,10 @@ class RoutineService{ $appid = self::options()['routine_appId'] ? self::options()['routine_appId'] : '';//如果是公众号 就是公众号的appid $mch_id = self::options()['pay_routine_mchid'] ? self::options()['pay_routine_mchid'] : ''; $nonce_str = self::nonce_str();//随机字符串 - $spbill_create_ip = '118.190.105.59'; + $spbill_create_ip = self::get_server_ip(); $total_fee = $fee*100;//因为充值金额最小是1 而且单位为分 如果是充值1元所以这里需要*100 $trade_type = 'JSAPI';//交易类型 默认 - $notify_url = SystemConfigService::get('site_url').Url::build('wechat/Index/notify'); + $notify_url = SystemConfigService::get('site_url').Url::build('routine/Routine/notify'); $post['appid'] = $appid; $post['attach'] = $attach; $post['body'] = $body; @@ -43,9 +43,6 @@ class RoutineService{ $post['total_fee'] = $total_fee;//总金额 $post['trade_type'] = $trade_type; $sign = self::sign($post);//签名 -// dump($sign); -// dump($post); -// exit(); $post_xml = ' '.$appid.' '.$attach.' @@ -154,4 +151,19 @@ class RoutineService{ } return $data; } + + public static function get_server_ip() { + if (isset($_SERVER)) { + if($_SERVER['SERVER_ADDR']) { + $server_ip = $_SERVER['SERVER_ADDR']; + } + else { + $server_ip = $_SERVER['LOCAL_ADDR']; + } + } + else { + $server_ip = getenv('SERVER_ADDR'); + } + return $server_ip; + } } \ No newline at end of file