ShopController.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. if (!empty($custom)) {
  52. $custom->visitTime = date("Y-m-d H:i:s");
  53. $custom->save();
  54. }
  55. }
  56. }
  57. util::success(['info' => $info, 'hd' => $hd, 'custom' => $custom]);
  58. }
  59. //获取商家的默认门店 ssh 2019.12.6
  60. public function actionDetail()
  61. {
  62. $introUserId = Yii::$app->request->get('introUserId');
  63. $shop = isset($this->shop) && !empty($this->shop) ? $this->shop->attributes : [];
  64. $ad = [];
  65. if (isset($this->shop->img) && !empty($this->shop->img) && $this->shop->img != '[]') {
  66. $arr = json_decode($this->shop->img, true);
  67. if (!empty($arr)) {
  68. foreach ($arr as $img) {
  69. $imgUrl = imgUtil::groupImg($img);
  70. $ad[] = ['adImgUrl' => $imgUrl];
  71. }
  72. }
  73. }
  74. //新人专享礼物
  75. $newUserGift = [];
  76. if (!empty($introUserId)) {
  77. $userInfo = UserService::getUserInfo($this->userId);
  78. $newUserGift = InviteService::hasNewGift($userInfo);
  79. }
  80. util::success(['ad' => $ad, 'shop' => $shop, 'newUserGift' => $newUserGift]);
  81. }
  82. }