瀏覽代碼

日志取消

bianjunhui 2 年之前
父節點
當前提交
8d6cee97ba

+ 30 - 3
application/lib/data/adminAction.php

@@ -443,6 +443,18 @@ class AdvertAdminAction extends BaseAction{
             $sql    = "select *  from ly_send_sms_log_count  $where order by sendtime desc,log_id desc ";
         }
 
+        $result = $this->getDbEntity()->query($sql);
+        return $result;
+    }
+    //短信发送列表
+    public function select_smslog_list_query($where,$limit=0){
+
+        if(!empty($limit)){
+            $sql    = "select a.* ,b.params_json from ly_send_sms_log_count as a inner join ly_sms_data_tmp_new as b on a.log_id=b.fid  $where order by a.sendtime desc,a.log_id desc limit $limit";
+        }else{
+            $sql    = "select a.*  from ly_send_sms_log_count as a inner join ly_sms_data_tmp_new as b on a.log_id=b.fid  $where order by a.sendtime desc,a.log_id desc ";
+        }
+
         $result = $this->getDbEntity()->query($sql);
         return $result;
     }
@@ -465,6 +477,21 @@ class AdvertAdminAction extends BaseAction{
             $result = $this->getDbEntity()->query($sql);
             return $result[0]['count'];
         }
+    //查询短信发送数量
+    public function select_smslog_count_query($where){
+        $sql    = "select count(*) as count from ly_send_sms_log_count as a inner join ly_sms_data_tmp_new as b on a.log_id=b.fid  $where  ";
+        $result = $this->getDbEntity()->query($sql);
+        return $result[0]['count'];
+    }
+
+    //删除短信发送
+    public function delete_smslog($id,$totals){
+        $sql1    = "DELETE FROM `ly_sms_data_tmp_new` WHERE `fid`='{$id}'  ";
+        $this->getDbEntity()->query($sql1);
+        $sql2    = "update ly_send_sms_log_count set status=1,nosend='{$totals}' WHERE `log_id`='{$id}'";
+        $this->getDbEntity()->query($sql2);
+        return true;
+    }
 		//添加邮件模板
 		public function add_email_msg($data){
 			$sql    = "insert into ly_email_template(msg_title,msg_content,status,add_time,`update_time`,uid,`type`) values
@@ -711,11 +738,11 @@ class AdvertAdminAction extends BaseAction{
             return $result;
         }
         //插入待发送短信参数数据--牛信云
-        public function add_sms_data_queue_new($data,$showtime,$datetime){
-            $sql = 'INSERT INTO `ly_sms_data_tmp_new` (`params_json`,`sendtime`,`showtime`) VALUES ';
+        public function add_sms_data_queue_new($data,$showtime,$datetime,$fid){
+            $sql = 'INSERT INTO `ly_sms_data_tmp_new` (`params_json`,`sendtime`,`showtime`,`fid`) VALUES ';
             foreach($data as $value){
                 $params_json = serialize($value);
-                $sql .= "('{$params_json}','{$datetime}','{$showtime}'),";
+                $sql .= "('{$params_json}','{$datetime}','{$showtime}','{$fid}'),";
             }
             $sql = trim($sql, ',').';';
             $result = $this->getDbEntity()->insert_sql($sql);

+ 83 - 4
application/module/ctrl/Send_sms_adminAction.class.php

@@ -226,14 +226,15 @@ class Send_sms_adminAction extends Action
                 $apid=$appkey;
                 $apsecret=$secretkey;
             }
+            $fid=0;
             if($count>0){
                 //$one_info['msg_content'],$_POST['group_name']
-                $admin->add_sms_data_logs($uid,$uname,$_POST['group_name'],$one_info['msg_title'],$count,$send_type,$showtime,$datetime,$apid,$apsecret);
+                $fid=$admin->add_sms_data_logs($uid,$uname,$_POST['group_name'],$one_info['msg_title'],$count,$send_type,$showtime,$datetime,$apid,$apsecret);
             }
             if($uid==7||$uid==1||$uid==6||$uid==3||$uid==4){
-                $result = $admin->add_sms_data_queue_new($params_arr,$showtime,$datetime);
+                $result = $admin->add_sms_data_queue_new($params_arr,$showtime,$datetime,$fid);
             }else{
-                $result = $admin->add_sms_data_queue($params_arr,$showtime,$datetime);
+                $result = $admin->add_sms_data_queue($params_arr,$showtime,$datetime,$fid);
             }
 
             if ($result) {
@@ -259,7 +260,7 @@ class Send_sms_adminAction extends Action
         $admin = new AdvertAdminAction();
         $where = "where  1=1 ";
         $page     = $_REQUEST['page']?$_REQUEST['page']:1;
-        $pageSize = 5;
+        $pageSize = 10;
         $n        = ($page-1)*$pageSize;
         $pa       = "";//查询参数
         $limit = " $n,$pageSize";
@@ -277,6 +278,7 @@ class Send_sms_adminAction extends Action
         $status_array = array(
             '1' => '已发送',
             '2' => '未发送',
+            '3' => '已取消',
         );
         $new=array();
         $times=time();
@@ -293,6 +295,31 @@ class Send_sms_adminAction extends Action
             if($v['sendtime']>time()){
                 $new[$k]['status']=2;
             }
+            if($new[$k]['status']==2){
+                if($v['status']==1){
+                    $new[$k]['status']=3;
+                }
+            }
+        }
+        if ($_GET['id']) {
+            $id=$_GET['id'];
+            $wheres =" where b.fid={$id} " ;
+            $totals = $admin->select_smslog_count_query($wheres);
+            if($totals){
+                $result =$admin->delete_smslog($id,$totals);
+                if ($result) {
+                    $info = '取消成功';
+                    header("Location:/?a=send_sms_admin&m=query&info=$info");
+                } else {
+                    $error = '取消失败';
+                    header("Location:/?a=send_sms_admin&m=query&error=$error");
+                }
+            }else{
+                $error = '取消失败,没有待发送的短信';
+                header("Location:/?a=send_sms_admin&m=query&error=$error");
+            }
+
+            exit();
         }
         $this->assign('status_array',$status_array);
         $this->assign('send_array',$send_array);
@@ -305,6 +332,58 @@ class Send_sms_adminAction extends Action
         $this->assign('uname',$uname);
         $this->display('query.html');
     }
+
+    function querylists(){
+        require_once (ONU_ROOT . "frame/Page.class.php");
+        $admin = new AdvertAdminAction();
+        $where = "where  1=1 ";
+        if ($_GET['id']) {
+            $where.=" and b.fid={$_GET['id']} " ;
+        }
+        $page     = $_REQUEST['page']?$_REQUEST['page']:1;
+        $pageSize = 10;
+        $n        = ($page-1)*$pageSize;
+        $pa       = "";//查询参数
+        $limit = " $n,$pageSize";
+        $info           = $_REQUEST['info'];
+        $error			= $_REQUEST['error'];
+        $uname          = $_SESSION['user_infos']['uname'];
+        $list  = $admin->select_smslog_list_query($where,$limit);
+        $all_total = $admin->select_smslog_count_query($where);
+        $p = new Page($all_total,$pageSize,$pa);
+        $pp = $p->fpage();
+        $send_array = array(
+            '1' => '阿里',
+            '2' => '牛信云',
+        );
+        $status_array = array(
+            '1' => '发送中',
+            '2' => '未发送',
+        );
+        $new=array();
+        foreach ($list as $k=>$v){
+            $params = unserialize($v['params_json']);
+            $new[$k]=$v;
+            $new[$k]['status']=1;
+            $new[$k]['sendtime']=date('Y-m-d H:i:s',$v['sendtime']);
+            if($v['sendtime']>time()){
+                $new[$k]['status']=2;
+            }
+            $new[$k]['count']=count($params['phone']);
+        }
+        $this->assign('status_array',$status_array);
+        $this->assign('send_array',$send_array);
+        $this->assign('info',$info);
+        $this->assign('error',$error);
+        $this->assign('page',$page);
+        $this->assign("show",$pp);
+        $this->assign('list',$new);
+        $this->assign('uname',$uname);
+        $this->display('querylists.html');
+    }
+
+
+
     //过滤已加入分组美加用户州区号
     public function jinList(){
         $admin = new AdvertAdminAction();

+ 5 - 0
application/module/view/send_sms_admin/query.html

@@ -44,6 +44,7 @@
 						<th >定时发送时间</th>
 						<th>发送状态</th>
 						<th>发送方式</th>
+						<th>操作</th>
 					</tr>
 
 					<{foreach from=$list item=item}>
@@ -58,6 +59,10 @@
 						<td <{if $item.status==2}>style="color:red;"<{/if}>><{$status_array[$item.status]}></td>
 						<td <{if $item.send_type==2}><{/if}>><{$send_array[$item.send_type]}></td>
 
+						<td>
+							<a href="/?a=send_sms_admin&m=query&id=<{$item.log_id}>">取消</a>
+							<a href="/?a=send_sms_admin&m=querylists&id=<{$item.log_id}>">查看</a>
+						</td>
 					</tr>
 					<{/foreach}>
 				</table>

+ 83 - 0
application/module/view/send_sms_admin/querylists.html

@@ -0,0 +1,83 @@
+<{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  "><{$info}></div>
+			<{/if}>
+
+			<{if $error}>
+			<div   class="alert alert-danger alert-dismissable"><{$error}></div>
+			<{/if}>
+
+			<div id='main' class="form-actions">
+
+				<!--<a href="/?a=sms_template_admin&m=add" style="font-weight:bold;text-decoration:underline;">添加短信模板</a>-->
+
+				<div style="height:20px;"></div>
+
+				<table class="table table-striped" style="margin-top:15px;">
+					<tr>
+						<th>ID</th>
+						<th>创建人</th>
+						<th >发送标题</th>
+						<th>客户分组</th>
+						<th>发送数量</th>
+						<th>添加时间</th>
+						<th >定时发送时间</th>
+						<th>发送状态</th>
+						<th>发送方式</th>
+					</tr>
+
+					<{foreach from=$list item=item}>
+					<tr>
+						<td><{$item.log_id}></td>
+						<td><{$item.uname}></td>
+						<td><{$item.template_body}></td>
+						<td><{$item.group_name}></td>
+						<td><{$item.count}></td>
+						<td><{$item.addtime}></td>
+						<td><{$item.sendtime}></td>
+						<td <{if $item.status==2}>style="color:red;"<{/if}>><{$status_array[$item.status]}></td>
+						<td <{if $item.send_type==2}><{/if}>><{$send_array[$item.send_type]}></td>
+					</tr>
+					<{/foreach}>
+				</table>
+
+				<{$show}>
+
+			</div>
+
+		</div>
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+<style>
+	select{height:30px;}
+</style>
+<script>
+	$('#treeview11').addClass('active');
+	$(".send_sms_admin").addClass('active');
+</script>
+
+</body>
+</html>