221 lines
7.8 KiB
PHP
221 lines
7.8 KiB
PHP
<?php
|
||
|
||
namespace app\guildadmin\controller;
|
||
|
||
use app\admin\command\Menu;
|
||
use app\guildadmin\model\AuthGroup;
|
||
use app\guildadmin\model\AuthGroupAccess;
|
||
use app\guildadmin\model\AuthRule;
|
||
use app\common\controller\GuildAdmin;
|
||
use fast\Random;
|
||
use fast\Tree;
|
||
use think\Cache;
|
||
use think\Db;
|
||
use think\Exception;
|
||
use think\Hook;
|
||
use think\Session;
|
||
use think\Validate;
|
||
|
||
/**
|
||
* 管理员管理
|
||
*
|
||
* @icon fa fa-users
|
||
* @remark 一个管理员可以有多个角色组,左侧的菜单根据管理员所拥有的权限进行生成
|
||
*/
|
||
class GuildData extends GuildAdmin
|
||
{
|
||
|
||
protected $noNeedLogin = [];
|
||
protected $noNeedRight = [];
|
||
protected $layout = '';
|
||
protected $table_guild_subsidy_config = 'vs_guild_subsidy_config';
|
||
protected $table_guild_subsidy = 'vs_guild_subsidy';
|
||
protected $table_guild_user = 'vs_guild_user';
|
||
protected $table_guild_data = 'vs_guild_data';
|
||
protected $table_guild = 'vs_guild';
|
||
public function _initialize()
|
||
{
|
||
parent::_initialize();
|
||
}
|
||
|
||
//公会资料详情
|
||
public function guild_data_detail(){
|
||
$guild_id = input('guild_id',$this->guildId);
|
||
if(!$guild_id){
|
||
return V(0,"公会ID不存在");
|
||
}
|
||
$guild = Db::name($this->table_guild)->where('id',$guild_id)->find();
|
||
if(!$guild){
|
||
return V(0,"公会不存在");
|
||
}
|
||
$guild_data = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->find();
|
||
//公会会长
|
||
$guild_user = Db::name('user')->where('id',$guild['user_id'])->find();
|
||
$return_data =[];
|
||
$return_data ['company']['guild_name'] = $guild['guild_name'] ?? '';
|
||
$return_data ['company']['company_name'] = $guild_data['company_name'] ?? '';
|
||
$return_data ['company']['agreement'] = $guild_data['agreement'] ?? '';
|
||
$return_data ['company']['guild_cover'] = $guild['cover'] ?? '';
|
||
//负责人信息
|
||
$return_data ['boss']['boss_name'] = $guild_data['boss_name'] ?? '';
|
||
$return_data ['boss']['boss_mobile'] = $guild_data['boss_mobile'] ?? '';
|
||
$return_data ['boss']['boss_user_code'] = $guild_user['user_code'] ?? '';
|
||
//对公账号
|
||
$return_data ['bank']['bank_name'] = $guild_data['bank_name'] ?? '';
|
||
$return_data ['bank']['bank_num'] = $guild_data['bank_num'] ?? '';
|
||
$return_data ['bank']['bank_img'] = $guild_data['bank_img'] ?? '';
|
||
//扫描件
|
||
$return_data ['scan']['business_license_img'] = $guild_data['business_license_img'] ?? '';
|
||
$return_data ['scan']['id_card_1'] = $guild_data['id_card_1'] ?? '';
|
||
$return_data ['scan']['id_card_2'] = $guild_data['id_card_2'] ?? '';
|
||
|
||
return V(1,"成功", $return_data);
|
||
}
|
||
|
||
//公司信息修改
|
||
public function company_update(){
|
||
$guild_id = input('guild_id',$this->guildId);
|
||
if(!$guild_id){
|
||
return V(0,"公会ID不存在");
|
||
}
|
||
$guild = Db::name($this->table_guild)->where('id',$guild_id)->find();
|
||
if(!$guild){
|
||
return V(0,"公会不存在");
|
||
}
|
||
$guild_data = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->find();
|
||
if(!$guild_data){
|
||
return V(0,"公会资料不存在");
|
||
}
|
||
$company_name = input('company_name', '');
|
||
$agreement = input('agreement', '');
|
||
$guild_cover = input('guild_cover', '');
|
||
$data = [
|
||
'company_name' => $company_name,
|
||
'agreement' => $agreement
|
||
];
|
||
if($guild_cover){
|
||
db::name($this->table_guild)->where('id',$guild_id)->update(['cover' => $guild_cover]);
|
||
}
|
||
$ret = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->update($data);
|
||
if($ret){
|
||
return V(1,"修改成功");
|
||
}else{
|
||
return V(0,"修改失败");
|
||
}
|
||
}
|
||
|
||
//负责人信息修改
|
||
public function boss_update(){
|
||
$guild_id = input('guild_id',$this->guildId);
|
||
if(!$guild_id){
|
||
return V(0,"公会ID不存在");
|
||
}
|
||
$guild = Db::name($this->table_guild)->where('id',$guild_id)->find();
|
||
if(!$guild){
|
||
return V(0,"公会不存在");
|
||
}
|
||
$guild_data = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->find();
|
||
if(!$guild_data){
|
||
return V(0,"公会资料不存在");
|
||
}
|
||
$boss_name = input('boss_name', '');
|
||
$boss_mobile = input('boss_mobile', '');
|
||
$data = [
|
||
'boss_name' => $boss_name,
|
||
'boss_mobile' => $boss_mobile
|
||
];
|
||
$ret = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->update($data);
|
||
if($ret){
|
||
return V(1,"修改成功");
|
||
}else{
|
||
return V(0,"修改失败");
|
||
}
|
||
}
|
||
//对公账号信息修改
|
||
public function bank_update(){
|
||
$guild_id = input('guild_id',$this->guildId);
|
||
if(!$guild_id){
|
||
return V(0,"公会ID不存在");
|
||
}
|
||
$guild = Db::name($this->table_guild)->where('id',$guild_id)->find();
|
||
if(!$guild){
|
||
return V(0,"公会不存在");
|
||
}
|
||
$guild_data = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->find();
|
||
if(!$guild_data){
|
||
return V(0,"公会资料不存在");
|
||
}
|
||
$bank_name = input('bank_name', '');
|
||
$bank_num = input('bank_num', '');
|
||
$bank_img = input('bank_img', '');
|
||
$data = [
|
||
'bank_name' => $bank_name,
|
||
'bank_num' => $bank_num,
|
||
'bank_img' => $bank_img
|
||
];
|
||
$ret = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->update($data);
|
||
if($ret){
|
||
return V(1,"修改成功");
|
||
}else{
|
||
return V(0,"修改失败");
|
||
}
|
||
}
|
||
//扫描件信息修改
|
||
public function scan_update(){
|
||
$guild_id = input('guild_id',$this->guildId);
|
||
if(!$guild_id){
|
||
return V(0,"公会ID不存在");
|
||
}
|
||
$guild = Db::name($this->table_guild)->where('id',$guild_id)->find();
|
||
if(!$guild){
|
||
return V(0,"公会不存在");
|
||
}
|
||
$guild_data = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->find();
|
||
if(!$guild_data){
|
||
return V(0,"公会资料不存在");
|
||
}
|
||
$business_license_img = input('business_license_img', '');
|
||
$id_card_1 = input('id_card_1', '');
|
||
$id_card_2 = input('id_card_2', '');
|
||
$data = [
|
||
'business_license_img' => $business_license_img,
|
||
'id_card_1' => $id_card_1,
|
||
'id_card_2' => $id_card_2
|
||
];
|
||
$ret = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->update($data);
|
||
if($ret){
|
||
return V(1,"修改成功");
|
||
}else{
|
||
return V(0,"修改失败");
|
||
}
|
||
}
|
||
//后台密码修改
|
||
public function password_update(){
|
||
$guild_id = input('guild_id',$this->guildId);
|
||
if(!$guild_id){
|
||
return V(0,"公会ID不存在");
|
||
}
|
||
$guild_data = Db::name($this->table_guild_data)->where('guild_id',$guild_id)->find();
|
||
if(!$guild_data){
|
||
return V(0,"公会资料不存在");
|
||
}
|
||
$password = input('password', '');
|
||
if ($password) {
|
||
if (!Validate::is($password, '\S{6,30}')) {
|
||
return V(0,"密码长度必须在6-30位之间,不能包含空格", []);
|
||
}
|
||
$params['salt'] = Random::alnum();
|
||
$params['password'] = $this->auth->getEncryptPassword($password, $params['salt']);
|
||
}
|
||
$ret = Db::name('vs_guild_admin')->where('guild_id',$guild_id)->update($params);
|
||
if($ret){
|
||
$this->auth->logout();
|
||
Hook::listen("admin_logout_after", $this->request);
|
||
return V(1,"修改成功");
|
||
}else{
|
||
return V(0,"修改失败");
|
||
}
|
||
}
|
||
|
||
}
|