diff --git a/miniprogram/README.md b/miniprogram/README.md index f2a4ac6..925be2e 100644 --- a/miniprogram/README.md +++ b/miniprogram/README.md @@ -21,7 +21,7 @@ miniprogram.GetAnalysis().GetAnalysisDailyRetain() ``` ### 小程序虚拟支付 -#### `注意:需要传入 Appkey 的值` +#### `注意:需要传入 Appkey、OfferID 的值` 相关文档:[小程序虚拟支付](https://developers.weixin.qq.com/miniprogram/dev/platform-capabilities/industry/virtual-payment.html) ```go wc := wechat.NewWechat() @@ -29,6 +29,7 @@ miniprogram := wc.GetMiniProgram(&miniConfig.Config{ AppID: "xxx", AppSecret: "xxx", AppKey: "xxx", + OfferID: "xxx", Cache: cache.NewRedis(&redis.Options{ Addr: "", }), diff --git a/miniprogram/config/config.go b/miniprogram/config/config.go index 98ffaaa..39b8c69 100644 --- a/miniprogram/config/config.go +++ b/miniprogram/config/config.go @@ -10,5 +10,6 @@ type Config struct { AppID string `json:"app_id"` // appid AppSecret string `json:"app_secret"` // appSecret AppKey string `json:"app_key"` // appKey + OfferID string `json:"offer_id"` // offerId Cache cache.Cache } diff --git a/miniprogram/minidrama/constant.go b/miniprogram/minidrama/constant.go new file mode 100644 index 0000000..01198fd --- /dev/null +++ b/miniprogram/minidrama/constant.go @@ -0,0 +1,100 @@ +/* + * Copyright silenceper/wechat Author(https://silenceper.com/wechat/). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * You can obtain one at https://github.com/silenceper/wechat. + * + */ + +package minidrama + +const ( + // Success 错误码 0、成功 + Success ErrCode = 0 + // SystemError 错误码 -1、系统错误 + SystemError ErrCode = -1 + // InitError 错误码 -2 初始化未完成,请稍后再试 + InitError ErrCode = -2 + // FormatError 错误码 47001 输入格式错误 + FormatError ErrCode = 47001 + // ParamError 错误码 47003 参数不符合要求 + ParamError ErrCode = 47003 + // PostError 错误码 44002 POST 内容为空 + PostError ErrCode = 44002 + // MethodError 错误码 43002 HTTP 请求必须使用 POST 方法 + MethodError ErrCode = 43002 + // VideoTypeError 错误码 10090001 视频类型不支持 + VideoTypeError ErrCode = 10090001 + // ImageTypeError 错误码 10090002 图片类型不支持 + ImageTypeError ErrCode = 10090002 + // ImageURLError 错误码 10090003 图片 URL 无效 + ImageURLError ErrCode = 10090003 + // ResourceType 错误码 10090005 resource_type 无效 + ResourceType ErrCode = 10090005 + // OperationError 错误码 10093011 操作失败 + OperationError ErrCode = 10093011 + // ParamError2 错误码 10093014 参数错误(包括参数格式、类型等错误) + ParamError2 ErrCode = 10093014 + // OperationFrequentError 错误码 10093023 操作过于频繁 + OperationFrequentError ErrCode = 10093023 + // ResourceNotExistError 错误码 10093030 资源不存在 + ResourceNotExistError ErrCode = 10093030 +) + +const ( + // singleFileUpload 单个文件上传,上传媒体(和封面)文件,上传小文件(小于 10MB)时使用。上传大文件请使用分片上传接口。 + singleFileUpload = "https://api.weixin.qq.com/wxa/sec/vod/singlefileupload?access_token=" + + // pullUpload 拉取上传,该接口用于将一个网络上的视频拉取上传到平台。 + pullUpload = "https://api.weixin.qq.com/wxa/sec/vod/pullupload?access_token=" + + // getTask 查询任务,该接口用于查询拉取上传的任务状态。 + getTask = "https://api.weixin.qq.com/wxa/sec/vod/gettask?access_token=" + + // applyUpload 申请分片上传 + applyUpload = "https://api.weixin.qq.com/wxa/sec/vod/applyupload?access_token=" + + // uploadPart 上传分片 + uploadPart = "https://api.weixin.qq.com/wxa/sec/vod/uploadpart?access_token=" + + // commitUpload 确认上传,该接口用于完成整个分片上传流程,合并所有文件分片,确认媒体文件(和封面图片文件)上传到平台的结果,返回文件的 ID。请求中需要给出每一个分片的 part_number 和 etag,用来校验分片的准确性。 + commitUpload = "https://api.weixin.qq.com/wxa/sec/vod/commitupload?access_token=" + + // listMedia 获取媒体列表 + listMedia = "https://api.weixin.qq.com/wxa/sec/vod/listmedia?access_token=" + + // getMedia 获取媒资详细信息,该接口用于获取已上传到平台的指定媒资信息,用于开发者后台管理使用。用于给用户客户端播放的链接应该使用 getmedialink 接口获取。 + getMedia = "https://api.weixin.qq.com/wxa/sec/vod/getmedia?access_token=" + + // getMediaLink 获取媒资播放链接,该接口用于获取视频临时播放链接,用于给用户的播放使用。只有审核通过的视频才能通过该接口获取播放链接。 + getMediaLink = "https://api.weixin.qq.com/wxa/sec/vod/getmedialink?access_token=" + + // deleteMedia 删除媒体,该接口用于删除指定媒资。 + deleteMedia = "https://api.weixin.qq.com/wxa/sec/vod/deletemedia?access_token=" + + // auditDrama 审核剧本 + auditDrama = "https://api.weixin.qq.com/wxa/sec/vod/auditdrama?access_token=" + + // listDramas 获取剧目列表 + listDramas = "https://api.weixin.qq.com/wxa/sec/vod/listdramas?access_token=" + + // getDrama 获取剧目信息,该接口用于查询已提交的剧目。 + getDrama = "https://api.weixin.qq.com/wxa/sec/vod/getdrama?access_token=" + + // getCdnUsageData 查询 CDN 用量数据,该接口用于查询点播 CDN 的流量数据。 + getCdnUsageData = "https://api.weixin.qq.com/wxa/sec/vod/getcdnusagedata?access_token=" + + // getCdnLogs 查询 CDN 日志,该接口用于查询点播 CDN 的日志。 + getCdnLogs = "https://api.weixin.qq.com/wxa/sec/vod/getcdnlogs?access_token=" +) diff --git a/miniprogram/minidrama/doc.go b/miniprogram/minidrama/doc.go new file mode 100644 index 0000000..a74862c --- /dev/null +++ b/miniprogram/minidrama/doc.go @@ -0,0 +1,32 @@ +/* + * Copyright silenceper/wechat Author(https://silenceper.com/wechat/). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * You can obtain one at https://github.com/silenceper/wechat. + * + */ + +// Package minidrama Mini Program entertainment mini-drama related interface +package minidrama + +import ( + "github.com/silenceper/wechat/v2/miniprogram/context" +) + +// NewMiniDrama 实例化小程序娱乐直播 API +func NewMiniDrama(ctx *context.Context) *MiniDrama { + return &MiniDrama{ + ctx: ctx, + } +} diff --git a/miniprogram/minidrama/domain.go b/miniprogram/minidrama/domain.go new file mode 100644 index 0000000..5e2d241 --- /dev/null +++ b/miniprogram/minidrama/domain.go @@ -0,0 +1,440 @@ +/* + * Copyright silenceper/wechat Author(https://silenceper.com/wechat/). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * You can obtain one at https://github.com/silenceper/wechat. + * + */ + +package minidrama + +import ( + "github.com/silenceper/wechat/v2/miniprogram/context" + "github.com/silenceper/wechat/v2/util" +) + +// MiniDrama mini program entertainment live broadcast related +type MiniDrama struct { + ctx *context.Context +} + +// ErrCode error code +type ErrCode int + +// SingleFileUploadRequest 单文件上传请求 +// Content-Type 需要指定为 multipart/form-data; boundary= +// <箭头括号> 表示必须替换为有效值的变量。 +// 不填写 cover_type,cover_data 字段时默认截取视频首帧作为视频封面。 +type SingleFileUploadRequest struct { + MediaName string `json:"media_name"` // 媒体文件名称 文件名,需按照“剧目名 - 对应剧集数”格式命名文件,示例值:"我的演艺 - 第 1 集"。 + MediaType string `json:"media_type"` // 媒体文件类型 视频格式,支持:MP4,TS,MOV,MXF,MPG,FLV,WMV,AVI,M4V,F4V,MPEG,3GP,ASF,MKV,示例值:"MP4"。 + MediaData []byte `json:"media_data"` // 媒体文件数据 视频文件内容,二进制。 + CoverType string `json:"cover_type,omitempty"` // 视频封面图片格式,支持:JPG、JPEG、PNG、BMP、TIFF、AI、CDR、EPS、TIF,示例值:"JPG"。 + CoverData []byte `json:"cover_data,omitempty"` // 视频封面图片内容,二进制。 + SourceContext string `json:"source_context,omitempty"` // 来源上下文,会在上传完成事件中透传给开发者。 +} + +// SingleFileUploadResponse 单文件上传响应 +type SingleFileUploadResponse struct { + util.CommonError + MediaID int64 `json:"media_id"` // 媒体文件唯一标识,用于发布视频。 +} + +// PullUploadRequest 拉取上传请求 +// 不填写 cover_url 字段时默认截取视频首帧作为封面。 +// Content-Type 需要指定为 application/json +// 该接口为异步接口,上传完成会推送上传完成事件到开发者服务器,开发者也可以调用"查询任务"接口来轮询上传结果。 +type PullUploadRequest struct { + MediaName string `json:"media_name"` // 媒体文件名称 文件名,需按照“剧目名 - 对应剧集数”格式命名文件,示例值:"我的演艺 - 第 1 集"。 + MediaURL string `json:"media_url"` // 视频 URL,示例值:"https://developers.weixin.qq.com/test.mp4"。 + CoverURL string `json:"cover_url,omitempty"` // 视频封面 URL,示例值:"https://developers.weixin.qq.com/test.jpg"。 + SourceContext string `json:"source_context,omitempty"` // 来源上下文,会在上传完成事件中透传给开发者。 +} + +// PullUploadResponse 拉取上传响应 +type PullUploadResponse struct { + util.CommonError + TaskID int64 `json:"task_id"` // 任务 ID,用于查询拉取上传任务的结果。 +} + +// GetTaskRequest 查询任务请求 +// 该接口用于查询拉取上传的任务状态。 +// Content-Type 需要指定为 application/json。 +type GetTaskRequest struct { + TaskID int64 `json:"task_id"` // 任务 ID,用于查询拉取上传任务的结果。 +} + +// GetTaskResponse 查询任务响应 +type GetTaskResponse struct { + util.CommonError + TaskInfo TaskInfo `json:"task_info"` // 任务信息。 +} + +// TaskInfo 任务信息 +type TaskInfo struct { + ID int64 `json:"id"` // 任务 ID。 + TaskType int `json:"task_type"` // 任务类型,1:拉取上传任务。 + Status int `json:"status"` // 任务状态枚举值:1. 等待中;2. 正在处理;3. 已完成;4. 失败。 + ErrCode int `json:"errcode"` // 任务错误码,0 表示成功,其它表示失败。 + ErrMsg string `json:"errmsg"` // 任务错误原因。 + CreateTime int64 `json:"create_time"` // 任务创建时间,时间戳,单位:秒。 + FinishTime int64 `json:"finish_time"` // 任务完成时间,时间戳,单位:秒。 + MediaID int64 `json:"media_id"` // 媒体文件唯一标识,用于发布视频。 +} + +// ApplyUploadRequest 申请上传请求 +// 上传大文件时需使用分片上传方式,分为 3 个步骤: +// +// 申请分片上传,确定文件名、格式类型,返回 upload_id,唯一标识本次分片上传。 +// 上传分片,多次调用上传文件分片,需要携带 part_number 和 upload_id,其中 part_number 为分片的编号,支持乱序上传。当传入 part_number 和 upload_id 都相同的时候,后发起上传请求的分片将覆盖之前的分片。 +// 确认分片上传,当上传完所有分片后,需要完成整个文件的合并。请求体中需要给出每一个分片的 part_number 和 etag,用来校验分片的准确性,最后返回文件的 media_id。 +// 如果填写了 cover_type,表明本次分片上传除上传媒体文件外还需要上传封面图片,不填写 cover_type 则默认截取视频首帧作为封面。 +// Content-Type 需要指定为 application/json。 +type ApplyUploadRequest struct { + MediaName string `json:"media_name"` // 媒体文件名称 文件名,需按照“剧目名 - 对应剧集数”格式命名文件,示例值:"我的演艺 - 第 1 集"。 + MediaType string `json:"media_type"` // 媒体文件类型 视频格式,支持:MP4,TS,MOV,MXF,MPG,FLV,WMV,AVI,M4V,F4V,MPEG,3GP,ASF,MKV,示例值:"MP4"。 + CoverType string `json:"cover_type,omitempty"` // 视频封面图片格式,支持:JPG、JPEG、PNG、BMP、TIFF、AI、CDR、EPS、TIF,示例值:"JPG"。 + SourceContext string `json:"source_context,omitempty"` // 来源上下文,会在上传完成事件中透传给开发者。 +} + +// ApplyUploadResponse 申请上传响应 +type ApplyUploadResponse struct { + util.CommonError + UploadID string `json:"upload_id"` // 本次分片上传的唯一标识。 +} + +// UploadPartRequest 上传分片请求 +// 将文件的其中一个分片上传到平台,最多支持 100 个分片,每个分片大小为 5MB,最后一个分片可以小于 5MB。该接口适用于视频和封面图片。视频最大支持 500MB,封面图片最大支持 10MB。 +// 调用该接口之前必须先调用申请分片上传接口。 +// 在申请分片上传时,如果不填写 cover_type,则默认截取视频首帧作为封面。 +// Content-Type 需要指定为 multipart/form-data; boundary=,<箭头括号>表示必须替换为有效值的变量。 +// part_number 从 1 开始。如除了上传视频外还需要上传封面图片,则封面图片的 part_number 需重新从 1 开始编号。 +type UploadPartRequest struct { + UploadID string `json:"upload_id"` // 一次分片上传的唯一标识,由申请分片上传接口返回。 + PartNumber int `json:"part_number"` // 本次上传的分片的编号,范围在 1 - 100。 + ResourceType int `json:"resource_type"` // 指定该分片属于视频还是封面图片的枚举值:1. 视频,2. 封面图片。 + Data []byte `json:"data"` // 分片内容,二进制。 +} + +// UploadPartResponse 上传分片响应 +type UploadPartResponse struct { + util.CommonError + ETag string `json:"etag"` // 上传分片成功后返回的分片标识,用于后续确认分片上传接口。 +} + +// CommitUploadRequest 确认分片上传请求 +// 该接口用于完成整个分片上传流程,合并所有文件分片,确认媒体文件(和封面图片文件)上传到平台的结果,返回文件的 ID。请求中需要给出每一个分片的 part_number 和 etag,用来校验分片的准确性。 +// 注意事项 +// Content-Type 需要指定为 application/json。 +// 调用该接口之前必须先调用申请分片上传接口以及上传分片接口。 +// 如本次分片上传除上传媒体文件外还需要上传封面图片,则请求中还需提供 cover_part_infos 字段以用于合并封面图片文件分片。 +// 请求中 media_part_infos 和 cover_part_infos 字段必须按 part_number 从小到大排序,part_number 必须从 1 开始,连续且不重复。 +type CommitUploadRequest struct { + UploadID string `json:"upload_id"` + MediaPartInfos []*PartInfo `json:"media_part_infos"` + CoverPartInfos []*PartInfo `json:"cover_part_infos,omitempty"` +} + +// PartInfo 分片信息 +type PartInfo struct { + PartNumber int `json:"part_number"` // 分片编号。 + Etag string `json:"etag"` // 使用上传分片接口上传成功后返回的 etag 的值 +} + +// CommitUploadResponse 确认分片上传响应 +type CommitUploadResponse struct { + util.CommonError + MediaID int64 `json:"media_id"` // 媒体文件唯一标识,用于发布视频。 +} + +// ListMediaRequest 查询媒体列表请求 +// 该接口用于查询已经上传到平台的媒体文件列表。 +// 注意事项 +// Content-Type 需要指定为 application/json。 +// 本接口返回的视频或图片链接均为临时链接,不应将其保存下来。 +// media_name 参数支持模糊匹配,当需要模糊匹配时可以在前面或后面加上 %,否则为精确匹配。例如 "test%" 可以匹配到 "test123", "testxxx", "test"。 +// 调用方式 +type ListMediaRequest struct { + DramaID int64 `json:"drama_id,omitempty"` // 剧目 ID,可通过查询剧目列表接口获取。 + MediaName string `json:"media_name,omitempty"` // 媒体文件名称,可通过查询媒体列表接口获取,模糊匹配。 + StartTime int64 `json:"start_time,omitempty"` // 媒资上传时间>=start_time,Unix 时间戳,单位:秒。 + EndTime int64 `json:"end_time,omitempty"` // 媒资上传时间,<箭头括号>表示必须替换为有效值的变量。 +func (s *MiniDrama) UploadPart(ctx context.Context, in *UploadPartRequest) (out *UploadPartResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, uploadPart); err != nil { + return + } + + var ( + fields = []util.MultipartFormField{ + { + IsFile: true, + Fieldname: "data", + Filename: string(in.Data), + }, { + IsFile: false, + Fieldname: "upload_id", + Value: []byte(in.UploadID), + }, { + IsFile: false, + Fieldname: "part_number", + Value: []byte(strconv.Itoa(in.PartNumber)), + }, { + IsFile: false, + Fieldname: "resource_type", + Value: []byte(strconv.Itoa(in.PartNumber)), + }, + } + response []byte + ) + if response, err = util.PostMultipartForm(fields, address); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "UploadPart") + return +} + +// CommitUpload 确认上传 +func (s *MiniDrama) CommitUpload(ctx context.Context, in *CommitUploadRequest) (out *CommitUploadResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, commitUpload); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "CommitUpload") + return +} + +// ListMedia 获取媒体列表 +func (s *MiniDrama) ListMedia(ctx context.Context, in *ListMediaRequest) (out *ListMediaResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, listMedia); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "ListMedia") + return +} + +// GetMedia 获取媒资详细信息 +func (s *MiniDrama) GetMedia(ctx context.Context, in *GetMediaRequest) (out *GetMediaResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, getMedia); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "GetMedia") + return +} + +// GetMediaLink 获取媒资播放链接 +func (s *MiniDrama) GetMediaLink(ctx context.Context, in *GetMediaLinkRequest) (out *GetMediaLinkResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, getMediaLink); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "GetMediaLink") + return +} + +// DeleteMedia 删除媒体 +func (s *MiniDrama) DeleteMedia(ctx context.Context, in *DeleteMediaRequest) (out *DeleteMediaResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, deleteMedia); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "DeleteMedia") + return +} + +// AuditDrama 审核剧本 +func (s *MiniDrama) AuditDrama(ctx context.Context, in *AuditDramaRequest) (out *AuditDramaResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, auditDrama); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "AuditDrama") + return +} + +// ListDramas 获取剧目列表 +func (s *MiniDrama) ListDramas(ctx context.Context, in *ListDramasRequest) (out *ListDramasResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, listDramas); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "ListDramas") + return +} + +// GetDrama 获取剧目信息 +func (s *MiniDrama) GetDrama(ctx context.Context, in *GetDramaRequest) (out *GetDramaResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, getDrama); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "GetDrama") + return +} + +// GetCdnUsageData 查询 CDN 用量数据 +func (s *MiniDrama) GetCdnUsageData(ctx context.Context, in *GetCdnUsageDataRequest) (out *GetCdnUsageDataResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, getCdnUsageData); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "GetCdnUsageData") + return +} + +// GetCdnLogs 查询 CDN 日志 +func (s *MiniDrama) GetCdnLogs(ctx context.Context, in *GetCdnLogsRequest) (out *GetCdnLogsResponse, err error) { + var address string + if address, err = s.requestAddress(ctx, getCdnLogs); err != nil { + return + } + + var response []byte + if response, err = util.PostJSONContext(ctx, address, in); err != nil { + return + } + // 使用通用方法返回错误 + err = util.DecodeWithError(response, out, "GetCdnLogs") + return +} + +// requestAddress 请求地址 +func (s *MiniDrama) requestAddress(_ context.Context, url string) (string, error) { + accessToken, err := s.ctx.GetAccessToken() + if err != nil { + return "", err + } + return url + accessToken, nil +} diff --git a/miniprogram/miniprogram.go b/miniprogram/miniprogram.go index 001c765..36c5174 100644 --- a/miniprogram/miniprogram.go +++ b/miniprogram/miniprogram.go @@ -11,6 +11,7 @@ import ( "github.com/silenceper/wechat/v2/miniprogram/context" "github.com/silenceper/wechat/v2/miniprogram/encryptor" "github.com/silenceper/wechat/v2/miniprogram/message" + "github.com/silenceper/wechat/v2/miniprogram/minidrama" "github.com/silenceper/wechat/v2/miniprogram/privacy" "github.com/silenceper/wechat/v2/miniprogram/qrcode" "github.com/silenceper/wechat/v2/miniprogram/riskcontrol" @@ -138,3 +139,8 @@ func (miniProgram *MiniProgram) GetOpenAPI() *openapi.OpenAPI { func (miniProgram *MiniProgram) GetVirtualPayment() *virtualpayment.VirtualPayment { return virtualpayment.NewVirtualPayment(miniProgram.ctx) } + +// GetMiniDrama 小程序娱乐微短剧 +func (miniProgram *MiniProgram) GetMiniDrama() *minidrama.MiniDrama { + return minidrama.NewMiniDrama(miniProgram.ctx) +} diff --git a/miniprogram/virtualpayment/virtualpayment.go b/miniprogram/virtualpayment/virtualpayment.go index 2e1c557..b3386da 100644 --- a/miniprogram/virtualpayment/virtualpayment.go +++ b/miniprogram/virtualpayment/virtualpayment.go @@ -60,10 +60,7 @@ func (s *VirtualPayment) QueryUserBalance(ctx context.Context, in *QueryUserBala } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "QueryUserBalance"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "QueryUserBalance") return } @@ -91,10 +88,7 @@ func (s *VirtualPayment) CurrencyPay(ctx context.Context, in *CurrencyPayRequest } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "CurrencyPay"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "CurrencyPay") return } @@ -122,10 +116,7 @@ func (s *VirtualPayment) QueryOrder(ctx context.Context, in *QueryOrderRequest) } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "QueryOrder"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "QueryOrder") return } @@ -153,10 +144,7 @@ func (s *VirtualPayment) CancelCurrencyPay(ctx context.Context, in *CancelCurren } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "CancelCurrencyPay"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "CancelCurrencyPay") return } @@ -186,10 +174,7 @@ func (s *VirtualPayment) NotifyProvideGoods(ctx context.Context, in *NotifyProvi } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "NotifyProvideGoods"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "NotifyProvideGoods") return } @@ -218,10 +203,7 @@ func (s *VirtualPayment) PresentCurrency(ctx context.Context, in *PresentCurrenc } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "PresentCurrency"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "PresentCurrency") return } @@ -250,10 +232,7 @@ func (s *VirtualPayment) DownloadBill(ctx context.Context, in *DownloadBillReque } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "DownloadBill"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "DownloadBill") return } @@ -282,10 +261,7 @@ func (s *VirtualPayment) RefundOrder(ctx context.Context, in *RefundOrderRequest } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "RefundOrder"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "RefundOrder") return } @@ -314,10 +290,7 @@ func (s *VirtualPayment) CreateWithdrawOrder(ctx context.Context, in *CreateWith } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "CreateWithdrawOrder"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "CreateWithdrawOrder") return } @@ -346,10 +319,7 @@ func (s *VirtualPayment) QueryWithdrawOrder(ctx context.Context, in *QueryWithdr } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "QueryWithdrawOrder"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "QueryWithdrawOrder") return } @@ -378,10 +348,7 @@ func (s *VirtualPayment) StartUploadGoods(ctx context.Context, in *StartUploadGo } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "StartUploadGoods"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "StartUploadGoods") return } @@ -410,10 +377,7 @@ func (s *VirtualPayment) QueryUploadGoods(ctx context.Context, in *QueryUploadGo } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "QueryUploadGoods"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "QueryUploadGoods") return } @@ -442,10 +406,7 @@ func (s *VirtualPayment) StartPublishGoods(ctx context.Context, in *StartPublish } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "StartPublishGoods"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "StartPublishGoods") return } @@ -474,10 +435,7 @@ func (s *VirtualPayment) QueryPublishGoods(ctx context.Context, in *QueryPublish } // 使用通用方法返回错误 - if err = util.DecodeWithError(response, out, "QueryPublishGoods"); err != nil { - return - } - + err = util.DecodeWithError(response, out, "QueryPublishGoods") return }