xiaoyu 1 éve
szülő
commit
e20c7c053a

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

@@ -9348,6 +9348,51 @@ $by_online_mix_cb_phone = ['name' => 'by_online_mix_cb', 'store_id' => 352, 'qua
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$feihan_hf_phone = ['name' => 'feihan_hf', 'store_id' => 353, 'qualitys' => '2',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8829, 'price' => 10.24, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8829, 'price' => 10.09, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8829, 'price' => 10.23, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 8830, 'price' => 20.48, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8830, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8830, 'price' => 20.26, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 8831, 'price' => 30.105, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8831, 'price' => 30.135, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8831, 'price' => 30.135, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+        50 => [
+//            ['goods_id' => 8832, 'price' => 49.7, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8832, 'price' => 50.05, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8832, 'price' => 49.7, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8833, 'price' => 100.15, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8833, 'price' => 100.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8833, 'price' => 100.3, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8834, 'price' => 200.3, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8834, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8834, 'price' => 200.6, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 8835, 'price' => 300.45, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8835, 'price' => 300.3, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8835, 'price' => 300.9, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 8836, 'price' => 500.75, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8836, 'price' => 501, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8836, 'price' => 501.5, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -9636,6 +9681,7 @@ $phone_providers = [
     ['name' => 'hunchongby', 'cfg' => $hunchongby_phone],
     ['name' => 'juhu', 'cfg' => $juhu_phone],
     ['name' => 'by_online_mix_cb', 'cfg' => $by_online_mix_cb_phone],
+    ['name' => 'feihan_hf', 'cfg' => $feihan_hf_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 35 - 0
helper/refill/api/xyz/feihan_hf/RefillCallBack.php

@@ -0,0 +1,35 @@
+<?php
+namespace refill\feihan_hf;
+
+require_once(BASE_HELPER_RAPI_PATH . '/feihan_hf/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        return true;
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['ret_code']);
+        $order_sn = $params['sporder_id'];
+        $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 === 1) {
+            $official_sn = strtolower($params['serial_no']) == 'null' ? '' : $params['serial_no'];
+            $data['official_sn'] = $official_sn;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 9) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 167 - 0
helper/refill/api/xyz/feihan_hf/RefillPhone.php

@@ -0,0 +1,167 @@
+<?php
+
+namespace refill\feihan_hf;
+
+require_once(BASE_HELPER_RAPI_PATH . '/feihan_hf/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $card_no, int $amount, int $card_type, string $order_sn)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['userpws'] = md5(config::USER_PWS);
+        $params['cardid'] = config::goods_id;
+        $params['cardnum'] = $amount;
+        $params['sporder_id'] = $order_sn;
+        $params['sporder_time'] = date("YmdHis");
+        $params['game_userid'] = $card_no;
+        $params['ret_url'] = config::NOTIFY_URL;
+        $params['version'] = '6.0';
+        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['md5_str'] = $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 = $this->xmlToArray($resp);
+
+            $retCode = $resp['retcode'];
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            } elseif ($retCode === '1') {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($retCode, config::ERR_NOS, true)) {
+                return [false, $resp['err_msg'], false];
+            } elseif ($retCode === '9999') {
+                $net_errno = "HTTP-{$retCode}";
+                return [false, $resp['err_msg'], true];
+            } else {
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['err_msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['userpws'] = md5(config::USER_PWS);
+        $params['sporder_id'] = $refill_info['order_sn'];
+        $params['version'] = '6.0';
+
+        $key = config::KEY;
+        $content = "{$params['userid']}{$params['userpws']}{$params['sporder_id']}{$key}";
+        $params['md5_str'] = strtoupper(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 = $this->xmlToArray($resp, 'GB2312');
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            elseif ($resp['retcode'] === '1')
+            {
+                $status = $resp['game_state'];
+                if ($status === '1') {
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '0') {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['err_msg']];
+                }
+                return [true, $order_state];
+            }
+            elseif ($resp['retcode'] === '1010' && (time() - $refill_info['commit_time'] > 600))
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else
+            {
+                return [false, $resp['err_msg']];
+
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $params['userpws'] = md5(config::USER_PWS);
+        $params['version'] = '6.0';
+
+        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp, 'GB2312');
+
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['retcode'] === '1') {
+                return [true, $resp['totalBalance']];
+            } else {
+                return [false, $resp['err_msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content = "{$params['userid']}{$params['userpws']}{$params['cardid']}{$params['cardnum']}{$params['sporder_id']}{$params['sporder_time']}{$params['game_userid']}";
+        $content .= $key;
+        return strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml, $encode = 'GBK')
+    {
+        $getEncoder = function ($xml,$default_encode)
+        {
+            $ret = preg_match("/<?xml\s+[\s\S]*(encoding=[\"']([^\"']*)[\"'])[\s\S]*?>/", $xml, $res);
+            if($ret !== false && count($res) === 3) {
+                return [$res[2], $res[1]];
+            } else {
+                return [$default_encode,'encoding="' . $default_encode . '"'];
+            }
+        };
+
+        [$encode, $replace_str] = $getEncoder($xml, $encode);
+        $xml = mb_convert_encoding($xml,"utf-8","{$encode}");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
+    }
+}

+ 20 - 0
helper/refill/api/xyz/feihan_hf/api.txt

@@ -0,0 +1,20 @@
+userid:A230801001
+userpws:F0EC8B1E2BC73541
+keystr:D10CD71CA9AFD303
+
+
+测试环境账号:
+userid:A08566
+userpws:of111111    需要 MD5 小写
+秘钥(keystr):OFCARD
+测试号码:15715155515
+
+http://openapi.ofpay.com
+
+话费商品编码:140101
+
+ret_code                充值状态     1成功   9失败
+ordersuccesstime   充值完成时间
+sporder_id             外部订单号
+err_msg                 失败原因
+serial_no                官方流水号

+ 21 - 0
helper/refill/api/xyz/feihan_hf/config.php

@@ -0,0 +1,21 @@
+<?php
+namespace refill\feihan_hf;
+
+class config
+{
+    const ORDER_URL = 'http://api2.ofpay.com/onlineorder.do';
+    const QUERY_URL= 'http://api2.ofpay.com/queryOrderInfo.do';
+    const BALANCE_URL = 'http://api2.ofpay.com/newqueryuserinfo.do';
+
+    const USER_ID = 'A230801001';
+    const USER_PWS = 'F0EC8B1E2BC73541';
+    const KEY = 'D10CD71CA9AFD303';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_feihan_hf.php";
+
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERR_NOS = [
+        '4001', '1037', '9998', '331', '321', '319', '1008', '1007', '1005', '1004', '1003', '1002', '11', '1001'
+    ];
+
+    const goods_id = 140101;
+}

BIN
helper/refill/api/xyz/feihan_hf/飞翰话费报价-20230801(国研).xlsx


+ 4 - 0
mobile/callback/refill_feihan_hf.php

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

+ 12 - 0
test/TestRefill.php

@@ -3590,6 +3590,18 @@ class TestRefill extends TestCase
         $resp = $provider->balance();
     }
 
+    public function testFeihan_hf()
+    {
+        //        $provider = $this->getProvider('feihan_hf');
+//        $resp = $provider->add(15715155515, 4, 50, ['order_sn' => $this->make_sn(), 'regin_no' => 1]);
+
+        $body = '{"err_msg":"","ordersuccesstime":"20230802150200","sign":"52920F6CECE7DE9ACE4A0A0224DEFD0C","sporder_id":"58431690957151281598","userid":"A08566","ret_code":"1"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('feihan_hf','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);