提交 43809888 authored 作者: 屈传平's avatar 屈传平

hcw

上级 4f9f7d0f
package hcw
import (
"encoding/json"
"github.com/gogf/gf/net/ghttp"
)
//notify_id string 唯一请求ID(用于幂等校验)示例:20240320140000_123456
//app_id string 平台分配的应用ID
//type string 业务类型标识,见下表
//data object 业务数据对象
//signature string 请求签名(验证方法见第四章)
type OrderNotifyRes struct {
NotifyId int64 `json:"notify_id"`
AppId int64 `json:"app_id"`
Type int64 `json:"type"`
Data OrderNotifyData `json:"data"`
SignaTure int64 `json:"signature"`
}
// order_shipped 订单发货 { "order_no":"P123"}
// refund_result 发起售后成功 { "order_no":100.00}
// product_status 产品状态变更(1上架2下架) { "product_no":"SKU123"}
type OrderNotifyData struct {
OrderNo int64 `json:"order_no"`
ProductNo int64 `json:"product_no"`
}
// 回调
func (s *HcwClient) CallBack(r *ghttp.Request) (res *OrderNotifyRes, err error) {
body, err := CheckSign(r)
if nil != err {
return
}
if body == "" {
return
}
err = json.Unmarshal([]byte(body), &res)
return
}
func CheckSign(r *ghttp.Request) (body string, err error) {
body = r.GetBodyString()
return
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论