提交 aa4f55f2 authored 作者: 赵雪如's avatar 赵雪如

tmnew log

上级 afa4a967
...@@ -2,6 +2,7 @@ package tm ...@@ -2,6 +2,7 @@ package tm
import ( import (
"context" "context"
"encoding/json"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client" openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client" link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea" "github.com/alibabacloud-go/tea/tea"
...@@ -50,13 +51,13 @@ func initClient() (client *link.Client, err error){ ...@@ -50,13 +51,13 @@ func initClient() (client *link.Client, err error){
client, err = link.NewClient(config) client, err = link.NewClient(config)
return return
} }
func log(ctx context.Context,param string ,res string,err error){ func log(ctx context.Context,param string ,res interface{},err error){
start := gtime.TimestampMilli() start := gtime.TimestampMilli()
resString ,_:=json.Marshal(res)
if err != nil { if err != nil {
g.Log().Ctx(ctx).Cat(logName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", param, err.Error(), gtime.TimestampMilli()-start) g.Log().Ctx(ctx).Cat(logName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", param, err.Error(), gtime.TimestampMilli()-start)
} else { } else {
g.Log().Ctx(ctx).Cat(logName).Infof("参数【%v】响应【%v】响应时间【%v】", param, res, gtime.TimestampMilli()-start) g.Log().Ctx(ctx).Cat(logName).Infof("参数【%v】响应【%v】响应时间【%v】", param, string(resString), gtime.TimestampMilli()-start)
} }
return return
} }
......
...@@ -45,7 +45,7 @@ func (s *category) QueryMallCategoryList(ctx context.Context,item int64) (res *Q ...@@ -45,7 +45,7 @@ func (s *category) QueryMallCategoryList(ctx context.Context,item int64) (res *Q
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(item).MustToJsonString(),result.Body,err)
_ = gjson.NewWithOptions(result.Body, gjson.Options{ _ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true, StrNumber: true,
......
...@@ -182,10 +182,8 @@ func (s *goodsTmNew) QueryItemDetailWithDivision(ctx context.Context,item string ...@@ -182,10 +182,8 @@ func (s *goodsTmNew) QueryItemDetailWithDivision(ctx context.Context,item string
return return
} }
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(item).MustToJsonString(),result.Body,err)
if *result.Body.Success==false{
return
} //他们返回报错
_ = gjson.NewWithOptions(result.Body, gjson.Options{ _ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true, StrNumber: true,
}).Scan(&res) }).Scan(&res)
...@@ -213,7 +211,7 @@ func (s *goodsTmNew) ListDistributionItem(ctx context.Context,item *ListDistribu ...@@ -213,7 +211,7 @@ func (s *goodsTmNew) ListDistributionItem(ctx context.Context,item *ListDistribu
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(item).MustToJsonString(),result.Body,err)
_ = gjson.NewWithOptions(result.Body, gjson.Options{ _ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true, StrNumber: true,
......
...@@ -54,7 +54,7 @@ func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn ...@@ -54,7 +54,7 @@ func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(orderSn).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(orderSn).MustToJsonString(),result.Body,err)
a,_:=json.Marshal(result.Body) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res) err =json.Unmarshal([]byte(a),&res)
......
...@@ -280,7 +280,8 @@ func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderRe ...@@ -280,7 +280,8 @@ func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderRe
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(itemInfo).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
log(ctx,gjson.New(itemInfo).MustToJsonString(),result.Body,err)
a,_ :=json.Marshal(result.Body) a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil { if err = json.Unmarshal([]byte(a), &res); err != nil {
...@@ -312,7 +313,7 @@ func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRe ...@@ -312,7 +313,7 @@ func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRe
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(item).MustToJsonString(),result.Body,err)
a,_ :=json.Marshal(result.Body) a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil { if err = json.Unmarshal([]byte(a), &res); err != nil {
...@@ -347,7 +348,7 @@ func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCr ...@@ -347,7 +348,7 @@ func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCr
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(item).MustToJsonString(),result.Body,err)
err =gjson.New(result.Body).Scan(&res) err =gjson.New(result.Body).Scan(&res)
...@@ -371,7 +372,7 @@ func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfo ...@@ -371,7 +372,7 @@ func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfo
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(item).MustToJsonString(),result.Body,err)
a,_ :=json.Marshal(result.Body) a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil { if err = json.Unmarshal([]byte(a), &res); err != nil {
...@@ -399,7 +400,7 @@ func (s *orderTm) Status(ctx context.Context,item *OrderStatusReq) (res *OrderSt ...@@ -399,7 +400,7 @@ func (s *orderTm) Status(ctx context.Context,item *OrderStatusReq) (res *OrderSt
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(item).MustToJsonString(),result.Body,err)
a,_ :=json.Marshal(result.Body) a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil { if err = json.Unmarshal([]byte(a), &res); err != nil {
...@@ -428,7 +429,7 @@ func (s *orderTm) AddrInfo(ctx context.Context,itemInfo *AddrInfoReq) (res *Addr ...@@ -428,7 +429,7 @@ func (s *orderTm) AddrInfo(ctx context.Context,itemInfo *AddrInfoReq) (res *Addr
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(itemInfo).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(itemInfo).MustToJsonString(),result.Body,err)
a,_ :=json.Marshal(result.Body) a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil { if err = json.Unmarshal([]byte(a), &res); err != nil {
......
...@@ -118,7 +118,7 @@ func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *Refun ...@@ -118,7 +118,7 @@ func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *Refun
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(req).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(req).MustToJsonString(),result.Body,err)
a,_:=json.Marshal(result.Body) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res) err =json.Unmarshal([]byte(a),&res)
...@@ -154,7 +154,7 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA ...@@ -154,7 +154,7 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(req).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(req).MustToJsonString(),result.Body,err)
a,_:=json.Marshal(result.Body) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res) err =json.Unmarshal([]byte(a),&res)
...@@ -220,7 +220,7 @@ func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *Common ...@@ -220,7 +220,7 @@ func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *Common
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(req).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(req).MustToJsonString(),result.Body,err)
a,_:=json.Marshal(result.Body) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res) err =json.Unmarshal([]byte(a),&res)
...@@ -249,7 +249,7 @@ func (s *refundTm) Cancel(ctx context.Context, UserId, subLmOrderId, disputeId s ...@@ -249,7 +249,7 @@ func (s *refundTm) Cancel(ctx context.Context, UserId, subLmOrderId, disputeId s
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(disputeId).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err) log(ctx,gjson.New(disputeId).MustToJsonString(),result.Body,err)
a,_:=json.Marshal(result.Body) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res) err =json.Unmarshal([]byte(a),&res)
...@@ -270,13 +270,11 @@ func (s *refundTm) Detail(ctx context.Context,subOrderId string) (res *RefundInf ...@@ -270,13 +270,11 @@ func (s *refundTm) Detail(ctx context.Context,subOrderId string) (res *RefundInf
SubDistributionOrderId: tea.String(subOrderId), SubDistributionOrderId: tea.String(subOrderId),
TenantId: tea.String(server.TenantId), TenantId: tea.String(server.TenantId),
}) })
if err!=nil{
return
}
if result==nil{ if result==nil{
return return
} }
log(ctx,gjson.New(subOrderId).MustToJsonString(),result.Body,err)
a,_:=json.Marshal(result.Body) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res) err =json.Unmarshal([]byte(a),&res)
return return
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论