فهرست منبع

yiqian_tax,dev

zhaoming 1 سال پیش
والد
کامیت
aa3f6043a2

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

@@ -10140,6 +10140,51 @@ $weisanhuo_phone = ['name' => 'weisanhuo', 'store_id' => 384, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$yiqian_tax_phone = ['name' => 'yiqian_tax', 'store_id' => 385, 'qualitys' => '2',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 9017, 'price' => 10.39, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9017, 'price' => 10.08, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9017, 'price' => 10.39, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 9018, 'price' => 20.46, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9018, 'price' => 20.16, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 9018, 'price' => 20.46, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+//            ['goods_id' => 9019, 'price' => 30.36, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9019, 'price' => 29.985, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9019, 'price' => 29.97, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+//            ['goods_id' => 9020, 'price' => 50.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9020, 'price' => 49.975, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9020, 'price' => 49.95, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 9021, 'price' => 100.1, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9021, 'price' => 99.95, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9021, 'price' => 99.9, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 9022, 'price' => 200.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9022, 'price' => 199.9, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9022, 'price' => 199.8, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 9023, 'price' => 300.3, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 9023, 'price' => 299.85, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9023, 'price' => 299.7, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 9024, 'price' => 500.5, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 9024, 'price' => 498.75, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 9024, 'price' => 499.5, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_p hone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -10444,7 +10489,8 @@ $phone_providers = [
     ['name' => 'miaoxt_tax_seco', 'cfg' => $miaoxt_tax_seco_phone],
     ['name' => 'beirui_sec', 'cfg' => $beirui_sec_phone],
 //    ['name' => 'beirui_trd', 'cfg' => $beirui_trd_phone],
-        ['name' => 'weisanhuo', 'cfg' => $weisanhuo_phone],
+    ['name' => 'weisanhuo', 'cfg' => $weisanhuo_phone],
+    ['name' => 'yiqian_tax', 'cfg' => $yiqian_tax_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 18 - 0
helper/refill/api/xyz/yiqian_tax/API.MD

@@ -0,0 +1,18 @@
+
+## 壹仟含税
+
+- 用户编号(userId): 261
+- 密钥(privateKey):c739d5f68333deaeb6ae04d30e60e836896587968219656fcf66c1708c76f9d7
+
+- 登录名: youlaiyouwang
+- 登录密码:sup123456
+- 后台地址:47.94.208.3:616
+
+- 接口文档地址: https://shimo.im/docs/5bqnr2OZw9SDz4qy/read
+- 查询地址:http://47.94.208.3:6160/unicomAync/buy.do
+- 下单地址:http://47.94.208.3:6160/unicomAync/queryBizOrder.do
+- 余额地址:http://47.94.208.3:6160/unicomAync/queryBalance.do
+
+## 店铺
+- 账号:yiqian_tax
+- 密码:yiqian_tax67890

+ 54 - 0
helper/refill/api/xyz/yiqian_tax/RefillCallBack.php

@@ -0,0 +1,54 @@
+<?php
+namespace refill\yiqian_tax;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yiqian_tax/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): string
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "{$params['bizId']}{$params['downstreamSerialno']}{$params['ejId']}{$params['status']}{$userid}{$key}";
+        return md5($content);
+    }
+
+    public function notify($params): array
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['downstreamSerialno'];
+        $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) {
+            $official_sn = strtolower($params['voucher']) == 'null' ? '' : $params['voucher'];
+            $ch_trade_no = $params['ejId'];
+
+            $data['official_sn'] = $official_sn;
+            $data['ch_trade_no'] = $ch_trade_no;
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false, true, $official_sn];
+        }
+        elseif ($status === 3) {
+            return [$order_id, false, true, true, ''];
+        }
+        else {
+            return [$order_id, false, false, false, ''];
+        }
+    }
+}

+ 158 - 0
helper/refill/api/xyz/yiqian_tax/RefillPhone.php

@@ -0,0 +1,158 @@
+<?php
+declare(strict_types=0);
+
+namespace refill\yiqian_tax;
+
+require_once(BASE_HELPER_RAPI_PATH . '/yiqian_tax/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, int $card_type, string $order_sn): array
+    {
+        $params['userId'] = config::USER_ID;
+        $params['itemId'] = config::Products[$card_type][$amount];
+        $params['checkItemFacePrice'] = $amount * 1000;
+        $params['amt'] = 1;
+        $params['uid'] = $phone;
+        $params['serialno'] = $order_sn;
+        $params['dtCreate'] = date("YmdHis");
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params, &$net_errno = 0): array
+    {
+        $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, 'GET', false, [], $net_errno);
+
+        if (empty($resp)) {
+            return [false, '网络错误', true];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = refill\util::xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误', true];
+            }
+            $status = $resp['status'];
+            $code   = $resp['code'];
+
+            if (!in_array($status, ['success', 'failed'])) {
+                return [false, '网络错误', true];
+            } elseif ($code === '00') {
+                return [true, $resp['bizOrderId'], false];
+            } elseif (in_array($code, [23, 31, 50])) {
+                $net_errno = "HTTP-{$code}";
+                return [false, $code, true];
+            } else {
+                return [false, $code, false];
+            }
+        }
+    }
+
+    public function query($refill_info): array
+    {
+        $params['userId'] = config::USER_ID;
+        $params['serialno'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "{$params['userId']}{$params['serialno']}{$key}";
+        $params['sign'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误', ''];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = refill\util::xmlToArray($resp);
+            if (empty($resp))
+            {
+                return [false, '网络错误', ''];
+            }
+            else
+            {
+                $status = $resp['status'];
+                $code   = $resp['code'];
+
+                if (!in_array($status, ['success', 'failed'])) {
+                    return [false, $status, ''];
+                }
+                elseif($code === '00')
+                {
+                    $official_sn = '';
+
+                    $status = intval($resp['data']['status']);
+                    if ($status === 2) {
+                        $official_sn = $resp['data']['outOrderNo'];
+                        $ch_trade_no = $resp['data']['id'];
+                        Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $official_sn,'ch_trade_no' => $ch_trade_no]);
+                        $order_state = ORDER_STATE_SUCCESS;
+                    } elseif ($status === 3) {
+                        $order_state = ORDER_STATE_CANCEL;
+                    } elseif (in_array($status, [0, 1, 4, 9])) {
+                        $order_state = ORDER_STATE_SEND;
+                    } else {
+                        return [false, $status, ''];
+                    }
+                    return [true, $order_state, $official_sn];
+                }
+                elseif ($code === '22' && (time() - $refill_info['commit_time'] >= 600)) {
+                    return [true, ORDER_STATE_NOEXIST, ''];
+                }
+                else {
+                    return [false, $code, ''];
+                }
+            }
+        }
+    }
+
+    public function balance(): array
+    {
+        $params['userId'] = config::USER_ID;
+        $key = config::KEY;
+        $body = "{$params['userId']}{$key}";
+        $params['sign'] = md5($body);
+
+        $resp = http_request(config::BALANCE_URL, $params);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = refill\util::xmlToArray($resp);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            } elseif ($resp['status'] === 'success' && $resp['code'] === '00') {
+                return [true, $resp['balance']/1000];
+            } else {
+                return [false, $resp['code']];
+            }
+        }
+    }
+
+    private function sign($params): string
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "{$params['amt']}{$params['checkItemFacePrice']}{$params['dtCreate']}{$params['itemId']}{$params['itemPrice']}{$params['serialno']}";
+        $content .= "{$params['uid']}{$userid}{$key}";
+        return md5($content);
+    }
+}

+ 53 - 0
helper/refill/api/xyz/yiqian_tax/config.php

@@ -0,0 +1,53 @@
+<?php
+
+
+namespace refill\yiqian_tax;
+
+use mtopcard;
+class config
+{
+    //回调地址需配置
+    const ORDER_URL = 'http://47.94.208.3:6160/unicomAync/buy.do';
+    const QUERY_URL= 'http://47.94.208.3:6160/unicomAync/queryBizOrder.do';
+    const BALANCE_URL = 'http://47.94.208.3:6160/unicomAync/queryBalance.do';
+
+    const USER_ID= '261';
+    const KEY = 'c739d5f68333deaeb6ae04d30e60e836896587968219656fcf66c1708c76f9d7';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_yiqian_tax.php";
+
+    const Products = [
+        mtopcard\ChinaMobileCard =>
+            [
+                10  => 90440010,
+                20  => 90440020,
+                30  => 90440030,
+                50  => 90440050,
+                100 => 90440100,
+                200 => 90440200,
+                300 => 90440300,
+                500 => 90440500
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                10  => 90460010,
+                20  => 90460020,
+                30  => 90460030,
+                50  => 90460050,
+                100 => 90460100,
+                200 => 90460200,
+                300 => 90460300,
+                500 => 90460500
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                10  => 90290010,
+                20  => 90290020,
+                30  => 90290030,
+                50  => 90290050,
+                100 => 90290100,
+                200 => 90290200,
+                300 => 90290300,
+                500 => 90290500
+            ]
+    ];
+}

+ 4 - 0
mobile/callback/refill_yiqian_tax.php

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

+ 8 - 0
test/TestRefill.php

@@ -5821,6 +5821,14 @@ class TestRefill extends TestCase
         $ret = $provider->verify($data);
 //        $resp = $provider->notify($data);
     }
+
+    public function testyiqian_tax()
+    {
+        $provider = $this->getProvider('yiqian_tax');
+        $resp = $provider->balance();
+//        $resp = $provider->add(13699279618, 4, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '24271700815859899563']);
+    }
 }