|
|
@@ -124,29 +124,9 @@ class ProductClass extends BaseClass
|
|
|
$list[$k]['smallNum'] = $stockInfo['smallNum'];
|
|
|
$list[$k]['itemName'] = $v['name'] ?? '';
|
|
|
$list[$k]['prePrice'] = $v['price'] ?? 0;
|
|
|
- $price = $v['price'] ?? 0;
|
|
|
|
|
|
- //价格相关控制!!!!!!!请搜索 price_control
|
|
|
- if (empty($level)) {
|
|
|
- $discountPrice = $v['discountPrice'] ?? 0;
|
|
|
- if ($discountPrice > 0) {
|
|
|
- $price = $discountPrice;
|
|
|
- }
|
|
|
- } else {
|
|
|
- $currentPriceKey = $priceMap[$level] ?? 'price';
|
|
|
- $price = $v[$currentPriceKey] ?? 0;
|
|
|
-
|
|
|
- //特价
|
|
|
- $discountPrice = $v['discountPrice'] ?? 0;
|
|
|
- if ($discountPrice > 0) {
|
|
|
- $preAddPriceKey = $addPriceMap[0] ?? 'addPrice';
|
|
|
- $preAddPrice = $v[$preAddPriceKey] ?? 0;
|
|
|
- $currentAddPriceKey = $addPriceMap[$level] ?? 'addPrice';
|
|
|
- $currentAddPrice = $v[$currentAddPriceKey] ?? 0;
|
|
|
- $diff = bcsub($preAddPrice, $currentAddPrice, 2);
|
|
|
- $price = bcsub($discountPrice, $diff, 2);
|
|
|
- }
|
|
|
- }
|
|
|
+ //今日特价、会员价
|
|
|
+ $price = self::price($v, $level, $priceMap, $addPriceMap);
|
|
|
|
|
|
$list[$k]['price'] = $price;
|
|
|
$list[$k]['bigPrice'] = $price;
|
|
|
@@ -161,6 +141,42 @@ class ProductClass extends BaseClass
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
+ //输出价格 shish 20211009
|
|
|
+ public static function getFinalprice($product, $level, $priceMap, $addPriceMap, $changePrice = 0)
|
|
|
+ {
|
|
|
+ //开单改价优先级最高
|
|
|
+ if ($changePrice > 0) {
|
|
|
+ return $changePrice;
|
|
|
+ }
|
|
|
+ if (empty($product) || isset($product['price']) == false) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ //今日特价
|
|
|
+ $discountPrice = $product['discountPrice'] ?? 0;
|
|
|
+ $maxPriceField = $priceMap[0] ?? 'price';
|
|
|
+ $price = $product[$maxPriceField] ?? 0;
|
|
|
+ if (empty($level)) {
|
|
|
+ if ($discountPrice > 0) {
|
|
|
+ $price = $discountPrice;
|
|
|
+ }
|
|
|
+ return $price;
|
|
|
+ } else {
|
|
|
+ $currentPriceField = $priceMap[$level] ?? 'price';
|
|
|
+ $price = $product[$currentPriceField] ?? 0;
|
|
|
+ if ($discountPrice > 0) {
|
|
|
+
|
|
|
+ $maxAddPriceField = $addPriceMap[0] ?? 'addPrice';
|
|
|
+ $maxAddPrice = $product[$maxAddPriceField] ?? 0;
|
|
|
+
|
|
|
+ $currentAddPriceField = $addPriceMap[$level] ?? 'addPrice';
|
|
|
+ $currentAddPrice = $product[$currentAddPriceField] ?? 0;
|
|
|
+ $diff = bcsub($maxAddPrice, $currentAddPrice, 2);
|
|
|
+ $price = bcsub($discountPrice, $diff, 2);
|
|
|
+ }
|
|
|
+ return $price;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//根据花材ID,库存=》 计算出多少扎,多少支
|
|
|
public static function formatStockByItemId($itemId, $stock)
|
|
|
{
|
|
|
@@ -655,37 +671,12 @@ class ProductClass extends BaseClass
|
|
|
//大小数量合并多少扎
|
|
|
$itemNum = self::mergeItemNum($v['bigNum'], $v['smallNum'], $ratio);
|
|
|
|
|
|
- //价格相关控制!!!!!!!请搜索 price_control
|
|
|
- if (empty($level)) {
|
|
|
- $itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
- $discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
- if ($discountPrice > 0) {
|
|
|
- $itemPrice = $discountPrice;
|
|
|
- }
|
|
|
- } else {
|
|
|
-
|
|
|
- $currentPriceKey = $priceMap[$level] ?? 'price';
|
|
|
- $itemPrice = $productData[$productId][$currentPriceKey] ?? 0;
|
|
|
-
|
|
|
- //特价
|
|
|
- $discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
- if ($discountPrice > 0) {
|
|
|
- $preAddPriceKey = $addPriceMap[0] ?? 'addPrice';
|
|
|
- $preAddPrice = $productData[$productId][$preAddPriceKey] ?? 0;
|
|
|
- $currentAddPriceKey = $addPriceMap[$level] ?? 'addPrice';
|
|
|
- $currentAddPrice = $productData[$productId][$currentAddPriceKey] ?? 0;
|
|
|
- $diff = bcsub($preAddPrice, $currentAddPrice, 2);
|
|
|
- $itemPrice = bcsub($discountPrice, $diff, 2);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
//供应商开单可以传单价过来
|
|
|
- if (isset($v['price'])) {
|
|
|
- if (is_numeric($v['price']) == false || $v['price'] <= 0) {
|
|
|
- util::fail('价格不能小于0');
|
|
|
- }
|
|
|
- $itemPrice = $v['price'];
|
|
|
- }
|
|
|
+ $changePrice = isset($v['price']) && $v['price'] > 0 ? $v['price'] : 0;
|
|
|
+
|
|
|
+ //今日特价、会员价
|
|
|
+ $currentProduct = $productData[$productId] ?? [];
|
|
|
+ $itemPrice = self::price($currentProduct, $level, $priceMap, $addPriceMap, $changePrice);
|
|
|
|
|
|
$price = bcmul($itemNum, $itemPrice, 2);
|
|
|
$tmp = [];
|