xiaoyu 3 lat temu
rodzic
commit
22c5959ea0

+ 53 - 0
data/config/win/refill.ini.php

@@ -3314,6 +3314,58 @@ $meixu_phone = ['name' => 'meixu', 'store_id' => 160,'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$fuyuan_phone = ['name' => 'fuyuan', 'store_id' => 161,'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7357, 'price' => 10.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7357, 'price' => 9.98, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7357, 'price' => 10.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        20 => [
+            ['goods_id' => 7358, 'price' => 20.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7358, 'price' => 19.96, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7358, 'price' => 20.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        30 => [
+            ['goods_id' => 7359, 'price' => 30.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7359, 'price' => 29.94, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7359, 'price' => 30.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        50 => [
+            ['goods_id' => 7360, 'price' => 50.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7360, 'price' => 49.9, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7360, 'price' => 50.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        100 => [
+            ['goods_id' => 7361, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7361, 'price' => 99.8, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7361, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        200 => [
+            ['goods_id' => 7362, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7362, 'price' => 199.6, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7362, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        300 => [
+            ['goods_id' => 7363, 'price' => 300.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7363, 'price' => 299.4, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7363, 'price' => 300.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        500 => [
+            ['goods_id' => 7364, 'price' => 500.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7364, 'price' => 499, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7364, 'price' => 500.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3438,6 +3490,7 @@ $phone_providers = [
     ['name' => 'yiqian', 'cfg' => $yiqian_phone],
     ['name' => 'yinghuochong', 'cfg' => $yinghuochong_phone],
     ['name' => 'meixu', 'cfg' => $meixu_phone],
+    ['name' => 'fuyuan', 'cfg' => $fuyuan_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -3314,6 +3314,58 @@ $meixu_phone = ['name' => 'meixu', 'store_id' => 160,'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$fuyuan_phone = ['name' => 'fuyuan', 'store_id' => 161,'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7357, 'price' => 10.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7357, 'price' => 9.98, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7357, 'price' => 10.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        20 => [
+            ['goods_id' => 7358, 'price' => 20.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7358, 'price' => 19.96, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7358, 'price' => 20.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        30 => [
+            ['goods_id' => 7359, 'price' => 30.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7359, 'price' => 29.94, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7359, 'price' => 30.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        50 => [
+            ['goods_id' => 7360, 'price' => 50.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7360, 'price' => 49.9, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7360, 'price' => 50.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        100 => [
+            ['goods_id' => 7361, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7361, 'price' => 99.8, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7361, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        200 => [
+            ['goods_id' => 7362, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7362, 'price' => 199.6, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7362, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        300 => [
+            ['goods_id' => 7363, 'price' => 300.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7363, 'price' => 299.4, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7363, 'price' => 300.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        500 => [
+            ['goods_id' => 7364, 'price' => 500.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7364, 'price' => 499, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7364, 'price' => 500.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3438,6 +3490,7 @@ $phone_providers = [
     ['name' => 'yiqian', 'cfg' => $yiqian_phone],
     ['name' => 'yinghuochong', 'cfg' => $yinghuochong_phone],
     ['name' => 'meixu', 'cfg' => $meixu_phone],
+    ['name' => 'fuyuan', 'cfg' => $fuyuan_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 53 - 0
data/config/xyzadm/refill.ini.php

@@ -3314,6 +3314,58 @@ $meixu_phone = ['name' => 'meixu', 'store_id' => 160,'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$fuyuan_phone = ['name' => 'fuyuan', 'store_id' => 161,'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7357, 'price' => 10.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7357, 'price' => 9.98, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7357, 'price' => 10.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        20 => [
+            ['goods_id' => 7358, 'price' => 20.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7358, 'price' => 19.96, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7358, 'price' => 20.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        30 => [
+            ['goods_id' => 7359, 'price' => 30.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7359, 'price' => 29.94, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7359, 'price' => 30.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        50 => [
+            ['goods_id' => 7360, 'price' => 50.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7360, 'price' => 49.9, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7360, 'price' => 50.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        100 => [
+            ['goods_id' => 7361, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7361, 'price' => 99.8, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7361, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        200 => [
+            ['goods_id' => 7362, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7362, 'price' => 199.6, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7362, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        300 => [
+            ['goods_id' => 7363, 'price' => 300.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7363, 'price' => 299.4, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7363, 'price' => 300.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+
+        500 => [
+            ['goods_id' => 7364, 'price' => 500.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7364, 'price' => 499, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7364, 'price' => 500.2, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3438,6 +3490,7 @@ $phone_providers = [
     ['name' => 'yiqian', 'cfg' => $yiqian_phone],
     ['name' => 'yinghuochong', 'cfg' => $yinghuochong_phone],
     ['name' => 'meixu', 'cfg' => $meixu_phone],
+    ['name' => 'fuyuan', 'cfg' => $fuyuan_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 49 - 0
helper/refill/api/xyz/fuyuan/RefillCallBack.php

@@ -0,0 +1,49 @@
+<?php
+namespace refill\fuyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/fuyuan/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)
+    {
+        $agentid = config::AGENT_ID;
+        $key = config::KEY;
+        $content = "agentid={$agentid}&mobile_num={$params['mobile_num']}&charge_time={$params['charge_time']}&operator={$params['operator']}";
+        $content .= "&fy_order_no={$params['fy_order_no']}&cp_order_no={$params['cp_order_no']}&amount={$params['amount']}&status={$params['status']}&key={$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['cp_order_no'];
+        $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 === 3) {
+            $data['official_sn'] = strtolower($params['flowNo']) == 'null' ? '' : $params['flowNo'];
+            $data['ch_trade_no'] = strtolower($params['fy_order_no']) == 'null' ? '' : $params['fy_order_no'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true];
+        } elseif ($status === 4 || $status === 6) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 156 - 0
helper/refill/api/xyz/fuyuan/RefillPhone.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace refill\fuyuan;
+
+require_once(BASE_HELPER_RAPI_PATH . '/fuyuan/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, $card_type, string $order_sn)
+    {
+        $params['agentid'] = config::AGENT_ID;
+        $params['mobilenum'] = $phone;
+        $params['money'] = $amount;
+        $params['orderid'] = $order_sn;
+        $params['price'] = '';
+        $params['line'] = '';
+        $params['productid'] = '';
+        $params['operators'] = config::operator[$card_type];
+
+        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['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 = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $result = $resp['result'];
+            if ($result === '0000') {
+                return [true, '', false];
+            } elseif (in_array($result, config::ERR_NOS, true)) {
+                return [false, $result, false];
+            } elseif ($result === '1004') {
+                $net_errno = "HTTP-{$result}";
+                return [false, $result, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $result, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['agentid'] = config::AGENT_ID;
+        $params['orderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "agentid={$params['agentid']}&orderid={$params['orderid']}&key={$key}";
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params);
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            elseif($resp['result'] === '0000')
+            {
+                $status = $resp['state'];
+                if ($status === '3') {
+                    $updata['official_sn'] = $resp['flowNo'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($status, ['4','6'], true)) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, ['0','1'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+
+                return [true, $order_state];
+            }
+            elseif ($resp['result'] === '1013' && (time() - $refill_info['commit_time'] > 600))
+            {
+                $order_state = ORDER_STATE_NOEXIST;
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['result']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['agentid'] = config::AGENT_ID;
+        $key = config::KEY;
+        $content = "agentid={$params['agentid']}&key={$key}";
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::BALANCE_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['result'] === '0000') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['result']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $key = config::KEY;
+        $content = "agentid={$params['agentid']}&mobilenum={$params['mobilenum']}&money={$params['money']}&orderid={$params['orderid']}&productid={$params['productid']}";
+        $content .= "&key={$key}";
+        return md5($content);
+    }
+
+    public function xmlToArray($xml)
+    {
+        return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+    }
+}

+ 7 - 0
helper/refill/api/xyz/fuyuan/api.txt

@@ -0,0 +1,7 @@
+商户编号:100354
+商户秘钥:FTxjJs88iD81C6vY6kRvD7CAjP9B0s5r
+接口地址:http://api.miaochongwang.com:8003/
+
+cz.miaochongwang.com
+bjyezi
+754123

+ 25 - 0
helper/refill/api/xyz/fuyuan/config.php

@@ -0,0 +1,25 @@
+<?php
+
+
+namespace refill\fuyuan;
+
+use mtopcard;
+class config
+{
+    //回调地址需上游配置
+    const ORDER_URL = 'http://api.miaochongwang.com:8003/dopay.aspx';
+    const QUERY_URL= 'http://api.miaochongwang.com:8003/orderquery.aspx';
+    const BALANCE_URL = 'http://api.miaochongwang.com:8003/balance.aspx';
+
+    const AGENT_ID = '100354';
+    const KEY = 'FTxjJs88iD81C6vY6kRvD7CAjP9B0s5r';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_fuyuan.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => '移动',
+        mtopcard\ChinaUnicomCard  => '联通',
+        mtopcard\ChinaTelecomCard => '电信'
+    ];
+    const ERR_NOS = [
+        '1001','1002','1003','1005','1006','1007','1008','1009','1010','1011','1012'
+    ];
+}

BIN
helper/refill/api/xyz/fuyuan/福缘话费充值接口文档v211102.doc


+ 5 - 0
mobile/callback/refill_fuyuan.php

@@ -0,0 +1,5 @@
+<?php
+
+refill\util::push_notify('fuyuan',$_POST);
+$content = "agentid={$_POST['agentid']}&cp_order_no={$_POST['cp_order_no']}&fy_order_no={$_POST['fy_order_no']}&ret_result=0000";
+echo $content;

+ 14 - 0
test/TestRefill.php

@@ -1460,6 +1460,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testFuyuan()
+    {
+//        $provider = $this->getProvider('fuyuan');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 10, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '60431637736327027514']);
+
+        $body = '{"agentid":"100354","mobile_num":"13699279618","charge_time":"20211124","operator":"\u79fb\u52a8","fy_order_no":"333876728","cp_order_no":"60431637736327027514","amount":"10","status":"3","sign":"3a271b104cb0c9d6d157e75e538c6b11","remark":"\u5145\u503c\u6210\u529f","flowNo":""}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('fuyuan','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);