代码调整

This commit is contained in:
ziming 2025-06-16 19:04:07 +08:00
parent e2c5113d4c
commit b66023880d
4 changed files with 100 additions and 2 deletions

5
cmd/log.log Normal file
View File

@ -0,0 +1,5 @@
ERROR ts=2025-06-16T17:21:22+08:00 caller=client/order_digit.go:196 service.id=6551dda3098b service.name=market-gatway service.version=v1.0.1-631-gb1b82e6e msg=回调调用插件服务失败:
map[body:{"cardCode":"krorwUJwLmlr7pec6pjcOTOdsc4RrkPFOb27YhFGts3ljozBAeGFmAzZKlFK/RFU","merchantId":25943,"outTradeNo":"202506160907157760019451","status":"01"}
config:{"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"}
err:rpc error: code = Internal desc = 系统错误rpc error: code = Unavailable desc = connection error: desc = "transport: error while dialing: dial unix /tmp/plugin1274584100: connect: connection refused"
headers:{"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"]} tag:zltx_card_v1]

View File

@ -6,5 +6,6 @@ func main() {
//zltxQuery() //zltxQuery()
//wechatQueryCpn() //wechatQueryCpn()
//alipayQueryRedPack() //alipayQueryRedPack()
wechatOrderCpn() //wechatOrderCpn()
zltxCardNotify()
} }

78
cmd/zltx_card.go Normal file
View File

@ -0,0 +1,78 @@
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
}
// main 这只是一个演示
func zltxCardNotify() {
err := manage.Add(zltxCardConf)
if err != nil {
log.Fatalln(err)
}
defer func() {
fmt.Println("zltx_card_v1 close start")
manage.Close()
fmt.Println("zltx_card_v1 close end")
}()
//req := &proto.NotifyRequest{
// Config: zlxtCardCf(),
// Queries: []byte(``),
// Headers: []byte(`{"Accept-Encoding":["gzip, deflate, br"],"Authorization":["MD5 appid=101,sign=1A821E1E6FA824C7099D7F17F58E1650"],"Connection":["close"],"Content-Length":["183"],"Content-Type":["application/json"],"Cookie":[""],"User-Agent":["GuzzleHttp/6.5.5 curl/7.69.1 PHP/7.2.34"],"X-Forwarded-For":["47.96.248.136"],"X-Real-Ip":["47.96.248.136"],"X-Remoteaddr":["172.18.0.1"]}`),
// Body: []byte(`{"merchantId":25943,"outTradeNo":"202506161700247580010056","tradeNo":"789175179564695553","status":"01","cardCode":"XPHrv0+uPVQOqfymz1jJAsLOOuGpfvgXi9RIF1m4tRCsDdvcZDDNY21M/22F56M1"`),
//}
// 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("Order err:%+v i:%d", err, i)
} else {
log.Printf("Order res:%+v i:%d", res, i)
}
}
}

View File

@ -67,7 +67,21 @@ func (p *ZLTXCardV1Service) Query(ctx context.Context, request *proto.QueryReque
return queryResp(request, resp, cardCode) return queryResp(request, resp, cardCode)
} }
func (p *ZLTXCardV1Service) Notify(ctx context.Context, request *proto.NotifyRequest) (*proto.NotifyResponse, error) { func (p *ZLTXCardV1Service) Notify(ctx context.Context, request *proto.NotifyRequest) (resp2 *proto.NotifyResponse, respErr error) {
select {
case <-ctx.Done():
return nil, ctx.Err()
default:
// 继续执行
}
defer func() {
if err := recover(); err != nil {
respErr = fmt.Errorf("panic: %v", err)
}
}()
c, err := transConfig(request.Config) c, err := transConfig(request.Config)
if err != nil { if err != nil {
return nil, err return nil, err