CustomController.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <?php
  2. namespace console\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\shop\classes\ShopClass;
  5. use biz\shop\services\ShopAdminService;
  6. use biz\sj\classes\SjClass;
  7. use bizGhs\admin\classes\AdminClass;
  8. use bizGhs\custom\classes\CustomClass;
  9. use bizGhs\custom\models\Custom;
  10. use bizGhs\order\classes\OrderClass;
  11. use bizHd\purchase\classes\PurchaseClass;
  12. use bizHd\saas\classes\ApplyClass;
  13. use bizHd\saas\services\ApplyService;
  14. use common\components\dict;
  15. use common\components\noticeUtil;
  16. use common\components\stringUtil;
  17. use common\components\util;
  18. use yii\console\Controller;
  19. use Yii;
  20. class CustomController extends Controller
  21. {
  22. //欠款信息不一致跟踪 ssh 20220307 ./yii custom/adjust-debt
  23. public function actionAdjustDebt()
  24. {
  25. ini_set('memory_limit', '2045M');
  26. set_time_limit(0);
  27. $shopList = ShopClass::getAllByCondition(['ptStyle' => 2], null, '*', null, true);
  28. if (empty($shopList)) {
  29. return false;
  30. }
  31. foreach ($shopList as $key => $shop) {
  32. $shopId = $shop->id ?? 0;
  33. $query = new \yii\db\Query();
  34. $query->from(Custom::tableName());
  35. $query->where(['ownShopId' => $shopId]);
  36. $query->orderBy('addTime ASC');
  37. foreach ($query->batch(50) as $customList) {
  38. if (!empty($customList)) {
  39. foreach ($customList as $custom) {
  40. //$customName = $custom['name'] ?? '';
  41. $customId = $custom['id'] ?? 0;
  42. $where = ['customId' => $customId, 'debt' => 1];
  43. $orderList = OrderClass::getAllByCondition($where, 'addTime DESC', '*');
  44. $ghsOrderDebtAmount = 0;
  45. if (!empty($orderList)) {
  46. foreach ($orderList as $order) {
  47. $actPrice = $order['remainDebtPrice'] ?? 0;
  48. $ghsOrderDebtAmount = bcadd($ghsOrderDebtAmount, $actPrice, 2);
  49. }
  50. }
  51. $ghsId = $custom['ghsId'] ?? 0;
  52. $ghs = \bizHd\ghs\classes\GhsClass::getById($ghsId);
  53. $where = ['ghsId' => $ghsId, 'debt' => PurchaseClass::DEBT_YES];
  54. $cgList = PurchaseClass::getAllByCondition($where, 'addTime DESC', '*');
  55. $hdCgOrderDebtAmount = 0;
  56. if (!empty($cgList)) {
  57. foreach ($cgList as $cg) {
  58. $actPrice = $cg['remainDebtPrice'] ?? 0;
  59. $hdCgOrderDebtAmount = bcadd($hdCgOrderDebtAmount, $actPrice, 2);
  60. }
  61. }
  62. if ($ghsOrderDebtAmount < 0 || $hdCgOrderDebtAmount < 0) {
  63. noticeUtil::push("!!!!!!!供货商 {$ghsId} 客户id {$customId} 出现负数 $ghsOrderDebtAmount $hdCgOrderDebtAmount", '15280215347');
  64. echo "@@@@@@@@@@@@@供货商 {$ghsId} 客户id {$customId} 出现负数 $ghsOrderDebtAmount $hdCgOrderDebtAmount \n";
  65. }
  66. $ghsOrderDebtAmount = floatval($ghsOrderDebtAmount);
  67. $hdCgOrderDebtAmount = floatval($hdCgOrderDebtAmount);
  68. if ($ghsOrderDebtAmount != $hdCgOrderDebtAmount) {
  69. noticeUtil::push("!!!!!!!供货商 {$ghsId} 客户id {$customId} 二边欠款单总金额不一致", '15280215347');
  70. echo "---------供货商 {$ghsId} 客户id {$customId} 二边 欠款单 总金额 不一致 {$ghsOrderDebtAmount} {$hdCgOrderDebtAmount} \n";
  71. continue;
  72. }
  73. $customSaveDebtAmount = $custom['debtAmount'] ? floatval($custom['debtAmount']) : 0;
  74. $ghsSaveDebtAmount = $ghs['debtAmount'] ? floatval($ghs['debtAmount']) : 0;
  75. if ($customSaveDebtAmount != $ghsOrderDebtAmount) {
  76. echo "*********客户 {$customId} 欠款 和 订单总额 不一致 $customSaveDebtAmount $ghsOrderDebtAmount \n";
  77. noticeUtil::push("*********客户 {$customId} 欠款总金额 和 订单总合 不一致 $customSaveDebtAmount $ghsOrderDebtAmount ", '15280215347');
  78. continue;
  79. }
  80. if ($ghsSaveDebtAmount != $hdCgOrderDebtAmount) {
  81. echo "#########欠供货商 {$ghsId} 和 订单总额 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount \n";
  82. noticeUtil::push("#########欠供货商 {$ghsId} 金额 和 订单总合 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount ", '15280215347');
  83. continue;
  84. }
  85. }
  86. }
  87. }
  88. }
  89. }
  90. public function actionBatchCommand()
  91. {
  92. //批量创建客户
  93. $this->createCustomer();
  94. //从首店同步客户
  95. $this->copyCustomers();
  96. }
  97. //批量创建客户
  98. private function createCustomer()
  99. {
  100. $customerCachedKey = 'batch_create_customer_list';
  101. $customList = [];
  102. while ($count = Yii::$app->redis->executeCommand('LLEN', [$customerCachedKey])) {
  103. $customer = Yii::$app->redis->executeCommand('RPOP', [$customerCachedKey]);
  104. $customList[] = $customer;
  105. }
  106. if (empty($customList)) {
  107. return false;
  108. }
  109. foreach ($customList as $customer) {
  110. $connection = Yii::$app->db;
  111. $transaction = $connection->beginTransaction();
  112. $customerInfo = explode('_', $customer);
  113. $shopName = $customerInfo[0];
  114. $mobile = $customerInfo[1];
  115. try {
  116. // 组织表单数据
  117. $post = [];
  118. $post['introSjId'] = $customerInfo[2];
  119. $post['introShopId'] = $customerInfo[3];
  120. $post['introSjName'] = $customerInfo[4];
  121. $post['introStyle'] = SjClass::STYLE_SUPPLIER;
  122. $post['name'] = $shopName;
  123. if (empty($shopName)) {
  124. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称没有填写", '15280215347');
  125. $transaction->rollBack();
  126. continue;
  127. }
  128. $post['mobile'] = $mobile;
  129. if (stringUtil::isMobile($mobile) == false) {
  130. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号填写错误", '15280215347');
  131. $transaction->rollBack();
  132. continue;
  133. }
  134. if (stringUtil::getWordNum($shopName) > 15) {
  135. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称超过了15个汉字", '15280215347');
  136. $transaction->rollBack();
  137. continue;
  138. }
  139. $has = ApplyClass::getByCondition(['mobile' => $mobile]);
  140. if (!empty($has)) {
  141. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号已经存在了哦", '15280215347');
  142. $transaction->rollBack();
  143. continue;
  144. }
  145. $hasShop = ShopClass::getByCondition(['mobile' => $mobile]);
  146. if (!empty($hasShop)) {
  147. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号已经存在了", '15280215347');
  148. $transaction->rollBack();
  149. continue;
  150. }
  151. $adminName = $post['adminName'] ?? '';
  152. $miniOpenId = $post['miniOpenId'] ?? '';
  153. $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'miniOpenId' => $miniOpenId];
  154. $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
  155. $admin = AdminClass::replaceAdmin($adminInfo, $fromApp);
  156. $adminId = $admin['id'] ?? 0;
  157. $post['adminId'] = $adminId;
  158. $post['adminName'] = $admin['name'] ?? '';
  159. $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
  160. $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
  161. $post['from'] = ApplyClass::FROM_RETAIL;
  162. $post['style'] = SjClass::STYLE_RETAIL;
  163. //增加或更新申请
  164. $respond = ApplyService::replaceRetail($post);
  165. $id = $respond['id'] ?? 0;
  166. //后继代码,要用到此参数
  167. Yii::$app->params['ptStyle'] = 2;
  168. ApplyService::pass($id, '批发商手动添加');
  169. $transaction->commit();
  170. //只要手动添加的都标记为花店,任何情况都不会标记为散客
  171. CustomClass::updateByCondition(['mobile' => $mobile], ['isHd' => 1]);
  172. //noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 由批发商添加成功");
  173. } catch (\Exception $exception) {
  174. $transaction->rollBack();
  175. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,原因:" . $exception->getMessage(), '15280215347');
  176. }
  177. }
  178. }
  179. //批发端分店从首店同步客户
  180. private function copyCustomers()
  181. {
  182. $cachedKey = 'copy_other_shop_customers';
  183. $shopIdList = [];
  184. while ($count = Yii::$app->redis->executeCommand('LLEN', [$cachedKey])) {
  185. $shopIdData = Yii::$app->redis->executeCommand('RPOP', [$cachedKey]);
  186. $shopIdList[] = $shopIdData;
  187. }
  188. if (empty($shopIdList)) {
  189. return;
  190. }
  191. foreach ($shopIdList as $shopIdData) {
  192. $shopIdArr = explode('_', $shopIdData);
  193. if (count($shopIdArr) != 2) {
  194. Yii::info('copy customer 数据出错:' . $shopIdData);
  195. noticeUtil::push("从分店同步客户出错了:" . $shopIdData, '15280215347');
  196. continue;
  197. }
  198. //指定当前环境为批发商
  199. Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'ghs');
  200. $toShopId = $shopIdArr[0];
  201. $fromShopId = $shopIdArr[1];
  202. $fromCustomList = CustomClass::getAllByCondition(['ownShopId' => $fromShopId], null, '*');
  203. foreach ($fromCustomList as $fromCustomer) {
  204. $exist = CustomClass::exists(['ownShopId' => $toShopId, 'shopId' => $fromCustomer['shopId']]);
  205. if (!$exist) {
  206. CustomClass::build($toShopId, $fromCustomer['shopId'], $fromCustomer['name']);
  207. }
  208. }
  209. }
  210. }
  211. //从文件批量创建客户 ssh 20240426
  212. public function actionFileCreateCustom()
  213. {
  214. // $customerCachedKey = 'file_batch_create_customer_list';
  215. // $fileCustomList = [];
  216. // while ($count = Yii::$app->redis->executeCommand('LLEN', [$customerCachedKey])) {
  217. // $customer = Yii::$app->redis->executeCommand('RPOP', [$customerCachedKey]);
  218. // $fileCustomList[] = $customer;
  219. // }
  220. //
  221. // if (empty($fileCustomList)) {
  222. // noticeUtil::push("没有找到手机号", '15280215347');
  223. // return false;
  224. // }
  225. $fileCustomList = ['23580,/usr/local/nginx/html/huahuibao/vendor/../../resource/images/uploads/35869/23580/202404/27/f4ed6c0aa209b4d0d56dd6543b7c4e25.txt'];
  226. foreach ($fileCustomList as $fileCustom) {
  227. $customerInfo = explode(',', $fileCustom);
  228. $masterShopId = $customerInfo[0];
  229. $masterShop = ShopClass::getById($masterShopId, true);
  230. $masterSjId = $masterShop->sjId ?? 0;
  231. $masterSjName = $masterShop->merchantName ?? '';
  232. $filePath = $customerInfo[1];
  233. $content = file_get_contents($filePath);
  234. $content = trim($content);
  235. $arr = explode('
  236. ', $content);
  237. foreach ($arr as $key => $one) {
  238. $single = explode(',', $one);
  239. $shopName = trim($single[0]);
  240. $mobile = trim($single[1]);
  241. echo bcadd($key, 1) . ' ' . $shopName . ' ' . $mobile . "\n";
  242. $connection = Yii::$app->db;
  243. $transaction = $connection->beginTransaction();
  244. try {
  245. // 组织表单数据
  246. $post = [];
  247. $post['introSjId'] = $masterSjId;
  248. $post['introShopId'] = $masterShopId;
  249. $post['introSjName'] = $masterSjName;
  250. $post['introStyle'] = SjClass::STYLE_SUPPLIER;
  251. $post['name'] = $shopName;
  252. if (empty($shopName)) {
  253. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称没有填写", '15280215347');
  254. $transaction->rollBack();
  255. continue;
  256. }
  257. $post['mobile'] = $mobile;
  258. if (stringUtil::isMobile($mobile) == false) {
  259. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号填写错误", '15280215347');
  260. $transaction->rollBack();
  261. continue;
  262. }
  263. if (stringUtil::getWordNum($shopName) > 15) {
  264. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称超过了15个汉字", '15280215347');
  265. $transaction->rollBack();
  266. continue;
  267. }
  268. $hasShop = ShopClass::getByCondition(['mobile' => $mobile]);
  269. if (!empty($hasShop)) {
  270. //noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号已经存在了", '15280215347');
  271. $transaction->rollBack();
  272. continue;
  273. }
  274. $has = ApplyClass::getByCondition(['mobile' => $mobile]);
  275. if (!empty($has)) {
  276. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,在申请列表,手机号已经存在了哦", '15280215347');
  277. $transaction->rollBack();
  278. continue;
  279. }
  280. $adminName = $post['adminName'] ?? '';
  281. $miniOpenId = $post['miniOpenId'] ?? '';
  282. $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'miniOpenId' => $miniOpenId];
  283. $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
  284. $admin = AdminClass::replaceAdmin($adminInfo, $fromApp);
  285. $adminId = $admin['id'] ?? 0;
  286. $post['adminId'] = $adminId;
  287. $post['adminName'] = $admin['name'] ?? '';
  288. $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
  289. $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
  290. $post['from'] = ApplyClass::FROM_RETAIL;
  291. $post['style'] = SjClass::STYLE_RETAIL;
  292. //增加或更新申请
  293. $respond = ApplyService::replaceRetail($post);
  294. $id = $respond['id'] ?? 0;
  295. //后继代码,要用到此参数
  296. Yii::$app->params['ptStyle'] = 2;
  297. ApplyService::pass($id, '批发商手动添加');
  298. $transaction->commit();
  299. //只要手动添加的都标记为花店,任何情况都不会标记为散客
  300. CustomClass::updateByCondition(['mobile' => $mobile], ['isHd' => 1]);
  301. //noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 由批发商添加成功");
  302. } catch (\Exception $exception) {
  303. $transaction->rollBack();
  304. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,原因:" . $exception->getMessage(), '15280215347');
  305. }
  306. }
  307. }
  308. }
  309. public function actionImport()
  310. {
  311. $masterShopId = 55238;
  312. $masterShop = ShopClass::getById($masterShopId, true);
  313. $masterSjId = $masterShop->sjId ?? 0;
  314. $masterSjName = $masterShop->merchantName ?? '';
  315. $content = '1314花艺坊 15396301318
  316. 1314花艺坊 16521681314
  317. 贻苗鲜花店 15959886775
  318. 七里香花坊 18965691877
  319. 兰桂坊鲜花行 13774855302
  320. 星晴花艺 13559050210
  321. 好运鲜花行 15260835116
  322. 好运鲜花行 13615926212
  323. 恋善好多花 13960409739
  324. 水晶花艺坊 13559596871
  325. 华联花店 18859555183
  326. 枝也花艺 18250296177
  327. 美丽人生 13805928543
  328. 慕鑫花艺店 15980044733
  329. 温馨花店 18959765442
  330. 梦辰鲜花店 13788859910
  331. 填心花店 13505980311
  332. 车之宝 13599260160
  333. 木泽家花艺 13505909331
  334. 花·印象花艺生活馆 18750411995
  335. 恒利花艺 13599754442
  336. 友情园林花艺 13906999776
  337. 新锦堂花艺 18960312580
  338. 鑫鑫花艺 13665934834
  339. 春满园 18815989293
  340. 鑫鑫花艺 13665934834
  341. 花屿花店 18859428889
  342. 心馨鲜花行 13799553891
  343. 旺旺(铝合金太空架) 136369949
  344. 丽景花店 13506061215
  345. 幸运花艺坊 18960205098
  346. 芊禧花艺店(伊匠) 15985932041
  347. 思强花艺坊 15375751971
  348. 华盛鲜花坊 13959990453
  349. 薇FLOWER花坊 13655900006
  350. 凤艺花行 13599995559
  351. 露露发喜庆布置 13328890668
  352. 大盈优尚花艺坊 15905962910
  353. 也有花艺 15060930333
  354. Elaine花匠·花艺 15559591557
  355. 有家花店 15859763475
  356. 彩花大道花艺坊 13600768250
  357. 新概念花店 13505906311
  358. 时光花坊 15260411999
  359. 萧下馨香园花艺 13559570456
  360. 庄园花坊 13599933509
  361. 新世纪鲜花店 13559589534
  362. 心心相印 15059510032
  363. 心馨鲜花行 13799553891
  364. 缘雅花店(雅馨) 13774814696
  365. 玲珑花艺坊13159002310
  366. 阿华花艺坊13205051057
  367. 绿园婚庆策划13599106858
  368. 水晶花艺坊13559596871
  369. 有家花店 15859763475
  370. 馨源喜庆13599709998
  371. 如意花卉13850700343
  372. 珍妮花店13655965150
  373. 简爱花店 15305090323
  374. 花屿鹿17350083333
  375. 花之翼花店13400807255
  376. 雅兰花卉水族馆13004836174
  377. 金金婚庆13675911356
  378. 米多花苑13505082530
  379. 韵香花艺13859757598
  380. 雅士花店13636952280
  381. 大众花行13860751930
  382. 艾比嘉尔(伊莉娜)18558996680
  383. 雄阿鲜花店13505957242
  384. 花禧13489366158
  385. 龙翔喜庆15805955914
  386. 花之翼花店13400807255
  387. 心相印13305964403
  388. 花满园13599933509
  389. 一沐flower13799235516
  390. 玲珑花艺 13599255169
  391. 木易花坊 18859490932
  392. 新鸿发喜庆13506067363
  393. 胖吖花店18659806189
  394. 双氧花与茶13821636888
  395. 蝶恋花13799238373
  396. 安记花艺13506957325
  397. 嘉和鲜花园林绿化工程13665962427
  398. 哈尼花店13625992221
  399. 四季红婚庆15980301977
  400. 薇薇花坊13163933983
  401. 花之林园艺13599153000
  402. 优尚鲜花婚庆15905962910
  403. 阳光花艺坊13905071762
  404. 花舍花艺13559086600
  405. 大盈经典13599128005
  406. 欣欣花坊15605002189
  407. 夏之恋18815963312
  408. 诗娜花艺13850768837
  409. 艺菲(木泽)15060815333
  410. 花样年华花店 13959868951
  411. 馨逸创艺花馆13489215832
  412. 每日鲜花15060960918
  413. Elaine·花匠花艺15559591557
  414. 新时代花店13559551844
  415. 365鲜花坊15860426052
  416. 官桥浪漫花艺坊13338587331
  417. 薰草屋花13959776078
  418. 薰草屋花市18906098777
  419. 官桥彩花大道,13860710686
  420. 花花世界13636969069
  421. 雅馨花艺坊(石井)13799861148
  422. 新恒发18350639119
  423. 夏哥花行18650002752
  424. 花漫花店15805051191
  425. 花財鲜花店(花柬)13615962952
  426. 也有花艺工作室15260382233
  427. 瑤瑶鲜花店1385066235
  428. 福建春芽园林18960360886
  429. 莲河花店(石井)18106966733
  430. 水立方花艺 18359445626
  431. 爱慕花店 15805002864
  432. 景园花卉 18965427379
  433. 官桥-薰草屋花13959776078
  434. 东石-阿清花店15260606666
  435. 大盈-阳光花坊18065505593
  436. 绿苑鲜花坊18859998028
  437. 富红13860756709
  438. 浪漫花艺坊13338587331
  439. 水头东艺花卉坊13313883344
  440. 芒果花艺13960253306
  441. 官桥莲花15905065492
  442. 日生星花艺电话13328897135
  443. U兰花坊15860453349
  444. 乡野情花苑18959766168
  445. 香约花店15260828070
  446. 随缘花店13808550807
  447. 环岛花艺85586592
  448. 雅馨-缘雅花艺,85705558
  449. 水头-四季花屋 13489801402
  450. 官桥水族馆-小希花艺坊13505968166
  451. 听花堂18250631192
  452. 官桥闽通花店15959860280
  453. 大盈嘉禾13665962427
  454. 梧号花店18065273656
  455. 花景苑花艺馆15959507134
  456. 壹束鲜花坊-13655979291
  457. 辉煌花艺13959952646
  458. 猫哥花艺18659073678
  459. 柒月花店15659710381
  460. 花云轩13655925866
  461. 缤纷花艺坊13808558197
  462. 心情不错花店15260801864
  463. 玉兰香花店13459583228
  464. 水头花卉盆栽15860434888
  465. 喜缘庆典 18159211358
  466. 春风鲜花行13599161081
  467. 石井予你花店15060480006
  468. 石井予你花店15060488316
  469. 圆圆花艺18965486999
  470. 圆圆花艺15059856655
  471. 艾米丽鲜花坊18859720722
  472. 漫野花艺工作室18350770045
  473. 东方鲜花精品13885906021
  474. 拾壹号花店15259742699
  475. 雅红花店 13808518072
  476. 东石-四季鲜花店15880748599
  477. 良兴花卉13365972255
  478. 星星发花艺店13506956480
  479. (小文)花给她18649972216
  480. 阳光城-小静花坊17350911359
  481. 诗情花艺13636907311
  482. 花拾间花艺生活馆15860502983
  483. 五里花满园13959909054
  484. 花甸 13626053459
  485. 圆盘13599255169
  486. 也有花艺15260382233
  487. 兰竹轩花店13960354737
  488. 塔头月好花缘13599706376
  489. 官桥-花屿花卉18046368392
  490. 阳光花坊18065505593
  491. 秋韵花店13600754486
  492. 绿创缘花店15880829613
  493. 壹加 one+ 18016756679
  494. 涵涵花艺荟 13959872768
  495. 你好花店15159872011
  496. 官桥伊美园 17760401152
  497. 水头花述15880889419
  498. 阿清花店15260606666
  499. 阳光花坊13959851312
  500. 水头鑫花坊18659590589
  501. 金金花坊13805963733
  502. 华鑫花店15259578811
  503. 阿免-蜂缘花艺坊15306956921
  504. 爱莉Alice花坊15159560685
  505. 尤加利花店15159538922
  506. 永胜花店13959891656
  507. 彩霞-官桥芊朵鲜花店15905065492
  508. 玉峰花艺15392257576
  509. 薪雅花艺15959592427
  510. 薇妮花店18050875587
  511. 予你·番禧15060480006 15060488316
  512. 石井-唯一花坊18959963600
  513. 安海-唯一花艺坊18698351683
  514. 壹贰叁花艺 15905065127
  515. 喜见花店15106061052
  516. 花言鲜花 15880815265
  517. 英林-予你花社15715981677
  518. 鲜花悟予花店15985923946
  519. 禾下·HEXIA鲜花婚策工作室15985955869
  520. 薇薇花坊鲜花绿植13163933983
  521. 花予礼鲜花店13559592011
  522. 圆圆-A·Lin花坊18965486999
  523. 圆圆-A·Lin花坊13788807699
  524. 蔓蔓花开15396306767
  525. 小李先森花坊 15880906873
  526. 花居里婚礼派对美学13960236836
  527. 新艺花艺13600700533
  528. 薇妮买花找我18050875587
  529. 张林-有家花店18350536612
  530. 喜柿花坊15060924833
  531. 惜缘花店18259563660
  532. 蔓蔓花艺18859989782
  533. 深缘广告+梅子花艺花卉15396593380
  534. 百缘鲜花阿欣15805031767
  535. 花言鲜花店15880815265
  536. 花心思花艺15880800812
  537. 囍礼花艺13559599226
  538. 超级花花(官桥店)13338589831';
  539. $content = trim($content);
  540. $arr = explode('
  541. ', $content);
  542. foreach ($arr as $key => $one) {
  543. $one = trim($one);
  544. $mobile = substr($one, -11);
  545. if (!stringUtil::isMobile($mobile)) {
  546. continue;
  547. }
  548. $name = str_replace($mobile, "", $one);
  549. $shopName = $name;
  550. echo bcadd($key, 1) . ' ' . $shopName . ' ' . $mobile . "\n";
  551. $connection = Yii::$app->db;
  552. $transaction = $connection->beginTransaction();
  553. try {
  554. // 组织表单数据
  555. $post = [];
  556. $post['introSjId'] = $masterSjId;
  557. $post['introShopId'] = $masterShopId;
  558. $post['introSjName'] = $masterSjName;
  559. $post['introStyle'] = SjClass::STYLE_SUPPLIER;
  560. $post['name'] = $shopName;
  561. if (empty($shopName)) {
  562. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称没有填写", '15280215347');
  563. $transaction->rollBack();
  564. continue;
  565. }
  566. $post['mobile'] = $mobile;
  567. if (stringUtil::isMobile($mobile) == false) {
  568. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号填写错误", '15280215347');
  569. $transaction->rollBack();
  570. continue;
  571. }
  572. if (stringUtil::getWordNum($shopName) > 15) {
  573. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,名称超过了15个汉字", '15280215347');
  574. $transaction->rollBack();
  575. continue;
  576. }
  577. $hasShop = ShopClass::getByCondition(['mobile' => $mobile]);
  578. if (!empty($hasShop)) {
  579. //noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,手机号已经存在了", '15280215347');
  580. $transaction->rollBack();
  581. continue;
  582. }
  583. $has = ApplyClass::getByCondition(['mobile' => $mobile]);
  584. if (!empty($has)) {
  585. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,在申请列表,手机号已经存在了哦", '15280215347');
  586. $transaction->rollBack();
  587. continue;
  588. }
  589. $adminName = $post['adminName'] ?? '';
  590. $miniOpenId = $post['miniOpenId'] ?? '';
  591. $adminInfo = ['name' => $adminName, 'mobile' => $mobile, 'miniOpenId' => $miniOpenId];
  592. $fromApp = dict::getDict('userSourceGetId', 'app', 'id');
  593. $admin = AdminClass::replaceAdmin($adminInfo, $fromApp);
  594. $adminId = $admin['id'] ?? 0;
  595. $post['adminId'] = $adminId;
  596. $post['adminName'] = $admin['name'] ?? '';
  597. $post['long'] = isset($post['longitude']) ? $post['longitude'] : '';
  598. $post['lat'] = isset($post['latitude']) ? $post['latitude'] : '';
  599. $post['from'] = ApplyClass::FROM_RETAIL;
  600. $post['style'] = SjClass::STYLE_RETAIL;
  601. //增加或更新申请
  602. $respond = ApplyService::replaceRetail($post);
  603. $id = $respond['id'] ?? 0;
  604. //后继代码,要用到此参数
  605. Yii::$app->params['ptStyle'] = 2;
  606. ApplyService::pass($id, '批发商手动添加');
  607. $transaction->commit();
  608. //只要手动添加的都标记为花店,任何情况都不会标记为散客
  609. CustomClass::updateByCondition(['mobile' => $mobile], ['isHd' => 1]);
  610. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 由批发商添加成功");
  611. } catch (\Exception $exception) {
  612. $transaction->rollBack();
  613. noticeUtil::push("花店 {$shopName} 手机号 {$mobile} 添加失败,原因:" . $exception->getMessage(), '15280215347');
  614. }
  615. }
  616. }
  617. }