shish 2 лет назад
Родитель
Сommit
a2b0a366e7
1 измененных файлов с 122 добавлено и 0 удалено
  1. 122 0
      app-ghs/controllers/ItemController.php

+ 122 - 0
app-ghs/controllers/ItemController.php

@@ -3,6 +3,7 @@
 namespace ghs\controllers;
 
 use biz\item\classes\PtItemClass;
+use biz\product\models\Product;
 use bizGhs\custom\classes\CustomClass;
 use bizGhs\item\classes\ItemClass;
 use common\components\dict;
@@ -18,6 +19,127 @@ use Yii;
 class ItemController extends BaseController
 {
 
+    //列出所有花材 ssh 20240222
+    public function actionGetItemList()
+    {
+        $py = Yii::$app->request->get('py', '');
+        $requestType = Yii::$app->request->get('requestType', 'common');
+        $status = Yii::$app->request->get('status', 1);
+        $delStatus = Yii::$app->request->get('delStatus', 0);
+        $classId = Yii::$app->request->get('classId', 0);
+        $where['mainId'] = $this->mainId;
+        $where['delStatus'] = $delStatus;
+        if (!empty($classId)) {
+            $where['classId'] = $classId;
+        }
+        if ($py) {
+            $pyName = strtolower($py);
+            $where['py'] = $pyName;
+        }
+        //改价和全部有库存花材列表
+        if ($requestType == 'changePrice' || $requestType == 'hasStockList') {
+            $where['stock>'] = 0;
+        }
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        if ($requestType == 'book') {
+            unset($where['status']);
+        }
+        //客户等级
+        $customId = Yii::$app->request->get('customId', 0);
+        $level = 1;
+        if (!empty($customId)) {
+            $custom = CustomClass::getById($customId, true);
+            $level = $custom->level ?? 1;
+        }
+        $itemInfoData = [];
+        if ($requestType == 'hasStockList') {
+            //有库存的花材列表
+            $field = 'id,py,name,classId,itemId,price,skPrice,hjPrice,stock';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+        } elseif ($requestType == 'changePrice') {
+            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,skMore,hjAddPrice,addPrice,variety,price,hjPrice,stock,onStock,presell,frontHide,reachNum,reachNumDiscount';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
+        } elseif ($requestType == 'changeStock') {
+            //修改库存列表
+            $field = 'id,py,cover,name,cost,itemId,status,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,frontHide';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::changeStockGroup($itemInfoData, $level);
+        } elseif ($requestType == 'kd') {
+            //开单的花材列表
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide,reachNum,reachNumDiscount';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::kdItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'book') {
+            //预订花材列表
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::bookItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'itemList') {
+            //花材列表
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
+        } elseif ($requestType == 'outList') {
+            //下架花材列表
+            $where['status'] = 2;
+            $where['delStatus'] = 0;
+            $where['removeStatus'] = 0;
+            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
+        } elseif ($requestType == 'stopList') {
+            //停用花材列表
+            unset($where['status']);
+            $where['delStatus'] = 1;
+            $where['removeStatus'] = 0;
+            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
+        } elseif ($requestType == 'removeList') {
+            //删除花材列表
+            unset($where['status']);
+            $where['delStatus'] = 1;
+            $where['removeStatus'] = 1;
+            $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
+        } elseif ($requestType == 'check') {
+            $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::checkItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'break') {
+            $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::breakItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'part') {
+            //拆散花材
+            $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::partItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'stockOut') {
+            $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,smallRatio,frontHide';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::stockOutGroup($itemInfoData, $level);
+        } elseif ($requestType == 'cg') {
+            $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,presell,ratioType,smallUnit,bigUnit,ratio,weight,frontHide';
+            $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
+            $itemInfoData = ProductClass::cgItemGroup($itemInfoData, $level);
+        } elseif ($requestType == 'warning') {
+            $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,discountPrice,stock,onStock,actualSold,presell,bigUnit,stockWarning,status,frontHide';
+            $itemInfoData = Product::find()->where("mainId={$this->mainId}")
+                ->andWhere('`stock`+`onStock`<`stockWarning`')
+                ->andWhere("delStatus=0")
+                ->select($field)->asArray()->all();
+            $itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
+        } else {
+            util::fail('没有数据');
+        }
+        util::success(['list' => $itemInfoData]);
+    }
+
     //花材申请平台认证 ssh 20231125
     public function actionApplyAuth()
     {