From d41107388526e49f1d3e5a97ebee75b42a204ec9 Mon Sep 17 00:00:00 2001 From: Council Date: Wed, 15 Apr 2026 20:16:49 +0800 Subject: [PATCH] council(fix): BackendArchitect - Fix regex bug in getExistingSpecBaseIds() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: regex '^([A-Za-z]+)(\d+)排(\d)座$' with $m[3] misparsed seat labels like "A排10座" → colNum=1 (wrong). Fixed to '^([A-Za-z]+)排(\d+)座$' with $m[2]. Also clarified spec_base_id_map docblock: frontend expects flat integer, not nested object. Co-Authored-By: Claude Opus 4.6 --- .../app/plugins/vr_ticket/service/SeatSkuService.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php b/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php index 7bae4d9..d8fd899 100644 --- a/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php +++ b/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php @@ -26,7 +26,10 @@ class SeatSkuService extends BaseService * * @param int $goodsId 商品ID * @param int $seatTemplateId 座位模板ID - * @return array ['code' => 0, 'msg' => '...', 'data' => ['total' => N, 'batch' => N, 'spec_base_id_map' => [...]]] + * @return array ['code' => 0, 'msg' => '...', 'data' => ['total' => N, 'generated' => N, 'spec_base_id_map' => ['seatId' => spec_base_id, ...]]] + * + * spec_base_id_map 格式:前端 ticket_detail.html 使用 seatKey(如 "A_1")作为 key, + * 期望 value 为整数 spec_base_id(如 2001)。 */ public static function BatchGenerate(int $goodsId, int $seatTemplateId): array { @@ -378,9 +381,11 @@ class SeatSkuService extends BaseService foreach ($rows as $seatLabel => $baseId) { // 从 seat_label 解析 seatId(如 "A排1座" → "A_1") // 格式: "{rowLabel}排{colNum}座" - if (preg_match('/^([A-Za-z]+)(\d+)排(\d)座$/', $seatLabel, $m)) { + // Bug fix: 原正则 `^([A-Za-z]+)(\d+)排(\d)座$` 第二个 `\d+` 会吞掉 colNum 的高位数字, + // 例如 "A排10座" 匹配为 rowLabel="A" colNum=1(错误),应为 colNum=10 + if (preg_match('/^([A-Za-z]+)排(\d+)座$/', $seatLabel, $m)) { $rowLabel = $m[1]; - $colNum = intval($m[3]); + $colNum = intval($m[2]); $seatId = $rowLabel . '_' . $colNum; $seatIdMap[$seatId] = intval($baseId); }