From 2bf999f9bc0414f582031c5da9f05d82bbfc5ab6 Mon Sep 17 00:00:00 2001 From: lqmac Date: Wed, 1 May 2024 23:27:27 +0800 Subject: [PATCH] 1 --- app/api/controller/Goods.php | 4 ++++ app/api/model/Goods.php | 14 ++++++++------ app/common/model/PriceSet.php | 9 +++++---- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/api/controller/Goods.php b/app/api/controller/Goods.php index ece47feb..118b92e0 100644 --- a/app/api/controller/Goods.php +++ b/app/api/controller/Goods.php @@ -62,6 +62,10 @@ class Goods extends Controller if (!empty($goodsInfo['content'])) { $goodsInfo['content'] = str_ireplace('onload="if(this.width>750){this.height=this.height*(750.0/this.width); this.width = 750;}', '', $goodsInfo['content']); } + //苏宁的商品不展示链接 + if ($goodsInfo['channel'] == 'sn') { + $goodsInfo['link'] = ""; + } return $this->renderSuccess(['detail' => $goodsInfo]); } diff --git a/app/api/model/Goods.php b/app/api/model/Goods.php index b99a3577..14fa6921 100644 --- a/app/api/model/Goods.php +++ b/app/api/model/Goods.php @@ -538,6 +538,8 @@ class Goods extends GoodsModel { // 获取商品记录 $goodsInfo = static::detail($goodsId, $with); + //单规格和多规格处理不一致 + $goodsInfo->skuList = $goodsInfo->skuList1 ? $goodsInfo->skuList1 : $goodsInfo->skuList; if ($goodsInfo->skuList) { foreach ($goodsInfo->skuList as &$value) { @@ -643,26 +645,26 @@ class Goods extends GoodsModel //价格判断 if (UserService::isstore()) { $priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); - $goods['goods_price_min_plus'] = round($priceArr['membershipPrice']); - $goods['goods_price_min_dealer'] = round($priceArr['distributionPrice']); - $goods['goods_price_min'] = round($goods['goods_price_min_plus']);//$goods['cost_price_min'];//店长售价,展示为成本价 + $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'];//店长售价,展示为成本价 } 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['goods_price_min'] = round($membershipPrice); + $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['goods_price_min'] = $membershipPrice; - $goods['goods_price_min'] = round($priceArr['distributionPrice']); + $goods['goods_price_min'] = $priceArr['distributionPrice']; } if ($goods['discount'] == 10) { $goods['discount'] = 0.0; } // 会员折扣价: 商品sku列表 - if ($goods->getRelation('skuList')) { + if ($goods->getRelation('skuList') || $goods->getRelation('skuList1')) { foreach ($goods['skuList'] as &$skuItem) { //价格判断 diff --git a/app/common/model/PriceSet.php b/app/common/model/PriceSet.php index 568c0b51..75d9fc2a 100644 --- a/app/common/model/PriceSet.php +++ b/app/common/model/PriceSet.php @@ -40,7 +40,8 @@ class PriceSet extends BaseModel $addPriceRate = self::getAddPriceRate(0, $category_ids, $cost_price); //没有加价率返回市场价 if (!$addPriceRate) { - return sprintf("%.2f", $market_price); + //return sprintf("%.2f", $market_price); + return round($market_price); } $membershipPrice = $cost_price * (1 + $addPriceRate * 0.01); //当加价率生效后,会员价高于市场价 @@ -48,7 +49,7 @@ class PriceSet extends BaseModel $membershipPrice = ($market_price - $cost_price) * $addPriceRate * 0.01 + $cost_price; } - return sprintf("%.2f", $membershipPrice); + return round($membershipPrice); } /** @@ -70,7 +71,7 @@ class PriceSet extends BaseModel //没有加价率返回市场价 if (!$addPriceRate) { - $arr['distributionPrice'] = sprintf("%.2f", $market_price); + $arr['distributionPrice'] = round($market_price); return $arr; } $distributionPrice = $cost_price * (1 + $addPriceRate * 0.01); @@ -83,7 +84,7 @@ class PriceSet extends BaseModel if ($distributionPrice > $membershipPrice) { $price = ($membershipPrice - $cost_price) * $addPriceRate * 0.01 + $cost_price; } - $arr['distributionPrice'] = sprintf("%.2f", $price); + $arr['distributionPrice'] = round($price); return $arr; }