浏览代码

答题之后推送工行

lizhen 1 天之前
父节点
当前提交
7cf6697f70
共有 1 个文件被更改,包括 47 次插入8 次删除
  1. 47 8
      application/api/controller/Jiashicang.php

+ 47 - 8
application/api/controller/Jiashicang.php

@@ -288,9 +288,6 @@ class Jiashicang extends Api
      */
     public function update_villager_integral($mobile_phone = '', $integral_value = 0, $integral_type = '', $remarks = [])
     {
-        // 正式环境URL,需要替换为实际的工行API网关地址
-        //$url = 'https://gw.dccnet.com.cn:8082/api/mybank/farm/farmplatf/updateVillagerIntegral/V1';
-        $url = 'https://gw.open.icbc.com.cn/api/mybank/farm/farmplatf/syncCommunityData/V1';
 
         // 如果没有传入手机号,尝试从登录用户获取
         if (empty($mobile_phone) && isset($this->auth->mobile)) {
@@ -299,7 +296,7 @@ class Jiashicang extends Api
 
         // 生成唯一序列号
         $fSeqNo = createUniqueNo('fseq', time());
-
+        $url = 'http://apip-gateway-nrouter-saas-gn-C.month.sdc.cs.icbc:8081/api/mybank/farm/farmplatf/syncCommunityData/V1';
         // 构建业务参数
         $biz_content = [
             'fSeqNo' => $fSeqNo,
@@ -326,7 +323,7 @@ class Jiashicang extends Api
 
         // 构建通用请求参数
         $data = [
-            'app_id' => '11000000000000010974',
+            'app_id' => '10000000000004096993',
             'msg_id' => createUniqueNo('msg', time()),
             'format' => 'json',
             'charset' => 'UTF-8',
@@ -336,14 +333,56 @@ class Jiashicang extends Api
             'biz_content' => $biz_content,
         ];
 
+        // 记录请求日志(调试用)
+        \think\Log::record('积分维护接口请求: ' . json_encode($data, JSON_UNESCAPED_UNICODE), 'info');
+
         // 发送请求
         $response = curl_post($url, json_encode($data, JSON_UNESCAPED_UNICODE));
         
+        // 记录原始响应(调试用)
+        \think\Log::record('积分维护接口原始响应: ' . $response, 'info');
+        
+        // 检查响应是否为空
+        if (empty($response)) {
+            return [
+                'return_code' => '-1',
+                'return_msg' => '接口无响应',
+                'raw_response' => $response
+            ];
+        }
+        
         // 解析响应
         $result = json_decode($response, true);
         
-        // 返回结果
-        return $result ? $result : ['return_code' => '-1', 'return_msg' => '接口调用失败', 'response' => $response];
+        // 检查JSON解析是否成功
+        if (json_last_error() !== JSON_ERROR_NONE) {
+            return [
+                'return_code' => '-2',
+                'return_msg' => 'JSON解析失败: ' . json_last_error_msg(),
+                'raw_response' => $response
+            ];
+        }
+        
+        // 检查是否有response_biz_content(按API文档,响应数据在这个字段里)
+        if (isset($result['response_biz_content'])) {
+            $biz_result = json_decode($result['response_biz_content'], true);
+            if ($biz_result) {
+                // 合并业务响应和原始响应
+                return array_merge($biz_result, ['raw_response' => $response]);
+            }
+        }
+        
+        // 如果直接有return_code,直接返回
+        if (isset($result['return_code'])) {
+            return $result;
+        }
+        
+        // 返回完整结果
+        return $result ? $result : [
+            'return_code' => '-3',
+            'return_msg' => '未知响应格式',
+            'raw_response' => $response
+        ];
     }
 
     /**
@@ -360,7 +399,7 @@ class Jiashicang extends Api
 
         // 调用积分维护接口
         $result = $this->update_villager_integral($mobile_phone, $integral_value, $integral_type, $remarks);
-var_dump($result);exit;
+        var_dump($result);exit;
         // 输出结果
         if ($result['return_code'] == 0) {
             $this->success('积分推送成功', $result);