HdController.php 4.7 KB

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