feat: update
This commit is contained in:
@@ -28,25 +28,25 @@ type orders struct {
|
||||
// @Bind pagination query
|
||||
// @Bind query query
|
||||
func (ctl *orders) List(ctx fiber.Ctx, pagination *requests.Pagination, query *OrderListQuery) (*requests.Pager, error) {
|
||||
cond := model.OrdersModel.BuildConditionWithKey(query.OrderNumber, query.UserID)
|
||||
return model.OrdersModel.List(ctx.Context(), pagination, cond)
|
||||
cond := model.OrdersModel().BuildConditionWithKey(query.OrderNumber, query.UserID)
|
||||
return model.OrdersModel().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 := model.OrdersModel.GetByID(ctx.Context(), id)
|
||||
order, err := model.OrdersModel().GetByID(ctx.Context(), id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
user, err := model.UsersModel.GetByID(ctx.Context(), order.UserID)
|
||||
user, err := model.UsersModel().GetByID(ctx.Context(), order.UserID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
post, err := model.PostsModel.GetByID(ctx.Context(), order.PostID)
|
||||
post, err := model.PostsModel().GetByID(ctx.Context(), order.PostID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error {
|
||||
}
|
||||
|
||||
order.Status = fields.OrderStatusRefundSuccess
|
||||
if err := model.OrdersModel.Update(ctx.Context(), order); err != nil {
|
||||
if err := order.Update(ctx.Context()); err != nil {
|
||||
return errors.Wrap(err, "update order failed")
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error {
|
||||
order.RefundTransactionID = resp.RefundId
|
||||
order.Status = fields.OrderStatusRefundProcessing
|
||||
|
||||
if err := model.OrdersModel.Update(ctx.Context(), order); err != nil {
|
||||
if err := order.Update(ctx.Context()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user