价格读取

pull/1/head
limu 10 months ago
parent 250a660114
commit 742b791cc2
  1. 33
      app/api/model/Goods.php
  2. 31
      app/api/service/Goods.php

@ -383,12 +383,39 @@ class Goods extends GoodsModel
// 会员折扣价: 商品sku列表
if ($goods->getRelation('skuList')) {
foreach ($goods['skuList'] as &$skuItem) {
$skuItem['goods_price'] = $skuItem['goods_price'];
$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()) {
$skuItem['goods_price_plus'] = min($temp_price_plus);
$skuItem['goods_price_dealer'] = min($temp_price_dealer);
} elseif (UserService::isPlusMember()) {
$skuItem['goods_price_plus'] = min($temp_price_plus);
} elseif (UserService::isDealerMember()) {
$skuItem['goods_price_dealer'] = min($temp_price_dealer);
}
}
// 会员折扣价: 已选择的商品sku(用于购物车)
}
// 折扣价: 已选择的商品sku(用于购物车)
if ($goods->getAttr('skuInfo')) {
$goods['skuInfo']['goods_price'] = $goods['skuInfo']['goods_price'];
if (UserService::isPlusMember()) {
$sku_price_plus = [];
foreach ($catIds as $k => $v) {
$sku_price_plus[] = GoodsPriceModel::getDiscountPrice($v, 1, $goods['skuInfo']['goods_price']);
}
$goods['skuInfo']['goods_price'] = min($sku_price_plus);
} elseif (UserService::isDealerMember()) {
$sku_price_dealer = [];
foreach ($catIds as $k => $v) {
$sku_price_dealer[] = GoodsPriceModel::getDiscountPrice($v, 2, $goods['skuInfo']['goods_price']);
}
$goods['skuInfo']['goods_price'] = min($sku_price_dealer);
}
}
}

@ -16,6 +16,7 @@ use app\api\model\Goods as GoodsModel;
use app\api\model\Setting as SettingModel;
use app\api\model\GoodsSku as GoodsSkuModel;
use app\api\model\Category as CategoryModel;
use app\api\service\User as UserService;
use app\common\model\store\Shop as ShopModel;
use app\api\service\sharp\Active as ActiveService;
use app\common\enum\Setting as SettingEnum;
@ -23,6 +24,7 @@ use app\common\service\Goods as GoodsService;
use app\api\model\sharp\Active as SharpActiveModel;
use app\api\model\sharp\ActiveTime as ActiveTimeModel;
use app\api\controller\sharp\Goods as miaosha;
use app\store\model\goods\GoodsPrice as GoodsPriceModel;
/**
* 商品服务类
@ -52,19 +54,19 @@ class Goods extends GoodsService
switch (request()->get('type')) {
case 1:
$data['imgurl']= 'https://www.saas.njrenzhou.com/uploads/10001/20240131/bdc5f17f3ff8c53ce0853177bc4f1917.png';
$data['imgurl'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240131/bdc5f17f3ff8c53ce0853177bc4f1917.png';
return $data;
break;
case 2:
$data['imgurl']= 'https://www.saas.njrenzhou.com/uploads/10001/20240131/e8e10653875e779bc72dbee65b8072c0.png';
$data['imgurl'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240131/e8e10653875e779bc72dbee65b8072c0.png';
return $data;
break;
case 3:
$data['imgurl']= 'https://www.saas.njrenzhou.com/uploads/10001/20240131/5c4ec6ffeb23223936295e290dc3d1f9.png';
$data['imgurl'] = 'https://www.saas.njrenzhou.com/uploads/10001/20240131/5c4ec6ffeb23223936295e290dc3d1f9.png';
return $data;
break;
case 4:
$data['imgurl']= [
$data['imgurl'] = [
'https://www.saas.njrenzhou.com/uploads/10001/20240131/5c4ec6ffeb23223936295e290dc3d1f9.png',
];
return $data;
@ -278,7 +280,7 @@ class Goods extends GoodsService
{
$data = [];
foreach ($goodsList as $goods) {
$data[] = [
$temp = [
'goods_id' => $goods['goods_id'],
'goods_name' => $goods['goods_name'],
'selling_point' => $goods['selling_point'],
@ -290,6 +292,25 @@ class Goods extends GoodsService
'goods_sales' => $goods['goods_sales'],
'remaizhishu' => $goods['remaizhishu'],
];
if (UserService::isLogin()) {
$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']);
}
//价格判断
if (UserService::isstore()) {
$temp['goods_price_min_plus'] = min($price_list_plus);
$temp['goods_price_min_dealer'] = min($price_list_dealer);
} elseif (UserService::isPlusMember()) {
$temp['goods_price_min_plus'] = min($price_list_plus);
} elseif (UserService::isDealerMember()) {
$temp['goods_price_min_dealer'] = min($price_list_dealer);
}
}
$data[] = $temp;
}
return $data;
}

Loading…
Cancel
Save