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

加日志

上级 92566f9e
package tm
import (
"context"
openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
)
type Config struct {
......@@ -29,6 +32,7 @@ const (
format string = "JSON"
typeAnony string = "ANONY"
typeEp string = "EP"
logName string = "tmNew"
)
func New(req *Config) {
......@@ -46,6 +50,16 @@ func initClient() (client *link.Client, err error){
client, err = link.NewClient(config)
return
}
func log(ctx context.Context,param string ,res string,err error){
start := gtime.TimestampMilli()
if err != nil {
g.Log().Ctx(ctx).Cat(logName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", param, err.Error(), gtime.TimestampMilli()-start)
} else {
g.Log().Ctx(ctx).Cat(logName).Infof("参数【%v】响应【%v】响应时间【%v】", param, res, gtime.TimestampMilli()-start)
}
return
}
// todo 部分接口验签通过,部分不通过天猫技术不支持对接,后续有时间再自己写
//func specialUrlEncode(req string) (res string) {
// req = url.QueryEscape(req)
......
......@@ -41,16 +41,15 @@ func (s *category) QueryMallCategoryList(ctx context.Context,item int64) (res *Q
CategoryId: tea.Int64(item),
TenantId: tea.String(server.TenantId),
})
if err !=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
_ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true,
}).Scan(&res)
return
}
type CategoryListRes struct {
......
......@@ -178,12 +178,11 @@ func (s *goodsTmNew) QueryItemDetailWithDivision(ctx context.Context,item string
LmItemId: tea.String(item),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
_ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true,
}).Scan(&res)
......@@ -207,12 +206,12 @@ func (s *goodsTmNew) ListDistributionItem(ctx context.Context,item *ListDistribu
PageNumber: tea.Int32(1),
PageSize: tea.Int32(10),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
_ = gjson.NewWithOptions(result.Body, gjson.Options{
StrNumber: true,
}).Scan(&res)
......
......@@ -5,6 +5,7 @@ import (
"encoding/json"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
)
type logisticsTmNew struct {
......@@ -48,14 +49,15 @@ func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn
MainDistributionOrderId: tea.String(orderSn),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(orderSn).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
return
}
\ No newline at end of file
......@@ -276,13 +276,12 @@ func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderRe
DeliveryAddress: tea.String(itemInfo.Addr),
DistributionSupplierId: tea.String(server.DistributionSupplierId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(itemInfo).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
return
......@@ -308,13 +307,13 @@ func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRe
PageSize: tea.Int32(item.PageSize),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
......@@ -344,14 +343,14 @@ func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCr
ItemInfoLists: itemInfoLists,
DeliveryAddress: tea.String(item.Address),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
err =gjson.New(result.Body).Scan(&res)
return
}
//订单详情
......@@ -368,13 +367,11 @@ func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfo
MainDistributionOrderId: tea.String(item.MainDistributionOrderId),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
......@@ -398,13 +395,12 @@ func (s *orderTm) Status(ctx context.Context,item *OrderStatusReq) (res *OrderSt
TenantId: tea.String(server.TenantId),
DistributionSupplierId: tea.String(server.DistributionSupplierId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(item).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
......@@ -428,13 +424,12 @@ func (s *orderTm) AddrInfo(ctx context.Context,itemInfo *AddrInfoReq) (res *Addr
DivisionCode: tea.String(itemInfo.DivisionCode),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(itemInfo).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
......
......@@ -5,6 +5,7 @@ import (
"encoding/json"
link "github.com/alibabacloud-go/linkedmall-20220531/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv"
)
......@@ -113,13 +114,12 @@ func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *Refun
GoodsStatus: tea.Int32(gconv.Int32(req.GoodsStatus)),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(req).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
......@@ -149,13 +149,13 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA
SubDistributionOrderId: tea.String(req.SubLmOrderId),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(req).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
......@@ -216,13 +216,12 @@ func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *Common
LogisticsNo: tea.String(req.LogisticsNo),
CpCode: tea.String(req.CpCode),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(req).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
......@@ -245,13 +244,13 @@ func (s *refundTm) Cancel(ctx context.Context, UserId, subLmOrderId, disputeId s
SubDistributionOrderId: tea.String(subLmOrderId),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
log(ctx,gjson.New(disputeId).MustToJsonString(),gjson.New(result.Body).MustToJsonString(),err)
a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论