xiaoyu 3 years ago
parent
commit
f29da21420

+ 18 - 19
helper/refill/api/xyz/dinghui/RefillPhone.php

@@ -15,7 +15,7 @@ class RefillPhone extends refill\IRefillPhone
     }
 
     //统一请求
-    private function url_request($messages, $method)
+    private function url_request($message, $method)
     {
         $params['msgtype'] = 'request_msg';
         $params['format'] = 'json';
@@ -25,27 +25,29 @@ class RefillPhone extends refill\IRefillPhone
         $params['method'] = $method;
         $params['channel'] = 'wap';
         $params['request_id'] = "REQ".$params['timestamp'];
-        $params['messages'] = $messages;
+        $params['message'] = $message;
 
         $sign = $this->sign($params);
         $params['sign'] = $sign;
-        $params = json_encode($params);
 
         $url = config::API_URL;
-        return http_post_data($url, $params, config::ExtHeaders, $net_errno);
+        return http_request($url, $params, 'POST', false, [], $net_errno);
     }
 
     private function req_params(int $phone, int $card_type, int $amount, string $order_sn)
     {
-        $params['app_order_no'] = $order_sn;
         $params['goods_sku'] = config::SKU[$card_type][$amount];
+        $params['app_order_no'] = $order_sn;
         $params['goods_count'] = 1;
 
-        $charge_params['charge_account_os_type'] = '';
-        $charge_params['charge_account_type'] = 'MOBILE';
-        $charge_params['charge_account_number'] = $phone;
-        $charge_params['charge_type'] = 0;
-        $params['charge_query_info'] = json_encode($charge_params);
+        $charge_params = [];
+        $charge_params = (object)$charge_params;
+        $charge_params->charge_account_number = "{$phone}";
+        $charge_params->charge_type = 0;
+        $charge_params->charge_account_type = 'MOBILE';
+        $charge_params->charge_account_os_type = '';
+
+        $params['charge_query_info'] = $charge_params;
 
         $params['notify_url'] = config::NOTIFY_URL;
         return $params;
@@ -67,7 +69,7 @@ class RefillPhone extends refill\IRefillPhone
             $resp = json_decode($resp, true);
             if (empty($resp)) {
                 return [false, '系统错误', true];
-            } elseif ($resp['errorCode'] === '000000') {
+            } elseif ($resp['code'] === '000000') {
                 return [true, $resp['result']['trade_no'], false];
             } else {
                 return [false, $resp['msg'], false];
@@ -91,10 +93,9 @@ class RefillPhone extends refill\IRefillPhone
 
             if (empty($resp)) {
                 return [false, '系统错误'];
-            } elseif ($resp['errorCode'] === '000000') {
+            } elseif ($resp['code'] === '000000') {
                 $status = $resp['result']['charge_result'];
                 if ($status === 'SUCCESS') {
-                    Model('refill_order')->edit($refill_info['order_id'], ['official_sn' => $resp['result']['charge_details']['charge_serial_id']]);
                     $order_state = ORDER_STATE_SUCCESS;
                 } elseif ($status === 'FAILED') {
                     $order_state = ORDER_STATE_CANCEL;
@@ -115,9 +116,9 @@ class RefillPhone extends refill\IRefillPhone
         $content = '';
         ksort($params);
         foreach ($params as $key => $val){
-            $content .= "{$key}={$val}";
+            $content .= "{$key}={$val}&";
         }
-
+        $content = rtrim($content,'&');
         $res = openssl_pkey_get_private(config::PRIVATE_KEY);
         openssl_sign($content, $sign, $res);
         return bin2hex($sign);
@@ -130,9 +131,7 @@ class RefillPhone extends refill\IRefillPhone
 
     private function pub_message($params): string
     {
-        $encrypt = json_encode($params);
-        $data = openssl_encrypt($encrypt, 'AES-128-ECB', config::AES_KEY, OPENSSL_RAW_DATA);
-        return base64_encode($data);
+        $encrypt = json_encode($params, JSON_UNESCAPED_SLASHES);
+        return openssl_encrypt($encrypt, 'AES-256-ECB', config::AES_KEY, 0, '');
     }
-
 }

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

@@ -19,7 +19,7 @@ class config
 
         ],
         mtopcard\ChinaUnicomCard => [
-            30 => 'DHCAR_TCSP01',
+            50 => 'YEZI_HF050',
         ],
         mtopcard\ChinaTelecomCard => [