Skip to content

Commit

Permalink
新增收银台相关API
Browse files Browse the repository at this point in the history
  • Loading branch information
zsmhub committed Mar 21, 2023
1 parent d57d4d6 commit 5a438f7
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api_generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ func main() {
rawHtmlSection = strings.ReplaceAll(rawHtmlSection, `GET(<strong>HTTPS</strong>)`, `GET<strong>HTTPS</strong>`)
rawHtmlSection = strings.ReplaceAll(rawHtmlSection, `<strong>请求方式</strong>:<strong>POST</strong>(<strong>HTTPS</strong>)`, `<strong>请求方式</strong>POST<strong>HTTPS</strong>`)
rawHtmlSection = strings.ReplaceAll(rawHtmlSection, `<strong>请求方式</strong>:<strong>GET</strong>(<strong>HTTPS</strong>)`, `<strong>请求方式</strong>GET<strong>HTTPS</strong>`)
rawHtmlSection = strings.ReplaceAll(rawHtmlSection, `<strong>请求方式</strong>:POST<strong>HTTPS</strong>`, `<strong>请求方式</strong>POST<strong>HTTPS</strong>`)
rawHtmlSection = strings.ReplaceAll(rawHtmlSection, `<strong>请求方式</strong>:GET<strong>HTTPS</strong>`, `<strong>请求方式</strong>GET<strong>HTTPS</strong>`)
// 过滤掉不是接口的节点
if !strings.Contains(rawHtmlSection, `<strong>请求方式</strong>`) {
fmt.Println("没有请求方式,跳过处理")
Expand Down
101 changes: 101 additions & 0 deletions apis/收银台-创建收款订单.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package apis

import (
"encoding/json"
)

// ReqOpenOrderPaytool 创建收款订单
// 文档:https://developer.work.weixin.qq.com/document/path/98045#创建收款订单

type (
ReqOpenOrderPaytool struct {
BusinessType int `json:"business_type"`
CustomCorpid string `json:"custom_corpid,omitempty"`
ProductList PaytoolProductList `json:"product_list"`
NonceStr string `json:"nonce_str"`
Ts int `json:"ts"`
Sig string `json:"sig"`
}

PaytoolProductList struct {
ThirdApp *PaytoolThirdApp `json:"third_app,omitempty"`
CustomizedApp *PaytoolCustomizedApp `json:"customized_app,omitempty"`
PromotionCase *PaytoolPromotionCase `json:"promotion_case,omitempty"`
}

PaytoolThirdApp struct {
OrderType int `json:"order_type"`
BuyInfoList []PaytoolBuyInfoList `json:"buy_info_list"`
}

PaytoolBuyInfoList struct {
Suiteid string `json:"suiteid"`
Appid int `json:"appid,omitempty"`
EditionId string `json:"edition_id,omitempty"`
DurationDays int `json:"duration_days,omitempty"`
TakeEffectDate string `json:"take_effect_date,omitempty"`
UserCount int `json:"user_count,omitempty"`
DiscountInfo *PaytoolDiscountInfo `json:"discount_info,omitempty"`
}

PaytoolDiscountInfo struct {
DiscountType int `json:"discount_type"`
DiscountAmount int `json:"discount_amount,omitempty"`
DiscountRatio int `json:"discount_ratio,omitempty"`
DiscountRemarks string `json:"discount_remarks"`
}

PaytoolPromotionCase struct {
OrderType int `json:"order_type"`
CaseId string `json:"case_id"`
PromotionEditionName string `json:"promotion_edition_name"`
DurationDays int `json:"duration_days,omitempty"`
TakeEffectDate string `json:"take_effect_date,omitempty"`
BuyInfoList []PaytoolBuyInfoList `json:"buy_info_list"`
}

PaytoolCustomizedApp struct {
OrderType int `json:"order_type"`
BuyInfoList []PaytoolBuyInfoList `json:"buy_info_list"`
}
)

var _ bodyer = ReqOpenOrderPaytool{}

func (x ReqOpenOrderPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

type RespOpenOrderPaytool struct {
CommonResp
OrderId string `json:"order_id"`
OrderUrl string `json:"order_url"`
OriginPrice int `json:"origin_price"`
PaidPrice int `json:"paid_price"`
}

var _ bodyer = RespOpenOrderPaytool{}

func (x RespOpenOrderPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

func (c *ApiClient) ExecOpenOrderPaytool(req ReqOpenOrderPaytool) (RespOpenOrderPaytool, error) {
var resp RespOpenOrderPaytool
err := c.executeWXApiPost("/cgi-bin/paytool/open_order", req, &resp, true)
if err != nil {
return RespOpenOrderPaytool{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespOpenOrderPaytool{}, bizErr
}
return resp, nil
}
61 changes: 61 additions & 0 deletions apis/收银台-取消收款订单.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package apis

import (
"encoding/json"
)

// 自动生成的文件, 生成方式: make api doc=微信文档地址url
// 可自行修改生成的文件,以满足开发需求

// ReqCloseOrderPaytool 取消收款订单请求
// 文档:https://developer.work.weixin.qq.com/document/path/98046#取消收款订单
type ReqCloseOrderPaytool struct {
// NonceStr 随机字符串,长度要求在32字节以内,用于保证签名不可预测及防重放攻击。<br/>需保证15分钟内不能重复,推荐随机字符串生成算法
NonceStr string `json:"nonce_str,omitempty"`
// OrderID 收款订单号<br/>不多于64字节
OrderID string `json:"order_id,omitempty"`
// Sig 数字签名
Sig string `json:"sig,omitempty"`
// Ts unix时间戳(中国时区),精确到秒。<br/>注意业务系统的机器时间与腾讯的时间相差不能超过15分钟
Ts int `json:"ts,omitempty"`
}

var _ bodyer = ReqCloseOrderPaytool{}

func (x ReqCloseOrderPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// RespCloseOrderPaytool 取消收款订单响应
// 文档:https://developer.work.weixin.qq.com/document/path/98046#取消收款订单
type RespCloseOrderPaytool struct {
CommonResp
}

var _ bodyer = RespCloseOrderPaytool{}

func (x RespCloseOrderPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// ExecCloseOrderPaytool 取消收款订单
// 文档:https://developer.work.weixin.qq.com/document/path/98046#取消收款订单
func (c *ApiClient) ExecCloseOrderPaytool(req ReqCloseOrderPaytool) (RespCloseOrderPaytool, error) {
var resp RespCloseOrderPaytool
err := c.executeWXApiPost("/cgi-bin/paytool/close_order", req, &resp, true)
if err != nil {
return RespCloseOrderPaytool{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespCloseOrderPaytool{}, bizErr
}
return resp, nil
}
93 changes: 93 additions & 0 deletions apis/收银台-获取收款订单列表.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package apis

import (
"encoding/json"
)

// 自动生成的文件, 生成方式: make api doc=微信文档地址url
// 可自行修改生成的文件,以满足开发需求

// ReqGetOrderListPaytool 获取收款订单列表请求
// 文档:https://developer.work.weixin.qq.com/document/path/98053#获取收款订单列表
type ReqGetOrderListPaytool struct {
// BusinessType 业务类型
BusinessType int `json:"business_type,omitempty"`
// Cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用不填
Cursor string `json:"cursor,omitempty"`
// EndTime 结束时间
EndTime int `json:"end_time,omitempty"`
// Limit 分页,预期请求的数据量,取值范围 1 ~ 2000
Limit int `json:"limit,omitempty"`
// NonceStr 随机字符串,长度要求在32字节以内,用于保证签名不可预测及防重放攻击。<br/>需保证15分钟内不能重复,推荐随机字符串生成算法
NonceStr string `json:"nonce_str,omitempty"`
// Sig 数字签名
Sig string `json:"sig,omitempty"`
// StartTime 起始时间
StartTime int `json:"start_time,omitempty"`
// Ts unix时间戳(中国时区),精确到秒。<br/>注意业务系统的机器时间与腾讯的时间相差不能超过15分钟
Ts int `json:"ts,omitempty"`
}

var _ bodyer = ReqGetOrderListPaytool{}

func (x ReqGetOrderListPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// RespGetOrderListPaytool 获取收款订单列表响应
// 文档:https://developer.work.weixin.qq.com/document/path/98053#获取收款订单列表
type RespGetOrderListPaytool struct {
CommonResp
// HasMore 是否还有更多数据
HasMore int `json:"has_more"`
// NextCursor 分页游标,下次请求时填写以获取之后分页的记录
NextCursor string `json:"next_cursor"`
PayOrderList []struct {
// BuyContent 购买内容
BuyContent string `json:"buy_content"`
// CreateTime 订单创建时间
CreateTime int `json:"create_time"`
// Creator 订单创建人
Creator string `json:"creator"`
// CustomCorpid 客户企业的corpid
CustomCorpid string `json:"custom_corpid"`
// OrderFrom 订单来源。取值范围为:<br/> 1 - 客户下单<br/> 2 - 服务商创建
OrderFrom int `json:"order_from"`
// OrderID 订单号
OrderID string `json:"order_id"`
// OrderStatus 订单状态。取值范围为:<br/>1 - 待支付 <br/> 2 - 已支付<br/> 3 - 订单取消<br/> 4 - 支付过期<br/> 5 - 退款申请中<br/> 6 - 已退款<br/> 7 - 交易完成
OrderStatus int `json:"order_status"`
// OriginPrice 原价金额
OriginPrice int `json:"origin_price"`
// PaidPrice 实付金额
PaidPrice int `json:"paid_price"`
} `json:"pay_order_list"` // 订单列表
}

var _ bodyer = RespGetOrderListPaytool{}

func (x RespGetOrderListPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// ExecGetOrderListPaytool 获取收款订单列表
// 文档:https://developer.work.weixin.qq.com/document/path/98053#获取收款订单列表
func (c *ApiClient) ExecGetOrderListPaytool(req ReqGetOrderListPaytool) (RespGetOrderListPaytool, error) {
var resp RespGetOrderListPaytool
err := c.executeWXApiPost("/cgi-bin/paytool/get_order_list", req, &resp, true)
if err != nil {
return RespGetOrderListPaytool{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespGetOrderListPaytool{}, bizErr
}
return resp, nil
}
119 changes: 119 additions & 0 deletions apis/收银台-获取收款订单详情.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
package apis

import (
"encoding/json"
)

// 自动生成的文件, 生成方式: make api doc=微信文档地址url
// 可自行修改生成的文件,以满足开发需求

// ReqGetOrderDetailPaytool 获取收款订单详情请求
// 文档:https://developer.work.weixin.qq.com/document/path/98054#获取收款订单详情
type ReqGetOrderDetailPaytool struct {
// NonceStr 随机字符串,长度要求在32字节以内,用于保证签名不可预测及防重放攻击。<br/>需保证15分钟内不能重复,推荐<a href="#47107/%E9%9A%8F%E6%9C%BA%E5%AD%97%E7%AC%A6%E4%B8%B2%E7%94%9F%E6%88%90%E7%AE%97%E6%B3%95" rel="nofollow">随机字符串生成算法</a>
NonceStr string `json:"nonce_str,omitempty"`
// OrderID 订单号
OrderID string `json:"order_id,omitempty"`
// Sig 数字签名。见<a href="#47107/%E8%AE%A2%E5%8D%95%E7%AD%BE%E5%90%8D%E7%AE%97%E6%B3%95" rel="nofollow">签名算法</a>。签名所需密钥获取路径:<br/>工作台-&gt;企业微信服务商助手-&gt;工具-&gt;收银台-&gt;收银台API调用密钥
Sig string `json:"sig,omitempty"`
// Ts unix时间戳(中国时区),精确到秒。<br/>注意业务系统的机器时间与腾讯的时间相差不能超过15分钟
Ts int `json:"ts,omitempty"`
}

var _ bodyer = ReqGetOrderDetailPaytool{}

func (x ReqGetOrderDetailPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// RespGetOrderDetailPaytool 获取收款订单详情响应
// 文档:https://developer.work.weixin.qq.com/document/path/98054#获取收款订单详情
type RespGetOrderDetailPaytool struct {
CommonResp
PayOrder struct {
OrderId string `json:"order_id"`
CreateTime int `json:"create_time"`
CustomCorpid string `json:"custom_corpid"`
BuyContent string `json:"buy_content"`
OriginPrice int `json:"origin_price"`
PaidPrice int `json:"paid_price"`
OrderStatus int `json:"order_status"`
OrderFrom int `json:"order_from"`
Creator string `json:"creator"`
CustomCorpName string `json:"custom_corp_name"`
PayChannel int `json:"pay_channel"`
ChannelOrderId string `json:"channel_order_id"`
PaidTime int `json:"paid_time"`
BusinessType int `json:"business_type"`
IncomeType int `json:"income_type"`
IncomeTime int `json:"income_time"`
IncomeAmount int `json:"income_amount"`
ProductList struct {
ThirdApp struct {
OrderType int `json:"order_type"`
BuyInfoList []struct {
Suiteid string `json:"suiteid"`
Appid int `json:"appid"`
EditionId string `json:"edition_id"`
UserCount int `json:"user_count"`
DurationDays int `json:"duration_days"`
OriginPrice int `json:"origin_price"`
PaidPrice int `json:"paid_price"`
GiftDurationDays int `json:"gift_duration_days"`
} `json:"buy_info_list"`
} `json:"third_app"`
CustomizedApp struct {
OrderType int `json:"order_type"`
BuyInfoList []struct {
Suiteid string `json:"suiteid"`
UserCount int `json:"user_count"`
DurationDays int `json:"duration_days"`
OriginPrice int `json:"origin_price"`
PaidPrice int `json:"paid_price"`
GiftDurationDays int `json:"gift_duration_days"`
} `json:"buy_info_list"`
} `json:"customized_app"`
PromotionCase struct {
OrderType int `json:"order_type"`
CaseId string `json:"case_id"`
PromotionEditionName string `json:"promotion_edition_name"`
BuyInfoList []struct {
Suiteid string `json:"suiteid"`
Appid int `json:"appid"`
UserCount int `json:"user_count"`
OriginPrice int `json:"origin_price"`
PaidPrice int `json:"paid_price"`
GiftDurationDays int `json:"gift_duration_days"`
} `json:"buy_info_list"`
} `json:"promotion_case"`
} `json:"product_list"`
} `json:"pay_order"`
}

var _ bodyer = RespGetOrderDetailPaytool{}

func (x RespGetOrderDetailPaytool) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}

// ExecGetOrderDetailPaytool 获取收款订单详情
// 文档:https://developer.work.weixin.qq.com/document/path/98054#获取收款订单详情
func (c *ApiClient) ExecGetOrderDetailPaytool(req ReqGetOrderDetailPaytool) (RespGetOrderDetailPaytool, error) {
var resp RespGetOrderDetailPaytool
err := c.executeWXApiPost("/cgi-bin/paytool/get_order_detail", req, &resp, true)
if err != nil {
return RespGetOrderDetailPaytool{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespGetOrderDetailPaytool{}, bizErr
}
return resp, nil
}

0 comments on commit 5a438f7

Please sign in to comment.