|
|
@@ -13,6 +13,7 @@ use bizGhs\item\classes\ItemClassClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\product\services\ProductService;
|
|
|
use bizGhs\item\services\ItemService;
|
|
|
+use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
|
|
|
@@ -35,14 +36,10 @@ class ProductController extends BaseController
|
|
|
//根据分类组装分类下的花材信息
|
|
|
$classIds = ItemClassClass::getGhsItemClassAll($this->sjId);
|
|
|
|
|
|
- //获取供应商下所有花材ID (itemIds)
|
|
|
- $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
|
|
|
-
|
|
|
- $itemIds = array_column($itemIdsInfo, 'itemId');
|
|
|
-
|
|
|
+ $where['merchantId'] = $this->sjId;
|
|
|
if ($py) {
|
|
|
- $pyNameItemIds = ItemClass::getItemIdsByPyName($py);
|
|
|
- $itemIds = array_intersect($itemIds, $pyNameItemIds);
|
|
|
+ $pyName = strtolower($py);
|
|
|
+ $where['py'] = $pyName;
|
|
|
}
|
|
|
$shopId = $this->shopId;
|
|
|
//兼容客户根据门店下单
|
|
|
@@ -56,46 +53,59 @@ class ProductController extends BaseController
|
|
|
if (!$shopId) {
|
|
|
$shopId = $this->shopId;
|
|
|
}
|
|
|
-
|
|
|
- $waringItemIds = ProductClass::getItemIdsWarning($this->sjId, $shopId);
|
|
|
- $itemIds = array_intersect($itemIds, $waringItemIds);
|
|
|
}
|
|
|
+ $where['shopId'] = $shopId;
|
|
|
|
|
|
-
|
|
|
- $itemInfoData = ProductClass::getProductInfoByItemIds($itemIds, $shopId);
|
|
|
-
|
|
|
+ $itemInfoData = ProductClass::getAllByCondition($where,null,"*");
|
|
|
+ $itemInfoData = ProductClass::groupProductInfo($itemInfoData);
|
|
|
//常用的itemIds
|
|
|
$oftenItemIds = ProductClass::getOftenItemIds($shopId);
|
|
|
+ //获取供应商下所有花材ID (itemIds)
|
|
|
+ $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
|
|
|
|
|
|
+ //dd($itemInfoData);
|
|
|
//组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
|
|
|
- $data = ProductService::assembleData($classIds, $itemIdsInfo, $itemInfoData, $oftenItemIds, $type);
|
|
|
+ $data = ProductService::assembleData($classIds, $itemIdsInfo,$itemInfoData, $oftenItemIds, $type);
|
|
|
|
|
|
util::success($data);
|
|
|
}
|
|
|
|
|
|
|
|
|
- //弃用
|
|
|
+ //当前门店所有花材分类
|
|
|
public function actionList()
|
|
|
{
|
|
|
//$classId = Yii::$app->request->get('classId',0);
|
|
|
$pyName = Yii::$app->request->get('py', '');
|
|
|
- $itemInfo = ItemClass::getGhsItemAll($this->sjId);
|
|
|
- $itemIds = array_column($itemInfo, 'itemId');
|
|
|
+// $itemInfo = ItemClass::getGhsItemAll($this->sjId);
|
|
|
+// $itemIds = array_column($itemInfo, 'itemId');
|
|
|
+ $where['merchantId'] = $this->sjId;
|
|
|
+
|
|
|
if ($pyName) {
|
|
|
- $pyNameItemIds = ItemClass::getItemIdsByPyName($pyName);
|
|
|
- $itemIds = array_intersect($itemIds, $pyNameItemIds);
|
|
|
+// $pyNameItemIds = ItemClass::getItemIdsByPyName($pyName);
|
|
|
+// $itemIds = array_intersect($itemIds, $pyNameItemIds);
|
|
|
+ $pyName = strtolower($pyName);
|
|
|
+ $where['py'] = $pyName;
|
|
|
}
|
|
|
$shopId = Yii::$app->request->get('shopId', 0);
|
|
|
if (!$shopId) {
|
|
|
$shopId = $this->shopId;
|
|
|
}
|
|
|
+ $where['shopId'] = $shopId;
|
|
|
+
|
|
|
$type = Yii::$app->request->get('type', '');
|
|
|
+
|
|
|
+ $data = ProductClass::getAllByCondition($where,null,"*");
|
|
|
+ $data = ProductClass::groupProductInfo($data);
|
|
|
if ($type == 'waring') {
|
|
|
//库存预警
|
|
|
- $waringItemIds = ProductClass::getItemIdsWarning($this->sjId, $shopId);
|
|
|
- $itemIds = array_intersect($itemIds, $waringItemIds);
|
|
|
+ $newData = [];
|
|
|
+ foreach ($data as $v){
|
|
|
+ if($v['stock'] <= $v['stockWarning']) {
|
|
|
+ $newData[] = $v;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::success(['list' => $newData]);
|
|
|
}
|
|
|
- $data = ProductClass::getProductInfoByItemIds($itemIds, $shopId);
|
|
|
util::success(['list' => $data]);
|
|
|
}
|
|
|
|