From 815113a6a20270f38d78f5708ac1c9251307c5b1 Mon Sep 17 00:00:00 2001 From: ztt <835303992@qq.com> Date: Sat, 24 Feb 2024 15:34:11 +0800 Subject: [PATCH] 1 --- app/api/controller/Active.php | 5 ++++- app/api/controller/User.php | 20 ++++++++++++++++++++ app/api/model/user/UserInvoice.php | 12 ++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/app/api/controller/Active.php b/app/api/controller/Active.php index 12883e02..318bcada 100644 --- a/app/api/controller/Active.php +++ b/app/api/controller/Active.php @@ -24,11 +24,14 @@ class Active extends Controller $model = new ActiveMain(); $list = $model->with('col') ->where('status', '=', 1) - ->where('id', $param['active_id'])->find(); + ->where('id', $param['active_id']) + ->find(); if ($list) { foreach ($list['col'] as $k => $row) { $goodsModel = new GoodsModel(); $goods_list = $goodsModel->getListByIdsFromApi(explode(',', $row['col_goods_ids'])); + // 隐藏冗余的属性 + $goods_list->hidden(GoodsModel::getHidden(['content', 'goods_images', 'images'])); $list['col'][$k]['goods_list'] = $goods_list; } return $this->renderSuccess($list->toArray()); diff --git a/app/api/controller/User.php b/app/api/controller/User.php index 88c89b80..712777c6 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -34,6 +34,15 @@ use think\response\Json; */ class User extends Controller { + /** + * 注销账号 + * [delete description] + * @return [type] [description] + */ + public function delete(){ + $user_id = UserService::getCurrentLoginUserId(); + UserModel::where('user_id', $user_id)->update(['is_delete' => 1,'update_time' => time()]); + } /** * 当前用户详情 * @return Json @@ -212,6 +221,17 @@ class User extends Controller return $this->renderSuccess('修改成功'); } + //发票抬头删除 + public function delInvoicing(): Json + { + $service = new UserInvoice(); + if(!$service->del($this->request->param())) { + return $this->renderSuccess($service->getError() ?: '操作失败'); + } + return $this->renderSuccess('删除成功·'); + + } + //开票记录 public function invoicingLog(): Json { diff --git a/app/api/model/user/UserInvoice.php b/app/api/model/user/UserInvoice.php index 95ef6558..955cb11c 100644 --- a/app/api/model/user/UserInvoice.php +++ b/app/api/model/user/UserInvoice.php @@ -86,4 +86,16 @@ class UserInvoice extends UserInvoiceModel ]) !== false; } + public function del($data) { + if(empty($data['id'])) { + $this->error = '参数异常'; + return false; + } + + $userId = UserService::getCurrentLoginUserId(); + $detail = self::get(['user_id' => $userId, 'id' => $data['id']]); + empty($detail) && throwError('未找到该抬头'); + return $detail->delete(); + } + } \ No newline at end of file