| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647 | <?phprequire_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";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}				//查询用户,通过uname		public function selectUserByName($uname){			$sql    = "select * from ly_user where uname='$uname' limit 1";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}				//查询所有用户		public function selectAllUser(){			$sql    = "select * from ly_user ";			$result = $this->getDbEntity()->query($sql);			return $result;		}				//查询属于部门领导的用户		public function selectHeaderUser(){			$sql    = "select id,uname from ly_user where role=2";			$result = $this->getDbEntity()->query($sql);			return $result;		}				//修改用户密码		public function updateUserPwd($uname,$pwd){			$sql    = "update ly_user set pwd='{$pwd}' where uname='{$uname}'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}				//修改用户权限		public function updateUserPersission($uname,$persission){			$sql    = "update ly_user set permission='{$persission}' where uname='{$uname}'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}				//修改用户角色及直属领导		public function updateUserRole($data){			$sql    = "update ly_user set role='{$data['role']}',header_uid='{$data['header_uid']}' where uname='{$data['uname']}'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}		//删除用户		public function deleteUser($uname){			$sql    = "delete from ly_user where uname='{$uname}'";				$result = $this->getDbEntity()->query($sql);			return $result;		}		//查询所有的图片		public function selectAllImages(){			$sql    = "select * from ly_smt_images ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//导入客户,添加客户信息		public function add_customer($data){			$sql    = "insert into ly_customer(email,uname,country,city,tel,uid,add_time,group_name) values						('{$data['email']}','{$data['uname']}','{$data['country']}','{$data['city']}','{$data['tel']}','{$data['uid']}','{$data['add_time']}','{$data['group_name']}')";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}		public function add_sms_customer($data){			$sql = "replace into ly_sms_customer(uname, country, tel, uid, group_name) values				('{$data['uname']}','{$data['country']}','{$data['tel']}','{$data['uid']}','{$data['group_name']}')";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}		public function import_sms_customer($values){			$sql = "replace into ly_sms_customer(uname, country, tel, uid, group_name, is_block) values" . $values;						$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}    		//导入客户,批量添加客户信息		public function addpl_customer($data){			$sql    = "insert into ly_customer(email,uname,country,city,tel,uid,add_time,group_name) values ";			foreach ($data as $k => $v) {				$sql    .= "(\"{$v['email']}\",\"{$v['uname']}\",\"{$v['country']}\",\"{$v['city']}\",\"{$v['tel']}\",\"{$v['uid']}\",\"{$v['add_time']}\",\"{$v['group_name']}\"),";			}			$sql = substr($sql,0,-1);			$sql .= ";";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}		//导入黑名单,添加黑名单信息		public function add_blacklist($data){			$sql    = "insert into ly_blacklist(email,uid,add_time) values							('{$data['email']}','{$data['uid']}','{$data['add_time']}')";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}		public function selectCustomerCount($where){			$sql    = "select count(*) as count  from ly_customer  $where  ";			$result = $this->getDbEntity()->query($sql);			return $result[0]['count'];		}		public function selectSmsCustomerCount($where){			$sql    = "select count(*) as count  from ly_sms_customer  $where  ";			$result = $this->getDbEntity()->query($sql);			return $result[0]['count'];		}		public function selectBlacklistCount($where){			$sql    = "select count(*) as count  from ly_blacklist  $where  ";			$result = $this->getDbEntity()->query($sql);			return $result[0]['count'];		}	//查询所有客户		public function selesctCustomer($where,$limit){			if(!empty($limit)){				$sql    = "select *  from ly_customer  $where order by id desc limit $limit ";			}else{				$sql    = "select *  from ly_customer  $where order by id desc ";			}			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function selesctSmsCustomer($where,$limit=0){			if(!empty($limit)){				$sql    = "select *  from ly_sms_customer  $where order by id desc limit $limit ";			}else{				$sql    = "select *  from ly_sms_customer  $where order by id desc ";			}			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function selectSmsBlackList($uid) {			$sql = "select tel from ly_sms_customer where is_block=1 and uid=$uid order by id desc ";			$result = $this->getDbEntity()->query($sql);			return $result;		}  		//查询UID下所有客户Email		public function selesctCustomerByUid($uid){			$sql    = "select email  from ly_customer where 1=1 and uid = $uid  ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//查询所有黑名单		public function selesctBlacklist($where,$limit){			if(!empty($limit)){				$sql    = "select *  from ly_blacklist  $where order by id desc limit $limit ";			}else{				$sql    = "select *  from ly_blacklist  $where order by id desc ";			}			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function selectAllBlack($uid){			$sql = "select email from ly_blacklist where uid=$uid";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//查询客户信息		public function selectOneCustomer($id){			$sql    = "select *  from ly_customer  where id='$id'  ";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		public function selectOneSmsCustomer($id){			$sql    = "select *  from ly_sms_customer  where id='$id'  ";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		//查询黑名单信息		public function selectOneBlack($id){			$sql    = "select *  from ly_blacklist  where id='$id'  ";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}	//根据邮箱查询客户信息		public function selectCustomerByEmail($email,$uid){			$sql    = "select *  from ly_customer  where email='$email' and uid='$uid'  ";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		public function selectCustomerByTel($tel, $uid){			$sql    = "select *  from ly_sms_customer  where tel='$tel' and uid='$uid'  ";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		//根据邮箱查询H黑名单信息		public function selectBlackByEmail($email,$uid){			$sql    = "select *  from ly_blacklist  where email='$email' and uid='$uid'  ";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		//编辑客户信息		public function updateCustomer($data,$id){			$sql    = "update ly_customer set email='{$data['email']}',uname='{$data['uname']}',group_name='{$data['group_name']}', 						country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}' 						where id='$id'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}		public function updateSmsCustomer($data,$id){			$sql    = "update ly_sms_customer set uname='{$data['uname']}',group_name='{$data['group_name']}', 						country = '{$data['country']}',tel='{$data['tel']}' 						where id='$id'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}		//编辑黑名单信息		public function updateBlack($data,$id){			$sql    = "update ly_blacklist set email='{$data['email']}'							where id='$id'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}		//编辑客户信息		public function updateCustomerByEmail($data){			$sql    = "update ly_customer set uname='{$data['uname']}',group_name='{$data['group_name']}',							country = '{$data['country']}',city = '{$data['city']}',tel='{$data['tel']}'							where uid='{$data['uid']}' and email='{$data['email']}'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		} 		 //批量更新客户用户组信息		public function updateCustomerGroupByEmail($data){			$sql = "insert into ly_im_data_tmp (sql_content) values ";			foreach ($data as $k => $v) {				$sql_content['tabname']   = "ly_customer";				$sql_content['exc']   = " update";				$sql_content['data']   = $v;				$sql .= "('".addslashes(serialize($sql_content))."'),";			}			$sql = substr($sql,0,-1);			$sql .= ";";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}		//删除客户信息		public function deleteCustomer($id,$uid){			$sql    = "delete  from ly_customer  where id='$id' and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function deleteSmsCustomer($id, $uid){			$sql    = "delete from ly_sms_customer  where id='$id' and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function deleteSmsCustomerByExcel($telsStr, $uid){			$sql    = "delete from ly_sms_customer  where tel in ($telsStr) and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//删除黑名单		public function deleteBlack($id,$uid){			$sql    = "delete  from ly_blacklist  where id='$id' and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//按客户分组删除客户信息		public function deleteCustomerByGroup($group_name,$uid){			$sql    = "delete  from ly_customer  where group_name='$group_name' and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function deleteSmsCustomerByGroup($group_name, $uid){			$sql    = "delete from ly_sms_customer  where group_name='$group_name' and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//删除多个分组的客户信息		public function deleteBatchCus($group_name,$uid){			$sql    = "delete  from ly_customer  where group_name in ($group_name) and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//批量删除客户信息		public function deleteBatchCustomer($id_array,$uid){			$sql    = "delete  from ly_customer  where id in ($id_array) and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function deleteBatchSmsCustomer($id_array, $uid){			$sql    = "delete from ly_sms_customer  where id in ($id_array) and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//批量删除黑名单		public function deleteBatchBlack($id_array,$uid){			$sql    = "delete  from ly_blacklist  where id in ($id_array) and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//批量删除用户分组		public function deleteBatchUserGroup($id_array,$uid){			$sql    = "delete  from ly_user_group  where id in ($id_array) and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function deleteBatchSmsUserGroup($id_array,$uid){			$sql    = "delete  from ly_sms_user_group  where id in ($id_array) and uid='$uid' ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//普通发送插入日志表  普通邮件发送日志表		public function inserEmail1Log($data){			$sql    = "insert into ly_send_email1_log(to_user,subject,content,replay_to,`time`,message,uid) values						('{$data['to']}','{$data['subject']}','{$data['html']}','{$data['replyto']}','{$data['time']}','{$data['message']}','{$data['uid']}')";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}		public function deleteBatchCustomerByEmail($id_array,$uid){			$sql    = "delete  from ly_customer  where email in ($id_array) and uid='$uid' ";					$result = $this->getDbEntity()->query($sql);			return $result;		}		//邮件模板列表		public function select_msg_list($where,$limit){			if(!empty($limit)){				$sql    = "select *  from ly_email_template  $where order by status asc,id desc limit $limit";			}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){			$sql    = "insert into ly_email_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 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']}', 						status = '{$data['status']}',update_time = '{$data['update_time']}' 						where id='$id' and uid='$uid'";			$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}' 						where id='$id' and uid='$uid'";			$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){			$sql    = "select * from ly_user_group  $where order by id desc";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//查询所有用户分组		public function select_sms_user_group($where){			$sql    = "select * from ly_sms_user_group  $where order by id desc";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//添加用户分组		public function add_user_group($data){			$sql    = "insert into ly_user_group(uid,`name`,add_time,update_time)					values('{$data['uid']}','{$data['name']}','{$data['add_time']}','{$data['update_time']}')";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}		public function add_sms_user_group($data){			$sql    = "insert into ly_sms_user_group(uid,`name`)					values('{$data['uid']}','{$data['name']}')";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}		//查询某个用户分组		public function select_one_user_group($id,$uid){			$sql    = "select * from ly_user_group where id='$id' and uid='$uid'";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		//查询多个用户分组		public function select_batch_user_group($in_array,$uid){			$sql    = "select * from ly_user_group where id in ($in_array) and uid='$uid'";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//判断客户分组		public function select_group_byName($group_name,$uid){			$sql    = "select * from ly_user_group where name='$group_name' and uid='$uid'";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		public function select_usergroup_byName($group_name,$uid){			$sql    = "select * from ly_sms_user_group where name='$group_name' and uid='$uid'";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		//修改用户分组		public function update_user_group($data, $id,$uid){			$sql    = "update ly_user_group set							`name` = '{$data['name']}',							update_time	   = '{$data['update_time']}'							where id='{$id}' and uid='$uid'";			$result = $this->getDbEntity()->execute_sql($sql);			return $result;		}		//查询分组用户的数量		public function select_usergroup_count($where){			$sql    = "select count(*) as count from ly_customer $where";			$result = $this->getDbEntity()->query($sql);			return $result[0];		}		//查询用户分组里的所有用户		public function select_usergroup_info($where,$limit){			if(!empty($limit)){				$sql    = "select * from ly_customer $where  order by add_time desc  limit $limit";			}else{				$sql    = "select * from ly_customer $where order by add_time desc";			}			$result = $this->getDbEntity()->query($sql);			return $result;		}		//删除用户分组		public function deleteUserGroupMsg($where){			$sql  = " delete from ly_user_group where $where";			$result = $this->getDbEntity()->query($sql);			return $result;		}		public function deleteSmsUserGroupMsg($where){			$sql  = " delete from ly_sms_user_group where $where";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//查询退信用户是否存在		public function select_ndr_user($where,$email){			$sql  = " select email from ly_ndr_user where $where and email='$email'";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//查询所有退信用户		public function selectAllNdrUser($uid){			$sql = "select email from ly_ndr_user where uid=$uid";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//插入退信用户		public function insert_ndr_user($data){			$sql    = "insert into ly_ndr_user(uid,email)					values('{$data['uid']}','{$data['email']}')";			$result = $this->getDbEntity()->insert_sql($sql);			return $result;		}    		//查询临时表数据		public function select_tmp_data(){			$sql  = " select id from ly_im_data_tmp ";			$result = $this->getDbEntity()->query($sql);			return $result;		}		//插入待发送邮件参数数据		public function add_email_data_queue($data){		    $sql = 'INSERT INTO `ly_email_data_tmp` (`params_json`) VALUES ';		    $params_json = '';		    foreach($data as $value){				$params_json = serialize($value);		        $sql .= "('{$params_json}'),";		    }		    		    $sql = trim($sql, ',').';';		    $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}
 |