From 4683862688c7bdc92b744d6faf793dcbb2b7e7e7 Mon Sep 17 00:00:00 2001 From: Council Date: Tue, 21 Apr 2026 12:45:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20GetGoodsViewData=20=E4=BD=BF=E7=94=A8=20?= =?UTF-8?q?SPEC=5FDIMS=20=E9=A1=BA=E5=BA=8F=E6=8E=A8=E6=96=AD=E7=BB=B4?= =?UTF-8?q?=E5=BA=A6=EF=BC=8C=E4=B8=8D=E5=86=8D=E4=BE=9D=E8=B5=96=20type?= =?UTF-8?q?=20=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/vr_ticket/service/SeatSkuService.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php b/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php index d281e26..f6a30b8 100644 --- a/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php +++ b/shopxo/app/plugins/vr_ticket/service/SeatSkuService.php @@ -510,18 +510,26 @@ class SeatSkuService extends BaseService return $seatSpecMap; } - // 2. 查询每个 spec_base_id 对应的 4 维 GoodsSpecValue + // 2. 查询每个 spec_base_id 对应的 GoodsSpecValue $specBaseIds = array_column($specs, 'id'); $specValues = \think\facade\Db::name('GoodsSpecValue') ->whereIn('goods_spec_base_id', $specBaseIds) + ->order('id', 'asc') // 按插入顺序,确保维度顺序一致 ->select() ->toArray(); - // 3. 按 spec_base_id 分组,构建 4 维 spec 数组 + // 3. 按 spec_base_id 分组,按 SPEC_DIMS 顺序映射维度 + // 不依赖 type 字段,而是按插入顺序匹配 SPEC_DIMS $specByBaseId = []; foreach ($specValues as $sv) { - $specByBaseId[$sv['goods_spec_base_id']][] = [ - 'type' => $sv['type'] ?? '', + $baseId = $sv['goods_spec_base_id']; + if (!isset($specByBaseId[$baseId])) { + $specByBaseId[$baseId] = []; + } + $idx = count($specByBaseId[$baseId]); // 当前维度索引 + $dimName = self::SPEC_DIMS[$idx] ?? ('dim_' . $idx); + $specByBaseId[$baseId][] = [ + 'type' => $dimName, // 使用 SPEC_DIMS 顺序推断维度名 'value' => $sv['value'] ?? '', ]; }