|
|
|
@ -493,7 +493,8 @@ class Goods extends GoodsModel |
|
|
|
|
public static function getSkuInfo($goodsInfo, string $goodsSkuId, bool $enableGradeMoney = true) |
|
|
|
|
{ |
|
|
|
|
$goodsInfo['skuInfo'] = GoodsService::getSkuInfo($goodsInfo['goods_id'], $goodsSkuId); |
|
|
|
|
$enableGradeMoney && (new static)->setGoodsGradeMoney($goodsInfo); |
|
|
|
|
//$enableGradeMoney && (new static)->setGoodsGradeMoney($goodsInfo); |
|
|
|
|
(new static)->setGoodsMoney($goodsInfo); |
|
|
|
|
return $goodsInfo['skuInfo']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -517,9 +518,11 @@ class Goods extends GoodsModel |
|
|
|
|
*/ |
|
|
|
|
private function setGoodsDataFromApi($goodsInfo) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
return $this->setGoodsData($goodsInfo, function ($goods) { |
|
|
|
|
// 计算并设置商品会员价 |
|
|
|
|
$this->getEnableGradeMoney() && $this->setGoodsGradeMoney($goods); |
|
|
|
|
|
|
|
|
|
//计算plus 分销价格 |
|
|
|
|
$this->setGoodsMoney($goods); |
|
|
|
|
}); |
|
|
|
@ -532,19 +535,15 @@ class Goods extends GoodsModel |
|
|
|
|
*/ |
|
|
|
|
private function setGoodsMoney(self $goods) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
// 判断是否登录 |
|
|
|
|
if (!UserService::isLogin()) { |
|
|
|
|
$goods['line_price_min'] = $goods['goods_price_min']; |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$catService = new \app\store\model\GoodsCategoryRel(); |
|
|
|
|
$catIds = $catService->where(['goods_id' => $goods->goods_id])->column('category_id'); |
|
|
|
|
//读取分类集 |
|
|
|
|
// $price_list_plus = $price_list_dealer = []; |
|
|
|
|
// foreach ($catIds as $k => $v) { |
|
|
|
|
// $price_list_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $goods['goods_price_min']); |
|
|
|
|
// $price_list_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['goods_price_min']); |
|
|
|
|
// } |
|
|
|
|
$goods['line_price_min'] = $goods['goods_price_min'];//划线价格等于市场价 |
|
|
|
|
|
|
|
|
|
//价格判断 |
|
|
|
@ -553,50 +552,40 @@ class Goods extends GoodsModel |
|
|
|
|
$goods['goods_price_min_plus'] = $priceArr['membershipPrice']; |
|
|
|
|
$goods['goods_price_min_dealer'] = $priceArr['distributionPrice']; |
|
|
|
|
$goods['goods_price_min'] = $goods['cost_price_min'];//店长售价,展示为成本价 |
|
|
|
|
// $goods['goods_price_min_plus'] = min($price_list_plus); |
|
|
|
|
// $goods['goods_price_min_dealer'] = min($price_list_dealer); |
|
|
|
|
|
|
|
|
|
} elseif (UserService::isPlusMember()) { |
|
|
|
|
$goods['goods_price_min'] = \app\common\model\PriceSet::membershipPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
//$goods['goods_price_min_plus'] = min($price_list_plus); |
|
|
|
|
} elseif (UserService::isDealerMember()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($goods['goods_price_min'], $goods['cost_price_min'], $catIds); |
|
|
|
|
$goods['goods_price_min'] = $priceArr['distributionPrice']; |
|
|
|
|
//$goods['goods_price_min_dealer'] = min($price_list_dealer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 会员折扣价: 商品sku列表 |
|
|
|
|
if ($goods->getRelation('skuList')) { |
|
|
|
|
|
|
|
|
|
foreach ($goods['skuList'] as &$skuItem) { |
|
|
|
|
// $temp_price_plus = $temp_price_dealer = []; |
|
|
|
|
// foreach ($catIds as $k => $v) { |
|
|
|
|
// $temp_price_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $skuItem['goods_price']); |
|
|
|
|
// $temp_price_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $skuItem['goods_price']); |
|
|
|
|
// } |
|
|
|
|
//价格判断 |
|
|
|
|
if (UserService::isstore()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
$skuItem['goods_price_min_plus'] = $priceArr['membershipPrice']; |
|
|
|
|
$skuItem['goods_price_min_dealer'] = $priceArr['distributionPrice']; |
|
|
|
|
$skuItem['goods_price_min'] = $skuItem['cost_price_min'];//店长售价,展示为成本价 |
|
|
|
|
// $skuItem['goods_price_plus'] = min($temp_price_plus); |
|
|
|
|
// $skuItem['goods_price_dealer'] = min($temp_price_dealer); |
|
|
|
|
$skuItem['goods_price'] = $skuItem['cost_price'];//店长售价,展示为成本价 |
|
|
|
|
} elseif (UserService::isPlusMember()) { |
|
|
|
|
//$skuItem['goods_price_plus'] = \app\common\model\PriceSet::membershipPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
$skuItem['goods_price_min'] = \app\common\model\PriceSet::membershipPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
|
|
|
|
|
//$skuItem['goods_price_plus'] = min($temp_price_plus); |
|
|
|
|
$skuItem['goods_price'] = \app\common\model\PriceSet::membershipPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
} elseif (UserService::isDealerMember()) { |
|
|
|
|
$priceArr = \app\common\model\PriceSet::distributionPrice($skuItem['goods_price'], $skuItem['cost_price'], $catIds); |
|
|
|
|
//$skuItem['goods_price_min_dealer'] = $priceArr['distributionPrice']; |
|
|
|
|
$skuItem['goods_price_min'] = $priceArr['distributionPrice']; |
|
|
|
|
//$skuItem['goods_price_dealer'] = min($temp_price_dealer); |
|
|
|
|
$skuItem['goods_price'] = $priceArr['distributionPrice']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//exit(); |
|
|
|
|
// var_dump(111); |
|
|
|
|
// exit(); |
|
|
|
|
// 折扣价: 已选择的商品sku(用于购物车) |
|
|
|
|
if ($goods->getAttr('skuInfo')) { |
|
|
|
|
|
|
|
|
|
if (UserService::isPlusMember()) { |
|
|
|
|
|
|
|
|
|
// $sku_price_plus = []; |
|
|
|
|
// foreach ($catIds as $k => $v) { |
|
|
|
|
// $sku_price_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $goods['skuInfo']['goods_price']); |
|
|
|
@ -654,6 +643,8 @@ class Goods extends GoodsModel |
|
|
|
|
} |
|
|
|
|
// 会员折扣价: 已选择的商品sku(用于购物车) |
|
|
|
|
if ($goods->getAttr('skuInfo')) { |
|
|
|
|
echo "11"; |
|
|
|
|
exit(); |
|
|
|
|
$goods['skuInfo']['goods_price'] = UserGradeService::getDiscountPrice($goods['skuInfo']['goods_price'], $discountRatio); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|