瀏覽代碼

yezi siyicheng

xiaoyu 2 年之前
父節點
當前提交
4f759d42df

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

@@ -8330,6 +8330,51 @@ $jiuyi_phone = ['name' => 'jiuyi', 'store_id' => 303, 'qualitys' => '2',
     ],
     ],
     'official_sn' => true, 'refill_type' => 'api'];
     'official_sn' => true, 'refill_type' => 'api'];
 
 
+$siyicheng_phone = ['name' => 'siyicheng', 'store_id' => 304, 'qualitys' => '1',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 8512, 'price' => 10.01, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8512, 'price' => 10.01, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8512, 'price' => 10.01, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 8513, 'price' => 20.02, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8513, 'price' => 20.02, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8513, 'price' => 20.02, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+        30 => [
+//            ['goods_id' => 8514, 'price' => 30.03, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8514, 'price' => 28.35, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8514, 'price' => 30.03, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        50 => [
+            ['goods_id' => 8515, 'price' => 48.4, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8515, 'price' => 47.25, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8515, 'price' => 51.5, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 8516, 'price' => 96.8, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8516, 'price' => 94.5, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8516, 'price' => 100.05, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 8517, 'price' => 193.6, 'quality' => 1, 'card_type' => 'chinamobile'],
+            ['goods_id' => 8517, 'price' => 189, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8517, 'price' => 200.1, 'quality' => 1, 'card_type' => 'chinatelecom']
+        ],
+//        300 => [
+//            ['goods_id' => 8518, 'price' => 300.15, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8518, 'price' => 300.15, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8518, 'price' => 300.15, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ],
+//        500 => [
+//            ['goods_id' => 8519, 'price' => 500.25, 'quality' => 1, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 8519, 'price' => 500.25, 'quality' => 1, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 8519, 'price' => 500.25, 'quality' => 1, 'card_type' => 'chinatelecom']
+//        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -8587,6 +8632,7 @@ $phone_providers = [
     ['name' => 'shenzhou', 'cfg' => $shenzhou_phone],
     ['name' => 'shenzhou', 'cfg' => $shenzhou_phone],
     ['name' => 'shenzhou_ylyw', 'cfg' => $shenzhou_ylyw_phone],
     ['name' => 'shenzhou_ylyw', 'cfg' => $shenzhou_ylyw_phone],
     ['name' => 'jiuyi', 'cfg' => $jiuyi_phone],
     ['name' => 'jiuyi', 'cfg' => $jiuyi_phone],
+    ['name' => 'siyicheng', 'cfg' => $siyicheng_phone],
 
 
 ];
 ];
 $config['phone_providers'] = $phone_providers;
 $config['phone_providers'] = $phone_providers;

+ 67 - 0
helper/refill/api/xyz/siyicheng/RefillCallBack.php

@@ -0,0 +1,67 @@
+<?php
+namespace refill\siyicheng;
+
+require_once(BASE_HELPER_RAPI_PATH . '/siyicheng/config.php');
+
+use refill;
+class RefillCallBack implements refill\IRefillCallBack
+{
+    public function verify($params): bool
+    {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+
+    private function check_empty($value)
+    {
+        if (!isset($value))
+            return true;
+        if ($value === null)
+            return true;
+        if (trim($value) === "")
+            return true;
+
+        return false;
+    }
+
+    public function notify($params)
+    {
+        $status = intval($params['orderStatus']);
+        $order_sn = $params['outOrderId'];
+        $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) {
+            $data['official_sn'] = strtolower($params['ext1']) == 'null' ? '' : $params['ext1'];
+            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];
+        }
+    }
+}

+ 155 - 0
helper/refill/api/xyz/siyicheng/RefillPhone.php

@@ -0,0 +1,155 @@
+<?php
+
+namespace refill\siyicheng;
+
+require_once(BASE_HELPER_RAPI_PATH . '/siyicheng/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['appId'] = config::APP_ID;
+        $params['outOrderId'] = $order_sn;
+        $params['uuid'] = $phone;
+        $params['itemId'] = config::PRODUCT[$card_type][$amount];
+        $params['itemFace'] = $amount;
+        $params['callbackUrl'] = config::NOTIFY_URL;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        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);
+        if(empty($params['itemId'])) {
+            return [false, '商品编号错误', false];
+        }
+        $sign = $this->sign($params);
+        $params['sign'] = $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['code'] === '00') {
+                return [true, $resp['orderId'], false];
+            } elseif (in_array($resp['code'], config::ERRCODES, true)) {
+                return [false, $resp['msg'], false];
+            } elseif (in_array($resp['code'], ['-22', '-23', '-99'], true)) {
+                $net_errno = "HTTP-{$resp['code']}";
+                return [false, $resp['msg'], true];
+            } else {
+                $net_errno = "HTTP-998";
+                return [false, $resp['msg'], true];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['appId'] = config::APP_ID;
+        $params['outOrderId'] = $refill_info['order_sn'];
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $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, '网络错误'];
+            }
+            elseif ($resp['code'] === '00')
+            {
+                $status = $resp['orderStatus'];
+                if ($status === '2') {
+                    $updata['official_sn'] = $resp['ext1'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === '3') {
+                    $order_state = ORDER_STATE_CANCEL;
+                } elseif ($status === '1') {
+                    $order_state = ORDER_STATE_SEND;
+                } elseif ($status === '4' && (time() - $refill_info['commit_time'] >= 600)) {
+                    $order_state = ORDER_STATE_NOEXIST;
+                } else {
+                    return [false, $resp['msg']];
+                }
+                return [true, $order_state];
+            }
+            else
+            {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    public function balance()
+    {
+        $params['appId'] = config::APP_ID;
+        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
+        $params['sign'] = $this->sign($params);
+
+        $resp = http_request(config::BALANCE_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, '网络错误'];
+            } elseif ($resp['code'] === '00') {
+                return [true, $resp['balance']];
+            } else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    /**
+     * 获取毫秒级别的时间戳
+     */
+    private function get_millisecond()
+    {
+        list($usec, $sec) = explode(" ", microtime());
+        return round($usec*1000);
+    }
+
+    private function sign($params)
+    {
+        $params['appSecret'] = config::APP_SECRET;
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            if($this->check_empty($value) === false) {
+                $content .= "{$key}={$value}&";
+            }
+        }
+        $content = rtrim($content, '&');
+        return md5($content);
+    }
+}

+ 37 - 0
helper/refill/api/xyz/siyicheng/config.php

@@ -0,0 +1,37 @@
+<?php
+
+
+namespace refill\siyicheng;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'http://121.41.113.253:9666/api/hfplat/info/submit';
+    const QUERY_URL = 'http://121.41.113.253:9666/api/info/query';
+    const BALANCE_URL = 'http://121.41.113.253:9666/api/wallet/balance';
+
+    const APP_ID = 'A3PsRxMTnw';
+    const APP_SECRET = 'XtcfHywlUEfPdaZw';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_siyicheng.php";
+
+    const PRODUCT = [
+        mtopcard\ChinaMobileCard => [
+            50  => 100211,
+            100 => 100212,
+            200 => 100213,
+        ],
+
+        mtopcard\ChinaUnicomCard => [
+            30  => 100218,
+            50  => 100219,
+            100 => 100220,
+            200 => 100221,
+        ],
+
+        mtopcard\ChinaTelecomCard => [
+
+        ]
+    ];
+    const ExtHeaders = ['Content-Type:application/x-www-form-urlencoded;charset=utf-8'];
+    const ERRCODES = ['-10', '-12', '-13', '-14', '-15', '-16', '-18', '-21'];
+}

+ 24 - 0
helper/refill/api/xyz/siyicheng/开户信息.txt

@@ -0,0 +1,24 @@
+后台地址:http://121.41.113.253:5888
+帐号:yezi
+密码:173571
+二级密码:QSsJ4876
+appId:A3PsRxMTnw
+appSecret:XtcfHywlUEfPdaZw
+后台-商品列表,可查看已配置商品信息
+后台-安全中心,可配置IP白名单
+话费直充接口:http://121.41.113.253:9666/api/hfplat/info/submit
+通用直充接口:http://121.41.113.253:9666/api/info/submit
+卡密提取接口:http://121.41.113.253:9666/api/tical/get
+查单接口接口:http://121.41.113.253:9666/api/info/query
+余额接口接口:http://121.41.113.253:9666/api/wallet/balance
+
+
+100211  全国移动50
+100212  全国移动100
+100213  全国移动200
+
+
+100218  全国联通30
+100219  全国联通50
+100220  全国联通100
+100221  全国联通200

+ 4 - 0
mobile/callback/refill_siyicheng.php

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

+ 14 - 0
test/TestRefill.php

@@ -3182,6 +3182,20 @@ class TestRefill extends TestCase
         $resp = $provider->balance();
         $resp = $provider->balance();
     }
     }
 
 
+    public function testSiyicheng()
+    {
+//        $provider = $this->getProvider('siyicheng');
+//        $resp = $provider->balance();
+//        $resp = $provider->add(15811535608, 4, 50, ['order_sn' => $this->make_sn(), 'regin_no' => 18]);
+//        $resp = $provider->query(['order_sn' => '82871678852155519038']);
+
+        $body = '{"orderId":"230315114915719293","appId":"A3PsRxMTnw","outOrderId":"82871678852155519038","sign":"d8d947c99dd19661fc4265f61c113d98","orderStatus":"3","completeTime":"20230315115208","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
+        $params = json_decode($body, true);
+        $provider = $this->getProvider('siyicheng', 'RefillCallBack');
+        $ret = $provider->verify($params);
+        $resp = $provider->notify($params);
+    }
+
     public function testAmingjd()
     public function testAmingjd()
     {
     {
 //        $provider = new refill\amingjd\RefillPhone([]);
 //        $provider = new refill\amingjd\RefillPhone([]);