|
|
@@ -96,17 +96,11 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//花材图片,名称,大小单位,小单位价格
|
|
|
- public static function groupProductInfo($list)
|
|
|
+ public static function groupProductInfo($list, $level = 0)
|
|
|
{
|
|
|
-
|
|
|
- $customId = isset(Yii::$app->params['customId']) ? Yii::$app->params['customId'] : 0;
|
|
|
- $customInfo = [];
|
|
|
- if (empty($customId)) {
|
|
|
- $customInfo = CustomClass::getById($customId, true);
|
|
|
- }
|
|
|
- $levelPriceKey = CustomClass::$levelPriceKeyMap;
|
|
|
- $customLevel = $customInfo->level ?? 0;
|
|
|
- $levelAddPriceKey = CustomClass::$levelAddPriceKeyMap;
|
|
|
+ //各个等级对应的price addPrice字段
|
|
|
+ $priceMap = CustomClass::$levelPriceKeyMap;
|
|
|
+ $addPriceMap = CustomClass::$levelAddPriceKeyMap;
|
|
|
|
|
|
foreach ($list as $k => $v) {
|
|
|
$shortCover = $v['cover'] ?? '';
|
|
|
@@ -129,26 +123,25 @@ class ProductClass extends BaseClass
|
|
|
$list[$k]['bigNum'] = $stockInfo['bigNum'];
|
|
|
$list[$k]['smallNum'] = $stockInfo['smallNum'];
|
|
|
$list[$k]['itemName'] = $v['name'] ?? '';
|
|
|
- //原价 shish 20210703
|
|
|
$list[$k]['prePrice'] = $v['price'] ?? 0;
|
|
|
$price = $v['price'] ?? 0;
|
|
|
|
|
|
//价格相关控制!!!!!!!请搜索 price_control
|
|
|
- if (empty($customInfo)) {
|
|
|
+ if (empty($level)) {
|
|
|
$discountPrice = $v['discountPrice'] ?? 0;
|
|
|
if ($discountPrice > 0) {
|
|
|
$price = $discountPrice;
|
|
|
}
|
|
|
} else {
|
|
|
- $currentPriceKey = $levelPriceKey[$customLevel] ?? 'price';
|
|
|
+ $currentPriceKey = $priceMap[$level] ?? 'price';
|
|
|
$price = $v[$currentPriceKey] ?? 0;
|
|
|
|
|
|
//特价
|
|
|
$discountPrice = $v['discountPrice'] ?? 0;
|
|
|
if ($discountPrice > 0) {
|
|
|
- $preAddPriceKey = $levelAddPriceKey[0] ?? 'addPrice';
|
|
|
+ $preAddPriceKey = $addPriceMap[0] ?? 'addPrice';
|
|
|
$preAddPrice = $v[$preAddPriceKey] ?? 0;
|
|
|
- $currentAddPriceKey = $levelAddPriceKey[$customLevel] ?? 'addPrice';
|
|
|
+ $currentAddPriceKey = $addPriceMap[$level] ?? 'addPrice';
|
|
|
$currentAddPrice = $v[$currentAddPriceKey] ?? 0;
|
|
|
$diff = bcsub($preAddPrice, $currentAddPrice, 2);
|
|
|
$price = bcsub($discountPrice, $diff, 2);
|
|
|
@@ -635,7 +628,7 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
|
|
|
//下单时计算商品的价格 linqh 2021.1.28
|
|
|
- public static function formatProductInfo($itemInfo, $customId = 0)
|
|
|
+ public static function formatProductInfo($itemInfo, $level = 0)
|
|
|
{
|
|
|
$data = [];
|
|
|
if (empty($itemInfo)) {
|
|
|
@@ -650,14 +643,9 @@ class ProductClass extends BaseClass
|
|
|
$totalBigNum = 0;
|
|
|
$totalSmallNum = 0;
|
|
|
|
|
|
- //不同的人卖不现价格
|
|
|
- $customLevel = 0;
|
|
|
- if (!empty($customId)) {
|
|
|
- $custom = CustomClass::getById($customId, true);
|
|
|
- $customLevel = $custom->level ?? 0;
|
|
|
- }
|
|
|
- $levelPriceKey = CustomClass::$levelPriceKeyMap;
|
|
|
- $levelAddPriceKey = CustomClass::$levelAddPriceKeyMap;
|
|
|
+ //不同等级对应 price addPrice
|
|
|
+ $priceMap = CustomClass::$levelPriceKeyMap;
|
|
|
+ $addPriceMap = CustomClass::$levelAddPriceKeyMap;
|
|
|
|
|
|
foreach ($itemInfo as $v) {
|
|
|
$productId = $v['productId'];
|
|
|
@@ -668,7 +656,7 @@ class ProductClass extends BaseClass
|
|
|
$itemNum = self::mergeItemNum($v['bigNum'], $v['smallNum'], $ratio);
|
|
|
|
|
|
//价格相关控制!!!!!!!请搜索 price_control
|
|
|
- if (empty($customId)) {
|
|
|
+ if (empty($level)) {
|
|
|
$itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
$discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
if ($discountPrice > 0) {
|
|
|
@@ -676,15 +664,15 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
- $currentPriceKey = $levelPriceKey[$customLevel] ?? 'price';
|
|
|
+ $currentPriceKey = $priceMap[$level] ?? 'price';
|
|
|
$itemPrice = $productData[$productId][$currentPriceKey] ?? 0;
|
|
|
|
|
|
//特价
|
|
|
$discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
if ($discountPrice > 0) {
|
|
|
- $preAddPriceKey = $levelAddPriceKey[0] ?? 'addPrice';
|
|
|
+ $preAddPriceKey = $addPriceMap[0] ?? 'addPrice';
|
|
|
$preAddPrice = $productData[$productId][$preAddPriceKey] ?? 0;
|
|
|
- $currentAddPriceKey = $levelAddPriceKey[$customLevel] ?? 'addPrice';
|
|
|
+ $currentAddPriceKey = $addPriceMap[$level] ?? 'addPrice';
|
|
|
$currentAddPrice = $productData[$productId][$currentAddPriceKey] ?? 0;
|
|
|
$diff = bcsub($preAddPrice, $currentAddPrice, 2);
|
|
|
$itemPrice = bcsub($discountPrice, $diff, 2);
|