提交 da05fd9d authored 作者: 张立波's avatar 张立波

盛创汇联

上级 6802d6ee
package schl
import (
"context"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"github.com/gogf/gf/container/garray"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/text/gregex"
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/grand"
"regexp"
"sort"
"strings"
)
var server *Config
type Config struct {
ApiUrl string
AppKey string
AppSecret string
ImgUrl string
}
const pkgName = "schl"
func New(config *Config) {
server = config
return
}
func (c *Config) Post(ctx context.Context, api string, bodyMap g.Map) (result string, err error) {
Start := gtime.TimestampMilli()
pubilcParams := new(PubilcParams)
pubilcParams.AppID = c.AppKey
pubilcParams.Timestamp = gtime.TimestampStr()
pubilcParams.Nonce = grand.S(16, false)
secret := c.AppSecret
sign := c.Sign(ctx, *pubilcParams, bodyMap, secret)
defer func() {
ctx = context.WithValue(ctx, "URI", api)
if err != nil {
g.Log().Ctx(ctx).Cat(pkgName).Cat("error").
Infof("参数【%v】错误【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(pkgName).
Infof("参数【%v】响应【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), result, gtime.TimestampMilli()-Start)
}
}()
pubilcParams.Signature = sign
pubilcParamsMap := gconv.Map(pubilcParams)
for k, v := range pubilcParamsMap {
bodyMap[k] = v
}
response, err := g.Client().Ctx(ctx).
Post(c.ApiUrl+api, bodyMap)
defer func() {
_ = response.Close()
}()
if nil != err {
return
}
result, _ = gregex.ReplaceString(`\s`, "", response.ReadAllString())
return
}
func (c *Config) Sign(ctx context.Context, pubilcParams PubilcParams, params g.Map, secret string) (sign string) {
allMaps := make(map[string]string)
var arr = garray.New().Append("appId", "timestamp", "nonce")
for k, v := range gconv.MapStrStr(pubilcParams) {
if arr.Contains(k) {
allMaps[k] = v
}
}
allMaps["secret"] = secret
for k, v := range params {
re3, _ := regexp.Compile(`\s`)
allMaps[k] = re3.ReplaceAllString(gconv.String(v), "")
}
keys := make([]string, 0)
for k := range allMaps {
keys = append(keys, k)
}
sort.Strings(keys)
paramsString := ""
for k, v := range keys {
if k > 0 {
paramsString += "&"
}
paramsString += v + "=" + allMaps[v]
}
paramsString += "&key=" + secret
hmacSha256String := hmacSha256(paramsString, secret)
sign = strings.ToUpper(hmacSha256String)
return
}
func hmacSha256(data string, secret string) string {
h := hmac.New(sha256.New, []byte(secret))
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}
package schl
type CommonRes struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
type PubilcParams struct {
AppID string `json:"appId"`
Nonce string `json:"nonce"`
Timestamp string `json:"timestamp"`
Signature string `json:"signature"`
}
type CategoryRes struct {
CommonRes
Result []CategoryItem `json:"result"`
}
type CategoryItem struct {
Id int `json:"id"`
Img string `json:"img"`
Name string `json:"name"`
SupId int `json:"supId"`
}
type ListGoodsRes struct {
CommonRes
Result []ListGoodsItem `json:"result"`
}
type ListGoodsItem struct {
Code string `json:"code"`
Name string `json:"name"`
ItemMainImg string `json:"itemMainImg"`
Imgs interface{} `json:"imgs"`
DetailImgs interface{} `json:"detailImgs"`
GoodsVideo string `json:"goodsVideo"`
ShareImg string `json:"shareImg"`
ShareVideo string `json:"shareVideo"`
MarketPrice float64 `json:"marketPrice"`
MarketPriceTagImg string `json:"marketPriceTagImg"`
NormalPrice float64 `json:"normalPrice"`
Vip1Price float64 `json:"vip1Price"`
Vip2Price float64 `json:"vip2Price"`
CurrVipPrice float64 `json:"currVipPrice"`
MinBuyNum int `json:"minBuyNum"`
PlusStep int `json:"plusStep"`
Unit string `json:"unit"`
Weight float64 `json:"weight"`
Volume float64 `json:"volume"`
Stock int `json:"stock"`
State int `json:"state"`
ForbidBuyArea string `json:"forbidBuyArea"`
SupplierFreightPayer int `json:"supplierFreightPayer"`
CategoryGRList []struct {
C1 int `json:"c1"`
C2 int `json:"c2"`
} `json:"categoryGRList"`
}
type ListGoodsByCodesReq struct {
CodeList []string `json:"codeList"` //["ZGRSH12","ZGYSH11","ZGJRJ10","ZGGTJ09","CWSKYTJ15","CWDYLG14"]
}
type OrderFreightPreviewReq struct {
Province string `json:"province"`
City string `json:"city"`
District string `json:"district"`
AddressDetail string `json:"addressDetail"`
GoodsParamsList string `json:"goodsParamsList"` //[{\"code\":\"goodsCode1\",\"goodsNum\":1}]
}
type OrderFreightPreviewRes struct {
CommonRes
Result OrderFreightPreviewItem `json:"result"`
}
type OrderFreightPreviewItem struct {
ExpName string `json:"expName"` //运费总额
Freight float64 `json:"freight"` //快递编码
ExpCode string `json:"expCode"` //快递名称
}
type CreateOrderReq struct {
PlatformOrderNo string `json:"platformOrderNo"` //商户单号,若创建多商品订单建议不传该参
CustName string `json:"custName"` //收货人
CustMobile string `json:"custMobile"` //收货人联系方式
Province string `json:"province"` //省
City string `json:"city"` //市
District string `json:"district"` //区
AddressDetail string `json:"addressDetail"`
GoodsParamsList string `json:"goodsParamsList"` //[{\"code\":\"goodsCode1\",\"goodsNum\":1}]code需创建订单的商品编码 goodsNum 数量
}
type CreateOrderRes struct {
CommonRes
Result CreateOrderItem `json:"result"`
}
type CreateOrderItem struct {
UnionId string `json:"unionId"` //平台订单编号,用于后续操作平台订单
PayMoney string `json:"payMoney"` //支付总额
GoodsMoneyAmount string `json:"goodsMoneyAmount"` //商品总额
ExpFeeAmount string `json:"expFeeAmount"` //运费总额
ExpCode string `json:"expCode"` //快递编码
ExpName string `json:"expName"` //快递名称
}
type SyncOrderExpNoReq struct {
UnionIdList string `json:"unionIdList"` //平台订单编号数组,需转成String传入
}
type SyncOrderExpNoRes struct {
CommonRes
Result []struct {
UnionId string `json:"unionId"` //平台订单编号
ExpNos []string `json:"expNos"` //快递/物流单号
} `json:"result"`
}
type QueryExpTrackReq struct {
UnionId string `json:"unionId"` //平台订单编号,用于后续操作平台订单
ExpNos string `json:"expNo"` //订单对应的快递单号数组
}
type QueryExpTrackRes struct {
CommonRes
Result QueryExpTrackItem `json:"result"`
}
type QueryExpTrackItem struct {
ExpInfo string `json:"expInfo"` //json
}
type ExpInfoItem struct {
Number string `json:"number"`
Type string `json:"type"`
List []struct {
Time string `json:"time"`
Status string `json:"status"`
} `json:"list"`
Deliverystatus string `json:"deliverystatus"`
Issign string `json:"issign"`
ExpName string `json:"expName"`
ExpSite string `json:"expSite"`
ExpPhone string `json:"expPhone"`
Logo string `json:"logo"`
Courier string `json:"courier"`
CourierPhone string `json:"courierPhone"`
UpdateTime string `json:"updateTime"`
TakeTime string `json:"takeTime"`
}
......@@ -2,132 +2,124 @@ package schl
import (
"context"
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
"github.com/gogf/gf/container/garray"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/text/gregex"
"github.com/gogf/gf/util/gconv"
"github.com/gogf/gf/util/grand"
"net/url"
"sort"
"strings"
"time"
)
type api struct {
}
var Api = api{}
var server *Config
/*
获取分类
*/
func (api) Category(ctx context.Context) (res *CategoryRes, err error) {
const Host = "https://schl-api.szbaoly.com"
result, err := server.Post(ctx, "vip/api/goods/listGoodsCategory", g.Map{})
err = gjson.New(result).Scan(&res)
if err != nil {
return
}
return
type Config struct {
ApiUrl string
AppKey string
AppSecret string
ImgUrl string
}
/*
获取商品
*/
func (api) GoodsList(ctx context.Context) (res *ListGoodsRes, err error) {
result, err := server.Post(ctx, "vip/api/goods/listGoods", g.Map{})
err = gjson.New(result).Scan(&res)
if err != nil {
return
}
return
type CommonRes struct {
Code int `json:"code"`
Msg string `json:"msg"`
}
/*
编码查询商品
*/
func (api) ListGoodsByCodes(ctx context.Context, codeList []string) (res *ListGoodsRes, err error) {
data := g.Map{
"codeList": gjson.New(codeList).MustToJsonString(),
}
result, err := server.Post(ctx, "vip/api/goods/listGoodsByCodes", data)
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
if err != nil {
return
}
return
type PubilcParams struct {
AppID string `json:"appid"`
Nonce string `json:"nonce"`
Timestamp string `json:"timestamp"`
Signature string `json:"signature"`
}
/*
订单运费预览
*/
func (api) OrderFreightPreview(ctx context.Context, req *OrderFreightPreviewReq) (res *OrderFreightPreviewRes, err error) {
const pkgName = "schl"
data := gconv.Map(req)
result, err := server.Post(ctx, "vip/api/order/orderFreightPreview", data)
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
if err != nil {
return
}
func New(config *Config) {
server = config
return
}
/*
同步订单快递单号
*/
func (api) SyncOrderExpNo(ctx context.Context, req string) (res *SyncOrderExpNoRes, err error) {
result, err := server.Post(ctx, "vip/api/order/syncOrderExpNo", g.Map{"unionIdList": gjson.New([]string{req}).MustToJsonString()})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
if err != nil {
func (c *Config) Post(ctx context.Context, URL string, bodyMap g.Map) (result string, err error) {
Start := gtime.TimestampMilli()
pubilcParams := new(PubilcParams)
pubilcParams.AppID = c.AppKey
pubilcParams.Timestamp = gtime.TimestampStr()
pubilcParams.Nonce = grand.S(16, false)
c.Sign(pubilcParams)
defer func() {
ctx = context.WithValue(ctx, "URI", URL)
if err != nil {
g.Log().Ctx(ctx).Cat(pkgName).Cat("error").
Infof("参数【%v】错误【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(pkgName).
Infof("参数【%v】响应【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), result, gtime.TimestampMilli()-Start)
}
}()
var value = url.Values{}
value.Add("appid", pubilcParams.AppID)
value.Add("nonce", pubilcParams.Nonce)
value.Add("timestamp", pubilcParams.Timestamp)
value.Add("signature", pubilcParams.Signature)
response, err := g.Client().
Timeout(time.Second*3).
ContentJson().
Post(Host+URL+"?"+value.Encode(), bodyMap)
defer func() {
_ = response.Close()
}()
if nil != err {
return
}
result, _ = gregex.ReplaceString(`\s`, "", response.ReadAllString())
return
}
/*
订单创建
*/
func (api) CreateOrder(ctx context.Context, req *CreateOrderReq) (res *CreateOrderRes, err error) {
data := gconv.Map(req)
result, err := server.Post(ctx, "vip/api/order/createOrder", data)
if err != nil {
return
func (c *Config) Sign(pubilcParams *PubilcParams) {
allMaps := make(map[string]string)
var arr = garray.New().Append("appid", "timestamp", "nonce")
for k, v := range gconv.MapStrStr(pubilcParams) {
if arr.Contains(k) {
allMaps[k] = v
}
}
err = gjson.New(result).Scan(&res)
if err != nil {
return
keys := make([]string, 0)
for k := range allMaps {
keys = append(keys, k)
}
if err != nil {
return
sort.Strings(keys)
paramsString := ""
for k, v := range keys {
if k > 0 {
paramsString += "&"
}
paramsString += v + "=" + allMaps[v]
}
return
}
/*
查询订单快递/物流轨迹
*/
func (api) QueryExpTrack(ctx context.Context, req *QueryExpTrackReq) (res *QueryExpTrackRes, err error) {
paramsString += "&key=" + server.AppSecret
data := gconv.Map(req)
result, err := server.Post(ctx, "vip/api/order/queryExpTrack", data)
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
if err != nil {
return
}
hmacSha256String := hmacSha256(paramsString, server.AppSecret)
pubilcParams.Signature = strings.ToUpper(hmacSha256String)
return
}
func hmacSha256(data string, secret string) string {
h := hmac.New(sha256.New, []byte(secret))
h.Write([]byte(data))
return hex.EncodeToString(h.Sum(nil))
}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type brandLogic struct {
}
var Brand = brandLogic{}
type BrandListRes struct {
CommonRes
Result []struct {
BrandImg string `json:"brandImg"`
BrandName string `json:"brandName"`
Id int `json:"id"`
} `json:"result"`
}
// List 获取商品品牌
func (*brandLogic) List(ctx context.Context) (res *BrandListRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/goods/listGoodsBrand", g.Map{})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type categoryLogic struct {
}
var Category = categoryLogic{}
type CategoryListRes struct {
CommonRes
Result []CategoryListItem `json:"result"`
}
type CategoryListItem struct {
Id int `json:"id"`
Img string `json:"img"`
Name string `json:"name"`
SupId int `json:"supId"`
}
// List 获取商品分类
func (*categoryLogic) List(ctx context.Context) (res *CategoryListRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/goods/listGoodsCategory", g.Map{})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
type goodsLogic struct {
}
var Goods = goodsLogic{}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type GoodsEventRes struct {
CommonRes
Result []struct {
EventKey string `json:"eventKey"`
EventDesc string `json:"eventDesc"`
ChangesContent []struct {
Code string `json:"code,omitempty"`
Price string `json:"price,omitempty"`
Id string `json:"id,omitempty"`
State string `json:"state,omitempty"`
} `json:"changesContent"`
} `json:"result"`
}
func (*goodsLogic) Event(ctx context.Context) (res *GoodsEventRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/goods/listGoodsChangeEvent", g.Map{})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv"
)
type GoodsListReq struct {
Current int `json:"current,omitempty"`
Size int `json:"size,omitempty"`
Query GoodsListQuery `json:"query"`
}
type GoodsListQuery struct {
QueryType int `json:"queryType"` //1:全量商品查询 2:选品库商品查询
GoodsIds []int `json:"goodsIds,omitempty"` //商品id数组,长度最大为100
GoodsCode string `json:"goodsCode,omitempty"` //商品规格编码
CategoryId1 int `json:"categoryId,omitempty"` //商品分类id
CategoryId2 int `json:"twoCategoryId,omitempty"` //二级分类id
CategoryId3 int `json:"treeCategoryId,omitempty"` //二级分类id
}
type GoodsListRes struct {
CommonRes
Result struct {
Current int `json:"current"`
Total int `json:"total"`
Records []GoodsListItem `json:"records"`
} `json:"result"`
}
type GoodsListItem struct {
Id int `json:"id"`
Title string `json:"title"`
MainImg string `json:"mainImg"`
State int `json:"state"`
GoodsCategoryList []GoodsListCategory `json:"goodsCategoryList"`
SpecificationList []GoodsListSpec `json:"specificationList"`
}
type GoodsListCategory struct {
C1 int `json:"c1"`
C2 int `json:"c2"`
C3 int `json:"c3"`
}
type GoodsListSpec struct {
Code string `json:"code"`
Name string `json:"name"`
GoodsId int `json:"goodsId"`
SpecInfo string `json:"specInfo"`
CurrVipPrice float64 `json:"currVipPrice"`
ItemMainImg string `json:"itemMainImg"`
Imgs []string `json:"imgs"`
DetailImgs []string `json:"detailImgs"`
Video string `json:"video"`
ForbidBuyArea string `json:"forbidBuyArea"`
IsFreeDelivery int `json:"isFreeDelivery"`
RemoteAreaFreight string `json:"remoteAreaFreight"`
MarketIcon string `json:"marketIcon"`
MarketPrice float64 `json:"marketPrice"`
MinBuyNum int `json:"minBuyNum"`
StepNum int `json:"stepNum"`
StockNum int `json:"stockNum"`
Weight float64 `json:"weight"`
Volume float64 `json:"volume"`
Unit string `json:"unit"`
JumpLink string `json:"jumpLink"`
TaxCode string `json:"taxCode"`
BillingName string `json:"billingName"`
BillingSpecName string `json:"billingSpecName"`
ZpTaxRate string `json:"zpTaxRate"`
Freight float64 `json:"freight"`
}
func (*goodsLogic) List(ctx context.Context, req GoodsListReq) (res *GoodsListRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/goods/listGoods", gconv.Map(req))
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv"
)
type logisticsLogic struct {
}
var Logistics = logisticsLogic{}
type LogisticsTraceReq struct {
UnionNo string `json:"unionNo"`
ExpNo string `json:"expNo"`
}
type LogisticsTraceRes struct {
CommonRes
Result struct {
Courier string `json:"courier"`
CourierPhone string `json:"courierPhone"`
DeliveryStatus int `json:"deliverystatus"`
ExpName string `json:"expName"`
ExpPhone string `json:"expPhone"`
List []struct {
Time string `json:"time"`
Status string `json:"status"`
} `json:"list"`
Number string `json:"number"`
Type string `json:"type"`
} `json:"result"`
TraceId string `json:"traceId"`
}
func (s *logisticsLogic) Trace(ctx context.Context, req LogisticsTraceReq) (res *LogisticsTraceRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/order/queryExpTrack", gconv.Map(req))
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
type orderLogic struct {
}
var Order = orderLogic{}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv"
)
type OrderBeforeReq struct {
FreightPayer int `json:"freightPayer"`
InvoiceHeaderId int `json:"invoiceHeaderId"`
InvoiceType int `json:"invoiceType"`
Province string `json:"province"`
City string `json:"city"`
District string `json:"district"`
ExpCode string `json:"expCode"`
OrderDetailsList []struct {
Code string `json:"code"`
Num int `json:"num"`
} `json:"orderDetailsList"`
}
type OrderBeforeRes struct {
Code int `json:"code"`
Msg string `json:"msg"`
Result struct {
Freight float64 `json:"freight"`
GoodsMoneyAmount float64 `json:"goodsMoneyAmount"`
PayMoney float64 `json:"payMoney"`
} `json:"result"`
TraceId string `json:"traceId"`
}
// Before 订单运费
func (s *orderLogic) Before(ctx context.Context, req OrderBeforeReq) (res *OrderBeforeRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/order/orderFreightPreview", gconv.Map(req))
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv"
)
type OrderCreateReq struct {
PlatformOrderNo string `json:"platformOrderNo"`
FreightPayer int `json:"freightPayer"`
InvoiceHeaderId int `json:"invoiceHeaderId"`
InvoiceType int `json:"invoiceType"`
CustName string `json:"custName"`
CustMobile string `json:"custMobile"`
Province string `json:"province"`
City string `json:"city"`
District string `json:"district"`
AddressDetail string `json:"addressDetail"`
ExpCode string `json:"expCode"`
OrderDetailsList []struct {
Code string `json:"code"`
Num int `json:"num"`
} `json:"orderDetailsList"`
}
type OrderCreateRes struct {
Code int `json:"code"`
Msg string `json:"msg"`
Result struct {
UnionNo string `json:"unionNo"`
TotalNum int `json:"totalNum"`
ExpFeeAmount float64 `json:"expFeeAmount"`
GoodsMoneyAmount int `json:"goodsMoneyAmount"`
PayMoney float64 `json:"payMoney"`
OrderList []struct {
SuborderId int `json:"suborderId"`
TotalGoodsAmount int `json:"totalGoodsAmount"`
FreightAmount float64 `json:"freightAmount"`
TotalAmount float64 `json:"totalAmount"`
OrderDetailList []struct {
OrderDetailId int `json:"orderDetailId"`
SpecCode string `json:"specCode"`
SpecName string `json:"specName"`
SpecInfo string `json:"specInfo"`
Num int `json:"num"`
UnitPrice int `json:"unitPrice"`
TotalAmount int `json:"totalAmount"`
} `json:"orderDetailList"`
} `json:"orderList"`
} `json:"result"`
}
// Create 创建订单
func (s *orderLogic) Create(ctx context.Context, req OrderCreateReq) (res *OrderCreateRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/order/createOrder", gconv.Map(req))
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type OrderEventRes struct {
CommonRes
Result []struct {
EventKey string `json:"eventKey"`
EventDesc string `json:"eventDesc"`
ChangesContent []struct {
UnionNo string `json:"unionNo"`
OrderDeliveredList []struct {
ExpName string `json:"expName"`
ExpNo string `json:"expNo"`
ExpCode string `json:"expCode"`
PackageList []struct {
OrderDetailId int `json:"orderDetailId"`
DeliveredNum int `json:"deliveredNum"`
DeliveredTime string `json:"deliveredTime"`
} `json:"packageList"`
} `json:"orderDeliveredList"`
} `json:"changesContent"`
} `json:"result"`
}
func (s *orderLogic) Event(ctx context.Context) (res *OrderEventRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/order/listOrderChangeEvent", g.Map{})
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
package schl
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/util/gconv"
)
type OrderListReq struct {
UnionNos []string `json:"unionNos,omitempty"` //平台订单号数组,最大长度为100
PlatformOrderNos []string `json:"platformOrderNos,omitempty"` //商户平台订单号数组,最大长度为100
}
type OrderListRes struct {
CommonRes
Result []struct {
UnionNo string `json:"unionNo"` //平台订单号
PlatformOrderNo string `json:"platformOrderNo"` //商户平台订单号
TotalAmount float64 `json:"totalAmount"` //订单商品总金额
TotalFreightAmount float64 `json:"totalFreightAmount"` //订单总运费 如开票则含13%税金
TotalNum int `json:"totalNum"` //订单商品总数
Province string `json:"province"` //收件人省份
City string `json:"city"` //收件人城市
District string `json:"district"` //收件人地区
AddressDetail string `json:"addressDetail"` //收件人详细地址
CreateTime string `json:"createTime"` //创建时间
PayTime string `json:"payTime"` //支付时间
PayNo string `json:"payNo"` //支付流水号
CustMobile string `json:"custMobile"` //收件人名称
CustName string `json:"custName"` //收件人名称
OrderList []struct {
FreightAmount float64 `json:"freightAmount"` //子单运费
FreightPayer int `json:"freightPayer"`
InvoiceType int `json:"invoiceType"`
OrderDeliveredList []struct {
ExpCode string `json:"expCode"`
ExpName string `json:"expName"`
ExpNo string `json:"expNo"`
PackageList []struct {
DeliveredNum int `json:"deliveredNum"`
DeliveredTime string `json:"deliveredTime"`
OrderDetailId int `json:"orderDetailId"`
} `json:"packageList"`
} `json:"orderDeliveredList"`
OrderDetailList []struct {
Num int `json:"num"`
OrderDetailId int `json:"orderDetailId"`
SpecCode string `json:"specCode"`
SpecInfo string `json:"specInfo"`
SpecName string `json:"specName"`
TaxAmount float64 `json:"taxAmount"`
TotalAmount float64 `json:"totalAmount"`
TotalTaxAmount float64 `json:"totalTaxAmount"`
UnitPrice float64 `json:"unitPrice"`
} `json:"orderDetailList"`
State int `json:"state"` //订单状态 -2:已退款 1:已支付 2:已发货 3:已完成
SuborderId int `json:"suborderId"` //子订单id
TotalAmount float64 `json:"totalAmount"` //子单总金额
TotalGoodsAmount float64 `json:"totalGoodsAmount"` //子单商品总金额
TotalTaxAmount float64 `json:"totalTaxAmount"`
} `json:"orderList"`
PayAmount float64 `json:"payAmount"`
} `json:"result"`
}
func (s *orderLogic) List(ctx context.Context, req OrderListReq) (res *OrderListRes, err error) {
result, err := server.Post(ctx, "/open/xdxt/api/v2/order/listOrderInfo", gconv.Map(req))
if err != nil {
return
}
err = gjson.New(result).Scan(&res)
return
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论