xiaoyu 2 年 前
コミット
f0b158b2e4

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

@@ -6317,6 +6317,51 @@ $huoshenguo_fs_phone = ['name' => 'huoshenguo_fs', 'store_id' => 237, 'qualitys'
     ],
     'official_sn' => true, 'refill_type' => 'api'];
 
+$jinglan_phone = ['name' => 'jinglan', 'store_id' => 238, 'qualitys' => '2',
+    'amount' => [
+//        10 => [
+//            ['goods_id' => 7967, 'price' => 10.02, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7967, 'price' => 10, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7967, 'price' => 10, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        20 => [
+//            ['goods_id' => 7968, 'price' => 20.04, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7968, 'price' => 20, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7968, 'price' => 20, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+//        30 => [
+//            ['goods_id' => 7969, 'price' => 30.06, 'quality' => 2, 'card_type' => 'chinamobile'],
+//            ['goods_id' => 7969, 'price' => 30, 'quality' => 2, 'card_type' => 'chinaunicom'],
+//            ['goods_id' => 7969, 'price' => 30, 'quality' => 2, 'card_type' => 'chinatelecom']
+//        ],
+        50 => [
+            ['goods_id' => 7970, 'price' => 50.1, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7970, 'price' => 50, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7970, 'price' => 50, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        100 => [
+            ['goods_id' => 7971, 'price' => 100.2, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7971, 'price' => 100, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7971, 'price' => 100, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        200 => [
+            ['goods_id' => 7972, 'price' => 200.4, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7972, 'price' => 200, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7972, 'price' => 200, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        300 => [
+            ['goods_id' => 7973, 'price' => 300.6, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7973, 'price' => 300, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7973, 'price' => 300, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ],
+        500 => [
+            ['goods_id' => 7974, 'price' => 501, 'quality' => 2, 'card_type' => 'chinamobile'],
+            ['goods_id' => 7974, 'price' => 500, 'quality' => 2, 'card_type' => 'chinaunicom'],
+            ['goods_id' => 7974, 'price' => 500, 'quality' => 2, 'card_type' => 'chinatelecom']
+        ]
+    ],
+    'official_sn' => true, 'refill_type' => 'api'];
+
 $phone_providers = [
 //    ['name' => 'beixt', 'cfg' => $beixt_phone],
 //    ['name' => 'bxtwt', 'cfg' => $bxtwt_phone],
@@ -6511,6 +6556,7 @@ $phone_providers = [
     ['name' => 'xinruiheng', 'cfg' => $xinruiheng_phone],
     ['name' => 'dezhi', 'cfg' => $dezhi_phone],
     ['name' => 'huoshenguo_fs', 'cfg' => $huoshenguo_fs_phone],
+    ['name' => 'jinglan', 'cfg' => $jinglan_phone],
 
 ];
 $config['phone_providers'] = $phone_providers;

+ 18 - 16
helper/refill/api/xyz/jinglan/RefillCallBack.php

@@ -8,8 +8,10 @@ class RefillCallBack implements refill\IRefillCallBack
 {
     public function verify($params): bool
     {
-        $sign = $this->sign($params);
-        if ($params['Sign'] == $sign) {
+        $input = $params;
+        unset($input['sign']);
+        $sign = $this->sign($input);
+        if ($params['sign'] == $sign) {
             return true;
         } else {
             return false;
@@ -18,30 +20,30 @@ class RefillCallBack implements refill\IRefillCallBack
 
     private function sign($params)
     {
-        $key = config::KEY;
-        $content = "Orderid={$params['Orderid']}&Chargeid={$params['Chargeid']}&Orderstatu_int={$params['Orderstatu_int']}&Errorcode={$params['Errorcode']}&Password={$key}";
+        ksort($params);
+        $content = '';
+        foreach ($params as $key => $value) {
+            $content .= "{$key}={$value}&";
+        }
+        $content .= "key=" . config::KEY;
         return md5($content);
     }
 
-
     public function notify($params)
     {
-        $status = intval($params['Orderstatu_int']);
-        $order_sn = $params['Orderid'];
+        $status = intval($params['orderState']);
+        $order_sn = $params['merOrderNo'];
         $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 (in_array($status, [11, 16])) {
-            return [$order_id, true, false,true];
-        }
-        elseif (in_array($status, [20, 21, 26])) {
-            return [$order_id, false, true,true];
-        }
-        else {
-            return [$order_id, false, false,false];
+        if ($status === 24) {
+            return [$order_id, true, false, true];
+        } elseif (in_array($status, [23, -1])) {
+            return [$order_id, false, true, true];
+        } else {
+            return [$order_id, false, false, false];
         }
     }
 }

+ 18 - 18
helper/refill/api/xyz/jinglan/RefillPhone.php

@@ -47,7 +47,7 @@ class RefillPhone extends refill\IRefillPhone
             if (empty($resp)) {
                 return [false, '网络错误', true];
             } elseif ($resp['resultCode'] === '0') {
-                return [true, $resp['orderNo'], false];
+                return [true, $resp['data']['orderNo'], false];
             } elseif (in_array($resp['resultCode'], config::ERRCODES, true)) {
                 return [false, $resp['resultMsg'], false];
             } elseif (in_array($resp['resultCode'], ['12', '13', '14', '15', '999'], true)) {
@@ -91,15 +91,15 @@ class RefillPhone extends refill\IRefillPhone
                 if ((time() - $refill_info['commit_time'] < 60)) {
                     return [false, '下单一分钟后查询'];
                 }
-                $status = $resp['orderStatuInt'];
-                if (in_array($status, ['11', '16'], true)) {
+                $status = $resp['data']['orderState'];
+                if ($status === 24) {
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif (in_array($status, ['20', '21', '26'], true)) {
+                } elseif (in_array($status, [23, -1], true)) {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif (in_array($status, ['0', '1', '2', '6'], true)) {
+                } elseif (in_array($status, [0, 20], true)) {
                     $order_state = ORDER_STATE_SEND;
                 } else {
-                    return [false, $resp['resultMsg']];
+                    return [false, $status];
                 }
                 return [true, $order_state];
             } elseif ($resp['resultCode'] === '12' && (time() - $refill_info['commit_time'] > 600)) {
@@ -113,15 +113,18 @@ class RefillPhone extends refill\IRefillPhone
     public function balance()
     {
         $params_getter = function () {
-            $params['action'] = 'YE';
+            $params = [];
+            $params['action'] = 'queryBalance';
+            $params['requestTime'] = date("Y-m-d H:i:s");
+            $params['merAccount'] = config::ACCOUNT;
+
             return $params;
         };
 
         $params = $params_getter();
-        $body = $this->pack_params($params);
+        $params['sign'] = $this->sign($params);
 
-        $resp = http_post_data(config::API_URL, $body, config::ExtHeaders, $net_errno);
-        $resp = iconv('GB2312', 'UTF-8', $resp);
+        $resp = http_request(config::API_URL, $params, 'POST', false, config::ExtHeaders, $net_errno);
 
         if (empty($resp)) {
             return [false, '系统错误'];
@@ -133,25 +136,22 @@ class RefillPhone extends refill\IRefillPhone
 
             if (empty($resp)) {
                 return [false, '系统错误'];
-            } elseif ($resp['errorCode'] === 1) {
-                return [true, $resp['agentBalance']];
+            } elseif ($resp['resultCode'] === '0') {
+                return [true, $resp['data']['balance']];
             } else {
-                return [false, $resp['errorDesc']];
+                return [false, $resp['resultMsg']];
             }
         }
     }
 
     private function sign($params)
     {
-        $key = config::KEY;
         ksort($params);
         $content = '';
         foreach ($params as $key => $value) {
-            if($this->check_empty($value) === false) {
-                $content .= "{$key}={$value}&";
-            }
+            $content .= "{$key}={$value}&";
         }
-        $content .= "key={$key}";
+        $content .= "key=" . config::KEY;
         return md5($content);
     }
 }

+ 4 - 0
mobile/callback/refill_jinglan.php

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

ファイルの差分が大きいため隠しています
+ 16 - 1
test/TestRefill.php