ShopController.php 2.7 KB

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