|
|
@@ -8,6 +8,7 @@ namespace hd\controllers;
|
|
|
|
|
|
use biz\ghs\classes\GhsClass;
|
|
|
use biz\item\classes\PtItemClass;
|
|
|
+use biz\shop\classes\ShopClass;
|
|
|
use bizGhs\item\classes\ItemClassClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\product\services\ProductService;
|
|
|
@@ -100,6 +101,77 @@ class ProductController extends BaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //批量改价
|
|
|
+ public function actionBatchChangePrice()
|
|
|
+ {
|
|
|
+ util::fail('暂时无法修改');
|
|
|
+
|
|
|
+ $shopAdmin = $this->shopAdmin;
|
|
|
+ if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
|
|
|
+ util::fail('超管才能修改');
|
|
|
+ }
|
|
|
+
|
|
|
+ //花材价格只能在首店修改,并同步到分店
|
|
|
+ $shop = $this->shop;
|
|
|
+ $default = $shop->default ?? 0;
|
|
|
+ if ($default != 1) {
|
|
|
+ util::fail('请在首店修改');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = Yii::$app->request->post('data', '');
|
|
|
+ if (empty($data)) {
|
|
|
+ util::fail('没有修改');
|
|
|
+ }
|
|
|
+ $arr = json_decode($data, true);
|
|
|
+ if (empty($arr)) {
|
|
|
+ util::fail('没有修改!');
|
|
|
+ }
|
|
|
+
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+
|
|
|
+ $ids = array_column($arr, 'id');
|
|
|
+ $ids = array_unique(array_filter($ids));
|
|
|
+ if (empty($ids)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+
|
|
|
+ $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id', true);
|
|
|
+
|
|
|
+ foreach ($arr as $product) {
|
|
|
+ if (isset($product['price']) == false) {
|
|
|
+ util::fail('没有价格');
|
|
|
+ }
|
|
|
+ if (isset($product['id']) == false) {
|
|
|
+ util::fail('没有花材');
|
|
|
+ }
|
|
|
+ $price = $product['price'];
|
|
|
+ $productId = $product['id'];
|
|
|
+
|
|
|
+ $product = $productList[$productId] ?? [];
|
|
|
+ if (empty($product)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ if (isset($product->shopId) == false || $product->shopId != $this->shopId) {
|
|
|
+ util::fail('没有权限访问');
|
|
|
+ }
|
|
|
+ if (empty($price)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ProductClass::changePrice($product, $price, ProductClass::PRICE_LABEL_CHANGE);
|
|
|
+ }
|
|
|
+ $transaction->commit();
|
|
|
+ util::complete('修改成功');
|
|
|
+
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ Yii::info("修改失败原因:" . $e->getMessage());
|
|
|
+ util::fail('修改失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
//从零售端采购入库,查看供应商的某个门店的product
|
|
|
public function actionGhsItem()
|
|
|
{
|
|
|
@@ -109,7 +181,6 @@ class ProductController extends BaseController
|
|
|
if (empty($ghs)) {
|
|
|
util::fail('没有找到供应商');
|
|
|
}
|
|
|
- $sjId = $ghs['sjId'] ?? 0;
|
|
|
$shopId = $ghs['shopId'] ?? 0;
|
|
|
$black = $ghs['black'] ?? 2;
|
|
|
if ($black == 2) {
|
|
|
@@ -121,11 +192,10 @@ class ProductController extends BaseController
|
|
|
|
|
|
//获取所有当前供应商的分类 (全部、常用)
|
|
|
//根据分类组装分类下的花材信息
|
|
|
- //中央ID
|
|
|
- $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
|
|
|
-// $where['sjId'] = $sjId;
|
|
|
-// $where['shopId'] = $shopId;
|
|
|
- $where['mainId'] = $this->mainId;
|
|
|
+ $shop = ShopClass::getById($shopId, true);
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $classIds = ItemClassClass::getGhsItemClassAll($mainId);
|
|
|
+ $where['mainId'] = $mainId;
|
|
|
$where['delStatus'] = 0;
|
|
|
$where['status'] = 1;
|
|
|
|