cqp 4 недель назад
Родитель
Сommit
2adfd5a505
1 измененных файлов с 6 добавлено и 6 удалено
  1. 6 6
      app/Service/Service.php

+ 6 - 6
app/Service/Service.php

@@ -844,13 +844,13 @@ class Service
         $prefix = $need['prefix'] ?? '';
         $period = $need['period']; // 示例:202603
 
-        // 1. 原子更新:去掉 top_depart_id 维度
-        // 联合唯一索引应调整为 (bill_type, period)
+        // 1. 原子更新:加上 login_type 维度
+        // 注意:你的数据库联合唯一索引应该是 (bill_type, login_type, period)
         DB::statement("
-        INSERT INTO sys_bill_sequences (bill_type, period, current_value) 
-        VALUES (?, ?, 1) 
+        INSERT INTO sys_bill_sequences (bill_type, login_type, period, current_value) 
+        VALUES (?, ?, ?, 1) 
         ON DUPLICATE KEY UPDATE current_value = current_value + 1
-    ", [$type, $period]);
+    ", [$type, $login_type, $period]);
 
         // 2. 获取本次生成的流水号
         $sequence = DB::table('sys_bill_sequences')
@@ -859,7 +859,7 @@ class Service
             ->where('period', $period)
             ->value('current_value');
 
-        // 3. 拼接输出:前缀 + 周期 + 补齐流水号
+        // 3. 拼接输出
         return $prefix . $period . str_pad($sequence, $length, '0', STR_PAD_LEFT);
     }
 }