Parcourir la source

兼容性问题处理

lizhen il y a 15 heures
Parent
commit
f454c82873
3 fichiers modifiés avec 18 ajouts et 9 suppressions
  1. 11 4
      addons/exam/controller/Paper.php
  2. 5 5
      application/command/IcbcQueue.php
  3. 2 0
      think

+ 11 - 4
addons/exam/controller/Paper.php

@@ -297,6 +297,12 @@ class Paper extends Base
      */
     public function update_villager_integral($mobile_phone = '', $integral_value = 0, $integral_type = '', $remarks = [])
     {
+        // PHP 8+ 兼容:确保参数不为null
+        $mobile_phone = $mobile_phone ?? '';
+        $integral_value = $integral_value ?? 0;
+        $integral_type = $integral_type ?? '';
+        $remarks = $remarks ?? [];
+        
         // 如果没有传入手机号,尝试从登录用户获取
         if (empty($mobile_phone) && isset($this->auth->mobile)) {
             $mobile_phone = $this->auth->mobile;
@@ -443,11 +449,12 @@ class Paper extends Base
     private function addIcbcQueue($mobile_phone, $integral_value, $integral_type, $nickname)
     {
         try {
+            // PHP 8+ 兼容:确保所有值都不为null
             $data = [
-                'mobile_phone' => $mobile_phone,
-                'integral_value' => $integral_value,
-                'integral_type' => $integral_type,
-                'nickname' => $nickname,
+                'mobile_phone' => $mobile_phone ?? '',
+                'integral_value' => $integral_value ?? 0,
+                'integral_type' => $integral_type ?? '',
+                'nickname' => $nickname ?? '',
                 'status' => 0, // 0-待处理, 1-处理中, 2-成功, 3-失败
                 'retry_count' => 0,
                 'createtime' => time(),

+ 5 - 5
application/command/IcbcQueue.php

@@ -104,14 +104,14 @@ class IcbcQueue extends Command
         // 生成16位唯一序列号
         $fSeqNo = time() . str_pad(mt_rand(0, 999999), 6, '0', STR_PAD_LEFT);
         
-        // 构建业务参数
+        // 构建业务参数 (PHP 8+ 兼容)
         $biz_content = [
             'fSeqNo' => $fSeqNo,
             'corpCode' => 'xingfulishequ',
-            'mobilePhone' => $task['mobile_phone'],
-            'integralValue' => (string)$task['integral_value'],
-            'integralType' => $task['integral_type'],
-            'remark1' => $task['nickname'],
+            'mobilePhone' => $task['mobile_phone'] ?? '',
+            'integralValue' => (string)($task['integral_value'] ?? 0),
+            'integralType' => $task['integral_type'] ?? '',
+            'remark1' => $task['nickname'] ?? '',
         ];
         
         // 工行RSA密钥

+ 2 - 0
think

@@ -10,6 +10,8 @@
 // | Author: yunwuxin <448901948@qq.com>
 // +----------------------------------------------------------------------
 
+
+
 // 定义项目路径
 define('APP_PATH', __DIR__ . '/application/');