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