From 37f2326b21daf3b4774a0bd8d44caa019e6b0f02 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Tue, 20 Jun 2023 19:44:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86Code=E7=A0=81?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../internal/logic/useroderdeletelogic.go | 7 +++++-- utils/basic/basic.go | 14 ++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/server/home-user-auth/internal/logic/useroderdeletelogic.go b/server/home-user-auth/internal/logic/useroderdeletelogic.go index 4f646627..26f6d1bc 100644 --- a/server/home-user-auth/internal/logic/useroderdeletelogic.go +++ b/server/home-user-auth/internal/logic/useroderdeletelogic.go @@ -72,8 +72,6 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo return resp.SetStatus(basic.CodeOrderNotCancelledErr) } - //这里是将给定的PHP代码翻译成Golang代码: - uOrder := &gmodel.FsOrder{ Id: orderId, } @@ -136,6 +134,11 @@ func (l *UserOderDeleteLogic) UserOderDelete(req *types.RequestOrderId, userinfo PaymentIntent: pay.TradeNo, }) } + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return resp.SetStatus(basic.CodeApiErr) + } + } // if err == nil && err == nil { // return ResponseSuccess(200, "Cancel successfully", order) diff --git a/utils/basic/basic.go b/utils/basic/basic.go index 84d2f87c..1d5ee065 100644 --- a/utils/basic/basic.go +++ b/utils/basic/basic.go @@ -22,15 +22,17 @@ var ( CodeOrderNotFoundErr = &StatusResponse{5030, "the order not found"} //未找到订单 CodeOrderNotCancelledErr = &StatusResponse{5031, "The current order cannot be cancelled"} // 当前订单无法取消 + CodePayNotFoundErr = &StatusResponse{5020, "The pay not found"} // 支付信息无法查询 + CodeGuestDupErr = &StatusResponse{5010, "the user is already a guest user and does not need to apply again"} // 用户已经是访客用户,不需要重复申请 CodeGuestGenErr = &StatusResponse{5011, "serialization failed for guest_id of the visitor"} // 访客ID序列化失败 - CodeDbUpdateErr = &StatusResponse{5000, "update database error"} // 数据库更新错误 - CodeDupGuestErr = &StatusResponse{5001, "the user is already a guest user and does not need to apply again"} // 用户已经是访客用户,不需要重复申请 - CodeRequestParamsErr = &StatusResponse{5002, "invalid request param"} // 请求参数无效 - CodeDbRecordNotFoundErr = &StatusResponse{5003, "db record not found"} //未在数据库中找到记录 - CodeDbCreateErr = &StatusResponse{5004, "create one in database error"} // 在数据库中创建错误 - CodeDbSqlErr = &StatusResponse{5005, "database is error"} // 数据库错误 + CodeDbUpdateErr = &StatusResponse{5000, "update database error"} // 数据库更新错误 + // 5001 + CodeRequestParamsErr = &StatusResponse{5002, "invalid request param"} // 请求参数无效 + CodeDbRecordNotFoundErr = &StatusResponse{5003, "db record not found"} //未在数据库中找到记录 + CodeDbCreateErr = &StatusResponse{5004, "create one in database error"} // 在数据库中创建错误 + CodeDbSqlErr = &StatusResponse{5005, "database is error"} // 数据库错误 ) type Response struct {