xiaoyu 3 年之前
父節點
當前提交
eb89b27fb6

+ 1 - 27
helper/refill/api/xyz/bailian/RefillCallBack.php

@@ -10,7 +10,7 @@ class RefillCallBack implements refill\IRefillCallBack
     {
         $input = $params;
         unset($input['sign']);
-        $sign = $this->sign($input);
+        $sign = config::sign($input);
         if ($params['sign'] == $sign) {
             return true;
         } else {
@@ -18,32 +18,6 @@ class RefillCallBack implements refill\IRefillCallBack
         }
     }
 
-    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']);

+ 23 - 30
helper/refill/api/xyz/bailian/RefillOil.php

@@ -61,12 +61,12 @@ class RefillOil extends refill\IRefillOil
 
     public function query($refill_info)
     {
-        $params['appId'] = config::APP_ID;
-        $params['outOrderId'] = $refill_info['order_sn'];
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
-        $sign = config::sign($params);
+        $params['time'] = time();
+        $params['macid'] = config::MAC_ID;
+        $params['id'] = $refill_info['order_sn'];
+        $params['sign'] = config::sign($params);
 
-        $resp = http_request(config::QUERY_URL, $params, 'POST', false, config::ExtHeaders);
+        $resp = http_request(config::QUERY_URL, $params, 'GET');
 
         if (empty($resp)) {
             return [false, '网络错误'];
@@ -78,41 +78,40 @@ class RefillOil extends refill\IRefillOil
             if (empty($resp)) {
                 return [false, '网络错误'];
             }
-            elseif ($resp['code'] === '00')
+            elseif ($resp['errCode'] === 0)
             {
                 $status = intval($resp['orderStatus']);
-
-                if ($status === 2) {
-                    Log::record("mengu query sms:{$resp['ext1']}",Log::DEBUG);
-                    Model('')->table('refill_ext')->insert(['order_id' => $refill_info['order_id'], 'sms' => $resp['ext1']]);
-                    $official_sn = config::official_sn($resp['ext1']);
-
-                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $official_sn]);
+                if ($status === 1) {
+                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['data']['voucher']]);
                     $order_state = ORDER_STATE_SUCCESS;
-                } elseif ($status === 3) {
+                } elseif ($status === 2) {
                     $order_state = ORDER_STATE_CANCEL;
-                } elseif ($status === 1) {
+                } elseif ($status === 3) {
                     $order_state = ORDER_STATE_SEND;
                 } else {
-                    return [false, $resp['msg']];
+                    return [false, $status];
                 }
 
                 return [true, $order_state];
             }
+            elseif ($resp['errCode'] === 4 && (time() - $refill_info['commit_time'] >= 600))
+            {
+                return [true, ORDER_STATE_NOEXIST];
+            }
             else
             {
-                return [false, $resp['msg']];
+                return [false, $resp['errInfo']];
             }
         }
     }
 
     public function balance()
     {
-        $params['appId'] = config::APP_ID;
-        $params['timestamp'] = date("YmdHis").$this->get_millisecond();
-        $sign = config::sign($params);
+        $params['time'] = time();
+        $params['macid'] = config::MAC_ID;
+        $params['sign'] = config::sign($params);
 
-        $resp = http_request(config::BALANCE_URL, $params, 'POST', false, config::ExtHeaders);
+        $resp = http_request(config::BALANCE_URL, $params, 'GET');
 
         if (empty($resp)) {
             return [false, '网络错误'];
@@ -123,17 +122,11 @@ class RefillOil extends refill\IRefillOil
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '网络错误'];
-            } elseif ($resp['code'] === '00') {
-                return [true, $resp['balance']];
+            } elseif ($resp['errCode'] === 0) {
+                return [true, $resp['data']['balance']];
             } else {
-                return [false, $resp['msg']];
+                return [false, $resp['errInfo']];
             }
         }
     }
-
-    private function get_millisecond()
-    {
-        list($usec, $sec) = explode(" ", microtime());
-        return round($usec*1000);
-    }
 }

+ 1 - 1
helper/refill/api/xyz/bailian/config.php

@@ -12,7 +12,7 @@ class config
 
     const MAC_ID = '1646476170480002';
     const KEY = 'ffcb6768ad0a8b631acd29355a31b50d';
-    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_menggu.php";
+    const NOTIFY_URL = BASE_SITE_URL . "/mobile/callback/refill_bailian.php";
     const PRODUCT = [
         mtopcard\SinopecCard => [
             500 => 100004,