ItemController.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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', 'index'];
  15. public function actionAll()
  16. {
  17. $where = [];
  18. $where['mainId'] = $this->mainId;
  19. $classId = Yii::$app->request->get('classId', 0);
  20. if (!empty($classId)) {
  21. $where['classId'] = $classId;
  22. }
  23. $status = Yii::$app->request->get('status', 0);
  24. if (!empty($status)) {
  25. $where['status'] = $status;
  26. }
  27. $delStatus = Yii::$app->request->get('delStatus', 0);
  28. if ($delStatus != 2) {
  29. $where['delStatus'] = $delStatus;
  30. }
  31. //输出标准会员价,即批发价,默认显示的是批发价
  32. $level = 0;
  33. $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
  34. $data = ProductClass::groupProductInfo($data, $level);
  35. util::success(['list' => $data]);
  36. }
  37. //散客查看花材详情 ssh 20230109
  38. public function actionGetMallItemInfo()
  39. {
  40. $get = Yii::$app->request->get();
  41. $id = $get['id'] ?? 0;
  42. $item = ItemClass::getById($id);
  43. $discountPrice = $item['discountPrice'] ?? 0;
  44. if ($discountPrice > 0) {
  45. $skDiscountPrice = $item['skDiscountPrice'] ?? 0;
  46. $item['skPrice'] = $skDiscountPrice;
  47. }
  48. $presell = $item['presell'] ?? 0;
  49. if ($presell == 1) {
  50. $preSellDate = $item['presellDate'] ?? '';
  51. $preSellDateShow = [];
  52. if (!empty($preSellDate)) {
  53. $dateArr = explode(',', trim($preSellDate));
  54. if (!empty($dateArr)) {
  55. foreach ($dateArr as $sellTime) {
  56. $showDate = date("n月j日", $sellTime);
  57. $preSellDateShow[] = $showDate;
  58. }
  59. }
  60. }
  61. $item['presellDateShow'] = $preSellDateShow;
  62. }
  63. $shortCover = $item['cover'] ?? '';
  64. $cover = imgUtil::groupImg($shortCover);
  65. $item['shortCover'] = $shortCover;
  66. $item['bigCover'] = $cover . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  67. $item['cover'] = $cover . "?x-oss-process=image/resize,m_fill,h_100,w_100";
  68. util::success(['info' => $item]);
  69. }
  70. //扫码看价格 ssh 20221008
  71. public function actionShowInfo()
  72. {
  73. $get = Yii::$app->request->get();
  74. $id = $get['id'] ?? 0;
  75. $item = ItemClass::getById($id, true);
  76. if (empty($item)) {
  77. util::stop('');
  78. }
  79. if (isset($item->skDiscountPrice) && $item->skDiscountPrice > 0) {
  80. $skPrice = $item->skDiscountPrice;
  81. } else {
  82. $skPrice = $item->skPrice ?? 0;
  83. }
  84. $skPrice = floatval($skPrice);
  85. $name = $item->name ?? '';
  86. $classId = $item->classId ?? 0;
  87. $class = ItemClassClass::getById($classId, true);
  88. $className = $class->name ?? '';
  89. echo '<div style="font-size:80px;margin-top:80px;margin-left:60px;">' . $name . '</div>';
  90. echo '<div style="font-size:80px;margin-top:30px;margin-left:60px;color:red;">' . $skPrice . '元</div>';
  91. echo '<div style="font-size:60px;margin-top:50px;margin-left:60px;">' . $className . '</div>';
  92. }
  93. public function actionIndex()
  94. {
  95. $py = Yii::$app->request->get('py', '');
  96. //默认显示上架商品
  97. $status = Yii::$app->request->get('status', 1);
  98. //默认显示未删除商品
  99. $delStatus = Yii::$app->request->get('delStatus', 0);
  100. $shop = $this->shop;
  101. if (!isset($shop->ptStyle) || $shop->ptStyle != 1) {
  102. util::fail('访问门店出错了');
  103. }
  104. $user = $this->user;
  105. if (empty($user)) {
  106. util::success([]);
  107. }
  108. //普莲花艺、叶上花、丰行、小武鲜花、九江云朵、源花汇、紫荆不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
  109. $mainId = $this->mainId;
  110. if (getenv('YII_ENV') == 'production') {
  111. if (in_array($mainId, [40057, 7779, 42940, 26374, 10536, 65381])) {
  112. util::fail('暂时无法访问');
  113. }
  114. } else {
  115. if (in_array($mainId, [0, 1])) {
  116. util::fail('暂时无法访问');
  117. }
  118. }
  119. //获取所有当前供货商的分类 (全部、常用)
  120. //根据分类组装分类下的花材信息
  121. //中央ID
  122. $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
  123. $where['mainId'] = $this->mainId;
  124. if ($py) {
  125. $pyName = strtolower($py);
  126. $where['py'] = $pyName;
  127. }
  128. if (!empty($status)) {
  129. $where['status'] = $status;
  130. }
  131. $where['delStatus'] = $delStatus;
  132. $where['frontHide'] = 0;
  133. $level = 0;
  134. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
  135. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  136. $respond = ProductService::assembleData($classIds, $itemInfoData, true);
  137. $data = $respond['classItem'] ?? [];
  138. CustomClass::buildRelation($this->shop, $this->user);
  139. util::success($data);
  140. }
  141. }