Procházet zdrojové kódy

椰子 金羽快充1号-游来(含)

lowkeyman před 4 dny
rodič
revize
23070f510b

+ 46 - 0
data/config/xyz/phone.ini.php

@@ -4333,6 +4333,51 @@ $zhixinzhuanch_phone = [
 //        ]
     ]
 ];
+$jinyu_phone = [
+    'name' => 'jinyu', 'store_id' => 440, 'qualitys' => '2', 'official_sn' => true, 'refill_type' => 'api',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9469, 'price' => 10, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9469, 'price' => 10, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9469, 'price' => 10, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 9470, 'price' => 20, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9470, 'price' => 20, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9470, 'price' => 20, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 9471, 'price' => 30, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9471, 'price' => 30, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9471, 'price' => 30, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+        50 => [
+//            ['goods_id' => 9472, 'price' => 50, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9472, 'price' => 51.875, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9472, 'price' => 50, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9473, 'price' => 103.75, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9473, 'price' => 103.75, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9473, 'price' => 103.75, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9474, 'price' => 207.5, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9474, 'price' => 207.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9474, 'price' => 207.5, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 9475, 'price' => 311.25, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9475, 'price' => 311.25, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9475, 'price' => 311.25, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 9476, 'price' => 518.75, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9476, 'price' => 500, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9476, 'price' => 518.75, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ]
+];
 
 $phone_providers = [
 	[ 'name' => 'xunyin', 'cfg' => $xunyin_phone ],
@@ -4458,4 +4503,5 @@ $phone_providers = [
     [ 'name' => 'kachong70_ye', 'cfg' => $kachong70_ye_phone ],
     [ 'name' => 'canbin_sec', 'cfg' => $canbin_sec_phone ],
     [ 'name' => 'zhixinzhuanch', 'cfg' => $zhixinzhuanch_phone ],
+    [ 'name' => 'jinyu', 'cfg' => $jinyu_phone ],
 	];

+ 18 - 0
helper/refill/api/xyz/jinyu/API.MD

@@ -0,0 +1,18 @@
+## 金羽快充1号-游来(含)
+### 全国账户:
+- 后台:http://121.199.28.63:10186/plat/login
+- 账户:youlai
+- 密码:123456aa
+
+- ID:100030
+- 秘钥:c592c7bb115c47ad8ee62da7bb7d11d5
+
+### API
+- 提单地址:http://121.199.28.63:10186/plat/api/hf/submitorder
+- 查单地址:http://121.199.28.63:10186/plat/api/queryorder
+- 余额查询地址:http://121.199.28.63:10186/plat/api/querybalance
+- 对接文档地址:https://docs.qq.com/doc/DWEhQWEhDVEJIdUVC
+
+### 店铺账号
+- jinyu
+- jinyu67890

+ 51 - 0
helper/refill/api/xyz/jinyu/RefillCallBack.php

@@ -0,0 +1,51 @@
+<?php
+namespace refill\jinyu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jinyu/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) {
+            $official_sn = strtolower($params['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            $data['official_sn'] = $official_sn;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true, $official_sn];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, true, true, ''];
+        }
+        else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 143 - 0
helper/refill/api/xyz/jinyu/RefillPhone.php

@@ -0,0 +1,143 @@
+<?php
+
+namespace refill\jinyu;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jinyu/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'] = '';
+        $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 (in_array($nRtn, [2050, 999], true)) {
+                $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, '网络错误', ''];
+            }
+            $offical_sn = '';
+            $status = $resp['nRtn'];
+            if ($status === 5012) {
+                $offical_sn = $resp['szRtnMsg'];
+                $updata['official_sn'] = $offical_sn;
+                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'], $offical_sn];
+            }
+
+            return [true, $order_state, $offical_sn];
+        }
+    }
+
+    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/jinyu/config.php

@@ -0,0 +1,27 @@
+<?php
+
+
+namespace refill\jinyu;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.199.28.63:10186/plat/api/hf/submitorder';
+    const QUERY_URL= 'http://121.199.28.63:10186/plat/api/queryorder';
+    const BALANCE_URL = 'http://121.199.28.63:10186/plat/api/querybalance';
+
+    const USER_ID= '100030';
+    const KEY = 'c592c7bb115c47ad8ee62da7bb7d11d5';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jinyu.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
+    ];
+}

+ 4 - 0
mobile/callback/refill_jinyu.php

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

+ 6 - 0
test/TestRefill.php

@@ -6626,6 +6626,12 @@ class TestRefill extends TestCase
         $provider = $this->getProvider('dexin_fs');
         $resp = $provider->balance();
     }
+
+    public function testjinyu()
+    {
+        $provider = $this->getProvider('jinyu');
+        $resp = $provider->balance();
+    }
 }