CustomController.php 43 KB

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