From 4fb1362c6c3c76e202e01c8faaa44b8802d3d96c Mon Sep 17 00:00:00 2001 From: "qiyunfanbo126.com" <815699> Date: Wed, 31 Jul 2024 09:22:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=B7=E6=A0=BC=E6=8E=92?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/http/controllers/front/OrderController.go | 6 ++++++ app/http/requestmapping/front.go | 2 ++ app/http/routes/route.go | 3 ++- app/services/OrderService.go | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/http/controllers/front/OrderController.go b/app/http/controllers/front/OrderController.go index 0f7e599..2d7bedc 100644 --- a/app/http/controllers/front/OrderController.go +++ b/app/http/controllers/front/OrderController.go @@ -85,6 +85,12 @@ func OrderRefund(c *gin.Context) { controllers.HandCodeRes(c, nil, code) } +func OrderDelete(c *gin.Context) { + var request = controllers.GetRequest(c).(*front.OrderQueryRequest) + err := services.OrderDelete(request.OrderId) + controllers.HandRes(c, nil, err) +} + func OrderNotify(c *gin.Context) { c.Header("method", "unionpay.b2cNotify") c.Header("merchantId", config.GetConf().YouChu.MerchantId) diff --git a/app/http/requestmapping/front.go b/app/http/requestmapping/front.go index 526914d..baa6cce 100644 --- a/app/http/requestmapping/front.go +++ b/app/http/requestmapping/front.go @@ -22,4 +22,6 @@ var FrontRequestMap = map[string]func() interface{}{ common.FRONT_API_V1_Auth + "/order/query": func() interface{} { return new(front.OrderQueryRequest) }, //退款订单 common.FRONT_API_V1_Auth + "/order/refund": func() interface{} { return new(front.OrderQueryRequest) }, + //退款订单 + common.FRONT_API_V1_Auth + "/order/delete": func() interface{} { return new(front.OrderQueryRequest) }, } diff --git a/app/http/routes/route.go b/app/http/routes/route.go index a3f8709..bed9ffa 100644 --- a/app/http/routes/route.go +++ b/app/http/routes/route.go @@ -4,6 +4,7 @@ package routes * 配置路由 */ import ( + ginSwagger "github.com/swaggo/gin-swagger" "qteam/app/constants/common" "qteam/app/http/controllers" "qteam/app/http/controllers/front" @@ -15,7 +16,6 @@ import ( "github.com/gin-gonic/gin" "github.com/qit-team/snow-core/http/middleware" "github.com/qit-team/snow-core/log/logger" - "github.com/swaggo/gin-swagger" "github.com/swaggo/gin-swagger/swaggerFiles" ) @@ -72,6 +72,7 @@ func RegisterRoute(router *gin.Engine) { order.POST("/list", front.OrderList) order.POST("/query", front.OrderQuery) order.POST("/refund", front.OrderRefund) + order.POST("/delete", front.OrderDelete) } } } diff --git a/app/services/OrderService.go b/app/services/OrderService.go index fb5ec86..601eeb8 100644 --- a/app/services/OrderService.go +++ b/app/services/OrderService.go @@ -97,6 +97,7 @@ func CreateOrderService(userId int, productId int) (code int, data front.InsertO func OrderQueryService(userId int, OrderRequest *front.OrderListRequest) (code int, data []ordersmodel.OrdersProductsList, count int64) { repo := ordersmodel.GetInstance().GetDb() conn := builder.NewCond() + conn.And(builder.IsNull{"Delete"}) if config.GetConf().Debug == false { conn = conn.And(builder.Eq{"a.user_id": userId}) } @@ -186,6 +187,11 @@ func OrderRefundService(userId int, orderId int) (code int) { } } +func OrderDelete(id string) error { + _, err := ordersmodel.GetInstance().GetDb().Where("id = ?", id).Update(ordersmodel.Orders{Deleted: time.Now()}) + return err +} + func OrderNotify(request front.YouChuRequest) (NotifyResponse front.YouChuOrderNotifyResponse) { requestStr, _ := json.Marshal(request) utils.Log(nil, "订单回调请求--原始数据:", string(requestStr))