220 lines
6.9 KiB
PHP
220 lines
6.9 KiB
PHP
<?php
|
|
/**
|
|
* SAAS应用系统 --- 十年开发经验汇集巨献!
|
|
* ==========================================================
|
|
* Copy right 2020-2050 成都众联思索科技有限公司,保留所有权利。
|
|
* ----------------------------------------------------------
|
|
* 官方网址: https://www.zoomtk.com
|
|
* 这不是自由软件!未经允许不得用于商业目或程序代码摘取及修改。
|
|
* 任何企业和个人未经允许对程序代码以任何形式任何目的再发布传播。
|
|
* 唯一发布渠道www.zoomtk.com;非官方渠道统一视为侵权行为。
|
|
* ==========================================================
|
|
*/
|
|
namespace addon\saas\shop\controller;
|
|
use addon\saas\model\AgentLevel;
|
|
use addon\saas\model\RegionManage as ManageModel;
|
|
use addon\saas\model\RegionLevel;
|
|
use addon\saas\model\Site as SiteModel;
|
|
use addon\saas\model\WebSite;
|
|
use app\model\system\Address as AddressModel;
|
|
|
|
class Region extends SaasBase
|
|
{
|
|
/***
|
|
* 业务经理
|
|
* @return array|mixed
|
|
*/
|
|
public function lists()
|
|
{
|
|
$model = new ManageModel();
|
|
if (request()->isAjax()) {
|
|
$condition[] = ['f.site_id', '=', $this->site_id];
|
|
$real_name = input('real_name', '');
|
|
if ($real_name) {
|
|
$condition[] = ['m.nickname', 'like', '%' . $real_name . '%'];
|
|
}
|
|
$mobile = input('mobile', '');
|
|
if ($mobile) {
|
|
$condition[] = ['m.mobile', 'like', '%' . $mobile . '%'];
|
|
}
|
|
$start_time = input('start_time', '');
|
|
$end_time = input('end_time', '');
|
|
if ($start_time && $end_time) {
|
|
$condition[] = ['f.create_time', 'between', [date_to_time($start_time), date_to_time($end_time)]];
|
|
} elseif (!$start_time && $end_time) {
|
|
$condition[] = ['f.create_time', '<=', date_to_time($end_time)];
|
|
|
|
} elseif ($start_time && !$end_time) {
|
|
$condition[] = ['f.create_time', '>=', date_to_time($start_time)];
|
|
}
|
|
$status = input('status', '');
|
|
if (!empty($status)) {
|
|
$condition[] = ['f.status', '=', $status];
|
|
}
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$list = $model->getManagePageList($condition, $page, $page_size, 'f.create_time desc');
|
|
return $list;
|
|
} else {
|
|
$this->forthMenu();
|
|
return $this->fetch('region/lists');
|
|
}
|
|
}
|
|
|
|
/***
|
|
* 查看商户
|
|
*/
|
|
public function detail()
|
|
{
|
|
$id = input('id');
|
|
if (request()->isAjax()) {
|
|
$page = input('page', 1);
|
|
$page_size = input('page_size', PAGE_LIST_ROWS);
|
|
$search_text = input('search_text', '');
|
|
$states = input('states', 'all');
|
|
$condition[] = ['a.manage_id', '=', $id];
|
|
if ($states != 'all') {
|
|
$condition[] = ['a.states', '=', $states];
|
|
}
|
|
if ($search_text) {
|
|
$condition[] = ['a.username|a.site_name|a.site_tel', 'like', '%' . $search_text . '%'];
|
|
}
|
|
$pat_model = new SiteModel();
|
|
$res = $pat_model->getPageList($condition, $page, $page_size);
|
|
return $res;
|
|
}
|
|
$this->assign("id", $id);
|
|
return $this->fetch('manage/shoplist');
|
|
}
|
|
|
|
/***
|
|
* 添加经理
|
|
* @return mixed
|
|
*/
|
|
public function adduser()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$data = request()->post();
|
|
|
|
$model = new ManageModel();
|
|
$data['site_id'] = $this->site_id;
|
|
$res = $model->addManage($data);
|
|
return $res;
|
|
}
|
|
//查询省级数据列表
|
|
$address_model = new AddressModel();
|
|
$list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]);
|
|
$this->assign("province_list", $list["data"]);
|
|
$RegionLevel = new RegionLevel();
|
|
$level_list = $RegionLevel->getRegionLevelList([['site_id', '=', $this->site_id]], 'id,level_name');
|
|
$this->assign("level_list", $level_list['data']);
|
|
return $this->fetch('region/add');
|
|
}
|
|
|
|
/***
|
|
* 添加经理
|
|
* @return mixed
|
|
*/
|
|
public function edituser()
|
|
{
|
|
$model = new ManageModel();
|
|
$id = input('id',0);
|
|
$info = $model->getManageInfo([['f.id', '=', $id]])['data'];
|
|
if(!$info){
|
|
return $this->error('数据错误');
|
|
}
|
|
if (request()->isAjax()) {
|
|
$data = request()->post();
|
|
$res = $model->editManage($data,$id);
|
|
return $res;
|
|
}
|
|
//查询省级数据列表
|
|
$address_model = new AddressModel();
|
|
$list = $address_model->getAreaList([["pid", "=", 0], ["level", "=", 1]]);
|
|
$this->assign("province_list", $list["data"]);
|
|
$RegionLevel = new RegionLevel();
|
|
$level_list = $RegionLevel->getRegionLevelList([['site_id', '=', $this->site_id]], 'id,level_name');
|
|
$this->assign("level_list", $level_list['data']);
|
|
$this->assign("info", $info);
|
|
return $this->fetch('region/edit');
|
|
}
|
|
|
|
/**
|
|
* 冻结
|
|
*/
|
|
public function frozen()
|
|
{
|
|
$fenxiao_id = input('id', '');
|
|
|
|
$model = new ManageModel();
|
|
|
|
return $model->frozen($fenxiao_id);
|
|
}
|
|
|
|
/**
|
|
* 解冻
|
|
*/
|
|
public function unfrozen()
|
|
{
|
|
$id = input('id', '');
|
|
|
|
$model = new ManageModel();
|
|
|
|
return $model->frozen($id,1);
|
|
}
|
|
|
|
/**
|
|
* 解冻
|
|
*/
|
|
public function deluser()
|
|
{
|
|
$id = input('id', '');
|
|
|
|
$model = new ManageModel();
|
|
|
|
return $model->deleteManage($id,1);
|
|
}
|
|
|
|
|
|
/**
|
|
* 修改经理等级
|
|
*/
|
|
public function change_level()
|
|
{
|
|
$id = input('manage_id', '');
|
|
if (request()->isAjax()) {
|
|
$level_model = new RegionLevel();
|
|
$model = new ManageModel();
|
|
$_info = $model->getManageInfo([['f.id', '=', $id]], 'f.member_id,f.level_id,l.level_name');
|
|
$_info = $_info['data'];
|
|
$condition[] = ['site_id', '=', $this->site_id];
|
|
if (!empty($_info)) {
|
|
$condition[] = ['id', '<>', $_info['level_id']];
|
|
}
|
|
$lists = $level_model->getRegionLevelPage($condition);
|
|
return $lists;
|
|
} else {
|
|
$this->assign('manage_id', $id);
|
|
return $this->fetch('region/change_level');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 确认变更
|
|
*/
|
|
public function confirmChangeLevel()
|
|
{
|
|
if (request()->isAjax()) {
|
|
|
|
$manage_id = input('manage_id', '');
|
|
$level_id = input('level_id', '');
|
|
$model = new ManageModel();
|
|
$data = [
|
|
'level_id' => $level_id,
|
|
];
|
|
$res = $model->changeManageLevel($data, [['id', '=', $manage_id]]);
|
|
return $res;
|
|
}
|
|
}
|
|
}
|