feat: update refund issues

This commit is contained in:
Rogee
2025-05-13 14:24:55 +08:00
parent 610eb8d553
commit 2cf3b858b7
2 changed files with 37 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ import (
"quyun/providers/wepay"
"github.com/gofiber/fiber/v3"
"github.com/pkg/errors"
)
type OrderListQuery struct {
@@ -45,7 +46,24 @@ func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error {
return err
}
refundTotal := order.Price * int64(order.Discount) / 100
if order.PaymentMethod == "balance" {
if err := models.Users.AddBalance(ctx.Context(), order.UserID, order.Meta.Data.CostBalance); err != nil {
return errors.Wrap(err, "add balance failed")
}
if err := models.Users.RevokePosts(ctx.Context(), order.UserID, order.PostID); err != nil {
return errors.Wrap(err, "revoke posts failed")
}
order.Status = fields.OrderStatusRefundSuccess
if err := models.Orders.Update(ctx.Context(), order); err != nil {
return errors.Wrap(err, "update order failed")
}
return nil
}
refundTotal := order.Price*int64(order.Discount)/100 - order.Meta.Data.CostBalance
resp, err := ctl.wepay.Refund(ctx.Context(), func(bm *wepay.BodyMap) {
bm.
OutRefundNo(order.OrderNo).