ShopController.php 2.7 KB

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