106 lines
2.9 KiB
Go
106 lines
2.9 KiB
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"gitea.cdlsxd.cn/sdk/plugin/instance"
|
|
"gitea.cdlsxd.cn/sdk/plugin/manage"
|
|
"gitea.cdlsxd.cn/sdk/plugin/proto"
|
|
"log"
|
|
)
|
|
|
|
var zltxCardConf = &manage.Config{
|
|
Cmd: "pkg/mac/zltx_card_v1.so",
|
|
Tag: "zltx_card_v1",
|
|
Version: 1,
|
|
CookieKey: "zltx_card_v1",
|
|
CookieValue: "zltx_card_v1",
|
|
}
|
|
|
|
func zlxtCardCf() []byte {
|
|
|
|
return []byte(`{"app_id":"101","app_key":"95E7EC7D4A394FF8D11788E5E436DE99","base_uri":"https://openapi.1688sup.com","merchant_id":25943,"notify_url":"https://market.86698.cn/v1/order/direct/notify"}`)
|
|
|
|
//type Config struct {
|
|
// AppId string `json:"app_id"`
|
|
// AppKey string `json:"app_key"`
|
|
// BaseUri string `json:"base_uri"`
|
|
// NotifyUrl string `json:"notify_url"`
|
|
// MerchantId int64 `json:"merchant_id"`
|
|
//}
|
|
//c := &Config{
|
|
// AppId: "101",
|
|
// AppKey: "95E7EC7D4A394FF8D11788E5E436DE99",
|
|
// BaseUri: "https://openapi.1688sup.com",
|
|
// NotifyUrl: "https://gateway.dev.cdlsxd.cn/yxh5api/v1/order/direct/notify",
|
|
// MerchantId: 25943,
|
|
//}
|
|
//marshal, _ := json.Marshal(c)
|
|
//return marshal
|
|
}
|
|
|
|
func zltxCardQuery() {
|
|
|
|
err := manage.Add(zltxCardConf)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
defer func() {
|
|
fmt.Println("zltx_card_v1_1 close start")
|
|
manage.Close()
|
|
fmt.Println("zltx_card_v1_1 close end")
|
|
}()
|
|
|
|
for i := 0; i < 1; i++ {
|
|
req := &proto.QueryRequest{
|
|
Config: zlxtCardCf(),
|
|
Order: &proto.QueryRequest_Order{
|
|
OrderNo: "test_plugin_zltx_v1_card_3",
|
|
TradeNo: "",
|
|
Account: "",
|
|
Extra: nil,
|
|
},
|
|
}
|
|
res, err := instance.Query(context.Background(), zltxCardConf.Tag, req)
|
|
if err != nil {
|
|
log.Printf("query err:%+v i:%d", err, i)
|
|
} else {
|
|
log.Printf("query res:%+v i:%d", res, i)
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// main 这只是一个演示
|
|
func zltxCardNotify() {
|
|
|
|
err := manage.Add(zltxCardConf)
|
|
if err != nil {
|
|
log.Fatalln(err)
|
|
}
|
|
|
|
defer func() {
|
|
fmt.Println("zltx_card_v1_1 close start")
|
|
manage.Close()
|
|
fmt.Println("zltx_card_v1_1 close end")
|
|
}()
|
|
|
|
// transport: error while dialing: dial unix /tmp/plugin2702936918: connect: connection refused
|
|
for i := 0; i < 5; i++ {
|
|
req := &proto.NotifyRequest{
|
|
Config: zlxtCardCf(),
|
|
Queries: []byte(``),
|
|
Headers: []byte(`{"Accept":["*/*"],"Accept-Encoding":["gzip, deflate, br"],"Authorization":["MD5 appid=101,sign=7EF17E77501F943FF98620D6D7D45140"],"Connection":["close"],"Content-Length":["152"],"Content-Type":["application/json"],"User-Agent":["Apifox/1.0.0 (https://apifox.com)"],"X-Forwarded-For":["117.175.169.61"],"X-Real-Ip":["117.175.169.61"],"X-Remoteaddr":["172.18.0.1"]}`),
|
|
Body: []byte(`{"cardCode":"krorwUJwLmlr7pec6pjcOTOdsc4RrkPFOb27YhFGts3ljozBAeGFmAzZKlFK/RFU","merchantId":25943,"outTradeNo":"202506160907157760019451","status":"01"}`),
|
|
}
|
|
res, err := instance.Notify(context.Background(), zltxCardConf.Tag, req)
|
|
if err != nil {
|
|
log.Printf("notify err:%+v i:%d", err, i)
|
|
} else {
|
|
log.Printf("notify res:%+v i:%d", res, i)
|
|
}
|
|
}
|
|
|
|
}
|