CustomController.php 45 KB

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