|
@@ -152,10 +152,16 @@ class ProductController extends BaseController
|
|
|
util::success(['list' => $data]);
|
|
util::success(['list' => $data]);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //批量改价
|
|
|
|
|
+ public function actionBatchChangePrice()
|
|
|
|
|
+ {
|
|
|
|
|
+ util::complete();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
//改价
|
|
//改价
|
|
|
public function actionChangePrice()
|
|
public function actionChangePrice()
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
|
|
+ //花材价格只能在首店修改,并同步到分店
|
|
|
$shop = $this->shop;
|
|
$shop = $this->shop;
|
|
|
$default = $shop->default ?? 0;
|
|
$default = $shop->default ?? 0;
|
|
|
if ($default != 1) {
|
|
if ($default != 1) {
|
|
@@ -173,8 +179,6 @@ class ProductController extends BaseController
|
|
|
$productId = Yii::$app->request->post('productId', 0);
|
|
$productId = Yii::$app->request->post('productId', 0);
|
|
|
$price = Yii::$app->request->post('price', '');
|
|
$price = Yii::$app->request->post('price', '');
|
|
|
if (is_numeric($price) && $price > 0) {
|
|
if (is_numeric($price) && $price > 0) {
|
|
|
- //改价
|
|
|
|
|
-
|
|
|
|
|
//判断是否有效
|
|
//判断是否有效
|
|
|
$productData = ProductClass::getProductData($productId, $this->shopId);
|
|
$productData = ProductClass::getProductData($productId, $this->shopId);
|
|
|
if (!$productData) {
|
|
if (!$productData) {
|
|
@@ -187,14 +191,6 @@ class ProductController extends BaseController
|
|
|
if (!$productData) {
|
|
if (!$productData) {
|
|
|
util::fail("花材不存在");
|
|
util::fail("花材不存在");
|
|
|
}
|
|
}
|
|
|
- $itemId = $productData['itemId'];
|
|
|
|
|
- //获取该花材的每扎成本价和每扎加价
|
|
|
|
|
- //自动调价=每扎成本价+每扎加价
|
|
|
|
|
- // $itemData = ItemClass::getItemData($itemId, $this->sjId);
|
|
|
|
|
-// if (!$itemData) {
|
|
|
|
|
-// util::fail("出错拉");
|
|
|
|
|
-// }
|
|
|
|
|
-// $price = bcadd($itemData['cost'], $itemData['addPrice'], 2);
|
|
|
|
|
$price = bcadd($productData['cost'], $productData['addPrice'], 2);
|
|
$price = bcadd($productData['cost'], $productData['addPrice'], 2);
|
|
|
ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
|
|
ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
|
|
|
}
|
|
}
|
|
@@ -209,13 +205,6 @@ class ProductController extends BaseController
|
|
|
if (!$productData) {
|
|
if (!$productData) {
|
|
|
util::fail("花材不存在");
|
|
util::fail("花材不存在");
|
|
|
}
|
|
}
|
|
|
- //$itemId = $productData['itemId'];
|
|
|
|
|
- //获取该花材的每扎成本价和每扎加价
|
|
|
|
|
- //自动调价=每扎成本价+每扎加价
|
|
|
|
|
-// $itemData = ItemClass::getItemData($itemId, $this->sjId);
|
|
|
|
|
-// if (!$itemData) {
|
|
|
|
|
-// util::fail("出错拉");
|
|
|
|
|
-// }
|
|
|
|
|
//2021.04.06改为用product中的成本价+加价
|
|
//2021.04.06改为用product中的成本价+加价
|
|
|
$price = bcadd($productData['cost'], $productData['addPrice'], 2);
|
|
$price = bcadd($productData['cost'], $productData['addPrice'], 2);
|
|
|
ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
|
|
ProductClass::changePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
|
|
@@ -432,11 +421,10 @@ class ProductController extends BaseController
|
|
|
{
|
|
{
|
|
|
$id = Yii::$app->request->get('id');
|
|
$id = Yii::$app->request->get('id');
|
|
|
$productData = ProductClass::getById($id);
|
|
$productData = ProductClass::getById($id);
|
|
|
- if(!$productData){
|
|
|
|
|
|
|
+ if (!$productData) {
|
|
|
util::fail("花材不存在");
|
|
util::fail("花材不存在");
|
|
|
}
|
|
}
|
|
|
- if($productData['shopId'] != $this->shopId){
|
|
|
|
|
- //
|
|
|
|
|
|
|
+ if ($productData['shopId'] != $this->shopId) {
|
|
|
util::fail("无效花材");
|
|
util::fail("无效花材");
|
|
|
}
|
|
}
|
|
|
//去除无用的字段
|
|
//去除无用的字段
|