lqmac 9 months ago
parent 6fb6919685
commit 1d01b558c0
  1. 47
      app/api/model/Goods.php
  2. 7
      app/api/service/Cart.php
  3. 1
      app/api/service/Goods.php
  4. 4
      app/common/model/Category.php

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

@ -110,6 +110,13 @@ class Cart extends BaseService
}
// 获取当前选择的商品SKU信息
$goodsInfo['skuInfo'] = GoodsModel::getSkuInfo($goodsInfo, $item['goods_sku_id'], $enableGradeMoney);
// if (UserService::isPlusMember()) {
// $goodsInfo['skuInfo']['goods_price'] = \app\common\model\PriceSet::membershipPrice($goodsInfo['skuInfo']['goods_price'], $goods['skuInfo']['cost_price'], $catIds);
// } elseif (UserService::isDealerMember()) {
// $priceArr = \app\common\model\PriceSet::distributionPrice($goodsInfo['skuInfo']['goods_price'], $goodsInfo['skuInfo']['cost_price'], $catIds);
// $goodsInfo['skuInfo']['goods_price'] = $priceArr['distributionPrice'];
// }
if (empty($goodsInfo['skuInfo'])) {
return false;
}

@ -226,6 +226,7 @@ class Goods extends GoodsService
$arr = explode(" ", $info['shop_hours']);
$arr = explode("-", $arr[1] ?? "");
$info['is_open'] = 0;
$info['service_num_for_me'] = 5;
// if ($arr && count($arr) == 2) {
// $start = explode(":", $arr[0]);
// $end = explode(":", $arr[1]);

@ -91,9 +91,9 @@ class Category extends BaseModel
$filter[] = ['is_hot', '=', $params['is_hot']];
}
//添加店内分类
// if (!empty($param['is_in_store']) && $param['is_in_store'] == 1) {
if (isset($param['is_in_store']) && $param['is_in_store'] != "") {
$filter[] = ['is_in_store', '=', $params['is_in_store'] ?? 0];
// }
}
// 查询列表数据
return $this->with(['image'])

Loading…
Cancel
Save