You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
263 lines
6.7 KiB
263 lines
6.7 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YFCMF [ WE CAN DO IT MORE SIMPLE ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2015-2016 http://www.rainfer.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: rainfer <81818832@qq.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\admin\controller;
|
|
|
|
use think\Db;
|
|
use app\admin\model\Agency;
|
|
|
|
class Sms extends Base
|
|
{
|
|
/**
|
|
* 列表
|
|
*/
|
|
public function index()
|
|
{
|
|
$kind=input("kind");
|
|
$this->assign('kind',$kind);
|
|
$search_name=input('search_name');
|
|
$this->assign('search_name',$search_name);
|
|
$map=array();
|
|
if($kind)$map['sms_type']=$kind;
|
|
if($search_name){
|
|
$map['sms_content|sms_code']= array('like',"%".$search_name."%");
|
|
}
|
|
$admin_list=Db::name('smslog')->where($map)->order('sms_id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
|
|
$page = $admin_list->render();
|
|
$this->assign('list',$admin_list);
|
|
$this->assign('page',$page);
|
|
$types=['forget'=>'忘记密码','reg'=>'注册','activitys'=>'活动'];
|
|
$this->assign('types',$types);
|
|
return $this->fetch();
|
|
}
|
|
public function ajaxmem(){
|
|
$member_list =Db::name('member_list')->field("member_list_id,member_list_username,member_list_tel,member_list_nickname")->where(['user_status'=>1])->order('member_list_id desc')->paginate(60,false,['query'=>get_query()]);
|
|
return json($member_list);
|
|
}
|
|
/**
|
|
* 添加
|
|
*/
|
|
public function add()
|
|
{
|
|
$kind=input("kind");
|
|
$this->assign('kind',$kind);
|
|
$tpls=db('smstpl')->where(['status'=>1])->select();
|
|
$tags=db('smstag')->where(['status'=>1])->select();
|
|
$this->assign('tpls',$tpls);
|
|
$this->assign('tags',$tags);
|
|
return $this->fetch();
|
|
}
|
|
/**
|
|
* 添加操作
|
|
*/
|
|
public function runadd()
|
|
{
|
|
$kind=input("kind");
|
|
$tels=input('sms_tel');
|
|
$tels=nl2br($tels);
|
|
$tels=explode("<br />", $tels);
|
|
// 启动事务
|
|
Db::startTrans();
|
|
$query=true;
|
|
try{
|
|
foreach ($tels as $teline){
|
|
$teline=trim($teline);
|
|
if($teline){
|
|
$teline=explode(";", $teline);
|
|
foreach ($teline as $tel){
|
|
$tel=trim($tel);
|
|
if($tel){
|
|
$data=[];
|
|
$data['kind']=$kind;
|
|
$data['sms_type']=$kind;
|
|
$data['sms_state']=input('sms_state',-1);
|
|
$data['sms_txt']=input('sms_txt');
|
|
$data['sms_tel']=$tel;
|
|
$data['sms_time']=time();
|
|
$res=Db::name('smslog')->insert($data);
|
|
if(!$res){
|
|
$query=false;
|
|
Db::rollback();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Db::commit();
|
|
} catch (\Exception $e) {
|
|
// 回滚事务
|
|
Db::rollback();
|
|
}
|
|
if($query){
|
|
$this->success('添加成功',url('index'));
|
|
}else{
|
|
$this->error('添加失败',url('index'));
|
|
}
|
|
}
|
|
/**
|
|
* 修改
|
|
*/
|
|
public function edit()
|
|
{
|
|
$kind=input("kind");
|
|
$this->assign('kind',$kind);
|
|
$list=Db::name('smslog')->find(input('id'));
|
|
if($list['sms_content']){
|
|
$list['sms_content']=json_decode($list['sms_content'],true);
|
|
}
|
|
$this->assign('list',$list);
|
|
|
|
return $this->fetch();
|
|
}
|
|
/**
|
|
* 修改
|
|
*/
|
|
public function check()
|
|
{
|
|
$kind=input("kind");
|
|
$this->assign('kind',$kind);
|
|
$list=Db::name('smslog')->find(input('id'));
|
|
if($list['sms_content']){
|
|
$list['sms_content']=json_decode($list['sms_content'],true);
|
|
}
|
|
$this->assign('list',$list);
|
|
|
|
return $this->fetch();
|
|
}
|
|
/**
|
|
* 修改操作
|
|
*/
|
|
public function runedit()
|
|
{
|
|
$kind=input("kind");
|
|
$this->assign('kind',$kind);
|
|
|
|
$data=[];
|
|
$data['sms_id']=input('id');
|
|
$state=input('sms_state');
|
|
if($state!='')$data['sms_state']=$state;
|
|
$data['sms_txt']=input('sms_txt');
|
|
$data['sms_tel']=input('sms_tel');
|
|
|
|
$rst=Db::name('smslog')->update($data);
|
|
if($rst!==false){
|
|
$this->success('修改成功',url('index'));
|
|
}else{
|
|
$this->error('修改失败',url('index'));
|
|
}
|
|
}
|
|
/**
|
|
* 删除
|
|
*/
|
|
public function del()
|
|
{
|
|
$kind=input("kind");
|
|
$this->assign('kind',$kind);
|
|
$admin_id=input('id');
|
|
if (empty($admin_id)){
|
|
$this->error('ID不存在',url('index'));
|
|
}
|
|
$rst=Db::name('smslog')->delete($admin_id);
|
|
if($rst!==false){
|
|
$this->success('删除成功',url('index'));
|
|
}else{
|
|
$this->error('删除失败',url('index'));
|
|
}
|
|
}
|
|
/**
|
|
* 列表
|
|
*/
|
|
public function tag()
|
|
{
|
|
$search_name=input('search_name');
|
|
$this->assign('search_name',$search_name);
|
|
$map=array();
|
|
if($search_name){
|
|
$map['title']= array('like',"%".$search_name."%");
|
|
}
|
|
$admin_list=Db::name('smstag')->where($map)->order('id desc')->paginate(config('paginate.list_rows'),false,['query'=>get_query()]);
|
|
|
|
$page = $admin_list->render();
|
|
$this->assign('list',$admin_list);
|
|
$this->assign('page',$page);
|
|
return $this->fetch();
|
|
}
|
|
/**
|
|
* 添加
|
|
*/
|
|
public function addtag()
|
|
{
|
|
return $this->fetch();
|
|
}
|
|
/**
|
|
* 添加操作
|
|
*/
|
|
public function runaddtag()
|
|
{
|
|
$data=[];
|
|
$data['status']=input('status',-1);
|
|
$data['title']=input('title');
|
|
$data['infor']=input('infor');
|
|
$data['create_date']=time();
|
|
$query=Db::name('smstag')->insert($data);
|
|
if($query){
|
|
$this->success('添加成功',url('tag'));
|
|
}else{
|
|
$this->error('添加失败',url('tag'));
|
|
}
|
|
}
|
|
/**
|
|
* 修改
|
|
*/
|
|
public function edittag()
|
|
{
|
|
$list=Db::name('smstag')->find(input('id'));
|
|
if($list['infor']){
|
|
$list['infors']=explode(';',$list['infor']);
|
|
}
|
|
$this->assign('list',$list);
|
|
return $this->fetch();
|
|
}
|
|
/**
|
|
* 修改操作
|
|
*/
|
|
public function runedittag()
|
|
{
|
|
$data=[];
|
|
$data['id']=input('id');
|
|
$state=input('status');
|
|
if($state!='')$data['status']=$state;
|
|
$data['title']=input('title');
|
|
$data['infor']=input('infor');
|
|
|
|
$rst=Db::name('smstag')->update($data);
|
|
if($rst!==false){
|
|
$this->success('修改成功',url('tag'));
|
|
}else{
|
|
$this->error('修改失败',url('tag'));
|
|
}
|
|
}
|
|
/**
|
|
* 删除
|
|
*/
|
|
public function deltag()
|
|
{
|
|
$admin_id=input('id');
|
|
if (empty($admin_id)){
|
|
$this->error('ID不存在',url('tag'));
|
|
}
|
|
$rst=Db::name('smstag')->delete($admin_id);
|
|
if($rst!==false){
|
|
$this->success('删除成功',url('tag'));
|
|
}else{
|
|
$this->error('删除失败',url('tag'));
|
|
}
|
|
}
|
|
}
|