GhsProductController.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * User: admin
  4. * Date Time: 2021/3/2 14:33
  5. */
  6. namespace hd\controllers;
  7. use bizGhs\admin\classes\AdminClass;
  8. use bizGhs\item\classes\ItemClass;
  9. use bizGhs\item\classes\ItemClassClass;
  10. use bizGhs\product\classes\ProductClass;
  11. use bizGhs\product\services\ProductService;
  12. use bizGhs\item\services\ItemService;
  13. use common\components\util;
  14. use Yii;
  15. class GhsProductController extends BaseController
  16. {
  17. //从零售端采购入库,查看供货商的某个门店的product
  18. public function actionIndex()
  19. {
  20. $get = Yii::$app->request->get();
  21. $shopId = $get['shopId']??0;
  22. $sjId = $get['sjId']??0;
  23. AdminClass::addRecentShop($shopId,$this->admin);
  24. //获取所有当前供应商的分类 (全部、常用)
  25. //根据分类组装分类下的花材信息
  26. $classIds = ItemClassClass::getGhsItemClassAll($sjId);
  27. $where['merchantId'] = $sjId;
  28. $where['shopId'] = $shopId;
  29. $itemInfoData = ProductClass::getAllByCondition($where,null,"*");
  30. $itemInfoData = ProductClass::groupProductInfo($itemInfoData);
  31. //常用的itemIds
  32. $oftenItemIds = ProductClass::getOftenItemIds($shopId);
  33. //获取供应商下所有花材ID (itemIds)
  34. $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
  35. //dd($itemInfoData);
  36. //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
  37. $data = ProductService::assembleData($classIds, $itemIdsInfo,$itemInfoData, $oftenItemIds, '');
  38. util::success($data);
  39. }
  40. }