CustomController.php 43 KB

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