Send_sms_adminAction.class.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. <?php
  2. /***
  3. * User: jun_hy
  4. * Date: 2022/7/5
  5. * Time: 16:24
  6. */
  7. /**
  8. * 短信发送,
  9. */
  10. require_once(ONU_ROOT . 'application/module/ctrl/Action.class.php');
  11. require_once(ONU_ROOT . 'application/lib/data/adminAction.php');
  12. header('content-Type: text/html; charset=utf-8');
  13. class Send_sms_adminAction extends Action
  14. {
  15. public function __construct()
  16. {
  17. parent::__construct();
  18. if (empty($_SESSION['mds_user'])) {
  19. header("Location:/?a=index&m=admin_login");
  20. exit();
  21. }
  22. }
  23. public function index()
  24. {
  25. $showtime = $_POST['demo_datetime'];
  26. $datetime=strtotime($showtime);
  27. if(empty($datetime)){
  28. $datetime=time();
  29. }
  30. $info = $_REQUEST['info'];
  31. $uid = $_SESSION['user_infos']['id'];
  32. $uname = $_SESSION['user_infos']['uname'];
  33. $fromName = '';
  34. $from='';
  35. $fromDm='';
  36. $accessKeyId='LTAI5tD31ApgijqwnZthM9SH';
  37. $accessKeySecret='NsEwR56E7qB8hBLBxkUqaZe4AahEyd';
  38. switch ($uid) {
  39. case 6:
  40. $fromName = 'SuperNova Hair';
  41. $from = 'SuperNova';
  42. $fromDm='14582122478';
  43. $accessKeyId='LTAI5tECcoZZWAMi7PLxhNHf';
  44. $accessKeySecret='g3oyP3SNPbU8sQ8nwNo7eDrHlbH6lQ';
  45. break;
  46. case 1:
  47. $fromName = 'Alipearl Hair';
  48. $from = 'Alipearl';
  49. $fromDm='14582122378';
  50. $accessKeyId='LTAI5tECcoZZWAMi7PLxhNHf';
  51. $accessKeySecret='g3oyP3SNPbU8sQ8nwNo7eDrHlbH6lQ';
  52. break;
  53. case 3:
  54. $fromName = 'Westkiss Hair';
  55. $from = 'WestKissHair';
  56. $fromDm='14582071604';
  57. $accessKeyId='LTAI5tQG2Dy2hCBz5jLF4Hs2';
  58. $accessKeySecret='B3qZ8C8asV7VQTioSCPYb262wuS0pT';
  59. break;
  60. case 4:
  61. $fromName = 'Wiggins Hair';
  62. $from = 'WigginsHair';
  63. $fromDm='14582061730';
  64. $accessKeyId='LTAI5tD31ApgijqwnZthM9SH';
  65. $accessKeySecret='NsEwR56E7qB8hBLBxkUqaZe4AahEyd';
  66. break;
  67. case 5:
  68. $fromName = 'Asteria Hair';
  69. $from= 'AsteriaHair';
  70. $fromDm='14582026788';
  71. $accessKeyId='LTAI5tD31ApgijqwnZthM9SH';
  72. $accessKeySecret='NsEwR56E7qB8hBLBxkUqaZe4AahEyd';
  73. break;
  74. case 7:
  75. $fromName = 'Yolissa Hair';
  76. $from = 'YolissaHair';
  77. $fromDm='14582065939';
  78. $accessKeyId='LTAI5tQG2Dy2hCBz5jLF4Hs2';
  79. $accessKeySecret='B3qZ8C8asV7VQTioSCPYb262wuS0pT';
  80. break;
  81. case 8:
  82. $fromName = 'Mellow Hair';
  83. $from = 'Mellow';
  84. $fromDm='13013071900';
  85. $accessKeyId='LTAI5tECcoZZWAMi7PLxhNHf';
  86. $accessKeySecret='g3oyP3SNPbU8sQ8nwNo7eDrHlbH6lQ';
  87. break;
  88. }
  89. $admin = new AdvertAdminAction();
  90. //查询所有的邮件模板
  91. $where = "where uid='{$_SESSION['user_infos']['id']}' and type=1 and status=1";
  92. $template_list = $admin->select_smstm_list($where);
  93. //查询所有的用户分组
  94. $where2 = "where uid='$uid' ";
  95. $group_list = $admin->select_sms_user_group($where2);
  96. /*if(!empty($_POST['group_name']) && $_POST['group_name']!='all'){
  97. $where3.=" and group_name='{$_POST['group_name']}'";
  98. }
  99. $customer_list = $admin->selesctCustomer($where3);*/
  100. /*if(!empty($_POST['group_name']) && $_POST['group_name']!='all'){
  101. $where3.=" and group_name='{$_POST['group_name']}'";
  102. $customer_list = $admin->selesctCustomer($where3);
  103. }elseif(!empty($_POST['group_name']) && $_POST['group_name']=='all'){
  104. $customer_list = $admin->selesctCustomer($where2);
  105. }
  106. $count = count($customer_list);
  107. //假设一次只能给100个人发,看需要发几次
  108. $c = 100;
  109. $p = ceil($count/100);//需要发总次数*/
  110. $where3 = "where uid='$uid' and is_block=0 and is_send=1 ";
  111. if (!empty($_POST['group_name'])) {
  112. if ($_POST['group_name'] != 'all') {
  113. $where3 .= " and group_name='{$_POST['group_name']}'";
  114. $customer_list = $admin->selesctSmsCustomer($where3);
  115. } elseif ($_POST['group_name'] == 'all') {
  116. $customer_list = $admin->selesctSmsCustomer($where2);
  117. }
  118. $count = count($customer_list);
  119. $c = 100;
  120. $p = ceil($count/100);
  121. }
  122. $send_type=1;
  123. if ($_POST['template_id']) {
  124. $id = $_POST['template_id'];
  125. $one_info = $admin->select_onesms_template($id);
  126. $content = str_replace("'", '', $one_info['msg_content']);
  127. for($i=1;$i<=$p;$i++){
  128. $min = $c*($i-1);
  129. $data = array();
  130. $x_smtpapi=array();
  131. $customer_list_now = array_slice($customer_list, $min, $c);
  132. foreach($customer_list_now as $key=>$list){
  133. $countryMobile = $this->getCountryMobile($list['country']);
  134. if($countryMobile==1){
  135. $data[$key]['from_name'] =$fromDm;
  136. }else{
  137. $data[$key]['from_name'] =$from;
  138. }
  139. $data[$key]['mobile'] =$countryMobile.$list['tel'];
  140. $appkey='FH1W2L97';
  141. $secretkey='OCio2JBh';
  142. if($uid==7){//--牛信云 yolissahair
  143. $x_smtpapi[] = $countryMobile.$list['tel'];
  144. $from=18332604755;
  145. $appkey='fm6S6TTz';
  146. $secretkey='PNQzoBIk';
  147. }
  148. if($uid==5){//--牛信云 asteriahair
  149. $x_smtpapi[] = $countryMobile.$list['tel'];
  150. $from=18332359525;
  151. $appkey='ss9jHs2r';
  152. $secretkey='XW7iy4uC';
  153. }
  154. if($uid==1){//--牛信云 alipearlhair
  155. $x_smtpapi[] = $countryMobile.$list['tel'];
  156. $from=18444795753;
  157. $appkey='qQcsCT7e';
  158. $secretkey='2Z9dyFyn';
  159. }
  160. if($uid==6){//--牛信云 supernovahair
  161. $x_smtpapi[] = $countryMobile.$list['tel'];
  162. $from=18444796463;
  163. $appkey='4CdNKjBj';
  164. $secretkey='lVd866Tx';
  165. }
  166. if($uid==3){//--牛信云 westkisshair
  167. $x_smtpapi[] = $countryMobile.$list['tel'];
  168. $from=18444797525;
  169. $appkey='MMoVdvdC';
  170. $secretkey='jlkPGrdi';
  171. }
  172. if($uid==4){//--牛信云 wigginshair
  173. $x_smtpapi[] = $countryMobile.$list['tel'];
  174. $from=18337593782;
  175. $appkey='t9Qse0Rs';
  176. $secretkey='xHw8EAIM';
  177. }
  178. }
  179. $params = array(
  180. 'to' => $data,
  181. 'template_id' => $id,
  182. 'uid' => $uid,
  183. 'accessKeyId' => $accessKeyId,
  184. 'accessKeySecret' => $accessKeySecret,
  185. 'template_body' => $content
  186. );
  187. if($uid==7||$uid==1||$uid==6||$uid==3||$uid==4||$uid==5){//--牛信云
  188. $send_type=2;
  189. if($uid==5){
  190. $params = array(
  191. 'appkey' => $appkey,
  192. 'secretkey' =>$secretkey,
  193. 'phone' => $x_smtpapi,
  194. 'content' => $content,
  195. // 'source_address' => $from,
  196. 'uid' => $uid
  197. );
  198. }else{
  199. $params = array(
  200. 'appkey' => $appkey,
  201. 'secretkey' =>$secretkey,
  202. 'phone' => $x_smtpapi,
  203. 'content' => $content,
  204. 'source_address' => $from,
  205. 'uid' => $uid
  206. );
  207. }
  208. }
  209. $params_arr[] = $params;
  210. }
  211. if($send_type==1){
  212. $apid=$accessKeyId;
  213. $apsecret=$accessKeySecret;
  214. }else{
  215. $apid=$appkey;
  216. $apsecret=$secretkey;
  217. }
  218. $fid=0;
  219. if($count>0){
  220. //$one_info['msg_content'],$_POST['group_name']
  221. $fid=$admin->add_sms_data_logs($uid,$uname,$_POST['group_name'],$one_info['msg_title'],$count,$send_type,$showtime,$datetime,$apid,$apsecret);
  222. }
  223. if($uid==7||$uid==1||$uid==6||$uid==3||$uid==4||$uid==5){
  224. $result = $admin->add_sms_data_queue_new($params_arr,$showtime,$datetime,$fid,$uid);
  225. }else{
  226. $result = $admin->add_sms_data_queue($params_arr,$showtime,$datetime,$fid);
  227. }
  228. if ($result) {
  229. $info = '短信已进入待发送队列';
  230. } else {
  231. $info = '短信发送失败';
  232. }
  233. header("Location:/?a=send_sms_admin&m=index&info=$info");
  234. exit();
  235. }
  236. $email = $admin->selectSmsTmpData();
  237. $this->assign('email_counts', $email[0]['ct']);
  238. $this->assign('group_list', $group_list);
  239. $this->assign('info', $info);
  240. $this->assign('template_list', $template_list);
  241. $this->display("index.html");
  242. }
  243. function query(){
  244. require_once (ONU_ROOT . "frame/Page.class.php");
  245. $admin = new AdvertAdminAction();
  246. $where = "where 1=1 ";
  247. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  248. $pageSize = 10;
  249. $n = ($page-1)*$pageSize;
  250. $pa = "";//查询参数
  251. $limit = " $n,$pageSize";
  252. $info = $_REQUEST['info'];
  253. $error = $_REQUEST['error'];
  254. $uname = $_SESSION['user_infos']['uname'];
  255. $list = $admin->select_smslog_list($where,$limit);
  256. $all_total = $admin->select_smslog_count($where);
  257. $p = new Page($all_total,$pageSize,$pa);
  258. $pp = $p->fpage();
  259. $send_array = array(
  260. '1' => '阿里',
  261. '2' => '牛信云',
  262. );
  263. $status_array = array(
  264. '1' => '已发送',
  265. '2' => '未发送',
  266. '3' => '已取消',
  267. );
  268. $new=array();
  269. $times=time();
  270. $where.=" and sendtime> $times and status is null ";
  271. $lists = $admin->select_smslog_list($where);
  272. $wnums=0;
  273. foreach ($lists as $ks=>$vs){
  274. $wnums=$wnums+$vs['count'];
  275. }
  276. foreach ($list as $k=>$v){
  277. $new[$k]=$v;
  278. $new[$k]['status']=1;
  279. $new[$k]['sendtime']=date('Y-m-d H:i:s',$v['sendtime']);
  280. if($v['sendtime']>time()){
  281. $new[$k]['status']=2;
  282. }
  283. if($v['status']==1){
  284. $new[$k]['status']=3;
  285. }
  286. }
  287. if ($_GET['id']) {
  288. $id=$_GET['id'];
  289. $wheres =" where b.fid={$id} " ;
  290. $totals = $admin->select_smslog_count_query($wheres);
  291. if($totals){
  292. $result =$admin->delete_smslog($id,$totals);
  293. if ($result) {
  294. $info = '取消成功';
  295. header("Location:/?a=send_sms_admin&m=query&info=$info");
  296. } else {
  297. $error = '取消失败';
  298. header("Location:/?a=send_sms_admin&m=query&error=$error");
  299. }
  300. }else{
  301. $error = '取消失败,没有待发送的短信';
  302. header("Location:/?a=send_sms_admin&m=query&error=$error");
  303. }
  304. exit();
  305. }
  306. $this->assign('status_array',$status_array);
  307. $this->assign('send_array',$send_array);
  308. $this->assign('wnums',$wnums);
  309. $this->assign('info',$info);
  310. $this->assign('error',$error);
  311. $this->assign('page',$page);
  312. $this->assign("show",$pp);
  313. $this->assign('list',$new);
  314. $this->assign('uname',$uname);
  315. $this->display('query.html');
  316. }
  317. function didquery(){
  318. require_once (ONU_ROOT . "frame/Page.class.php");
  319. $admin = new AdvertAdminAction();
  320. $where = "where 1=1 ";
  321. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  322. $pageSize = 10;
  323. $n = ($page-1)*$pageSize;
  324. $pa = "";//查询参数
  325. $limit = " $n,$pageSize";
  326. $info = $_REQUEST['info'];
  327. $error = $_REQUEST['error'];
  328. $uname = $_SESSION['user_infos']['uname'];
  329. $tel = trim($_REQUEST['tel']);
  330. if(!empty($tel)) {
  331. $where.=" and (mobile='$tel' or from_phone ='$tel' )";
  332. }
  333. $starttime = trim($_REQUEST['starttime']);
  334. if(!empty($starttime)) {
  335. $starttimes=strtotime($starttime);
  336. $where.=" and UNIX_TIMESTAMP(receive_time) >'{$starttimes}'";
  337. }
  338. $endtime = trim($_REQUEST['endtime']);
  339. if(!empty($endtime)) {
  340. $endtimes=strtotime($endtime);
  341. $where.=" and UNIX_TIMESTAMP(receive_time) <'{$endtimes}'";
  342. }
  343. $list = $admin->select_smsdidlog_list($where,$limit);
  344. $all_total = $admin->select_smsdidlog_count($where);
  345. $p = new Page($all_total,$pageSize,$pa);
  346. $pp = $p->fpage();
  347. $status_array = array(
  348. '1' => '正常',
  349. '2' => '禁用',
  350. );
  351. foreach ($list as $k=>$v){
  352. $new[$k]=$v;
  353. $new[$k]['uname']=$this->getName($admin,$v['uid']);
  354. }
  355. $this->assign('tel',$tel);
  356. $this->assign('starttime',$starttime);
  357. $this->assign('endtime',$endtime);
  358. $this->assign('status_array',$status_array);
  359. $this->assign('info',$info);
  360. $this->assign('error',$error);
  361. $this->assign('page',$page);
  362. $this->assign("show",$pp);
  363. $this->assign('list',$new);
  364. $this->assign('uname',$uname);
  365. $this->display('didquery.html');
  366. }
  367. public function export(){
  368. $admin = new AdvertAdminAction();
  369. $where = "where status=2 ";
  370. $starttime = trim($_REQUEST['starttime']);
  371. if(!empty($starttime)) {
  372. $starttimes=strtotime($starttime);
  373. $where.=" and UNIX_TIMESTAMP(receive_time) >'{$starttimes}'";
  374. }
  375. $endtime = trim($_REQUEST['endtime']);
  376. if(!empty($endtime)) {
  377. $endtimes=strtotime($endtime);
  378. $where.=" and UNIX_TIMESTAMP(receive_time) <'{$endtimes}'";
  379. }
  380. $list = $admin->select_smsdidlog_list($where);
  381. $new=array();
  382. foreach ($list as $k=>$v){
  383. $new[$k]=$v;
  384. $new[$k]['uname']=$this->getName($admin,$v['uid']);
  385. }
  386. $d = date('Y-m-d',time());
  387. $this->generateEXCEL($d."导出取消订阅客户数据",$new);
  388. }
  389. function generateEXCEL($filename = 'report',$data = ''){
  390. //引入PHPExcel相关文件
  391. require_once( ONU_ROOT . 'phpexcel/PHPExcel.php');
  392. require_once( ONU_ROOT . 'phpexcel/PHPExcel/IOFactory.php');
  393. require_once( ONU_ROOT . 'phpexcel/PHPExcel/Writer/Excel5.php');
  394. //新建
  395. $resultPHPExcel = new PHPExcel();
  396. //设置参数
  397. //设值
  398. $resultPHPExcel->getActiveSheet()->setCellValue('A1', '站点');
  399. $resultPHPExcel->getActiveSheet()->setCellValue('B1', 'mobile');
  400. //设置水平居中
  401. $resultPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  402. $resultPHPExcel->getActiveSheet()->getStyle('B1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  403. //设置水平居中
  404. $resultPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  405. $resultPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  406. $i = 2;
  407. foreach($data as $item){
  408. $resultPHPExcel->getActiveSheet()->setCellValue('A' . $i, $item['uname']);
  409. $resultPHPExcel->getActiveSheet()->setCellValue('B' . $i, $item['mobile']);
  410. //设置单元格宽度
  411. $resultPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(40);
  412. $resultPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(30);
  413. $resultPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(30);
  414. $resultPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(30);
  415. //设置水平居中
  416. $resultPHPExcel->getActiveSheet()->getStyle('A')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  417. $resultPHPExcel->getActiveSheet()->getStyle('B')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
  418. //设置行高度
  419. $resultPHPExcel->getActiveSheet()->getRowDimension("1")->setRowHeight(20);
  420. $resultPHPExcel->getActiveSheet()->getRowDimension($i)->setRowHeight(20);
  421. $i ++;
  422. }
  423. //设置导出文件名
  424. $xlsWriter = new PHPExcel_Writer_Excel5($resultPHPExcel);
  425. ob_end_clean();//清除缓冲区,避免乱码
  426. //ob_start(); ob_flush();
  427. header("Content-Type: application/vnd.ms-excel; charset=UTF-8");
  428. header("Content-Type: application/force-download");
  429. header("Content-Type: application/octet-stream");
  430. header("Content-Type: application/download");
  431. //header('Content-Disposition:inline;filename="'.$outputFileName.'"');
  432. header('Content-Disposition:attachment;filename='.'"'.$filename.'.xls"'); //可以对文件名进行处理
  433. header("Content-Transfer-Encoding: binary");
  434. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
  435. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
  436. header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
  437. header("Pragma: no-cache");
  438. $xlsWriter->save('php://output');
  439. exit;
  440. }
  441. public function getName($admin,$uid){
  442. $result = $admin->selectUserName($uid);
  443. return $result['uname'];
  444. }
  445. function querylists(){
  446. require_once (ONU_ROOT . "frame/Page.class.php");
  447. $admin = new AdvertAdminAction();
  448. $where = "where 1=1 ";
  449. if ($_GET['id']) {
  450. $where.=" and b.fid={$_GET['id']} " ;
  451. }
  452. $page = $_REQUEST['page']?$_REQUEST['page']:1;
  453. $pageSize = 10;
  454. $n = ($page-1)*$pageSize;
  455. $pa = "";//查询参数
  456. $limit = " $n,$pageSize";
  457. $info = $_REQUEST['info'];
  458. $error = $_REQUEST['error'];
  459. $uname = $_SESSION['user_infos']['uname'];
  460. $list = $admin->select_smslog_list_query($where,$limit);
  461. $all_total = $admin->select_smslog_count_query($where);
  462. $p = new Page($all_total,$pageSize,$pa);
  463. $pp = $p->fpage();
  464. $send_array = array(
  465. '1' => '阿里',
  466. '2' => '牛信云',
  467. );
  468. $status_array = array(
  469. '1' => '发送中',
  470. '2' => '未发送',
  471. );
  472. $new=array();
  473. foreach ($list as $k=>$v){
  474. $params = unserialize($v['params_json']);
  475. $new[$k]=$v;
  476. $new[$k]['status']=1;
  477. $new[$k]['sendtime']=date('Y-m-d H:i:s',$v['sendtime']);
  478. if($v['sendtime']>time()){
  479. $new[$k]['status']=2;
  480. }
  481. $new[$k]['count']=count($params['phone']);
  482. }
  483. $this->assign('status_array',$status_array);
  484. $this->assign('send_array',$send_array);
  485. $this->assign('info',$info);
  486. $this->assign('error',$error);
  487. $this->assign('page',$page);
  488. $this->assign("show",$pp);
  489. $this->assign('list',$new);
  490. $this->assign('uname',$uname);
  491. $this->display('querylists.html');
  492. }
  493. //过滤已加入分组美加用户州区号
  494. public function jinList(){
  495. $admin = new AdvertAdminAction();
  496. $where =" where is_send=1";
  497. $page=1;
  498. $pageSize=50;
  499. $city_code =$admin->selectCityCode() ;
  500. $new=array();
  501. foreach ($city_code as $v){
  502. $new[]=$v['code'];
  503. }
  504. do {
  505. try {
  506. $n = ($page-1)*$pageSize;
  507. $limit = " $n,$pageSize";
  508. $customer_list = $admin->selesctSmsCustomer($where,$limit);
  509. foreach ($customer_list as $vs){
  510. $countryMobile = $this->getCountryMobile($vs['country']);
  511. if($countryMobile==1){
  512. $tel=$this->checkMobileCode($vs['tel']);
  513. $is_send =$this->getSend($tel,$new);
  514. if($is_send==2){
  515. $admin->upCodeSmsCustomer($is_send,$vs['id'],$tel);
  516. }
  517. }
  518. }
  519. $page=$page+1;
  520. } catch (\Exception $e) {
  521. exit(1);
  522. }
  523. } while (is_array($customer_list) && !empty($customer_list));
  524. echo ' over~~';
  525. }
  526. public function checkMobileCode($mobile){
  527. $mobile= str_replace('-', '', $mobile);
  528. $mobile= str_replace('_', '', $mobile);
  529. $mobile= str_replace('(', '', $mobile);
  530. $mobile= str_replace(')', '', $mobile);
  531. $mobile= str_replace('+', '', $mobile);
  532. $mobile= str_replace(' ', '', $mobile);
  533. $mobile=trim($mobile);
  534. $frist =(int)substr($mobile, 0, 1 );
  535. $lenth=strlen($mobile);
  536. if($lenth==11&&$frist==1){//例:14696305087
  537. $mobile =substr($mobile , 2 , 10);
  538. }
  539. return $mobile;
  540. }
  541. public function getSend($mobile,$new)
  542. {
  543. $lenth=strlen($mobile);
  544. $code =0;
  545. if($lenth==10){
  546. $code = substr($mobile , 0 , 3);
  547. }
  548. $is_send=2;
  549. if($code){
  550. if (in_array($code, $new)) {
  551. $is_send=1;
  552. }
  553. }
  554. return $is_send;
  555. }
  556. public function getCountryMobile($countryCode){
  557. $country = $countryCode;
  558. $countrys_en = [ "China", "Afghanistan", "Albania", "Algera",
  559. "Andorra", "Angola", "Anguilla", "Ascension",
  560. "Antigua and Barbuda", "Argentina", "Armenia", "Aruba",
  561. "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain",
  562. "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
  563. "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina",
  564. "Botwana", "Brazill", "Brunei", "Bulgaria", "Burkina Faso",
  565. "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde",
  566. "Cayman Islands", "Central African Republic", "Chad", "Chile",
  567. "Colombia", "Comoros", "Republic of the Congo",
  568. "Democratic Republic of the Congo", "Cook Islands", "Costa Rica",
  569. "Cote divoire", "Croatia", "Cuba", "Cyprus", "+Czech Republic",
  570. "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador",
  571. "Egypt", "EISalvador", "Estonia", "Ethiopia", "Faroe Islands",
  572. "Fiji", "Finland", "France", "French Guiana", "French Polynesia",
  573. "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar",
  574. "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam",
  575. "Guatemala", "Guinea", "Guernsey", "Guinea", "Guyana", "Haiti",
  576. "Honduras", "Hong Kong", "Myanmar", "Hungary", "Iceland", "Indea",
  577. "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel",
  578. "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazeakhstan",
  579. "Kenya", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia",
  580. "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein",
  581. "Lithuania", "Luxembourg", "Macao", "Macedonia", "Madagascar",
  582. "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Martinique",
  583. "Mauritania", "Mauritius", "Mayotte", "Mexico", "Moldova",
  584. "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco",
  585. "Mozambique", "Namibia", "Nepal", "Netherlands",
  586. "Netherlands Antillse", "New Caledonia", "NewZealand", "Nicaragua",
  587. "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palestinian",
  588. "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines",
  589. "Poland", "Portugal", "PuertoRico", "Qotar", "Reunion", "Romania",
  590. "Russia", "Rwanda", "Samoa Eastern", "Samoa Western", "San Marino",
  591. "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia",
  592. "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia",
  593. "South Africa", "Korea", "Spain", "SriLanka", "St Kitts and Nevis",
  594. "St.Lucia", "St.Vincent", "Sudan", "Suriname", "Swaziland",
  595. "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan",
  596. "Tanzania", "Thailand", "Timor Leste", "Togo", "Tonga",
  597. "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan",
  598. "Turks and Caicos Islands", "Uganda", "Ukraine",
  599. "United Arab Emirates", "United Kingdom", "USA", "Uruguay",
  600. "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands",
  601. "Yemen", "Zambia", "Zimbabwe" ];
  602. $countrys = array_keys($countrys_en,$country,true);
  603. if($countrys[0]){
  604. $countryMobile =$this->getCountryCode($countrys[0]);
  605. }else{
  606. $countryMobile ='+1';
  607. }
  608. $countryMobile = str_replace('+','',$countryMobile);
  609. return (int)$countryMobile;
  610. }
  611. //获取国家手机编号
  612. public function getCountryCode($countryCode){
  613. $codes = [ "+86", "+93", "+355", "+213", "+376", "+244", "+1264",
  614. "+247", "+1268", "+54", "+374", "+297", "+61", "+43", "+994",
  615. "+1242", "+973", "+880", "+1246", "+375", "+32", "+501", "+229",
  616. "+1441", "+975", "+591", "+387", "+267", "+55", "+673", "+359",
  617. "+226", "+257", "+855", "+237", "+1", "+238", "+1345", "+236",
  618. "+235", "+56", "+57", "+269", "+242", "+243", "+682", "+506",
  619. "+225", "+385", "+53", "+357", "+420", "+45", "+253", "+1767",
  620. "+1809", "+593", "+20", "+503", "+372", "+251", "+298", "+679",
  621. "+358", "+33", "+594", "+689", "+241", "+220", "+995", "+94",
  622. "+233", "+350", "+30", "+299", "+1473", "+590", "+1671", "+502",
  623. "+240", "+44", "+224", "+592", "+509", "+504", "+852", "+95",
  624. "+36", "+354", "+91", "+62", "+98", "+964", "+353", "+44", "+972",
  625. "+93", "+1876", "+81", "+44", "+962", "+7", "+254", "+383", "+965",
  626. "+996", "+856", "+371", "+961", "+266", "+231", "+218", "+423",
  627. "+370", "+352", "+853", "+389", "+261", "+265", "+60", "+960",
  628. "+223", "+356", "+596", "+222", "+230", "+262", "+52", "+373",
  629. "+377", "+976", "+382", "+1664", "+212", "+258", "+264", "+977",
  630. "+31", "+599", "+687", "+64", "+505", "+227", "+234", "+47",
  631. "+968", "+92", "+970", "+507", "+675", "+595", "+51", "+63", "+48",
  632. "+351", "+1", "+974", "+262", "+40", "+7", "+250", "+684", "+685",
  633. "+378", "+239", "+966", "+221", "+381", "+248", "+232", "+65",
  634. "+421", "+386", "+27", "+82", "+34", "+94", "+1869", "+1758",
  635. "+1784", "+249", "+597", "+268", "+46", "+41", "+963", "+886",
  636. "+992", "+255", "+66", "+670", "+228", "+676", "+1868", "+216",
  637. "+90", "+993", "+1649", "+256", "+380", "+971", "+44", "+1",
  638. "+598", "+998", "+678", "+58", "+84", "+1340", "+967", "+260",
  639. "+263" ];
  640. return $codes[$countryCode];
  641. }
  642. }