Browse Source

xyz qianqian_fs_gd

xiaoyu 2 năm trước cách đây
mục cha
commit
5425c5fa3d

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

@@ -7172,6 +7172,19 @@ $dazhanggui_fs_gd_phone = ['name' => 'dazhanggui_fs_gd', 'store_id' => 264, 'qua
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$qianqian_fs_gd_phone = ['name' => 'qianqian_fs_gd', 'store_id' => 265, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8207, 'price' => 9.73, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        20 => [['goods_id' => 8208, 'price' => 19.46, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        30 => [['goods_id' => 8209, 'price' => 29.19, 'quality' => 1, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 8210, 'price' => 48.65, 'quality' => 1, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 8211, 'price' => 97.3, 'quality' => 1, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 8212, 'price' => 194.6, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 8213, 'price' => 291.9, 'quality' => 1, 'card_type' => 'chinamobile']],
+//        500 => [['goods_id' => 8214, 'price' => 486.5, 'quality' => 1, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7392,6 +7405,8 @@ $phone_providers = [
     ['name' => 'wanxin', 'cfg' => $wanxin_phone],
     ['name' => 'yuewen', 'cfg' => $yuewen_phone],
     ['name' => 'meixu_fs', 'cfg' => $meixu_fs_phone],
+    ['name' => 'dazhanggui_fs_gd', 'cfg' => $dazhanggui_fs_gd_phone],
+    ['name' => 'qianqian_fs_gd', 'cfg' => $qianqian_fs_gd_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 46 - 0
helper/refill/api/xyz/qianqian_fs_gd/RefillCallBack.php

@@ -0,0 +1,46 @@
+<?php
+namespace refill\qianqian_fs_gd;
+require_once(BASE_HELPER_RAPI_PATH . '/qianqian_fs_gd/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $signature = [config::KEY, $params['timestamp'], config::ACCOUNT];
+        sort($signature, SORT_STRING);
+        $signature = implode($signature);
+        return sha1($signature);
+    }
+
+    public function notify($params)
+    {
+        $status = $params['status'];
+        $order_sn = $params['consumerNo'];
+        $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 === '001') {
+            $data['official_sn'] = strtolower($params['voucherNo']) == 'null' ? '' : $params['voucherNo'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif (in_array($status,config::NotifyErrCodes, true)) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 174 - 0
helper/refill/api/xyz/qianqian_fs_gd/RefillPhone.php

@@ -0,0 +1,174 @@
+<?php
+
+namespace refill\qianqian_fs_gd;
+
+require_once(BASE_HELPER_RAPI_PATH . '/qianqian_fs_gd/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    public function goods($quality,int $amount,int $card_type,$regin_no,$other)
+    {
+        [$goods_id, $price] = parent::goods($quality,$amount,$card_type,$regin_no,$other);
+        if($goods_id <= 0) return [0,0];
+        $key = "{$card_type}-{$amount}-{$regin_no}";
+        $price = config::Price[$key];
+        if(empty($price)) {
+            Log::record("channel cannot find price where name={$this->mName}, goods_id = {$goods_id} card_type={$card_type} amount={$amount} regin_no={$regin_no}",Log::ERR);
+            return [0,0];
+        } else {
+            return [$goods_id,ncPriceFormat($price)];
+        }
+    }
+
+
+    private function req_params(int $phone, int $card_type, string $order_sn)
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['consumerNo'] = $order_sn;
+        $params['mobile'] = $phone;
+        $params['ispCode'] = config::operator[$card_type];
+        $params['cbkUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = $this->get_millisecond();
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $regin_no = $params['regin_no'] ?? -1;
+        if($regin_no <= 0) {
+            return [false, '省份获取错误', false];
+        }
+        $params = $this->req_params($card_no, $card_type, $params['order_sn']);
+        $params['flowCode'] = config::ProductIDS[$card_type][$regin_no][$amount];
+        if (empty($params['flowCode'])) {
+            return [false, '产品编号错误', false];
+        }
+
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'GET', false, [], $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['status'] === '001') {
+                return [true, $resp['orderNo'], false];
+            } else {
+                return [false, $resp['status'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['consumerNo'] = $refill_info['order_sn'];
+        $params['timestamp'] = $this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::QUERY_URL, $params);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+
+            $status = $resp['status'];
+            if ($status === '001')
+            {
+                $order_state = ORDER_STATE_SUCCESS;
+                $save['official_sn'] = strtolower($resp['voucherNo']) == 'null' ? '' : $resp['voucherNo'];
+                Model('refill_order')->edit($refill_info['order_id'], $save);
+            }
+            elseif (in_array($status,config::QueryErrCodes, true))
+            {
+                if ($status === '026')
+                {
+                    //订单不存在状态,三小时内查询可失败,超过则返回充值中.不可以在下单后的同时立马发起查询,否则返回该状态处理为充值中,至少隔30秒以上再发起查询
+                    $commit_secs = time() - $refill_info['commit_time'];
+                    if ($commit_secs > 0 && $commit_secs <= 180) {
+                        return [false, '时长不足'];
+                    } elseif ($commit_secs > 180 && $commit_secs <= 10800) {
+                        $order_state = ORDER_STATE_NOEXIST;
+                    } else {
+                        $order_state = ORDER_STATE_SEND;
+                    }
+                }
+                else {
+                    $order_state = ORDER_STATE_CANCEL;
+                }
+            }
+            elseif ($status === '002') {
+                $order_state = ORDER_STATE_SEND;
+            }
+            else {
+                return [false, $status];
+            }
+
+            return [true, $order_state];
+        }
+    }
+
+    public function balance()
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['timestamp'] = $this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::BALANCE_URL, $params);
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            } elseif ($resp['status'] === 'success') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['descriptor']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $signature = [config::KEY, $params['timestamp'], config::ACCOUNT];
+        sort($signature, SORT_STRING);
+        $signature = implode($signature);
+        return sha1($signature);
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        $cur = microtime (true);
+        return intval($cur * 1000);
+    }
+}

+ 44 - 0
helper/refill/api/xyz/qianqian_fs_gd/config.php

@@ -0,0 +1,44 @@
+<?php
+
+
+namespace refill\qianqian_fs_gd;
+use mtopcard;
+
+class config
+{
+    const ORDER_URL = 'http://116.62.12.248/flow-receiver/api/recharge/feecbk';
+    const QUERY_URL = 'http://116.62.12.248/flow-receiver/api/query/feecbk';
+    const BALANCE_URL = 'http://116.62.12.248/flow-receiver/api/balance/feecbk';
+    const NOTIFY_URL = BASE_SITE_URL . '/mobile/callback/refill_qianqian_fs_gd.php';
+
+    const ACCOUNT = 'wlyezhigdfs';
+    const KEY = '97bb99311f814e779923644cc2be5a8c';
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'CMCC',
+        mtopcard\ChinaUnicomCard  => 'CUCC',
+        mtopcard\ChinaTelecomCard => 'CTCC'
+    ];
+    const ProductIDS = [
+        mtopcard\ChinaMobileCard => [
+            //广东
+            19 => [
+                50 => 'CMCCGDr50r',
+                100 => 'CMCCGDr100r',
+                200 => 'CMCCGDr200r'
+            ],
+        ]
+    ];
+
+    const NotifyErrCodes = [
+        '003','004','005','006','007','008','015','016','017','018','019','020','021','022','023','025','027','028','098','099'
+    ];
+
+    const QueryErrCodes = [
+        '003','004','005','006','007','008','015','016','017','018','019','020','021','022','023','024','025','026','027','028','098','099'
+    ];
+
+    const Price = [
+        // 移动
+        "4-50-19" => 48, "4-100-19" => 96, "4-200-19" => 192,//广东 19
+    ];
+}

+ 23 - 0
helper/refill/api/xyz/qianqian_fs_gd/椰子.txt

@@ -0,0 +1,23 @@
+
+账号:wlyezhigdfs
+密码:yz123456
+密钥:97bb99311f814e779923644cc2be5a8c
+
+客户后台地址:http://116.62.12.248/flow-consumer/login.html
+
+下单地址
+http://116.62.12.248/flow-receiver/api/recharge/feecbk
+查询地址
+http://116.62.12.248/flow-receiver/api/query/feecbk
+余额查询地址
+http://116.62.12.248/flow-receiver/api/balance/feecbk
+
+
+请务必绑定我们回调IP:116.62.12.248
+
+产品编码可登录客户后台查看:个人信息>产品编码
+
+广东移动产品编码		面值
+CMCCGDr50r				50
+CMCCGDr100r				100
+CMCCGDr200r				200

BIN
helper/refill/api/xyz/qianqian_fs_gd/话费API接口文档.docx


+ 14 - 0
test/TestRefill.php

@@ -2791,6 +2791,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testQianqian_fs_gd()
+    {
+//        $provider = $this->getProvider('qianqian_fs_gd');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(15811535608, 4, 50, ['order_sn' => $this->make_sn(), 'regin_no' => 19]);
+//        $resp = $provider->query(['order_sn' => '17721668570001406531']);
+
+        $body = '{"status":"019","orderNo":"F2211161140175529547","consumerNo":"17721668570001406531","mobile":"15811535608","voucherNo":"null","account":"wlyezhigdfs","timestamp":"1668570018003","sign":"f709d1f3e3fa0d527c2c3f0b7453c2d667b3d9c0"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('qianqian_fs_gd', 'RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);