fix bug
This commit is contained in:
@@ -58,8 +58,7 @@ class Address
|
|||||||
Db::name("app_address")->where("userid",$userid)->update(["is_default"=>0]);
|
Db::name("app_address")->where("userid",$userid)->update(["is_default"=>0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$datas = [
|
||||||
Db::name("app_address")->insert([
|
|
||||||
"userid"=>$userid,
|
"userid"=>$userid,
|
||||||
"name"=>$post['name'],
|
"name"=>$post['name'],
|
||||||
"mobile"=>$post['mobile'],
|
"mobile"=>$post['mobile'],
|
||||||
@@ -68,8 +67,33 @@ class Address
|
|||||||
"area"=>$post['area'],
|
"area"=>$post['area'],
|
||||||
"detail"=>$post['detail'],
|
"detail"=>$post['detail'],
|
||||||
"is_default"=>$post['is_default'],
|
"is_default"=>$post['is_default'],
|
||||||
]);
|
];
|
||||||
|
|
||||||
|
if(!empty($post['id'])){
|
||||||
|
$d = Db::name("app_address")->where("id",$post['id'])->find();
|
||||||
|
if($userid != $d['userid']){
|
||||||
|
return show("找不到地址信息!");
|
||||||
|
}
|
||||||
|
Db::name("app_address")->where("id",$post['id'])->update($datas);
|
||||||
|
}else{
|
||||||
|
Db::name("app_address")->insert($datas);
|
||||||
|
}
|
||||||
return show("添加成功!", SUCCESS_CODE, []);
|
return show("添加成功!", SUCCESS_CODE, []);
|
||||||
}
|
}
|
||||||
|
public function delete(){
|
||||||
|
$post = $GLOBALS['data']['data'];
|
||||||
|
$userid = $GLOBALS['data']['userid'];
|
||||||
|
if (empty($userid)) {
|
||||||
|
return show("请登录!",NEED_LOGIN);
|
||||||
|
}
|
||||||
|
if(!empty($post['id'])) {
|
||||||
|
return show("找不到地址信息!");
|
||||||
|
}
|
||||||
|
$d = Db::name("app_address")->where("id",$post['id'])->find();
|
||||||
|
if($userid != $d['userid']){
|
||||||
|
return show("找不到地址信息!");
|
||||||
|
}
|
||||||
|
Db::name("app_address")->where("id",$post['id'])->delete();
|
||||||
|
return show("删除成功!", SUCCESS_CODE, []);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user