HdController.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace mall\controllers;
  3. use bizHd\recharge\classes\RechargeShbClass;
  4. use bizHd\recharge\classes\RechargeSqClass;
  5. use bizMall\hd\classes\HdClass;
  6. use common\components\imgUtil;
  7. use common\components\util;
  8. use bizHd\custom\classes\CustomClass;
  9. use Yii;
  10. class HdController extends BaseController
  11. {
  12. public $guestAccess = ['list', 'info'];
  13. public function actionRecover()
  14. {
  15. $get = Yii::$app->request->get();
  16. $id = $get['id'] ?? 0;
  17. $hd = HdClass::getById($id, true);
  18. if (empty($hd)) {
  19. util::fail('没有花店信息');
  20. }
  21. if ($hd['userId'] != $this->userId) {
  22. util::fail('不是你的店');
  23. }
  24. $hd->delStatus = 0;
  25. $hd->save();
  26. util::complete('已恢复');
  27. }
  28. public function actionDel()
  29. {
  30. $get = Yii::$app->request->get();
  31. $id = $get['id'] ?? 0;
  32. $hd = HdClass::getById($id, true);
  33. if (empty($hd)) {
  34. util::fail('没有花店信息');
  35. }
  36. if ($hd['userId'] != $this->userId) {
  37. util::fail('不是你的店');
  38. }
  39. $hd->delStatus = 1;
  40. $hd->save();
  41. util::complete('删除成功');
  42. }
  43. //花店详情 ssh 20250627
  44. public function actionDetail()
  45. {
  46. $get = Yii::$app->request->get();
  47. $id = $get['id'] ?? 0;
  48. $hd = HdClass::getById($id);
  49. if (empty($hd)) {
  50. util::fail('没有花店信息');
  51. }
  52. if ($hd['userId'] != $this->userId) {
  53. util::fail('不是你的店');
  54. }
  55. $shortAvatar = !empty($val['avatar']) ? $val['avatar'] : 'hhb_small.png';
  56. $smallAvatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  57. $bigAvatar = imgUtil::groupImg($shortAvatar) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  58. $hd['shortAvatar'] = $shortAvatar;
  59. $hd['smallAvatar'] = $smallAvatar;
  60. $hd['bigAvatar'] = $bigAvatar;
  61. util::success($hd);
  62. }
  63. //花店信息 ssh 20230111
  64. public function actionInfo()
  65. {
  66. $get = Yii::$app->request->get();
  67. $id = $get['id'] ?? 0;
  68. $user = $this->user;
  69. $shop = $this->shop;
  70. if (empty($user)) {
  71. $hd = [];
  72. if (!empty($shop)) {
  73. $sjName = $shop->merchantName ?? '';
  74. $name = $shop->shopName == '首店' ? $sjName : $sjName . ' ' . $shop->shopName;
  75. $hd = ['name' => $name];
  76. }
  77. $custom = [];
  78. util::success(['hd' => $hd, 'custom' => $custom]);
  79. } else {
  80. if (empty($id)) {
  81. $respond = CustomClass::buildRelation($shop, $user);
  82. $hd = $respond['hd'];
  83. $custom = $respond['custom'];
  84. } else {
  85. $hd = HdClass::getById($id, true);
  86. $customId = $hd->customId;
  87. $custom = \bizMall\custom\classes\CustomClass::getById($customId, true);
  88. }
  89. // 根据 xhShop 中的 `rechargeWeal`来选择返回快捷充值选项
  90. if ($shop->rechargeWeal == 1) {
  91. $itemType = 'money'; //送钱
  92. $itemList = [];
  93. $weal = RechargeSqClass::getAllByCondition(['mainId' => $shop->mainId], 'recharge asc', '*', null, true);
  94. if (!empty($weal)) {
  95. foreach ($weal as $key => $val) {
  96. $recharge = floatval($val->recharge);
  97. $give = floatval($val->give);
  98. $itemList[] = ['recharge' => $recharge, 'give' => $give];
  99. }
  100. }
  101. } else if ($shop->rechargeWeal == 2 || $shop->rechargeWeal == 3) {
  102. $itemType = 'hb'; //送红包
  103. $itemList = RechargeShbClass::getList('*', ['shopId' => $shop->id]);
  104. }
  105. util::success(['hd' => $hd, 'custom' => $custom, 'itemType' => $itemType, 'itemList' => $itemList]);
  106. }
  107. }
  108. public function actionList()
  109. {
  110. $get = Yii::$app->request->get();
  111. $delStatus = $get['delStatus'] ?? 0;
  112. $userId = $this->userId;
  113. $respond = ['list' => [],'moreData'=>0,'totalNum'=>0,'totalPage'=>0];
  114. if ($userId > 0) {
  115. $mallUpgrading = getenv('MALL_UPGRADING') == false ? 0 : getenv('MALL_UPGRADING');
  116. if ($mallUpgrading == 1) {
  117. $allowShopAdminIdsStr = getenv('MALL_UPGRADE_ALLOW_USER_IDS') ?: '';
  118. $allowShopAdminIds = !empty($allowShopAdminIdsStr) ? explode(',', $allowShopAdminIdsStr) : [];
  119. if (!in_array($userId, $allowShopAdminIds)) {
  120. util::fail('系统升级中,稍后再试,编号:' . $userId);
  121. }
  122. }
  123. $where = [];
  124. $where['userId'] = $userId;
  125. $where['delStatus'] = $delStatus;
  126. $respond = HdClass::getHdList($where);
  127. }
  128. util::success($respond);
  129. }
  130. }