小费接口
This commit is contained in:
@@ -145,3 +145,62 @@ func (a *API) GetRiderLatestPosition(sfOrderID string) (retVal *RiderLatestPosit
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
// 添加小费
|
||||
func (a *API) AddTipFee(deliveryId string, fee int64) error {
|
||||
param := &Addordergratuityfee{
|
||||
DevId: a.devId,
|
||||
OrderId: deliveryId,
|
||||
PushTime: time.Now().Unix(),
|
||||
GratuityFee: fee,
|
||||
OrderType: 0,
|
||||
ShopId: 0,
|
||||
ShopType: 0,
|
||||
serialNumber: "",
|
||||
}
|
||||
resp := a.HttpPostJson("addordergratuityfee", param)
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
if resp.BaseRetVal.ErrorCode != SuccessCode {
|
||||
return fmt.Errorf("%s", resp.BaseRetVal.ErrorMsg)
|
||||
}
|
||||
var retVal *AddordergratuityfeeResp
|
||||
s, _ := json.Marshal(resp.BaseRetVal.Result)
|
||||
if err := json.Unmarshal(s, &retVal); err == nil {
|
||||
return nil
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// 获取运单小费
|
||||
func (a *API) QueryTipFee(sfOrderId string) (int64, error) {
|
||||
resp := a.HttpPostJson("getordergratuityfee", map[string]interface{}{
|
||||
"dev_id": a.devId,
|
||||
"order_id": sfOrderId,
|
||||
"push_time": time.Now().Unix()},
|
||||
)
|
||||
if resp.HttpStatusCode != HttpStatusSuccessCode {
|
||||
return 0, errors.New("HTTP请求错误,请检查重试")
|
||||
}
|
||||
if resp.BaseRetVal.ErrorCode != SuccessCode {
|
||||
return 0, fmt.Errorf("%s", resp.BaseRetVal.ErrorMsg)
|
||||
}
|
||||
var retVal *QueryOrderTipFee
|
||||
s, _ := json.Marshal(resp.BaseRetVal.Result)
|
||||
if err := json.Unmarshal(s, &retVal); err == nil {
|
||||
return retVal.TotalGratuityFee, nil
|
||||
} else {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
type QueryOrderTipFee struct {
|
||||
SfOrderId string //顺丰订单号,新版本V1.9+升级为JS开头的15位字符串类型, 老版本为int类型
|
||||
ShopOrderId string //商家订单号
|
||||
TotalGratuityFee int64 //该订单总的加小费金额
|
||||
TotalGratuityTimes int64 //该订单总的加小费次数
|
||||
GratuityFeeList interface{} // 加小费列表,未加则是空数组
|
||||
PushTime string //推送时间
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user