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); }