getSalesPriceAttr($product['sales_price'],$product); $product['specTableList'] = json_encode($productmodel->getSpecTableListAttr($product['specTableList'],$product)); $data = []; if ($spec && $product['use_spec'] == \addons\unishop\model\Product::SPEC_ON && !empty($product['specTableList'])) { $specValueArr = json_decode($product['specTableList'], true); foreach ($specValueArr as $k => $specItem) { if (implode(',', $specItem['value']) == $spec) { if ($key) { $data = $specItem[$key]; } else { $specItem['stock'] = intval($specItem['stock']);//数据类型 $specItem['sales'] = intval($specItem['sales']);//数据类型 $data = $specItem; $data['key'] = $k; } } } } if (empty($data)) { if ($key) { $data = $product[$key]; } else { $data['market_price'] = $product['market_price']; $data['sales_price'] = $product['sales_price']; $data['stock'] = $product['stock']; $data['sales'] = $product['sales']; $data['image'] = $product['image']; } } if (is_array($data)){ $data['image'] = $data['image'] ? $data['image'] : $product['image']; } return $data; } }