更新若干功能
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
2026-08-20 19:16:49 +08:00
parent 72bc6502eb
commit 4ddf5e3c5f
48 changed files with 1908 additions and 18 deletions

View File

@@ -7,6 +7,7 @@ use App\Models\business\CatalogueModel;
use App\Models\business\CategoryModel;
use App\Models\business\ImageModel;
use App\Service\business\PriceService;
use App\Service\common\MediaUrlService;
/**
* 小程序商品列表与详情
@@ -16,6 +17,8 @@ use App\Service\business\PriceService;
*/
class WxProductService extends BaseWxService
{
protected bool $needLogin = false;
/**
* 商品列表:分类点到二级时按父分类下的所有子分类查
*/
@@ -76,12 +79,15 @@ class WxProductService extends BaseWxService
$this->utils->errorThrow('商品不存在');
}
$info = $info->toArray();
$media = MediaUrlService::getInstance();
$info['cover'] = $media->toPublic($info['cover'] ?? '');
$info['video'] = $media->toPublic($info['video'] ?? '');
// 渲染图作为详情轮播
$info['carousel'] = [];
foreach ($info['images'] ?? [] as $image) {
if ((int) $image['type'] === ImageModel::TYPE_RENDER) {
$info['carousel'][] = $image['url'];
$info['carousel'][] = $media->toPublic($image['url'] ?? '');
}
}
@@ -89,6 +95,9 @@ class WxProductService extends BaseWxService
$applied = PriceService::getInstance()->applyToRows($info['price_sheet'] ?? [], $showPrice, $this->priceMultiplier());
$info['price_sheet'] = $applied['rows'];
$info['is_show_price'] = $applied['is_show_price'];
$info['favorited'] = $this->userId > 0
? WxFavoriteService::getInstance()->isFavorited((int) $id)
: false;
return $info;
}
}