78 lines
1.6 KiB
Go
78 lines
1.6 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"gitea.cdlsxd.cn/sdk/plugin/instance"
|
|
"gitea.cdlsxd.cn/sdk/plugin/manage"
|
|
"gitea.cdlsxd.cn/sdk/plugin/proto"
|
|
"log"
|
|
)
|
|
|
|
var zltxConf = &manage.Config{
|
|
Cmd: "pkg/zltx.so",
|
|
Tag: "zltx",
|
|
Version: 1,
|
|
CookieKey: "zltx",
|
|
CookieValue: "zltx",
|
|
}
|
|
|
|
func config() []byte {
|
|
type Config struct {
|
|
AppId string `json:"app_id"`
|
|
AppKey string `json:"app_key"`
|
|
BaseUri string `json:"base_uri"`
|
|
NotifyUrl string `json:"notify_url"`
|
|
}
|
|
c := &Config{
|
|
AppId: "23329",
|
|
AppKey: "8db16e8cc8363ed4eb4c14f9520bcc32",
|
|
BaseUri: "http://test.openapi.1688sup.cn",
|
|
NotifyUrl: "http://test.openapi.1688sup.cn",
|
|
}
|
|
marshal, _ := json.Marshal(c)
|
|
return marshal
|
|
}
|
|
|
|
// main 这只是一个演示
|
|
func main() {
|
|
err := manage.Add(zltxConf)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
zltx()
|
|
}
|
|
|
|
func zltx() {
|
|
orderRequest := &proto.OrderRequest{
|
|
Config: config(),
|
|
Order: &proto.OrderRequest_Order{
|
|
OrderNo: "test_main_zltx_6",
|
|
Account: "18666666666",
|
|
Quantity: 1,
|
|
Extra: nil,
|
|
},
|
|
Product: &proto.OrderRequest_Product{
|
|
ProductNo: "106",
|
|
Extra: []byte(`{}`),
|
|
},
|
|
}
|
|
queryRequest := &proto.QueryRequest{
|
|
Config: config(),
|
|
Order: &proto.QueryRequest_Order{
|
|
OrderNo: "test_main_zltx_6",
|
|
},
|
|
}
|
|
res, err := instance.Order(context.Background(), zltxConf.Tag, orderRequest)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
log.Printf("Order res:%+v", res)
|
|
|
|
resQuery, err := instance.Query(context.Background(), zltxConf.Tag, queryRequest)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
log.Printf("Query res:%+v", resQuery)
|
|
}
|