83 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
			
		
		
	
	
			83 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Go
		
	
	
	
| package main
 | |
| 
 | |
| import (
 | |
| 	"codeup.aliyun.com/6552e56cc3b2728a4557fc18/plugin/instance"
 | |
| 	"codeup.aliyun.com/6552e56cc3b2728a4557fc18/plugin/proto"
 | |
| 	"context"
 | |
| 	"encoding/json"
 | |
| 	"log"
 | |
| )
 | |
| 
 | |
| var conf = &instance.PkgConf{
 | |
| 	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 := instance.Load([]*instance.PkgConf{conf})
 | |
| 	if err != nil {
 | |
| 		panic(err)
 | |
| 	}
 | |
| 	zltx()
 | |
| }
 | |
| 
 | |
| func zltx() {
 | |
| 	res, err := instance.Order(context.Background(), conf.Tag, getOrderRequest())
 | |
| 	if err != nil {
 | |
| 		log.Fatalln(err)
 | |
| 	}
 | |
| 	log.Printf("Order res:%+v", res)
 | |
| 
 | |
| 	resQuery, err := instance.Query(context.Background(), conf.Tag, getQueryRequest())
 | |
| 	if err != nil {
 | |
| 		log.Fatalln(err)
 | |
| 	}
 | |
| 	log.Printf("Query res:%+v", resQuery)
 | |
| }
 | |
| 
 | |
| func getOrderRequest() *proto.OrderRequest {
 | |
| 	return &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(`{}`),
 | |
| 		},
 | |
| 	}
 | |
| }
 | |
| 
 | |
| func getQueryRequest() *proto.QueryRequest {
 | |
| 	return &proto.QueryRequest{
 | |
| 		Config: config(),
 | |
| 		Order: &proto.QueryRequest_Order{
 | |
| 			OrderNo: "test_main_zltx_6",
 | |
| 		},
 | |
| 	}
 | |
| }
 |