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

+ 41 - 0
data/config/zy/refill.ini.php

@@ -2246,6 +2246,46 @@ $huishiy_phone = ['name' => 'huishiy', 'store_id' => 92, 'qualitys' => '2',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$by_online_mix_cb_phone = ['name' => 'by_online_mix_cb', 'store_id' => 93, 'qualitys' => '3',
+    'amount' => [
+        1 => [
+            ['goods_id' => 7015, 'price' => 1, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        2 => [
+            ['goods_id' => 7016, 'price' => 2, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        3 => [
+            ['goods_id' => 7017, 'price' => 3, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        4 => [
+            ['goods_id' => 7018, 'price' => 4, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        5 => [
+            ['goods_id' => 7019, 'price' => 5, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        6 => [
+            ['goods_id' => 7020, 'price' => 6, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        7 => [
+            ['goods_id' => 7021, 'price' => 7, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        8 => [
+            ['goods_id' => 7022, 'price' => 8, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        9 => [
+            ['goods_id' => 7023, 'price' => 9, 'quality' => 3, 'card_type' => 'chinamobile'],
+        ],
+        10 => [['goods_id' => 7024, 'price' => 10, 'quality' => 3, 'card_type' => 'chinamobile']],
+        20 => [['goods_id' => 7025, 'price' => 20, 'quality' => 3, 'card_type' => 'chinamobile']],
+        30 => [['goods_id' => 7026, 'price' => 30, 'quality' => 3, 'card_type' => 'chinamobile']],
+        50 => [['goods_id' => 7027, 'price' => 50, 'quality' => 3, 'card_type' => 'chinamobile']],
+        100 => [['goods_id' => 7028, 'price' => 100, 'quality' => 3, 'card_type' => 'chinamobile']],
+        200 => [['goods_id' => 7029, 'price' => 200, 'quality' => 3, 'card_type' => 'chinamobile']],
+        300 => [['goods_id' => 7030, 'price' => 300, 'quality' => 3, 'card_type' => 'chinamobile']],
+        500 => [['goods_id' => 7031, 'price' => 500, 'quality' => 3, 'card_type' => 'chinamobile']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
     ['name' => 'yezi_hf', 'cfg' => $yezi_hf_phone],
     ['name' => 'yezia', 'cfg' => $yezia_phone],
@@ -2320,6 +2360,7 @@ $phone_providers = [
     ['name' => 'yiyunwozhifu', 'cfg' => $yiyunwozhifu_phone],
     ['name' => 'qilianhcfei', 'cfg' => $qilianhcfei_phone],
     ['name' => 'huishiy', 'cfg' => $huishiy_phone],
+    ['name' => 'by_online_mix_cb', 'cfg' => $by_online_mix_cb_phone],
 
 ];
 

+ 39 - 0
helper/refill/api/zy/by_online_mix_cb/API信息.txt

@@ -0,0 +1,39 @@
+测试域名 http://commapitest.bjzykj.work
+正式域名 http://commapi.bjzykj.work
+
+APPid:9
+version 1.0 版本号 默认 1.0
+APPkey:Hgxsyv041Jo45MR
+APPSecret:Hgxsyv041jQBaojkVZkdCKp6pUoYc1E4
+
+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 内蒙古

+ 46 - 0
helper/refill/api/zy/by_online_mix_cb/RefillCallBack.php

@@ -0,0 +1,46 @@
+<?php
+namespace refill\by_online_mix_cb;
+
+require_once(BASE_HELPER_RAPI_PATH . '/by_online_mix_cb/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("onHnydCbSuccess", ['order_id' => $order_id], 1);
+            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];
+        }
+    }
+}

+ 156 - 0
helper/refill/api/zy/by_online_mix_cb/RefillPhone.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace refill\by_online_mix_cb;
+
+require_once(BASE_HELPER_RAPI_PATH . '/by_online_mix_cb/config.php');
+require_once(BASE_HELPER_RAPI_PATH . '/by_online_mix_cb/hnyd.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];
+        }
+
+        $order_sn = $params['order_sn'];
+        $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) {
+                Model()->table('refill_order')->where(['order_sn' => $order_sn])->update(['official_sn' => $resp['data']['charge_id']]);
+                return [true, $resp['data']['order_sn'], false];
+            }
+            elseif ($resp['code'] === 1001) {
+                $err = 998;
+                $net_errno = "HTTP-$err";
+                return [false, $resp['msg'], true];
+            }
+            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'];
+        $params['is_HN'] = 2;
+        $sign = config::sign($params);
+        $params['sign'] = $sign;
+
+        $charge_id = $refill_info['official_sn'];
+        $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)
+            {
+                if(empty($resp['data'])) {
+                    return [false, '没有移动返回的原始数据', ''];
+                }
+                else
+                {
+                    ksort($resp);
+                    $response = new response($resp['data']);
+                    $record = $response->find_record($charge_id);
+                    if($record !== false)
+                    {
+                        if ($record->canceled()) {
+                            $order_state = ORDER_STATE_CANCEL;
+                        } elseif ($record->successed()) {
+                            $order_state = ORDER_STATE_SUCCESS;
+                            Model('refill_order')->edit($refill_info['order_id'], ['ch_trade_no' => $record->trade_id()]);
+                        } else {
+                            $order_state = ORDER_STATE_SEND;
+                        }
+                        return [true, $order_state, $charge_id];
+                    }
+                    elseif(time() - $refill_info['commit_time'] >= 2700) {
+                        return [true, ORDER_STATE_NOEXIST, $charge_id];
+                    }
+                    else {
+                        return [false, '没有移动返回的原始数据', ''];
+                    }
+                }
+            }
+            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']];
+            }
+        }
+    }
+}

+ 59 - 0
helper/refill/api/zy/by_online_mix_cb/config.php

@@ -0,0 +1,59 @@
+<?php
+namespace refill\by_online_mix_cb;
+
+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 = '9';
+    const APP_KEY = 'Hgxsyv041Jo45MR';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_by_online_mix_cb.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  //'新疆'
+    ];
+}

+ 106 - 0
helper/refill/api/zy/by_online_mix_cb/hnyd.php

@@ -0,0 +1,106 @@
+<?php
+
+namespace refill\by_online_mix_cb;
+
+class record
+{
+    private $mRecord;
+    public function __construct($record)
+    {
+        $this->mRecord = $record;
+    }
+
+    public function charge_id() {
+        return trim($this->mRecord['CHARGE_ID']);
+    }
+
+    public function trade_id() {
+        return trim($this->mRecord['OUT_TRADE_ID']);
+    }
+
+    public function fee()
+    {
+        return intval($this->mRecord['RECV_FEE']);
+    }
+
+    public function charge_time()
+    {
+        if(empty($this->mRecord['RECV_TIME'])) {
+            return false;
+        } else {
+            return strtotime($this->mRecord['RECV_TIME']);
+        }
+    }
+
+    public function canceled()
+    {
+        $deal_tag = $this->deal_tag();
+        return ($deal_tag === 2);
+    }
+
+    private function deal_tag()
+    {
+        return intval($this->mRecord['DEAL_TAG'] ?? 0);
+    }
+
+    public function successed()
+    {
+        $deal_tag = $this->deal_tag();
+        return ($deal_tag === 1);
+    }
+}
+
+
+class response
+{
+    private $mResult;
+    private $mRecords = [];
+    private $respCode;
+    public function __construct($resp)
+    {
+        $this->respCode = intval($resp['respCode']);
+        $this->mResult = $resp['result'];
+        ksort($this->mResult);
+
+        if(isset($this->mResult['data']))
+        {
+            $items = $this->mResult['data'];
+            foreach ( $items as $item)
+            {
+                ksort($item);
+                $this->mRecords[] = $item;
+            }
+            unset($this->mResult['data']);
+        }
+        else
+        {
+            $keys = ["DEAL_INFO","MONTH","DEAL_TAG","USER_ID_OUT","SERIAL_NUMBER_OUT",
+                     "DEAL_TIME","RECV_FEE","RECV_TIME","BIND_SERIAL_NUMBER","OUT_TRADE_ID",
+                     "GROUP_ID","CHARGE_ID","CANCEL_CHARGE_ID","ACCT_ID_OUT","CANCEL_TAG",
+                     "CANCEL_TIME","REMARK","LOCAL_SN","KITE_ORDER_NUM","CUST_NAME"];
+
+            $item = [];
+            foreach ($keys as $key) {
+                $item[$key] = $this->mResult[$key] ?? "";
+            }
+            ksort($item);
+            $this->mRecords[] = $item;
+            foreach ($keys as $key) {
+                unset($this->mResult[$key]);
+            }
+        }
+    }
+
+    public function find_record($charge_id)
+    {
+        foreach ($this->mRecords as $record)
+        {
+            $chid = $record['CHARGE_ID'];
+            if($chid == $charge_id) {
+                return new record($record);
+            }
+        }
+
+        return false;
+    }
+}

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


+ 4 - 0
mobile/callback/refill_by_online_mix_cb.php

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