fix:支付

This commit is contained in:
momo 2023-09-28 18:04:35 +08:00
parent e991ee3966
commit 821c2063c9
2 changed files with 13 additions and 11 deletions

View File

@ -34,7 +34,7 @@ func main() {
ctx := svc.NewServiceContext(c) ctx := svc.NewServiceContext(c)
handler.RegisterHandlers(server, ctx) handler.RegisterHandlers(server, ctx)
go ctx.Repositories.NewOrder.CloseList(context.Background(), &repositories.CloseListReq{}) go ctx.Repositories.NewOrder.CloseList(context.Background(), &repositories.CloseListReq{Type: 1})
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port) fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
server.Start() server.Start()

View File

@ -217,16 +217,18 @@ func (d *defaultOrder) CloseList(ctx context.Context, in *CloseListReq) (res *Cl
} else { } else {
dtime = time.Now().Add(time.Second * time.Duration(math.Abs(float64(dd)))) dtime = time.Now().Add(time.Second * time.Duration(math.Abs(float64(dd))))
} }
// 延时任务 if in.Type == 1 {
d.DelayQueue.AddTask(dtime, constants.QUEUE_NAME_ORDER, func(args ...interface{}) { // 延时任务
ctx := context.Background() d.DelayQueue.AddTask(dtime, constants.QUEUE_NAME_ORDER, func(args ...interface{}) {
orderSn := args[0].(string) ctx := context.Background()
logc.Infof(ctx, "order close, orderSn: %s", orderSn) orderSn := args[0].(string)
d.Close(ctx, &CloseReq{ logc.Infof(ctx, "order close, orderSn: %s", orderSn)
OrderSn: orderSn, d.Close(ctx, &CloseReq{
Type: 1, OrderSn: orderSn,
}) Type: 1,
}, []interface{}{*orderInfo.OrderSn}) })
}, []interface{}{*orderInfo.OrderSn})
}
} }
return nil, nil return nil, nil
} }