ShopController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <?php
  2. namespace hd\controllers;
  3. use biz\shop\classes\ShopClass;
  4. use biz\sj\services\MerchantExtendService;
  5. use bizGhs\admin\classes\AdminClass;
  6. use bizGhs\custom\classes\CustomClass;
  7. use bizHd\admin\classes\ShopAdminClass;
  8. use bizHd\custom\classes\CustomClass as HdCustomClass;
  9. use bizHd\custom\classes\HdClass;
  10. use bizHd\merchant\classes\SjClass;
  11. use bizHd\merchant\services\ShopService;
  12. use bizHd\purchase\classes\PurchaseClass;
  13. use bizHd\saas\services\RegionService;
  14. use bizHd\shop\classes\ShopExtClass;
  15. use common\components\dict;
  16. use common\components\dirUtil;
  17. use common\components\imgUtil;
  18. use common\components\stringUtil;
  19. use common\components\util;
  20. use common\components\wxUtil;
  21. use Yii;
  22. class ShopController extends BaseController
  23. {
  24. public $guestAccess = ['all', 'gathering-img-url', 'check-shop'];
  25. public function actionModifySjName()
  26. {
  27. $get = Yii::$app->request->get();
  28. $adminId = $this->adminId;
  29. $staff = $this->shopAdmin;
  30. if ($staff->founder != 2 && $adminId != 4) {
  31. util::fail('老板才能改店名');
  32. }
  33. $name = $get['name'] ?? '';
  34. if (empty($name)) {
  35. util::fail('请填写名称');
  36. }
  37. //开启事务
  38. $connection = Yii::$app->db;
  39. $transaction = $connection->beginTransaction();
  40. try {
  41. $shop = $this->shop;
  42. $shop->merchantName = $name;
  43. $shop->save();
  44. $sj = SjClass::getById($shop->sjId, true);
  45. if (empty($sj)) {
  46. util::fail('门店信息缺失呢');
  47. }
  48. $sj->name = $name;
  49. $sj->save();
  50. $fullName = $shop->shopName == '首店' ? $name : $name . ' ' . $shop->shopName;
  51. $shopId = $shop->id;
  52. HdClass::updateByCondition(['shopId' => $shopId], ['name' => $fullName]);
  53. CustomClass::updateByCondition(['shopId' => $shopId], ['originName' => $fullName]);
  54. $transaction->commit();
  55. util::complete('修改成功');
  56. } catch (\Exception $exception) {
  57. $transaction->rollBack();
  58. Yii::error("修改门店名称失败:" . $exception->getMessage());
  59. util::fail('修改门店名称失败');
  60. }
  61. }
  62. //我的可以进入的门店 ssh 20230424
  63. public function actionMyShop()
  64. {
  65. $staff = $this->shopAdmin;
  66. $shopList = [];
  67. if (isset($staff->super) && $staff->super == 1) {
  68. $sjId = $this->sjId ?? 0;
  69. $shopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'ptStyle' => 1], null, 'id,shopName,merchantName,sjId,mainId,ptStyle', 'id');
  70. }
  71. $adminId = $this->adminId ?? 0;
  72. $staffList = ShopAdminClass::getAllByCondition(['adminId' => $adminId], null, '*', null, true);
  73. $mainIdList = [];
  74. if (!empty($staffList)) {
  75. foreach ($staffList as $staff) {
  76. $isPt = $staff->isPt ?? 0;
  77. $delStatus = $staff->delStatus ?? 0;
  78. //$super = $staff->super ?? 0;
  79. $mainId = $staff->mainId ?? 0;
  80. if ($isPt == 0 && $delStatus == 0) {
  81. $mainIdList[] = $mainId;
  82. }
  83. }
  84. }
  85. if (!empty($mainIdList)) {
  86. $addShopList = ShopClass::getAllByCondition(['mainId' => ['in', $mainIdList], 'ptStyle' => 1], null, 'id,shopName,merchantName,sjId,mainId,ptStyle', 'id');
  87. if (!empty($addShopList)) {
  88. foreach ($addShopList as $addShop) {
  89. $addShopId = $addShop['id'] ?? 0;
  90. if (isset($shopList[$addShopId]) == false) {
  91. $shopList[$addShopId] = $addShop;
  92. }
  93. }
  94. }
  95. }
  96. $list = array_values($shopList);
  97. util::success(['list' => $list]);
  98. }
  99. //是否开启完整功能 ssh 20230226
  100. public function actionChangeOnlyCg()
  101. {
  102. $shop = $this->shop;
  103. $get = Yii::$app->request->get();
  104. $onlyCg = $get['onlyCg'] ?? 1;
  105. $shop->onlyCg = $onlyCg;
  106. $shop->save();
  107. util::complete('操作成功');
  108. }
  109. public function actionCheckShop()
  110. {
  111. $get = Yii::$app->request->get();
  112. $mobile = $get['mobile'] ?? '';
  113. if (empty($mobile)) {
  114. util::success(['has' => 0]);
  115. }
  116. $shop = ShopClass::getByCondition(['mobile' => $mobile], true);
  117. if (!empty($shop)) {
  118. util::success(['has' => 1]);
  119. }
  120. util::success(['has' => 0]);
  121. }
  122. //获取当前门店信息 ssh 2021.3.27
  123. public function actionCurrentShop()
  124. {
  125. $shopExt = ShopExtClass::getByCondition(['shopId' => $this->shop->id], false, false, 'reachVip');
  126. $shop = $this->shop->attributes;
  127. $shop['reachVip'] = $shopExt['reachVip'];
  128. $shop['warning'] = '';
  129. //$shop['warning'] = '明天凌晨1:00~2:00系统升级,暂停使用';
  130. util::success($shop);
  131. }
  132. //门店列表 ssh 20202.2.29
  133. public function actionList()
  134. {
  135. $where = [];
  136. $where['sjId'] = $this->sjId;
  137. $where['delStatus'] = 0;
  138. $list = \bizHd\shop\classes\ShopClass::getShopList($where);
  139. util::success($list);
  140. }
  141. //更新门店 ssh 2020.2.29
  142. public function actionUpdate()
  143. {
  144. $data = Yii::$app->request->post();
  145. $data['sjId'] = $this->sjId;
  146. $id = isset($data['id']) ? $data['id'] : 0;
  147. unset($data['id']);
  148. $data['meetNum'] = isset($data['meetNum']) ? intval($data['meetNum']) : 0;
  149. $data['meetAmount'] = isset($data['meetAmount']) ? floatval($data['meetAmount']) : 0;
  150. $data['cutAmount'] = isset($data['cutAmount']) ? floatval($data['cutAmount']) : 0;
  151. $shop = ShopService::getById($id);
  152. ShopClass::valid($shop, $this->sjId);
  153. $data['img'] = isset($data['img']) && is_array($data['img']) ? json_encode($data['img']) : '';
  154. //手机号具有唯一性,暂时不允许修改 --- 同批发端 app-ghs/controllers/ShopController.php 保持一致
  155. unset($data['mobile']);
  156. // 添加事务处理
  157. $connection = Yii::$app->db;
  158. $transaction = $connection->beginTransaction();
  159. try {
  160. ShopClass::updateShop($shop, $data);
  161. $transaction->commit();
  162. util::complete();
  163. } catch (\Exception $exception) {
  164. $transaction->rollBack();
  165. Yii::error("更新门店失败:" . $exception->getMessage());
  166. util::fail('更新门店失败');
  167. }
  168. }
  169. //修改门店营业时间
  170. public function actionUpdateOpenTime()
  171. {
  172. $post = Yii::$app->request->post();
  173. $shopId = intval($post['shopId'] ?? $post['id'] ?? 0);
  174. if ($shopId <= 0) {
  175. $shopId = intval($this->shopId);
  176. }
  177. if ($shopId != intval($this->shopId)) {
  178. util::fail('不是您的门店');
  179. }
  180. $shop = ShopClass::getShopInfo($shopId);
  181. if (empty($shop)) {
  182. util::fail('门店不存在');
  183. }
  184. ShopClass::valid($shop, $this->sjId);
  185. ShopClass::updateOpenTime($shop, $post);
  186. util::complete('修改成功');
  187. }
  188. public function actionAdd()
  189. {
  190. $data = Yii::$app->request->post();
  191. $data['sjId'] = $this->sjId;
  192. $data['shopId'] = $this->shopId;
  193. if (isset($data['shopName']) == false || empty($data['shopName'])) {
  194. util::fail('请填写门店名称');
  195. }
  196. $sj = $this->sj;
  197. $sjName = $sj->name ?? '';
  198. $data['merchantName'] = $sjName;
  199. $ptStyle = $sj->style ?? dict::getDict('ptStyle', 'hd');
  200. $data['ptStyle'] = $ptStyle;
  201. $connection = Yii::$app->db;
  202. $transaction = $connection->beginTransaction();
  203. try {
  204. $mobile = $data['mobile'] ?? 0;
  205. if (stringUtil::isMobile($mobile) == false) {
  206. util::fail('请填写正确手机号');
  207. }
  208. $adminInfo = ['name' => $mobile, 'mobile' => $mobile];
  209. $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
  210. $admin = AdminClass::replaceAdmin($adminInfo, $fromApp);
  211. $adminId = $admin['id'] ?? 0;
  212. $data['adminId'] = $adminId;
  213. \bizHd\shop\classes\ShopClass::addMainShop($data, $this->shop, $this->sj);
  214. $transaction->commit();
  215. util::complete();
  216. } catch (\Exception $exception) {
  217. $transaction->rollBack();
  218. util::fail();
  219. }
  220. }
  221. //切换门店 lqh 2021.1.31
  222. public function actionToggleShop()
  223. {
  224. $adminId = $this->adminId;
  225. $mainId = $this->mainId;
  226. //多处要同步修改,关键词 no_allow_toggle_shop
  227. if (getenv('YII_ENV') == 'production') {
  228. //安海恋善不允许切换门店
  229. if (in_array($mainId, [44759, 56314, 56315, 56452])) {
  230. if (in_array($adminId, [54630, 54723])) {
  231. util::fail('专用账号,不允许切换门店');
  232. }
  233. }
  234. //惠雅南城不允许切换门店
  235. if ($mainId == 52 && $adminId == 3539) {
  236. util::fail('收银专用账号,不允许切换门店');
  237. }
  238. //惠雅莞城不允许切换门店
  239. if ($mainId == 1459 && $adminId == 2812) {
  240. util::fail('收银专用账号,不允许切换门店');
  241. }
  242. //淘花里中山店
  243. if ($mainId == 16948 && $adminId == 17908) {
  244. util::fail('收银专用账号,不允许切换门店');
  245. }
  246. //淘花里小榄店
  247. if ($mainId == 72057 && $adminId == 69792) {
  248. util::fail('收银专用账号,不允许切换门店');
  249. }
  250. }
  251. $shopAdmin = $this->shopAdmin;
  252. $switchShop = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($shopAdmin);
  253. if ($switchShop == 0) {
  254. util::fail('不能切换门店');
  255. }
  256. $newShopId = Yii::$app->request->post('shopId', 0);
  257. $deviceId = Yii::$app->request->post('deviceId', '');
  258. $newShop = ShopClass::getById($newShopId, true);
  259. if (empty($newShop)) {
  260. util::fail('没有找到门店30');
  261. }
  262. $res = \bizHd\admin\classes\AdminClass::toggleShop($this->admin, $newShop, $this->sjId, $this->shopAdmin);
  263. if ($deviceId != '') {
  264. //设备登录状态更新
  265. $oldDevice = \bizHd\device\classes\HdDeviceClass::getByCondition(['shopId' => $this->shopId, 'deviceId' => $deviceId], true);
  266. if ($oldDevice) {
  267. $oldDevice->status = 0;
  268. $oldDevice->save();
  269. }
  270. $newLoginDevice = \bizHd\device\classes\HdDeviceClass::getByCondition(['shopId' => $newShopId, 'deviceId' => $deviceId], true);
  271. if ($newLoginDevice) {
  272. $newLoginDevice->status = 1;
  273. $newLoginDevice->save();
  274. }
  275. }
  276. util::success($res);
  277. }
  278. //网页端使用,下载微信和支付宝收款码 ssh 20250821
  279. public function actionGatheringCode()
  280. {
  281. $id = Yii::$app->request->get('id', 0);
  282. $shop = ShopService::getById($id, true);
  283. if (empty($shop)) {
  284. util::fail('没有找到门店31');
  285. }
  286. ShopClass::valid($shop->attributes, $this->sjId);
  287. $imgUrl = ShopClass::generateGatheringCode($this->sjId, $id);
  288. $shopName = $shop->shopName ?? '';
  289. $file = fopen($imgUrl, "rb");
  290. Header("Content-type: application/octet-stream ");
  291. Header("Accept-Ranges: bytes ");
  292. Header("Content-Disposition: attachment;filename={$shopName}收款码.jpg");
  293. $contents = "";
  294. while (!feof($file)) {
  295. $contents .= fread($file, 8192);
  296. }
  297. echo $contents;
  298. fclose($file);
  299. }
  300. //小程序端使用,下载收款码 ssh 20250821
  301. public function actionMiniGatheringCode()
  302. {
  303. $shop = $this->shop;
  304. $shopId = $shop->id;
  305. $imgUrl = ShopClass::generateGatheringCode($this->sjId, $shopId);
  306. util::success(['imgUrl' => $imgUrl]);
  307. }
  308. //获取二维码
  309. public function actionGetGatheringCodeUrl()
  310. {
  311. $id = Yii::$app->request->get('id', 0);
  312. $shop = ShopService::getById($id, true);
  313. if (empty($shop)) {
  314. util::fail('没有找到门店32');
  315. }
  316. ShopClass::valid($shop->attributes, $this->sjId);
  317. $imgUrl = Yii::$app->params['hdHost'] . '/auth/gathering-img-url?id=' . $id;
  318. util::success(['url' => $imgUrl]);
  319. }
  320. public function actionGatheringImgUrl()
  321. {
  322. $id = Yii::$app->request->get('id', 0);
  323. $shop = ShopService::getById($id, true);
  324. if (empty($shop)) {
  325. util::fail('没有找到门店33');
  326. }
  327. $sjId = $shop->sjId;
  328. $imgUrl = ShopClass::generateGatheringCode($sjId, $id);
  329. $fileResource = file_get_contents($imgUrl);
  330. header('Content-type: image/jpeg');
  331. echo $fileResource;
  332. }
  333. //获取小程序的收款码 ssh
  334. public function actionGatheringMiniCode()
  335. {
  336. $id = Yii::$app->request->get('id', 0);
  337. $extend = MerchantExtendService::getBySjId($this->sjId);
  338. if ($extend['miniAuth'] == 0) {
  339. util::fail('您的小程序还没有授权');
  340. }
  341. $shop = ShopService::getById($id);
  342. ShopService::valid($shop, $this->sjId);
  343. $applyMemberCode = wxUtil::generateGatheringMiniCode($this->sj->attributes, $id);
  344. $file = dirUtil::getImgDir() . $applyMemberCode;
  345. if (file_exists($file) == false) {
  346. util::fail('没有找到注册会员码');
  347. }
  348. $fileName = "门店({$id})小程序收款码.jpg";
  349. $contentType = 'image/jpeg';
  350. header("Cache-control: private");
  351. header("Content-type: $contentType"); //设置要下载的文件类型
  352. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  353. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  354. readfile($file);
  355. }
  356. //下载会员注册码 ssh 2020.2.29
  357. public function actionApplyMemberCode()
  358. {
  359. $id = Yii::$app->request->get('id', 0);
  360. $extend = MerchantExtendService::getBySjId($this->sjId);
  361. if ($extend['miniAuth'] == 0) {
  362. util::fail('您的小程序还没有授权');
  363. }
  364. $shop = ShopService::getById($id);
  365. ShopService::valid($shop, $this->sjId);
  366. $applyMemberCode = wxUtil::generateMemberCode($this->sj->attributes, $id);
  367. $file = dirUtil::getImgDir() . $applyMemberCode;
  368. if (file_exists($file) == false) {
  369. util::fail('没有找到注册会员码');
  370. }
  371. $fileName = "注册会员码{$id}.jpg";
  372. $contentType = 'image/jpeg';
  373. header("Cache-control: private");
  374. header("Content-type: $contentType"); //设置要下载的文件类型
  375. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  376. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  377. readfile($file);
  378. }
  379. //删除门店 ssh 2020.3.1
  380. public function actionDelete()
  381. {
  382. util::fail('禁止操作');
  383. $id = Yii::$app->request->get('id', 0);
  384. util::fail('功能开发中');
  385. $shop = ShopService::getById($id);
  386. ShopService::valid($shop, $this->sjId);
  387. ShopService::deleteShop($shop);
  388. util::complete();
  389. }
  390. //获取门店详情 ssh 2021.4.23
  391. public function actionDetail()
  392. {
  393. $shopId = Yii::$app->request->get('shopId');
  394. if (empty($shopId)) {
  395. $shopId = $this->shopId;
  396. }
  397. $shop = ShopClass::getShopInfo($shopId);
  398. $shop['hasMap'] = dict::getDict('hasMap'); //添加 hasMap 属性(字典中的 hasMap)
  399. util::success(['info' => $shop]);
  400. }
  401. //提现信息更新 ssh 2021.3.23
  402. public function actionCashUpdate()
  403. {
  404. $get = Yii::$app->request->get();
  405. $cashAccount = $get['cashAccount'] ?? '';
  406. $cashName = $get['cashName'] ?? '';
  407. $cashBank = $get['cashBank'] ?? '';
  408. if (empty($cashName)) {
  409. util::fail('请填写姓名');
  410. }
  411. if (empty($cashAccount)) {
  412. util::fail('请填写银行卡号');
  413. }
  414. if (empty($cashBank)) {
  415. util::fail('请输入开户行');
  416. }
  417. $shopAdmin = $this->shopAdmin;
  418. $shopId = $shopAdmin->shopId ?? 0;
  419. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  420. util::fail('超管才能操作');
  421. }
  422. ShopClass::updateById($shopId, ['cashAccount' => $cashAccount, 'cashName' => $cashName, 'cashBank' => $cashBank]);
  423. $shop = $this->shop;
  424. $sjName = $shop->merchantName ?? '';
  425. $shopName = $shop->shopName ?? '';
  426. //noticeUtil::push("{$sjName}-{$shopName} 修改提现账号,{$cashName} {$cashAccount} {$cashBank}", '15280215347');
  427. util::complete();
  428. }
  429. //获取所有门店lqh 2021.1.31
  430. public function actionAll()
  431. {
  432. $res = [];
  433. $shopAdmin = isset($this->shopAdmin) && !empty($this->shopAdmin) ? $this->shopAdmin->attributes : [];
  434. if (isset($shopAdmin['super']) && $shopAdmin['super'] == 1) {
  435. $res = ShopClass::getAllShop($this->sjId);
  436. }
  437. util::success($res);
  438. }
  439. //获取采购时的支付方式 ssh 20211004
  440. public function actionGetCgPayWay()
  441. {
  442. $get = Yii::$app->request->get();
  443. $id = $get['id'] ?? 0;
  444. $cg = PurchaseClass::getById($id, true);
  445. PurchaseClass::valid($cg, $this->shopId);
  446. $customId = $cg->customId ?? 0;
  447. $custom = CustomClass::getById($customId);
  448. $hasDebtPay = $custom['debt'] ?? 0;
  449. //预订单不能欠款
  450. if ($cg->book == 1) {
  451. $hasDebtPay = 0;
  452. }
  453. $current = time();
  454. $cgDeadTime = strtotime($cg->deadline);
  455. //让客户在失效前$aheadTime秒要支付,这样回调通知时订单才不会过期状态
  456. $aheadTime = dict::getDict('order_online_pay_has_ahead_time');
  457. $count = $cgDeadTime - $current - $aheadTime;
  458. $data = [];
  459. $data['balance'] = $this->shop->balance ?? 0;
  460. $data['count'] = $count;
  461. $data['hasDebtPay'] = $hasDebtPay;
  462. util::success($data);
  463. }
  464. //地区 ssh 20220606
  465. public function actionRegion()
  466. {
  467. $regionTree = RegionService::tree();
  468. util::success(['region' => $regionTree]);
  469. }
  470. //散客门店详情 ssh 20211007
  471. public function actionKjCustom()
  472. {
  473. $defaultCustomId = $this->shop->defaultCustomId ?? 0;
  474. $custom = [];
  475. if (!empty($defaultCustomId)) {
  476. $custom = HdCustomClass::getById($defaultCustomId);
  477. $avatar = $custom['avatar'] ?? '';
  478. $custom['avatar'] = imgUtil::groupImg($avatar) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  479. }
  480. util::success(['custom' => $custom]);
  481. }
  482. //散客门店设置
  483. public function actionKjCustomSet()
  484. {
  485. $id = Yii::$app->request->get('id', 0);
  486. $custom = HdCustomClass::getById($id, true);
  487. if (empty($custom)) {
  488. util::fail('没有找到客户');
  489. }
  490. if ($custom->shopId != $this->shopId) {
  491. util::fail('客户不属于当前门店');
  492. }
  493. $shop = $this->shop;
  494. $shop->defaultCustomId = $id;
  495. $shop->save();
  496. util::complete('修改成功');
  497. }
  498. public function actionUpdateShopAvatar()
  499. {
  500. $data = Yii::$app->request->post();
  501. $id = isset($data['id']) ? $data['id'] : 0;
  502. $shop = ShopClass::getById($id, true, 'id, sjId, avatar');
  503. ShopService::valid($shop, $this->sjId);
  504. if (isset($data['avatar']) && $data['avatar'] != '') {
  505. $shop->avatar = $data['avatar'];
  506. $re = $shop->save();
  507. if ($re) {
  508. \bizGhs\custom\classes\CustomClass::updateByCondition(['shopId' => $id], [
  509. 'avatar' => $data['avatar']
  510. ]);
  511. util::complete('头像修改完成');
  512. }
  513. util::fail('头像修改失败');
  514. }
  515. util::fail('头像参数出错');
  516. }
  517. //获取充值设置
  518. public function actionGetRechargeSetting()
  519. {
  520. $shopId = $this->shop->id;
  521. $shop = ShopClass::getById($shopId, false, 'rechargeWeal');
  522. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'reachVip');
  523. $return = [
  524. 'rechargeRule' => $shop['rechargeWeal'] == 3 ? 2 : $shop['rechargeWeal'],
  525. 'isVipMember' => $shopExt['reachVip'] > 0 ? 1 : 0,
  526. 'vipAmount' => $shopExt['reachVip'],
  527. 'hbPayable' => $shop['rechargeWeal'] == 2 ? 1 : 0,
  528. ];
  529. util::success($return);
  530. }
  531. //充值设置
  532. public function actionSaveRechargeSetting()
  533. {
  534. $data = Yii::$app->request->post();
  535. $rechargeWeal = intval($data['rechargeRule']);
  536. $isVipMember = intval($data['isVipMember']);
  537. if ($isVipMember == 1 && $data['vipAmount'] >= 0.01) {
  538. $reachVip = floatval($data['vipAmount']);
  539. } else {
  540. $reachVip = 0;
  541. }
  542. $hbPayable = intval($data['hbPayable']);
  543. if ($rechargeWeal == 2 && $hbPayable == 0) {
  544. $rechargeWeal = 3;
  545. }
  546. $shopAdmin = $this->shopAdmin;
  547. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  548. util::fail('超管才能操作');
  549. }
  550. $shopId = $this->shop->id;
  551. ShopClass::updateById($shopId, ['rechargeWeal' => $rechargeWeal]);
  552. ShopExtClass::updateByCondition(['shopId' => $shopId], ['reachVip' => $reachVip]);
  553. util::complete('充值设置成功');
  554. }
  555. }