ShopController.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\custom\classes\CustomClass;
  4. use bizHd\custom\classes\HdClass;
  5. use bizHd\shop\classes\ShopClass;
  6. use bizMall\ad\services\AdService;
  7. use bizMall\goods\services\CategoryService;
  8. use bizMall\goods\services\GoodsCategoryService;
  9. use bizMall\invite\services\InviteService;
  10. use bizMall\merchant\services\MerchantService;
  11. use bizMall\merchant\services\ShopService;
  12. use bizMall\user\classes\UserClass;
  13. use bizMall\user\services\UserService;
  14. use common\components\imgUtil;
  15. use Yii;
  16. use yii\web\Controller;
  17. use common\components\util;
  18. class ShopController extends BaseController
  19. {
  20. public $guestAccess = ['info'];
  21. //门店详情 ssh 20230210
  22. public function actionInfo()
  23. {
  24. $get = Yii::$app->request->get();
  25. $hdId = $get['hdId'] ?? 0;
  26. $shop = $this->shop;
  27. $info = !empty($shop) ? $shop->attributes : [];
  28. if (isset($info['superWx'])) {
  29. $superWx = $info['superWx'];
  30. $info['superWx'] = imgUtil::groupImg($superWx) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  31. } else {
  32. $info['superWx'] = '';
  33. }
  34. $shortAvatar = $info['avatar'] ?? '';
  35. $avatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_300,w_300";
  36. $info['avatar'] = $avatar;
  37. $info['shortAvatar'] = $shortAvatar;
  38. $user = $this->user;
  39. $hd = [];
  40. $custom = [];
  41. if (!empty($user)) {
  42. if (empty($hdId)) {
  43. $shop = $this->shop;
  44. $respond = CustomClass::buildRelation($shop, $user);
  45. $hd = $respond['hd'];
  46. $custom = $respond['custom'];
  47. } else {
  48. $hd = HdClass::getById($hdId, true);
  49. $customId = $hd->customId;
  50. $custom = CustomClass::getById($customId, true);
  51. }
  52. }
  53. util::success(['info' => $info, 'hd' => $hd, 'custom' => $custom]);
  54. }
  55. //获取商家的默认门店 ssh 2019.12.6
  56. public function actionDetail()
  57. {
  58. $introUserId = Yii::$app->request->get('introUserId');
  59. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  60. $ad = [];
  61. if (isset($this->shop->img) && !empty($this->shop->img) && $this->shop->img != '[]') {
  62. $arr = json_decode($this->shop->img, true);
  63. if (!empty($arr)) {
  64. foreach ($arr as $img) {
  65. $imgUrl = imgUtil::groupImg($img);
  66. $ad[] = ['adImgUrl' => $imgUrl];
  67. }
  68. }
  69. }
  70. //新人专享礼物
  71. $newUserGift = [];
  72. if (!empty($introUserId)) {
  73. $userInfo = UserService::getUserInfo($this->userId);
  74. $newUserGift = InviteService::hasNewGift($userInfo);
  75. }
  76. util::success(['ad' => $ad, 'shop' => $shop, 'newUserGift' => $newUserGift]);
  77. }
  78. }