bianjunhui 3 lat temu
rodzic
commit
35310f668a

+ 68 - 9
application/lib/data/adminAction.php

@@ -2,14 +2,14 @@
 require_once(ONU_ROOT . 'application/lib/data/Base.class.php');
 
 class AdvertAdminAction extends BaseAction{
-		
+
 		//添加用户
 		public function addUser($uname,$pwd){
 			$sql    = "insert into ly_user(uname,pwd) values('{$uname}','{$pwd}')";
 			$result = $this->getDbEntity()->insert_sql($sql);
 			return $result;
 		}
-		
+
 		//登录
 		public function selectUser($uname,$pwd){
 			$sql    = "select * from ly_user where uname='$uname' and pwd='$pwd' limit 1";
@@ -150,7 +150,7 @@ class AdvertAdminAction extends BaseAction{
 			return $result;
 		}
 
-		public function selesctSmsCustomer($where,$limit){
+		public function selesctSmsCustomer($where,$limit=0){
 			if(!empty($limit)){
 				$sql    = "select *  from ly_sms_customer  $where order by id desc limit $limit ";
 			}else{
@@ -387,17 +387,35 @@ class AdvertAdminAction extends BaseAction{
 			}else{
 				$sql    = "select *  from ly_email_template  $where order by status asc,id desc";
 			}
-
 			$result = $this->getDbEntity()->query($sql);
 			return $result;
 		}
 
+        //短信模板列表
+        public function select_smstm_list($where,$limit=0){
+
+            if(!empty($limit)){
+                $sql    = "select *  from ly_sms_template  $where order by status asc,id desc limit $limit";
+            }else{
+                $sql    = "select *  from ly_sms_template  $where order by status asc,id desc";
+            }
+
+            $result = $this->getDbEntity()->query($sql);
+            return $result;
+        }
+
 		//查询邮件模板数量
 		public function select_msg_count($where){
 			$sql    = "select count(*) as count  from ly_email_template  $where ";
 			$result = $this->getDbEntity()->query($sql);
 			return $result[0]['count'];
 		}
+        //查询短信模板数量
+        public function select_smstm_count($where){
+            $sql    = "select count(*) as count  from ly_sms_template  $where ";
+            $result = $this->getDbEntity()->query($sql);
+            return $result[0]['count'];
+        }
 
 		//添加邮件模板
 		public function add_email_msg($data){
@@ -406,14 +424,25 @@ class AdvertAdminAction extends BaseAction{
 			$result = $this->getDbEntity()->insert_sql($sql);
 			return $result;
 		}
-
+        //添加短信模板
+        public function add_smstm_msg($data){
+            $sql    = "insert into ly_sms_template(msg_title,msg_content,status,add_time,`update_time`,uid,`type`) values
+                            ('{$data['msg_title']}','{$data['msg_content']}','{$data['status']}','{$data['add_time']}','{$data['update_time']}','{$data['uid']}','{$data['type']}')";
+            $result = $this->getDbEntity()->insert_sql($sql);
+            return $result;
+        }
 		//查询某一个邮件模板
 		public function select_one_template($id){
 			$sql    = "select *  from ly_email_template  where id='$id' ";
 			$result = $this->getDbEntity()->query($sql);
 			return $result[0];
 		}
-
+        //查询某一个短信模板
+        public function select_onesms_template($id){
+            $sql    = "select *  from ly_sms_template  where id='$id' ";
+            $result = $this->getDbEntity()->query($sql);
+            return $result[0];
+        }
 		//修改邮件模板
 		public function update_email_msg($data,$id,$uid){
 			$sql    = "update ly_email_template set msg_title='{$data['msg_title']}',msg_content='{$data['msg_content']}',
@@ -422,7 +451,14 @@ class AdvertAdminAction extends BaseAction{
 			$result = $this->getDbEntity()->execute_sql($sql);
 			return $result;
 		}
-
+        //修改短信模板
+        public function update_smstm_msg($data,$id,$uid){
+            $sql    = "update ly_sms_template set msg_title='{$data['msg_title']}',msg_content='{$data['msg_content']}',
+                            status = '{$data['status']}',update_time = '{$data['update_time']}'
+                            where id='$id' and uid='$uid'";
+            $result = $this->getDbEntity()->execute_sql($sql);
+            return $result;
+        }
 		//禁用邮件模板
 		public function deleteEmailTemplate($status,$id,$uid){
 			$sql    = "update ly_email_template set status='{$status}'
@@ -430,7 +466,13 @@ class AdvertAdminAction extends BaseAction{
 			$result = $this->getDbEntity()->execute_sql($sql);
 			return $result;
 		}
-
+        //禁用短信模板
+        public function deleteSmsTemplate($status,$id,$uid){
+            $sql    = "update ly_sms_template set status='{$status}'
+                            where id='$id' and uid='$uid'";
+            $result = $this->getDbEntity()->execute_sql($sql);
+            return $result;
+        }
 
 		//查询所有用户分组
 		public function select_user_group($where){
@@ -577,12 +619,29 @@ class AdvertAdminAction extends BaseAction{
 		    $result = $this->getDbEntity()->insert_sql($sql);
 		    return $result;
 		}
-		
+        //插入待发送短信参数数据
+        public function add_sms_data_queue($data){
+            $sql = 'INSERT INTO `ly_sms_data_tmp` (`params_json`) VALUES ';
+            foreach($data as $value){
+                $params_json = serialize($value);
+                $sql .= "('{$params_json}'),";
+            }
+            $sql = trim($sql, ',').';';
+            $result = $this->getDbEntity()->insert_sql($sql);
+            return $result;
+        }
 		//查询代发邮件数量
 		public function selectEmailTmpData(){
 		    $sql = 'SELECT COUNT(`id`) AS `ct` FROM `ly_email_data_tmp`;';
 		    $result = $this->getDbEntity()->query($sql);
 		    return $result;
 		}
+
+        //查询待发短信数量
+        public function selectSmsTmpData(){
+            $sql = 'SELECT COUNT(`id`) AS `ct` FROM `ly_sms_data_tmp`;';
+            $result = $this->getDbEntity()->query($sql);
+            return $result;
+        }
 	//end
 }

+ 224 - 0
application/module/ctrl/Send_sms_adminAction.class.php

@@ -0,0 +1,224 @@
+<?php
+/***
+ * User: jun_hy
+ * Date: 2022/7/5
+ * Time: 16:24
+ */
+/**
+ * 短信发送,
+ */
+
+require_once(ONU_ROOT . 'application/module/ctrl/Action.class.php');
+require_once(ONU_ROOT . 'application/lib/data/adminAction.php');
+
+header('content-Type: text/html; charset=utf-8');
+
+class Send_sms_adminAction extends Action
+{
+
+    public function __construct()
+    {
+        parent::__construct();
+        if (empty($_SESSION['mds_user'])) {
+            header("Location:/?a=index&m=admin_login");
+            exit();
+        }
+    }
+
+    public function index()
+    {
+        $info = $_REQUEST['info'];
+        $uid = $_SESSION['user_infos']['id'];
+        $fromName = '';
+        switch ($uid) {
+            case 6:
+                $fromName = 'SuperNova Hair';
+                break;
+            case 1:
+                $fromName = 'Alipearl Hair';
+                break;
+            case 3:
+                $fromName = 'Westkiss Hair';
+                break;
+            case 4:
+                $fromName = 'Wiggins Hair';
+                break;
+            case 5:
+                $fromName = 'Asteria Hair';
+                break;
+            case 7:
+                $fromName = 'Yolissa Hair';
+                break;
+            case 8:
+                $fromName = 'Mellow Hair';
+                break;
+        }
+        $admin = new AdvertAdminAction();
+        //查询所有的邮件模板
+        $where = "where uid='{$_SESSION['user_infos']['id']}' and type=1 and status=1";
+        $template_list = $admin->select_smstm_list($where);
+
+        //查询所有的用户分组
+        $where2 = "where uid='$uid' ";
+        $group_list = $admin->select_sms_user_group($where2);
+        /*if(!empty($_POST['group_name']) && $_POST['group_name']!='all'){
+            $where3.=" and group_name='{$_POST['group_name']}'";
+        }
+        $customer_list = $admin->selesctCustomer($where3);*/
+
+        /*if(!empty($_POST['group_name']) && $_POST['group_name']!='all'){
+            $where3.=" and group_name='{$_POST['group_name']}'";
+            $customer_list = $admin->selesctCustomer($where3);
+        }elseif(!empty($_POST['group_name']) && $_POST['group_name']=='all'){
+            $customer_list = $admin->selesctCustomer($where2);
+        }
+
+        $count = count($customer_list);
+
+        //假设一次只能给100个人发,看需要发几次
+        $c = 100;
+        $p = ceil($count/100);//需要发总次数*/
+        $where3 = "where uid='$uid' and is_block=0 ";
+        if (!empty($_POST['group_name'])) {
+            if ($_POST['group_name'] != 'all') {
+                $where3 .= " and group_name='{$_POST['group_name']}'";
+                $customer_list = $admin->selesctSmsCustomer($where3);
+            } elseif ($_POST['group_name'] == 'all') {
+                $customer_list = $admin->selesctSmsCustomer($where2);
+            }
+            $count = count($customer_list);
+            $c = 100;
+            $p = ceil($count/100);
+        }
+
+        if ($_POST['template_id']) {
+            $id = $_POST['template_id'];
+            $one_info = $admin->select_onesms_template($id);
+            $content = str_replace("'", '', $one_info['msg_content']);
+
+            for($i=1;$i<=$p;$i++){
+                $min = $c*($i-1);
+                $data = array();
+                $customer_list_now = array_slice($customer_list, $min, $c);
+                foreach($customer_list_now as $key=>$list){
+                    $countryMobile = $this->getCountryMobile($list['country']);
+                    $data['ymobile'][] =$list['tel'];
+                    $data['mobile'][] =$countryMobile.$list['tel'];
+                }
+                $params = array(
+                    'to' => $data,
+                    'template_id' => $id,
+                    'from_name' => $fromName,
+                    'uid' => $uid,
+                    'template_body' => $content
+                );
+                $params_arr[] = $params;
+            }
+            $result = $admin->add_sms_data_queue($params_arr);
+            if ($result) {
+                $info = '短信已进入待发送队列';
+            } else {
+                $info = '短信发送失败';
+            }
+            header("Location:/?a=send_sms_admin&m=index&info=$info");
+            exit();
+        }
+        $email = $admin->selectSmsTmpData();
+        $this->assign('email_counts', $email[0]['ct']);
+
+        $this->assign('group_list', $group_list);
+        $this->assign('info', $info);
+        $this->assign('template_list', $template_list);
+        $this->display("index.html");
+
+    }
+
+    public function getCountryMobile($countryCode){
+        $country = $countryCode;
+        $countrys_en = [ "China", "Afghanistan", "Albania", "Algera",
+            "Andorra", "Angola", "Anguilla", "Ascension",
+            "Antigua and Barbuda", "Argentina", "Armenia", "Aruba",
+            "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain",
+            "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
+            "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegovina",
+            "Botwana", "Brazill", "Brunei", "Bulgaria", "Burkina Faso",
+            "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde",
+            "Cayman Islands", "Central African Republic", "Chad", "Chile",
+            "Colombia", "Comoros", "Republic of the Congo",
+            "Democratic Republic of the Congo", "Cook Islands", "Costa Rica",
+            "Cote divoire", "Croatia", "Cuba", "Cyprus", "+Czech Republic",
+            "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador",
+            "Egypt", "EISalvador", "Estonia", "Ethiopia", "Faroe Islands",
+            "Fiji", "Finland", "France", "French Guiana", "French Polynesia",
+            "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar",
+            "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam",
+            "Guatemala", "Guinea", "Guernsey", "Guinea", "Guyana", "Haiti",
+            "Honduras", "Hong Kong", "Myanmar", "Hungary", "Iceland", "Indea",
+            "Indonesia", "Iran", "Iraq", "Ireland", "Isle of Man", "Israel",
+            "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazeakhstan",
+            "Kenya", "Kosovo", "Kuwait", "Kyrgyzstan", "Laos", "Latvia",
+            "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein",
+            "Lithuania", "Luxembourg", "Macao", "Macedonia", "Madagascar",
+            "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Martinique",
+            "Mauritania", "Mauritius", "Mayotte", "Mexico", "Moldova",
+            "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco",
+            "Mozambique", "Namibia", "Nepal", "Netherlands",
+            "Netherlands Antillse", "New Caledonia", "NewZealand", "Nicaragua",
+            "Niger", "Nigeria", "Norway", "Oman", "Pakistan", "Palestinian",
+            "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines",
+            "Poland", "Portugal", "PuertoRico", "Qotar", "Reunion", "Romania",
+            "Russia", "Rwanda", "Samoa Eastern", "Samoa Western", "San Marino",
+            "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia",
+            "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia",
+            "South Africa", "Korea", "Spain", "SriLanka", "St Kitts and Nevis",
+            "St.Lucia", "St.Vincent", "Sudan", "Suriname", "Swaziland",
+            "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan",
+            "Tanzania", "Thailand", "Timor Leste", "Togo", "Tonga",
+            "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan",
+            "Turks and Caicos Islands", "Uganda", "Ukraine",
+            "United Arab Emirates", "United Kingdom", "USA", "Uruguay",
+            "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands",
+            "Yemen", "Zambia", "Zimbabwe" ];
+        $countrys = array_keys($countrys_en,$country,true);
+        if($countrys[0]){
+            $countryMobile =$this->getCountryCode($countrys[0]);
+        }else{
+            $countryMobile ='+1';
+        }
+        $countryMobile = str_replace('+','',$countryMobile);
+        return (int)$countryMobile;
+    }
+
+    //获取国家手机编号
+    public function getCountryCode($countryCode){
+        $codes = [ "+86", "+93", "+355", "+213", "+376", "+244", "+1264",
+            "+247", "+1268", "+54", "+374", "+297", "+61", "+43", "+994",
+            "+1242", "+973", "+880", "+1246", "+375", "+32", "+501", "+229",
+            "+1441", "+975", "+591", "+387", "+267", "+55", "+673", "+359",
+            "+226", "+257", "+855", "+237", "+1", "+238", "+1345", "+236",
+            "+235", "+56", "+57", "+269", "+242", "+243", "+682", "+506",
+            "+225", "+385", "+53", "+357", "+420", "+45", "+253", "+1767",
+            "+1809", "+593", "+20", "+503", "+372", "+251", "+298", "+679",
+            "+358", "+33", "+594", "+689", "+241", "+220", "+995", "+94",
+            "+233", "+350", "+30", "+299", "+1473", "+590", "+1671", "+502",
+            "+240", "+44", "+224", "+592", "+509", "+504", "+852", "+95",
+            "+36", "+354", "+91", "+62", "+98", "+964", "+353", "+44", "+972",
+            "+93", "+1876", "+81", "+44", "+962", "+7", "+254", "+383", "+965",
+            "+996", "+856", "+371", "+961", "+266", "+231", "+218", "+423",
+            "+370", "+352", "+853", "+389", "+261", "+265", "+60", "+960",
+            "+223", "+356", "+596", "+222", "+230", "+262", "+52", "+373",
+            "+377", "+976", "+382", "+1664", "+212", "+258", "+264", "+977",
+            "+31", "+599", "+687", "+64", "+505", "+227", "+234", "+47",
+            "+968", "+92", "+970", "+507", "+675", "+595", "+51", "+63", "+48",
+            "+351", "+1", "+974", "+262", "+40", "+7", "+250", "+684", "+685",
+            "+378", "+239", "+966", "+221", "+381", "+248", "+232", "+65",
+            "+421", "+386", "+27", "+82", "+34", "+94", "+1869", "+1758",
+            "+1784", "+249", "+597", "+268", "+46", "+41", "+963", "+886",
+            "+992", "+255", "+66", "+670", "+228", "+676", "+1868", "+216",
+            "+90", "+993", "+1649", "+256", "+380", "+971", "+44", "+1",
+            "+598", "+998", "+678", "+58", "+84", "+1340", "+967", "+260",
+            "+263" ];
+        return $codes[$countryCode];
+    }
+}
+

+ 172 - 0
application/module/ctrl/Sms_template_adminAction.class.php

@@ -0,0 +1,172 @@
+<?php
+/***
+ * User: jun_hy
+ * Date: 2022/7/2
+ * Time: 8:39
+ * 邮件模版管理
+ */
+require_once( ONU_ROOT . 'application/module/ctrl/Action.class.php');
+require_once ( ONU_ROOT . 'application/lib/data/adminAction.php');
+class Sms_template_adminAction extends Action{
+
+    public function __construct(){
+        parent::__construct();
+        if(empty($_SESSION['mds_user'])){
+            header("Location:/?a=index&m=admin_login");
+            exit();
+        }
+//		$this->checkAdministratorRight('3');
+
+    }
+
+    function index(){
+        require_once (ONU_ROOT . "frame/Page.class.php");
+        $admin = new AdvertAdminAction();
+
+        $where = "where uid='{$_SESSION['user_infos']['id']}' and type=1 ";
+
+        $page     = $_REQUEST['page']?$_REQUEST['page']:1;
+        $pageSize = 5;
+        $n        = ($page-1)*$pageSize;
+        $pa       = "";//查询参数
+
+        $limit = " $n,$pageSize";
+
+        $info           = $_REQUEST['info'];
+        $error			= $_REQUEST['error'];
+        $uname          = $_SESSION['user_infos']['uname'];
+
+        $list  = $admin->select_smstm_list($where,$limit);
+        $all_total = $admin->select_smstm_count($where);
+
+        $p = new Page($all_total,$pageSize,$pa);
+        $pp = $p->fpage();
+
+        $status_array = array(
+            '1' => '开启',
+            '2' => '禁用',
+        );
+
+        $this->assign('status_array',$status_array);
+        $this->assign('info',$info);
+        $this->assign('error',$error);
+        $this->assign('page',$page);
+        $this->assign("show",$pp);
+        $this->assign('list',$list);
+        $this->assign('uname',$uname);
+        $this->display('index.html');
+    }
+
+
+    function add(){
+
+        $admin = new AdvertAdminAction();
+
+//		$_POST['msg_content'] = str_replace("\n","<br/>",$_POST['msg_content']);
+        $msg_content	= $_POST['sms_content'];
+
+        $data['uid'] = $_SESSION['user_infos']['id'];
+        $data['msg_title'] = addslashes($_POST['msg_title']);
+        $data['msg_content'] = addslashes($msg_content);
+        $data['status'] = $_POST['status'];
+        $data['add_time'] = time();
+        $data['update_time'] = time();
+        $data['type'] = 1;
+
+        if($_POST['msg_content']|| $_POST['msg_title']){
+
+            if(!empty($data['msg_title']) && !empty($data['msg_content']) ){
+
+                $add = $admin->add_smstm_msg($data);
+
+                if($add){
+                    $info = "添加短信模板成功";
+                    header("Location:/?a=sms_template_admin&m=index&info=$info");
+                    exit();
+                }else{
+                    $info = "添加失败";
+                }
+
+            }else{
+                $info = "模板标题、内容均不能为空";
+            }
+
+        }
+
+        $this->assign('data',$data);
+        $this->assign('info',$info);
+        $this->display('add.html');
+    }
+
+
+
+    function update(){
+
+        $admin = new AdvertAdminAction();
+
+        $id				= $_REQUEST['id'];
+
+        //$one_info 		= $admin->select_onesms_template($id);
+//		$one_info['msg_content'] = str_replace("<br/>","\n",$one_info['msg_content']);
+//		$_POST['msg_content'] = str_replace("\n","<br/>",$_POST['msg_content']);
+        $msg_content	= addslashes($_POST['sms_content']);
+
+        $data['msg_title'] = addslashes($_POST['msg_title']);
+        $data['msg_content'] = $msg_content;
+        $data['status'] = $_POST['status'];
+        $data['update_time'] = time();
+
+        if($_POST['msg_title'] || $_POST['msg_content']){
+
+            if(!empty($data['msg_title']) && !empty($data['msg_content']) ){
+
+                $update = $admin->update_smstm_msg($data, $id,$_SESSION['user_infos']['id']);
+
+                if($update){
+                    $info = "修改短信模板成功";
+                    header("Location:/?a=sms_template_admin&m=index&info=$info");
+                    exit();
+                }else{
+                    $info = "修改失败";
+                }
+
+            }else{
+                $info = "模板标题、内容均不能为空";
+            }
+
+        }
+
+        $one_info 		= $admin->select_onesms_template($id);
+//		$one_info['msg_content'] = str_replace("<br/>","\n",$one_info['msg_content']);
+//		$one_info['msg_content'] =  htmlspecialchars(stripslashes($one_info['msg_content']));
+
+        $this->assign('id',$id);
+        $this->assign('one_info',$one_info);
+        $this->assign('info',$info);
+        $this->display('update.html');
+
+    }
+
+    //删除就是改状态为禁用
+    public function delete(){
+
+        $admin = new AdvertAdminAction();
+
+        $id	   = $_REQUEST['id'];
+        $status = $_REQUEST['status'];
+
+        if(!empty($id)){
+            $delete = $admin->deleteSmsTemplate($status,$id,$_SESSION['user_infos']['id']);
+            $info = "禁用成功";
+        }else{
+            $error = "禁用失败";
+        }
+
+        header("Location:/?a=sms_template_admin&m=index&info=$info&error=$error");
+        exit();
+    }
+
+
+    //end class
+
+}

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

@@ -68,6 +68,28 @@
                         <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>
+                <li id="treeview10" class="treeview">
+                    <a href="#">
+                        <i class="fa fa-table"></i> <span>短信模板管理</span>
+                        <i class="fa fa-angle-left pull-right"></i>
+                    </a>
+                    <ul class="treeview-menu">
+                        <li class="email_template_left"><a href="/?a=sms_template_admin"><i class="fa fa-angle-double-right"></i>短信模板管理</a></li>
+                    </ul>
+                </li>
+
+                <li id="treeview11" class="treeview">
+                    <a href="#">
+                        <i class="fa fa-bar-chart-o"></i>
+                        <span>短信发送</span>
+                        <i class="fa fa-angle-left pull-right"></i>
+                    </a>
+                    <ul class="treeview-menu">
+                        <!--<li class="send_email1_left"><a href="/?a=send_email1_admin"><i class="fa fa-angle-double-right"></i> 普通发送</a></li>-->
+                        <li class="send_email2_left"><a href="/?a=send_sms_admin"><i class="fa fa-angle-double-right"></i> 模板发送</a></li>
+                    </ul>
+                </li>
+
                 <li id="treeview6" style="display:none;"  class="treeview">
                     <a href="#">
                         <i class="fa fa-th"></i> <span>EDM数据统计</span>

+ 106 - 0
application/module/view/send_sms_admin/index.html

@@ -0,0 +1,106 @@
+<{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>待发送邮件  <span style="color:red;"><{$email_counts}></span> 封</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="" id="form1">
+
+					<table class="table table-bordered" style="margin-top:15px;">
+
+						<tr>
+
+							<td>收件人</td>
+							<td>
+
+								<select name="group_name" id="group_name">
+									<option value="0">请选择</option>
+									<option value="all">所有客户</option>
+									<{foreach from=$group_list item=item}>
+									<option value="<{$item.name}>"><{$item.name}></option>
+									<{/foreach}>
+
+								</select>
+
+							</td>
+
+						</tr>
+
+						<tr>
+							<td>请选择短信模板</td>
+							<td>
+								<select name="template_id" id="template_id">
+									<option value="0">请选择</option>
+									<{foreach from=$template_list item=item}>
+									<option value="<{$item.id}>"><{$item.msg_title}></option>
+									<{/foreach}>
+								</select>
+							</td>
+						</tr>
+
+						<tr>
+							<td>&nbsp;</td>
+							<td >
+								<input type="button" onclick="to_submit();" value="提交" class="btn btn-info" style="width:120px;" />
+							</td>
+						</tr>
+
+					</table>
+				</form>
+
+
+			</div>
+
+		</div>
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+<style>
+	select{height:30px;}
+	.form-actions li{list-style:none;width:25px;float:left;padding-bottom:8px;padding-right:5px;}
+</style>
+<script>
+	$('#treeview11').addClass('active');
+	$(".send_sms_left").addClass('active');
+
+	function to_submit(){
+		var template_id = $('#template_id').val();
+		var group_name = $('#group_name').val();
+		if(template_id==0 || group_name==0){
+			alert("请选择模板和客户");
+		}else{
+			$('#form1').submit();
+		}
+	}
+</script>
+
+
+</body>
+</html>
+
+
+
+

+ 113 - 0
application/module/view/sms_template_admin/add.html

@@ -0,0 +1,113 @@
+<{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-danger alert-dismissable"><{$info}></div>
+			<{/if}>
+
+			<div id='main' class="form-actions">
+
+				<form method="post" action="" >
+					<table class="table table-bordered" style="margin-top:15px;">
+						<tr>
+
+							<td>模板标题</td>
+							<td>
+
+								<input type="text" name="msg_title" class="form-control" style="width:450px;" value="<{$data.msg_title}>" />
+							</td>
+
+						</tr>
+
+						<!--<tr>-->
+							<!--<td>模板内容</td>-->
+							<!--<td>-->
+								<!--<div>-->
+									<!--<textarea name="msg_content" id="msg_content" style="height: 255px; width: 30%; "><{$data.msg_content}></textarea>-->
+								<!--</div>-->
+
+							<!--</td>-->
+						<!--</tr>-->
+
+						<tr>
+							<td>模板内容</td>
+							<td>
+
+                                        <textarea id="sms_content" name="sms_content" rows="10" cols="60">
+
+                                        </textarea>
+
+							</td>
+						</tr>
+
+						<tr>
+							<td>状态</td>
+							<td>
+								<input type="radio" name="status" value="1" checked>&nbsp;开启
+								<input type="radio" name="status" value="2">&nbsp;禁用
+							</td>
+						</tr>
+
+						<tr>
+							<td>&nbsp;</td>
+							<td >
+								<input type="submit" value="提交" class="btn btn-info" style="width:120px;" />
+							</td>
+						</tr>
+
+					</table>
+				</form>
+
+
+			</div>
+
+		</div>
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+<!-- CK Editor -->
+<script src="static/AdminLTE/js/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
+
+<script type="text/javascript">
+	$(function() {
+		// Replace the <textarea id="msg_content"> with a CKEditor
+		// instance, using default configuration.
+		CKEDITOR.replace( 'msg_content', { allowedContent: true});
+		CKEDITOR.replace('msg_content');
+		//bootstrap WYSIHTML5 - text editor
+		$(".textarea").wysihtml5();
+	});
+</script>
+
+<style>
+	select{height:30px;}
+	.form-actions li{list-style:none;width:25px;float:left;padding-bottom:8px;padding-right:5px;}
+</style>
+<script>
+	$('#treeview10').addClass('active');
+	$(".sms_template_left").addClass('active');
+
+</script>
+
+</body>
+</html>

+ 92 - 0
application/module/view/sms_template_admin/index.html

@@ -0,0 +1,92 @@
+<{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 style="width:125px;">操作</th>
+					</tr>
+
+					<{foreach from=$list item=item}>
+					<tr>
+						<td><{$item.id}></td>
+						<td><{$item.msg_title}></td>
+						<td style="width:40%"><{$item.msg_content}></td>
+						<td><{$status_array[$item.status]}></td>
+						<td><{$uname}></td>
+						<td><{$item.update_time|date_format:'%Y-%m-%d'}></td>
+						<td><{$item.add_time|date_format:'%Y-%m-%d'}></td>
+						<td>
+							<a href="/?a=sms_template_admin&m=update&id=<{$item.id}>">修改</a>
+
+							<{if $item.status==1}>
+							<a href="/?a=sms_template_admin&m=delete&id=<{$item.id}>&status=2" style="margin-left:30px;" >禁用</a>
+							<{/if}>
+
+							<{if $item.status==2}>
+							<a href="/?a=sms_template_admin&m=delete&id=<{$item.id}>&status=1" style="margin-left:30px;" >启用</a>
+							<{/if}>
+
+						</td>
+					</tr>
+					<{/foreach}>
+				</table>
+
+				<{$show}>
+
+			</div>
+
+		</div>
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+<style>
+	select{height:30px;}
+</style>
+<script>
+	$('#treeview10').addClass('active');
+	$(".sms_template_left").addClass('active');
+</script>
+
+</body>
+</html>

+ 123 - 0
application/module/view/sms_template_admin/update.html

@@ -0,0 +1,123 @@
+<{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-danger alert-dismissable"><{$info}></div>
+			<{/if}>
+
+			<div id='main' class="form-actions">
+
+				<form method="post" action="" >
+
+					<input type="hidden" name="id" value="<{$id}>" />
+					<table class="table table-bordered" style="margin-top:15px;">
+
+						<tr>
+
+							<td>模板标题</td>
+							<td>
+
+								<input type="text" name="msg_title" class="form-control" style="width:450px;" value="<{$one_info.msg_title}>" />
+							</td>
+
+						</tr>
+
+						<!--<tr>-->
+							<!--<td>模板内容</td>-->
+							<!--<td>-->
+
+								<!--<div>-->
+								<!--<textarea name="msg_content"  id="msg_content" style="height: 255px; width: 30%; "><{$one_info.msg_content}></textarea>-->
+								<!--</div>-->
+
+							<!--</td>-->
+						<!--</tr>-->
+
+						<tr>
+							<td>模板内容</td>
+							<td>
+
+                                        <textarea id="sms_content" name="sms_content" rows="10" cols="60">
+											<{$one_info.msg_content}>
+                                        </textarea>
+
+							</td>
+						</tr>
+
+						<tr>
+							<td>状态</td>
+							<td>
+								<input type="radio" name="status" value="1" <{if $one_info.status==1}>checked<{/if}>  >&nbsp;开启
+								<input type="radio" name="status" value="2" <{if $one_info.status==2}>checked<{/if}> >&nbsp;禁用
+							</td>
+						</tr>
+
+
+						<tr>
+							<td>&nbsp;</td>
+							<td >
+								<input type="submit" value="提交" class="btn btn-info" style="width:120px;" />
+							</td>
+						</tr>
+
+					</table>
+				</form>
+
+
+			</div>
+
+		</div>
+
+	</section><!-- /.content -->
+</aside><!-- /.right-side -->
+</div><!-- ./wrapper -->
+
+
+<!-- CK Editor -->
+<script src="static/AdminLTE/js/plugins/ckeditor/ckeditor.js" type="text/javascript"></script>
+
+<script type="text/javascript">
+	$(function() {
+		// Replace the <textarea id="msg_content"> with a CKEditor
+		// instance, using default configuration.
+		CKEDITOR.replace( 'msg_content', { allowedContent: true});
+		CKEDITOR.replace('msg_content');
+		//bootstrap WYSIHTML5 - text editor
+		$(".textarea").wysihtml5();
+	});
+</script>
+
+<style>
+	select{height:30px;}
+	.form-actions li{list-style:none;width:25px;float:left;padding-bottom:8px;padding-right:5px;}
+</style>
+<script>
+	$('#treeview10').addClass('active');
+	$(".sms_template_left").addClass('active');
+
+</script>
+
+</body>
+</html>
+
+
+
+

+ 125 - 0
frame/alisms.php

@@ -0,0 +1,125 @@
+<?php
+/***
+ * User: jun_hy
+ * Date: 2022/7/6
+ * Time: 15:41
+ */
+function sendSmsali($phone,$template_body)
+{
+    $params = array();
+    $params["To"] = $phone;
+    $params["From"] = '13013071800';
+    $params["Message"] = $template_body;
+    $params['Type'] = "NOTIFY";
+    $content = request(
+        "dysmsapi.aliyuncs.com",
+        array_merge($params, array(
+            "RegionId" => "cn-hangzhou",
+            "Action" => "SendMessageToGlobe",
+            "Version" => "2017-05-25",
+        ))
+    );
+    if ($content->Code == 'OK') {
+        return $content;
+    } else {
+        return false;
+    }
+}
+/**
+ * 查询发送短信状态
+ * mobile            手机号码
+ * TemplateParam    参数数组
+ * TemplateCode        模版CODE
+ */
+function QuerySendDetails($phone,$bizId,$times)
+{
+    $params = array();
+    $params["PhoneNumber"] = $phone;
+    $params['BizId'] =  $bizId;
+    $params['SendDate'] =  $times;
+    $params['PageSize'] =  10;
+    $params['CurrentPage'] =  1;
+    $content = $this->request(
+        "dysmsapi.aliyuncs.com",
+        array_merge($params, array(
+            "RegionId" => "cn-hangzhou",
+            "Action" => "QuerySendDetails",
+            "Version" => "2017-05-25",
+        ))
+    );
+    if ($content->Code == 'OK') {
+        return $content->SmsSendDetailDTOs;
+    } else {
+        return false;
+    }
+}
+
+
+ function request($domain, $params, $security = false)
+{
+    $accessKeyId ='LTAI5tD31ApgijqwnZthM9SH';
+    $accessKeySecret = 'NsEwR56E7qB8hBLBxkUqaZe4AahEyd';
+    $apiParams = array_merge(array(
+        "SignatureMethod" => "HMAC-SHA1",
+        "SignatureNonce" => uniqid(mt_rand(0, 0xffff), true),
+        "SignatureVersion" => "1.0",
+        "AccessKeyId" => $accessKeyId,
+        "Timestamp" => gmdate("Y-m-d\TH:i:s\Z"),
+        "Format" => "JSON",
+    ), $params);
+    ksort($apiParams);
+
+    $sortedQueryStringTmp = "";
+    foreach ($apiParams as $key => $value) {
+        $sortedQueryStringTmp .= "&" . encode($key) . "=" . encode($value);
+    }
+
+    $stringToSign = "GET&%2F&" . encode(substr($sortedQueryStringTmp, 1));
+
+    $sign = base64_encode(hash_hmac("sha1", $stringToSign, $accessKeySecret . "&", true));
+
+    $signature = encode($sign);
+
+    $url = ($security ? 'https' : 'http') . "://{$domain}/?Signature={$signature}{$sortedQueryStringTmp}";
+
+    try {
+        $content = fetchContent($url);
+        return json_decode($content);
+    } catch (\Exception $e) {
+        return false;
+    }
+}
+
+ function encode($str)
+{
+    $res = urlencode($str);
+    $res = preg_replace("/\+/", "%20", $res);
+    $res = preg_replace("/\*/", "%2A", $res);
+    $res = preg_replace("/%7E/", "~", $res);
+    return $res;
+}
+
+ function fetchContent($url)
+{
+    $ch = curl_init();
+    curl_setopt($ch, CURLOPT_URL, $url);
+    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
+    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
+        "x-sdk-client" => "php/2.0.0"
+    ));
+
+    if (substr($url, 0, 5) == 'https') {
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
+    }
+
+    $rtn = curl_exec($ch);
+
+    if ($rtn === false) {
+        trigger_error("[CURL_" . curl_errno($ch) . "]: " . curl_error($ch), E_USER_ERROR);
+    }
+    curl_close($ch);
+
+    return $rtn;
+}

+ 43 - 0
jb/smsQueue.php

@@ -0,0 +1,43 @@
+<?php
+/***
+ * User: jun_hy
+ * Date: 2022/7/6
+ * Time: 16:11
+ */
+
+require_once('class.mysql.php');
+require_once('/www/wwwroot/edm.alipearl.net/frame/alisms.php');
+//require_once('../frame/alisms.php');
+set_time_limit(1800);
+$dbms = 'mysql';
+$host = 'localhost';
+$DB_Database = $dbName = 'edm_alipearl_net';
+$user = 'edm_alipearl_net';
+$pass = '6fP8Pf6dLdmFBYR4';
+$db_charset = "utf8";
+
+$db = new Daopdo($host, $user, $pass, $dbName, $db_charset);
+
+$sql['email_data'] = 'SELECT `id`,`params_json` FROM `ly_sms_data_tmp` ORDER BY `id` ASC LIMIT 1;';
+
+$email_data = $db->query($sql['email_data'], 'Row');
+if (empty($email_data)) {
+    exit(0);
+} else {
+    $sql['delQueueHead'] = "DELETE FROM `ly_sms_data_tmp` WHERE `id`='{$email_data['id']}';";
+    $db->query($sql['delQueueHead']);
+}
+$params = unserialize($email_data['params_json']);
+$mobile =$params['to']['mobile'];
+foreach ($mobile as $k=>$v){
+    sendSmsali($v,$params['template_body']);
+    $times=date('Y-m-d H:i:s',time());
+    $sql['insert_log'] = 'INSERT INTO `ly_send_sms_log` (`mobile`,`addtime`,`template_id`,`template_body`,`from_name`,`uid`) VALUES ';
+    $sql['insert_log'] .= "('{$v}','{$times}','{$params['template_id']}','{$params['template_body']}','{$params['from_name']}','{$params['uid']}');";
+    $insert_log = $db->query($sql['insert_log']);
+}
+
+
+
+
+