CustomController.php 43 KB

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