Send_sms_adminAction.class.php 30 KB

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