xiaoyu 3 年 前
コミット
ed75aa3608

+ 15 - 1
data/config/win/refill.ini.php

@@ -1864,6 +1864,19 @@ $yunsuoyaoman_phone = ['name' => 'yunsuoyaoman', 'store_id' => 88,'qualitys' =>
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$youhe_phone = ['name' => 'youhe', 'store_id' => 103, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 6917, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6918, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6919, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6920, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6921, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6922, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6923, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6924, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1937,7 +1950,8 @@ $phone_providers = [
     ['name' => 'xinhengyang', 'cfg' => $xinhengyang_phone],
     ['name' => 'miaoxt', 'cfg' => $miaoxt_phone],
     ['name' => 'tianyan', 'cfg' => $tianyan_phone],
-    ['name' => 'yunsuoyaoman', 'cfg' => $yunsuoyaoman_phone]
+    ['name' => 'yunsuoyaoman', 'cfg' => $yunsuoyaoman_phone],
+    ['name' => 'youhe', 'cfg' => $youhe_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 29 - 1
data/config/xyz/refill.ini.php

@@ -1851,6 +1851,32 @@ $tianyan_phone = ['name' => 'tianyan', 'store_id' => 102, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yunsuoyaoman_phone = ['name' => 'yunsuoyaoman', 'store_id' => 88,'qualitys' => '5',
+    'amount' => [
+        10 => [['goods_id' => 6805, 'price' => 9.03, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6806, 'price' => 18.06, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6807, 'price' => 27.09, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6808, 'price' => 45.15, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6809, 'price' => 90.3, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6810, 'price' => 180.6, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6811, 'price' => 270.9, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6812, 'price' => 451.5, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$youhe_phone = ['name' => 'youhe', 'store_id' => 103, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 6917, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6918, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6919, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6920, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6921, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6922, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6923, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6924, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1923,7 +1949,9 @@ $phone_providers = [
     ['name' => 'lechong', 'cfg' => $lechong_phone],
     ['name' => 'xinhengyang', 'cfg' => $xinhengyang_phone],
     ['name' => 'miaoxt', 'cfg' => $miaoxt_phone],
-    ['name' => 'tianyan', 'cfg' => $tianyan_phone]
+    ['name' => 'tianyan', 'cfg' => $tianyan_phone],
+    ['name' => 'yunsuoyaoman', 'cfg' => $yunsuoyaoman_phone],
+    ['name' => 'youhe', 'cfg' => $youhe_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 29 - 1
data/config/xyzadm/refill.ini.php

@@ -1851,6 +1851,32 @@ $tianyan_phone = ['name' => 'tianyan', 'store_id' => 102, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yunsuoyaoman_phone = ['name' => 'yunsuoyaoman', 'store_id' => 88,'qualitys' => '5',
+    'amount' => [
+        10 => [['goods_id' => 6805, 'price' => 9.03, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6806, 'price' => 18.06, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6807, 'price' => 27.09, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6808, 'price' => 45.15, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6809, 'price' => 90.3, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6810, 'price' => 180.6, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6811, 'price' => 270.9, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6812, 'price' => 451.5, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
+$youhe_phone = ['name' => 'youhe', 'store_id' => 103, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 6917, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6918, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6919, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6920, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6921, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6922, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6923, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6924, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1923,7 +1949,9 @@ $phone_providers = [
     ['name' => 'lechong', 'cfg' => $lechong_phone],
     ['name' => 'xinhengyang', 'cfg' => $xinhengyang_phone],
     ['name' => 'miaoxt', 'cfg' => $miaoxt_phone],
-    ['name' => 'tianyan', 'cfg' => $tianyan_phone]
+    ['name' => 'tianyan', 'cfg' => $tianyan_phone],
+    ['name' => 'yunsuoyaoman', 'cfg' => $yunsuoyaoman_phone],
+    ['name' => 'youhe', 'cfg' => $youhe_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 50 - 0
helper/refill/api/xyz/youhe/RefillCallBack.php

@@ -0,0 +1,50 @@
+<?php
+namespace refill\youhe;
+
+require_once(BASE_HELPER_RAPI_PATH . '/youhe/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['szVerifyString'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
+        $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['nFlag']);
+        $order_sn = $params['szOrderId'];
+        $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['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            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];
+        }
+    }
+}

+ 138 - 0
helper/refill/api/xyz/youhe/RefillPhone.php

@@ -0,0 +1,138 @@
+<?php
+
+namespace refill\youhe;
+
+require_once(BASE_HELPER_RAPI_PATH . '/youhe/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['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $order_sn;
+        $params['szPhoneNum'] = $phone;
+        $params['nMoney'] = $amount;
+        $params['nSortType'] = config::operator[$card_type];
+        $params['nProductClass'] = 1;
+        $params['nProductType'] = 1;
+        $params['szTimeStamp'] = date("Y-m-d H:i:s");
+        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        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);
+
+        $sign = $this->sign($params);
+        $params['szVerifyString'] = $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);
+            $nRtn = intval($resp['nRtn']);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($nRtn == 0) {
+                return [true, '', false];
+            } elseif (in_array($nRtn, config::ERR_NO)) {
+                return [false, $resp['szRtnCode'], false];
+            } elseif (in_array($nRtn, [2050, 999])) {
+                $net_errno = "HTTP-{$nRtn}";
+                return [false, $resp['szRtnCode'], false];
+            } else {
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['szRtnCode'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
+        $params['szVerifyString'] = md5($content);
+
+        $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, '网络错误'];
+            }
+            $status = intval($resp['nRtn']);
+            if ($status === 5012) {
+                $updata['official_sn'] = $resp['szRtnMsg'];
+                Model('refill_order')->edit($refill_info['order_id'], $updata);
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($status === 5013) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif (in_array($status, [5011, 5019])) {
+                $order_state = ORDER_STATE_SEND;
+            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] >= 300)) {
+                $order_state = ORDER_STATE_NOEXIST;
+            } else {
+                return [false, $status];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    public function balance()
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szKey={$key}";
+        $params['szVerifyString'] = md5($content);
+
+        $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['nRtn'] == 0) {
+                return [true, $resp['fBalance']];
+            } else {
+                return [false, $resp['szRtnCode']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
+        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey={$key}";
+        return md5($content);
+    }
+}

+ 27 - 0
helper/refill/api/xyz/youhe/config.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace refill\youhe;
+
+use mtopcard;
+class config
+{
+    //953 1
+    const ORDER_URL = 'http://118.31.168.250:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://118.31.168.250:10186/plat/api/old/queryorder';
+    const BALANCE_URL = 'http://118.31.168.250:10186/plat/api/old/queryBalance';
+
+    const USER_ID= '200022';
+    const KEY = '7a196827b8a24987b777b3ccef04d84c';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_youhe.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+
+    const ERR_NO = [
+        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    ];
+}

+ 21 - 0
helper/refill/api/xyz/youhe/北京椰子API对接信息.txt

@@ -0,0 +1,21 @@
+正式API id :200022
+正式API 密钥:7a196827b8a24987b777b3ccef04d84c
+
+测试ID:200000
+秘钥:2a7533687d974571a2051ad555bfd2f5
+
+登陆地址:http://118.31.168.250:10186/plat/index
+账户名:yezi
+初始密码(建议首次登陆之后修改):YoFwI74xAYGVCPOu
+
+接口IP:118.31.168.250
+
+话费下单地址:http://118.31.168.250:10186/plat/api/old/submitorder
+查询地址:http://118.31.168.250:10186/plat/api/old/queryorder
+查询余额地址:http://118.31.168.250:10186/plat/api/old/queryBalance
+
+对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+
+
+ 

+ 4 - 0
mobile/callback/refill_youhe.php

@@ -0,0 +1,4 @@
+<?php
+
+refill\util::push_notify('youhe',$_POST);
+echo ('ok');

+ 11 - 0
test/TestRefill.php

@@ -631,6 +631,17 @@ class TestRefill extends TestCase
 //        refill\RefillFactory::instance()->notify('yunsuoyaoman', $params);
     }
 
+    public function testYouhe()
+    {
+        $providers = new refill\youhe\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '70421628146378080613']);
+//        $resp = $providers->balance();
+        $body = '{"szOrderId":"70421628146378080613","fSalePrice":"28.59","szAgentId":"200022","nFlag":"2","szVerifyString":"29b5b132c4373447d67d92709afd1c2f","szPhoneNum":"18500608333","szRtnMsg":"110103353032108051453020270482","nDemo":"30"}';
+        $params = json_decode($body, true);
+        refill\RefillFactory::instance()->notify('youhe', $params);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);