Files
OMS/app/logistics/controller/admin/area.php
2026-01-04 17:22:44 +08:00

154 lines
4.3 KiB
PHP

<?php
/**
* Copyright 2026 ShopeX (https://www.shopex.cn)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class logistics_ctl_admin_area extends desktop_controller {
var $workground = 'setting_tools';
function index(){
$action=array(
array(
'label' => $this->app->_('添加地区'),
'href' => 'index.php?app=logistics&ctl=admin_area&act=addArea',
'target'=>'dialog::{width:600,height:600,title:\'添加地区\'}',
),
);
$params=array(
'title' => '地区管理',
'actions'=>$action,
'use_buildin_recycle' => true,
);
$this->finder('logistics_mdl_area',$params);
}
/**
* 添加大区
*/
function addArea(){
$area_id = intval($_GET['area_id']);
if($area_id){
$area = $this->app->model('area')->detailArea($area_id);
$this->pagedata['area'] = $area;
}
$this->page('admin/addArea.html');
}
/**
* 获取RegionById
* @param mixed $pregionid ID
* @return mixed 返回结果
*/
public function getRegionById($pregionid)
{
$obj_regions_op = kernel::single('eccommon_regions_operation');
$region = $obj_regions_op->getRegionById($pregionid);
foreach($region as $k=>$v){
$region[$k]['child_count'] = 0;
}
return $region;
}
/**
* showRegionTreeList
* @param mixed $serid ID
* @param mixed $branch_id ID
* @return mixed 返回值
*/
public function showRegionTreeList($serid,$branch_id)
{
$area = $this->app->model('area')->getArea();
foreach($area as $k=>$v){
foreach($v['area_items'] as $ak=>$av){
$region_obj = $this->app->model('rule')->chkBranchRegion($branch_id,$av['region_id'],'');
if($region_obj){
$area[$k]['area_items'][$ak]['flag']=1;
}
}
}
$this->pagedata['area'] = $area;
$this->singlepage('admin/regionSelect.html');
}
/**
* showRegionList
* @return mixed 返回值
*/
public function showRegionList()
{
$region_id = $_GET['region_id'];
$region_ids = $region_id ? explode(',',$region_id) : '';
$regionlist = $this->getRegionById('');
$this->pagedata['region_ids'] = $region_ids;
$this->pagedata['regionlist'] = $regionlist;
$this->pagedata['multi'] = 'true';
$this->page('admin/regionSelect1.html');
}
function saveDlArea(){
$this->begin('index.php?app=logistics&ctl=admin_area&act=index');
$data = $_POST;
$area_data = array();
if($data['area_id']){
$area_data['area_id'] = $data['area_id'];
}
$area_data['local_name'] = $data['local_name'];
$area_data['region_name'] = $data['region_name'];
$area_data['region_id'] = $data['p_region_id'];
$area_data['ordernum'] = $data['ordernum'];
$msg='';
$chkregion=$this->app->model('area')->chkRegion($data['p_region_id'],$data['area_id'],$msg);
if(!$chkregion){
$this->end(false, $msg.'已存在于其他区中');
}
$result = $this->app->model('area')->save($area_data);
if($result){
$this->end(true, app::get('eccommon')->_('新建成功').$msg);
}else{
$this->end(false, app::get('eccommon')->_('新建失败'));
}
}
function test(){
set_time_limit(0);
echo '<pre>';
$confirm='';
$branch_id = $_GET['branch_id'];
$area_id = $_GET['area_id'];
$weight = $_GET['weight'];
$corp_ids = kernel::single('logistics_rule')->autoMatchDlyCorp($area_id,$branch_id,$weight,$shop_type);
print_r($corp_ids);
}
}
?>