diff --git a/app/api/controller/LocalStore.php b/app/api/controller/LocalStore.php index 9c73fd6b..d5780b86 100755 --- a/app/api/controller/LocalStore.php +++ b/app/api/controller/LocalStore.php @@ -390,12 +390,24 @@ class LocalStore extends Api } } + // 修改自提站点联系电话 + public function editPostStationPhone() + { + try { + $post = $this->request->post(); + LocalStoreLogic::editPostStationPhone($post); + return JsonServer::success('设置成功'); + } catch (\Exception $e) { + return JsonServer::error($e->getMessage()); + } + } + // 删除自提点 public function delPostStation() { try { $post = $this->request->post(); - LocalStoreLogic::delPostStation($post, $this->user_id); + LocalStoreLogic::delPostStation($post); return JsonServer::success('设置成功'); } catch (\Exception $e) { return JsonServer::error($e->getMessage()); diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index 91c8dbcc..7b9bfa92 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -464,6 +464,10 @@ class LocalStoreLogic extends Logic throw new \Exception('经纬度不能为空'); } + if (!$post['phone']) { + throw new \Exception('自提点联系电话不能为空'); + } + $post['user_id'] = $user_id; $result = LocalStorePostStation::insert($post); @@ -474,16 +478,32 @@ class LocalStoreLogic extends Logic throw new \Exception('更新失败'); } - public static function delPostStation($post, $user_id) + // 修改自提站点联系电话 + public static function editPostStationPhone($post) + { + if (!$post['id']) { + throw new \Exception('参数不能为空'); + } + + if (!$post['phone']) { + throw new \Exception('自提点联系电话不能为空'); + } + + $result = LocalStorePostStation::where([ + 'id' => $post['id'], + ])->update(['phone' => $post['phone']]); + } + + // 删除自提点 + public static function delPostStation($post) { if (!$post['id']) { throw new \Exception('参数不能为空'); } $result = LocalStorePostStation::where([ - 'id' => $post['id'], - 'user_id' => $user_id - ])->update(['is_delete' => 1]); + 'id' => $post['id'] + ])->update(['is_delete' => 1, 'delete_time' => time()]); if ($result) { return true;