ItemController.php 2.5 KB

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