Skip to content

Commit

Permalink
完成直播间所有接口的收录
Browse files Browse the repository at this point in the history
  • Loading branch information
royalrick committed Oct 6, 2021
1 parent 17268fa commit 3061eed
Show file tree
Hide file tree
Showing 19 changed files with 676 additions and 4 deletions.
35 changes: 35 additions & 0 deletions livebroadcast/Goods_video.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsVideo = "/wxaapi/broadcast/goods/getVideo"

type GoodsVideoRequest struct {
// 必填 商品ID
GoodsId int64 `json:"goodsId"`
// 必填 房间ID
RoomId int64 `json:"roomId"`
}

type GoodsVideoResponse struct {
request.CommonError
// 必填 讲解链接
Url int64 `json:"url"`
}

// 更新商品
func (cli *LiveBroadcast) GoodsVideo(req *GoodsVideoRequest) (*GoodsVideoResponse, error) {

api, err := cli.conbineURI(apiGoodsVideo, nil)
if err != nil {
return nil, err
}

res := new(GoodsVideoResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
8 changes: 4 additions & 4 deletions livebroadcast/goods_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ const apiGoodsAdd = "/wxaapi/broadcast/goods/add"

type GoodsAddRequest struct {
// 商品信息
GoodsInfo GoodsInfo `json:"goodsInfo"`
GoodsInfo *GoodsAddInfo `json:"goodsInfo"`
}

type GoodsInfo struct {
type GoodsAddInfo struct {
// 必填 填入mediaID(mediaID获取后,三天内有效);图片mediaID的获取,请参考以下文档: https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/New_temporary_materials.html;图片规则:图片尺寸最大300像素*300像素;
CoverImgUrl string `json:"coverImgUrl"`
// 必填 商品名称,最长14个汉字,1个汉字相当于2个字符
Expand All @@ -29,9 +29,9 @@ type GoodsInfo struct {
type GoodsAddResponse struct {
request.CommonError
// 商品ID
GoodsId string `json:"goodsId"`
GoodsId int64 `json:"goodsId"`
// 审核单ID
AuditId string `json:"auditId"`
AuditId int64 `json:"auditId"`
}

// 商品添加并提审
Expand Down
33 changes: 33 additions & 0 deletions livebroadcast/goods_audit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsAudit = "/wxaapi/broadcast/goods/audit"

type GoodsAuditRequest struct {
// 商品ID
GoodsId int64 `json:"goodsId"`
}

type GoodsAuditResponse struct {
request.CommonError
// 审核单ID
AuditId int64 `json:"auditId"`
}

// 重新提交审核
func (cli *LiveBroadcast) GoodsAudit(req *GoodsAuditRequest) (*GoodsAuditResponse, error) {

api, err := cli.conbineURI(apiGoodsAudit, nil)
if err != nil {
return nil, err
}

res := new(GoodsAuditResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
31 changes: 31 additions & 0 deletions livebroadcast/goods_delete.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsDelete = "/wxaapi/broadcast/goods/delete"

type GoodsDeleteRequest struct {
// 商品ID
GoodsId int64 `json:"goodsId"`
}

type GoodsDeleteResponse struct {
request.CommonError
}

// 删除商品
func (cli *LiveBroadcast) GoodsDelete(req *GoodsDeleteRequest) (*GoodsDeleteResponse, error) {

api, err := cli.conbineURI(apiGoodsDelete, nil)
if err != nil {
return nil, err
}

res := new(GoodsDeleteResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
57 changes: 57 additions & 0 deletions livebroadcast/goods_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsInfo = "/wxa/business/getgoodswarehouse"

type GoodsInfoRequest struct {
// 商品ID
GoodsIds []int64 `json:"goods_ids"`
}

type GoodsInfoResponse struct {
request.CommonError
// 商品个数
Total int64 `json:"total"`

// 商品
Goods []struct {
// 商品ID
GoodsId int64 `json:"goods_id"`
// 商品名称
Name string `json:"name"`
// 商品图片url
CoverImgUrl string `json:"cover_img_url"`
// 商品详情页的小程序路径
Url string `json:"url"`
// 1:一口价,此时读price字段; 2:价格区间,此时price字段为左边界,price2字段为右边界; 3:折扣价,此时price字段为原价,price2字段为现价;
PriceType uint8 `json:"priceType"`
// 价格左区间,单位“元”
Price float64 `json:"price"`
// 价格右区间,单位“元”
Price2 float64 `json:"price2"`
// 0:未审核,1:审核中,2:审核通过,3审核失败
AuditStatus uint8 `json:"audit_status"`
// 1、2:表示是为 API 添加商品,否则是直播控制台添加的商品
ThirdPartyTag uint8 `json:"third_party_tag"`
// 当商品为第三方小程序的商品则为对应第三方小程序的appid,自身小程序商品则为''
ThirdPartyAppid string `json:"thirdPartyAppid"`
} `json:"goods"`
}

// 获取商品状态
func (cli *LiveBroadcast) GoodsInfo(req *GoodsInfoRequest) (*GoodsInfoResponse, error) {

api, err := cli.conbineURI(apiGoodsInfo, nil)
if err != nil {
return nil, err
}

res := new(GoodsInfoResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
58 changes: 58 additions & 0 deletions livebroadcast/goods_list.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsList = "/wxaapi/broadcast/goods/getapproved"

type GoodsListRequest struct {
// 必填 分页条数起点
Offset int `query:"offset"`
// 非必填 分页大小,默认30,不超过100
Limit int `query:"limit"`
// 必填 商品状态,0:未审核。1:审核中,2:审核通过,3:审核驳回
Status uint8 `query:"status"`
}

type GoodsListResponse struct {
request.CommonError
// 商品个数
Total int64 `json:"total"`
// 商品
Goods []struct {
// 商品ID
GoodsId int64 `json:"goodsId"`
// 商品图片url
CoverImgUrl string `json:"coverImgUrl"`
// 商品名称
Name string `json:"name"`
// 价格左区间,单位“元”
Price float64 `json:"price"`
// 价格右区间,单位“元”
Price2 float64 `json:"price2"`
// 商品详情页的小程序路径
Url string `json:"url"`
// 1:一口价,此时读price字段; 2:价格区间,此时price字段为左边界,price2字段为右边界; 3:折扣价,此时price字段为原价,price2字段为现价;
PriceType uint8 `json:"priceType"`
// 1、2:表示是为 API 添加商品,否则是直播控制台添加的商品
ThirdPartyTag uint8 `json:"thirdPartyTag"`
// 当商品为第三方小程序的商品则为对应第三方小程序的appid,自身小程序商品 则为''
ThirdPartyAppid string `json:"thirdPartyAppid"`
} `json:"goods"`
}

// 获取商品列表
func (cli *LiveBroadcast) GoodsList(req *GoodsListRequest) (*GoodsListResponse, error) {

api, err := cli.conbineURI(apiGoodsList, req)
if err != nil {
return nil, err
}

res := new(GoodsListResponse)
err = cli.request.Get(api, res)
if err != nil {
return nil, err
}

return res, nil
}
33 changes: 33 additions & 0 deletions livebroadcast/goods_push.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsPush = "/wxaapi/broadcast/goods/push"

type GoodsPushRequest struct {
// 必填 商品ID
GoodsId int64 `json:"goodsId"`
// 必填 房间ID
RoomId int64 `json:"roomId"`
}

type GoodsPushResponse struct {
request.CommonError
}

// 推送商品
func (cli *LiveBroadcast) GoodsPush(req *GoodsPushRequest) (*GoodsPushResponse, error) {

api, err := cli.conbineURI(apiGoodsPush, nil)
if err != nil {
return nil, err
}

res := new(GoodsPushResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
33 changes: 33 additions & 0 deletions livebroadcast/goods_reset_audit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsResetAudit = "/wxaapi/broadcast/goods/resetaudit"

type GoodsResetAuditRequest struct {
// 必填 商品ID
GoodsId int64 `json:"goodsId"`
// 必填 审核单ID
AuditId int64 `json:"auditId"`
}

type GoodsResetAuditResponse struct {
request.CommonError
}

// 撤回商品审核
func (cli *LiveBroadcast) GoodsResetAudit(req *GoodsResetAuditRequest) (*GoodsResetAuditResponse, error) {

api, err := cli.conbineURI(apiGoodsResetAudit, nil)
if err != nil {
return nil, err
}

res := new(GoodsResetAuditResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
35 changes: 35 additions & 0 deletions livebroadcast/goods_sale.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsSale = "/wxaapi/broadcast/goods/onsale"

type GoodsSaleRequest struct {
// 必填 商品ID
GoodsId int64 `json:"goodsId"`
// 必填 审核单ID
AuditId int64 `json:"auditId"`
// 必填 上下架 【0:下架,1:上架】
OnSale uint8 `json:"onSale"`
}

type GoodsSaleResponse struct {
request.CommonError
}

// 上下架商品
func (cli *LiveBroadcast) GoodsSale(req *GoodsSaleRequest) (*GoodsSaleResponse, error) {

api, err := cli.conbineURI(apiGoodsSale, nil)
if err != nil {
return nil, err
}

res := new(GoodsSaleResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
39 changes: 39 additions & 0 deletions livebroadcast/goods_sort.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package livebroadcast

import "github.com/medivhzhan/weapp/v3/request"

const apiGoodsSort = "/wxaapi/broadcast/goods/sort"

type GoodsSortRequest struct {
// 必填 房间ID
RoomId int64 `json:"roomId"`

// 必填 房间ID
Goods []*SortGoods `json:"goods"`
}

type SortGoods struct {
// 必填 商品ID
GoodsId int64 `json:"goodsId"`
}

type GoodsSortResponse struct {
request.CommonError
}

// 直播间商品排序
func (cli *LiveBroadcast) GoodsSort(req *GoodsSortRequest) (*GoodsSortResponse, error) {

api, err := cli.conbineURI(apiGoodsSort, nil)
if err != nil {
return nil, err
}

res := new(GoodsSortResponse)
err = cli.request.Post(api, req, res)
if err != nil {
return nil, err
}

return res, nil
}
Loading

0 comments on commit 3061eed

Please sign in to comment.