Browse Source

xyz jinfeng_fs

xiaoyu 2 years ago
parent
commit
fc2f2064ca

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

@@ -6862,6 +6862,19 @@ $weixue_yi_phone = ['name' => 'weixue_yi', 'store_id' => 250, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$jinfeng_fs_phone = ['name' => 'jinfeng_fs', 'store_id' => 251, 'qualitys' => '1',
+    'amount' => [
+//        10 => [['goods_id' => 8079, 'price' => 9.5, 'quality' => 1, 'card_type' => 'chinatelecom']],
+//        20 => [['goods_id' => 8080, 'price' => 19, 'quality' => 1, 'card_type' => 'chinatelecom']],
+        30 => [['goods_id' => 8081, 'price' => 28.5, 'quality' => 1, 'card_type' => 'chinatelecom']],
+        50 => [['goods_id' => 8082, 'price' => 47.5, 'quality' => 1, 'card_type' => 'chinatelecom']],
+        100 => [['goods_id' => 8083, 'price' => 95, 'quality' => 1, 'card_type' => 'chinatelecom']],
+        200 => [['goods_id' => 8084, 'price' => 190, 'quality' => 1, 'card_type' => 'chinatelecom']],
+//        300 => [['goods_id' => 8085, 'price' => 285, 'quality' => 1, 'card_type' => 'chinatelecom']],
+//        500 => [['goods_id' => 8086, 'price' => 475, 'quality' => 1, 'card_type' => 'chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -7069,6 +7082,7 @@ $phone_providers = [
     ['name' => 'dazhanggui_fs', 'cfg' => $dazhanggui_fs_phone],
     ['name' => 'feimingyu_high', 'cfg' => $feimingyu_high_phone],
     ['name' => 'weixue_yi', 'cfg' => $weixue_yi_phone],
+    ['name' => 'jinfeng_fs', 'cfg' => $jinfeng_fs_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 34 - 0
helper/refill/api/xyz/jinfeng_fs/RefillCallBack.php

@@ -0,0 +1,34 @@
+<?php
+namespace refill\jinfeng_fs;
+require_once(BASE_HELPER_RAPI_PATH . '/jinfeng_fs/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+       return true;
+    }
+
+    public function notify($params)
+    {
+        $status = $params['status'];
+        $order_sn = $params['consumerNo'];
+
+        $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 === '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)) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 149 - 0
helper/refill/api/xyz/jinfeng_fs/RefillPhone.php

@@ -0,0 +1,149 @@
+<?php
+
+namespace refill\jinfeng_fs;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jinfeng_fs/config.php');
+
+use refill;
+use Log;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, string $order_sn)
+    {
+        $params['account'] = config::ACCOUNT;
+        $params['consumerNo'] = $order_sn;
+        $params['mobile'] = $phone;
+        $params['timestamp'] = date("YmdHis");
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $params['order_sn']);
+        $params['flowCode'] = config::ProductIDS[$card_type][$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'] = date("YmdHis");
+        $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))
+            {
+                if ($status === '026')
+                {
+                    //订单不存在状态,三小时内查询可失败,超过则返回充值中.不可以在下单后的同时立马发起查询,否则返回该状态处理为充值中,至少隔30秒以上再发起查询
+                    $commit_secs = time() - $refill_info['commit_time'];
+                    if ($commit_secs > 0 && $commit_secs < 30) {
+                        return [false, '时长不足'];
+                    } elseif ($commit_secs <= 10800 && $commit_secs >= 30) {
+                        $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'] = date("YmdHis");
+        $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)
+    {
+        $data['account'] = $params['account'];
+        $data['timestamp'] = $params['timestamp'];
+        $data['secret'] = config::KEY;
+        asort($data);
+        $content = '';
+        foreach ($data as $val){
+            $content .= $val;
+        }
+        return sha1($content);
+    }
+}

+ 36 - 0
helper/refill/api/xyz/jinfeng_fs/config.php

@@ -0,0 +1,36 @@
+<?php
+
+
+namespace refill\jinfeng_fs;
+use mtopcard;
+
+class config
+{
+    //回调地址需配置
+    const ORDER_URL = 'http://47.108.199.201/flow-receiver/fee/recharge';
+    const QUERY_URL = 'http://47.108.199.201/flow-receiver/fee/query/single';
+    const BALANCE_URL = 'http://47.108.199.201/flow-receiver/fee/balance/query';
+    const NOTIFY_URL = BASE_SITE_URL . '/mobile/callback/refill_jinfeng_fs.php';
+    const ACCOUNT = 'jfyzdxfs';
+    const KEY = 'e42ab28c0b4d4c02947b31ee769d825b';
+
+    const ProductIDS = [
+        mtopcard\ChinaMobileCard => [
+
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30 => 'CTCCALLr30r', 50 => 'CTCCALLr50r', 100 => 'CTCCALLr100r', 200 => 'CTCCALLr200r',
+        ]
+    ];
+
+    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'
+    ];
+}

+ 19 - 0
helper/refill/api/xyz/jinfeng_fs/北京国研.txt

@@ -0,0 +1,19 @@
+账号:jfyzdxfs
+密钥:e42ab28c0b4d4c02947b31ee769d825b
+
+http://47.108.199.201/flow-consumer/login.html
+jfyzdxfs
+jfyzdxfs
+
+下单地址
+http://47.108.199.201/flow-receiver/fee/recharge
+查询地址
+http://47.108.199.201/flow-receiver/fee/query/single
+余额查询地址
+http://47.108.199.201/flow-receiver/fee/balance/query
+
+
+CTCCALLr30r  电信30
+CTCCALLr50r  电信50
+CTCCALLr100r  电信100
+CTCCALLr200r  电信200

File diff suppressed because it is too large
+ 3 - 0
helper/refill/api/xyz/jinfeng_fs/话费充值接口v1.1.doc


+ 10 - 0
mobile/callback/refill_jinfeng_fs.php

@@ -0,0 +1,10 @@
+<?php
+
+$content = $_SERVER['post_content'];
+
+$inputs = json_decode($content,true) ?? [];
+foreach ($inputs as $input) {
+    refill\util::push_notify('jinfeng_fs',$input);
+}
+
+echo ('SUCCESS');

+ 14 - 0
test/TestRefill.php

@@ -2592,6 +2592,20 @@ class TestRefill extends TestCase
         $resp = $provider->balance();
     }
 
+    public function testJinfeng_fs()
+    {
+//        $provider = $this->getProvider('jinfeng_fs');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(18010110637, 6, 30, ['order_sn' => $this->make_sn(), 'regin_no' =>18]);
+//        $resp = $provider->query(['order_sn' => '67481665209341012765']);
+
+        $body = '{"orderNo":"F2210081409124193922","status":"019","consumerNo":"67481665209341012765","voucherNo":null,"mobile":"18010110637"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('jinfeng_fs', 'RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);