ItemController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. $discountPrice = $item['discountPrice'] ?? 0;
  22. if ($discountPrice > 0) {
  23. $skMore = $item['skMore'] ?? 0;
  24. $skPrice = bcadd($skMore, $discountPrice, 2);
  25. $skPrice = floatval($skPrice);
  26. $item['skPrice'] = $skPrice;
  27. }
  28. $presell = $item['presell'] ?? 0;
  29. if ($presell == 1) {
  30. $preSellDate = $item['presellDate'] ?? '';
  31. $preSellDateShow = [];
  32. if (!empty($preSellDate)) {
  33. $dateArr = explode(',', trim($preSellDate));
  34. if (!empty($dateArr)) {
  35. foreach ($dateArr as $sellTime) {
  36. $showDate = date("n月j日", $sellTime);
  37. $preSellDateShow[] = $showDate;
  38. }
  39. }
  40. }
  41. $item['presellDateShow'] = $preSellDateShow;
  42. }
  43. $shortCover = $item['cover'] ?? '';
  44. $cover = imgUtil::groupImg($shortCover);
  45. $item['shortCover'] = $shortCover;
  46. $item['bigCover'] = $cover . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  47. $item['cover'] = $cover . "?x-oss-process=image/resize,m_fill,h_100,w_100";
  48. util::success(['info' => $item]);
  49. }
  50. //扫码看价格 ssh 20221008
  51. public function actionShowInfo()
  52. {
  53. $get = Yii::$app->request->get();
  54. $id = $get['id'] ?? 0;
  55. $item = ItemClass::getById($id, true);
  56. $price = $item->skPrice ?? 0;
  57. $price = floatval($price);
  58. $name = $item->name ?? '';
  59. echo '<div style="font-size:80px;margin-top:80px;margin-left:60px;">' . $name . '</div>';
  60. echo '<div style="font-size:80px;margin-top:20px;margin-left:60px;">' . $price . '元</div>';
  61. }
  62. public function actionIndex()
  63. {
  64. $py = Yii::$app->request->get('py', '');
  65. //默认显示上架商品
  66. $status = Yii::$app->request->get('status', 1);
  67. //默认显示未删除商品
  68. $delStatus = Yii::$app->request->get('delStatus', 0);
  69. //获取所有当前供货商的分类 (全部、常用)
  70. //根据分类组装分类下的花材信息
  71. //中央ID
  72. $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
  73. $where['mainId'] = $this->mainId;
  74. if ($py) {
  75. $pyName = strtolower($py);
  76. $where['py'] = $pyName;
  77. }
  78. if (!empty($status)) {
  79. $where['status'] = $status;
  80. }
  81. $where['delStatus'] = $delStatus;
  82. $where['frontHide'] = 0;
  83. $level = 0;
  84. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
  85. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  86. $data = ProductService::assembleData($classIds, $itemInfoData, true);
  87. CustomClass::buildRelation($this->shop, $this->user);
  88. util::success($data);
  89. }
  90. }