ShopController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\shop\classes\MainClass;
  4. use biz\shop\classes\ShopAdminClass;
  5. use biz\shop\classes\ShopExtClass;
  6. use biz\sj\services\MerchantExtendService;
  7. use bizGhs\admin\classes\AdminClass;
  8. use bizGhs\custom\classes\CustomClass;
  9. use bizGhs\ghs\classes\GhsClass;
  10. use bizGhs\merchant\classes\ShopClass;
  11. use bizGhs\merchant\services\ShopService;
  12. use bizGhs\pictext\classes\PicTextClass;
  13. use bizHd\saas\services\RegionService;
  14. use common\components\arrayUtil;
  15. use common\components\dict;
  16. use common\components\dirUtil;
  17. use common\components\httpUtil;
  18. use common\components\imgUtil;
  19. use common\components\IntraCityExpress;
  20. use common\components\stringUtil;
  21. use common\components\util;
  22. use common\components\wxUtil;
  23. use Yii;
  24. use bizGhs\stat\classes\StatSaleClass;
  25. class ShopController extends BaseController
  26. {
  27. public $guestAccess = ['all'];
  28. //修改客户微信二维码 ssh 20240714
  29. public function actionChangeWx()
  30. {
  31. $get = Yii::$app->request->get();
  32. $url = $get['url'] ?? '';
  33. $shop = $this->shop;
  34. $shop->superWx = $url;
  35. $shop->save();
  36. util::complete('修改成功');
  37. }
  38. //我的可以进入的门店 ssh 20230424
  39. public function actionMyShop()
  40. {
  41. $staff = $this->shopAdmin;
  42. $shopList = [];
  43. if (isset($staff->super) && $staff->super == 1) {
  44. $sjId = $this->sjId ?? 0;
  45. $shopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'ptStyle' => 2], null, 'id,shopName,merchantName,sjId,mainId,ptStyle', 'id');
  46. }
  47. $adminId = $this->adminId;
  48. $staffList = ShopAdminClass::getAllByCondition(['adminId' => $adminId], null, '*', null, true);
  49. $mainIdList = [];
  50. if (!empty($staffList)) {
  51. foreach ($staffList as $staff) {
  52. $isPt = $staff->isPt ?? 0;
  53. $delStatus = $staff->delStatus ?? 0;
  54. //$super = $staff->super ?? 0;
  55. $mainId = $staff->mainId ?? 0;
  56. if ($isPt == 0 && $delStatus == 0) {
  57. $mainIdList[] = $mainId;
  58. }
  59. }
  60. }
  61. if (!empty($mainIdList)) {
  62. $addShopList = ShopClass::getAllByCondition(['mainId' => ['in', $mainIdList], 'ptStyle' => 2], null, 'id,shopName,merchantName,sjId,mainId,ptStyle', 'id');
  63. if (!empty($addShopList)) {
  64. foreach ($addShopList as $addShop) {
  65. $addShopId = $addShop['id'] ?? 0;
  66. if (!isset($shopList[$addShopId])) {
  67. $shopList[$addShopId] = $addShop;
  68. }
  69. }
  70. }
  71. }
  72. $list = array_values($shopList);
  73. util::success(['list' => $list]);
  74. }
  75. //绑定零售店 ssh 20220430
  76. public function actionBindLsShop()
  77. {
  78. $id = Yii::$app->request->get('id');
  79. $connection = Yii::$app->db;
  80. $transaction = $connection->beginTransaction();
  81. util::fail('此方法已停用,如需启用请确认有没问题');
  82. try {
  83. $shop = $this->shop ?? [];
  84. $lsShopId = $shop->lsShopId ?? 0;
  85. if (!empty($lsShopId)) {
  86. util::fail('您已经绑定过了');
  87. }
  88. ShopClass::bindLsShopByCustomId($shop, $id, $this->adminId);
  89. $transaction->commit();
  90. util::complete();
  91. } catch (\Exception $exception) {
  92. $transaction->rollBack();
  93. util::fail('绑定失败');
  94. }
  95. }
  96. //预订设置 ssh 20220324
  97. public function actionBookSet()
  98. {
  99. $get = Yii::$app->request->get();
  100. $presell = $get['presell'] ?? 0;
  101. $this->shop->presell = $presell;
  102. $this->shop->save();
  103. util::complete();
  104. }
  105. //当前门店信息
  106. public function actionInfo()
  107. {
  108. $shop = $this->shop ?? [];
  109. util::success($shop);
  110. }
  111. //获取当前门店信息 ssh 2021.3.27
  112. public function actionCurrentShop()
  113. {
  114. $main = $this->shop;
  115. util::success($main);
  116. }
  117. //门店列表 ssh 2021.1.14
  118. public function actionList()
  119. {
  120. $where = [];
  121. $where['sjId'] = $this->sjId;
  122. $where['delStatus'] = 0;
  123. $list = ShopClass::getShopList($where);
  124. util::success($list);
  125. }
  126. //更新门店 ssh 2020.2.29
  127. public function actionUpdate()
  128. {
  129. $post = Yii::$app->request->post();
  130. $post['sjId'] = $this->sjId;
  131. $id = $post['id'] ?? 0;
  132. $shop = ShopService::getById($id);
  133. if (empty($shop)) {
  134. util::fail('没有找到门店,编号657701');
  135. }
  136. $staff = $this->shopAdmin;
  137. if (!isset($staff->finance) || $staff->finance == 0) {
  138. //花掌柜的小石,源花汇的小吕和小吴,没有财务权限也要能修改门店
  139. if (!in_array($this->adminId, [4, 11961, 11976])) {
  140. util::fail('没有修改门店权限');
  141. }
  142. }
  143. if (!isset($staff->super) || $staff->super == 0) {
  144. //花掌柜的小石,源花汇的小吕和小吴,没有改库存改价格权限也要能修改门店
  145. if (!in_array($this->adminId, [4, 11961, 11976])) {
  146. util::fail('没有修改门店权限哦');
  147. }
  148. }
  149. if ($this->mainId == 59421) {
  150. if (!in_array($this->adminId, [4])) {
  151. util::fail('已停用,请联系管理员');
  152. }
  153. }
  154. $post['meetNum'] = isset($post['meetNum']) && !empty($post['meetNum']) ? $post['meetNum'] : 0;
  155. $post['meetAmount'] = isset($post['meetAmount']) && !empty($post['meetAmount']) ? $post['meetAmount'] : 0;
  156. $post['cutAmount'] = isset($post['cutAmount']) && !empty($post['cutAmount']) ? $post['cutAmount'] : 0;
  157. ShopClass::valid($shop, $this->sjId);
  158. //手机号具有唯一性,暂时不允许修改 --- 同零售端 app-hd/controllers/ShopController.php 保持一致
  159. unset($post['mobile']);
  160. $post['img'] = isset($post['img']) && is_array($post['img']) ? json_encode($post['img']) : '';
  161. \biz\shop\classes\ShopClass::updateShop($shop, $post);
  162. //同步更新同城配送微信门店
  163. // 校验有无经纬度数据,没有不更新(说明地图定位功能不可用了)
  164. if($post['lat'] != '' && $post['long'] != '') {
  165. $shopExt = \bizGhs\shop\classes\MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
  166. if ($shopExt['wxStoreId'] == '') {
  167. Yii::error(__CLASS__ . __METHOD__ .' - 未创建门店,请先创建');
  168. util::complete();
  169. }
  170. $shopName = isset($post['shopName']) ? $post['shopName'] : '';
  171. $sjName = $shop['merchantName'] ?? '';
  172. $storeName = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  173. $storeData = [
  174. 'keys' => ['wx_store_id' => $shopExt['wxStoreId']],
  175. 'content' => [
  176. 'store_name' => $storeName,
  177. 'address_info' => [
  178. 'province' => $post['province'],
  179. 'city' => $post['city'],
  180. 'area' => $post['dist'],
  181. 'street' => '',
  182. 'house' => $post['floor'] ? $post['address'] . $post['floor'] : $post['address'],
  183. 'lat' => $post['lat'],
  184. 'lng' => $post['long'],
  185. 'phone' => $post['telephone']
  186. ],
  187. //"order_pattern" => 2,
  188. //"service_trans_prefer" => "SFTC" //order_pattern = 2时必填
  189. ]
  190. ];
  191. $result = IntraCityExpress::updateStore($storeData);
  192. if ($result['errcode'] == 0) {
  193. Yii::info("同步更新同城配送微信门店成功");
  194. } else {
  195. Yii::error("同步更新同城配送微信门店失败:" . $result['errmsg']);
  196. }
  197. }
  198. util::complete();
  199. }
  200. // 更新门店头像
  201. public function actionUpdateAvatar()
  202. {
  203. $post = Yii::$app->request->post();
  204. $shopId = $post['shopId'];
  205. if ($post['shopId'] != $this->shopId or $this->mainId == 0) {
  206. util::fail('不是您的门店');
  207. }
  208. $avatar = $post['avatar'];
  209. if ($avatar == '') {
  210. util::fail('头像地址不能为空');
  211. }
  212. $shop = ShopClass::getById($shopId, true);
  213. $shop->avatar = $avatar;
  214. $shop->save();
  215. $ptStyle = $shop['ptStyle'] ?? dict::getDict('ptStyle', 'hd');
  216. $update = ['avatar' => $avatar];
  217. $where = ['mainId' => $this->mainId];
  218. if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
  219. GhsClass::updateByCondition($where, $update);
  220. } else {
  221. util::fail('门店头像更新失败,平台类型错误');
  222. }
  223. $shopImg = imgUtil::groupImg($shop->avatar);
  224. $smallShopImg = imgUtil::groupImg($shop->avatar) . "?x-oss-process=image/resize,m_fill,h_80,w_80";
  225. util::success(['shopImg' => $shopImg, 'smallShopImg' => $smallShopImg], '门店头像更新成功');
  226. }
  227. //添加门店 ssh 2021.1.14
  228. public function actionAdd()
  229. {
  230. $shop = $this->shop;
  231. $default = $shop->default ?? 0;
  232. if ($default == 0) {
  233. util::fail('当前直营分店,请切回总店添加');
  234. }
  235. $adminId = $this->adminId;
  236. $ptSuperAdminId = \biz\admin\classes\AdminClass::getPtSuperAdminId();
  237. if ($adminId != $shop->adminId && $adminId != $ptSuperAdminId) {
  238. util::fail('本店超管才能添加门店');
  239. }
  240. $mainId = $this->mainId;
  241. if (getenv('YII_ENV') == 'production') {
  242. if ($mainId == 42490) {
  243. util::fail('无法建分店,请联系石头');
  244. }
  245. } else {
  246. if ($mainId == 644) {
  247. util::fail('无法建分店,请联系石头');
  248. }
  249. }
  250. $data = Yii::$app->request->post();
  251. $data['sjId'] = $this->sjId;
  252. $data['shopId'] = $this->shopId;
  253. $data['adminId'] = $this->adminId;
  254. if (isset($data['shopName']) == false || empty($data['shopName'])) {
  255. util::fail('请填写门店名称');
  256. }
  257. $sj = $this->sj;
  258. $sjName = $sj->name ?? '';
  259. $ptStyle = $sj->style ?? dict::getDict('ptStyle', 'hd');
  260. $data['ptStyle'] = $ptStyle;
  261. $data['merchantName'] = $sjName;
  262. $data['default'] = 0;
  263. $connection = Yii::$app->db;
  264. $transaction = $connection->beginTransaction();
  265. try {
  266. $mobile = $data['mobile'] ?? 0;
  267. if (stringUtil::isMobile($mobile) == false) {
  268. util::fail('请填写正确手机号');
  269. }
  270. $adminInfo = ['name' => $mobile, 'mobile' => $mobile];
  271. $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
  272. $admin = AdminClass::replaceAdmin($adminInfo, $fromApp);
  273. $adminId = $admin['id'] ?? 0;
  274. $data['adminId'] = $adminId;
  275. ShopClass::addMainShop($data, $this->shop, $this->sj);
  276. $transaction->commit();
  277. util::complete();
  278. } catch (\Exception $exception) {
  279. $transaction->rollBack();
  280. util::fail();
  281. }
  282. }
  283. //PC下载微信和支付宝收款码 ssh 2020.2.29
  284. public function actionGatheringCode()
  285. {
  286. $id = Yii::$app->request->get('id', 0);
  287. $shop = ShopService::getById($id);
  288. ShopClass::valid($shop, $this->sjId);
  289. $gatheringCode = ShopClass::generateGatheringCode($this->sjId, $id);
  290. $file = dirUtil::getImgDir() . $gatheringCode;
  291. if (file_exists($file) == false) {
  292. util::fail('没有找到收款码');
  293. }
  294. if (httpUtil::isMiniProgram()) {
  295. $imgUrl = imgUtil::getPrefix() . $gatheringCode;
  296. util::success(['imgUrl' => $imgUrl]);
  297. }
  298. $fileName = "门店({$id})收款码.jpg";
  299. $contentType = 'image/jpeg';
  300. header("Cache-control: private");
  301. header("Content-type: $contentType"); //设置要下载的文件类型
  302. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  303. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  304. readfile($file);
  305. }
  306. //PC获取小程序的收款码 ssh
  307. public function actionGatheringMiniCode()
  308. {
  309. $id = Yii::$app->request->get('id', 0);
  310. $extend = MerchantExtendService::getBySjId($this->sjId);
  311. if ($extend['miniAuth'] == 0) {
  312. util::fail('您的小程序还没有授权');
  313. }
  314. $shop = ShopService::getById($id);
  315. ShopClass::valid($shop, $this->sjId);
  316. $applyMemberCode = wxUtil::generateGatheringMiniCode($this->sj->attributes, $id);
  317. $file = dirUtil::getImgDir() . $applyMemberCode;
  318. if (file_exists($file) == false) {
  319. util::fail('没有找到注册会员码');
  320. }
  321. if (httpUtil::isMiniProgram()) {
  322. $imgUrl = imgUtil::getPrefix() . $applyMemberCode;
  323. util::success(['imgUrl' => $imgUrl]);
  324. }
  325. $fileName = "门店({$id})小程序收款码.jpg";
  326. $contentType = 'image/jpeg';
  327. header("Cache-control: private");
  328. header("Content-type: $contentType"); //设置要下载的文件类型
  329. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  330. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  331. readfile($file);
  332. }
  333. //PC下载会员注册码 ssh 2020.2.29
  334. public function actionApplyMemberCode()
  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. ShopClass::valid($shop, $this->sjId);
  343. $applyMemberCode = wxUtil::generateMemberCode($this->sj->attributes, $id);
  344. $file = dirUtil::getImgDir() . $applyMemberCode;
  345. if (file_exists($file) == false) {
  346. util::fail('没有找到注册会员码');
  347. }
  348. if (httpUtil::isMiniProgram()) {
  349. $imgUrl = imgUtil::getPrefix() . $applyMemberCode;
  350. util::success(['imgUrl' => $imgUrl]);
  351. }
  352. $fileName = "注册会员码{$id}.jpg";
  353. $contentType = 'image/jpeg';
  354. header("Cache-control: private");
  355. header("Content-type: $contentType"); //设置要下载的文件类型
  356. header("Content-Length:" . filesize($file)); //设置要下载文件的文件大小
  357. header("Content-Disposition: attachment; filename=" . urldecode($fileName)); //设置要下载文件的文件名
  358. readfile($file);
  359. }
  360. //删除门店 ssh 2020.3.1
  361. public function actionDelete()
  362. {
  363. util::fail('禁止操作');
  364. $id = Yii::$app->request->get('id', 0);
  365. $shop = ShopService::getById($id);
  366. ShopClass::valid($shop, $this->sjId);
  367. ShopClass::deleteShop($shop);
  368. util::complete();
  369. }
  370. //获取所有门店lqh 2021.1.31
  371. public function actionAll()
  372. {
  373. $res = ShopClass::getAllShop($this->sjId);
  374. util::success($res);
  375. }
  376. //切换门店 lqh 2021.1.31
  377. public function actionToggleShop()
  378. {
  379. $mainId = $this->mainId;
  380. $adminId = $this->adminId;
  381. //多处要同步修改,关键词 no_allow_toggle_shop
  382. if (getenv('YII_ENV') == 'production') {
  383. //安海恋善不允许切换门店
  384. if (in_array($mainId, [44759, 56314, 56315, 56452])) {
  385. if (in_array($adminId, [54630, 54723])) {
  386. util::fail('专用账号,不允许切换门店');
  387. }
  388. }
  389. //惠雅南城不允许切换门店
  390. if ($mainId == 52 && $adminId == 3539) {
  391. util::fail('收银专用账号,不允许切换门店');
  392. }
  393. //惠雅莞城不允许切换门店
  394. if ($mainId == 1459 && $adminId == 2812) {
  395. util::fail('收银专用账号,不允许切换门店');
  396. }
  397. }
  398. $shopAdmin = $this->shopAdmin;
  399. $switchShop = ShopAdminClass::hasSwitchShopRight($shopAdmin);
  400. if ($switchShop == 0) {
  401. util::fail('不能切换门店');
  402. }
  403. $newShopId = Yii::$app->request->post('shopId', 0);
  404. $newShop = ShopClass::getById($newShopId, true);
  405. if (empty($newShop)) {
  406. util::fail('没有找到门店66');
  407. }
  408. $res = AdminClass::toggleShop($this->admin, $newShop, $this->sjId, $this->shopAdmin);
  409. util::success($res);
  410. }
  411. //提现信息更新 ssh 2021.3.23
  412. public function actionCashUpdate()
  413. {
  414. $get = Yii::$app->request->get();
  415. $cashAccount = $get['cashAccount'] ?? '';
  416. $cashName = $get['cashName'] ?? '';
  417. $cashBank = $get['cashBank'] ?? '';
  418. if (empty($cashName)) {
  419. util::fail('请填写姓名');
  420. }
  421. if (empty($cashAccount)) {
  422. util::fail('请填写银行卡号');
  423. }
  424. if (empty($cashBank)) {
  425. util::fail('请输入开户行');
  426. }
  427. $shopAdmin = $this->shopAdmin;
  428. $mainId = $shopAdmin->mainId ?? 0;
  429. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  430. util::fail('超管才能操作');
  431. }
  432. MainClass::updateById($mainId, ['cashAccount' => $cashAccount, 'cashName' => $cashName, 'cashBank' => $cashBank]);
  433. $shop = $this->shop;
  434. $sjName = $shop->merchantName ?? '';
  435. $shopName = $shop->shopName ?? '';
  436. //noticeUtil::push("{$sjName}-{$shopName} 修改提现账号,{$cashName} {$cashAccount} {$cashBank}", '15280215347');
  437. util::complete();
  438. }
  439. //获取门店详情 ssh 2021.4.23
  440. public function actionDetail()
  441. {
  442. $shopId = Yii::$app->request->get('shopId');
  443. if (empty($shopId)) {
  444. $shopId = $this->shopId;
  445. }
  446. $shop = ShopClass::getById($shopId, true);
  447. if ($shop->mainId != $this->mainId) {
  448. //这个注释不能打开,因为首店可能修改其它分店信息
  449. //util::fail('无法查看');
  450. }
  451. $shop = $shop->toArray();
  452. $shop['hasMap'] = dict::getDict('hasMap'); //添加 hasMap 属性(字典中的 hasMap)
  453. util::success(['info' => $shop]);
  454. }
  455. //获取平台所有的供货商门店 ssh 20210908
  456. public function actionGetPtGhsShop()
  457. {
  458. $hasSale = Yii::$app->request->get('hasSale', 0);
  459. $name = Yii::$app->request->get('name', '');
  460. $arr = ['ptStyle' => 2, 'live' => 1];
  461. if (!empty($name)) {
  462. $arr['merchantName'] = ['like', $name];
  463. $hasSale = 0;
  464. }
  465. $shopList = ShopClass::getAllByCondition($arr, 'id asc', '*');
  466. $totalSale = 0;
  467. $totalShopNum = 0;
  468. $totalBalance = 0;
  469. if (!empty($shopList)) {
  470. foreach ($shopList as $key => $shop) {
  471. $mainId = $shop['mainId'] ?? 0;
  472. $main = MainClass::getById($mainId, true);
  473. $balance = $main->balance ?? 0;
  474. if (!empty($name) || $hasSale == 0) {
  475. $incomeList = [];
  476. } else {
  477. $respond = StatSaleClass::profile($mainId);
  478. $incomeList = $respond['income'] ?? [];
  479. }
  480. $todaySale = 0;
  481. if (!empty($incomeList)) {
  482. foreach ($incomeList as $item) {
  483. //调拨出库暂时不算到收入里去
  484. if (isset($item['id']) && $item['id'] == 'allot') {
  485. continue;
  486. }
  487. $todaySale = bcadd($todaySale, $item['amount'], 2);
  488. }
  489. }
  490. $shopList[$key]['balance'] = $balance;
  491. $shopList[$key]['todaySale'] = $todaySale;
  492. $count = CustomClass::getCount(['ownMainId' => $mainId]);
  493. $count = $count > 0 ? $count : 0;
  494. $shopList[$key]['shopNum'] = $count;
  495. if ($hasSale == 1 && $todaySale <= 0) {
  496. unset($shopList[$key]);
  497. }
  498. $totalSale = bcadd($totalSale, $todaySale, 2);
  499. $totalSale = floatval($totalSale);
  500. $totalBalance = bcadd($totalBalance, $balance, 2);
  501. $totalBalance = floatval($totalBalance);
  502. $totalShopNum = bcadd($totalShopNum, $count);
  503. }
  504. $shopList = arrayUtil::arraySort($shopList, 'todaySale');
  505. }
  506. util::success(['list' => $shopList, 'totalSale' => $totalSale, 'totalBalance' => $totalBalance, 'totalShopNum' => $totalShopNum]);
  507. }
  508. //切换门店 ssh 20220624
  509. public function actionSwitchGhsShop()
  510. {
  511. $shopId = Yii::$app->request->get('shopId', 0);
  512. $shop = ShopClass::getById($shopId, true);
  513. if (empty($shop)) {
  514. util::fail('没有找到门店67');
  515. }
  516. $shopAdmin = $this->shopAdmin;
  517. $admin = $this->admin;
  518. $adminId = $this->adminId ?? 0;
  519. if (getenv('YII_ENV') == 'production') {
  520. if (in_array($adminId, [4]) == false) {
  521. util::fail('开发中');
  522. }
  523. } else {
  524. if (in_array($adminId, [919]) == false) {
  525. util::fail('开发中');
  526. }
  527. }
  528. ShopAdminClass::changeShopAddRelate($shopAdmin, $shop, 1);
  529. $admin->currentGhsShopId = $shopId;
  530. $lsShopId = $shop->lsShopId ?? 0;
  531. $admin->currentShopId = $lsShopId;
  532. $admin->save();
  533. util::complete();
  534. }
  535. //散客门店详情 ssh 20211007
  536. public function actionSkCustom()
  537. {
  538. $skCustomId = $this->shop->skCustomId ?? 0;
  539. $custom = [];
  540. if (!empty($skCustomId)) {
  541. $custom = CustomClass::getById($skCustomId);
  542. $avatar = $custom['avatar'] ?? '';
  543. $custom['avatar'] = imgUtil::groupImg($avatar) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  544. }
  545. util::success(['custom' => $custom]);
  546. }
  547. //散客门店设置
  548. public function actionSkCustomSet()
  549. {
  550. $id = Yii::$app->request->get('id', 0);
  551. $custom = CustomClass::getById($id, true);
  552. CustomClass::valid($custom, $this->shopId);
  553. $this->shop->skCustomId = $id;
  554. $this->shop->save();
  555. util::complete('修改成功');
  556. }
  557. //运费模式和运费成本设置 ssh 20211014
  558. public function actionUpdateCgModel()
  559. {
  560. $get = Yii::$app->request->get();
  561. $cgModel = $get['cgModel'] ?? 0;
  562. $cgPerCost = $get['cgPerCost'] ?? 0;
  563. if ($cgModel == 1) {
  564. if (is_numeric($cgPerCost) == false || $cgPerCost < 0) {
  565. util::fail('请输入运费成本');
  566. }
  567. $this->shop->cgPerCost = $cgPerCost;
  568. }
  569. $this->shop->cgModel = $cgModel;
  570. $this->shop->save();
  571. util::complete('修改成功');
  572. }
  573. //地区 ssh 20220606
  574. public function actionRegion()
  575. {
  576. $regionTree = RegionService::tree();
  577. util::success(['region' => $regionTree]);
  578. }
  579. //获取购买须知信息
  580. public function actionPurchaseGuide()
  581. {
  582. $shopId = intval($this->shopId);
  583. if ($shopId <= 0) {
  584. util::fail('门店数据错误');
  585. }
  586. $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], false, false, 'id, shopId, purchaseGuide');
  587. if ($shopExt['purchaseGuide'] > 0) {
  588. $picText = PicTextClass::getById($shopExt['purchaseGuide'], false, 'id, title');
  589. }
  590. if ($shopExt) {
  591. $shopExt['title'] = isset($picText['title']) ? $picText['title'] : '';
  592. util::success(['shopExt' => $shopExt]);
  593. }
  594. util::fail('获取数据失败');
  595. }
  596. }