ItemController.php 1.5 KB

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