Files
2026-05-20 16:13:58 +08:00

65 lines
1.6 KiB
Go

package checkWx
import (
"bytes"
"context"
"stat/common/httputil"
"stat/common/log"
"time"
)
const ApiToken string = "866mcJyA4teCehxivaCJec3qbghWStjA"
type Resp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
type CheckResp struct {
Code int `json:"code"`
Msg string `json:"msg"`
Data struct {
Pass bool `json:"pass"`
} `json:"data"`
}
//获取订单信息
func CheckWx(execUrl, domian string) (checkResp CheckResp, err error) {
c, cancle := context.WithTimeout(context.Background(), 5*time.Second)
defer cancle()
code, err := httputil.NewCtx(c).GetWithJResp(&checkResp, execUrl+"?"+bindUrl(domian), nil)
log.Info("http method CheckWx response code ==>", log.Any("statusCode", code), log.Any("checkResp", checkResp))
if err != nil {
log.Error("CheckWx failed", log.Any("Error", err))
}
return
}
func TgSend(msgPayload, text string) (resp Resp, err error) {
params := map[string]interface{}{
"tgName": "ys_bot",
"text": text,
"msgPayload": msgPayload,
"chatId": -228259065,
}
c, cancle := context.WithTimeout(context.Background(), 5*time.Second)
defer cancle()
code, err := httputil.NewCtx(c).POSTJsonWithJResp(&resp, "http://uni.ysappb.me/api/tg/send", nil, params)
log.Info("http method TgSend response code ==>", log.Any("statusCode", code), log.Any("resp", resp))
if err != nil {
log.Error("TgSend failed", log.Any("Error", err))
}
return
}
func bindUrl(domain string) string {
buf := bytes.Buffer{}
buf.WriteString("apiToken=")
buf.WriteString(ApiToken + "&")
buf.WriteString("req_url=")
buf.WriteString(domain)
return buf.String()
}