53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package cmb
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"go.opentelemetry.io/otel/trace"
|
|
"voucher/internal/biz/bo"
|
|
"voucher/internal/pkg/mq"
|
|
)
|
|
|
|
func (v *Cmb) PushOrderMQ(ctx context.Context, orderNo string) error {
|
|
|
|
eventMap := v.bc.RocketMQ.EventMap["order"]
|
|
sendOption := []mq.SendOption{
|
|
mq.WithSendShardingKeysOption(fmt.Sprintf("%s", orderNo)),
|
|
mq.WithOpenTelemetryOption(trace.SpanFromContext(ctx).SpanContext().TraceID().String()),
|
|
}
|
|
|
|
if err := v.MqSendMixRepo.SendSync(ctx, eventMap.Topic, []byte("{}"), sendOption...); err != nil {
|
|
return fmt.Errorf("收单成功,消费队列投递失败[%v]", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (v *Cmb) OrderConsume(ctx context.Context, order *bo.OrderBo) (err error) {
|
|
return
|
|
}
|
|
|
|
func (v *Cmb) PushQueryDelayMQ(ctx context.Context, orderNo string) error {
|
|
|
|
eventMap := v.bc.RocketMQ.EventMap["query"]
|
|
sendOption := []mq.SendOption{
|
|
mq.WithSendShardingKeysOption(orderNo),
|
|
mq.WithOpenTelemetryOption(trace.SpanFromContext(ctx).SpanContext().TraceID().String()),
|
|
mq.WithSendDelayLevelOption(300),
|
|
}
|
|
|
|
if err := v.MqSendMixRepo.SendSync(ctx, eventMap.Topic, []byte("{}"), sendOption...); err != nil {
|
|
return fmt.Errorf("查询入队投递失败[%v]", err)
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (v *Cmb) QueryConsume(ctx context.Context, order *bo.OrderBo) (err error) {
|
|
return
|
|
}
|
|
|
|
func (v *Cmb) NotifyConsume(ctx context.Context, orderNo string) (err error) {
|
|
return
|
|
}
|