瀏覽代碼

yl yamiao_high yamiao_normal yamiaoman

xiaoyu 3 年之前
父節點
當前提交
8d3fdc1433

文件差異過大導致無法顯示
+ 445 - 334
data/config/yl/refill.ini.php


+ 2 - 2
helper/refill/api/yl/yamiao_high/config.php

@@ -10,8 +10,8 @@ class config
     const QUERY_URL = 'http://120.55.90.36:8911/api/order/query';
     const BALANCE_URL = 'http://120.55.90.36:8911/api/account/balance';
 
-    const APP_ID = 'HHngfxQs6M';
-    const APP_SECRET = 'jToNycSIbofVwPSn';
+    const APP_ID = 'ILo9IfHYg0';
+    const APP_SECRET = 'xjHkCgnJwxDgFbpK';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yamiao_high.php";
     const PRODUCT = [
         mtopcard\ChinaMobileCard => [

+ 5 - 5
helper/refill/api/yl/yamiao_high/开户信息.txt

@@ -1,9 +1,9 @@
 后台地址:http://120.55.90.36:8888
-帐号:椰
-密码:545795
-二级密码:eJMW5323
-appId:HHngfxQs6M
-appSecret:jToNycSIbofVwPSn
+帐号:椰林高价
+密码:168884
+二级密码:nuxc3785
+appId:ILo9IfHYg0
+appSecret:xjHkCgnJwxDgFbpK
 后台-商品列表,可查看已配置商品信息
 后台-安全中心,可配置IP白名单
 接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290

+ 2 - 2
helper/refill/api/yl/yamiao_normal/config.php

@@ -10,8 +10,8 @@ class config
     const QUERY_URL = 'http://120.55.90.36:8911/api/order/query';
     const BALANCE_URL = 'http://120.55.90.36:8911/api/account/balance';
 
-    const APP_ID = 'RvQe0E9q3S';
-    const APP_SECRET = 'OfVpRCIUBQGYSQUL';
+    const APP_ID = 'Mxh2JUZocr';
+    const APP_SECRET = 'fKWyNeYlRZAimWXO';
     const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yamiao_normal.php";
     const PRODUCT = [
         mtopcard\ChinaMobileCard => [

+ 5 - 5
helper/refill/api/yl/yamiao_normal/开户信息.txt

@@ -1,9 +1,9 @@
 后台地址:http://120.55.90.36:8888
-帐号:yezi
-密码:304641
-二级密码:tKDZ6725
-appId:RvQe0E9q3S
-appSecret:OfVpRCIUBQGYSQUL
+帐号:椰林低价
+密码:260379
+二级密码:LFBU6725
+appId:Mxh2JUZocr
+appSecret:fKWyNeYlRZAimWXO
 后台-商品列表,可查看已配置商品信息
 后台-安全中心,可配置IP白名单
 接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290

+ 67 - 0
helper/refill/api/yl/yamiaoman/RefillCallBack.php

@@ -0,0 +1,67 @@
+<?php
+namespace refill\yamiaoman;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yamiaoman/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
+        $order_info = Model('vr_order')->getOrderInfo(['order_sn' => $order_sn]);
+        if (empty($order_info)) {
+            return [false, false, false,false];
+        }
+
+        $order_id = $order_info['order_id'];
+        if ($status === 2) {
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 3) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/yl/yamiaoman/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\yamiaoman;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yamiaoman/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $order_sn = $params['order_sn'];
+        $params = $this->req_params($card_no, $amount, $card_type, $order_sn);
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
+            } else {
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            elseif ($resp['code'] === '00')
+            {
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+}

+ 34 - 0
helper/refill/api/yl/yamiaoman/config.php

@@ -0,0 +1,34 @@
+<?php
+
+
+namespace refill\yamiaoman;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://120.55.90.36:8911/api/hf/order/submit';
+    const QUERY_URL = 'http://120.55.90.36:8911/api/order/query';
+    const BALANCE_URL = 'http://120.55.90.36:8911/api/account/balance';
+
+    const APP_ID = 'EzkE5PIewV';
+    const APP_SECRET = 'XbENwMHSxmYnrfyA';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yamiaoman.php";
+
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+
+        ],
+        mtopcard\ChinaUnicomCard => [
+            50  => 100027,
+            100 => 100028,
+            200 => 100029,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            50  => 100030,
+            100 => 100031,
+            200 => 100032,
+        ],
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
+}

+ 22 - 0
helper/refill/api/yl/yamiaoman/开户信息.txt

@@ -0,0 +1,22 @@
+后台地址:http://120.55.90.36:8888
+帐号:椰林慢充
+密码:083027
+二级密码:WNHg9179
+appId:EzkE5PIewV
+appSecret:XbENwMHSxmYnrfyA
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+接口文档:https://www.showdoc.com.cn/1686453783298366/7925312871840290
+话费直充接口:http://120.55.90.36:8911/api/hf/order/submit
+通用直充接口:http://120.55.90.36:8911/api/order/submit
+卡密提取接口:http://120.55.90.36:8911/api/card/get
+查单接口接口:http://120.55.90.36:8911/api/order/query
+余额接口接口:http://120.55.90.36:8911/api/account/balance
+
+100027 慢充联通50
+100028 慢充联通100
+100029 慢充联通200
+
+100030 慢充电信50
+100031 慢充电信100
+100032 慢充电信200

+ 98 - 0
test/TestRefillYl.php

@@ -0,0 +1,98 @@
+<?php
+use PHPUnit\Framework\TestCase;
+
+define('APP_ID', 'test');
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
+
+require_once(BASE_ROOT_PATH . '/global.php');
+require_once(BASE_CORE_PATH . '/lrlz.php');
+require_once(BASE_ROOT_PATH . '/fooder.php');
+
+require_once(BASE_CORE_PATH . '/framework/function/http.php');
+require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
+require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
+
+const LocalTest = 1;
+const NetTest = 2;
+
+const CurrentTest = NetTest;
+
+class TestRefillYl extends TestCase
+{
+    public static function setUpBeforeClass(): void
+    {
+        Base::run_util();
+        refill\RefillFactory::instance();
+    }
+
+    private function getProvider($name,$type = 'RefillPhone')
+    {
+        $file = BASE_HELPER_RAPI_PATH . "/$name/{$type}.php";
+        if(!file_exists($file)){
+            Log::record("provider api file={$file} not exist.",Log::DEBUG);
+            return false;
+        } else {
+            require_once($file);
+            Log::record("file={$file} load success.",Log::DEBUG);
+        }
+
+        $class_name = "refill\\{$name}\\{$type}";
+        if (class_exists($class_name, false)) {
+            $caller = new $class_name([]);
+            return $caller;
+        } else {
+            $error = "Base Error: class {$class_name} isn't exists!";
+            Log::record($error, Log::ERR);
+            return false;
+        }
+    }
+
+    private function make_sn()
+    {
+        return mt_rand(1000, 9999)
+            . sprintf('%010d', time())
+            . sprintf('%06d', (float)microtime() * 1000000);
+    }
+
+    public function testYamiao_high()
+    {
+//        $provider = $this->getProvider('yamiao_high');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '80031648092448376229']);
+
+        $body = '{"orderId":"220324112752228331","appId":"ILo9IfHYg0","outOrderId":"80031648092448376229","sign":"1ef1ba02308669673ebcb136cb67e1c1","orderStatus":"3","completeTime":"20220324112803","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('yamiao_high','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
+    public function testYamiao_normal()
+    {
+//        $provider = $this->getProvider('yamiao_normal');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '65931648092912669252']);
+
+        $body = '{"orderId":"220324113519231696","appId":"Mxh2JUZocr","outOrderId":"65931648092912669252","sign":"6560cab5e7ec5f265b04632c4c2a1f1a","orderStatus":"3","completeTime":"20220324113522","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('yamiao_normal','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
+    public function testYamiaoman()
+    {
+        $provider = $this->getProvider('yamiaoman');
+        $resp = $provider->balance();
+//        $resp = $provider->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '53351647242979116742']);
+
+//        $body = '{"orderId":"220314152954756093","appId":"zIODZmzSCk","outOrderId":"53351647242979116742","sign":"41ad7d4b4b26559377c6443d2b0d6c68","orderStatus":"3","completeTime":"20220314172722","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
+//        $params = json_decode($body, true);
+//        $provider = $this->getProvider('yamiaoman','RefillCallBack');
+//        $ret = $provider->verify($params);
+//        $resp = $provider->notify($params);
+    }
+}