mirror of
https://github.com/crmeb/CRMEB.git
synced 2026-10-28 13:31:04 +00:00
fix(移动端发票): 开票详情商品图片与金额不回显
buildLegacyCartInfo 合成旧版 cartInfo 时 attrInfo 只带了 suk, 且 productInfo 缺 price 字段;移动端 orderGoods 组件在 attrInfo 存在时取 attrInfo.image/attrInfo.price 展示图片与规格价、单价取 productInfo.price,字段缺失导致图片与金额空白。 补齐 attrInfo.image/price(规格缺省回退商品主图/商品价)与 productInfo.price,开票列表与开票详情两处消费方同时修复
This commit is contained in:
parent
cfba968bc8
commit
a8e9119a0c
@ -155,6 +155,11 @@ class OrderInvoiceServices extends BaseService
|
||||
|
||||
/**
|
||||
* 由订单中台商品快照合成旧版 cartInfo 结构(兼容移动端旧组件)
|
||||
*
|
||||
* 移动端 orderGoods 组件按旧版结构取值:attrInfo 存在时图片/规格价取
|
||||
* attrInfo.image / attrInfo.price,商品单价取 productInfo.price,
|
||||
* 三者缺一会导致商品图片或金额不回显。
|
||||
*
|
||||
* @param array $extra 解析后的 extra_info
|
||||
* @return array
|
||||
*/
|
||||
@ -162,13 +167,22 @@ class OrderInvoiceServices extends BaseService
|
||||
{
|
||||
$cartInfo = [];
|
||||
foreach ($extra['items'] ?? [] as $product) {
|
||||
$attrInfo = is_array($product['attr_info'] ?? null) ? $product['attr_info'] : [];
|
||||
// 规格图优先,缺省回退商品主图;规格价优先,缺省回退商品价
|
||||
$image = $attrInfo['image'] ?? ($product['image'] ?? '');
|
||||
$price = $attrInfo['price'] ?? ($product['price'] ?? 0);
|
||||
$cartInfo[] = [
|
||||
'cart_num' => $product['cart_num'] ?? 1,
|
||||
'truePrice' => $product['true_price'] ?? 0,
|
||||
'productInfo' => [
|
||||
'image' => $product['image'] ?? '',
|
||||
'store_name' => $product['store_name'] ?? '',
|
||||
'attrInfo' => ['suk' => $product['attr_info']['suk'] ?? ($product['sku'] ?? '')],
|
||||
'price' => $price,
|
||||
'attrInfo' => array_merge($attrInfo, [
|
||||
'suk' => $attrInfo['suk'] ?? ($product['sku'] ?? ''),
|
||||
'image' => $image,
|
||||
'price' => $price,
|
||||
]),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user