ItemController.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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\item\classes\ItemClass;
  8. use bizMall\user\classes\UserClass;
  9. use common\components\util;
  10. use Yii;
  11. class ItemController extends BaseController
  12. {
  13. public $guestAccess = ['show-info'];
  14. //扫码看价格 ssh 20221008
  15. public function actionShowInfo()
  16. {
  17. $get = Yii::$app->request->get();
  18. $id = $get['id'] ?? 0;
  19. $item = ItemClass::getById($id, true);
  20. $price = $item->skPrice ?? 0;
  21. $price = floatval($price);
  22. echo '<span style="font-size:80px;margin-top:80px;margin-left:60px;">' . $price . '元</span>';
  23. }
  24. public function actionIndex()
  25. {
  26. $py = Yii::$app->request->get('py', '');
  27. //默认显示上架商品
  28. $status = Yii::$app->request->get('status', 1);
  29. //默认显示未删除商品
  30. $delStatus = Yii::$app->request->get('delStatus', 0);
  31. //获取所有当前供货商的分类 (全部、常用)
  32. //根据分类组装分类下的花材信息
  33. //中央ID
  34. $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
  35. $where['mainId'] = $this->mainId;
  36. if ($py) {
  37. $pyName = strtolower($py);
  38. $where['py'] = $pyName;
  39. }
  40. if (!empty($status)) {
  41. $where['status'] = $status;
  42. }
  43. $where['delStatus'] = $delStatus;
  44. $where['frontHide'] = 0;
  45. $level = 0;
  46. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
  47. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  48. $data = ProductService::assembleData($classIds, $itemInfoData, true);
  49. CustomClass::buildRelation($this->shop, $this->user);
  50. util::success($data);
  51. }
  52. }