diff --git a/backend/app/http/admin/orders.go b/backend/app/http/admin/orders.go index ae2552f..5c26d11 100644 --- a/backend/app/http/admin/orders.go +++ b/backend/app/http/admin/orders.go @@ -3,6 +3,7 @@ package admin import ( "quyun/app/models" "quyun/app/requests" + "quyun/providers/wepay" "github.com/gofiber/fiber/v3" ) @@ -13,7 +14,9 @@ type OrderListQuery struct { } // @provider -type orders struct{} +type orders struct { + wepay *wepay.Client +} // List users // @@ -24,3 +27,15 @@ func (ctl *orders) List(ctx fiber.Ctx, pagination *requests.Pagination, query *O cond := models.Orders.BuildConditionWithKey(query.OrderNumber, query.UserID) return models.Orders.List(ctx.Context(), pagination, cond) } + +// Refund +// @Router /admin/orders/{id}/refund [post] +// @Bind id path +func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error { + order, err := models.Orders.GetByID(ctx.Context(), id) + if err != nil { + return err + } + + return ctx.JSON(order) +} diff --git a/backend/app/http/admin/statistics.go b/backend/app/http/admin/statistics.go index 45f5062..c5f937f 100644 --- a/backend/app/http/admin/statistics.go +++ b/backend/app/http/admin/statistics.go @@ -43,7 +43,7 @@ func (s *statistics) statistics(ctx fiber.Ctx) (*StatisticsResponse, error) { return nil, err } - statistics.Order, err = models.Orders.Count(ctx.Context(), table.Orders.Status.EQ(Int(int64(fields.OrderStatusPaid)))) + statistics.Order, err = models.Orders.Count(ctx.Context(), table.Orders.Status.EQ(Int(int64(fields.OrderStatusCompleted)))) if err != nil { return nil, err } diff --git a/backend/app/models/orders.go b/backend/app/models/orders.go index e644ef9..a0491a8 100644 --- a/backend/app/models/orders.go +++ b/backend/app/models/orders.go @@ -227,7 +227,7 @@ func (m *ordersModel) Count(ctx context.Context, cond BoolExpression) (int64, er func (m *ordersModel) SumAmount(ctx context.Context) (int64, error) { tbl := table.Orders stmt := SELECT(SUM(tbl.Price).AS("cnt")).FROM(tbl).WHERE( - tbl.Status.EQ(Int(int64(fields.OrderStatusPaid))), + tbl.Status.EQ(Int(int64(fields.OrderStatusCompleted))), ) m.log.Infof("sql: %s", stmt.DebugSql()) diff --git a/backend/app/models/posts.go b/backend/app/models/posts.go index b5227de..40c5e00 100644 --- a/backend/app/models/posts.go +++ b/backend/app/models/posts.go @@ -292,7 +292,7 @@ func (m *postsModel) Bought(ctx context.Context, userId int64, pagination *reque tbl.INNER_JOIN(table.Posts, table.Posts.ID.EQ(tbl.PostID)), ). WHERE( - tbl.UserID.EQ(Int64(1)), + tbl.UserID.EQ(Int64(userId)), ). ORDER_BY(tbl.ID.DESC()). LIMIT(pagination.Limit).