ItemController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. echo '<span style="font-size:80px;margin-top:80px;margin-left:60px;">' . $price . '元</span>';
  59. }
  60. public function actionIndex()
  61. {
  62. $py = Yii::$app->request->get('py', '');
  63. //默认显示上架商品
  64. $status = Yii::$app->request->get('status', 1);
  65. //默认显示未删除商品
  66. $delStatus = Yii::$app->request->get('delStatus', 0);
  67. //获取所有当前供货商的分类 (全部、常用)
  68. //根据分类组装分类下的花材信息
  69. //中央ID
  70. $classIds = ItemClassClass::getGhsItemClassAll($this->mainId);
  71. $where['mainId'] = $this->mainId;
  72. if ($py) {
  73. $pyName = strtolower($py);
  74. $where['py'] = $pyName;
  75. }
  76. if (!empty($status)) {
  77. $where['status'] = $status;
  78. }
  79. $where['delStatus'] = $delStatus;
  80. $where['frontHide'] = 0;
  81. $level = 0;
  82. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
  83. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  84. $data = ProductService::assembleData($classIds, $itemInfoData, true);
  85. CustomClass::buildRelation($this->shop, $this->user);
  86. util::success($data);
  87. }
  88. }