ShopController.php 3.6 KB

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