添加自提点
This commit is contained in:
parent
0022719b12
commit
fc53744c6b
@ -335,4 +335,15 @@ class LocalStore extends Api
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 设置自提站点
|
||||
public function setPostStation()
|
||||
{
|
||||
try {
|
||||
$post = $this->request->post();
|
||||
$data = LocalStoreLogic::setPostStation($post, $this->user_id);
|
||||
} catch(\Exception $e) {
|
||||
return JsonServer::error($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -352,4 +352,28 @@ class LocalStoreLogic extends Logic
|
||||
'more' => $more,
|
||||
];
|
||||
}
|
||||
|
||||
public static function setPostStation($post, $user_id)
|
||||
{
|
||||
throw new \Exception('未选择区域');
|
||||
|
||||
if (!$post['province'] && !$post['city'] && !$post['area'] && !$post['address']) {
|
||||
throw new \Exception('未选择区域');
|
||||
}
|
||||
|
||||
if (!$post['lat'] && !$post['lng']) {
|
||||
throw new \Exception('经纬度不能为空');
|
||||
}
|
||||
|
||||
$result = LocalStore::where('user_id', $user_id)->update([
|
||||
'post_station' => json_encode($post, JSON_UNESCAPED_UNICODE),
|
||||
'update_time' => time()
|
||||
]);
|
||||
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
|
||||
throw new \Exception('更新失败');
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user