ItemController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace mall\controllers;
  3. use bizGhs\item\classes\ItemClassClass;
  4. use bizGhs\product\classes\ProductClass;
  5. use bizGhs\product\services\ProductService;
  6. use common\components\util;
  7. use Yii;
  8. class ItemController extends BaseController
  9. {
  10. public function actionIndex()
  11. {
  12. $py = Yii::$app->request->get('py', '');
  13. //默认显示上架商品
  14. $status = Yii::$app->request->get('status', 1);
  15. //默认显示未删除商品
  16. $delStatus = Yii::$app->request->get('delStatus', 0);
  17. //获取所有当前供应商的分类 (全部、常用)
  18. //根据分类组装分类下的花材信息
  19. //中央ID
  20. $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
  21. $where['mainId'] = $this->mainId;
  22. if ($py) {
  23. $pyName = strtolower($py);
  24. $where['py'] = $pyName;
  25. }
  26. if (!empty($status)) {
  27. $where['status'] = $status;
  28. }
  29. $where['delStatus'] = $delStatus;
  30. $level = 0;
  31. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
  32. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  33. $data = ProductService::assembleData($classIds, $itemInfoData, true);
  34. util::success($data);
  35. }
  36. }