Skip to content

Commit

Permalink
新增收银台API和回调事件
Browse files Browse the repository at this point in the history
  • Loading branch information
zsmhub committed Dec 7, 2022
1 parent cd3b66f commit ff69a87
Show file tree
Hide file tree
Showing 12 changed files with 577 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apis/应用授权-获取企业授权信息.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ func (x ReqGetAuthInfoService) intoBody() ([]byte, error) {
// RespGetAuthInfoService 获取企业授权信息响应
// 文档:https://developer.work.weixin.qq.com/document/path/90604#获取企业授权信息
type RespGetAuthInfoService struct {
CommonResp
AuthCorpInfo AuthCorpInfo `json:"auth_corp_info"`
AuthInfo AuthInfo `json:"auth_info"`
DealerCorpInfo DealerCorpInfo `json:"dealer_corp_info"`
CommonResp
// 收银台获取企业授权信息额外返回字段:https://developer.work.weixin.qq.com/document/path/91912
EditionInfo EditionInfo `json:"edition_info"`
}

var _ bodyer = RespGetAuthInfoService{}
Expand Down
17 changes: 17 additions & 0 deletions apis/应用授权-获取企业永久授权码.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type (
State string `json:"state"`
TemplateID string `json:"template_id"`
} `json:"register_code_info"`
// 收银台获取企业永久授权码额外返回字段:https://developer.work.weixin.qq.com/document/path/91911
EditionInfo EditionInfo `json:"edition_info"`
}

AuthCorpInfo struct {
Expand Down Expand Up @@ -93,6 +95,21 @@ type (
CorpName string `json:"corp_name"`
Corpid string `json:"corpid"`
}

EditionInfo struct {
Agent []EditionInfoAgent `json:"agent"`
}

EditionInfoAgent struct {
Agentid int `json:"agentid"`
EditionId string `json:"edition_id"`
EditionName string `json:"edition_name"`
AppStatus int `json:"app_status"`
UserLimit int `json:"user_limit"`
ExpiredTime int `json:"expired_time"`
IsVirtualVersion bool `json:"is_virtual_version"`
IsSharedFromOtherCorp bool `json:"is_shared_from_other_corp"`
}
)

var _ bodyer = RespGetPermanentCodeService{}
Expand Down
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
// 可自行修改生成的文件,以满足开发需求

// ReqProlongTryService 延长试用期请求
// 文档:https://developer.work.weixin.qq.com/document/path/91913#延长试用期
type ReqProlongTryService struct {
// Appid 仅旧套件需要填此参数
Appid int `json:"appid,omitempty"`
// BuyerCorpid 购买方corpid,必填
BuyerCorpid string `json:"buyer_corpid"`
// ProlongDays 延长天数,必填
ProlongDays int `json:"prolong_days"`
}

var _ bodyer = ReqProlongTryService{}

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

// RespProlongTryService 延长试用期响应
// 文档:https://developer.work.weixin.qq.com/document/path/91913#延长试用期
type RespProlongTryService struct {
CommonResp
// TryEndTime 延长后的试用到期时间(UNIX时间戳)
TryEndTime int `json:"try_end_time"`
}

var _ bodyer = RespProlongTryService{}

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

// ExecProlongTryService 延长试用期
// 文档:https://developer.work.weixin.qq.com/document/path/91913#延长试用期
func (c *ApiClient) ExecProlongTryService(req ReqProlongTryService) (RespProlongTryService, error) {
var resp RespProlongTryService
err := c.executeWXApiPost("/cgi-bin/service/prolong_try", req, &resp, true)
if err != nil {
return RespProlongTryService{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespProlongTryService{}, bizErr
}
return resp, nil
}
109 changes: 109 additions & 0 deletions apis/收银台-获取订单列表.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package apis

import (
"encoding/json"
)

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

// ReqGetOrderListService 获取订单列表请求
// 文档:https://developer.work.weixin.qq.com/document/path/91910#获取订单列表
type ReqGetOrderListService struct {
// EndTime 终止时间,UNIX时间戳,必填
EndTime int `json:"end_time"`
// StartTime 起始时间,UNIX时间戳,必填
StartTime int `json:"start_time"`
// TestMode 指定拉取正式或测试授权的订单。默认值为0,其中 0-正式授权,1-测试授权。
TestMode int `json:"test_mode,omitempty"`
}

var _ bodyer = ReqGetOrderListService{}

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

// RespGetOrderListService 获取订单列表响应
// 文档:https://developer.work.weixin.qq.com/document/path/91910#获取订单列表
type RespGetOrderListService struct {
CommonResp
OrderList []struct {
// Appid 套件应用id(仅旧套件有该字段)
Appid int `json:"appid"`
// BeginTime 购买生效期的开始时间(UNIX时间戳)
BeginTime int `json:"begin_time"`
DealerCorpInfo struct {
// CorpName 代理商的企业简称
CorpName string `json:"corp_name"`
// Corpid 代理商corpid
Corpid string `json:"corpid"`
} `json:"dealer_corp_info"` // 代理商信息(仅当有渠道商报备后才会有此字段)
// DealerShareAmount 代理商分成金额,单位分
DealerShareAmount int `json:"dealer_share_amount"`
// EditionID 购买版本ID
EditionID string `json:"edition_id"`
// EditionName 购买版本名字
EditionName string `json:"edition_name"`
// EndTime 购买生效期的结束时间(UNIX时间戳)
EndTime int `json:"end_time"`
// OperatorCorpid 下单方corpid
OperatorCorpid string `json:"operator_corpid"`
// OperatorID 下单操作人员userid。如果是服务商代下单,没有该字段。
OperatorID string `json:"operator_id"`
// OrderFrom 下单来源。0-企业下单;1-服务商代下单;2-代理商代下单
OrderFrom int `json:"order_from"`
// OrderPeriod 购买的时长,单位天
OrderPeriod int `json:"order_period"`
// OrderStatus 订单状态。订单状态。0-待支付,1-已支付,2-已取消, 3-支付过期, 4-申请退款中, 5-退款成功, 6-退款被拒绝
OrderStatus int `json:"order_status"`
// OrderTime 下单时间(UNIX时间戳)
OrderTime int `json:"order_time"`
// OrderType 订单类型。0-新购应用,1-扩容应用人数,2-续期应用时间,3-变更版本
OrderType int `json:"order_type"`
// Orderid 订单号
Orderid string `json:"orderid"`
// PaidCorpid 客户企业的corpid
PaidCorpid string `json:"paid_corpid"`
// PaidTime 付款时间(UNIX时间戳)
PaidTime int `json:"paid_time"`
// PlatformShareAmount 平台分成金额,单位分
PlatformShareAmount int `json:"platform_share_amount"`
// Price 应付价格,单位分
Price int `json:"price"`
// ServiceShareAmount 服务商分成金额,单位分
ServiceShareAmount int `json:"service_share_amount"`
// Suiteid 应用id
Suiteid string `json:"suiteid"`
// UserCount 购买的人数
UserCount int `json:"user_count"`
} `json:"order_list"` // 订单列表
}

var _ bodyer = RespGetOrderListService{}

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

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

import (
"encoding/json"
)

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

// ReqGetOrderService 获取订单详情请求
// 文档:https://developer.work.weixin.qq.com/document/path/91909#获取订单详情
type ReqGetOrderService struct {
// Orderid 订单号,必填
Orderid string `json:"orderid"`
}

var _ bodyer = ReqGetOrderService{}

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

// RespGetOrderService 获取订单详情响应
// 文档:https://developer.work.weixin.qq.com/document/path/91909#获取订单详情
type RespGetOrderService struct {
// Appid 套件应用id(仅旧套件有该字段)
Appid int `json:"appid"`
// BeginTime 购买生效期的开始时间(UNIX时间戳)
BeginTime int `json:"begin_time"`
DealerCorpInfo struct {
// CorpName 代理商的企业简称
CorpName string `json:"corp_name"`
// Corpid 代理商corpid
Corpid string `json:"corpid"`
} `json:"dealer_corp_info"` // 渠道商信息(仅当有渠道商报备后才会有此字段)
// DealerShareAmount 代理商分成金额,单位分
DealerShareAmount int `json:"dealer_share_amount"`
// EditionID 购买版本ID
EditionID string `json:"edition_id"`
// EditionName 购买版本名字
EditionName string `json:"edition_name"`
// EndTime 购买生效期的结束时间(UNIX时间戳)
EndTime int `json:"end_time"`
CommonResp
// OperatorCorpid 下单方corpid
OperatorCorpid string `json:"operator_corpid"`
// OperatorID 下单操作人员userid。如果是服务商代下单,没有该字段。
OperatorID string `json:"operator_id"`
// OrderFrom 下单来源。0-企业下单;1-服务商代下单;2-代理商代下单
OrderFrom int `json:"order_from"`
// OrderPeriod 购买的时长,单位为天
OrderPeriod int `json:"order_period"`
// OrderStatus 订单状态。0-待支付,1-已支付,2-已取消, 3-支付过期, 4-申请退款中, 5-退款成功, 6-退款被拒绝
OrderStatus int `json:"order_status"`
// OrderTime 下单时间(UNIX时间戳)
OrderTime int `json:"order_time"`
// OrderType 订单类型。0-新购应用,1-扩容应用人数,2-续期应用时间,3-变更版本
OrderType int `json:"order_type"`
// Orderid 订单号
Orderid string `json:"orderid"`
// PaidCorpid 客户企业的corpid
PaidCorpid string `json:"paid_corpid"`
// PaidTime 付款时间(UNIX时间戳)
PaidTime int `json:"paid_time"`
// PlatformShareAmount 平台分成金额,单位分
PlatformShareAmount int `json:"platform_share_amount"`
// Price 应付价格,单位分
Price int `json:"price"`
// ServiceShareAmount 服务商分成金额,单位分
ServiceShareAmount int `json:"service_share_amount"`
// Suiteid 应用id
Suiteid string `json:"suiteid"`
// UserCount 本次订单扩容之后的人数
UserCount int `json:"user_count"`
}

var _ bodyer = RespGetOrderService{}

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

// ExecGetOrderService 获取订单详情
// 文档:https://developer.work.weixin.qq.com/document/path/91909#获取订单详情
func (c *ApiClient) ExecGetOrderService(req ReqGetOrderService) (RespGetOrderService, error) {
var resp RespGetOrderService
err := c.executeWXApiPost("/cgi-bin/service/get_order", req, &resp, true)
if err != nil {
return RespGetOrderService{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespGetOrderService{}, bizErr
}
return resp, nil
}
1 change: 1 addition & 0 deletions callback_generate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func main() {
api.XmlStr = strings.ReplaceAll(api.XmlStr, "&lt;", "<")
api.XmlStr = strings.ReplaceAll(api.XmlStr, "&gt;", ">")
api.XmlStr = strings.ReplaceAll(api.XmlStr, "]]</", "]]></") // 修复官方xml错误
api.XmlStr = strings.ReplaceAll(api.XmlStr, "</ ", "</") // 修复官方xml错误

api.Msg, _ = callbacks.CallbackMessage{}.ParseMessageFromXml([]byte(api.XmlStr))

Expand Down
15 changes: 15 additions & 0 deletions callbacks/callback_constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ const InfoTypeChangeSchoolContact EventType = "change_school_contact"
// 重置永久授权码通知
const InfoTypeRestPermanentCode EventType = "reset_permanent_code"

// 收银台-下单成功通知
const InfoTypeOpenOrder EventType = "open_order"

// 收银台-应用版本变更通知
const InfoTypeChangeEdtion EventType = "change_editon"

// 收银台-支付成功通知
const InfoTypePayForAppSuccess EventType = "pay_for_app_success"

// 收银台-改单通知
const InfoTypeChangeOrder EventType = "change_order"

// 收银台-退款通知
const InfoTypeRefund EventType = "refund"

// ChangeType 变更类型
type ChangeType string

Expand Down
Loading

0 comments on commit ff69a87

Please sign in to comment.