修改商品采购价格设置的错误

This commit is contained in:
lewis 2024-12-31 13:35:42 +08:00
parent aee0609d17
commit 733adc5091

View File

@ -431,14 +431,30 @@ class PurchaseProductOfferLogic extends BaseLogic
public static function getProductCatePriceRate($product)
{
$productCatePriceRate = StoreCategory::where('id', $product['cate_id'])->value('price_rate');
if (!empty($productCatePriceRate)) {
if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) {
return $productCatePriceRate;
}
$productCatePriceRate = StoreCategory::where('id', $product['two_cate_id'])->value('price_rate');
if (!empty($productCatePriceRate)) {
if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) {
return $productCatePriceRate;
}
return StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
$productCatePriceRate = StoreCategory::where('id', $product['top_cate_id'])->value('price_rate');
if (!empty($productCatePriceRate) && self::hasPurchase($productCatePriceRate)) {
return $productCatePriceRate;
}
return [];
}
public static function hasPurchase(array $productCatePriceRate): bool
{
$res = true;
foreach ($productCatePriceRate as $item) {
if ($item['id'] == 21 && empty($item['rate'])) {
$res = false;
break;
}
}
return $res;
}
}