|
@@ -42,7 +42,7 @@ class WareHouse extends BaseController
|
|
|
if($wsmtype==''){
|
|
|
return error_show(1004,'参数wsmtype 不能为空');
|
|
|
}
|
|
|
- $isT = Db::name('warehouse_info')->where([['name',"=",$name]])->find();
|
|
|
+ $isT = Db::name('warehouse_info')->where([['name',"=",$name],["is_del","=",0]])->find();
|
|
|
if(!empty($isT)){
|
|
|
return error_show(1004,'仓库名称已存在');
|
|
|
}
|
|
@@ -118,6 +118,94 @@ class WareHouse extends BaseController
|
|
|
|
|
|
public function info(){
|
|
|
$post =$this->request->post();
|
|
|
+ $id = isset($post['id']) && $post['id']!==''?intval($post['id']): "";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ };
|
|
|
+ $warse = Db::name("warehouse_info")->where(["id"=>$id,"is_del"=>0])->find();
|
|
|
+ if(empty($warse)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ return app_show(0,"获取成功",$warse);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function save(){
|
|
|
+ $post =$this->request->post();
|
|
|
+ $id = isset($post['id']) && $post['id']!==''?intval($post['id']): "";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ };
|
|
|
+ $warse = Db::name("warehouse_info")->where(["id"=>$id,"is_del"=>0])->find();
|
|
|
+ if(empty($warse)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ $name = isset($post['name'])&& $post['name']!='' ?trim($post['name']) :'';
|
|
|
+ if($name==''){
|
|
|
+ return error_show(1004,'参数name 不能为空');
|
|
|
+ }
|
|
|
+ $isT = Db::name('warehouse_info')->where([['name',"=",$name],["is_del","=",0],["id","<>",$id]])->find();
|
|
|
+ if(!empty($isT)){
|
|
|
+ return error_show(1004,'仓库名称已存在');
|
|
|
+ }
|
|
|
+ $addr = isset($post['addr'])&& $post['addr']!='' ?trim($post['addr']) :'';
|
|
|
+ if($addr==''){
|
|
|
+ return error_show(1004,'参数addr 不能为空');
|
|
|
+ }
|
|
|
+ $contactor = isset($post['contactor'])&& $post['contactor']!='' ?trim($post['contactor']) :'';
|
|
|
+ if($contactor==''){
|
|
|
+ return error_show(1004,'参数contactor 不能为空');
|
|
|
+ }
|
|
|
+ $mobile = isset($post['mobile'])&& $post['mobile']!='' ?trim($post['mobile']) :'';
|
|
|
+ if($mobile==''){
|
|
|
+ return error_show(1004,'参数mobile 不能为空');
|
|
|
+ }
|
|
|
+ $position = isset($post['position'])&& $post['position']!='' ?trim($post['position']) :'';
|
|
|
+ $data =[
|
|
|
+ 'name'=>$name,
|
|
|
+ 'addr'=>$addr,
|
|
|
+ 'contactor'=>$contactor,
|
|
|
+ 'mobile'=>$mobile,
|
|
|
+ 'position'=>$position,
|
|
|
+ 'updatetime'=>date("Y-m-d H:i:s")
|
|
|
+ ];
|
|
|
+ $add = Db::name('warehouse_info')->where($warse)->update($data);
|
|
|
+ return $add ? app_show(0,'仓库修改成功'): error_show(1005,'仓库修改失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ public function delete(){
|
|
|
+ $post =$this->request->post();
|
|
|
+ $id = isset($post['id']) && $post['id']!==''?intval($post['id']): "";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ };
|
|
|
+ $warse = Db::name("warehouse_info")->where(["id"=>$id,"is_del"=>0])->find();
|
|
|
+ if(empty($warse)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ $warse['is_del'] = 1;
|
|
|
+ $warse['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $Del= Db::name("warehouse_info")->save($warse);
|
|
|
+ return $Del? app_show(0,'仓库删除成功'): error_show(1005,'仓库删除失败');
|
|
|
+ }
|
|
|
|
|
|
+ public function status(){
|
|
|
+ $post =$this->request->post();
|
|
|
+ $id = isset($post['id']) && $post['id']!==''?intval($post['id']): "";
|
|
|
+ if($id===""){
|
|
|
+ return error_show(1004,"参数id不能为空");
|
|
|
+ };
|
|
|
+ $warse = Db::name("warehouse_info")->where(["id"=>$id,"is_del"=>0])->find();
|
|
|
+ if(empty($warse)){
|
|
|
+ return error_show(1004,"未找到数据");
|
|
|
+ }
|
|
|
+ $status = isset($post['status']) && $post['status']!=="" ? intval($post['status']) : "";
|
|
|
+ if($status===""){
|
|
|
+ return error_show(1005,"参数status 不能为空");
|
|
|
+ }
|
|
|
+ $warse['status'] = $status;
|
|
|
+ $warse['updatetime'] = date("Y-m-d H:i:s");
|
|
|
+ $Del= Db::name("warehouse_info")->save($warse);
|
|
|
+ return $Del? app_show(0,'仓库状态修改成功'): error_show(1005,'仓库状态修改失败');
|
|
|
}
|
|
|
+
|
|
|
}
|