فهرست منبع

dashang_normal

xiaoyu 3 سال پیش
والد
کامیت
24015933fd

+ 18 - 4
data/config/win/refill.ini.php

@@ -617,8 +617,8 @@ $wantong_phone = ['name' => 'wantong', 'store_id' => 36, 'qualitys' => '4',
 $zhongst_phone = ['name' => 'zhongst', 'store_id' => 39, 'qualitys' => '2',
     'amount' => [
         10 => [
-            ['goods_id' => 6464, 'price' => 10.04, 'quality' => 2, 'card_type' => 'chinamobile'],
-            ['goods_id' => 6464, 'price' => 10.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 6464, 'price' => 10.25, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 6464, 'price' => 10.15, 'quality' => 2, 'card_type' => 'chinaunicom'],
             ['goods_id' => 6464, 'price' => 10.01, 'quality' => 2, 'card_type' => 'chinatelecom']
         ],
 
@@ -2875,7 +2875,7 @@ $xiaoniu_hf_phone = ['name' => 'xiaoniu_hf', 'store_id' => 141, 'qualitys' => '3
 
 $shuoruan_phone = ['name' => 'shuoruan', 'store_id' => 142, 'qualitys' => '2',
     'amount' => [
-//        10 => [['goods_id' => 7219, 'price' => 9.97, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        10 => [['goods_id' => 7219, 'price' => 10.3, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
 //        20 => [['goods_id' => 7220, 'price' => 19.94, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
 //        30 => [['goods_id' => 7221, 'price' => 29.91, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
         50 => [['goods_id' => 7222, 'price' => 49.85, 'quality' => 2, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
@@ -2986,6 +2986,19 @@ $feimingyu_phone = ['name' => 'feimingyu', 'store_id' => 147, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$dashang_normal_phone = ['name' => 'dashang_normal', 'store_id' => 148, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7267, 'price' => 9.56, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7268, 'price' => 19.12, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7269, 'price' => 28.68, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7270, 'price' => 47.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7271, 'price' => 95.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7272, 'price' => 191.2, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        300 => [['goods_id' => 7273, 'price' => 286.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        500 => [['goods_id' => 7274, 'price' => 478, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3097,7 +3110,8 @@ $phone_providers = [
     ['name' => 'shuoruan', 'cfg' => $shuoruan_phone],
     ['name' => 'linzhu', 'cfg' => $linzhu_phone],
     ['name' => 'huafutongman', 'cfg' => $huafutongman_phone],
-    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone]
+    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone],
+    ['name' => 'dashang_normal', 'cfg' => $dashang_normal_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -2986,6 +2986,19 @@ $feimingyu_phone = ['name' => 'feimingyu', 'store_id' => 147, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$dashang_normal_phone = ['name' => 'dashang_normal', 'store_id' => 148, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7267, 'price' => 9.56, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7268, 'price' => 19.12, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7269, 'price' => 28.68, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7270, 'price' => 47.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7271, 'price' => 95.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7272, 'price' => 191.2, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        300 => [['goods_id' => 7273, 'price' => 286.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        500 => [['goods_id' => 7274, 'price' => 478, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3097,7 +3110,8 @@ $phone_providers = [
     ['name' => 'shuoruan', 'cfg' => $shuoruan_phone],
     ['name' => 'linzhu', 'cfg' => $linzhu_phone],
     ['name' => 'huafutongman', 'cfg' => $huafutongman_phone],
-    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone]
+    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone],
+    ['name' => 'dashang_normal', 'cfg' => $dashang_normal_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 15 - 1
data/config/xyzadm/refill.ini.php

@@ -2986,6 +2986,19 @@ $feimingyu_phone = ['name' => 'feimingyu', 'store_id' => 147, 'qualitys' => '1',
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$dashang_normal_phone = ['name' => 'dashang_normal', 'store_id' => 148, 'qualitys' => '1',
+    'amount' => [
+        10 => [['goods_id' => 7267, 'price' => 9.56, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 7268, 'price' => 19.12, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 7269, 'price' => 28.68, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 7270, 'price' => 47.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 7271, 'price' => 95.6, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 7272, 'price' => 191.2, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        300 => [['goods_id' => 7273, 'price' => 286.8, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+//        500 => [['goods_id' => 7274, 'price' => 478, 'quality' => 1, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -3097,7 +3110,8 @@ $phone_providers = [
     ['name' => 'shuoruan', 'cfg' => $shuoruan_phone],
     ['name' => 'linzhu', 'cfg' => $linzhu_phone],
     ['name' => 'huafutongman', 'cfg' => $huafutongman_phone],
-    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone]
+    ['name' => 'feimingyu', 'cfg' => $feimingyu_phone],
+    ['name' => 'dashang_normal', 'cfg' => $dashang_normal_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 50 - 0
helper/refill/api/xyz/dashang_normal/RefillCallBack.php

@@ -0,0 +1,50 @@
+<?php
+namespace refill\dashang_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dashang_normal/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)
+    {
+        $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)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['downstreamSerialno'];
+        $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['voucher']) == 'null' ? '' : $params['voucher'];
+            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];
+        }
+    }
+}

+ 159 - 0
helper/refill/api/xyz/dashang_normal/RefillPhone.php

@@ -0,0 +1,159 @@
+<?php
+declare(strict_types=0);
+
+namespace refill\dashang_normal;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dashang_normal/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)
+    {
+        $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)
+    {
+        $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 = $this->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])) {
+                $net_errno = "HTTP-{$code}";
+                return [false, $code, true];
+            } else {
+                return [false, $code, false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $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 = $this->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')
+                {
+                    $status = intval($resp['data']['status']);
+                    if ($status === 2) {
+                        Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['data']['outOrderNo']]);
+                        $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];
+                }
+                elseif ($code === '22' && (time() - $refill_info['commit_time'] >= 600)) {
+                    return [true, ORDER_STATE_NOEXIST];
+                }
+                else {
+                    return [false, $code];
+                }
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $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 = $this->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)
+    {
+        $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);
+    }
+
+    public function xmlToArray($xml)
+    {
+        return json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
+    }
+}

+ 47 - 0
helper/refill/api/xyz/dashang_normal/config.php

@@ -0,0 +1,47 @@
+<?php
+
+
+namespace refill\dashang_normal;
+
+use mtopcard;
+class config
+{
+    //回调地址需配置
+    const ORDER_URL = 'http://47.114.209.57/unicomAync/buy.do';
+    const QUERY_URL= 'http://47.114.209.57/unicomAync/queryBizOrder.do';
+    const BALANCE_URL = 'http://47.114.209.57/unicomAync/queryBalance.do';
+
+    const USER_ID= '80800357';
+    const KEY = '1d3a51d49c3b0ba2685389b52f26bffb';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dashang_normal.php";
+
+    const Products = [
+        mtopcard\ChinaMobileCard =>
+            [
+                10  => 60030010,
+                20  => 60030020,
+                30  => 60030030,
+                50  => 60030050,
+                100 => 60030100,
+                200 => 60030200
+            ],
+        mtopcard\ChinaUnicomCard =>
+            [
+                10  => 60050010,
+                20  => 60050020,
+                30  => 60050030,
+                50  => 60050050,
+                100 => 60050100,
+                200 => 60050200
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                10  => 60040010,
+                20  => 60040020,
+                30  => 60040030,
+                50  => 60040050,
+                100 => 60040100,
+                200 => 60040200
+            ]
+    ];
+}

BIN
helper/refill/api/xyz/dashang_normal/下游对接供货接口.docx


+ 34 - 0
helper/refill/api/xyz/dashang_normal/开户信息.txt

@@ -0,0 +1,34 @@
+ 开户信息如下:
+北京国研方略信息科学研究院
+查单平台:http://bm.jiaoyi101.com
+登录名:gyflbilldj
+初始密码:sup123456
+对接信息
+userId:80800357
+key: 1d3a51d49c3b0ba2685389b52f26bffb
+下单:http://47.114.209.57/unicomAync/buy.do
+查询:http://47.114.209.57/unicomAync/queryBizOrder.do
+余额:http://47.114.209.57/unicomAync/queryBalance.do
+
+
+话费低价产品编码
+60040010 全国电信10
+60040020 全国电信20
+60040030 全国电信30
+60040050 全国电信50
+60040100 全国电信100
+60040200 全国电信200
+
+60050010 全国联通10
+60050020 全国联通20
+60050030 全国联通30
+60050050 全国联通50
+60050100 全国联通100
+60050200 全国联通200
+
+60030010 全国移动10
+60030020 全国移动20
+60030030 全国移动30
+60030050 全国移动50
+60030100 全国移动100
+60030200 全国移动200

+ 4 - 0
mobile/callback/refill_dashang_normal.php

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

+ 15 - 1
test/TestRefill.php

@@ -1282,7 +1282,21 @@ class TestRefill extends TestCase
         $params = json_decode($body, true);
         $provider = $this->getProvider('feimingyu','RefillCallBack');
         $ret = $provider->verify($params);
-        $data = $provider->notify($params);
+        $resp = $provider->notify($params);
+    }
+
+    public function testDashangnormal()
+    {
+//        $provider = $this->getProvider('dashang_normal');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(18074608795, 6, 30, ['order_sn' => $this->make_sn()]);
+//        $resp = $provider->query(['order_sn' => '34461636081408575185']);
+
+        $body = '{"userId":"80800357","bizId":"60040030","ejId":"91105110431325","downstreamSerialno":"34461636081408575185","status":"3","voucher":"","voucherType":"0","sign":"24a40c2b677820533e418d4a2b3f0806"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('dashang_normal','RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
     }
 
     public function testAmingjd()