xiaoyu 2 lat temu
rodzic
commit
d37b42f1d4

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

@@ -8245,12 +8245,46 @@ $shenzhou_phone = ['name' => 'shenzhou', 'store_id' => 301, 'qualitys' => '3',
         ],
         500 => [
             ['goods_id' => 8495, 'price' => 518.5, 'quality' => 3, 'card_type' => 'chinamobile'],
-//            ['goods_id' => 8495, 'price' => 520, 'quality' => 3, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8495, 'price' => 520, 'quality' => 3, 'card_type' => 'chinaunicom'],
             ['goods_id' => 8495, 'price' => 518.5, 'quality' => 3, 'card_type' => 'chinatelecom'],
         ]
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$shenzhou_ylyw_phone = ['name' => 'shenzhou_ylyw', 'store_id' => 302, 'qualitys' => '3',
+    'amount' => [
+//        10 => [['goods_id' => 8496, 'price' => 9.7, 'quality' => 3, 'card_type' => 'chinaunicom']],
+//        20 => [['goods_id' => 8497, 'price' => 19.4, 'quality' => 3, 'card_type' => 'chinaunicom']],
+//        30 => [
+//            ['goods_id' => 8498, 'price' => 31.2, 'quality' => 3, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8498, 'price' => 31.14, 'quality' => 3, 'card_type' => 'chinaunicom'],
+//        ],
+        50 => [
+            ['goods_id' => 8499, 'price' => 51.85, 'quality' => 3, 'card_type' => 'chinaunicom'],
+        ],
+        100 => [
+            ['goods_id' => 8500, 'price' => 103.7, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8500, 'price' => 103.7, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8500, 'price' => 103.7, 'quality' => 3, 'card_type' => 'chinatelecom'],
+        ],
+        200 => [
+            ['goods_id' => 8501, 'price' => 207.4, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8501, 'price' => 207.4, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8501, 'price' => 207.4, 'quality' => 3, 'card_type' => 'chinatelecom'],
+        ],
+        300 => [
+            ['goods_id' => 8502, 'price' => 311.1, 'quality' => 3, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8502, 'price' => 311.1, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8502, 'price' => 311.1, 'quality' => 3, 'card_type' => 'chinatelecom'],
+        ],
+        500 => [
+            ['goods_id' => 8503, 'price' => 518.5, 'quality' => 3, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8503, 'price' => 520, 'quality' => 3, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8503, 'price' => 518.5, 'quality' => 3, 'card_type' => 'chinatelecom'],
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],

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

@@ -0,0 +1,50 @@
+<?php
+namespace refill\shenzhou_ylyw;
+
+require_once(BASE_HELPER_RAPI_PATH . '/shenzhou_ylyw/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')->getOrderInfoForNotify(['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];
+        }
+    }
+}

+ 142 - 0
helper/refill/api/xyz/shenzhou_ylyw/RefillPhone.php

@@ -0,0 +1,142 @@
+<?php
+
+namespace refill\shenzhou_ylyw;
+
+require_once(BASE_HELPER_RAPI_PATH . '/shenzhou_ylyw/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['szProductId'] = config::Product[$card_type][$amount];
+        $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 = $resp['nRtn'];
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($nRtn === 0) {
+                return [true, '', false];
+            } elseif (in_array($nRtn, config::ERR_NOS, true)) {
+                return [false, $resp['szRtnCode'], false];
+            } elseif ($nRtn === 999) {
+                $net_errno = "HTTP-{$nRtn}";
+                return [false, $resp['szRtnCode'], true];
+            } else {
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['szRtnCode'], true];
+            }
+        }
+    }
+
+    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 = $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],true)) {
+                $order_state = ORDER_STATE_SEND;
+            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] > 300)) {
+                $order_state = ORDER_STATE_NOEXIST;
+            } else {
+                return [false, $resp['szRtnMsg']];
+            }
+
+            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);
+    }
+}

+ 26 - 0
helper/refill/api/xyz/shenzhou_ylyw/api.txt

@@ -0,0 +1,26 @@
+正式环境:
+话费下单地址:http://47.98.242.182:10186/plat/api/old/submitorder
+查询地址:http://47.98.242.182:10186/plat/api/old/queryorder
+查询余额地址:http://47.98.242.182:10186/plat/api/old/queryBalance
+
+正式ID:200238
+秘钥:70b8f03f1b0248acb18b7927cf12a073
+对接文档地址:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+
+客户端地址:http://47.98.242.182:10186/plat/index   账号:游来有旺票  密码: 123456(登录后请立即修改)
+
+移动100面值   1000100
+移动200面值   1000200
+移动300面值   1000300
+移动500面值   1000500
+
+联通50面值    2000050
+联通100面值   2000100
+联通200面值   2000200
+联通300面值   2000300
+
+电信100面值   3000100
+电信200面值   3000200
+电信300面值   3000300
+电信500面值   3000500

+ 48 - 0
helper/refill/api/xyz/shenzhou_ylyw/config.php

@@ -0,0 +1,48 @@
+<?php
+
+
+namespace refill\shenzhou_ylyw;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.98.242.182:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://47.98.242.182:10186/plat/api/old/queryorder';
+    const BALANCE_URL = 'http://47.98.242.182:10186/plat/api/old/queryBalance';
+
+    const USER_ID= '200238';
+    const KEY = '70b8f03f1b0248acb18b7927cf12a073';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_shenzhou_ylyw.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_NOS = [
+        1000,1001,1003,1004,2001,2002,2003,2020,2021,1006,2030,3003
+    ];
+
+    const Product = [
+        mtopcard\ChinaMobileCard => [
+            100 => 1000100,
+            200 => 1000200,
+            300 => 1000300,
+            500 => 1000500,
+        ],
+        mtopcard\ChinaUnicomCard => [
+            50  => 2000050,
+            100 => 2000100,
+            200 => 2000200,
+            300 => 2000300,
+        ],
+        mtopcard\ChinaTelecomCard => [
+            100 => 3000100,
+            200 => 3000200,
+            300 => 3000300,
+            500 => 3000500,
+        ],
+    ];
+}

+ 4 - 0
mobile/callback/refill_shenzhou_ylyw.php

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

+ 6 - 0
test/TestRefill.php

@@ -3176,6 +3176,12 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testShenzhou_ylyw()
+    {
+        $provider = $this->getProvider('shenzhou_ylyw');
+        $resp = $provider->balance();
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);