lqmac 7 months ago
parent 187d8efab8
commit 2bf999f9bc
  1. 4
      app/api/controller/Goods.php
  2. 14
      app/api/model/Goods.php
  3. 9
      app/common/model/PriceSet.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]);
}

@ -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) {
//价格判断

@ -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;
}

Loading…
Cancel
Save