feat: update refund issues
This commit is contained in:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user