feat: 添加otel
This commit is contained in:
10
internal/service/supplier/third_party/apple.go
vendored
10
internal/service/supplier/third_party/apple.go
vendored
@@ -185,7 +185,7 @@ func (c *AppleCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roa
|
||||
|
||||
// KMEncrypt 加密卡密
|
||||
func (c *AppleCardImpl) kMEncrypt(kf, appSecret string) (string, error) {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "kMEncrypt")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果", "kMEncrypt")
|
||||
defer cancel()
|
||||
secret := utils.GetMD5LOWER(appSecret)[:16] // 加密秘钥
|
||||
block, err := aes.NewCipher([]byte(secret))
|
||||
@@ -202,7 +202,7 @@ func (c *AppleCardImpl) kMEncrypt(kf, appSecret string) (string, error) {
|
||||
}
|
||||
|
||||
func (c *AppleCardImpl) PayNotify() {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayNotify")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果", "PayNotify")
|
||||
defer cancel()
|
||||
attach := strings.TrimSpace(c.GetString("attach"))
|
||||
orderInfo := order.GetOrderByBankOrderId(ctx, attach) // OrderId
|
||||
@@ -239,7 +239,7 @@ func (c *AppleCardImpl) PayNotify() {
|
||||
}
|
||||
|
||||
func (c *AppleCardImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInfo) bool {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果", "PayQuery")
|
||||
defer cancel()
|
||||
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
@@ -305,7 +305,7 @@ func (c *AppleCardImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadIn
|
||||
}
|
||||
|
||||
func (c *AppleCardImpl) PayQueryV2(orderInfo order.OrderInfo, roadInfo road.RoadInfo) supply_model.MsgModel {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQueryV2")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果", "PayQueryV2")
|
||||
defer cancel()
|
||||
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
@@ -388,7 +388,7 @@ func (c *AppleCardImpl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
if err != nil {
|
||||
return config.PAYFOR_FAIL, ""
|
||||
}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayForQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果", "PayForQuery")
|
||||
defer cancel()
|
||||
|
||||
params := map[string]string{}
|
||||
|
||||
@@ -117,7 +117,7 @@ func (c *AppleCardSharkImpl) SendCard(ctx context.Context, jsonStr string, cardI
|
||||
}
|
||||
|
||||
func (c *AppleCardSharkImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) supplier.ScanData {
|
||||
ctx, cancel := otelTrace.Span(ctx, "AppleCardSharkImpl", "Scan", trace.WithAttributes(
|
||||
ctx, cancel := otelTrace.Span(ctx, "苹果鲨鱼", "Scan", trace.WithAttributes(
|
||||
attribute.String("BankOrderId", orderInfo.BankOrderId),
|
||||
attribute.String("MerchantUid", orderInfo.MerchantUid),
|
||||
attribute.String("ExValue", orderInfo.ExValue),
|
||||
@@ -166,7 +166,7 @@ func (c *AppleCardSharkImpl) kMEncrypt(ctx context.Context, kf, appSecret string
|
||||
}
|
||||
|
||||
func (c *AppleCardSharkImpl) PayNotify() {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayNotify")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果鲨鱼", "PayNotify")
|
||||
defer cancel()
|
||||
attach := strings.TrimSpace(c.GetString("attach"))
|
||||
orderInfo := order.GetOrderByBankOrderId(ctx, attach) // OrderId
|
||||
@@ -218,7 +218,7 @@ func (c *AppleCardSharkImpl) PayNotify() {
|
||||
|
||||
func (c *AppleCardSharkImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInfo) bool {
|
||||
params := map[string]any{}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果鲨鱼", "PayQuery")
|
||||
defer cancel()
|
||||
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
@@ -283,7 +283,7 @@ func (c *AppleCardSharkImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.R
|
||||
|
||||
func (c *AppleCardSharkImpl) PayQueryV2(orderInfo order.OrderInfo, roadInfo road.RoadInfo) supply_model.MsgModel {
|
||||
params := map[string]any{}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "AppleCardSharkImpl")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果鲨鱼", "AppleCardSharkImpl")
|
||||
defer cancel()
|
||||
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
@@ -360,7 +360,7 @@ func (c *AppleCardSharkImpl) PayFor(info payfor.PayforInfo) string {
|
||||
|
||||
func (c *AppleCardSharkImpl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
cfg := config.Config{}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayForQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "苹果鲨鱼", "PayForQuery")
|
||||
defer cancel()
|
||||
|
||||
url, err := cfg.GetMFCardQueryUrl()
|
||||
|
||||
@@ -133,7 +133,7 @@ func (f *FatSixImpl) sendCard(ctx context.Context, jsonStr string, cardInfo supp
|
||||
}
|
||||
|
||||
func (f *FatSixImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadInfo road.RoadInfo, info3 merchant.MerchantInfo) supplier.ScanData {
|
||||
ctx, cancel := otelTrace.Span(ctx, "FatSixImpl", "Scan", trace.WithAttributes(
|
||||
ctx, cancel := otelTrace.Span(ctx, "胖小六", "Scan", trace.WithAttributes(
|
||||
attribute.String("BankOrderId", orderInfo.BankOrderId),
|
||||
attribute.String("MerchantUid", orderInfo.MerchantUid),
|
||||
attribute.String("ExValue", orderInfo.ExValue),
|
||||
|
||||
12
internal/service/supplier/third_party/jd.go
vendored
12
internal/service/supplier/third_party/jd.go
vendored
@@ -113,7 +113,7 @@ func (c *JDCardImpl) SendCard(ctx context.Context, jsonStr string, cardInfo supp
|
||||
}
|
||||
|
||||
func (c *JDCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) supplier.ScanData {
|
||||
ctx, cancel := otelTrace.Span(ctx, "JDCardImpl", "Scan", trace.WithAttributes(
|
||||
ctx, cancel := otelTrace.Span(ctx, "京东", "Scan", trace.WithAttributes(
|
||||
attribute.String("BankOrderId", orderInfo.BankOrderId),
|
||||
attribute.String("MerchantUid", orderInfo.MerchantUid),
|
||||
attribute.String("ExValue", orderInfo.ExValue),
|
||||
@@ -147,7 +147,7 @@ func (c *JDCardImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadIn
|
||||
|
||||
// KMEncrypt 加密卡密
|
||||
func (c *JDCardImpl) kMEncrypt(kf, appSecret string) (string, error) {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "kMEncrypt")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "京东", "kMEncrypt")
|
||||
defer cancel()
|
||||
|
||||
secret := utils.GetMD5LOWER(appSecret)[:16] // 加密秘钥
|
||||
@@ -165,7 +165,7 @@ func (c *JDCardImpl) kMEncrypt(kf, appSecret string) (string, error) {
|
||||
}
|
||||
|
||||
func (c *JDCardImpl) PayNotify() {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayNotify")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "京东", "PayNotify")
|
||||
defer cancel()
|
||||
attach := strings.TrimSpace(c.GetString("merchantId"))
|
||||
orderInfo := order.GetOrderByBankOrderId(ctx, attach) // OrderId
|
||||
@@ -216,7 +216,7 @@ func (c *JDCardImpl) PayNotify() {
|
||||
|
||||
func (c *JDCardImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInfo) bool {
|
||||
params := map[string]any{}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "京东", "PayQuery")
|
||||
defer cancel()
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
if err != nil {
|
||||
@@ -280,7 +280,7 @@ func (c *JDCardImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInfo)
|
||||
|
||||
func (c *JDCardImpl) PayQueryV2(orderInfo order.OrderInfo, roadInfo road.RoadInfo) supply_model.MsgModel {
|
||||
params := map[string]any{}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQueryV2")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "京东", "PayQueryV2")
|
||||
defer cancel()
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
if err != nil {
|
||||
@@ -355,7 +355,7 @@ func (c *JDCardImpl) PayFor(info payfor.PayforInfo) string {
|
||||
}
|
||||
|
||||
func (c *JDCardImpl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayForQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "京东", "PayForQuery")
|
||||
defer cancel()
|
||||
cfg := config.Config{}
|
||||
url, err := cfg.GetMFCardQueryUrl()
|
||||
|
||||
@@ -127,7 +127,7 @@ func (c *MFCardV2Impl) SendCard(ctx context.Context, jsonStr string, cardInfo su
|
||||
}
|
||||
|
||||
func (c *MFCardV2Impl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) supplier.ScanData {
|
||||
ctx, cancel := otelTrace.Span(ctx, "MFCardV2Impl", "Scan", trace.WithAttributes(
|
||||
ctx, cancel := otelTrace.Span(ctx, "蜜蜂178", "Scan", trace.WithAttributes(
|
||||
attribute.String("BankOrderId", orderInfo.BankOrderId),
|
||||
attribute.String("MerchantUid", orderInfo.MerchantUid),
|
||||
attribute.String("ExValue", orderInfo.ExValue),
|
||||
@@ -171,7 +171,7 @@ func (c *MFCardV2Impl) Scan(ctx context.Context, orderInfo order.OrderInfo, road
|
||||
|
||||
// KMEncrypt 加密卡密
|
||||
func (c *MFCardV2Impl) kMEncrypt(kf, appSecret string) (string, error) {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "kMEncrypt")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "蜜蜂178", "kMEncrypt")
|
||||
defer cancel()
|
||||
secret := utils.GetMD5LOWER(appSecret)[:16] // 加密秘钥
|
||||
block, err := aes.NewCipher([]byte(secret))
|
||||
@@ -188,7 +188,7 @@ func (c *MFCardV2Impl) kMEncrypt(kf, appSecret string) (string, error) {
|
||||
}
|
||||
|
||||
func (c *MFCardV2Impl) PayNotify() {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayNotify")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "蜜蜂178", "PayNotify")
|
||||
defer cancel()
|
||||
otelTrace.Logger.WithContext(ctx).Info("消息回调成功!!!")
|
||||
params := make(map[string]any)
|
||||
@@ -257,7 +257,7 @@ func (c *MFCardV2Impl) PayNotify() {
|
||||
}
|
||||
|
||||
func (c *MFCardV2Impl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInfo) bool {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "蜜蜂178", "PayQuery")
|
||||
defer cancel()
|
||||
params := map[string]any{}
|
||||
|
||||
@@ -322,7 +322,7 @@ func (c *MFCardV2Impl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInf
|
||||
}
|
||||
|
||||
func (c *MFCardV2Impl) PayQueryV2(orderInfo order.OrderInfo, roadInfo road.RoadInfo) supply_model.MsgModel {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQueryV2")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "蜜蜂178", "PayQueryV2")
|
||||
defer cancel()
|
||||
params := map[string]any{}
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
@@ -399,7 +399,7 @@ func (c *MFCardV2Impl) PayFor(info payfor.PayforInfo) string {
|
||||
}
|
||||
|
||||
func (c *MFCardV2Impl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayForQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "蜜蜂178", "PayForQuery")
|
||||
defer cancel()
|
||||
cfg := config.Config{}
|
||||
url, err := cfg.GetMFCardQueryUrl()
|
||||
|
||||
10
internal/service/supplier/third_party/walmart.go
vendored
10
internal/service/supplier/third_party/walmart.go
vendored
@@ -187,7 +187,7 @@ func (c *WalMartImpl) SendCard(ctx context.Context, jsonStr string, cardInfo sup
|
||||
}
|
||||
|
||||
func (c *WalMartImpl) Scan(ctx context.Context, orderInfo order.OrderInfo, roadInfo road.RoadInfo, merchantInfo merchant.MerchantInfo) supplier.ScanData {
|
||||
ctx, cancel := otelTrace.Span(ctx, "WalMartImpl", "Scan", trace.WithAttributes(
|
||||
ctx, cancel := otelTrace.Span(ctx, "沃尔玛星耀", "Scan", trace.WithAttributes(
|
||||
attribute.String("BankOrderId", orderInfo.BankOrderId),
|
||||
attribute.String("MerchantUid", orderInfo.MerchantUid),
|
||||
attribute.String("ExValue", orderInfo.ExValue),
|
||||
@@ -232,7 +232,7 @@ type ResponseStruct struct {
|
||||
}
|
||||
|
||||
func (c *WalMartImpl) PayNotify() {
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayNotify")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "沃尔玛星耀", "PayNotify")
|
||||
defer cancel()
|
||||
otelTrace.Logger.WithContext(ctx).Info("【沃尔玛】快付回调开始")
|
||||
response := ResponseStruct{}
|
||||
@@ -271,7 +271,7 @@ func (c *WalMartImpl) PayNotify() {
|
||||
|
||||
func (c *WalMartImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInfo) bool {
|
||||
params := map[string]any{}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "沃尔玛星耀", "PayQuery")
|
||||
defer cancel()
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
if err != nil {
|
||||
@@ -335,7 +335,7 @@ func (c *WalMartImpl) PayQuery(orderInfo order.OrderInfo, roadInfo road.RoadInfo
|
||||
|
||||
func (c *WalMartImpl) PayQueryV2(orderInfo order.OrderInfo, roadInfo road.RoadInfo) supply_model.MsgModel {
|
||||
params := map[string]any{}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayQueryV2")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "沃尔玛星耀", "PayQueryV2")
|
||||
defer cancel()
|
||||
cardData, err := sonic.GetFromString(orderInfo.CardReturnData)
|
||||
if err != nil {
|
||||
@@ -415,7 +415,7 @@ func (c *WalMartImpl) PayForQuery(payFor payfor.PayforInfo) (string, string) {
|
||||
if err != nil {
|
||||
return config.PAYFOR_FAIL, ""
|
||||
}
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "", "PayForQuery")
|
||||
ctx, cancel := otelTrace.Span(c.Ctx.Request.Context(), "沃尔玛星耀", "PayForQuery")
|
||||
defer cancel()
|
||||
params := map[string]string{}
|
||||
params["order_id"] = payFor.BankOrderId
|
||||
|
||||
Reference in New Issue
Block a user