xiaoyu пре 1 година
родитељ
комит
f5722122d1

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

@@ -8948,6 +8948,19 @@ $jiuyi_yin_phone = ['name' => 'jiuyi_yin', 'store_id' => 322, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$by_online_kami_phone = ['name' => 'by_online_kami', 'store_id' => 327, 'qualitys' => '3',
+    'amount' => [
+//        10 => [['goods_id' => 8667, 'price' => 10, 'quality' => 3, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        20 => [['goods_id' => 8668, 'price' => 20, 'quality' => 3, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        30 => [['goods_id' => 8669, 'price' => 30, 'quality' => 3, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 8670, 'price' => 50, 'quality' => 3, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 8671, 'price' => 100, 'quality' => 3, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 8672, 'price' => 200, 'quality' => 3, 'card_type' => 'chinamobile']],
+//        300 => [['goods_id' => 8673, 'price' => 300, 'quality' => 3, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        500 => [['goods_id' => 8674, 'price' => 500, 'quality' => 3, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -9221,6 +9234,7 @@ $phone_providers = [
     ['name' => 'by_online', 'cfg' => $by_online_phone],
     ['name' => 'guochuang_nation_trd', 'cfg' => $guochuang_nation_trd_phone],
     ['name' => 'jiuyi_yin', 'cfg' => $jiuyi_yin_phone],
+    ['name' => 'by_online_kami', 'cfg' => $by_online_kami_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 39 - 0
helper/refill/api/xyz/by_online_kami/API信息.txt

@@ -0,0 +1,39 @@
+测试域名 http://commapitest.bjzykj.work
+正式域名 http://commapi.bjzykj.work
+
+APPid:7
+version 1.0 版本号 默认 1.0
+APPkey:Hfhsej959bReF4B
+
+
+1 北京
+2 天津
+3 上海
+4 重庆
+5 河北
+6 山西
+8 辽宁
+9 吉林
+10 黑龙江
+11 江苏
+12 浙江
+13 安徽
+14 福建
+15 江西
+16 山东
+17 河南
+18 湖北
+19 湖南
+20 广东
+21 甘肃
+22 四川
+23 贵州
+24 海南
+25 云南
+26 青海
+27 陕西
+28 广西
+29 西藏
+30 宁夏
+31 新疆
+32 内蒙古

+ 44 - 0
helper/refill/api/xyz/by_online_kami/RefillCallBack.php

@@ -0,0 +1,44 @@
+<?php
+namespace refill\by_online_kami;
+
+require_once(BASE_HELPER_RAPI_PATH . '/by_online_kami/config.php');
+
+use refill;
+use QueueClient;
+
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = config::sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['order_status']);
+        $order_sn = $params['merchantorder_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 === 7) {
+            $data['official_sn'] = strtolower($params['charge_id']) == 'null' ? '' : $params['charge_id'];
+            Model('refill_order')->edit($order_id, $data);
+            QueueClient::async_push("QueryRefund", ['order_id' => $order_id], 3600);
+            return [$order_id, true, false, true];
+        } elseif (in_array($status, [3, 4, 6], true)) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
+        }
+    }
+}

+ 186 - 0
helper/refill/api/xyz/by_online_kami/RefillPhone.php

@@ -0,0 +1,186 @@
+<?php
+
+namespace refill\by_online_kami;
+
+require_once(BASE_HELPER_RAPI_PATH . '/by_online_kami/config.php');
+
+use refill;
+use Log;
+use Cache;
+
+class RefillPhone extends refill\IRefillPhone
+{
+    public function __construct($cfgs)
+    {
+        parent::__construct($cfgs);
+    }
+
+    private function req_params(int $phone, int $amount, int $card_type, string $order_sn, $regin_no)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['version'] = '1.0';
+        $params['merchantOrderNo'] = $order_sn;
+        $params['productId'] = 1;
+        $params['account'] = "{$phone}";
+        $params['amt'] = $amount * 100;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['provinceId'] = config::ProvinceMap[$regin_no];
+        $params['parameter'] = '';
+        $params['extra'] = '';
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0)
+    {
+        $regin_no = $params['regin_no'] ?? -1;
+        if ($regin_no <= 0) {
+            return [false, '省份获取错误', false];
+        }
+
+        if($this->exist($card_no)) {
+            return [false, '今日已经提交过', false];
+        }
+
+        $params = $this->req_params($card_no, $amount, $card_type, $params['order_sn'], $regin_no);
+        $sign = config::sign($params);
+        $params['sign'] = $sign;
+
+        $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'] === 1000) {
+                return [true, $resp['data']['order_sn'], false];
+            } else {
+                return [false, $resp['msg'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['version'] = '1.0';
+        $params['merchantOrderNo'] = $refill_info['order_sn'];
+        $sign = config::sign($params);
+        $params['sign'] = $sign;
+
+        $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, '网络错误'];
+            }
+            elseif ($resp['code'] === 1000)
+            {
+                $status = $resp['data']['order_status'];
+                if ($status === 7) {
+                    $updata['official_sn'] = $resp['data']['charge_id'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif (in_array($status, [3, 4, 6], true)) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif (in_array($status, [0, 1, 2, 5], true)) {
+                    $order_state = ORDER_STATE_SEND;
+                } else {
+                    return [false, $status];
+                }
+
+                return [true, $order_state];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['appId'] = config::APP_ID;
+        $params['version'] = '1.0';
+        $sign = config::sign($params);
+        $params['sign'] = $sign;
+
+        $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['code'] === 1000) {
+                return [true, $resp['data']['balance'] / 100];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function exist($card_no)
+    {
+        $ins = Cache::getInstance('cacheredis');
+        $today = strtotime(date('Ymd',time()));
+
+        $name = "unique_tongfu_{$today}";
+        $key = "$card_no";
+
+        $value = $ins->hget($name,'',$key);
+        if($value === false) {
+            $ins->hset($name, '', [$key=> 1]);
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    //[是否需要返销,是否网络错误]
+    public function need_refund($refill_info)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['version'] = '1.0';
+        $params['merchantOrderNo'] = $refill_info['order_sn'];
+        $sign = config::sign($params);
+        $params['sign'] = $sign;
+
+        $resp = http_request(config::QUERY_URL, $params);
+
+        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'] === 1000)
+            {
+                $status = $resp['data']['order_status'];
+                if ($status === 8 or $status === 3) {
+                    return [true,false];
+                }
+            }
+            else {
+                return [false,false];
+            }
+        }
+    }
+}

+ 59 - 0
helper/refill/api/xyz/by_online_kami/config.php

@@ -0,0 +1,59 @@
+<?php
+namespace refill\by_online_kami;
+
+class config
+{
+    const ORDER_URL = 'http://commapi.bjzykj.work/comm/recharge';
+    const QUERY_URL = 'http://commapi.bjzykj.work/comm/orderQuery';
+    const BALANCE_URL = 'http://commapi.bjzykj.work/comm/account';
+
+    const APP_ID = '7';
+    const APP_KEY = 'Hfhsej959bReF4B';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_by_online_kami.php";
+    const ExtHeaders = ['Content-Type: application/json'];
+
+    public static function sign($params)
+    {
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            $content .= "{$key}={$value}&";
+        }
+        $content .= config::APP_KEY;
+        return md5($content);
+    }
+
+    const ProvinceMap = [
+        1	=> 1,  //'北京',
+        2	=> 2,  //'天津',
+        3	=> 5, //'河北',
+        4	=> 6, //'山西',
+        5	=> 32,  //'内蒙古',
+        6	=> 8,  //'辽宁',
+        7	=> 9,  //'吉林',
+        8	=> 10,  //'黑龙江',
+        9	=> 3,  //'上海',
+        10	=> 11, //'江苏',
+        11	=> 12, //'浙江',
+        12	=> 13, //'安徽',
+        13	=> 14, //'福建',
+        14	=> 15, //'江西',
+        15	=> 16, //'山东',
+        16	=> 17,  //'河南',
+        17	=> 18, //'湖北',
+        18	=> 19, //'湖南',
+        19	=> 20, //'广东',
+        20	=> 28, //'广西',
+        21	=> 24, //'海南',
+        22	=> 4,  //'重庆',
+        23	=> 22, //'四川',
+        24	=> 23, //'贵州',
+        25	=> 25, //'云南',
+        26	=> 29, //'西藏',
+        27	=> 27, //'陕西',
+        28	=> 21, //'甘肃',
+        29	=> 26, //'青海',
+        30	=> 30, //'宁夏',
+        31	=> 31  //'新疆'
+    ];
+}

BIN
helper/refill/api/xyz/by_online_kami/纸莺运营商数据管理平台对外接口.pdf


+ 4 - 0
mobile/callback/refill_by_online_kami.php

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