xiaoyu vor 3 Jahren
Ursprung
Commit
fcc7897da6

+ 39 - 1
data/config/win/refill.ini.php

@@ -1474,6 +1474,43 @@ $hongxudagy996_phone = ['name' => 'hongxudagy996', 'store_id' => 91, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$bingdht_phone = ['name' => 'bingdht', 'store_id' => 92,'qualitys' => '5',
+    'amount' => [
+        10 => [
+            ['goods_id' => 6833, 'price' => 9.05, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6833, 'price' => 8.95, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        20 => [
+            ['goods_id' => 6834, 'price' => 18.1, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6834, 'price' => 17.9, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        30 => [
+            ['goods_id' => 6835, 'price' => 27.15, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6835, 'price' => 26.85, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 6836, 'price' => 45.25, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6836, 'price' => 44.75, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 6837, 'price' => 90.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6837, 'price' => 89.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 6838, 'price' => 181, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6838, 'price' => 179, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        300 => [
+            ['goods_id' => 6839, 'price' => 271.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6839, 'price' => 268.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        500 => [
+            ['goods_id' => 6840, 'price' => 452.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6840, 'price' => 447.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1536,7 +1573,8 @@ $phone_providers = [
     ['name' => 'yunchonggong', 'cfg' => $yunchonggong_phone],
     ['name' => 'yunchonggongman', 'cfg' => $yunchonggongman_phone],
     ['name' => 'hongxudayz996', 'cfg' => $hongxudayz996_phone],
-    ['name' => 'hongxudagy996', 'cfg' => $hongxudagy996_phone]
+    ['name' => 'hongxudagy996', 'cfg' => $hongxudagy996_phone],
+    ['name' => 'bingdht', 'cfg' => $bingdht_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1474,6 +1474,43 @@ $hongxudagy996_phone = ['name' => 'hongxudagy996', 'store_id' => 91, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$bingdht_phone = ['name' => 'bingdht', 'store_id' => 92,'qualitys' => '5',
+    'amount' => [
+        10 => [
+            ['goods_id' => 6833, 'price' => 9.05, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6833, 'price' => 8.95, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        20 => [
+            ['goods_id' => 6834, 'price' => 18.1, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6834, 'price' => 17.9, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        30 => [
+            ['goods_id' => 6835, 'price' => 27.15, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6835, 'price' => 26.85, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 6836, 'price' => 45.25, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6836, 'price' => 44.75, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 6837, 'price' => 90.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6837, 'price' => 89.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 6838, 'price' => 181, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6838, 'price' => 179, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        300 => [
+            ['goods_id' => 6839, 'price' => 271.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6839, 'price' => 268.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        500 => [
+            ['goods_id' => 6840, 'price' => 452.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6840, 'price' => 447.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1536,7 +1573,8 @@ $phone_providers = [
     ['name' => 'yunchonggong', 'cfg' => $yunchonggong_phone],
     ['name' => 'yunchonggongman', 'cfg' => $yunchonggongman_phone],
     ['name' => 'hongxudayz996', 'cfg' => $hongxudayz996_phone],
-    ['name' => 'hongxudagy996', 'cfg' => $hongxudagy996_phone]
+    ['name' => 'hongxudagy996', 'cfg' => $hongxudagy996_phone],
+    ['name' => 'bingdht', 'cfg' => $bingdht_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -1474,6 +1474,43 @@ $hongxudagy996_phone = ['name' => 'hongxudagy996', 'store_id' => 91, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$bingdht_phone = ['name' => 'bingdht', 'store_id' => 92,'qualitys' => '5',
+    'amount' => [
+        10 => [
+            ['goods_id' => 6833, 'price' => 9.05, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6833, 'price' => 8.95, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        20 => [
+            ['goods_id' => 6834, 'price' => 18.1, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6834, 'price' => 17.9, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        30 => [
+            ['goods_id' => 6835, 'price' => 27.15, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6835, 'price' => 26.85, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        50 => [
+            ['goods_id' => 6836, 'price' => 45.25, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6836, 'price' => 44.75, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        100 => [
+            ['goods_id' => 6837, 'price' => 90.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6837, 'price' => 89.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        200 => [
+            ['goods_id' => 6838, 'price' => 181, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6838, 'price' => 179, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        300 => [
+            ['goods_id' => 6839, 'price' => 271.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6839, 'price' => 268.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ],
+        500 => [
+            ['goods_id' => 6840, 'price' => 452.5, 'quality' => 5, 'card_type' => 'chinamobile,chinatelecom'],
+            ['goods_id' => 6840, 'price' => 447.5, 'quality' => 5, 'card_type' => 'chinaunicom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -1536,7 +1573,8 @@ $phone_providers = [
     ['name' => 'yunchonggong', 'cfg' => $yunchonggong_phone],
     ['name' => 'yunchonggongman', 'cfg' => $yunchonggongman_phone],
     ['name' => 'hongxudayz996', 'cfg' => $hongxudayz996_phone],
-    ['name' => 'hongxudagy996', 'cfg' => $hongxudagy996_phone]
+    ['name' => 'hongxudagy996', 'cfg' => $hongxudagy996_phone],
+    ['name' => 'bingdht', 'cfg' => $bingdht_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

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

@@ -0,0 +1,50 @@
+<?php
+namespace refill\bingdht;
+
+require_once(BASE_HELPER_RAPI_PATH . '/bingdht/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $sign = $this->sign($params);
+        if ($params['szVerifyString'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nDemo={$params['nDemo']}&fSalePrice={$params['fSalePrice']}";
+        $content .= "&nFlag={$params['nFlag']}&szKey={$key}";
+        return md5($content);
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['nFlag']);
+        $order_sn = $params['szOrderId'];
+        $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['szRtnMsg']) == 'null' ? '' : $params['szRtnMsg'];
+            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];
+        }
+    }
+}

+ 104 - 0
helper/refill/api/xyz/bingdht/RefillPhone.php

@@ -0,0 +1,104 @@
+<?php
+
+namespace refill\bingdht;
+
+require_once(BASE_HELPER_RAPI_PATH . '/bingdht/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['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $order_sn;
+        $params['szPhoneNum'] = $phone;
+        $params['nMoney'] = $amount;
+        $params['nSortType'] = config::operator[$card_type];
+        $params['nProductClass'] = 1;
+        $params['nProductType'] = 1;
+        $params['szTimeStamp'] = date("Y-m-d H:i:s");
+        $params['szNotifyUrl'] = config::NOTIFY_URL;
+        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['szVerifyString'] = $sign;
+
+        $resp = http_request(config::ORDER_URL, $params, 'POST', false, 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['nRtn'] == 0) {
+                return [true, '', false];
+            } else {
+                return [false, $resp['szRtnCode'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['szAgentId'] = config::USER_ID;
+        $params['szOrderId'] = $refill_info['order_sn'];
+        $key = config::KEY;
+        $content = "szAgentId={$params['szAgentId']}&szOrderId={$params['szOrderId']}&szKey={$key}";
+        $params['szVerifyString'] = md5($content);
+
+        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+
+        if (empty($resp)) {
+            return [false, '网络错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '网络错误'];
+            }
+            $status = intval($resp['nRtn']);
+            if ($status === 5012) {
+                $updata['official_sn'] = $resp['szRtnMsg'];
+                Model('refill_order')->edit($refill_info['order_id'], $updata);
+                $order_state = ORDER_STATE_SUCCESS;
+            } elseif ($status === 5013) {
+                $order_state = ORDER_STATE_CANCEL;
+            } elseif (in_array($status, [5011, 5019])) {
+                $order_state = ORDER_STATE_SEND;
+            } elseif ($status === 5005 && (time() - $refill_info['commit_time'] >= 300)) {
+                $order_state = ORDER_STATE_NOEXIST;
+            } else {
+                return [false, $status];
+            }
+            return [true, $order_state];
+        }
+    }
+
+    private function sign($params)
+    {
+        $userid = config::USER_ID;
+        $key = config::KEY;
+        $content = "szAgentId={$userid}&szOrderId={$params['szOrderId']}&szPhoneNum={$params['szPhoneNum']}&nMoney={$params['nMoney']}&nSortType={$params['nSortType']}";
+        $content .= "&nProductClass={$params['nProductClass']}&nProductType={$params['nProductType']}&szTimeStamp={$params['szTimeStamp']}&szKey={$key}";
+        return md5($content);
+    }
+}

+ 11 - 0
helper/refill/api/xyz/bingdht/api.txt

@@ -0,0 +1,11 @@
+开发文档:https://docs.qq.com/doc/DWkV1VkxQVk13eEtQ
+
+话费、油卡下单地址:http://116.62.100.67:10186/plat/api/old/submitorder
+查询地址:http://116.62.100.67:10186/plat/api/old/queryorder
+查询余额地址:http://116.62.100.67:10186/plat/api/old/queryBalance
+
+管理端:http://116.62.100.67:10186/plat/index
+账号:bjyz001
+初始密码:123456
+商户ID:200044
+密钥:53c402addd464518960b1eeff9097445

+ 22 - 0
helper/refill/api/xyz/bingdht/config.php

@@ -0,0 +1,22 @@
+<?php
+
+
+namespace refill\bingdht;
+
+use mtopcard;
+class config
+{
+    //lt 895 yd dx 905
+    const ORDER_URL = 'http://116.62.100.67:10186/plat/api/old/submitorder';
+    const QUERY_URL= 'http://116.62.100.67:10186/plat/api/old/queryorder';
+
+    const USER_ID= '200044';
+    const KEY = '53c402addd464518960b1eeff9097445';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_bingdht.php";
+    const operator = [
+        mtopcard\ChinaMobileCard  => 1,
+        mtopcard\ChinaUnicomCard  => 2,
+        mtopcard\ChinaTelecomCard => 3
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+}

+ 4 - 0
mobile/callback/refill_bingdht.php

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

+ 10 - 0
test/TestRefill.php

@@ -726,6 +726,16 @@ class TestRefill extends TestCase
         refill\RefillFactory::instance()->notify('yunchonggong',$input);
     }
 
+    public function testBingdht()
+    {
+        $providers = new refill\bingdht\RefillPhone([]);
+//        $resp = $providers->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
+//        $resp = $providers->query(['order_sn' => '62491626761331174794']);
+        $data = '{"szOrderId":"62491626761331174794","fSalePrice":"45.25","szAgentId":"200044","nFlag":"3","szVerifyString":"46745191d31b16ee7978a7f5554357d6","szPhoneNum":"18500608333","szRtnMsg":"","nDemo":"50"}';
+        $input = json_decode($data, true);
+        refill\RefillFactory::instance()->notify('bingdht',$input);
+    }
+
     public function testPrice()
     {
         $amounts = [10, 20, 30, 50, 100, 200, 300, 500];