ItemController.php 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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\pictext\classes\PicTextGhsItemClass;
  8. use bizMall\item\classes\ItemClass;
  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. $pixTextGoods = PicTextGhsItemClass::getByCondition(['mainId' => $item['mainId'], 'ghsItemId' => $id], true);
  69. $item['picTextGoods'] = $pixTextGoods;
  70. // 封面图与多花材图片的兼容处理
  71. if ($item['images'] == '' && $item['shortCover'] != '') {
  72. $item['images'] = $item['shortCover'];
  73. }
  74. util::success(['info' => $item]);
  75. }
  76. //扫码看价格 ssh 20221008
  77. public function actionShowInfo()
  78. {
  79. $get = Yii::$app->request->get();
  80. $id = $get['id'] ?? 0;
  81. $item = ItemClass::getById($id, true);
  82. if (empty($item)) {
  83. util::stop('');
  84. }
  85. if (isset($item->skDiscountPrice) && $item->skDiscountPrice > 0) {
  86. $skPrice = $item->skDiscountPrice;
  87. } else {
  88. $skPrice = $item->skPrice ?? 0;
  89. }
  90. $skPrice = floatval($skPrice);
  91. $name = $item->name ?? '';
  92. $classId = $item->classId ?? 0;
  93. $class = ItemClassClass::getById($classId, true);
  94. $className = $class->name ?? '';
  95. echo '<div style="font-size:80px;margin-top:80px;margin-left:60px;">' . $name . '</div>';
  96. echo '<div style="font-size:80px;margin-top:30px;margin-left:60px;color:red;">' . $skPrice . '元</div>';
  97. echo '<div style="font-size:60px;margin-top:50px;margin-left:60px;">' . $className . '</div>';
  98. }
  99. public function actionIndex()
  100. {
  101. $py = Yii::$app->request->get('py', '');
  102. //默认显示上架商品
  103. $status = Yii::$app->request->get('status', 1);
  104. //默认显示未删除商品
  105. $delStatus = Yii::$app->request->get('delStatus', 0);
  106. $shop = $this->shop;
  107. if (!isset($shop->ptStyle) || $shop->ptStyle != 1) {
  108. util::fail('访问门店出错了');
  109. }
  110. $user = $this->user;
  111. if (empty($user)) {
  112. util::success([]);
  113. }
  114. //普莲花艺、叶上花、丰行、小武鲜花、九江云朵、源花汇、紫荆不能在花卉宝下单,多处要同步修改,关键词ls_mall_not_open
  115. $mainId = $this->mainId;
  116. if (getenv('YII_ENV') == 'production') {
  117. if (in_array($mainId, [40057, 7779, 42940, 26374, 10536, 65381])) {
  118. util::fail('暂时无法访问');
  119. }
  120. } else {
  121. if (in_array($mainId, [0, 1])) {
  122. util::fail('暂时无法访问');
  123. }
  124. }
  125. //获取所有当前供货商的分类 (全部、常用)
  126. //根据分类组装分类下的花材信息
  127. //中央ID
  128. $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
  129. $where['mainId'] = $this->mainId;
  130. if ($py) {
  131. $pyName = strtolower($py);
  132. $where['py'] = $pyName;
  133. }
  134. if (!empty($status)) {
  135. $where['status'] = $status;
  136. }
  137. $where['delStatus'] = $delStatus;
  138. //批发端没有隐藏
  139. //$where['frontHide'] = 0;
  140. //零售端没有隐藏
  141. $where['frontUse'] = 0;
  142. $level = 0;
  143. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
  144. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  145. $respond = ProductService::assembleData($classIds, $itemInfoData, true);
  146. $data = $respond['classItem'] ?? [];
  147. CustomClass::buildRelation($this->shop, $this->user);
  148. util::success($data);
  149. }
  150. }