xiaoyu il y a 3 ans
Parent
commit
7832e8f5fc

+ 38 - 0
data/config/win/refill.ini.php

@@ -2489,6 +2489,43 @@ $hangtong_phone = ['name' => 'hangtong', 'store_id' => 126,'qualitys' => '1',
     ],
     'refill_type' => 'api'];
 
+$dashang_phone = ['name' => 'dashang', 'store_id' => 127, 'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7108, 'price' => 10.05, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7108, 'price' => 9.98, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 7109, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7109, 'price' => 19.96, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 7110, 'price' => 30.15, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7110, 'price' => 29.94, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7111, 'price' => 50.25, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7111, 'price' => 49.9, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7112, 'price' => 100.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7112, 'price' => 99.8, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7113, 'price' => 201, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7113, 'price' => 199.6, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7114, 'price' => 301.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7114, 'price' => 299.4, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7115, 'price' => 502.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7115, 'price' => 499, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2585,6 +2622,7 @@ $phone_providers = [
     ['name' => 'zhongst_mix', 'cfg' => $zhongst_mix_phone],
     ['name' => 'jinfeng', 'cfg' => $jinfeng_phone],
     ['name' => 'hangtong', 'cfg' => $hangtong_phone],
+    ['name' => 'dashang', 'cfg' => $dashang_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -2489,6 +2489,43 @@ $hangtong_phone = ['name' => 'hangtong', 'store_id' => 126,'qualitys' => '1',
     ],
     'refill_type' => 'api'];
 
+$dashang_phone = ['name' => 'dashang', 'store_id' => 127, 'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7108, 'price' => 10.05, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7108, 'price' => 9.98, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 7109, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7109, 'price' => 19.96, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 7110, 'price' => 30.15, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7110, 'price' => 29.94, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7111, 'price' => 50.25, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7111, 'price' => 49.9, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7112, 'price' => 100.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7112, 'price' => 99.8, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7113, 'price' => 201, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7113, 'price' => 199.6, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7114, 'price' => 301.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7114, 'price' => 299.4, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7115, 'price' => 502.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7115, 'price' => 499, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2585,6 +2622,7 @@ $phone_providers = [
     ['name' => 'zhongst_mix', 'cfg' => $zhongst_mix_phone],
     ['name' => 'jinfeng', 'cfg' => $jinfeng_phone],
     ['name' => 'hangtong', 'cfg' => $hangtong_phone],
+    ['name' => 'dashang', 'cfg' => $dashang_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 38 - 0
data/config/xyzadm/refill.ini.php

@@ -2489,6 +2489,43 @@ $hangtong_phone = ['name' => 'hangtong', 'store_id' => 126,'qualitys' => '1',
     ],
     'refill_type' => 'api'];
 
+$dashang_phone = ['name' => 'dashang', 'store_id' => 127, 'qualitys' => '2',
+    'amount' => [
+        10 => [
+            ['goods_id' => 7108, 'price' => 10.05, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7108, 'price' => 9.98, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        20 => [
+            ['goods_id' => 7109, 'price' => 20.1, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7109, 'price' => 19.96, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        30 => [
+            ['goods_id' => 7110, 'price' => 30.15, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7110, 'price' => 29.94, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 7111, 'price' => 50.25, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7111, 'price' => 49.9, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7112, 'price' => 100.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7112, 'price' => 99.8, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7113, 'price' => 201, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7113, 'price' => 199.6, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7114, 'price' => 301.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7114, 'price' => 299.4, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7115, 'price' => 502.5, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7115, 'price' => 499, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2585,6 +2622,7 @@ $phone_providers = [
     ['name' => 'zhongst_mix', 'cfg' => $zhongst_mix_phone],
     ['name' => 'jinfeng', 'cfg' => $jinfeng_phone],
     ['name' => 'hangtong', 'cfg' => $hangtong_phone],
+    ['name' => 'dashang', 'cfg' => $dashang_phone],
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -0,0 +1,50 @@
+<?php
+namespace refill\dashang;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dashang/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];
+        }
+    }
+}

+ 156 - 0
helper/refill/api/xyz/dashang/RefillPhone.php

@@ -0,0 +1,156 @@
+<?php
+
+namespace refill\dashang;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dashang/config.php');
+
+use refill;
+use Log;
+use mtopcard;
+
+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 ($status === 'success' && $code === '00') {
+                return [true, $resp['bizOrderId'], false];
+            } elseif (in_array($code, [23, 31])) {
+                $net_errno = "HTTP-{$code}";
+                return [false, $code, false];
+            } 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($status === 'success' && $code === '00')
+                {
+                    $status = intval($resp['data']['status']);
+                    if ($status === 2) {
+                        $updata['official_sn'] = $resp['data']['outOrderNo'];
+                        Model('refill_order')->edit($refill_info['order_id'], $updata);
+                        $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']];
+            } 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);
+    }
+}

+ 42 - 0
helper/refill/api/xyz/dashang/config.php

@@ -0,0 +1,42 @@
+<?php
+
+
+namespace refill\dashang;
+
+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= '80800346';
+    const KEY = 'bb9c64bbd8937e03ca73f9d7b29a17af';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dashang.php";
+
+    const Products = [
+        mtopcard\ChinaUnicomCard =>
+            [
+                10  => 90330010,
+                20  => 90330020,
+                30  => 90330030,
+                50  => 90330050,
+                100 => 90330100,
+                200 => 90330200,
+                300 => 90330300,
+                500 => 90330500
+            ],
+        mtopcard\ChinaTelecomCard =>
+            [
+                10  => 90290010,
+                20  => 90290020,
+                30  => 90290030,
+                50  => 90290050,
+                100 => 90290100,
+                200 => 90290200,
+                300 => 90290300,
+                500 => 90290500
+            ]
+    ];
+}

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


+ 31 - 0
helper/refill/api/xyz/dashang/开户信息-1.txt

@@ -0,0 +1,31 @@
+ 开户信息如下:
+北京国研方略信息科学研究院
+查单平台:http://bm.jiaoyi101.com
+登录名:gyflbill
+初始密码:sup123456
+对接信息
+userId:80800346
+key: bb9c64bbd8937e03ca73f9d7b29a17af
+下单:http://47.114.209.57/unicomAync/buy.do
+查询:http://47.114.209.57/unicomAync/queryBizOrder.do
+余额:http://47.114.209.57/unicomAync/queryBalance.do
+
+
+联通沃支付
+90330010 中国联通-官方10
+90330020 中国联通-官方20
+90330030 中国联通-官方30
+90330050 中国联通-官方50
+90330100 中国联通-官方100
+90330200 中国联通-官方200
+90330300 中国联通-官方300
+90330500 中国联通-官方500
+电信电渠
+90290010 中国电信-电渠10
+90290020 中国电信-电渠20
+90290030 中国电信-电渠30
+90290050 中国电信-电渠50
+90290100 中国电信-电渠100
+90290200 中国电信-电渠200
+90290300 中国电信-电渠300
+90290500 中国电信-电渠500

+ 4 - 0
mobile/callback/refill_dashang.php

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

+ 14 - 0
test/TestRefill.php

@@ -997,6 +997,20 @@ class TestRefill extends TestCase
         $resp = $providers->notify($params);
     }
 
+    public function testDashang()
+    {
+//        $providers = $this->getProvider('dashang');
+//        $resp = $providers->balance();
+//        $resp = $providers->add(18074608795, 6, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '63101631784169445345']);
+
+        $body = '{"userId":"80800346","bizId":"90290050","ejId":"90916171545126","downstreamSerialno":"67971631783703671946","status":"3","voucher":"","voucherType":"0","sign":"46b13acf67f271e2f85db189ab9e1391"}';
+        $params = json_decode($body, true);
+        $providers = $this->getProvider('dashang','RefillCallBack');
+        $ret = $providers->verify($params);
+        $resp = $providers->notify($params);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);