request->get('id', 0); $shop = $this->shop; // 必须有店铺上下文,否则无法校验 mainId / 计价 if (empty($shop) || empty($this->mainId)) { util::fail('访问门店出错了'); } // 游客可浏览:custom 为空时 groupGoodsBaseInfo 按无会员价处理,不报「用户信息缺失」 $custom = !empty($this->custom) ? $this->custom : []; $params = []; $goods = GoodsClass::getGoodsInfo($id, $shop, $custom, $params); if (empty($goods)) { util::fail('商品不存在'); } if ($goods['mainId'] != $this->mainId) { util::fail('不是你的商品'); } $goods = \bizHd\goods\classes\GoodsClass::appendUseCasesAndSpecs($goods, $this->mainId); // $setting = GoodsSettingClass::getByCondition(['mainId' => $this->mainId]); // $intro = $setting['goodsIntroduce'] ?? ''; // $info['commonIntro'] = $intro; // 商品详情图文 if (empty($goods['masterId'])) { $picTextGoodsId = $id; } else { $picTextGoodsId = $goods['masterId']; } $pixTextGoods = PicTextGoodsClass::getByCondition(['mainId' => $this->mainId, 'goodsId' => $picTextGoodsId], true); $goods['picTextGoods'] = $pixTextGoods; $categoryId = intval(Yii::$app->request->get('categoryId')); if ($categoryId <= 0 && $id > 0) { $categoryMap = GoodsCategoryClass::getGoodsHasCategoryIdsBatch([$picTextGoodsId]); $categoryIds = $categoryMap[$picTextGoodsId] ?? []; if (!empty($categoryIds)) { $categoryId = intval($categoryIds[0]); } } // 商品所属分类图文 $goods['picText'] = []; $category = CategoryClass::getById($categoryId); if (!empty($category)) { $picTextId = $category['picTextId']; $picText = PicTextClass::getById($picTextId, true); $goods['picText'] = $picText; } $goods['customId'] = $this->customId ?: 0; util::success($goods); } }