Explorar el Código

fix: 自选宝箱新增时bug

Pius-X hace 1 año
padre
commit
37944bf989
Se han modificado 1 ficheros con 8 adiciones y 3 borrados
  1. 8 3
      application/models/OptionalChestModel.php

+ 8 - 3
application/models/OptionalChestModel.php

@@ -6,8 +6,6 @@ class OptionalChestModel extends CI_Model
     {
         $tb = otable::optionalChestConfig();
 
-        $jsonData = [];
-
         // 校验
         foreach ($data as $item) {
             if (empty($item['id'])) {
@@ -33,7 +31,6 @@ class OptionalChestModel extends CI_Model
                     return array(1, "$prefix 奖励不能配置为自选宝箱");
                 }
             }
-            $jsonData[$item['id']] = $item;
 
             $item['reward'] = json_encode($item['reward'], JSON_NUMERIC_CHECK);
             $sql = funs::db_upsertSQL($tb, $item);
@@ -43,6 +40,14 @@ class OptionalChestModel extends CI_Model
             }
         }
 
+        $list = oo::commonOprDb('games')->getAll("SELECT * from {$tb} WHERE 1");
+
+        $jsonData = [];
+        foreach ($list as $item) {
+            $item['reward'] = json_decode($item['reward'], true);
+            $jsonData[$item['id']] = $item;
+        }
+
         self::updateCache($jsonData);
 
         $filename = 'OptionalChestConf' . time() . '.json';