You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
904 lines
27 KiB
PHP
904 lines
27 KiB
PHP
<?php
|
|
|
|
namespace Admin\Controller;
|
|
/**
|
|
* 后台首页控制器
|
|
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
|
*/
|
|
class ToolController extends ThinkController {
|
|
|
|
/**
|
|
*保存设置
|
|
*/
|
|
public function saveTool($value='')
|
|
{
|
|
$name = $_POST['name'];
|
|
$config = I('config');
|
|
$data = array('config'=>json_encode($config),'template'=>$_POST['template'],'status'=>$_POST['status']);
|
|
$map['name']=$name;
|
|
|
|
$day_pay = $config['day_pay_limit'];
|
|
$month_pay = $config['month_pay_limit'];
|
|
if(!empty($day_pay) && !empty($month_pay)) {
|
|
if($month_pay / date('t') > $day_pay) {
|
|
$this->error('月支付限量较日支付限量过大');
|
|
} elseif ($month_pay < $day_pay) {
|
|
$this->error('月支付限量不能小于日支付限量');
|
|
}
|
|
}
|
|
|
|
if($_POST['status']==1&&$name=="weixin"){
|
|
$map_['name']=array("in",'wei_xin,wei_xin_app,weixin_gf');
|
|
M('tool','tab_')->where($map_)->setField('status','0');
|
|
}
|
|
if($_POST['status']==1&&$name=="wei_xin"||$name=="wei_xin_app"){
|
|
$map_['name']=['in','weixin,weixin_gf'];
|
|
M('tool','tab_')->where($map_)->setField('status','0');
|
|
}
|
|
if($_POST['status']==1&&$name=="weixin_gf"){
|
|
$map_['name']=array("in",'wei_xin,wei_xin_app,weixin');
|
|
M('tool','tab_')->where($map_)->setField('status','0');
|
|
}
|
|
if (isset($config['channel_rate']) && ($config['channel_rate'] > 100 || !is_numeric($config['channel_rate']))) {
|
|
$this->error('请输入正确的渠道费率');
|
|
}
|
|
if (isset($config['channel_rate'])) $config['channel_rate'] = round($config['channel_rate'], 2);
|
|
|
|
$flag = M('Tool','tab_')->where($map)->setField($data);
|
|
if($flag !== false){
|
|
$config['status']=$_POST['status'];
|
|
$this->set_config($name,$config);
|
|
\Think\Log::actionLog('Tool/saveTool','Tool',1);
|
|
$this->success('保存成功');
|
|
}else{
|
|
$this->error('保存失败');
|
|
}
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* 给图片添加水印
|
|
* @author 鹿文学
|
|
* @date 2018-05-03
|
|
*/
|
|
public function addWatermarkOnPic() {
|
|
// watermark
|
|
$tool = M('tool',"tab_")->field('config,status')->where(['name'=>'watermark'])->find();
|
|
|
|
if(empty($tool)){$this->error('没有此设置');}
|
|
|
|
if($tool['status']==0) {$this->error('添加水印已关闭');exit;}
|
|
|
|
$piclist = M('picture')->field('path,url,water')->where(['status'=>1,'water'=>array('neq','')])->select();
|
|
|
|
if (!is_array($piclist)) {$this->error('没有图片需要添加');exit;}
|
|
|
|
$water = json_decode($tool['config'],true);
|
|
|
|
$temp = explode(',',$water['position']);
|
|
$position = 3*$temp[0]+$temp[1]+1;
|
|
|
|
|
|
$image = new \Think\Image();
|
|
|
|
if ($water['types']==1) { // 文字
|
|
|
|
$offset = array(
|
|
$water['hoffset']?$water['hoffset']:0,
|
|
$water['voffset']?$water['voffset']:0
|
|
);
|
|
|
|
foreach ($piclist as $k => $v) {
|
|
|
|
$image->open(ROOTTT.$v['path'])->text($water['font_text'],FONTS.$water['font'],$water['font_size'],$water['font_color'],$position,$offset)->save(ROOTTT.$v['water'],$image->type(),$water['quality']);
|
|
|
|
}
|
|
|
|
} else { // 图片
|
|
|
|
foreach ($piclist as $k => $v) {
|
|
|
|
|
|
$img_url=M('picture')->find($water['icon']);
|
|
$img_url=$img_url['path'];
|
|
$image->open(ROOTTT.$v['path'])->water(ROOTTT.$img_url,$position,$water['transparency'])->save(ROOTTT.$v['water'],$image->type(),$water['quality']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->success('水印添加成功');
|
|
|
|
}
|
|
|
|
public function save($config){
|
|
$name = $_POST['name'];
|
|
$a = $this->set_config($name,$config);
|
|
if ($a){
|
|
return true;
|
|
}else{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/**
|
|
*显示扩展设置信息
|
|
*/
|
|
protected function BaseConfig($name='')
|
|
{
|
|
$map['name'] = array('in',$name);
|
|
$tool = M('tool',"tab_")->where($map)->select();
|
|
if(empty($tool)){$this->error('没有此设置');}
|
|
foreach ($tool as $key => $val) {
|
|
$this->assign($tool[$key]['name'],json_decode($tool[$key]['config'],true));
|
|
unset($tool[$key]['config']);
|
|
$this->assign($tool[$key]['name']."_data",$tool[$key]);
|
|
}
|
|
}
|
|
/**
|
|
*短信设置
|
|
*/
|
|
public function smsset($value='')
|
|
{
|
|
$this->BaseConfig("sms_set,alidayu,jiguang,alidayunew,zhongwang");
|
|
$this->meta_title = '短信设置';
|
|
|
|
$this->m_title = '短信设置';
|
|
$url = 'Tool/smsset';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*防沉迷设置
|
|
*/
|
|
public function age($value='')
|
|
{
|
|
$this->BaseConfig("tool_age");
|
|
$this->meta_title = '实名认证';
|
|
|
|
$this->m_title = '实名认证';
|
|
$url = 'Tool/age';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*文件存储
|
|
*/
|
|
public function storage($value='')
|
|
{
|
|
$str = "oss_storage,qiniu_storage,cos_storage,bos_storage,ks3_storage";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '文件存储';
|
|
|
|
$this->m_title = '文件存储';
|
|
$url = 'Tool/storage';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*动态密保
|
|
*/
|
|
public function cooperate($value='')
|
|
{
|
|
$str = "set_cooperate";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '动态密保';
|
|
|
|
$this->m_title = '动态密保';
|
|
$url = 'Tool/cooperate';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*支付设置
|
|
*/
|
|
public function payset($value='')
|
|
{
|
|
$str = "alipay,weixin,wei_xin,wei_xin_app,jubaobar,weixin_gf,jft,jft_wap,goldpig,ptb_pay,bind_pay,sqpay,heepay,yeepay";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '支付设置';
|
|
|
|
$this->m_title = '支付设置';
|
|
$url = 'Tool/payset';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*邮件设置
|
|
*/
|
|
public function email($value='')
|
|
{
|
|
$str = "email_set";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '邮件设置';
|
|
|
|
$this->m_title = '邮件设置';
|
|
$url = 'Tool/email';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*第三方登录设置
|
|
*/
|
|
public function qq_thirdparty($value='')
|
|
{
|
|
$str = "qq_login,weixin_login,fb_login,gg_login";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '第三方登录';
|
|
|
|
$this->m_title = '第三方登录';
|
|
$url = 'Tool/qq_thirdparty';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*第三方登录设置
|
|
*/
|
|
public function wx_thirdparty($value='')
|
|
{
|
|
$str = "weixin_login";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '第三方登录';
|
|
$this->display();
|
|
}
|
|
/**
|
|
*第三方登录设置
|
|
*/
|
|
public function wb_thirdparty($value='')
|
|
{
|
|
$str = "sina_login";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '第三方登录';
|
|
$this->display();
|
|
}
|
|
/**
|
|
*第三方登录设置
|
|
*/
|
|
public function bd_thirdparty($value='')
|
|
{
|
|
$str = "baidu_login";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '第三方登录';
|
|
$this->display();
|
|
}
|
|
/**
|
|
*畅言设置
|
|
*/
|
|
public function changyan($value=''){
|
|
$str = "changyan";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '畅言设置';
|
|
|
|
$this->m_title = '畅言设置';
|
|
$url = 'Tool/changyan';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
/**
|
|
*聚宝云
|
|
*/
|
|
public function saveTool_jubaobar(){
|
|
$name = $_POST['name'];
|
|
$config = I('config');
|
|
$data = array('config'=>json_encode($config),'template'=>$_POST['template'],'status'=>$_POST['status']);
|
|
$map['name']=$name;
|
|
$flag = M('Tool','tab_')->where($map)->setField($data);
|
|
if($flag !== false){
|
|
$this->set_config($name,$config);
|
|
$this->update_xml($config['key']);
|
|
$this->success('保存成功');
|
|
}else{
|
|
$this->error('保存失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
*修改 聚宝云 安全口令
|
|
*/
|
|
private function update_xml($key=""){
|
|
// $file = $_SERVER['DOCUMENT_ROOT'].'Application/Sdk/SecretKey/jubaopay/jubaopay.ini';
|
|
$file = './Application/Sdk/SecretKey/jubaopay/jubaopay.ini';
|
|
//创建DOMDocument的对象
|
|
$dom = new \DOMDocument('1.0');
|
|
//载入mainchart.xml文件
|
|
$dom->load($file);
|
|
$dom->getElementsByTagName('psw')->item(0)->nodeValue = $key;
|
|
$dom->save($file);
|
|
}
|
|
|
|
/**
|
|
*设置config
|
|
*/
|
|
private function set_config($name="",$config=""){
|
|
$config_file ="./Application/Common/Conf/pay_config.php";
|
|
if(file_exists($config_file)){
|
|
$configs=include $config_file;
|
|
}else {
|
|
$configs=array();
|
|
}
|
|
#定义一个数组
|
|
$data = array();
|
|
#给数组赋值
|
|
$data[$name] = $config;
|
|
$configs=array_merge($configs,$data);
|
|
$result = file_put_contents($config_file, "<?php\treturn " . var_export($configs, true) . ";");
|
|
|
|
$ageConfigJson = json_encode($config);
|
|
M('tool', 'tab_')->where([
|
|
'name' => $name
|
|
])->save([
|
|
'config' => $ageConfigJson,
|
|
'type' => 1,
|
|
'status' => isset($config['status']) ? $config['status'] : $config['bat']
|
|
]);
|
|
}
|
|
|
|
public function ios_game(){
|
|
if($_GET['t']==1){
|
|
$url="qq";
|
|
}elseif($_GET['t']==2){
|
|
$url="wx";
|
|
}elseif($_GET['t']==3){
|
|
$url="wb";
|
|
}else{
|
|
$url="bd";
|
|
}
|
|
$this->meta_title = '第三方登录';
|
|
$this->assign('thirdparty',$url."_thirdparty");
|
|
$this->assign('param_lists',$url."_param_lists");
|
|
$this->display();
|
|
}
|
|
|
|
public function qq_param_lists(){
|
|
if(isset($_GET['game_id'])){
|
|
$map['game_id']=$_GET['game_id'];
|
|
}
|
|
$map['type']=1;
|
|
$model = array(
|
|
'm_name' => 'param',
|
|
'map' => $map,
|
|
'fields'=>'id,game_id,openid,key,callback,status,create_time',
|
|
'order' =>'id desc',
|
|
'title' => "第三方登录",
|
|
'template_list' =>'qq_param_lists',
|
|
);
|
|
$this->meta_title = '第三方登录';
|
|
$user = A('User','Event');
|
|
$user->user_join_($model,$_GET['p']);
|
|
|
|
}
|
|
|
|
public function wx_param_lists(){
|
|
if(isset($_GET['game_id'])){
|
|
$map['game_id']=$_GET['game_id'];
|
|
}
|
|
$map['type']=2;
|
|
$model = array(
|
|
'm_name' => 'param',
|
|
'map' => $map,
|
|
'fields'=>'id,game_id,wx_appid,appsecret,callback,status,create_time',
|
|
'order' =>'id desc',
|
|
'title' => "第三方登录",
|
|
'template_list' =>'wx_param_lists',
|
|
);
|
|
$this->meta_title = '第三方登录';
|
|
$user = A('User','Event');
|
|
$user->user_join_($model,$_GET['p']);
|
|
|
|
}
|
|
public function wb_param_lists(){
|
|
if(isset($_GET['game_id'])){
|
|
$map['game_id']=$_GET['game_id'];
|
|
}
|
|
$map['type']=3;
|
|
$model = array(
|
|
'm_name' => 'param',
|
|
'map' => $map,
|
|
'field'=>'id,game_id,appkey,scope,callback,status,create_time',
|
|
'order' =>'id desc',
|
|
'title' => "第三方登录",
|
|
'template_list' =>'wb_param_lists',
|
|
);
|
|
$this->meta_title = '第三方登录';
|
|
$user = A('User','Event');
|
|
$user->user_join_($model,$_GET['p']);
|
|
|
|
}
|
|
|
|
public function bd_param_lists(){
|
|
if(isset($_GET['game_id'])){
|
|
$map['game_id']=$_GET['game_id'];
|
|
}
|
|
$map['type']=4;
|
|
$model = array(
|
|
'm_name' => 'param',
|
|
'map' => $map,
|
|
'field'=>'id,game_id,openid,key,callback,status,create_time',
|
|
'order' =>'id desc',
|
|
'title' => "第三方登录",
|
|
'template_list' =>'bd_param_lists',
|
|
);
|
|
$this->meta_title = '第三方登录';
|
|
$user = A('User','Event');
|
|
$user->user_join_($model,$_GET['p']);
|
|
|
|
}
|
|
|
|
|
|
public function add_thirdparty(){
|
|
if(IS_POST){
|
|
if($_POST['type']==1){
|
|
if(empty($_POST['openid'])){
|
|
$this->error('openid不能为空');exit;
|
|
}
|
|
if(empty($_POST['key'])){
|
|
$this->error('安全校验码不能为空');exit;
|
|
}
|
|
$url="qq_param_lists";
|
|
}elseif($_POST['type']==2){
|
|
if(empty($_POST['wx_appid'])){
|
|
$this->error('APPID不能为空');exit;
|
|
}
|
|
if(empty($_POST['appsecret'])){
|
|
$this->error('APPSECRET不能为空');exit;
|
|
}
|
|
$url="wx_param_lists";
|
|
}elseif($_POST['type']==3){
|
|
if(empty($_POST['appkey'])||empty($_POST['scope'])){
|
|
$this->error('参数不能为空');exit;
|
|
}
|
|
$url="wb_param_lists";
|
|
}else{
|
|
if(empty($_POST['clientid'])){
|
|
$this->error('参数不能为空');exit;
|
|
}
|
|
$url="bd_param_lists";
|
|
}
|
|
|
|
$find=M('param','tab_')->where(['game_id'=>$_POST['game_id'],'type'=>$_POST['type']])->find();
|
|
if(null!==$find){
|
|
$this->error('该游戏已经设置过参数');exit;
|
|
}
|
|
if($_POST['game_id']==0){
|
|
$count=M('param','tab_')->where(['game_id'=>['gt',0],'type'=>$_POST['type']])->count();
|
|
if($count>=1){
|
|
$this->error('如需设置全部游戏 请先将其他游戏数据删除');exit;
|
|
}
|
|
}
|
|
$add=M('param','tab_')->add($_POST);
|
|
if($add){
|
|
$this->success('新增成功',U($url));
|
|
}else{
|
|
$this->error('新增失败',U($url));
|
|
}
|
|
}else{
|
|
|
|
switch($_GET['type']) {
|
|
case 1:$this->meta_title = '第三方登录';break;
|
|
case 2:$this->meta_title = '第三方登录';break;
|
|
|
|
}
|
|
|
|
$this->display();
|
|
}
|
|
}
|
|
|
|
|
|
public function edit_thirdparty($id){
|
|
if(IS_POST){
|
|
if($_POST['type']==1){
|
|
if(empty($_POST['openid'])){
|
|
$this->error('openid不能为空');exit;
|
|
}
|
|
if(empty($_POST['key'])) {
|
|
$this->error('安全校验码不能为空');exit;
|
|
}
|
|
|
|
$url="qq_param_lists";
|
|
}elseif($_POST['type']==2){
|
|
if(empty($_POST['wx_appid'])){
|
|
$this->error('APPID不能为空');exit;
|
|
}
|
|
if(empty($_POST['appsecret'])){
|
|
$this->error('APPSECRET不能为空');exit;
|
|
}
|
|
$url="wx_param_lists";
|
|
}elseif($_POST['type']==3){
|
|
if(empty($_POST['appkey'])||empty($_POST['scope'])){
|
|
$this->error('参数不能为空');exit;
|
|
}
|
|
$url="wb_param_lists";
|
|
}else{
|
|
if(empty($_POST['clientid'])){
|
|
$this->error('参数不能为空');exit;
|
|
}
|
|
$url="bd_param_lists";
|
|
}
|
|
|
|
$add=M('param','tab_')->save($_POST);
|
|
if($add){
|
|
$this->success('修改成功',U($url));
|
|
}else{
|
|
$this->error('修改失败',U($url));
|
|
}
|
|
}else{
|
|
$find=M('param','tab_')->where(['id'=>$id])->find();
|
|
$this->assign('data',$find);
|
|
switch($_GET['type']) {
|
|
case 1:$this->meta_title = '第三方登录';break;
|
|
case 2:$this->meta_title = '第三方登录';break;
|
|
|
|
}
|
|
$this->display();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
* @author 麦当苗儿 <zuojiazi@vip.qq.com>
|
|
*/
|
|
public function del(){
|
|
$id = array_unique((array)I('ids',0));
|
|
|
|
if ( empty($id) ) {
|
|
$this->error('请选择要操作的数据!');
|
|
}
|
|
$map = array('id' => array('in', $id) );
|
|
if(M('param','tab_')->where($map)->delete()){
|
|
$this->success('删除成功');
|
|
} else {
|
|
$this->error('删除失败!');
|
|
}
|
|
}
|
|
|
|
public function changeStatus($field = null,$value=null)
|
|
{
|
|
$id = array_unique((array)I('id', 0));
|
|
$id = is_array($id) ? implode(',', $id) : $id;
|
|
if (empty($id)) {
|
|
$this->error('请选择要操作的数据!');
|
|
}
|
|
$map['id'] = array('in', $id);
|
|
$result = M('param','tab_')->where($map)->setField($field,$value);
|
|
$msg = $value == 0?"关闭":"开启";
|
|
if($result !== false){
|
|
$this->success($msg.'成功');
|
|
}else{
|
|
$this->error($msg.'失败');
|
|
}
|
|
}
|
|
|
|
/*
|
|
* 水印
|
|
*/
|
|
public function watermark() {
|
|
|
|
$this->BaseConfig("watermark");
|
|
|
|
$this->meta_title = '水印设置';
|
|
|
|
$this->m_title = '水印设置';
|
|
$url = 'Tool/watermark';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
|
|
}
|
|
|
|
/**
|
|
* 支付宝参数设置
|
|
* @author 鹿文学
|
|
*/
|
|
public function alipay_param($value='') {
|
|
$str = "alipay_param";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '支付宝认证';
|
|
|
|
$this->m_title = '支付宝认证';
|
|
$url = 'Tool/alipay_param';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
* 用户VIP设置
|
|
* @author 鹿文学
|
|
*/
|
|
public function vip($value='') {
|
|
$str = "viplevel";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '用户VIP设置';
|
|
|
|
$this->m_title = '用户VIP设置';
|
|
$url = 'Tool/vip';
|
|
$this->m_url = $url;
|
|
$this->assign('commonset',M('Kuaijieicon')->where(['url'=>$url,'status'=>1])->find());
|
|
|
|
|
|
$this->display();
|
|
}
|
|
|
|
/**
|
|
*公司信息列表
|
|
*/
|
|
public function company_info()
|
|
{
|
|
$model = M('company_info', 'tab_');
|
|
$map = [];
|
|
$id = intval(I('id', 0));
|
|
if (!empty($id)) {
|
|
$map['tab_company_info.id'] = $id;
|
|
$parameter['id'] = $id;
|
|
}
|
|
|
|
if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') {
|
|
$status = intval($_REQUEST['status']);
|
|
$map['tab_company_info.status'] = $status;
|
|
$parameter['status'] = $status;
|
|
}
|
|
|
|
$page = intval(I('get.p', 0));
|
|
$page = $page ? $page : 1; //默认显示第一页数据
|
|
$row = intval(I('row', 0));
|
|
$row = empty($row) ? 10 : $row;//每页条数
|
|
|
|
$data = $model->alias('p')
|
|
->field('p.id,p.partner,p.status,p.create_time,link_man,link_phone,address,company_tax_no,payee_name,
|
|
bank_account,opening_bank,m.nickname')
|
|
->join('left join sys_member as m on m.uid = p.uid')
|
|
->where($map)
|
|
->order('id desc')
|
|
->page($page, $row)
|
|
->select();
|
|
|
|
/* 查询记录总数 */
|
|
$count = $model
|
|
->where($map)
|
|
->count();
|
|
|
|
if (!empty($data)) {
|
|
foreach ($data as &$list) {
|
|
$list['status'] = ($list['status'] == 0) ? '已关闭' : '已开启';
|
|
$list['create_time'] = date('Y-m-d H:i:s', $list['create_time']);
|
|
}
|
|
}
|
|
|
|
//分页
|
|
$parameter['p'] = $page;
|
|
$parameter['row'] = $row;
|
|
$page = set_pagination($count, $row, $parameter);
|
|
if ($page) {
|
|
$this->assign('_page', $page);
|
|
}
|
|
|
|
$this->assign('listData', $data);
|
|
$this->assign('count', $count);
|
|
$this->meta_title = '公司信息管理';
|
|
$this->display();
|
|
}
|
|
|
|
//添加
|
|
public function company_add()
|
|
{
|
|
if ($_POST) {
|
|
$partner = I('post.partner', '');
|
|
$status = intval(I('post.status', 1));
|
|
|
|
if (empty($partner)) {
|
|
$this->error('请输入公司名称');
|
|
}
|
|
if (empty(I('link_man'))) {
|
|
$this->error('请输入联系人');
|
|
}
|
|
if (empty(I('link_phone'))) {
|
|
$this->error('请输入联系电话');
|
|
}
|
|
if (!in_array($status, [0, 1])) {
|
|
$this->error('参数异常');
|
|
}
|
|
|
|
$model = M('company_info', 'tab_');
|
|
$map['partner'] = $partner;
|
|
$res = $model->where($map)->getField('id');
|
|
if ($res) {
|
|
$this->error('公司名称已存在');
|
|
}
|
|
|
|
if(!checkPhone(I('link_phone'))) {
|
|
$this->error('联系电话格式不正确');
|
|
}
|
|
$res2 = $model->where(['link_phone' => I('link_phone')])->getField('id');
|
|
if ($res2) {
|
|
$this->error('已存在此联系电话');
|
|
}
|
|
$time = time();
|
|
$save['partner'] = $partner;
|
|
$save['status'] = $status;
|
|
|
|
$save['link_man'] = I('link_man');
|
|
$save['link_phone'] = I('link_phone');
|
|
$save['address'] = I('address');
|
|
$save['company_tax_no'] = I('company_tax_no');
|
|
$save['payee_name'] = I('payee_name');
|
|
$save['bank_account'] = I('bank_account');
|
|
$save['opening_bank'] = I('opening_bank');
|
|
|
|
$save['uid'] = UID;
|
|
$save['create_time'] = $time;
|
|
$save['last_up_time'] = $time;
|
|
|
|
$res = $model->add($save);
|
|
if ($res) {
|
|
\Think\Log::actionLog('company/add', 'company_info', $res);
|
|
$this->success('保存成功', U('company_info'));
|
|
} else {
|
|
$this->error('保存失败');
|
|
}
|
|
} else {
|
|
$this->meta_title = '新增公司';
|
|
$this->display();
|
|
}
|
|
}
|
|
|
|
//编辑
|
|
public function company_edit()
|
|
{
|
|
$model = M('company_info', 'tab_');
|
|
|
|
if ($_POST) {
|
|
$partner = I('post.partner', '');
|
|
$status = intval(I('post.status', 1));
|
|
$id = intval(I('post.id', 0));
|
|
|
|
if (empty($partner)) {
|
|
$this->error('请输入合作方名称');
|
|
}
|
|
if (empty(I('link_man'))) {
|
|
$this->error('请输入联系人');
|
|
}
|
|
if (empty(I('link_phone'))) {
|
|
$this->error('请输入联系电话');
|
|
}
|
|
if (!in_array($status, [0, 1])) {
|
|
$this->error('参数异常');
|
|
}
|
|
|
|
$data = $model
|
|
->field('id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank')
|
|
->find($id);
|
|
if (empty($data)) {
|
|
$this->error('数据异常');
|
|
}
|
|
|
|
$map['partner'] = $partner;
|
|
$res = $model->where($map)->getField('id');
|
|
if ($res && $res != $id) {
|
|
$this->error('公司名称已存在');
|
|
}
|
|
|
|
if(!checkPhone(I('link_phone'))) {
|
|
$this->error('联系电话格式不正确');
|
|
}
|
|
$res2 = $model->where([
|
|
'link_phone' => I('link_phone'),
|
|
'id' => ['neq', $id]
|
|
])->getField('id');
|
|
|
|
if ($res2) {
|
|
$this->error('已存在此联系电话');
|
|
}
|
|
$time = time();
|
|
$save['id'] = $id;
|
|
$save['partner'] = $partner;
|
|
|
|
$save['link_man'] = I('link_man');
|
|
$save['link_phone'] = I('link_phone');
|
|
$save['address'] = I('address');
|
|
$save['company_tax_no'] = I('company_tax_no');
|
|
$save['payee_name'] = I('payee_name');
|
|
$save['bank_account'] = I('bank_account');
|
|
$save['opening_bank'] = I('opening_bank');
|
|
|
|
$save['status'] = $status;
|
|
$save['last_up_time'] = $time;
|
|
$res = $model->save($save);
|
|
if ($res === false) {
|
|
$this->error('保存失败');
|
|
} else {
|
|
\Think\Log::actionLog('company/edit', 'company_info', $id);
|
|
$this->success('保存成功', U('company_info'));
|
|
}
|
|
} else {
|
|
$id = intval(I('get.id', 0));
|
|
$map['id'] = $id;
|
|
$data = $model
|
|
->field('id,partner,status,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank')
|
|
->find($id);
|
|
if (empty($data)) {
|
|
$this->error('数据异常', U('company_info'));
|
|
}
|
|
|
|
$this->assign('company_info', $data);
|
|
$this->meta_title = '编辑公司';
|
|
$this->display();
|
|
}
|
|
}
|
|
|
|
//删除
|
|
public function company_del()
|
|
{
|
|
if (!empty($_POST['ids'])) {
|
|
if (!is_array($_POST['ids'])) {
|
|
$this->error('参数异常');
|
|
}
|
|
|
|
$id = implode(',', $_POST['ids']);
|
|
} else {
|
|
$id = intval(I('get.id', 0));
|
|
if ($id == 0) {
|
|
$this->error('参数异常');
|
|
}
|
|
}
|
|
|
|
$res = M('company_info', 'tab_')->delete($id);
|
|
if ($res === false) {
|
|
$this->error('删除失败');
|
|
}
|
|
|
|
$this->success('删除成功', U('company_info'));
|
|
}
|
|
|
|
/**
|
|
*公司信息管理(旧版备份)
|
|
*/
|
|
public function company_info_old()
|
|
{
|
|
$str = "company_info";
|
|
$this->BaseConfig($str);
|
|
$this->meta_title = '公司信息管理';
|
|
$this->display();
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|