Bladeren bron

yezi jiuyi_yin

xiaoyu 1 jaar geleden
bovenliggende
commit
fdba74731b

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

@@ -8855,6 +8855,51 @@ $guochuang_nation_trd_phone = ['name' => 'guochuang_nation_trd', 'store_id' => 3
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$jiuyi_yin_phone = ['name' => 'jiuyi_yin', 'store_id' => 322, 'qualitys' => '2',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8640, 'price' => 10.24, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8640, 'price' => 10.09, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8640, 'price' => 10.23, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 8641, 'price' => 20.48, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8641, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8641, 'price' => 20.26, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+            ['goods_id' => 8642, 'price' => 30.105, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8642, 'price' => 30.135, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8642, 'price' => 30.135, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 8643, 'price' => 50.175, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8643, 'price' => 50.125, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8643, 'price' => 50.225, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8644, 'price' => 100.35, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8644, 'price' => 100.25, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8644, 'price' => 100.45, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8645, 'price' => 200.7, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8645, 'price' => 200.4, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8645, 'price' => 200.9, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 8646, 'price' => 301.05, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8646, 'price' => 300.6, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8646, 'price' => 301.35, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 8647, 'price' => 501.75, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8647, 'price' => 501, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 8647, 'price' => 502.25, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -9127,6 +9172,7 @@ $phone_providers = [
     ['name' => 'zhenghe_sec', 'cfg' => $zhenghe_sec_phone],
     ['name' => 'by_online', 'cfg' => $by_online_phone],
     ['name' => 'guochuang_nation_trd', 'cfg' => $guochuang_nation_trd_phone],
+    ['name' => 'jiuyi_yin', 'cfg' => $jiuyi_yin_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

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

@@ -0,0 +1,58 @@
+<?php
+
+
+namespace refill\jiuyi_yin;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jiuyi_yin/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')->getOrderInfoForNotify(['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];
+        }
+    }
+}

+ 140 - 0
helper/refill/api/xyz/jiuyi_yin/RefillPhone.php

@@ -0,0 +1,140 @@
+<?php
+
+namespace refill\jiuyi_yin;
+
+require_once(BASE_HELPER_RAPI_PATH . '/jiuyi_yin/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'] = 1;
+        $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];
+            } elseif ($resp['code'] === 3) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], [0, 2], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
+            } else {
+                $err = 998;
+                $net_errno = "HTTP-{$err}";
+                return [false, $resp['msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['access_key'] = config::ACCESS_KEY;
+        $params['orderid'] = $refill_info['ch_trade_no'];
+        $params['out_trade_no'] = $refill_info['order_sn'];
+        $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) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['data']['official_id']]);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 3) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === 1) {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === 5 && (time() - $refill_info['commit_time'] > 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['access_key'] = config::ACCESS_KEY;
+        $params['timestamp'] = time();
+        $params['sign'] = $this->sign($params);
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::BALANCE_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, '系统错误'];
+            } elseif ($resp['code'] == 1) {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    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));
+    }
+}

BIN
helper/refill/api/xyz/jiuyi_yin/api.pdf


+ 38 - 0
helper/refill/api/xyz/jiuyi_yin/config.php

@@ -0,0 +1,38 @@
+<?php
+namespace refill\jiuyi_yin;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://47.93.7.11:10050/order/insert';
+    const QUERY_URL = 'http://47.93.7.11:10050/order/query';
+    const BALANCE_URL = 'http://47.93.7.11:10050/member/account';
+
+    const ACCESS_KEY = 'ACK211394684';
+    const ACCESS_SECRET = '74B1D6461A6E984BA3EEC8293975FF37';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jiuyi_yin.php";
+
+    const ExtHeaders = ['Content-Type: application/json; charset=utf-8'];
+
+    const product_code = [
+        mtopcard\ChinaMobileCard => [
+            30  => 'SKU100285',
+            50  => 'SKU100286',
+            100 => 'SKU100287',
+            200 => 'SKU100288',
+            300 => 'SKU100289',
+            500 => 'SKU100290'
+        ],
+        mtopcard\ChinaUnicomCard => [
+
+        ],
+        mtopcard\ChinaTelecomCard => [
+            30  => 'SKU100291',
+            50  => 'SKU100292',
+            100 => 'SKU100293',
+            200 => 'SKU100294',
+            300 => 'SKU100295',
+            500 => 'SKU100296'
+        ],
+    ];
+}

+ 14 - 0
helper/refill/api/xyz/jiuyi_yin/产品编码.txt

@@ -0,0 +1,14 @@
+【全国移动手支】产品编码:
+全国移动手支30-限		SKU100285
+全国移动手支50-限		SKU100286
+全国移动手支100-限	    SKU100287
+全国移动手支200-限		SKU100288
+全国移动手支300-限		SKU100289
+全国移动手支500-限		SKU100290
+【全国电信电渠】产品编码:
+全国电信电渠30-限		SKU100291
+全国电信电渠50-限		SKU100292
+全国电信电渠100-限	    SKU100293
+全国电信电渠200-限		SKU100294
+全国电信电渠300-限		SKU100295
+全国电信电渠500-限		SKU100296

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

@@ -0,0 +1,14 @@
+九亿九亿创芯生产环境接口地址:
+直充收单:http://47.93.7.11:10050/order/insert
+直充查单:http://47.93.7.11:10050/order/query
+余额查询:http://47.93.7.11:10050/member/account
+
+九亿创芯会员端登录地址
+http://47.93.7.11:10040/html/login.html
+
+正式账号:
+
+前台登录名:18513846008ZL
+前台登陆密码:700886
+access_key:ACK211394684
+accessSecret:74B1D6461A6E984BA3EEC8293975FF37

+ 8 - 0
mobile/callback/refill_jiuyi_yin.php

@@ -0,0 +1,8 @@
+<?php
+$content = $_SERVER['post_content'];
+$input = json_decode($content,true);
+refill\util::push_notify('jiuyi_yin',$input);
+
+$response = ["code" => "0"];
+$body = json_encode($response);
+echo($body);