소스 검색

过滤美加州区号

bianjunhui 3 년 전
부모
커밋
89f1459e57

+ 14 - 2
application/lib/data/adminAction.php

@@ -92,8 +92,7 @@ class AdvertAdminAction extends BaseAction{
 		}
 
 		public function import_sms_customer($values){
-			$sql = "replace into ly_sms_customer(uname, country, tel, uid, group_name, is_block) values" . $values;
-			
+			$sql = "replace into ly_sms_customer(uname, country, tel, uid, group_name, is_block,is_send) values" . $values;
 			$result = $this->getDbEntity()->insert_sql($sql);
 			return $result;
 		}
@@ -683,5 +682,18 @@ class AdvertAdminAction extends BaseAction{
             $result = $this->getDbEntity()->query($sql);
             return $result;
         }
+
+        //查询美加州区号
+        public function selectCityCode(){
+            $sql    = "select code from ly_country_code ";
+            $result = $this->getDbEntity()->query($sql);
+            return $result;
+        }
+        //更改美加州区号用户状态
+        public function upCodeSmsCustomer($is_send,$id){
+            $sql    = "update ly_sms_customer set is_send='{$is_send}' where id='{$id}'";
+            $result = $this->getDbEntity()->execute_sql($sql);
+            return $result;
+        }
 	//end
 }

+ 41 - 1
application/module/ctrl/Send_sms_adminAction.class.php

@@ -94,7 +94,7 @@ class Send_sms_adminAction extends Action
         //假设一次只能给100个人发,看需要发几次
         $c = 100;
         $p = ceil($count/100);//需要发总次数*/
-        $where3 = "where uid='$uid' and is_block=0 ";
+        $where3 = "where uid='$uid' and is_block=0 and is_send=1 ";
         if (!empty($_POST['group_name'])) {
             if ($_POST['group_name'] != 'all') {
                 $where3 .= " and group_name='{$_POST['group_name']}'";
@@ -171,6 +171,46 @@ class Send_sms_adminAction extends Action
         $this->assign('template_list', $template_list);
         $this->display("index.html");
 
+    }
+    //过滤已加入分组美加用户州区号
+    public function jinList(){
+        $admin = new AdvertAdminAction();
+        $where =" where is_send=0";
+        $page=1;
+        $pageSize=50;
+        $city_code =$admin->selectCityCode();
+        $new=array();
+        foreach ($city_code as $v){
+            $new[]=$v['code'];
+        }
+        $is_send=1;
+        do {
+            try {
+                $n        = ($page-1)*$pageSize;
+                $limit = " $n,$pageSize";
+                $customer_list = $admin->selesctSmsCustomer($where,$limit);
+
+                foreach ($customer_list as $vs){
+                    $countryMobile = $this->getCountryMobile($vs['country']);
+                    if($countryMobile==1){
+                        $code = substr($vs['tel'] , 0 , 3);
+                        if (in_array($code, $new)) {
+                            $is_send=1;
+                        }else{
+                            $is_send=2;
+                        }
+                    }
+                    $admin->upCodeSmsCustomer($is_send,$vs['id']);
+                }
+                $page=$page+1;
+            } catch (\Exception $e) {
+                exit(1);
+            }
+        } while (is_array($customer_list) && !empty($customer_list));
+
+        echo ' over~~';
+
+
     }
 
     public function getCountryMobile($countryCode){

+ 53 - 3
application/module/ctrl/Sms_customer_list_adminAction.class.php

@@ -108,7 +108,44 @@ class Sms_customer_list_adminAction extends Action{
 		$this->assign("show",$pp);
 		$this->display("blacklist.html");
 	}
+    public function nosendList(){
 
+        require_once (ONU_ROOT . "frame/Page.class.php");
+
+        $admin = new AdvertAdminAction();
+
+        $info = $_REQUEST['info'];
+
+        $page     = $_REQUEST['page']?$_REQUEST['page']:1;
+        $pageSize    = isset($_REQUEST['pagesize'])?$_REQUEST['pagesize']:20;
+
+        $n        = ($page-1)*$pageSize;
+        $pa       = "";//查询参数
+        $pa='&pagesize='.$pageSize;
+        $limit = " $n,$pageSize";
+        $where = " where 1=1 ";
+
+        $tel = trim($_REQUEST['tel']);
+        if(!empty($tel)) {
+            $where.=" and tel='$tel'";
+        }
+
+        $where.=" and is_send=2";
+        $customer_list = $admin->selesctSmsCustomer($where,$limit);
+        $all_total = $admin->selectSmsCustomerCount($where);
+
+        $p = new Page($all_total,$pageSize,$pa);
+        $pp = $p->fpage();
+
+
+        $this->assign('tel',$tel);
+        $this->assign('list',$customer_list);
+        $this->assign('info',$info);
+        $this->assign('page',$page);
+        $this->assign('pagesize',$pageSize);
+        $this->assign("show",$pp);
+        $this->display("nosendList.html");
+    }
 	public function remove(){
 
 		$admin = new AdvertAdminAction();
@@ -248,6 +285,12 @@ class Sms_customer_list_adminAction extends Action{
 	public function import(){
 
 		$admin = new AdvertAdminAction();
+        $city_code =$admin->selectCityCode();
+        $new=array();
+        foreach ($city_code as $v){
+            $new[]=$v['code'];
+        }
+        $is_send=1;
 		$uid   = $_SESSION['user_infos']['id'];
 
 		if($_POST['to_import_user']=='yes'){
@@ -272,15 +315,22 @@ class Sms_customer_list_adminAction extends Action{
 						$tel = trim($array[1]);
 						$country = trim($array[2]);
 						$groupName = trim($array[3]);
-
 						if(in_array($tel, $blackListArr)) {
 							continue;
 						}
-
-						$values .= "('{$uname}', '{$country}', '{$tel}', {$uid}, '{$groupName}', 0),";
+						if($country=='United States'||$country=='Canada'){
+                            $code = substr($tel , 0 , 3);
+                            if (in_array($code, $new)) {
+                                $is_send=1;
+                            }else{
+                                $is_send=2;
+                            }
+                        }
+						$values .= "('{$uname}', '{$country}', '{$tel}', {$uid}, '{$groupName}', 0, '{$is_send}'),";
 					}
 
 				}
+
 				if($values) {
 					$values = trim($values, ",");
 					$insert = $admin->import_sms_customer($values);

+ 1 - 0
application/module/view/public/admin_navi.html

@@ -65,6 +65,7 @@
                         <li class="customer_list_left"><a href="/?a=sms_customer_list_admin"><i class="fa fa-angle-double-right"></i>短信客户管理列表</a></li>
                         <li class="user_group_left"><a href="/?a=user_smsgroup_admin"><i class="fa fa-angle-double-right"></i>短信客户分组</a></li>
                         <li class="user_group_left"><a href="/?a=sms_customer_list_admin&m=blackList"><i class="fa fa-angle-double-right"></i>短信黑名单列表</a></li>
+                        <li class="user_group_left"><a href="/?a=sms_customer_list_admin&m=nosendList"><i class="fa fa-angle-double-right"></i>不发送列表</a></li>
                         <li class="user_group_left"><a href="/?a=sms_customer_list_admin&m=remove"><i class="fa fa-angle-double-right"></i>短信客户删除</a></li>
                     </ul>
                 </li>

+ 142 - 0
application/module/view/sms_customer_list_admin/nosendList.html

@@ -0,0 +1,142 @@
+<{include file='../public/admin_header.html'}>
+<{include file='../public/admin_navi.html'}>
+<!-- Right side column. Contains the navbar and content of the page -->
+<aside class="right-side">
+	<!-- Content Header (Page header) -->
+	<section class="content-header">
+		<h1>
+			不发送列表
+			<small>Control panel</small>
+		</h1>
+		<ol class="breadcrumb">
+			<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
+			<li class="active">Blank page</li>
+		</ol>
+	</section>
+
+	<!-- Main content -->
+	<section class="content">
+		<div class="span9">
+
+			<{if $info}>
+			<div   class="alert alert-success  nodisplay"><{$info}></div>
+			<{/if}>
+
+			<div id='main' class="form-actions">
+				<form method="post" action="/?a=sms_customer_list_admin&m=nosendList" >
+					<div style="margin-left:20px;float:left;margin-bottom:20px;margin-right:20px;">
+						手机号码:<input type="text" name="tel" value="<{$tel}>" style="width:200px;">
+					</div>
+
+					<div style="clear:both;margin-left:20px;">
+						<input type="submit" class="btn btn-info" value="查询" style="clear:both;height: 30px; width: 260px; "/>
+					</div>
+				</form>
+				<br/><br/>
+
+				<form id="batch_delete" method="post" action="/?a=sms_customer_list_admin&m=batch_delete">
+
+					<table class="table table-mailbox" style="margin-top:15px;">
+
+						<tr>
+							<th style="width:80px;"><input type="checkbox"  id="check-all" />&nbsp;&nbsp;全选</th>
+							<th>ID</th>
+							<th>手机号</th>
+							<th>操作</th>
+						</tr>
+
+						<{foreach from=$list item=item}>
+						<tr>
+							<td>
+								<input type="checkbox"   name="id_array[]" value="<{$item.id}>" />
+							</td>
+							<td><{$item.id}></td>
+							<td><{$item.tel}></td>
+
+							<td>
+								<a href="/?a=sms_customer_list_admin&m=edit&id=<{$item.id}>">编辑</a>
+								<a onclick="to_confirm('<{$item.id}>','<{$item.tel}>')" style="float:right;margin-right:15px;cursor:pointer;">删除</a>
+							</td>
+						</tr>
+						<{/foreach}>
+					</table>
+				</form>
+				<{$show}>
+
+			</div>
+
+
+			<script src="static/AdminLTE/js/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js" type="text/javascript"></script>
+			<script src="static/AdminLTE/js/plugins/iCheck/icheck.min.js" type="text/javascript"></script>
+			<link href="static/AdminLTE/css/iCheck/minimal/blue.css" rel="stylesheet" type="text/css" />
+			<link href="static/AdminLTE/css/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
+			<script src="static/AdminLTE/js/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
+			<script type="text/javascript">
+				$(function() {
+
+					"use strict";
+
+					//iCheck for checkbox and radio inputs
+					$('input[type="checkbox"]').iCheck({
+						checkboxClass: 'icheckbox_minimal-blue',
+						radioClass: 'iradio_minimal-blue'
+					});
+
+					//When unchecking the checkbox
+					$("#check-all").on('ifUnchecked', function(event) {
+						//Uncheck all checkboxes
+						$("input[type='checkbox']", ".table-mailbox").iCheck("uncheck");
+					});
+					//When checking the checkbox
+					$("#check-all").on('ifChecked', function(event) {
+						//Check all checkboxes
+						$("input[type='checkbox']", ".table-mailbox").iCheck("check");
+					});
+
+				});
+			</script>
+
+			<script>
+				function toSubmit(){
+					var n = $("input:checked").length;
+
+					if (n<=1) {
+						alert("请选择要批量删除的黑名单吗");
+					}else{
+						if(confirm("确定要删除吗?")){
+							$('#batch_delete').submit();
+						}
+					}
+				}
+			</script>
+
+		</div>
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+<style>
+	select{height:30px;}
+</style>
+<script>
+	$('#treeview9').addClass('active');
+	$(".blacklist_left").addClass('active');
+
+	$(function() {
+		//Date range picker
+		$('#reservation').daterangepicker();
+
+	});
+</script>
+<script>
+	function to_confirm(id, tel){
+		if(confirm("确定要删除手机号 "+tel+" 吗?"))
+		{
+			window.location.href = "/?a=sms_customer_list_admin&m=delete&id="+id;
+		}
+	}
+</script>
+
+</body>
+</html>