weixin

package
v0.0.0-...-4215923 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PAY_SUCCESS    = 1  //支付成功
	PAY_REFUND     = 2  //转入退款
	PAY_CLOSED     = 3  //已关闭
	PAY_NOTPAY     = 4  //未支付
	PAY_REVOKED    = 5  //已撤销
	PAY_USERPAYING = 6  //支付中
	PAY_ERROR      = -1 //支付失败
)
View Source
const (
	GETSHAREURL  = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="          //小程序码
	GETQRCODEURL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" //小程序二维码
)

Variables

View Source
var CertFileLoc = "/conf/cert/apiclient_cert.pem"

CertFileLoc cert.pem

View Source
var KeyFileLoc = "/conf/cert/apiclient_key.pem"

KeyFileLoc key.pem

View Source
var RootcaFileLoc = "/conf/cert/rootca.pem"

RootcaFileLoc rootca.pem

Functions

func NewWeLM

func NewWeLM(config *WeLMInfoReq, authorization string) *weLM

Types

type APITicket

type APITicket struct {
	Errcode   int    `json:"errcode"`
	Errmsg    string `json:"errmsg"`
	Ticket    string `json:"ticket"`
	ExpiresIn int    `json:"expires_in"`
}

APITicket ...

type AccessToken

type AccessToken struct {
	AccessToken  string `json:"access_token"`  //	网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
	ExpiresIn    string `json:"expires_in"`    // access_token接口调用凭证超时时间,单位(秒)
	RefreshToken string `json:"refresh_token"` //	用户刷新access_token
	Openid       string `json:"openid"`        // 用户唯一标识,请注意,在未关注公众号时,用户访问公众号的网页,也会产生一个用户和公众号唯一的OpenID
	Scope        string `json:"scope"`         // 用户授权的作用域,使用逗号(,)分隔
}

type Choices

type Choices struct {
	Text         string `json:"text"`
	Index        int    `json:"index"`
	Logprobs     int    `json:"logprobs"`
	FinishReason string `json:"finish_reason"`
}

type CustomImage

type CustomImage struct {
	MediaId string `json:"media_id"` //	图片
}

type CustomMsg

type CustomMsg struct {
	Touser  string       `json:"touser"`          //	是	接收者(用户)的 openid
	Msgtype string       `json:"msgtype"`         //	是	所需下发的模板消息的id
	Text    *CustomText  `json:"text,omitempty"`  //	文本类容
	Voice   *CustomVoice `json:"voice,omitempty"` //	语音
	Music   *CustomMusic `json:"music,omitempty"` //	音乐消息
	Image   *CustomImage `json:"image,omitempty"` //	图片消息
}

CustomMsg 客服消息头

type CustomMusic

type CustomMusic struct {
	Title        string `json:"title"`          // 标题
	Description  string `json:"description"`    // 描述
	MusicUrl     string `json:"musicurl"`       // 链接
	HQMusicUrl   string `json:"hqmusicurl"`     // 链接
	ThumbMediaId string `json:"thumb_media_id"` // 缩略图
}

type CustomText

type CustomText struct {
	Content string `json:"content"` //	文本类容
}

type CustomVoice

type CustomVoice struct {
	MediaId string `json:"media_id"` //	语音
}

type FreepublishiInfo

type FreepublishiInfo struct {
	ArticleId        string `json:"article_id"`         // 成功发布的图文消息id
	Title            string `json:"title"`              // 文章标题
	Author           string `json:"author"`             // 作者
	Digest           string `json:"digest"`             // 摘要
	ContentSourceUrl string `json:"content_source_url"` // 图文消息的原文地址,即点击“阅读原文”后的URL
	Url              string `json:"url"`                // 图文消息的URL
	ThumbMediaId     string `json:"thumb_media_id"`     //  图文消息的封面图片素材id(一定是永久MediaID)
	IsDeleted        bool   `json:"is_deleted"`         // 该图文是否被删除
	UpdateTime       int64  `json:"update_time"`        // 更新时间
}

type FreepublishiInfoContent

type FreepublishiInfoContent struct {
	NewsItem []FreepublishiInfoNewItem `json:"news_item"` // 成功发布的图文消息id
}

type FreepublishiInfoItem

type FreepublishiInfoItem struct {
	ArticleId  string                  `json:"article_id"`  // 成功发布的图文消息id
	UpdateTime int64                   `json:"update_time"` // 更新时间
	Content    FreepublishiInfoContent `json:"content"`
}

type FreepublishiInfoNewItem

type FreepublishiInfoNewItem struct {
	Title            string `json:"title"`              // 文章标题
	Author           string `json:"author"`             // 作者
	Digest           string `json:"digest"`             // 再要
	ContentSourceUrl string `json:"content_source_url"` // 图文消息的原文地址,即点击“阅读原文”后的URL
	Url              string `json:"url"`                // 图文消息的URL
	ThumbMediaId     string `json:"thumb_media_id"`     //  图文消息的封面图片素材id(一定是永久MediaID)
	IsDeleted        bool   `json:"is_deleted"`         // 该图文是否被删除
}

type FreepublishiInfoReq

type FreepublishiInfoReq struct {
	Offset    int64 `json:"offset"`
	Count     int64 `json:"count"`
	NoContent int64 `json:"no_content"`
}

type FreepublishiInfoResp

type FreepublishiInfoResp struct {
	TotalCount int                    `json:"total_count"`
	ItemCount  int                    `json:"item_count"`
	Item       []FreepublishiInfoItem `json:"item"`
}

type GetblacklistReq

type GetblacklistReq struct {
	BeginOpenid string `json:"begin_openid"` // 开始的openid
}

type GetblacklistResp

type GetblacklistResp struct {
	Total      int64      `json:"total"` // 总量
	Count      int64      `json:"count"` // 素材下载地址
	Data       OpenIDData `json:"data"`  //
	NextOpenid string     `json:"next_openid"`
}

type GuideAutoReply

type GuideAutoReply struct {
	Content string `json:"content"` // 新客户关注自动回复内容,图片填mediaid,获取方式同图片素材,小程序卡片填下面请求demo中字段的json格式
	Msgtype int    `json:"msgtype"` // 1表示文字,2表示图片,3表示小程序卡片
}

type GuideConfig

type GuideConfig struct {
	GuideAccount       string               `json:"guide_account"`         // 顾问号
	IsDelete           bool                 `json:"is_delete"`             // 操作类型,false表示添加 true表示删除
	GuideFastReplyList []GuideFastReplyList `json:"guide_fast_reply_list"` // 	快捷回复列表
	GuideAutoReply     GuideAutoReply       `json:"guide_auto_reply"`      //	第一条新客户关注自动回复
	GuideAutoReplyPlus GuideAutoReply       `json:"guide_auto_reply_plus"` //	第二条新客户关注自动回复
}

type GuideFastReplyList

type GuideFastReplyList struct {
	Content string `json:"content"` // 快捷回复
}

GuideFastReplyList 快捷回复列表

type MediaIdReq

type MediaIdReq struct {
	MediaId string `json:"media_id"` // 永久素材id
}

type MediaResp

type MediaResp struct {
	Title     string     `json:"title"`     // 素材标题
	DownUrl   string     `json:"down_url"`  // 素材下载地址
	NewsItemS []NewsItem `json:"news_item"` //
}

type NewsItem

type NewsItem struct {
	Title            string `json:"title"`              // 素材标题
	Url              string `json:"url"`                // 图文页的URL
	ContentSourceUrl string `json:"content_source_url"` // 图文消息的原文地址,即点击“阅读原文”后的URL
}

type OpenIDData

type OpenIDData struct {
	Openid []string `json:"openid"`
}

type QrcodeRet

type QrcodeRet struct {
	Errcode int    `json:"errcode"`
	Errmsg  string `json:"errmsg"`
}

QrcodeRet ...

type ResTempMsg

type ResTempMsg struct {
	Errcode int    `json:"errcode"` //
	Errmsg  string `json:"errmsg"`
}

ResTempMsg 模版消息返回值

type SubButton

type SubButton struct {
	Type string `json:"type,omitempty"`
	Name string `json:"name,omitempty"`
	Key  string `json:"key,omitempty"`
	Url  string `json:"url,omitempty"`
}

type TempMsg

type TempMsg struct {
	Touser     string                       `json:"touser"`      //	是	接收者(用户)的 openid
	TemplateID string                       `json:"template_id"` //	是	所需下发的模板消息的id
	Page       string                       `json:"page"`        //	否	点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
	Data       map[string]map[string]string `json:"data"`        //是	模板内容,不填则下发空模板
}

TempMsg 订阅消息头

type TempWebMsg

type TempWebMsg struct {
	Touser     string                       `json:"touser"`      //	是	接收者(用户)的 openid
	TemplateID string                       `json:"template_id"` //	是	所需下发的模板消息的id
	Page       string                       `json:"url"`         //	否	点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
	Data       map[string]map[string]string `json:"data"`        //是	模板内容,不填则下发空模板
}

TempMsg 订阅消息头

type UploadTmpFileResp

type UploadTmpFileResp struct {
	Tp        string `json:"type"`
	MediaId   string `json:"media_id"`
	CreatedAt int64  `json:"created_at"`
}

type UserInfo

type UserInfo struct {
	OpenID     string   `json:"openid"`
	Nickname   string   `json:"nickname"`
	Sex        int32    `json:"sex"`
	Province   string   `json:"province"`
	City       string   `json:"city"`
	Country    string   `json:"country"`
	HeadImgURL string   `json:"headimgurl"`
	Privilege  []string `json:"privilege"`
	Unionid    string   `json:"unionid"`
}

UserInfo 用户信息

type WeLMInfoReq

type WeLMInfoReq struct {
	Prompt      string  `json:"prompt"`      // 可选,默认值空字符串,给模型的提示
	Model       string  `json:"model"`       // 必选,要使用的模型名称,当前支持的模型名称有medium、 large 和 xl
	MaxTokens   int     `json:"max_tokens"`  // 可选,最多生成的token个数,默认值 16
	Temperature float64 `json:"temperature"` // 可选 默认值 0.85,表示使用的sampling temperature,更高的temperature意味着模型具备更多的可能性。对于更有创造性的应用,可以尝试0.85以上,而对于有明确答案的应用,可以尝试0(argmax采样)。 建议改变这个值或top_p,但不要同时改变。
	TopP        float64 `json:"top_p"`       // 可选 默认值 0.95,来源于nucleus sampling,采用的是累计概率的方式。即从累计概率超过某一个阈值p的词汇中进行采样,所以0.1意味着只考虑由前10%累计概率组成的词汇。 建议改变这个值或temperature,但不要同时改变。
	TopK        float64 `json:"top_k"`       // 可选 默认值50,从概率分布中依据概率最大选择k个单词,建议不要过小导致模型能选择的词汇少。
	N           int     `json:"n"`           // 可选 默认值 1 返回的序列的个数
	Echo        bool    `json:"echo"`        // 可选 默认值false,是否返回prompt
	Stop        string  `json:"stop"`        // 可选 默认值 null,停止符号。当模型当前生成的字符为stop中的任何一个字符时,会停止生成。若没有配置stop,当模型当前生成的token id 为end_id或生成的token个数达到max_tokens时,停止生成。合理配置stop可以加快推理速度、减少quota消耗。
}

func GetDefaultWelm

func GetDefaultWelm() WeLMInfoReq

type WeLMInfoResp

type WeLMInfoResp struct {
	Id      string    `json:"id"`
	Object  string    `json:"object"`
	Created int64     `json:"created"`
	Model   string    `json:"model"`
	Choices []Choices `json:"choices"`
}

type WxGetUser

type WxGetUser struct {
	Total int64         `json:"total"`
	Count int64         `json:"count"`
	Data  WxGetUserData `json:"data"`
}

type WxGetUserData

type WxGetUserData struct {
	Openid     []string `json:"openid"`
	NextOpenid string   `json:"next_openid"`
}

type WxInfo

type WxInfo struct {
	AppID     string // 微信公众平台应用ID
	AppSecret string // 微信支付商户平台商户号
	APIKey    string // 微信支付商户平台API密钥
	MchID     string // 商户号
	NotifyURL string // 通知地址
	ShearURL  string // 微信分享url
}

WxInfo 微信配置信息

type WxJsSign

type WxJsSign struct {
	Appid     string `json:"appid"`
	Noncestr  string `json:"noncestr"`
	Timestamp string `json:"timestamp"`
	Url       string `json:"url"`
	Signature string `json:"signature"`
}

WxJsSign

type WxMenu

type WxMenu struct {
	Button []WxMenuButton `json:"button"`
}

type WxMenuButton

type WxMenuButton struct {
	Type      string      `json:"type,omitempty"`
	Name      string      `json:"name,omitempty"`
	Key       string      `json:"key,omitempty"`
	Url       string      `json:"url,omitempty"`
	SubButton []SubButton `json:"sub_button"`
}

type WxTools

type WxTools interface {
	GetAccessToken() (accessToken string, err error)                                                          // 获取登录凭证
	GetAPITicket() (ticket string, err error)                                                                 // 获取微信卡券ticket
	GetJsTicket() (ticket string, err error)                                                                  // 获取微信js ticket
	SendTemplateMsg(msg TempMsg) bool                                                                         // 发送订阅消息
	SmallAppOauth(jscode string) string                                                                       // 小程序授权
	SmallAppUnifiedorder(openID string, price int64, priceBody, orderID, clientIP string) message.MessageBody // 小程序统一下单接口
	SelectOrder(openID, orderID string) (int, message.MessageBody)                                            // 统一查询接口
	RefundPay(openID, orderID, refundNO string, totalFee, refundFee int64) (bool, message.MessageBody)        // 申请退款
	WxEnterprisePay(openID, tradeNO, desc, ipAddr string, amount int) bool                                    // 企业付款
	GetShareQrcode(path string, scene, page string) (ret QrcodeRet)                                           // 获取小程序码
	GetWxQrcode(path, page string, width int) (ret QrcodeRet)                                                 // 获取小程序二维码 (有限个)
	GetAllOpenId() ([]string, error)                                                                          // 获取所有用户id
	GetFreepublish(max int64) ([]FreepublishiInfo, error)                                                     // 获取成功发布列表,最大条数
	GetMaterial(mediaId string) (string, error)                                                               // 获取素材地址
	GetBlacklist(openid string) ([]string, string, error)                                                     // 获取黑名单列表
	// --------------------h5------------------------------
	GetWebOauth(code string) (*AccessToken, error)                  // 授权
	GetWebUserinfo(openid, accessToken string) (*WxUserinfo, error) // 获取用户信息
	SendWebTemplateMsg(msg TempWebMsg) error                        // 发送公众号模板消息
	CreateMenu(menu WxMenu) error                                   // 创建自定义菜单
	DeleteMenu() error                                              // 删除自定义菜单
	SetGuideConfig(guideConfig GuideConfig) error                   // 快捷回复与关注自动回复

	SendCustomMsg(msg CustomMsg) error             // 发送客服消息
	UploadTmpFile(path, tp string) (string, error) //上传临时文件(tp:媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb))

	GetJsSign(url string) (*WxJsSign, error) // js-sdk 授权
}

WxTools 微信操作类型

func New

func New(info WxInfo) (WxTools, error)

New 新建及 初始化配置信息

type WxUserinfo

type WxUserinfo struct {
	Openid     string `json:"openid"`     // 微信用户唯一标识符,,微信用户唯一标识符
	NickName   string `json:"nickname"`   // 用户昵称
	Sex        int    `json:"sex"`        // 用户的性别
	City       string `json:"city"`       // 用户所在城市
	Province   string `json:"province"`   // 用户所在省份
	Country    string `json:"country"`    // 用户所在国家
	Headimgurl string `json:"headimgurl"` // 头像地址

}

WxUserinfo 微信用户信息

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL