diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index bafca674..c878844b 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -748,14 +748,14 @@ class Goods extends GoodsModel $goods['goods_price_min_plus'] = $priceArr['membershipPrice']; $goods['goods_price_min_dealer'] = $priceArr['distributionPrice']; $goods['goods_price_min'] = $goods['goods_price_min_plus'];//$goods['cost_price_min'];//店长售价,展示为成本价 - $goods['discount'] = bcdiv((string)($priceArr['membershipPrice'] * 10), (string)$goods_price_min, 1); + $goods['discount'] = $goods_price_min > 0 ? bcdiv((string)($priceArr['membershipPrice'] * 10), (string)$goods_price_min, 1) : 0; } elseif (UserService::isPlusMember()) { $membershipPrice = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); - $goods['discount'] = bcdiv((string)($membershipPrice * 10), (string)$goods['goods_price_min'], 1); + $goods['discount'] = $goods['goods_price_min'] > 0 ? bcdiv((string)($membershipPrice * 10), (string)$goods['goods_price_min'], 1) : 0; $goods['goods_price_min'] = $membershipPrice; } elseif (UserService::isDealerMember()) { $priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); - $goods['discount'] = bcdiv((string)($priceArr['distributionPrice'] * 10), (string)$goods['goods_price_min'], 1); + $goods['discount'] = $goods['goods_price_min'] > 0 ? bcdiv((string)($priceArr['distributionPrice'] * 10), (string)$goods['goods_price_min'], 1) : 0; //$goods['goods_price_min'] = $membershipPrice; $goods['goods_price_min'] = $priceArr['distributionPrice']; }