haru haru 2 lat temu
rodzic
commit
2cebcaa6f3

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

@@ -5998,6 +5998,51 @@ $yuke_phone = ['name' => 'yuke', 'store_id' => 227, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$chizeng_yi_phone = ['name' => 'chizeng_yi', 'store_id' => 228, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7894, 'price' => 9.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7894, 'price' => 9.44, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7894, 'price' => 9.53, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7895, 'price' => 19.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7895, 'price' => 18.88, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7895, 'price' => 19.06, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 7896, 'price' => 29.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7896, 'price' => 28.32, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7896, 'price' => 28.59, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        50 => [
+            ['goods_id' => 7897, 'price' => 49, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7897, 'price' => 47.2, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7897, 'price' => 47.65, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7898, 'price' => 98, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7898, 'price' => 94.4, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7898, 'price' => 95.3, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7899, 'price' => 196, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7899, 'price' => 188.8, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7899, 'price' => 190.6, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 7900, 'price' => 294, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7900, 'price' => 283.2, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7900, 'price' => 285.9, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 7901, 'price' => 490, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7901, 'price' => 472, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7901, 'price' => 476.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6183,6 +6228,8 @@ $phone_providers = [
     ['name' => 'liantongzx', 'cfg' => $liantongzx_phone],
     ['name' => 'bodian', 'cfg' => $bodian_phone],
     ['name' => 'yuke', 'cfg' => $yuke_phone],
+    ['name' => 'chizeng_yi', 'cfg' => $chizeng_yi_phone],
+
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 48 - 0
helper/refill/api/xyz/chizeng_yi/RefillCallBack.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\chizeng_yi;
+
+require_once(BASE_HELPER_RAPI_PATH . '/chizeng_yi/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)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&orderid={$params['orderid']}&sporderid={$params['sporderid']}&merchantsubmittime={$params['merchantsubmittime']}";
+        $content .= "&resultno={$params['resultno']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['resultno']);
+        $order_sn = $params['sporderid'];
+        $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 === 1) {
+            $data['official_sn'] = strtolower($params['remark1']) == 'null' ? '' : $params['remark1'];
+            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];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/xyz/chizeng_yi/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\chizeng_yi;
+
+require_once(BASE_HELPER_RAPI_PATH . '/chizeng_yi/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['userid'] = config::USER_ID;
+        $params['productid'] = config::ProductIdS[$card_type][$amount];
+        $params['price'] = $amount;
+        $params['num'] = 1;
+        $params['mobile'] = $phone;
+        $params['spordertime'] = date("YmdHis");
+        $params['sporderid'] = $order_sn;
+        $params['back_url'] = config::NOTIFY_URL;
+        $params['paytype'] = 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, 'POST', false, config::ExtHeaders, $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+
+            $resultno = $resp['resultno'];
+            if (in_array($resultno, ['0', '2'], true)) {
+                return [true, $resp['orderid'], false];
+            } elseif (in_array($resultno, config::ERR_NOS, true)) {
+                return [false, $resultno, false];
+            } elseif ($resultno === '9999' || $resultno === '5006') {
+                $net_errno = "HTTP-{$resultno}";
+                return [false, $resultno, true];
+            } else {
+                //未知结果码
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resultno, true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['userid'] = config::USER_ID;
+        $params['sporderid'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&sporderid={$params['sporderid']}&key={$key}";
+        $params['sign'] = 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);
+            if (empty($resp))
+            {
+                return [false, '网络错误'];
+            }
+            else
+            {
+                $resultno = $resp['resultno'];
+                if ($resultno === '1') {
+                    $updata['official_sn'] = $resp['remark1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($resultno === '9') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($resultno, ['0','2'], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($resultno === '5007' && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resultno];
+                }
+
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['userid'] = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$params['userid']}&key={$key}";
+        $params['sign'] = strtoupper(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 = $this->xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['resultno'] === '1') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['resultno']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "userid={$userid}&productid={$params['productid']}&price={$params['price']}&num={$params['num']}&mobile={$params['mobile']}&spordertime={$params['spordertime']}";
+        $content .= "&sporderid={$params['sporderid']}&key={$key}";
+        return strtoupper(md5($content));
+    }
+
+    public function xmlToArray($xml)
+    {
+        $replace_str = str_replace(' ','','encoding="gb2312"');
+        $xml = mb_convert_encoding($xml,"UTF-8","gb2312");
+        $xml = str_replace($replace_str, "encoding='utf-8'", $xml);
+        return refill\util::xmlToArray($xml);
+    }
+}

+ 56 - 0
helper/refill/api/xyz/chizeng_yi/config.php

@@ -0,0 +1,56 @@
+<?php
+
+
+namespace refill\chizeng_yi;
+
+use mtopcard;
+class config
+{
+    //https://www.showdoc.com.cn/AQL666666/
+    const ORDER_URL = 'http://123.60.208.38:9086/onlinepay.do';
+    const QUERY_URL= 'http://123.60.208.38:9086/searchpay.do';
+    const BALANCE_URL = 'http://123.60.208.38:9086/searchbalance.do';
+
+    const USER_ID= '10003583';
+    const KEY = 'bp8EEmk3xejyezxkKCRwXTEdwsHQSTCj';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_chizeng_yi.php";
+
+    const operator = [
+        mtopcard\ChinaMobileCard  => 'yd',
+        mtopcard\ChinaUnicomCard  => 'lt',
+        mtopcard\ChinaTelecomCard => 'dx'
+    ];
+    const ERR_NOS = [
+        '5001','5002','5003','5004','5005','5008','5009','5010','5011','5012'
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;'];
+    const ProductIdS = [
+        mtopcard\ChinaMobileCard =>
+            [
+                30  => '101687',
+                50  => '101688',
+                100 => '101689',
+                200 => '101690',
+                300 => '101691',
+                500 => '101692',
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                30  => '101705',
+                50  => '101706',
+                100 => '101707',
+                200 => '101708',
+                300 => '101709',
+                500 => '101710',
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                30  => '101723',
+                50  => '101724',
+                100 => '101725',
+                200 => '101726',
+                300 => '101727',
+                500 => '101728',
+            ]
+    ];
+}

+ 43 - 0
helper/refill/api/xyz/chizeng_yi/对接文档-yezi.txt

@@ -0,0 +1,43 @@
+登录地址:http://123.60.208.38:7080/login.jsp
+
+账号:椰子-溢价
+
+密码:yz123456
+
+id;10003583
+
+key;bp8EEmk3xejyezxkKCRwXTEdwsHQSTCj
+
+下单地址:http://123.60.208.38:9086/onlinepay.do
+
+查询地址:http://123.60.208.38:9086/searchpay.do
+
+余额地址:http://123.60.208.38:9086/searchbalance.do
+
+
+
+对接文档:https://www.showdoc.com.cn/AQL666666/
+
+编码	商品	                               面值
+101687	全国移动话费30元直充	30
+101688	全国移动话费50元直充	50
+101689	全国移动话费100元直充	100
+101690	全国移动话费200元直充	200
+101691	全国移动话费300元直充	300
+101692	全国移动话费500元直充	500
+
+
+101705	全国联通话费30元直充	30
+101706	全国联通话费50元直充	50
+101707	全国联通话费100元直充	100
+101708	全国联通话费200元直充	200
+101709	全国联通话费300元直充	300
+101710	全国联通话费500元直充	500
+
+
+101723	全国电信话费30元直充    30
+101724	全国电信话费50元直充	50
+101725	全国电信话费100元直充	100
+101726	全国电信话费200元直充	200
+101727	全国电信话费300元直充	300
+101728	全国电信话费500元直充	500

+ 4 - 0
mobile/callback/refill_chizeng_yi.php

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

+ 14 - 0
test/TestRefill.php

@@ -2319,6 +2319,20 @@ class TestRefill extends TestCase
         $resp = $provider->notify($params);
     }
 
+    public function testChizeng_yi()
+    {
+//        $provider = $this->getProvider('chizeng_yi');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(15811535608, 4, 100, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '45611653372272644548']);
+
+        $body = '{"orderid":"YOQ22052414043859005","sporderid":"45611653372272644548","userid":"10003583","merchantsubmittime":"20220524140541","resultno":"9","parvalue":"100","remark1":"","payno":"","fundbalance":"-98","sign":"23331D82F432054D58CA7047F33A13F7"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('chizeng_yi','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $provider = new refill\amingjd\RefillPhone([]);