feat: add refund statuses
This commit is contained in:
@@ -61,9 +61,11 @@ func (ctl *orders) Refund(ctx fiber.Ctx, id int64) error {
|
||||
meta.RefundResp = resp
|
||||
order.Meta = fields.ToJson(meta)
|
||||
order.RefundTransactionID = resp.RefundId
|
||||
order.Status = fields.OrderStatusRefundProcessing
|
||||
|
||||
if err := models.Orders.Update(ctx.Context(), order); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"quyun/providers/app"
|
||||
"quyun/providers/job"
|
||||
"quyun/providers/jwt"
|
||||
"quyun/providers/wepay"
|
||||
|
||||
"go.ipao.vip/atom"
|
||||
"go.ipao.vip/atom/container"
|
||||
@@ -35,8 +36,12 @@ func Provide(opts ...opt.Option) error {
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := container.Container.Provide(func() (*orders, error) {
|
||||
obj := &orders{}
|
||||
if err := container.Container.Provide(func(
|
||||
wepay *wepay.Client,
|
||||
) (*orders, error) {
|
||||
obj := &orders{
|
||||
wepay: wepay,
|
||||
}
|
||||
|
||||
return obj, nil
|
||||
}); err != nil {
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"quyun/providers/job"
|
||||
"quyun/providers/wepay"
|
||||
|
||||
"github.com/go-pay/gopay"
|
||||
"github.com/go-pay/gopay/wechat/v3"
|
||||
"github.com/gofiber/fiber/v3"
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -25,20 +24,21 @@ type pays struct {
|
||||
// @Bind channel path
|
||||
func (ctl *pays) Callback(ctx fiber.Ctx, channel string) error {
|
||||
log := log.WithField("method", "pays.Callback")
|
||||
|
||||
notify, err := ctl.wepay.ParseNotify(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("ParseNotify error:%v", err)
|
||||
return ctx.Status(http.StatusBadRequest).JSON(fiber.Map{"error": "Failed to parse notify"})
|
||||
}
|
||||
|
||||
if err := ctl.job.Add(&jobs.WechatPayNotify{PayNotify: notify}); err != nil {
|
||||
log.Errorf("add job error:%v", err)
|
||||
return ctx.Status(http.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to add job"})
|
||||
}
|
||||
|
||||
return ctx.Status(http.StatusOK).JSON(&wechat.V3NotifyRsp{
|
||||
Code: gopay.SUCCESS,
|
||||
Message: "成功",
|
||||
})
|
||||
return ctl.wepay.ParseNotify(
|
||||
ctx,
|
||||
func(ctx fiber.Ctx, notify *wechat.V3DecryptPayResult) error {
|
||||
if err := ctl.job.Add(&jobs.WechatPayNotify{Notify: notify}); err != nil {
|
||||
log.Errorf("add job error:%v", err)
|
||||
return ctx.Status(http.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to add job"})
|
||||
}
|
||||
return nil
|
||||
},
|
||||
func(c fiber.Ctx, notify *wechat.V3DecryptRefundResult) error {
|
||||
if err := ctl.job.Add(&jobs.WechatRefundNotify{Notify: notify}); err != nil {
|
||||
log.Errorf("add job error:%v", err)
|
||||
return c.Status(http.StatusInternalServerError).JSON(fiber.Map{"error": "Failed to add job"})
|
||||
}
|
||||
return nil
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user