|
|
@@ -98,6 +98,16 @@ class ProductClass extends BaseClass
|
|
|
//花材图片,名称,大小单位,小单位价格
|
|
|
public static function groupProductInfo($list)
|
|
|
{
|
|
|
+
|
|
|
+ $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;
|
|
|
+
|
|
|
foreach ($list as $k => $v) {
|
|
|
$shortCover = $v['cover'] ?? '';
|
|
|
$cover = imgUtil::getPrefix() . 'hhb_small.png';
|
|
|
@@ -119,20 +129,30 @@ 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;
|
|
|
|
|
|
- //特价 shish 20210901
|
|
|
- $discountPrice = $v['discountPrice'] ?? 0;
|
|
|
- $price = $discountPrice > 0 && $v['price'] > $discountPrice ? $discountPrice : $v['price'];
|
|
|
-
|
|
|
- //客户折扣价
|
|
|
- $customDiscount = isset(Yii::$app->params['customDiscount']) ? Yii::$app->params['customDiscount'] : 1;
|
|
|
- if ($customDiscount < 1 && $customDiscount > 0) {
|
|
|
- $price = bcmul($price, $customDiscount, 2);
|
|
|
- //四舍五入保留整数,涉及多个地方要同步修改,请搜索关键词:round_price!!!!
|
|
|
- $price = round($price, 0);
|
|
|
+ //价格相关控制!!!!!!!请搜索 price_control
|
|
|
+ if (empty($customInfo)) {
|
|
|
+ $discountPrice = $v['discountPrice'] ?? 0;
|
|
|
+ if ($discountPrice > 0) {
|
|
|
+ $price = $discountPrice;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $currentPriceKey = $levelPriceKey[$customLevel] ?? 'price';
|
|
|
+ $price = $v[$currentPriceKey] ?? 0;
|
|
|
+
|
|
|
+ //特价
|
|
|
+ $discountPrice = $v['discountPrice'] ?? 0;
|
|
|
+ if ($discountPrice > 0) {
|
|
|
+ $preAddPriceKey = $levelAddPriceKey[0] ?? 'addPrice';
|
|
|
+ $preAddPrice = $v[$preAddPriceKey] ?? 0;
|
|
|
+ $currentAddPriceKey = $levelAddPriceKey[$customLevel] ?? 'addPrice';
|
|
|
+ $currentAddPrice = $v[$currentAddPriceKey] ?? 0;
|
|
|
+ $diff = bcsub($preAddPrice, $currentAddPrice, 2);
|
|
|
+ $price = bcsub($discountPrice, $diff, 2);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
$list[$k]['price'] = $price;
|
|
|
@@ -631,11 +651,13 @@ class ProductClass extends BaseClass
|
|
|
$totalSmallNum = 0;
|
|
|
|
|
|
//不同的人卖不现价格
|
|
|
- $discount = 1;
|
|
|
+ $customLevel = 0;
|
|
|
if (!empty($customId)) {
|
|
|
$custom = CustomClass::getById($customId, true);
|
|
|
- $discount = $custom->discount ?? 1;
|
|
|
+ $customLevel = $custom->level ?? 0;
|
|
|
}
|
|
|
+ $levelPriceKey = CustomClass::$levelPriceKeyMap;
|
|
|
+ $levelAddPriceKey = CustomClass::$levelAddPriceKeyMap;
|
|
|
|
|
|
foreach ($itemInfo as $v) {
|
|
|
$productId = $v['productId'];
|
|
|
@@ -644,20 +666,29 @@ class ProductClass extends BaseClass
|
|
|
$cost = $productData[$productId]['cost'] ?? 0;
|
|
|
//大小数量合并多少扎
|
|
|
$itemNum = self::mergeItemNum($v['bigNum'], $v['smallNum'], $ratio);
|
|
|
- //售卖价格
|
|
|
- $itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
|
|
|
- //特价
|
|
|
- $discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
- if ($discountPrice > 0) {
|
|
|
- $itemPrice = $discountPrice;
|
|
|
- }
|
|
|
+ //价格相关控制!!!!!!!请搜索 price_control
|
|
|
+ if (empty($customId)) {
|
|
|
+ $itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
+ $discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
+ if ($discountPrice > 0) {
|
|
|
+ $itemPrice = $discountPrice;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
|
|
|
- //不同的人卖不同价格
|
|
|
- if ($discount > 0 && $discount < 1) {
|
|
|
- $itemPrice = bcmul($itemPrice, $discount, 2);
|
|
|
- //四舍五入保留整数,涉及多个地方要同步修改,请搜索关键词:round_price!!!!
|
|
|
- $itemPrice = round($itemPrice, 0);
|
|
|
+ $currentPriceKey = $levelPriceKey[$customLevel] ?? 'price';
|
|
|
+ $itemPrice = $productData[$productId][$currentPriceKey] ?? 0;
|
|
|
+
|
|
|
+ //特价
|
|
|
+ $discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
+ if ($discountPrice > 0) {
|
|
|
+ $preAddPriceKey = $levelAddPriceKey[0] ?? 'addPrice';
|
|
|
+ $preAddPrice = $productData[$productId][$preAddPriceKey] ?? 0;
|
|
|
+ $currentAddPriceKey = $levelAddPriceKey[$customLevel] ?? 'addPrice';
|
|
|
+ $currentAddPrice = $productData[$productId][$currentAddPriceKey] ?? 0;
|
|
|
+ $diff = bcsub($preAddPrice, $currentAddPrice, 2);
|
|
|
+ $itemPrice = bcsub($discountPrice, $diff, 2);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//供应商开单可以传单价过来
|