1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package tmv3
import (
"context"
"github.com/alibabacloud-go/linkedmall-20230930/v2/client"
"github.com/alibabacloud-go/tea/tea"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv"
)
type OrderBeforeReq struct {
DeliveryAddress OrderDeliveryAddress `json:"deliveryAddress"`
BuyerId string `json:"buyerId"`
ProductList []OrderItem `json:"productList"`
}
type OrderBeforeRes struct {
RequestId string `json:"requestId"`
OrderList []struct {
ProductList []struct {
ProductId string `json:"productId"`
ProductTitle string `json:"productTitle"`
SkuTitle string `json:"skuTitle"`
SkuId string `json:"skuId"`
PurchaserId string `json:"purchaserId"`
PromotionFee interface{} `json:"promotionFee"`
Quantity int `json:"quantity"`
ProductUrl interface{} `json:"productUrl"`
ProductPicUrl string `json:"productPicUrl"`
Price int `json:"price"`
CanSell bool `json:"canSell"`
Message interface{} `json:"message"`
Features interface{} `json:"features"`
} `json:"productList"`
DeliveryInfoList []struct {
Id string `json:"id"`
DisplayName string `json:"displayName"`
PostFee int `json:"postFee"`
ServiceType int `json:"serviceType"`
} `json:"deliveryInfoList"`
InvoiceInfo interface{} `json:"invoiceInfo"`
ExtInfo interface{} `json:"extInfo"`
CanSell bool `json:"canSell"`
Message interface{} `json:"message"`
} `json:"orderList"`
UnsellableOrderList []struct {
ProductList []struct {
ProductId string `json:"productId"`
ProductTitle string `json:"productTitle"`
SkuTitle string `json:"skuTitle"`
SkuId string `json:"skuId"`
PurchaserId string `json:"purchaserId"`
PromotionFee interface{} `json:"promotionFee"`
Quantity int `json:"quantity"`
ProductUrl interface{} `json:"productUrl"`
ProductPicUrl string `json:"productPicUrl"`
Price int `json:"price"`
CanSell bool `json:"canSell"`
Message interface{} `json:"message"`
Features interface{} `json:"features"`
} `json:"productList"`
DeliveryInfoList interface{} `json:"deliveryInfoList"`
InvoiceInfo interface{} `json:"invoiceInfo"`
ExtInfo interface{} `json:"extInfo"`
CanSell bool `json:"canSell"`
Message interface{} `json:"message"`
} `json:"unsellableOrderList"`
AddressList []struct {
AddressId int `json:"addressId"`
Receiver string `json:"receiver"`
ReceiverPhone string `json:"receiverPhone"`
AddressDetail string `json:"addressDetail"`
DivisionCode string `json:"divisionCode"`
TownDivisionCode string `json:"townDivisionCode"`
} `json:"addressList"`
ExtInfo interface{} `json:"extInfo"`
CanSell bool `json:"canSell"`
Message interface{} `json:"message"`
}
// Before 采购单渲染
func (s orderTm) Before(ctx context.Context, req OrderBeforeReq) (res *OrderBeforeRes, err error) {
Start := gtime.TimestampMilli()
ctx = context.WithValue(ctx, "URI", "RenderPurchaseOrder")
defer func() {
Log(ctx, req, res, err, Start)
}()
Request := &client.RenderPurchaseOrderRequest{}
var Body = new(client.PurchaseOrderRenderQuery)
Body.SetBuyerId(req.BuyerId)
var DeliveryAddress = new(client.AddressInfo)
DeliveryAddress.SetDivisionCode(req.DeliveryAddress.DivisionCode)
DeliveryAddress.SetAddressDetail(req.DeliveryAddress.AddressDetail)
DeliveryAddress.SetReceiverPhone(req.DeliveryAddress.ReceiverPhone)
DeliveryAddress.SetReceiver(req.DeliveryAddress.Receiver)
DeliveryAddress.SetTownDivisionCode(req.DeliveryAddress.TownDivisionCode)
Body.SetDeliveryAddress(DeliveryAddress)
var list []*client.OrderRenderProductDTO
for _, item := range req.ProductList {
list = append(list, &client.OrderRenderProductDTO{
ProductId: tea.String(item.ProductId),
PurchaserId: tea.String(PurchaserId),
Quantity: tea.Int32(gconv.Int32(item.Quantity)),
SkuId: tea.String(item.SkuId),
})
}
Body.SetProductList(list)
Request.SetBody(Body)
r, err := server.RenderPurchaseOrder(Request)
if err != nil {
return
}
err = gjson.New(r.Body).Scan(&res)
return
}