CustomController.php 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\admin\classes\AdminRoleClass;
  4. use biz\ghs\classes\GhsClass;
  5. use biz\shop\classes\ShopAdminClass;
  6. use biz\sj\classes\SjClass;
  7. use biz\wx\classes\WxMessageClass;
  8. use bizGhs\custom\classes\CustomClass;
  9. use bizGhs\custom\services\CustomService;
  10. use common\components\qrCodeUtil;
  11. use bizGhs\order\classes\OrderClass;
  12. use bizHd\saas\classes\ApplyClass;
  13. use bizHd\saas\services\ApplyService;
  14. use bizHd\shop\classes\ShopClass;
  15. //use bizHd\stat\classes\StatVisitClass;
  16. use bizGhs\stat\classes\StatVisitClass;
  17. use common\components\dict;
  18. use common\components\imgUtil;
  19. use common\components\orderSn;
  20. use common\components\stringUtil;
  21. use common\components\util;
  22. use Yii;
  23. class CustomController extends BaseController
  24. {
  25. //批量设置是否可看库存 ssh 20251031
  26. public function actionAllSetLookStock()
  27. {
  28. $get = Yii::$app->request->get();
  29. $showStock = $get['showStock'] ?? 0;
  30. $mainId = $this->mainId;
  31. CustomClass::updateByCondition(['ownMainId' => $mainId], ['showStock' => $showStock]);
  32. \bizGhs\ghs\classes\GhsClass::updateByCondition(['mainId' => $mainId], ['showStock' => $showStock]);
  33. util::complete('设置成功');
  34. }
  35. //批量设置是否可看销量 ssh 20251031
  36. public function actionAllSetLookSale()
  37. {
  38. $get = Yii::$app->request->get();
  39. $showSold = $get['showSold'] ?? 0;
  40. $shop = $this->shop;
  41. //没有配置到每个客户,只在总店有控制
  42. $shop->showSold = $showSold;
  43. $shop->save();
  44. util::complete('设置成功');
  45. }
  46. //批量授信 ssh 20251031
  47. public function actionAllCredit()
  48. {
  49. $staff = $this->shopAdmin;
  50. if ($staff->mobile != 15280215347) {
  51. util::fail('请管理员操作');
  52. }
  53. $get = Yii::$app->request->get();
  54. $amount = $get['amount'] ?? 0;
  55. $mainId = $this->mainId;
  56. CustomClass::updateByCondition(['ownMainId' => $mainId], ['debtLimit' => $amount]);
  57. util::complete('设置成功');
  58. }
  59. //客户设置相关 ssh 20250310
  60. public function actionSetChange()
  61. {
  62. $staff = $this->shopAdmin;
  63. if ($staff->founder != 2 && $staff->mobile != 15280215347) {
  64. util::fail('老板才能修改');
  65. }
  66. $post['homeAmount'] = !empty($post['homeAmount']) && is_numeric($post['homeAmount']) ? $post['homeAmount'] : 0;
  67. $post = Yii::$app->request->post();
  68. $shopId = $this->shopId;
  69. ShopClass::updateById($shopId, $post);
  70. $showStock = $post['showStock'] ?? 0;
  71. $arr = ['showStock' => $showStock];
  72. //如果新客需要审核,老的全部要打开为已经审核通过了
  73. $arr['passStatus'] = 1;
  74. CustomClass::updateByCondition(['ownShopId' => $shopId], $arr);
  75. GhsClass::updateByCondition(['shopId' => $shopId], $arr);
  76. util::complete('修改成功');
  77. }
  78. //获取收款码 ssh 20240530
  79. public function actionGetGatheringCode()
  80. {
  81. $get = Yii::$app->request->get();
  82. $id = $get['id'] ?? 0;
  83. $custom = CustomClass::getById($id, true);
  84. if (empty($custom)) {
  85. util::fail('没有找到客户');
  86. }
  87. if ($custom->ownMainId != $this->mainId) {
  88. util::fail('不是你的客户哈');
  89. }
  90. $ghsId = $custom->ghsId ?? 0;
  91. $salt = $custom->salt ?? '';
  92. //有多个地方要同步修改,关键词 custom_go_ghs_gathering_code
  93. if (getenv('YII_ENV') == 'production') {
  94. $url = "https://mall.huahb.cn/#/admin/ghs/pay?id={$ghsId}&salt={$salt}";
  95. } else {
  96. $url = "https://mall.huaml.com/#/admin/ghs/pay?id={$ghsId}&salt={$salt}";
  97. }
  98. $unique = "recharge_to_ghs_" . $id;
  99. $imgUrl = qrCodeUtil::generateRechargeQrCode($url, $unique);
  100. $imageUrl = imgUtil::groupImg($imgUrl);
  101. util::success(['imgUrl' => $imageUrl]);
  102. }
  103. //供货商给客户充值和结账 ssh 20240309
  104. public function actionRecharge()
  105. {
  106. ini_set('memory_limit', '2045M');
  107. set_time_limit(0);
  108. //避免重复提交
  109. $staffId = $this->shopAdminId;
  110. util::checkRepeatCommit($staffId, 5);
  111. $staff = $this->shopAdmin;
  112. if (isset($staff->finance) == false || $staff->finance == 0) {
  113. //淘花里中山店,没有财务权限要能销账
  114. if (in_array($this->shopId, [17118])) {
  115. if (!in_array($this->adminId, [17908])) {
  116. util::fail('你不能充值销账哦');
  117. }
  118. } else {
  119. util::fail('无法充值销单。。。');
  120. }
  121. }
  122. //多个地方需要同步修改clear_order_power
  123. if (getenv('YII_ENV') == 'production') {
  124. //小向花卉
  125. if (in_array($this->shopId, [23580, 24713])) {
  126. if (!in_array($this->adminId, [24043, 23960, 4])) {
  127. util::fail('不能销单哦!!');
  128. }
  129. }
  130. //花样年华只有总控才能结账
  131. if (in_array($this->shopId, [1585, 1596])) {
  132. if ($this->adminId != 2876) {
  133. util::fail('不能充值销单哦');
  134. }
  135. }
  136. //花大苪 洋桔梗,只有叶荷姐才能销账
  137. if (in_array($this->shopId, [16070])) {
  138. if (!in_array($this->adminId, [9303, 4])) {
  139. util::fail('不能充值销单哈');
  140. }
  141. }
  142. //恋善好多花控制销账权限
  143. if (in_array($this->shopId, [55238, 56609, 56611])) {
  144. if (!in_array($this->adminId, [43856, 54620])) {
  145. util::fail('暂无权限销单,请联系老板或财务');
  146. }
  147. }
  148. //天天鲜花 陈江店
  149. if (in_array($this->shopId, [763, 1405, 795])) {
  150. if (!in_array($this->adminId, [2094, 5959])) {
  151. util::fail('不能操作充值销单!');
  152. }
  153. }
  154. //花儿好仙
  155. if (in_array($this->shopId, [22666])) {
  156. if (!in_array($this->adminId, [12869, 23174])) {
  157. util::fail('不能充值销单哈');
  158. }
  159. }
  160. //小丽鲜花
  161. if (in_array($this->shopId, [11094])) {
  162. if (!in_array($this->adminId, [12073, 12296])) {
  163. util::fail('您不能充值销单哦');
  164. }
  165. }
  166. //源花汇
  167. if (in_array($this->shopId, [10649])) {
  168. if (!in_array($this->adminId, [11641, 11648, 4])) {
  169. util::fail('请闵总或小周操作');
  170. }
  171. }
  172. //昱成
  173. if (in_array($this->shopId, [8596])) {
  174. if (!in_array($this->adminId, [9303, 9601])) {
  175. util::fail('只能叶荷操作');
  176. }
  177. }
  178. //花大苪,多处请搜索关键词 hdb_clear_control
  179. if (in_array($this->shopId, [8249])) {
  180. if (!in_array($this->adminId, [9303])) {
  181. util::fail('只能叶荷和财务操作');
  182. }
  183. }
  184. //中山淘花里,销账权限控制,多处请搜索 thl_clear_control
  185. if (in_array($this->shopId, [17118])) {
  186. if (!in_array($this->adminId, [55494, 55445, 17908, 55459, 55707, 55709])) {
  187. util::fail('你不能销单哈。。');
  188. }
  189. }
  190. //淘花里小榄店 thl_xl_clear
  191. if (in_array($this->shopId, [72366])) {
  192. if (!in_array($this->adminId, [69792, 55445, 55707, 69792])) {
  193. util::fail('你不能销单那。。');
  194. }
  195. }
  196. //小齐鲜花总店和出车,多处请搜索关键词 xq_clear_control
  197. if (in_array($this->shopId, [41467, 42946])) {
  198. if (!in_array($this->adminId, [40144, 42912, 42023])) {
  199. util::fail('您不能充值销单哦。');
  200. }
  201. }
  202. } else {
  203. if (in_array($this->shopId, [36523])) {
  204. if ($this->adminId != 919) {
  205. util::fail('暂不能操作充值销单哈');
  206. }
  207. }
  208. }
  209. $get = Yii::$app->request->get();
  210. $amount = $get['amount'] ?? 0;
  211. $customId = $get['customId'] ?? 0;
  212. $payWay = $get['payWay'] ?? -1;
  213. $remark = $get['remark'] ?? '';
  214. $rechargeType = $get['rechargeType'] ?? 0;
  215. if ($rechargeType == 0 && $payWay < 0) {
  216. util::fail('请选择付款方式');
  217. }
  218. if ($amount <= 0) {
  219. //util::fail('充值金额需要大于0');
  220. }
  221. //解决重复充值问题
  222. $cacheKey = 'help_custom_recharge_' . $customId;
  223. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  224. if (!empty($has)) {
  225. util::fail('已充值,请15秒后再操作');
  226. return false;
  227. }
  228. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 15, 'has']);
  229. $custom = CustomClass::getLockById($customId);
  230. if (empty($custom)) {
  231. util::fail('没有找到客户');
  232. }
  233. if ($custom->ownMainId != $this->mainId) {
  234. util::fail('不是你的客户,无法充值');
  235. }
  236. $customShopId = $custom->shopId ?? 0;
  237. $shop = $this->shop;
  238. if ($customShopId == $shop->lsShopId) {
  239. util::fail('不能给自己充值');
  240. }
  241. $connection = Yii::$app->db;
  242. $transaction = $connection->beginTransaction();
  243. try {
  244. $staff = $this->shopAdmin;
  245. $params = ['remark' => $remark, 'rechargeType' => $rechargeType];
  246. $recharge = CustomService::rechargeClear($custom, $amount, $this->shop, $staff, $payWay, $params);
  247. $transaction->commit();
  248. WxMessageClass::customRechargeClearInform($shop, $recharge);
  249. util::complete('充值成功');
  250. } catch (\Exception $e) {
  251. Yii::info("充值失败原因:" . $e->getMessage());
  252. $transaction->rollBack();
  253. util::fail('充值失败');
  254. }
  255. }
  256. //生成货位号 ssh 20231215
  257. public function actionCreateSeatSn()
  258. {
  259. $get = Yii::$app->request->get();
  260. $id = $get['id'] ?? 0;
  261. $custom = CustomClass::getById($id, true);
  262. if ($custom->ownMainId != $this->mainId) {
  263. util::fail('不是您的客户');
  264. }
  265. $seatSn = $custom->seatSn ?? '';
  266. if (!empty($seatSn)) {
  267. util::fail('已经有货位号了');
  268. }
  269. $new = CustomClass::createSeatSn($this->mainId);
  270. $custom->seatSn = $new;
  271. $custom->save();
  272. //预订相关表的货位同步
  273. $shop = $this->shop;
  274. CustomClass::syncBookSeat($shop, $custom, $new);
  275. util::complete('已生成');
  276. }
  277. //修改货位号 ssh 20231215
  278. public function actionModifySeatSn()
  279. {
  280. $get = Yii::$app->request->get();
  281. $id = $get['id'] ?? 0;
  282. $new = $get['seatSn'] ?? 0;
  283. $custom = CustomClass::getById($id, true);
  284. if ($custom->ownMainId != $this->mainId) {
  285. util::fail('不是您的客户');
  286. }
  287. if (is_numeric($new) == false) {
  288. util::fail('请填写数字');
  289. }
  290. $custom->seatSn = $new;
  291. $custom->save();
  292. //预订相关表的货位同步
  293. $shop = $this->shop;
  294. CustomClass::syncBookSeat($shop, $custom, $new);
  295. util::complete('修改成功');
  296. }
  297. //修改客户地址 ssh 20230929
  298. public function actionModifyAddress()
  299. {
  300. $post = Yii::$app->request->post();
  301. $id = $post['id'] ?? 0;
  302. unset($post['id']);
  303. $custom = CustomClass::getById($id, true);
  304. if ($custom->ownMainId != $this->mainId) {
  305. util::fail('不是您的客户哦');
  306. }
  307. $city = $post['city'] ?? '';
  308. $dist = $post['dist'] ?? '';
  309. $address = $post['address'] ?? '';
  310. $floor = $post['floor'] ?? '';
  311. $post['fullAddress'] = $city . $dist . $address . $floor;
  312. $shopId = $custom->shopId ?? 0;
  313. ShopClass::updateById($shopId, $post);
  314. CustomClass::updateByCondition(['shopId' => $shopId], $post);
  315. util::complete('修改成功');
  316. }
  317. //修改花店散客身份 ssh 20230216
  318. public function actionChangeIsHd()
  319. {
  320. $get = Yii::$app->request->get();
  321. $id = $get['customId'] ?? 0;
  322. $isHd = $get['isHd'] ?? 1;
  323. $custom = CustomClass::getById($id, true);
  324. if (empty($custom)) {
  325. util::fail('没有找到客户');
  326. }
  327. if ($custom->ownMainId != $this->mainId) {
  328. util::fail('没有权限');
  329. }
  330. $ghsId = $custom->ghsId ?? 0;
  331. $ghs = GhsClass::getById($ghsId, true);
  332. if (empty($ghs)) {
  333. util::fail('修改失败了');
  334. }
  335. $ghs->isHd = $isHd;
  336. $ghs->save();
  337. $custom->isHd = $isHd;
  338. $custom->save();
  339. util::complete('修改成功');
  340. }
  341. //修改物流名称 ssh 20230112
  342. public function actionChangeWlName()
  343. {
  344. $get = Yii::$app->request->get();
  345. $id = $get['id'] ?? 0;
  346. $wlName = $get['wlName'] ?? 0;
  347. $custom = CustomClass::getById($id, true);
  348. if (empty($custom) || $custom->ownMainId != $this->mainId) {
  349. util::fail('修改失败');
  350. }
  351. $ghsId = $custom->ghsId ?? 0;
  352. $ghs = GhsClass::getById($ghsId, true);
  353. if (empty($ghs)) {
  354. util::fail('修改失败');
  355. }
  356. $ghs->customWlName = $wlName;
  357. $ghs->save();
  358. $custom->wlName = $wlName;
  359. $custom->save();
  360. util::complete('已修改');
  361. }
  362. //修改短名 ssh 2025312
  363. public function actionModifyShortName()
  364. {
  365. $get = Yii::$app->request->get();
  366. $id = $get['id'] ?? 0;
  367. $shortName = $get['shortName'] ?? 0;
  368. $custom = CustomClass::getById($id, true);
  369. if (empty($custom) || $custom->ownMainId != $this->mainId) {
  370. util::fail('修改失败');
  371. }
  372. $custom->shortName = $shortName;
  373. $custom->save();
  374. util::complete('修改成功');
  375. }
  376. //修改物流信息 ssh 20230105
  377. public function actionChangeWl()
  378. {
  379. util::fail('修改失败');
  380. }
  381. //修改名称 ssh 2022096
  382. public function actionChangeName()
  383. {
  384. $get = Yii::$app->request->get();
  385. $name = $get['name'] ?? '';
  386. $id = $get['id'] ?? 0;
  387. if (empty($name)) {
  388. util::fail('请填写名称');
  389. }
  390. $py = stringUtil::py($name);
  391. $custom = CustomClass::getById($id, true);
  392. CustomClass::valid($custom, $this->shopId);
  393. $custom->name = $name;
  394. $custom->py = $py;
  395. $custom->save();
  396. OrderClass::updateByCondition(['customId' => $id], ['customName' => $name, 'customNamePy' => $py]);
  397. $customShopId = $custom->shopId ?? 0;
  398. //在首店修改客户名称,直营店自动同步
  399. $masterShop = $this->shop;
  400. if (isset($masterShop->default) && $masterShop->default == 1) {
  401. $sjId = $masterShop->sjId ?? 0;
  402. $shopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
  403. foreach ($shopList as $shop) {
  404. $shopId = $shop->id ?? 0;
  405. if (isset($shop->join) && $shop->join == 1) {
  406. //加盟店不同步修改
  407. continue;
  408. }
  409. if ($shopId == $masterShop->id) {
  410. //前面已经同步修改过了
  411. continue;
  412. }
  413. $custom = CustomClass::getByCondition(['ownShopId' => $shopId, 'shopId' => $customShopId], true);
  414. if (empty($custom)) {
  415. continue;
  416. }
  417. $custom->name = $name;
  418. $custom->py = $py;
  419. $custom->save();
  420. }
  421. }
  422. util::complete('修改成功');
  423. }
  424. //帮客户添加员工 ssh 20220613
  425. public function actionAddStaff()
  426. {
  427. $post = Yii::$app->request->post();
  428. $customId = $post['id'] ?? 0;
  429. $mobile = $post['mobile'] ?? 0;
  430. if (stringUtil::isMobile($mobile) == false) {
  431. util::fail('手机号填写错误');
  432. }
  433. $info = CustomService::getById($customId, true);
  434. CustomClass::valid($info, $this->shopId);
  435. $connection = Yii::$app->db;
  436. $transaction = $connection->beginTransaction();
  437. try {
  438. $shopId = $info->shopId ?? 0;
  439. $customShop = ShopClass::getById($shopId, true);
  440. if (empty($customShop)) {
  441. util::fail('没有找到客户的门店');
  442. }
  443. $mainId = $customShop->mainId ?? 0;
  444. $ptStyle = dict::getDict('ptStyle', 'hd');
  445. $adminInfo = ['name' => $mobile, 'mobile' => $mobile, 'style' => $ptStyle, 'currentShopId' => $shopId];
  446. $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
  447. $admin = \bizGhs\admin\classes\AdminClass::replaceAdmin($adminInfo, $fromApp);
  448. $roleList = AdminRoleClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
  449. if (empty($roleList)) {
  450. util::fail('客户门店没有员工角色');
  451. }
  452. $currentRoleId = 0;
  453. foreach ($roleList as $role) {
  454. $roleId = $role->id ?? 0;
  455. $currentRoleId = $roleId;
  456. if ($role->roleName == '员工') {
  457. break;
  458. }
  459. }
  460. $params = [
  461. 'shopId' => $shopId,
  462. 'mobile' => $mobile,
  463. 'roleId' => $currentRoleId,
  464. ];
  465. \bizHd\staff\classes\StaffClass::appGenerateStaff($params, $admin);
  466. $transaction->commit();
  467. util::complete('添加成功');
  468. } catch (\Exception $e) {
  469. $transaction->rollBack();
  470. util::fail('添加失败');
  471. }
  472. }
  473. //添加新花店 ssh 2021.1.8
  474. public function actionAdd()
  475. {
  476. $post = Yii::$app->request->post();
  477. $post['style'] = SjClass::STYLE_RETAIL;
  478. $post['introSjId'] = $this->sjId;
  479. $post['introStyle'] = SjClass::STYLE_SUPPLIER;
  480. $mobile = $post['mobile'] ?? '';
  481. $confirmMobile = $post['confirmMobile'];
  482. $address = $post['address'] ?? '';
  483. util::fail('功能已停用');
  484. if (stringUtil::isMobile($mobile) == false) {
  485. util::fail(' 请填写正确的手机号');
  486. }
  487. if ($mobile != $confirmMobile) {
  488. util::fail('二次号码填写不一致');
  489. }
  490. $name = $post['name'] ?? '';
  491. if (empty($name)) {
  492. util::fail('名称不能为空');
  493. }
  494. if (stringUtil::getWordNum($name) > 15) {
  495. util::fail('名称不能超过15个汉字');
  496. }
  497. $has = SjClass::getByCondition(['name' => $name, 'style' => SjClass::STYLE_RETAIL]);
  498. if (!empty($has)) {
  499. util::fail('名称已经存在');
  500. }
  501. $has = ApplyClass::getByCondition(['mobile' => $mobile, 'style' => SjClass::STYLE_RETAIL]);
  502. if (!empty($has)) {
  503. util::fail('手机号已经添加过');
  504. }
  505. if (empty($address)) {
  506. util::fail('请填写地址');
  507. }
  508. $connection = Yii::$app->db;
  509. $transaction = $connection->beginTransaction();
  510. try {
  511. $shop = $this->shop;
  512. $sjId = $this->sjId;
  513. $shopId = $this->shopId;
  514. $sjName = $this->sj->name ?? '';
  515. $city = $shop->city ?? '';
  516. $dist = $shop->dist ?? '';
  517. $applyData = [
  518. 'name' => $name,
  519. 'licenseNo' => $mobile,
  520. 'certType' => ApplyClass::CERT_TYPE_MOBILE,
  521. 'mobile' => $mobile,
  522. 'introSjId' => $sjId,
  523. 'introSjName' => $sjName,
  524. 'introShopId' => $shopId,
  525. 'introStyle' => SjClass::STYLE_SUPPLIER,
  526. 'from' => ApplyClass::FROM_GHS,
  527. 'style' => SjClass::STYLE_RETAIL,
  528. 'province' => $shop->province ?? '',
  529. 'city' => $city,
  530. 'dist' => $dist,
  531. 'address' => $address,
  532. 'status' => ApplyClass::STATUS_PASS,
  533. 'replace' => 1,//1表示供货商添加的客户
  534. ];
  535. $apply = ApplyService::replaceRetail($applyData);
  536. $id = $apply['id'] ?? 0;
  537. $respond = ApplyService::pass($id);
  538. $shop = $respond['shop'] ?? [];
  539. $sj = $respond['sj'] ?? [];
  540. $hdSjId = $sj['id'] ?? 0;
  541. $hdShopId = $shop->id ?? 0;
  542. ApplyClass::updateById($id, ['sjId' => $hdSjId, 'shopId' => $hdShopId]);
  543. if (empty($hdShopId)) {
  544. util::fail('客户没有添加成功!');
  545. }
  546. $custom = CustomClass::build($this->shopId, $hdShopId);
  547. $custom['avatar'] = imgUtil::groupImg($custom['avatar']);
  548. //客户欠款额度设置
  549. $debt = isset($post['debt']) && $post['debt'] == CustomClass::IS_DEBT_YES ? CustomClass::IS_DEBT_YES : CustomClass::IS_DEBT_NO;
  550. $customId = $custom['id'] ?? 0;
  551. $debtLimit = isset($post['debtLimit']) && is_numeric($post['debtLimit']) ? $post['debtLimit'] : 0;
  552. CustomClass::updateById($customId, ['debtLimit' => $debtLimit, 'debt' => $debt]);
  553. $transaction->commit();
  554. util::success($custom);
  555. } catch (\Exception $exception) {
  556. $transaction->rollBack();
  557. Yii::info("添加客户没有成功:" . $exception->getMessage());
  558. util::fail('添加客户没有成功');
  559. }
  560. }
  561. //向队列写入新花店数据 shizhongqi 2022.6.8
  562. public function actionCreateCustomers()
  563. {
  564. $post = Yii::$app->request->post();
  565. $virtual = $post['virtual'] ?? 0;
  566. $arr = [];
  567. for ($i = 1; $i <= 5; $i++) {
  568. $name = $post['name' . $i] ?? '';
  569. $mobile = $post['mobile' . $i] ?? '';
  570. $confirmMobile = $post['confirmMobile' . $i] ?? '';
  571. if (empty($name) && empty($mobile) && empty($confirmMobile)) {
  572. continue;
  573. }
  574. if (empty($name)) {
  575. util::fail('花店名称不能为空');
  576. }
  577. if (stringUtil::getWordNum($name) > 15) {
  578. util::fail('名称不能超过15个汉字');
  579. }
  580. if (empty($mobile)) {
  581. //添加虚拟客户
  582. if ($virtual == 1) {
  583. $mobile = orderSn::getMobileSn();
  584. $confirmMobile = $mobile;
  585. } else {
  586. util::fail($name . " 手机号不能为空");
  587. }
  588. }
  589. if (stringUtil::isMobile($mobile) == false) {
  590. util::fail($name . " 手机号格式不正确");
  591. }
  592. if ($mobile != $confirmMobile) {
  593. util::fail($name . " 二次手机号不一致");
  594. }
  595. $hasShop = ShopClass::getByCondition(['mobile' => $mobile], true);
  596. if (!empty($hasShop)) {
  597. $shop = ShopClass::getByCondition(['mobile' => $mobile, 'ptStyle' => 1], true);
  598. if (!empty($shop)) {
  599. $ghsShopId = $this->shopId;
  600. $hdShopId = $shop->id;
  601. $custom = CustomClass::build($ghsShopId, $hdShopId);
  602. $customId = $custom['id'] ?? 0;
  603. $custom = CustomClass::getById($customId, true);
  604. if (!empty($custom)) {
  605. $custom->name = $name;
  606. $py = stringUtil::py($name);
  607. $custom->py = $py;
  608. $custom->save();
  609. }
  610. util::success(['customId' => $customId], $shop->merchantName . ' 添加成功');
  611. }
  612. util::fail($mobile . "手机号已经添加过了");
  613. }
  614. $has = ApplyClass::getByCondition(['mobile' => $mobile]);
  615. if (!empty($has)) {
  616. util::fail($mobile . "手机号已经申请添加过了");
  617. }
  618. $arr[] = ['name' => $name, 'mobile' => $mobile];
  619. }
  620. if (empty($arr)) {
  621. util::fail('请填写客户');
  622. }
  623. foreach ($arr as $item) {
  624. $name = $item['name'] ?? '';
  625. $mobile = $item['mobile'] ?? '';
  626. //队列方式去处理
  627. $customerCachedKey = 'batch_create_customer_list';
  628. $value = $name . '_' . $mobile . '_' . $this->sjId . '_' . $this->shop->id . '_' . $this->sj->name . '_' . $this->shopAdminId;
  629. Yii::$app->redis->executeCommand('LPUSH', [$customerCachedKey, $value]);
  630. Yii::info("供货商添加客户:name - " . $name . ' == mobile - ' . $mobile);
  631. Yii::info("shopAdminId: " . $this->shopAdminId);
  632. }
  633. util::complete('已提交,15秒后生效');
  634. }
  635. //从其它店同步客户 shizhongqi 2022.6.9
  636. public function actionCopyCustomers()
  637. {
  638. $get = Yii::$app->request->get();
  639. $fromShopId = $get['fromShopId'] ?? 0;
  640. $fromShop = ShopClass::getById($fromShopId, true);
  641. if (empty($fromShop)) {
  642. util::fail('门店不存在');
  643. }
  644. $toShopId = $this->shopId;
  645. if ($fromShopId == $toShopId) {
  646. util::fail('本店无需同步');
  647. }
  648. $fromShopName = $fromShop->shopName ?? '';
  649. if ($fromShop->syncCustom == 0) {
  650. util::fail('不允许从' . $fromShopName . '同步客户');
  651. }
  652. $toShop = $this->shop;
  653. $toShopName = $toShop->shopName ?? '';
  654. if ($toShop->syncCustom == 0) {
  655. util::fail($toShopName . '已关闭同步功能');
  656. }
  657. $toSjId = $toShop->sjId ?? 0;
  658. $fromSjId = $fromShop->sjId ?? 0;
  659. if ($toSjId != $fromSjId) {
  660. util::fail('不是您的门店');
  661. }
  662. $cachedKey = 'copy_other_shop_customers';
  663. Yii::$app->redis->executeCommand('LPUSH', [$cachedKey, $toShopId . '_' . $fromShopId]);
  664. Yii::info("从其他门店同步客户:目标门店id = " . $toShopId . ' 来源门店id = ' . $fromShopId);
  665. util::complete('已提交,1分钟后生效');
  666. }
  667. //客户列表 ssh 2021.7.8
  668. public function actionList()
  669. {
  670. $staff = $this->shopAdmin;
  671. if (isset($staff->identity) && $staff->identity == 2) {
  672. util::success(['list' => []]);
  673. }
  674. $get = Yii::$app->request->get();
  675. $type = $get['type'] ?? 0;
  676. $name = $get['name'] ?? '';
  677. $export = $get['export'] ?? 0;
  678. $mainId = $this->mainId;
  679. $isCashier = $get['isCashier'] ?? 0;
  680. if ($isCashier == 1) {
  681. //去掉收银台提示价格更新
  682. $staffId = $this->shopAdminId;
  683. Yii::$app->redis->executeCommand('DEL', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh']);
  684. }
  685. $where = ['ownMainId' => $this->mainId];
  686. $sort = 'visitTime DESC';
  687. $where['delStatus'] = 0;
  688. if ($type == 1) {
  689. //消费排行
  690. $sort = 'buyAmount DESC';
  691. } else if ($type == 2) {
  692. //欠款客户
  693. $where['isDebt'] = 1;
  694. $sort = '(debtAmount-balance) DESC';
  695. } else if ($type == 3) {
  696. //大客户
  697. $where['level'] = 2;
  698. } else if ($type == 4) {
  699. //零售客户
  700. $where['level'] = 0;
  701. } else if ($type == 5) {
  702. //休眠客户
  703. $recentDay = isset($get['recentDay']) && is_numeric($get['recentDay']) ? (int)$get['recentDay'] : 7;
  704. $totalSecond = bcmul(86400, $recentDay);
  705. $currentSecond = bcsub(time(), $totalSecond);
  706. $currentDate = date("Y-m-d H:i:s", $currentSecond);
  707. $where['recentExpend<'] = $currentDate;
  708. $sort = 'recentExpend desc';
  709. } else if ($type == 6) {
  710. //黑名单
  711. $where['black'] = 2;
  712. } else if ($type == 7) {
  713. //已删除
  714. $where['delStatus'] = 1;
  715. }
  716. $name = trim($name);
  717. if (!empty($name)) {
  718. if (is_numeric($name)) {
  719. if (stringUtil::isMobile($name)) {
  720. $where['mobile'] = $name;
  721. } else {
  722. $shop = $this->shop;
  723. //如果花大苪,搜索数字还是优先搜索客户名称,因为客户名称经常会编号
  724. if ($shop->id == 8249) {
  725. $where['name'] = ['like', $name];
  726. } else {
  727. $where['mobile'] = ['like', $name];
  728. }
  729. }
  730. } else if (stringUtil::isLetter($name)) {
  731. $where['py'] = ['like', $name];
  732. } else {
  733. $where['name'] = ['like', $name];
  734. }
  735. }
  736. if ($export == 1) {
  737. ini_set('memory_limit', '2045M');
  738. set_time_limit(0);
  739. CustomClass::exportCustom($where, $sort, $this->mainId);
  740. util::stop();
  741. }
  742. $list = CustomService::getCustomSortList($where, $sort);
  743. $main = $this->main;
  744. $list['totalUser'] = $main->totalUser ?? 0;
  745. $list['mayGatheringNum'] = $main->mayGatheringNum ?? 0;
  746. $list['shopInfo'] = $this->shop;
  747. util::success($list);
  748. }
  749. //今日访客 ssh 20211022
  750. public function actionGetVisit()
  751. {
  752. $ids = StatVisitClass::getVisitCustomIds($this->shop);
  753. if (empty($ids)) {
  754. util::success(['list' => []]);
  755. }
  756. $sort = 'visitTime DESC';
  757. $where = ['id' => ['in', $ids]];
  758. $respond = CustomService::getCustomSortList($where, $sort);
  759. util::success($respond);
  760. }
  761. //客户详情 ssh 2021.1.8
  762. public function actionDetail()
  763. {
  764. $get = Yii::$app->request->get();
  765. $customId = $get['id'] ?? 0;
  766. $info = CustomService::getCustomInfo($customId);
  767. CustomClass::valid($info, $this->shopId);
  768. $mainId = $info['mainId'] ?? 0;
  769. //超管的信息
  770. $superInfo = ShopAdminClass::getManager($mainId);
  771. $superName = $superInfo['name'] ?? '';
  772. $currentSuper = ['name' => $superName];
  773. $info['superInfo'] = $currentSuper;
  774. util::success($info);
  775. }
  776. //修改是否显示库存 ssh 20221022
  777. public function actionChangeShowStock()
  778. {
  779. $get = Yii::$app->request->get();
  780. $showStock = $get['showStock'] ?? 0;
  781. $customId = $get['customId'] ?? 0;
  782. $custom = CustomClass::getById($customId, true);
  783. CustomClass::valid($custom, $this->shopId);
  784. $ghsId = $custom->ghsId ?? 0;
  785. $ghs = GhsClass::getById($ghsId, true);
  786. if (empty($ghs)) {
  787. util::fail('没有找到供货商');
  788. }
  789. $ghs->showStock = $showStock;
  790. $ghs->save();
  791. $custom->showStock = $showStock;
  792. $custom->save();
  793. util::complete();
  794. }
  795. //修改状态 ssh 20240924
  796. public function actionChangePassStatus()
  797. {
  798. $get = Yii::$app->request->get();
  799. $passStatus = isset($get['passStatus']) ? $get['passStatus'] : 0;
  800. $customId = isset($get['customId']) ? $get['customId'] : 0;
  801. $custom = CustomClass::getById($customId, true);
  802. CustomClass::valid($custom, $this->shopId);
  803. $ghsId = $custom->ghsId ?? 0;
  804. $ghs = GhsClass::getById($ghsId, true);
  805. if (empty($ghs)) {
  806. util::fail('没有找到供货商');
  807. }
  808. $ghs->passStatus = $passStatus;
  809. $ghs->save();
  810. $custom->passStatus = $passStatus;
  811. $custom->save();
  812. util::complete();
  813. }
  814. public function actionChangeHome()
  815. {
  816. $get = Yii::$app->request->get();
  817. $home = isset($get['home']) ? $get['home'] : 0;
  818. $customId = !empty($get['customId']) ? $get['customId'] : 0;
  819. $custom = CustomClass::getById($customId, true);
  820. if (empty($custom)) {
  821. util::fail('没有找到客户呢');
  822. }
  823. if ($custom->ownShopId != $this->shopId) {
  824. util::fail('不是你的客户');
  825. }
  826. $ghsId = $custom->ghsId ?? 0;
  827. $ghs = GhsClass::getById($ghsId, true);
  828. if (empty($ghs)) {
  829. util::fail('没有找到供货商');
  830. }
  831. $ghs->home = $home;
  832. $ghs->save();
  833. $custom->home = $home;
  834. $custom->save();
  835. util::complete();
  836. }
  837. /**
  838. * 上门最低消费设置 -- 单个修改
  839. */
  840. public function actionModifyHomeAmount()
  841. {
  842. $get = Yii::$app->request->get();
  843. $id = $get['id'] ?? 0;
  844. $homeAmount = $get['homeAmount'] ?? 0;
  845. $homeType = $get['homeType'] ?? 0;
  846. $custom = CustomClass::getById($id, true);
  847. if (empty($custom)) {
  848. util::fail('没有找到客户');
  849. }
  850. if ($custom->ownMainId != $this->mainId) {
  851. util::fail('不是你的客户');
  852. }
  853. $ghsId = $custom->ghsId ?? 0;
  854. $ghs = GhsClass::getById($ghsId, true);
  855. if (empty($ghs)) {
  856. util::fail('没有找到供货商');
  857. }
  858. $custom->homeAmount = $homeAmount;
  859. $custom->homeType = $homeType;
  860. $custom->save();
  861. $ghs->homeAmount = $homeAmount;
  862. $ghs->homeType = $homeType;
  863. $ghs->save();
  864. util::complete('修改成功');
  865. }
  866. /**
  867. * 上门最低消费设置 -- 针对批发商客户进行批量修改
  868. */
  869. public function actionModifyAllHomeAmount()
  870. {
  871. $get = Yii::$app->request->get();
  872. $homeAmount = $get['homeAmount'] ?? 0;
  873. $homeType = $get['homeType'] ?? 0;
  874. $shopId = $this->shopId;
  875. ShopClass::updateById($shopId, ['homeAmount' => $homeAmount, 'homeType' => $homeType]);
  876. // 批量更新客户信息
  877. CustomClass::updateByCondition(['ownMainId' => $this->mainId], ['homeAmount' => $homeAmount, 'homeType' => $homeType]);
  878. //批量更新供货商信息
  879. GhsClass::updateByCondition(['shopId' => $shopId], ['homeAmount' => $homeAmount, 'homeType' => $homeType]);
  880. util::complete('修改成功');
  881. }
  882. //允许月结开关 ssh 2021.1.8
  883. public function actionDebt()
  884. {
  885. if (getenv('YII_ENV') == 'production') {
  886. if ($this->mainId == 4884) {
  887. if ($this->shopAdminId != 130738) {
  888. util::fail('只有倩姐才能修改');
  889. }
  890. }
  891. }
  892. $get = Yii::$app->request->get();
  893. $debt = isset($get['debt']) ? $get['debt'] : 0;
  894. $customId = isset($get['customId']) ? $get['customId'] : 0;
  895. $custom = CustomClass::getById($customId);
  896. CustomClass::valid($custom, $this->shopId);
  897. CustomClass::debt($custom, $debt);
  898. util::complete();
  899. }
  900. //采购查看权限的黑白名单开关 shizhongqi 2021.08.08
  901. public function actionSetBlack()
  902. {
  903. $black = Yii::$app->request->get('black', 2);
  904. $customId = Yii::$app->request->get('customId', 0);
  905. $custom = CustomClass::getById($customId, true);
  906. CustomClass::valid($custom, $this->shopId);
  907. $custom->black = $black;
  908. $custom->save();
  909. $ghsId = $custom->ghsId ?? 0;
  910. $ghs = GhsClass::getById($ghsId, true);
  911. if (empty($ghs)) {
  912. util::fail('出错了');
  913. }
  914. $ghs->black = $black;
  915. $ghs->save();
  916. util::complete();
  917. }
  918. //欠款客户 ssh 2021.2.4
  919. public function actionDebtList()
  920. {
  921. $get = Yii::$app->request->get();
  922. $where = ['ownShopId' => $this->shopId, 'isDebt' => 1];
  923. if (isset($get['name']) && !empty($get['name'])) {
  924. $where['name'] = ['like', $get['name']];
  925. }
  926. $list = CustomService::getDebtList($where);
  927. //共X个客户,合计欠款XXX元
  928. $main = $this->main;
  929. $list['customNum'] = $main->mayGatheringNum ?? 0;
  930. $list['debtAmount'] = $main->mayGathering ?? 0.00;
  931. util::success($list);
  932. }
  933. //修改欠款额度 ssh 20210625
  934. public function actionUpdateDebtLimit()
  935. {
  936. $shopAdmin = $this->shopAdmin;
  937. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  938. util::fail('管理员才能操作');
  939. }
  940. if (getenv('YII_ENV') == 'production') {
  941. if ($this->mainId == 4884) {
  942. if ($this->shopAdminId != 130738) {
  943. util::fail('请倩姐修改');
  944. }
  945. }
  946. if ($this->mainId == 10536) {
  947. if ($this->shopAdminId != 136416 && $this->shopAdminId != 136419) {
  948. util::fail('请闵总修改');
  949. }
  950. }
  951. }
  952. $get = Yii::$app->request->get();
  953. $id = $get['id'] ?? 0;
  954. $debtLimit = $get['debtLimit'] ?? 0;
  955. if (is_numeric($debtLimit) == false || $debtLimit < 0) {
  956. util::fail('请填写金额');
  957. }
  958. $custom = CustomClass::getById($id, true);
  959. CustomClass::valid($custom, $this->shopId);
  960. $custom->debtLimit = $debtLimit;
  961. $custom->save();
  962. util::complete();
  963. }
  964. //修改货位名称 ssh 20241006
  965. public function actionUpdateSeatSnName()
  966. {
  967. $get = Yii::$app->request->get();
  968. $id = $get['id'] ?? 0;
  969. $seatSnName = $get['seatSnName'] ?? '';
  970. $custom = CustomClass::getById($id, true);
  971. CustomClass::valid($custom, $this->shopId);
  972. $custom->seatSnName = $seatSnName;
  973. $custom->save();
  974. util::complete();
  975. }
  976. //修改折扣 ssh 20210913
  977. public function actionChangeDiscount()
  978. {
  979. $shopAdmin = $this->shopAdmin;
  980. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  981. util::fail('管理员才能操作');
  982. }
  983. $get = Yii::$app->request->get();
  984. $id = $get['id'] ?? 0;
  985. $discount = $get['discount'] ?? 0;
  986. if (is_numeric($discount) == false || $discount > 1 || $discount == 0) {
  987. util::fail('请填写小数值');
  988. }
  989. $custom = CustomClass::getById($id, true);
  990. CustomClass::valid($custom, $this->shopId);
  991. $custom->discount = $discount;
  992. $custom->save();
  993. $ghsId = $custom->ghsId ?? 0;
  994. $ghs = GhsClass::getById($ghsId, true);
  995. $ghs->giveDiscount = $discount;
  996. $ghs->save();
  997. util::complete();
  998. }
  999. //修改客户等级 ssh 20211007
  1000. public function actionChangeLevel()
  1001. {
  1002. $shopAdmin = $this->shopAdmin;
  1003. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  1004. util::fail('超管才能修改');
  1005. }
  1006. //泉城的只有苏小娟才能修改
  1007. if (getenv('YII_ENV') == 'production') {
  1008. if ($this->mainId == 60) {
  1009. if (in_array($this->adminId, [2499, 4]) == false) {
  1010. util::fail('请小娟修改');
  1011. }
  1012. }
  1013. }
  1014. $get = Yii::$app->request->get();
  1015. $customId = $get['customId'] ?? 0;
  1016. $level = $get['level'] ?? 1;
  1017. $custom = CustomClass::getById($customId, true);
  1018. CustomClass::valid($custom, $this->shopId);
  1019. $custom->level = $level;
  1020. $custom->save();
  1021. $ghsId = $custom->ghsId ?? 0;
  1022. $ghs = GhsClass::getById($ghsId, true);
  1023. if (empty($ghs)) {
  1024. util::fail('出错了');
  1025. }
  1026. $ghs->giveLevel = $level;
  1027. $ghs->save();
  1028. $map = CustomClass::$levelMap;
  1029. $name = $map[$level] ?? '';
  1030. util::success(['levelName' => $name]);
  1031. }
  1032. //打印货位号 ssh 20241006
  1033. public function actionPrintSeatSn()
  1034. {
  1035. $get = Yii::$app->request->get();
  1036. $customId = $get['id'] ?? 0;
  1037. $custom = CustomClass::getById($customId, true);
  1038. CustomClass::valid($custom, $this->shopId);
  1039. $seatSn = $custom->seatSn ?? 0;
  1040. if ($seatSn == 0) {
  1041. util::fail('没有货位');
  1042. }
  1043. $customName = $custom->name ?? '';
  1044. if (isset($custom->seatSnName) && !empty($custom->seatSnName)) {
  1045. $customName = $custom->seatSnName ?? '';
  1046. }
  1047. $customName = stringUtil::subStringUtf8($customName, 7, '..');
  1048. $a4Print = [
  1049. 'customName' => $customName,
  1050. 'seatSn' => $seatSn,
  1051. ];
  1052. $info['printData'] = $a4Print;
  1053. $template = '{"panels":[{"index":0,"name":1,"height":297,"width":210,"paperHeader":49.5,"paperFooter":780,"printElements":[{"options":{"left":12,"top":786,"height":49,"width":49},"printElementType":{"title":"html","type":"html"}},{"options":{"left":45,"top":52.5,"height":52,"width":128,"title":"文本","right":172.25,"bottom":104.5,"vCenter":108.25,"hCenter":78.5,"field":"seatSn","testData":"593","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":50,"fontWeight":"bold","textContentVerticalAlign":"middle","qrCodeLevel":0},"printElementType":{"title":"文本","type":"text"}},{"options":{"left":148.5,"top":52.5,"height":52,"width":400,"title":"文本","field":"customName","testData":"小林","coordinateSync":false,"widthHeightSync":false,"hideTitle":true,"fontSize":50,"fontWeight":"bolder","textAlign":"right","textContentVerticalAlign":"middle","qrCodeLevel":0,"right":566.5,"bottom":90.25,"vCenter":366.5,"hCenter":71.75},"printElementType":{"title":"文本","type":"text"}}],"paperNumberLeft":547.5,"paperNumberTop":786,"paperNumberDisabled":true,"paperNumberContinue":true,"fontFamily":"Microsoft YaHei","watermarkOptions":{"content":"","rotate":25,"timestamp":false,"format":"YYYY-MM-DD HH:mm","fillStyle":"rgba(184, 184, 184, 0.3)","fontSize":"14px","width":200,"height":200},"panelLayoutOptions":{"layoutType":"column","layoutRowGap":0,"layoutColumnGap":0}}]}';
  1054. $info['template'] = $template;
  1055. $custom->printSeatSn = 1;
  1056. $custom->save();
  1057. util::success($info);
  1058. }
  1059. //总赊账和总余额汇总 ssh 20250620
  1060. public function actionShowTotalBalance()
  1061. {
  1062. $lookMoney = \bizGhs\shop\classes\ShopAdminClass::lookMoneyPower($this->shopAdmin, $this->shop);
  1063. if ($lookMoney == 0) {
  1064. util::fail('无法查看哦');
  1065. }
  1066. $pfShop = $this->shop;
  1067. $lsShopId = $pfShop->lsShopId;
  1068. $pfShopId = $this->shopId;
  1069. $respond = CustomClass::showTotalBalance($pfShopId, $lsShopId);
  1070. $respond['pfShopId'] = $pfShopId;
  1071. $respond['lsShopId'] = $lsShopId;
  1072. util::success($respond);
  1073. }
  1074. public function actionChangeDelStatus()
  1075. {
  1076. $get = Yii::$app->request->get();
  1077. $customId = $get['id'] ?? 0;
  1078. $delStatus = $get['delStatus'] ?? 0;
  1079. $custom = CustomClass::getById($customId, true);
  1080. CustomClass::valid($custom, $this->shopId);
  1081. $ghsId = $custom->ghsId ?? 0;
  1082. $ghs = GhsClass::getById($ghsId, true);
  1083. if (empty($ghs)) {
  1084. util::fail('客户信息有缺失');
  1085. }
  1086. $custom->delStatus = $delStatus;
  1087. $custom->save();
  1088. $ghs->delStatus = $delStatus;
  1089. $ghs->save();
  1090. util::complete('删除成功');
  1091. }
  1092. }