ItemController.php 2.8 KB

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