Kaynağa Gözat

jumithird update and new provider dexin

xiaoyu 3 yıl önce
ebeveyn
işleme
4737533c3d

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

@@ -2061,6 +2061,19 @@ $wangliantx_phone = ['name' => 'wangliantx', 'store_id' => 112,'qualitys' => '1'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$dexin_phone = ['name' => 'dexin', 'store_id' => 113,'qualitys' => '5',
+    'amount' => [
+        10 => [['goods_id' => 6970, 'price' => 9.15, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        20 => [['goods_id' => 6971, 'price' => 18.3, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        30 => [['goods_id' => 6972, 'price' => 27.45, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        50 => [['goods_id' => 6973, 'price' => 45.75, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        100 => [['goods_id' => 6974, 'price' => 91.5, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        200 => [['goods_id' => 6975, 'price' => 183, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        300 => [['goods_id' => 6976, 'price' => 274.5, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']],
+        500 => [['goods_id' => 6977, 'price' => 457.5, 'quality' => 5, 'card_type' => 'chinamobile,chinaunicom,chinatelecom']]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -2141,7 +2154,8 @@ $phone_providers = [
     ['name' => 'guochuang', 'cfg' => $guochuang_phone],
     ['name' => 'xianghongrui', 'cfg' => $xianghongrui_phone],
     ['name' => 'dianchong', 'cfg' => $dianchong_phone],
-    ['name' => 'wangliantx', 'cfg' => $wangliantx_phone]
+    ['name' => 'wangliantx', 'cfg' => $wangliantx_phone],
+    ['name' => 'dexin', 'cfg' => $dexin_phone]
 ];
 $config['phone_providers'] = $phone_providers;
 

+ 61 - 0
helper/refill/api/xyz/dexin/RefillCallBack.php

@@ -0,0 +1,61 @@
+<?php
+
+
+namespace refill\dexin;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dexin/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)
+    {
+        ksort($params);
+        $body = "";
+        $key = config::KEY;
+        foreach ($params as $k => $v)
+        {
+            $body .= "{$k}={$v}&";
+        }
+        $body .= "key={$key}";
+        return md5($body);
+    }
+
+    //[$order_id, $success, $can_try, $need_handle]
+    public function notify($params)
+    {
+        $status = intval($params['status']);
+        $order_sn = $params['out_trade_no'];
+        $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 === 3) {
+            $data['official_sn'] = strtolower($params['official_trade_no']) == 'null' ? '' : $params['official_trade_no'];
+            $data['ch_trade_no'] = $params['trade_no'];
+            Model('refill_order')->edit($order_id, $data);
+            return [$order_id, true, false,true];
+        }
+        elseif ($status === 4) {
+            return [$order_id, false, true,true];
+        }
+        else {
+            return [$order_id, false, false,false];
+        }
+    }
+}

+ 112 - 0
helper/refill/api/xyz/dexin/RefillPhone.php

@@ -0,0 +1,112 @@
+<?php
+
+namespace refill\dexin;
+
+require_once(BASE_HELPER_RAPI_PATH . '/dexin/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, string $order_sn)
+    {
+        $params['user_id'] = config::USER_ID;
+        $params['out_trade_no'] = $order_sn;
+        $params['out_expired_time'] = '86400';
+        $params['mobile'] = "{$phone}";
+        $params['money'] = $amount;
+        $params['notify_url'] = config::NOTIFY_URL;
+
+        return $params;
+    }
+
+    public function add($card_no, $card_type, $amount, $params,&$net_errno = 0)
+    {
+        $params = $this->req_params($card_no, $amount, $params['order_sn']);
+        $sign = $this->sign($params);
+        $params['sign'] = $sign;
+
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::ORDER_URL, $params , [], $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['success'] == true && $resp['errorCode'] == 0) {
+                return [true, $resp['data']['trade_no'], false];
+            } else {
+                return [false, $resp['errorMessage'], false];
+            }
+        }
+    }
+
+    public function query($refill_info)
+    {
+        $params['user_id'] = config::USER_ID;
+        $params['out_trade_no'] = $refill_info['order_sn'];
+
+        $params['sign'] = $this->sign($params);
+        $params = json_encode($params);
+
+        $resp = http_post_data(config::QUERY_URL, $params , []);
+
+        if (empty($resp)) {
+            return [false, '系统错误'];
+        }
+        else
+        {
+            Log::record($resp, Log::DEBUG);
+            $resp = json_decode($resp, true);
+            if (empty($resp)) {
+                return [false, '系统错误'];
+            }
+            elseif ($resp['success'] == true && $resp['errorCode'] == 0)
+            {
+                $status = intval($resp['data']['status']);
+                if ($status === 3) {
+                    $updata['official_sn'] = $resp['data']['official_trade_no'];
+                    $updata['ch_trade_no'] = $resp['data']['trade_no'];
+                    Model('refill_order')->edit($refill_info['order_id'], $updata);
+                    $order_state = ORDER_STATE_SUCCESS;
+                } elseif ($status === 4) {
+                    $order_state = ORDER_STATE_CANCEL;
+                } else {
+                    $order_state = ORDER_STATE_SEND;
+                }
+                return [true, $order_state];
+            }
+            elseif($resp['code'] == 3006) {
+                return [true, ORDER_STATE_NOEXIST];
+            }
+            else {
+                return [false, $resp['msg']];
+            }
+        }
+    }
+
+    private function sign($params)
+    {
+        ksort($params);
+        $body = "";
+        $key = config::KEY;
+        foreach ($params as $k => $v)
+        {
+            $body .= "{$k}={$v}&";
+        }
+        $body .= "key={$key}";
+        return md5($body);
+    }
+}

+ 7 - 0
helper/refill/api/xyz/dexin/account.txt

@@ -0,0 +1,7 @@
+https://vip.qilinpay.xyz/user/
+beijingyezi
+123456
+谷歌验证码:551426
+
+8062
+9d8529fb51094d559fb01497ac92ae31

+ 18 - 0
helper/refill/api/xyz/dexin/config.php

@@ -0,0 +1,18 @@
+<?php
+namespace refill\dexin;
+
+use mtopcard;
+class config
+{
+    const ORDER_URL = 'https://vip.qilinpay.xyz/prepaid/mobile/submit';
+    const QUERY_URL = 'https://vip.qilinpay.xyz/prepaid/mobile/query';
+
+    const USER_ID = '8062';
+    const KEY = '9d8529fb51094d559fb01497ac92ae31';
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_dexin.php";
+    const operator = [
+        mtopcard\ChinaMobileCard => 'cmcc',
+        mtopcard\ChinaUnicomCard => 'cucc',
+        mtopcard\ChinaTelecomCard => 'ctcc'
+    ];
+}

+ 1 - 2
helper/refill/api/xyz/jumithird/config.php

@@ -9,7 +9,6 @@ class config
 
     const MCH_ID = '210303112631';
     const Token = '7e145747925c1619c341ab6d4f6a2e71';
-//    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jumi.php";
-    const NOTIFY_URL = "https://www.xyzshops.cn/mobile/signature.php";
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_jumithird.php";
     const ExtHeaders = ['Content-Type: application/json'];
 }

+ 6 - 0
mobile/callback/refill_jumithird.php

@@ -0,0 +1,6 @@
+<?php
+$content = $_SERVER['post_content'];
+$input = json_decode($content,true);
+
+refill\util::push_notify('jumithird',$input);
+echo ('SUCCESS');

+ 6 - 0
test/TestRefill.php

@@ -775,6 +775,12 @@ class TestRefill extends TestCase
         $resp = $providers->notify($params);
     }
 
+    public function testDexin()
+    {
+        $providers = $this->getProvider('dexin');
+        $resp = $providers->query(['order_sn' => '85901629801033376170']);
+    }
+
     public function testAmingjd()
     {
 //        $providers = new refill\amingjd\RefillPhone([]);