GhsProductController.php 1.6 KB

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