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

hdh

上级 416ce508
...@@ -3,9 +3,11 @@ package hdh ...@@ -3,9 +3,11 @@ package hdh
//会订货 //会订货
import ( import (
"context" "context"
"errors"
"github.com/gogf/gf/crypto/gmd5" "github.com/gogf/gf/crypto/gmd5"
"github.com/gogf/gf/encoding/gjson" "github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g" "github.com/gogf/gf/frame/g"
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/os/gtime" "github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gconv"
"time" "time"
...@@ -54,3 +56,13 @@ func post(ctx context.Context, method string, req interface{}) (res string, err ...@@ -54,3 +56,13 @@ func post(ctx context.Context, method string, req interface{}) (res string, err
res = resp.ReadAllString() res = resp.ReadAllString()
return return
} }
//检测回调sign
func CheckSign(r *ghttp.Request) (body string, err error) {
signStr := gconv.String(r.GetHeader("sign"))
body = r.GetBodyString()
if sign(body) != signStr {
err = errors.New("sign错误")
}
return
}
...@@ -3,6 +3,7 @@ package hdh ...@@ -3,6 +3,7 @@ package hdh
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/gogf/gf/net/ghttp"
) )
type GoodsNotifyRes struct { type GoodsNotifyRes struct {
...@@ -224,3 +225,13 @@ func GetGoodsInfo(ctx context.Context, req *GoodsInfoReq) (res *GoodsInfoRes, er ...@@ -224,3 +225,13 @@ func GetGoodsInfo(ctx context.Context, req *GoodsInfoReq) (res *GoodsInfoRes, er
err = json.Unmarshal([]byte(result), &res) err = json.Unmarshal([]byte(result), &res)
return return
} }
//商品回调
func GoodsCallBack(r *ghttp.Request) (res *GoodsNotifyRes, err error) {
body, err := CheckSign(r)
if nil != err {
return
}
err = json.Unmarshal([]byte(body), &res)
return
}
...@@ -3,6 +3,7 @@ package hdh ...@@ -3,6 +3,7 @@ package hdh
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"github.com/gogf/gf/net/ghttp"
) )
type OerCreateReq struct { type OerCreateReq struct {
...@@ -63,27 +64,6 @@ type PkgList struct { ...@@ -63,27 +64,6 @@ type PkgList struct {
PkgNo string `json:"pkgNo"` //包裹号 PkgNo string `json:"pkgNo"` //包裹号
} }
//物流轨迹回调接口
type ExpressNotifyRes struct {
OrderNum string `json:"orderNum"` //订单号
PkgList []struct {
ExpressCode int `json:"expressCode"` //物流状态code
ExpressList []struct {
ExpressCompany string `json:"expressCompany"` //物流公司
ExpressDetail []struct {
Express string `json:"express"` //物流节点
Time string `json:"time"` //时间
} `json:"expressDetail"` //物流详情
ExpressNum string `json:"expressNum"` //物流单号
} `json:"expressList"` //物流轨迹信息
OrderStatus string `json:"orderStatus"` //子订单状态
OrderStatusCode int `json:"orderStatusCode"` //订单状态code参考订单状态字典
PkgNo string `json:"pkgNo"` //包裹号(一笔订单可能被拆分为多个包裹)
Status string `json:"status"` //包裹物流轨迹状态 参考物流状态字典
} `json:"pkgList"` //包裹信息
UserOrderNum string `json:"userOrderNum"` //用户订单号
}
//创建订单 //创建订单
func OrderCreate(ctx context.Context, req *OerCreateReq) (res *OerCreateRes, err error) { func OrderCreate(ctx context.Context, req *OerCreateReq) (res *OerCreateRes, err error) {
...@@ -94,3 +74,13 @@ func OrderCreate(ctx context.Context, req *OerCreateReq) (res *OerCreateRes, err ...@@ -94,3 +74,13 @@ func OrderCreate(ctx context.Context, req *OerCreateReq) (res *OerCreateRes, err
err = json.Unmarshal([]byte(result), &res) err = json.Unmarshal([]byte(result), &res)
return return
} }
//订单回调
func OrderCallBack(r *ghttp.Request) (res *OrderNotifyRes, err error) {
body, err := CheckSign(r)
if nil != err {
return
}
err = json.Unmarshal([]byte(body), &res)
return
}
package hdh
import (
"context"
"encoding/json"
"github.com/gogf/gf/net/ghttp"
)
//物流轨迹回调接口
type ExpressNotifyRes struct {
OrderNum string `json:"orderNum"` //订单号
PkgList []struct {
ExpressCode int `json:"expressCode"` //物流状态code
ExpressList []struct {
ExpressCompany string `json:"expressCompany"` //物流公司
ExpressDetail []struct {
Express string `json:"express"` //物流节点
Time string `json:"time"` //时间
} `json:"expressDetail"` //物流详情
ExpressNum string `json:"expressNum"` //物流单号
} `json:"expressList"` //物流轨迹信息
OrderStatus string `json:"orderStatus"` //子订单状态
OrderStatusCode int `json:"orderStatusCode"` //订单状态code参考订单状态字典
PkgNo string `json:"pkgNo"` //包裹号(一笔订单可能被拆分为多个包裹)
Status string `json:"status"` //包裹物流轨迹状态 参考物流状态字典
} `json:"pkgList"` //包裹信息
UserOrderNum string `json:"userOrderNum"` //用户订单号
}
//物流信息查询请求
type ExpressQueryReq struct {
AppID string `json:"appId"`
OrderNum string `json:"orderNum"`
}
//物流信息查询返回
type ExpressQueryRes struct {
Code string `json:"code"`
Data []struct {
ExpressCode int `json:"expressCode"`
ExpressList []struct {
ExpressDetail []interface{} `json:"expressDetail"`
} `json:"expressList"`
ItemList []struct {
ChannelName string `json:"channelName"`
ChannelType string `json:"channelType"`
ItemId string `json:"itemId"`
Number int `json:"number"`
SkuId string `json:"skuId"`
} `json:"itemList"`
OrderStatus string `json:"orderStatus"`
OrderStatusCode int `json:"orderStatusCode"`
PkgNo string `json:"pkgNo"`
Status string `json:"status"`
} `json:"data"`
Message string `json:"message"`
Success int `json:"success"`
}
//物流信息查询
func ExpressQuery(ctx context.Context, req *ExpressQueryReq) (res *ExpressQueryRes, err error) {
result, err := post(ctx, "/track/query_track.do", req)
if nil != err {
return
}
err = json.Unmarshal([]byte(result), &res)
return
}
//物流信息回调
func ExpressNotify(r *ghttp.Request) (res *ExpressNotifyRes, err error) {
body, err := CheckSign(r)
if nil != err {
return
}
err = json.Unmarshal([]byte(body), &res)
return
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论