|
|
@@ -118,16 +118,19 @@ class ProductClass extends BaseClass
|
|
|
$list[$k]['bigNum'] = $stockInfo['bigNum'];
|
|
|
$list[$k]['smallNum'] = $stockInfo['smallNum'];
|
|
|
$list[$k]['itemName'] = $v['name'] ?? '';
|
|
|
- //换算大小单位对应价格
|
|
|
- $list[$k]['bigPrice'] = $v['price']; //大单位价格就是product表存的价格
|
|
|
|
|
|
- $smallPrice = bcdiv($v['price'], $ratio, 2);
|
|
|
- //小单位根据供应商要求+2倍 暂时注释
|
|
|
- //$smallPrice = bcmul($smallPrice, 2, 2);
|
|
|
+ //原价 shish 20210703
|
|
|
+ $list[$k]['prePrice'] = $v['price'] ?? 0;
|
|
|
+
|
|
|
+ //特价 shish 20210901
|
|
|
+ $discountPrice = $v['discountPrice'] ?? 0;
|
|
|
+ $price = $discountPrice > 0 ? $discountPrice : $v['price'];
|
|
|
+ $list[$k]['price'] = $price;
|
|
|
+ $list[$k]['bigPrice'] = $price;
|
|
|
|
|
|
+ $smallPrice = bcdiv($price, $ratio, 2);
|
|
|
$list[$k]['smallPrice'] = $smallPrice;
|
|
|
- //原价 shish 20210703
|
|
|
- $list[$k]['prePrice'] = bcadd($v['cost'], $v['addPrice'], 2);
|
|
|
+
|
|
|
}
|
|
|
return $list;
|
|
|
}
|
|
|
@@ -585,6 +588,13 @@ class ProductClass extends BaseClass
|
|
|
$itemNum = self::mergeItemNum($v['bigNum'], $v['smallNum'], $ratio);
|
|
|
//售卖价格
|
|
|
$itemPrice = $productData[$productId]['price'] ?? 0;
|
|
|
+
|
|
|
+ //折扣价
|
|
|
+ $discountPrice = $productData[$productId]['discountPrice'] ?? 0;
|
|
|
+ if ($discountPrice > 0) {
|
|
|
+ $itemPrice = $discountPrice;
|
|
|
+ }
|
|
|
+
|
|
|
$userPrice = 0; //用户传的价格
|
|
|
if (isset($v['price'])) {
|
|
|
if ($v['price'] <= 0) {
|
|
|
@@ -592,7 +602,7 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
$userPrice = $v['price'];
|
|
|
//用户传价格之后,单价会变化
|
|
|
- $itemPrice = bcdiv($userPrice,$itemNum,2);
|
|
|
+ $itemPrice = bcdiv($userPrice, $itemNum, 2);
|
|
|
}
|
|
|
|
|
|
//合计价格
|
|
|
@@ -729,13 +739,12 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
$upData['cover'] = $data['cover'];
|
|
|
}
|
|
|
- if (isset($data['cost'])) {
|
|
|
- if (empty($data['cost'])) {
|
|
|
- util::fail("请输入花材成本价");
|
|
|
- }
|
|
|
- $upData['cost'] = $data['cost'];
|
|
|
+ if (isset($data['discountPrice']) && is_numeric($data['discountPrice'])) {
|
|
|
+ $upData['discountPrice'] = $data['discountPrice'];
|
|
|
+ }
|
|
|
+ if (isset($data['price']) && is_numeric($data['price'])) {
|
|
|
+ $upData['price'] = $data['price'];
|
|
|
}
|
|
|
-
|
|
|
if (isset($data['weight'])) {
|
|
|
$upData['weight'] = $data['weight'];
|
|
|
}
|
|
|
@@ -929,7 +938,6 @@ class ProductClass extends BaseClass
|
|
|
public static function addProduct($data)
|
|
|
{
|
|
|
$classId = $data['classId'] ?? 0;
|
|
|
- $cost = $data['cost'] ?? false;
|
|
|
$addPrice = $data['addPrice'] ?? false;
|
|
|
$stockWarning = $data['stockWarning'] ?? false;
|
|
|
$data['py'] = stringUtil::py($data['name']);
|
|
|
@@ -961,8 +969,8 @@ class ProductClass extends BaseClass
|
|
|
if (!$classId) {
|
|
|
util::fail("请选择分类");
|
|
|
}
|
|
|
- if ($cost === false) {
|
|
|
- util::fail("请输入花材的成本价");
|
|
|
+ if (isset($data['price']) == false || is_numeric($data['price']) == false) {
|
|
|
+ util::fail("请输入价格");
|
|
|
}
|
|
|
if ($addPrice === false) {
|
|
|
util::fail("请输入花材的加价");
|
|
|
@@ -979,7 +987,6 @@ class ProductClass extends BaseClass
|
|
|
if ($weight === false) {
|
|
|
util::fail("请输入花材重量");
|
|
|
}
|
|
|
-
|
|
|
$existItemClass = ItemClassClass::exists(['id' => $classId, 'sjId' => $data['sjId']]);
|
|
|
if (!$existItemClass) {
|
|
|
util::fail("花材分类不存在");
|
|
|
@@ -1008,7 +1015,6 @@ class ProductClass extends BaseClass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $data['price'] = $data['cost'] + $data['addPrice'];
|
|
|
//根据sjId, 找到所有的shopId,都添加
|
|
|
$shopIds = ShopService::getShopIds($data['sjId']);
|
|
|
foreach ($shopIds as $shopId) {
|