council(fix): BackendArchitect - Fix regex bug in getExistingSpecBaseIds()
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 <noreply@anthropic.com>refactor/vr-ticket-20260416
parent
f003606ee6
commit
d411073885
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue