xiaoyu vor 3 Jahren
Ursprung
Commit
c71858bd8b

Datei-Diff unterdrückt, da er zu groß ist
+ 865 - 225
data/config/win/refill.ini.php


+ 58 - 0
helper/refill/api/xyz/xingzy/RefillCallBack.php

@@ -0,0 +1,58 @@
+<?php
+
+
+namespace refill\xingzy;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xingzy/config.php');
+
+use refill;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        unset($input['data']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        foreach ($params as $k => $v) {
+            $body .= "{$k}{$v}";
+        }
+        return base64_encode(hash_hmac("sha1", $body, config::ACCESS_SECRET, true));
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['code']);
+        $order_sn = $params['out_trade_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 === 2) {
+            $data['official_sn'] = strtolower($params['data']['official_id']) == 'null' ? '' : $params['data']['official_id'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 106 - 0
helper/refill/api/xyz/xingzy/RefillPhone.php

@@ -0,0 +1,106 @@
+<?php
+
+namespace refill\xingzy;
+
+require_once(BASE_HELPER_RAPI_PATH . '/xingzy/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 $card_type, int $amount, string $order_sn)
+    {
+        $params['phone'] = $phone;
+        $params['access_key'] = config::ACCESS_KEY;
+        $params['par_value'] = $amount;
+        $params['code'] = config::product_code[$card_type][$amount];
+        $params['producttype'] = $amount;
+        $params['out_trade_no'] = $order_sn;
+        $params['timestamp'] = time();
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $card_type, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+        $params['notify_url'] = config::NOTIFY_URL;
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::ORDER_URL, $params , config::ExtHeaders, $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['code'] == 1) {
+                return [true, $resp['data']['orderid'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['out_trade_no'] = $refill_info['order_sn'];
+        $params['access_key'] = config::ACCESS_KEY;
+        $params['timestamp'] = time();
+        $params['sign'] = $this->sign($params);
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::QUERY_URL, $params , config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            else
+            {
+                $status = intval($resp['code']);
+                if ($status === 2) {
+                    $updata['official_sn'] = $resp['data']['official_id'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 1) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        foreach ($params as $k => $v) {
+            $body .= "{$k}{$v}";
+        }
+        return base64_encode(hash_hmac("sha1", $body, config::ACCESS_SECRET, true));
+    }
+}

+ 48 - 0
helper/refill/api/xyz/xingzy/config.php

@@ -0,0 +1,48 @@
+<?php
+namespace refill\xingzy;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://39.101.64.104:9000/order/insert';
+    const QUERY_URL = 'http://39.101.66.124:8071/order/query';
+
+    const ACCESS_KEY = '211394702';
+    const ACCESS_SECRET = 'WgpRyYE2h0ydedUay1t+Sg==';
+//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_xingzy.php";
+    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const ExtHeaders = ['Content-Type: application/json; charset=utf-8'];
+
+    const product_code = [
+        mtopcard\ChinaMobileCard => [
+            10 => 'SKU100087',
+            20 => 'SKU100088',
+            30 => 'SKU100089',
+            50 => 'SKU100090',
+            100 => 'SKU100091',
+            200 => 'SKU100092',
+            300 => 'SKU100093',
+            500 => 'SKU100094'
+        ],
+        mtopcard\ChinaUnicomCard => [
+            10 => 'SKU100095',
+            20 => 'SKU100096',
+            30 => 'SKU100097',
+            50 => 'SKU100098',
+            100 => 'SKU100099',
+            200 => 'SKU100100',
+            300 => 'SKU100101',
+            500 => 'SKU100102'
+        ],
+        mtopcard\ChinaTelecomCard => [
+            10 => 'SKU100103',
+            20 => 'SKU100104',
+            30 => 'SKU100105',
+            50 => 'SKU100106',
+            100 => 'SKU100107',
+            200 => 'SKU100108',
+            300 => 'SKU100109',
+            500 => 'SKU100110'
+        ],
+    ];
+}

+ 27 - 0
helper/refill/api/xyz/xingzy/产品编码.txt

@@ -0,0 +1,27 @@
+全国移动慢充10元   	   SKU100087
+全国移动慢充20元       SKU100088
+全国移动慢充30元       SKU100089
+全国移动慢充50元       SKU100090
+全国移动慢充100元     SKU100091
+全国移动慢充200元     SKU100092
+全国移动慢充300元     SKU100093
+全国移动慢充500元     SKU100094
+
+全国联通慢充10元          SKU100095
+全国联通慢充20元          SKU100096
+全国联通慢充30元          SKU100097
+全国联通慢充50元          SKU100098
+全国联通慢充100             SKU100099     	
+全国联通慢充200元          SKU100100  
+全国联通慢充300元          SKU100101
+全国联通慢充500元          SKU100102
+    
+
+全国电信慢充10元             SKU100103
+全国电信慢充20元             SKU100104
+全国电信慢充30元             SKU100105
+全国电信慢充50元             SKU100106
+全国电信慢充100元           SKU100107
+全国电信慢充200元           SKU100108
+全国电信慢充300元           SKU100109
+全国电信慢充500元           SKU100110

+ 18 - 0
helper/refill/api/xyz/xingzy/椰子账户信息.txt

@@ -0,0 +1,18 @@
+《接口开发文档》:https://www.showdoc.cc/826025946776812?page_id=4511307456216019
+收单:http://39.101.64.104:8081/order/insert 
+查单:http://39.101.64.104:8071/order/query
+余额查询:http://39.101.64.104:8071/member/account
+生产地址:
+收单(新):http://39.101.64.104:9000/order/insert??
+查单:http://39.101.66.124:8071/order/query
+余额查询:http://39.101.66.124:8071/member/account
+会员端:http://39.101.64.104:9022
+
+正式账号:
+前台登录名:18500608333
+前台登陆密码:965889
+access_key:211394702
+accessSecret:WgpRyYE2h0ydedUay1t+Sg==
+
+
+

+ 6 - 0
test/TestRefill.php

@@ -399,6 +399,12 @@ class TestRefill extends TestCase
 //        refill\RefillFactory::instance()->notify('moxj_yd',$params);
     }
 
+    public function testXingzyPhone()
+    {
+        $providers = new refill\xingzy\RefillPhone([]);
+        $sign = $providers->ct_sign();
+    }
+
     public function testTongluPhone()
     {
         $providers = new refill\tonglu\RefillPhone([]);