HdController.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\custom\classes\HdClass;
  4. use common\components\imgUtil;
  5. use common\components\util;
  6. use bizHd\custom\classes\CustomClass;
  7. use Yii;
  8. class HdController extends BaseController
  9. {
  10. public $guestAccess = ['list', 'info'];
  11. //花店详情 ssh 20250627
  12. public function actionDetail()
  13. {
  14. $get = Yii::$app->request->get();
  15. $id = $get['id'] ?? 0;
  16. $hd = \bizMall\hd\classes\HdClass::getById($id);
  17. if (empty($hd)) {
  18. util::fail('没有花店信息');
  19. }
  20. if ($hd['userId'] != $this->userId) {
  21. util::fail('不是你的店');
  22. }
  23. $shortAvatar = !empty($val['avatar']) ? $val['avatar'] : 'hhb_small.png';
  24. $smallAvatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  25. $bigAvatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  26. $hd['shortAvatar'] = $shortAvatar;
  27. $hd['smallAvatar'] = $smallAvatar;
  28. $hd['bigAvatar'] = $bigAvatar;
  29. util::success($hd);
  30. }
  31. //花店信息 ssh 20230111
  32. public function actionInfo()
  33. {
  34. $get = Yii::$app->request->get();
  35. $id = $get['id'] ?? 0;
  36. $user = $this->user;
  37. $shop = $this->shop;
  38. if (empty($user)) {
  39. $hd = [];
  40. if (!empty($shop)) {
  41. $sjName = $shop->merchantName ?? '';
  42. $name = $shop->shopName == '首店' ? $sjName : $sjName . ' ' . $shop->shopName;
  43. $hd = ['name' => $name];
  44. }
  45. $custom = [];
  46. util::success(['hd' => $hd, 'custom' => $custom]);
  47. } else {
  48. if (empty($id)) {
  49. $respond = CustomClass::buildRelation($shop, $user);
  50. $hd = $respond['hd'];
  51. $custom = $respond['custom'];
  52. } else {
  53. $hd = \bizMall\hd\classes\HdClass::getById($id, true);
  54. $customId = $hd->customId;
  55. $custom = \bizMall\custom\classes\CustomClass::getById($customId, true);
  56. }
  57. util::success(['hd' => $hd, 'custom' => $custom]);
  58. }
  59. }
  60. public function actionList()
  61. {
  62. $showGlInfo = getenv('SHOW_GL_INFO');
  63. $info = $showGlInfo === false ? 1 : $showGlInfo;
  64. if (empty($this->userId)) {
  65. util::success(['list' => [], 'showGlInfo' => $info]);
  66. }
  67. $where = [];
  68. $where['userId'] = $this->userId;
  69. $where['delStatus'] = 0;
  70. $respond = HdClass::getHdList($where);
  71. $respond['showGlInfo'] = $info;
  72. util::success($respond);
  73. }
  74. }