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

gjson 改json

上级 21c43c59
...@@ -51,10 +51,6 @@ func (s *category) QueryMallCategoryList(ctx context.Context,item int64) (res *Q ...@@ -51,10 +51,6 @@ func (s *category) QueryMallCategoryList(ctx context.Context,item int64) (res *Q
StrNumber: true, StrNumber: true,
}).Scan(&res) }).Scan(&res)
//req ,_:=gjson.Encode(item)
//resultString ,_:=gjson.Encode(result)
//log(ctx,string(req),err,string(resultString))
return return
} }
type CategoryListRes struct { type CategoryListRes struct {
......
...@@ -2,9 +2,9 @@ package tm ...@@ -2,9 +2,9 @@ package tm
import ( import (
"context" "context"
"encoding/json"
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"
"github.com/gogf/gf/encoding/gjson"
) )
type logisticsTmNew struct { type logisticsTmNew struct {
...@@ -43,7 +43,6 @@ func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn ...@@ -43,7 +43,6 @@ func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn
if client==nil{ if client==nil{
return return
} }
result ,err :=client.QueryLogistics4Distribution(&link.QueryLogistics4DistributionRequest{ result ,err :=client.QueryLogistics4Distribution(&link.QueryLogistics4DistributionRequest{
DistributorId: tea.String(server.DistributorId), DistributorId: tea.String(server.DistributorId),
MainDistributionOrderId: tea.String(orderSn), MainDistributionOrderId: tea.String(orderSn),
...@@ -56,7 +55,7 @@ func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn ...@@ -56,7 +55,7 @@ func (s *logisticsTmNew) QueryLogistics4Distribution(ctx context.Context,orderSn
if result==nil{ if result==nil{
return return
} }
err =gjson.New(result.Body).Scan(&res) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
return return
} }
\ No newline at end of file
...@@ -6,7 +6,7 @@ import ( ...@@ -6,7 +6,7 @@ import (
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"
"github.com/gogf/gf/encoding/gjson" "github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
) )
type orderTm struct { type orderTm struct {
...@@ -79,7 +79,7 @@ type RenderDistributionOrderRes struct { ...@@ -79,7 +79,7 @@ type RenderDistributionOrderRes struct {
type OrderCreateReq struct { type OrderCreateReq struct {
UserId string UserId string
ChannelOrder string ChannelOrder string
Address OrderAddress Address string
ItemLists []OrderGoodsItem ItemLists []OrderGoodsItem
} }
type OrderGoodsItem struct { type OrderGoodsItem struct {
...@@ -236,6 +236,24 @@ type OrderStatusRes struct { ...@@ -236,6 +236,24 @@ type OrderStatusRes struct {
// //
//99:交易成功 //99:交易成功
} }
type AddrInfoReq struct {
DivisionCode string `json:"DivisionCode"`
}
type AddrInfoRes struct {
RequestId string `json:"RequestId"`
Message string `json:"Message"`
Code string `json:"Code"`
Model struct{
DivisionList []AddrInfo `json:"DivisionList"`
} `json:"Model"`
}
type AddrInfo struct {
ParentId int `json:"ParentId"`
DivisionLevel int `json:"DivisionLevel"`
DivisionName string `json:"DivisionName"`
Pinyin string `json:"Pinyin"`
DivisionCode int `json:"DivisionCode"`
}
//Before 验证订单商品 //Before 验证订单商品
func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderReq) (res *RenderDistributionOrderRes, err error) { func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderReq) (res *RenderDistributionOrderRes, err error) {
client,err :=initClient() client,err :=initClient()
...@@ -250,13 +268,12 @@ func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderRe ...@@ -250,13 +268,12 @@ func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderRe
} }
var itemInfoLists []*link.RenderDistributionOrderRequestItemInfoLists var itemInfoLists []*link.RenderDistributionOrderRequestItemInfoLists
err =gjson.New(itemInfo.ItemInfoLists).Scan(&itemInfoLists) err =gjson.New(itemInfo.ItemInfoLists).Scan(&itemInfoLists)
result ,err :=client.RenderDistributionOrder(&link.RenderDistributionOrderRequest{ result ,err :=client.RenderDistributionOrder(&link.RenderDistributionOrderRequest{
BuyerId: tea.String(itemInfo.BuyerId), BuyerId: tea.String(itemInfo.BuyerId),
DistributorId: tea.String(server.DistributorId), DistributorId: tea.String(server.DistributorId),
ItemInfoLists: itemInfoLists, ItemInfoLists: itemInfoLists,
TenantId: tea.String(server.TenantId), TenantId: tea.String(server.TenantId),
DeliveryAddress: tea.String(gjson.New(itemInfo.Addr).MustToJsonString()), DeliveryAddress: tea.String(itemInfo.Addr),
DistributionSupplierId: tea.String(server.DistributionSupplierId), DistributionSupplierId: tea.String(server.DistributionSupplierId),
}) })
if err!=nil{ if err!=nil{
...@@ -266,11 +283,14 @@ func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderRe ...@@ -266,11 +283,14 @@ func (s *orderTm) Before(ctx context.Context,itemInfo *RenderDistributionOrderRe
if result==nil{ if result==nil{
return return
} }
_ = gjson.NewWithOptions(result.Body, gjson.Options{ a,_ :=json.Marshal(result.Body)
StrNumber: true, if err = json.Unmarshal([]byte(a), &res); err != nil {
}).Scan(&res) return
}
return return
} }
//订单列表 //订单列表
func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRes, err error) { func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRes, err error) {
client,err :=initClient() client,err :=initClient()
...@@ -296,7 +316,7 @@ func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRe ...@@ -296,7 +316,7 @@ func (s *orderTm) List(ctx context.Context,item *OrderListReq) (res *OrderListRe
return return
} }
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 {
panic(err) panic(err)
} }
return return
...@@ -322,7 +342,7 @@ func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCr ...@@ -322,7 +342,7 @@ func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCr
DistributionSupplierId: tea.String(server.DistributionSupplierId), DistributionSupplierId: tea.String(server.DistributionSupplierId),
BuyerId: tea.String(item.UserId), BuyerId: tea.String(item.UserId),
ItemInfoLists: itemInfoLists, ItemInfoLists: itemInfoLists,
DeliveryAddress: tea.String(gjson.New(item.Address).MustToJsonString()), DeliveryAddress: tea.String(item.Address),
}) })
if err!=nil{ if err!=nil{
return return
...@@ -331,7 +351,6 @@ func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCr ...@@ -331,7 +351,6 @@ func (s *orderTm) Create(ctx context.Context,item *OrderCreateReq) (res *OrderCr
if result==nil{ if result==nil{
return return
} }
err =gjson.New(result.Body).Scan(&res) err =gjson.New(result.Body).Scan(&res)
return return
} }
...@@ -344,7 +363,6 @@ func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfo ...@@ -344,7 +363,6 @@ func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfo
if client==nil{ if client==nil{
return return
} }
g.Dump(item.MainDistributionOrderId,"item.MainDistributionOrderId")
result ,err :=client.QueryOrderDetail4Distribution(&link.QueryOrderDetail4DistributionRequest{ result ,err :=client.QueryOrderDetail4Distribution(&link.QueryOrderDetail4DistributionRequest{
DistributorId: tea.String(server.DistributorId), DistributorId: tea.String(server.DistributorId),
MainDistributionOrderId: tea.String(item.MainDistributionOrderId), MainDistributionOrderId: tea.String(item.MainDistributionOrderId),
...@@ -358,7 +376,10 @@ func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfo ...@@ -358,7 +376,10 @@ func (s *orderTm) Detail(ctx context.Context,item *OrderInfoReq) (res *OrderInfo
return return
} }
err =gjson.New(result.Body).Scan(&res) a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
}
return return
} }
...@@ -384,9 +405,41 @@ func (s *orderTm) Status(ctx context.Context,item *OrderStatusReq) (res *OrderSt ...@@ -384,9 +405,41 @@ func (s *orderTm) Status(ctx context.Context,item *OrderStatusReq) (res *OrderSt
if result==nil{ if result==nil{
return return
} }
err =gjson.New(result.Body).Scan(&res) a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
}
return
}
//地址
func (s *orderTm) AddrInfo(ctx context.Context,itemInfo *AddrInfoReq) (res *AddrInfoRes, err error) {
client,err :=initClient()
if err!=nil{
return
}
if client==nil{
return
}
result ,err :=client.QueryChildDivisionCodeById(&link.QueryChildDivisionCodeByIdRequest{
DistributorId: tea.String(server.DistributorId),
DivisionCode: tea.String(itemInfo.DivisionCode),
TenantId: tea.String(server.TenantId),
})
if err!=nil{
return
}
if result==nil{
return
}
a,_ :=json.Marshal(result.Body)
if err = json.Unmarshal([]byte(a), &res); err != nil {
panic(err)
}
return return
} }
//订单详情 //订单详情
......
...@@ -5,7 +5,6 @@ import ( ...@@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
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"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gconv"
) )
...@@ -113,6 +112,7 @@ func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *Refun ...@@ -113,6 +112,7 @@ func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *Refun
TenantId: tea.String(server.TenantId), TenantId: tea.String(server.TenantId),
GoodsStatus: tea.Int32(gconv.Int32(req.GoodsStatus)), GoodsStatus: tea.Int32(gconv.Int32(req.GoodsStatus)),
}) })
if err!=nil{ if err!=nil{
return return
} }
...@@ -120,7 +120,8 @@ func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *Refun ...@@ -120,7 +120,8 @@ func (s *refundTm) Before(ctx context.Context, req *RefundBeforeReq) (res *Refun
if result==nil{ if result==nil{
return return
} }
err =gjson.New(result.Body).Scan(&res) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
return return
} }
...@@ -140,7 +141,7 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA ...@@ -140,7 +141,7 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA
ApplyReasonTextId: tea.Int64(req.ApplyReasonTextId), ApplyReasonTextId: tea.Int64(req.ApplyReasonTextId),
ApplyRefundCount: tea.Int32(req.ApplyRefundCount), ApplyRefundCount: tea.Int32(req.ApplyRefundCount),
ApplyRefundFee: tea.Int64(req.ApplyRefundFee), ApplyRefundFee: tea.Int64(req.ApplyRefundFee),
BizClaimType: tea.Int32(req.ApplyRefundCount), BizClaimType: tea.Int32(gconv.Int32(req.BizClaimType)),//gconv.Int32(req.BizClaimType)
DistributorId: tea.String(server.DistributorId), DistributorId: tea.String(server.DistributorId),
GoodsStatus: tea.Int32(req.GoodsStatus), GoodsStatus: tea.Int32(req.GoodsStatus),
//LeaveMessage: tea.String("测试退款"), //LeaveMessage: tea.String("测试退款"),
...@@ -155,7 +156,8 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA ...@@ -155,7 +156,8 @@ func (s *refundTm) Apply(ctx context.Context, req *RefundApplyReq) (res *RefundA
if result==nil{ if result==nil{
return return
} }
err =gjson.New(result.Body).Scan(&res) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
return return
} }
...@@ -221,7 +223,8 @@ func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *Common ...@@ -221,7 +223,8 @@ func (s *refundTm) Submit(ctx context.Context, req RefundSubmitReq) (res *Common
if result==nil{ if result==nil{
return return
} }
err =gjson.New(result.Body).Scan(&res) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
return return
} }
...@@ -249,7 +252,8 @@ func (s *refundTm) Cancel(ctx context.Context, UserId, subLmOrderId, disputeId s ...@@ -249,7 +252,8 @@ func (s *refundTm) Cancel(ctx context.Context, UserId, subLmOrderId, disputeId s
if result==nil{ if result==nil{
return return
} }
err =gjson.New(result.Body).Scan(&res) a,_:=json.Marshal(result.Body)
err =json.Unmarshal([]byte(a),&res)
return return
} }
...@@ -274,9 +278,7 @@ func (s *refundTm) Detail(ctx context.Context,subOrderId string) (res *RefundInf ...@@ -274,9 +278,7 @@ func (s *refundTm) Detail(ctx context.Context,subOrderId string) (res *RefundInf
if result==nil{ if result==nil{
return return
} }
a,_ :=json.Marshal(result.Body) a,_:=json.Marshal(result.Body)
if err := json.Unmarshal([]byte(a), &res); err != nil { err =json.Unmarshal([]byte(a),&res)
panic(err)
}
return return
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论