feat(card_sender): 添加请求提交前的随机延迟

- 引入lancet库生成随机数
- 在提交请求前添加5到10秒的随机睡眠时间
- 增加随机延迟以防止请求过于频繁造成问题
- 记录请求提交通知事件的开始和结束时间span事件
This commit is contained in:
danial
2025-12-10 18:15:21 +08:00
parent d8a5e32a52
commit 5e1710efb4

View File

@@ -9,6 +9,7 @@ import (
"gateway/internal/otelTrace"
"gateway/internal/utils"
"gateway/internal/utils/useragent"
"github.com/duke-git/lancet/v2/random"
"net/url"
"regexp"
"sort"
@@ -95,6 +96,7 @@ func (s *SendCardTaskTypeFlyFishV2) HandleSendCardTask(ctx context.Context, orde
))
defer span.End()
time.Sleep(time.Second * time.Duration(random.RandInt(5, 10)))
queryUrl, err := url.Parse(orderItem.PayURL)
if err != nil {
return errors.New("解析提交地址失败")
@@ -146,6 +148,8 @@ func (s *SendCardTaskTypeFlyFishV2) HandleSendCardTask(ctx context.Context, orde
"productCode": productCode,
}
time.Sleep(time.Second * time.Duration(random.RandInt(5, 10)))
span.AddEvent("start submit data")
resp, err := webClient.R().SetContext(ctx).SetFormData(formData).Post("https://ccfy.cardpay.fyi/submitcard")
span.AddEvent("end submit data")