ShopController.php 2.8 KB

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