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/SSaleWarehouse/addWarehouse', 'setWarehouse' => '/index.php/Retail/SSaleWarehouse/addWarehouse' ); $authArr = checkFunction($arr); $this->assign('authArr', $authArr); $userInfo = session("ls_userinfo"); $store_id = session("storeid"); $where['status'] = 1; $where['merchant_id'] = $userInfo['merchantid']; $where['store_id'] = $store_id; $info = D('SSaleWarehouse')->getFind($where); if ($info) { $type = false; } else { $type = true; } $this->assign('type', $type); $this->display(); } public function warehouseList() { $userInfo = session("ls_userinfo"); $store_id = session("storeid"); $where['merchant_id'] = $userInfo['merchantid']; $where['store_id'] = $store_id; $where['status'] = 1; $info = D('SSaleWarehouse')->getSelect($where, $page = '', $limit = '', "*"); if ($info) { $count = D('SSaleWarehouse')->getCount($where); 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/SSaleWarehouse/addWarehouseOperation', ); $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('SSaleWarehouse')->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; $data['store_id'] = $this->store_id; $WarehouseClass = new Warehouse(); $result = $WarehouseClass->storeSaleWarehouseOperation($data); if ($result['status'] == 1) { if (!empty($data['id'])) { $desc = '供给仓库-添加';//操作行为描述 } else { $desc = '供给仓库-编辑';//操作行为描述 } //操作日志记录 $source = 0;//请求来源: 0pc系统 1小助手 $type = 4;//平台: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; } }