文件
mashangyoujiu/Application/Retail/Controller/SaleWarehouseController.class.php

178 行
6.1 KiB
PHP
可执行文件

此文件含有模棱两可的 Unicode 字符

此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。

<?php
namespace Retail\Controller;
use Common\Business\Warehouse;
use Think\Controller;
//[1.5.70]
class SaleWarehouseController extends BaseController
{
/*
* *************************************************可售仓库管理用到的参数及外部方法**********************************************
* SaleWarehouse.class.php
* SaleWarehouseModel.class.php
* @param $data['name'] 仓库名称
* @param $data['number'] 仓库编号
* @param $data['province'] 省
* @param $data['city'] 市
* @param $data['area'] 区
* @param $data['address'] 地址
* @param $data['measure_area'] 面积
* @param $data['person_name'] 负责人姓名
* @param $data['person_phone'] 负责人手机号
* @param $data['remarks'] 备注
* @param $data['default'] 是否默认 1默认 2不默认
* function paramJudge() 判断参数id是否正确 路径 Common/function.php
*/
/*
* *****************************************省市区*****************************************************
*/
//省
public function Province()
{
$province = M('citys');
$prov = $province->where(array('parentid' => 0))->select();
return $prov;
}
public function getCity()
{
if (IS_POST) {
$pid = I('post.pid');
$list = M('citys')->where(array('parentid' => $pid))->select();
$res['status'] = 1;
$res['data'] = $list;
$this->ajaxReturn($res);
}
}
/*
* *************************************************查询信息**************************************************
*/
/*
* 商户下的所有仓库信息
*/
public function index()
{
$arr = array(
'addWarehouse' => '/index.php/Retail/SaleWarehouse/addWarehouse',
'setWarehouse' => '/index.php/Retail/SaleWarehouse/addWarehouse'
);
$authArr = checkFunction($arr);
$this->assign('authArr', $authArr);
$userInfo = session("merchant_userinfo");
$where['status'] = 1;
$where['merchant_id'] = $userInfo['id'];
$info = D('SaleWarehouse')->getFind($where);
if ($info) {
$type = false;
} else {
$type = true;
}
$this->assign('type', $type);
$this->display();
}
public function warehouseList()
{
$userInfo = session("merchant_userinfo");
$where['merchant_id'] = $userInfo['id'];
$where['status'] = 1;
$info = D('SaleWarehouse')->getSelect($where, $page = '', $limit = '', "*");
if ($info) {
foreach ($info as $key => &$val) {
$val['add_time'] = date('Y-m-d H:i:s', $val['add_time']);
$val['region'] = $val['province'] . $val['city'] . $val['area'];
$val['measure_area'] = round($val['measure_area'], 2);
}
} else {
$info = array();
}
$res['status'] = 1;
$res['msg'] = '';
$res['data'] = $info;
$this->ajaxReturn($res);
}
/*
* 添加与编辑仓库的信息
* @param $id 编辑的仓库id
*/
public function addWarehouse()
{
$arr = array(
'onSubmit' => '/index.php/Retail/SaleWarehouse/editWarehouseOperation',
);
$authArr = checkFunction($arr);
$this->assign('authArr', $authArr);
$prov = $this->Province();
$this->assign('prov', json_encode($prov));
$id = I("get.id");
if ($id) { //编辑
$where['id'] = $id;
$info = D('SaleWarehouse')->getFind($where);
if ($info) {
$info['measure_area'] = round($info['measure_area'], 2);
$parentid = M('citys')->where(array('city_name' => $info['city']))->getField('cityid');
$city = M('citys')->where(array('parentid' => $parentid))->select();
$parentid = M('citys')->where(array('city_name' => $info['area']))->getField('cityid');
$area = M('citys')->where(array('parentid' => $parentid))->select();
$this->assign('city', json_encode($city));
$this->assign('area', json_encode($area));
} else {
$info = array();
}
$this->assign('id', $id);
$this->assign('data', $info);
} else {//添加
$city = array();
$area = array();
$this->assign('city', json_encode($city));
$this->assign('area', json_encode($area));
}
$this->display();
}
/*
* *********************************************操作接口******************************************************
*/
/*
*添加可售仓库操作
*
*/
public function addWarehouseOperation()
{
$data = I("post.");
$data['merchant_id'] = $this->merchant_id;
$WarehouseClass = new Warehouse();
$result = $WarehouseClass->merchantSaleWarehouseOperation($data);
if($result['status'] == 1){
if (!empty($data['id'])) {
$desc = '供给仓库-添加';//操作行为描述
} else {
$desc = '供给仓库-编辑';//操作行为描述
}
//操作日志记录
$source = 0;//请求来源: 0pc系统 1小助手
$type = 3;//平台:1合伙人端 2代理商端 3商户端 4门店端
$request_data = json_encode($_POST);//请求参数 json数据
action_log($source, $type, $request_data, $desc);
}
$this->ajaxReturn($result);
}
/*
* 判断id
*/
public function judgeId($id)
{
if (!$id) {
$res['status'] = 0;
$res['msg'] = '参数缺失';
} else {
$res['status'] = 1;
$res['msg'] = '成功';
}
return $res;
}
}