1
This commit is contained in:
@@ -17,9 +17,14 @@ const (
|
||||
// KuaiShouBashUrl 基础域名
|
||||
KuaiShouBashUrl = "https://open.kuaishou.com" // 域名
|
||||
|
||||
KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录
|
||||
KuaiShouGetToken = KuaiShouBashUrl + "/oauth2/access_token" // 获取授权token
|
||||
KuaiShouPreCreateOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/create_order" // 预下单接口
|
||||
KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录
|
||||
KuaiShouGetToken = KuaiShouBashUrl + "/oauth2/access_token" // 获取授权token
|
||||
KuaiShouPreCreateOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/create_order" // 预下单接口
|
||||
KuaiShouGetOrderDetail = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_order" // 获取订单详情接口
|
||||
KuaiShouRefundOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/apply_refund" // 订单退款
|
||||
KuaiShouRefundOrderDetail = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_refund" // 订单退款详情
|
||||
KuaiShouGetSettleOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/settle" // 刷新订单结算信息
|
||||
KuaiShouQuerySettleOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_settle" // 查询订单的结算信息
|
||||
)
|
||||
|
||||
type API struct {
|
||||
@@ -82,8 +87,9 @@ func (a *API) GetToken() error {
|
||||
func (a *API) AccessAPI1(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
globals.SugarLogger.Debugf("====param := %s", utils.Format4Output(params, false))
|
||||
request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
request.Header.Set("Content-Type", "application/json")
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
@@ -137,8 +143,6 @@ func (a *API) sign(param map[string]interface{}) string {
|
||||
|
||||
sort.Strings(paramsArr)
|
||||
|
||||
globals.SugarLogger.Debugf("param := %s", utils.Format4Output(param, false))
|
||||
globals.SugarLogger.Debugf("paramsArr := %s", utils.Format4Output(paramsArr, false))
|
||||
signParma := make([]string, len(paramsArr))
|
||||
for k, v := range paramsArr {
|
||||
if !utils.IsNil(param[v]) {
|
||||
|
||||
93
platformapi/kuaishou_mini/kuaishou_callback.go
Normal file
93
platformapi/kuaishou_mini/kuaishou_callback.go
Normal file
@@ -0,0 +1,93 @@
|
||||
package kuaishou_mini
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
const (
|
||||
CallbackTypePay = "PAYMENT" // 支付回调
|
||||
CallbackTypeRefund = "REFUND" // 退款回调
|
||||
CallbackTypeSettle = "SETTLE" // 结算回调
|
||||
|
||||
OrderPayStatusHandleing = "PROCESSING" // 支付订单处理中
|
||||
OrderPayStatusSuccess = "SUCCESS" // 订单支付成功
|
||||
OrderPayStatusFailed = "FAILED" // 订单支付失败
|
||||
)
|
||||
|
||||
// KauiShouCallback 回调处理
|
||||
func (a *API) KauiShouCallback(request *http.Request) (*CallBackDetail, *RefundCallBack, string, string, error) {
|
||||
data, err := ioutil.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
return nil, nil, "", "-1", err
|
||||
}
|
||||
|
||||
var callback *KauiShouCallbackRes
|
||||
if err := json.Unmarshal(data, &callback); err != nil {
|
||||
return nil, nil, "", "-1", err
|
||||
}
|
||||
|
||||
switch callback.BizType {
|
||||
case CallbackTypePay:
|
||||
var payCallback *CallBackDetail
|
||||
if value, ok := callback.Data.(string); ok {
|
||||
if err := json.Unmarshal([]byte(value), &payCallback); err != nil {
|
||||
return nil, nil, "", callback.MessageId, err
|
||||
}
|
||||
} else {
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(value)), &payCallback); err != nil {
|
||||
return nil, nil, "", callback.MessageId, err
|
||||
}
|
||||
}
|
||||
return payCallback, nil, CallbackTypePay, callback.MessageId, err
|
||||
case CallbackTypeRefund:
|
||||
var refundCallback *RefundCallBack
|
||||
if value, ok := callback.Data.(string); ok {
|
||||
if err := json.Unmarshal([]byte(value), &refundCallback); err != nil {
|
||||
return nil, nil, "", callback.MessageId, err
|
||||
}
|
||||
} else {
|
||||
if err := json.Unmarshal([]byte(utils.Interface2String(value)), &refundCallback); err != nil {
|
||||
return nil, nil, "", callback.MessageId, err
|
||||
}
|
||||
}
|
||||
return nil, refundCallback, CallbackTypeRefund, callback.MessageId, err
|
||||
case CallbackTypeSettle:
|
||||
return nil, nil, "", callback.MessageId, errors.New("无效回调类型")
|
||||
default:
|
||||
return nil, nil, "", callback.MessageId, errors.New("无效回调类型")
|
||||
}
|
||||
}
|
||||
|
||||
// KuaiShouRefundCallBack 快手退款回调
|
||||
//func (a *API) KuaiShouRefundCallBack(request *http.Request) (*RefundCallBack, error) {
|
||||
// data, err := ioutil.ReadAll(request.Body)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// var callback *RefundCallBack
|
||||
// if err := json.Unmarshal(data, &callback); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// return callback, err
|
||||
//}
|
||||
|
||||
// KuaiShouSettleCallBack 当订单结算成功之后,快手小程序服务端会通过 post 方式回调开发者提供的 HTTP 接口
|
||||
//func (a *API) KuaiShouSettleCallBack(request *http.Request) (*SettleCallback, error) {
|
||||
// data, err := ioutil.ReadAll(request.Body)
|
||||
// if err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// var callback *SettleCallback
|
||||
// if err := json.Unmarshal(data, &callback); err != nil {
|
||||
// return nil, err
|
||||
// }
|
||||
//
|
||||
// return callback, err
|
||||
//}
|
||||
@@ -42,8 +42,158 @@ type PreCreateOrderReq struct {
|
||||
CancelOrder int64 `json:"cancel_order"` // 该字段表示创建订单的同时是否覆盖之前已存在的订单。
|
||||
}
|
||||
|
||||
// PreCreateOrderResponse 预下单返回参数
|
||||
type PreCreateOrderResponse struct {
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
OrderInfo string `json:"order_info"` //拉起收银台的 orderInfo
|
||||
}
|
||||
|
||||
// GetOrderDetailRes 获取支付订单详情
|
||||
type GetOrderDetailRes struct {
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
PaymentInfo string `json:"payment_info"` //拉起收银台的 orderInfo
|
||||
}
|
||||
|
||||
type PaymentInfo struct {
|
||||
TotalAmount int64 `json:"total_amount"` // 预下单用户支付金额
|
||||
PayStatus string `json:"pay_status"` // 支付状态。 取值: PROCESSING-处理中|SUCCESS-成功|FAILED-失败 TIMEOUT-超时
|
||||
PayTime int64 `json:"pay_time"` // 订单支付时间,单位为毫秒时间戳。
|
||||
PayChannel string `json:"pay_channel"` // 支付渠道。取值:UNKNOWN - 未知|WECHAT-微信 |ALIPAY-支付宝。(注:如果用户还未支付,这里返回的是UNKNOWN.)
|
||||
OutOrderNo string `json:"out_order_no"` // 开发者下单单号
|
||||
KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号
|
||||
ExtraInfo string `json:"extra_info"` // 订单来源信息,历史订单为""
|
||||
EnablePromotion bool `json:"enable_promotion"` // 是否参与分销,true:分销,false:非分销
|
||||
PromotionAmount int64 `json:"promotion_amount"` // 预计分销金额,单位:分
|
||||
OpenId string `json:"open_id"` // 订单对应的用户open id
|
||||
OrderStatus int64 `json:"order_status"` // 开发者回传的订单同步状态
|
||||
}
|
||||
|
||||
// KauiShouCallbackRes 快手支付回调
|
||||
type KauiShouCallbackRes struct {
|
||||
Data interface{} `json:"data"`
|
||||
MessageId string `json:"message_id"` // 当前回调消息的唯一ID,在同一个消息多次通知时,保持一致。
|
||||
BizType string `json:"biz_type"` // 业务类型。取值:PAYMENT-支付
|
||||
AppId string `json:"app_id"` // 当前小程序的AppID
|
||||
Timestamp int64 `json:"timestamp"` // 流程变动的时间戳
|
||||
}
|
||||
|
||||
type CallBackDetail struct {
|
||||
Channel string `json:"channel"` // 支付渠道。取值:UNKNOWN - 未知|WECHAT-微信|ALIPAY-支付宝
|
||||
OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号
|
||||
Attach string `json:"attach"` // 预下单时携带的开发者自定义信息
|
||||
Status string `json:"status"` // 订单支付状态。 取值: PROCESSING-处理中|SUCCESS-成功|FAILED-失败
|
||||
KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号
|
||||
OrderAmount int `json:"order_amount"` // 订单金额
|
||||
TradeNo string `json:"trade_no"` // 用户侧支付页交易单号
|
||||
ExtraInfo string `json:"extra_info"` // 订单来源信息,同支付查询接口
|
||||
EnablePromotion bool `json:"enable_promotion"` // 是否参与分销,true:分销,false:非分销
|
||||
PromotionAmount int `json:"promotion_amount"` // 预计分销金额,单位:分
|
||||
}
|
||||
|
||||
// RefundParam 申请退单参数
|
||||
type RefundParam struct {
|
||||
OutOrderNo string `json:"out_order_no"` // 开发者需要发起退款的支付订单号
|
||||
OutRefundNo string `json:"out_refund_no"` // 开发者的退款单号
|
||||
Reason string `json:"reason"` // 退款理由
|
||||
Attach string `json:"attach"` // 开发者自定义字段,回调原样回传
|
||||
NotifyUrl string `json:"notify_url"` // 通知URL必须为直接可访问的URL,不允许携带查询串。
|
||||
RefundAmount int64 `json:"refund_amount"` // 用户退款金额,单位为分。不允许传非整数的数值
|
||||
Sign string `json:"sign"` // 签名
|
||||
MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景,示例值:[{"copies":2}], 内容见multi_copies_goods_info字段说明
|
||||
}
|
||||
|
||||
// RefundRes 申请退款返回参数
|
||||
type RefundRes struct {
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
RefundNo string `json:"refund_no"`
|
||||
}
|
||||
|
||||
// RefundOrderDetail 获取退款订单详情
|
||||
type RefundOrderDetail struct {
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
RefundInfo string `json:"refund_info"`
|
||||
}
|
||||
|
||||
// RefundInfo 获取申请退款详情
|
||||
type RefundInfo struct {
|
||||
KsOrderNo string `json:"ks_order_no"`
|
||||
RefundStatus string `json:"refund_status"`
|
||||
RefundNo string `json:"refund_no"`
|
||||
KsRefundType string `json:"ks_refund_type"`
|
||||
RefundAmount int `json:"refund_amount"`
|
||||
KsRefundNo string `json:"ks_refund_no"`
|
||||
}
|
||||
|
||||
// RefundCallBack 快手退款回调
|
||||
type RefundCallBack struct {
|
||||
//Data struct {
|
||||
OutRefundNo string `json:"out_refund_no"` // 开发者的退款单号
|
||||
RefundAmount int `json:"refund_amount"` // 退款金额
|
||||
Attach string `json:"attach"` // 预下单时携带的开发者自定义信息
|
||||
Status string `json:"status"` // 退款状态。 取值: PROCESSING-处理中,SUCCESS-成功,FAILED-失败
|
||||
KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号
|
||||
KsRefundNo string `json:"ks_refund_no"` // 快手小程序平台退款单号
|
||||
KsRefundType string `json:"ks_refund_type"` // 退款账户说明[]
|
||||
//} `json:"data"`
|
||||
//MessageId string `json:"message_id"`
|
||||
//BizType string `json:"biz_type"`
|
||||
//AppId string `json:"app_id"`
|
||||
//Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
// OrderSettleAccountParam 发起订单结算请求参数
|
||||
type OrderSettleAccountParam struct {
|
||||
OutOrderNo string `json:"out_order_no"`
|
||||
OutSettleNo string `json:"out_settle_no"`
|
||||
Reason string `json:"reason"`
|
||||
Attach string `json:"attach"`
|
||||
NotifyUrl string `json:"notify_url"`
|
||||
Sign string `json:"sign"`
|
||||
SettleAmount int64 `json:"settle_amount"`
|
||||
MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"`
|
||||
}
|
||||
|
||||
// OrderSettleAccountRes 发起订单结算返回参数
|
||||
type OrderSettleAccountRes struct {
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
SettleNo string `json:"settle_no"`
|
||||
}
|
||||
|
||||
// QuerySettleInfoRes 查询订单结算信息
|
||||
type QuerySettleInfoRes struct {
|
||||
Result int `json:"result"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
SettleInfo string `json:"settle_info"`
|
||||
}
|
||||
|
||||
type SettleInfo struct {
|
||||
SettleNo string `json:"settle_no"`
|
||||
TotalAmount int `json:"total_amount"`
|
||||
SettleAmount int `json:"settle_amount"`
|
||||
SettleStatus string `json:"settle_status"`
|
||||
KsOrderNo string `json:"ks_order_no"`
|
||||
KsSettleNo string `json:"ks_settle_no"`
|
||||
}
|
||||
|
||||
// SettleCallback 快手结算回调
|
||||
type SettleCallback struct {
|
||||
//Data struct {
|
||||
OutSettleNo string `json:"out_settle_no"` // 外部结算单号,即开发者结算请求的单号。
|
||||
Attach string `json:"attach"` // 预下单时携带的开发者自定义信息
|
||||
SettleAmount int `json:"settle_amount"` // 结算后给商户的金额,单位:分
|
||||
Status string `json:"status"` // 结算状态。 取值: PROCESSING-处理中,SUCCESS-成功,FAILED-失败
|
||||
KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号。
|
||||
KsSettleNo string `json:"ks_settle_no"` // 快手小程序平台结算单号。
|
||||
EnablePromotion bool `json:"enable_promotion"` // 是否参与分销,true:分销,false:非分销
|
||||
PromotionAmount int `json:"promotion_amount"` // 预计分销金额,单位:分
|
||||
//} `json:"data"`
|
||||
//BizType string `json:"biz_type"`
|
||||
//MessageId string `json:"message_id"`
|
||||
//AppId string `json:"app_id"`
|
||||
//Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package kuaishou_mini
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -31,6 +32,127 @@ func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) {
|
||||
return order.OrderInfo, nil
|
||||
}
|
||||
|
||||
// GetOrderDetail 订单详情查询接口
|
||||
func (a *API) GetOrderDetail(outOrderNo string) (*PaymentInfo, error) {
|
||||
data, err := a.AccessAPI1(KuaiShouGetOrderDetail, map[string]interface{}{"out_order_no": outOrderNo})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
orderDetail := &GetOrderDetailRes{}
|
||||
if err := utils.Map2StructByJson(data, orderDetail, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if orderDetail.Result != 1 {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if orderDetail.PaymentInfo == "" {
|
||||
return nil, errors.New("快手支付订单详情返回值为空")
|
||||
}
|
||||
|
||||
paymentInfo := &PaymentInfo{}
|
||||
if err := json.Unmarshal([]byte(orderDetail.PaymentInfo), paymentInfo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return paymentInfo, err
|
||||
}
|
||||
|
||||
// RefundOrder 支付请求退款接口
|
||||
// 在途资金中的所有货款均是与订单关联的,只有当该订单在途资金中剩余金额超过退款金额时,才可以进行在途资金的退款。
|
||||
// 当可提现金额也不足退款金额时,会退款失败,为了避免出现订单无法退款的情况出现,请根据业务情况自行保留一部分可提现金额在系统中
|
||||
func (a *API) RefundOrder(param *RefundParam) (refundNo string, err error) {
|
||||
data, err := a.AccessAPI1(KuaiShouRefundOrder, utils.Struct2MapByJson(param))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var result *RefundRes
|
||||
if err := utils.Map2StructByJson(data, &result, false); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if result.Result != 1 {
|
||||
return "", errors.New(result.ErrorMsg)
|
||||
}
|
||||
return result.RefundNo, nil
|
||||
}
|
||||
|
||||
// RefundOrderDetail 查询退款订单详情
|
||||
func (a *API) RefundOrderDetail(outRefundNo string) (*RefundInfo, error) {
|
||||
data, err := a.AccessAPI1(KuaiShouRefundOrderDetail, map[string]interface{}{"out_refund_no": outRefundNo})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var refundOrderDetail *RefundOrderDetail
|
||||
if err := utils.Map2StructByJson(data, &refundOrderDetail, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if refundOrderDetail.Result != 1 {
|
||||
return nil, errors.New(refundOrderDetail.ErrorMsg)
|
||||
}
|
||||
|
||||
var refundInfo *RefundInfo
|
||||
if err := json.Unmarshal([]byte(refundOrderDetail.RefundInfo), &refundInfo); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return refundInfo, nil
|
||||
}
|
||||
|
||||
// PaySettleAccounts 结算用于确认一笔在途资金,将其转化为可提现资金。
|
||||
// 结算规则
|
||||
// 1、订单履约完成后发起结算,结算周期为 订单到达核销状态(订单状态为11或15)满3天后可发起结算。核销状态通过订单同步接口 (opens new window)进行同步。
|
||||
// 2、需要主动调用结算接口后,才能进行后续资金的提现。
|
||||
// 3、结算时,小程序平台会收取整笔交易的平台服务费。若结算后发生退款,则平台服务费不作退还。
|
||||
|
||||
func (a *API) PaySettleAccounts4Order(param *OrderSettleAccountParam) (string, error) {
|
||||
data, err := a.AccessAPI1(KuaiShouGetSettleOrder, utils.Struct2MapByJson(param))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
var settle *OrderSettleAccountRes
|
||||
if err := utils.Map2StructByJson(data, &settle, false); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if settle.Result != 1 {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return settle.SettleNo, nil
|
||||
}
|
||||
|
||||
// QuerySettleInfo 查询结算信息
|
||||
func (a *API) QuerySettleInfo(outSettleNo string) (*SettleInfo, error) {
|
||||
data, err := a.AccessAPI1(KuaiShouQuerySettleOrder, map[string]interface{}{"out_settle_no": outSettleNo})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var settle *QuerySettleInfoRes
|
||||
if err := utils.Map2StructByJson(data, &settle, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if settle.Result != 1 {
|
||||
return nil, errors.New(settle.ErrorMsg)
|
||||
}
|
||||
|
||||
if settle.SettleInfo == "" {
|
||||
return nil, errors.New("数据查询为空")
|
||||
}
|
||||
|
||||
var result *SettleInfo
|
||||
if err := json.Unmarshal([]byte(settle.SettleInfo), result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (a *API) FullUrl(bashUrl string) string {
|
||||
if a.accessToken == "" || a.expiresIn < time.Now().Unix() {
|
||||
a.GetToken()
|
||||
|
||||
@@ -129,10 +129,11 @@ func TestSgin(t *testing.T) {
|
||||
|
||||
func TestBaokuanHuodong(t *testing.T) {
|
||||
// 获取门店所有的爆款活动
|
||||
storeId := 668887
|
||||
vendorStoreId := "17056471"
|
||||
storeId := 103201
|
||||
vendorStoreId := "8694421"
|
||||
|
||||
actList, _ := api.RetailDiscountList(vendorStoreId, 56)
|
||||
actList, err := api.RetailDiscountList(vendorStoreId, 56)
|
||||
fmt.Println(err)
|
||||
if len(actList) > 0 {
|
||||
allActivitySkuIdList := make([]string, 0, 0) // 此门店全部的折扣(爆款)活动商品
|
||||
activationActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店正在进行的折扣(爆款)活动商品
|
||||
|
||||
@@ -11,3 +11,16 @@ func TestGetConnectionToken(t *testing.T) {
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetWayBillFee(t *testing.T) {
|
||||
//order, _ := api.OrderGetOrderDetail(1100486451772280163, false)
|
||||
//globals.SugarLogger.Debugf("order:==%s", utils.Format4Output(order, false)) 2002
|
||||
api.GetWayBillFee("1100486451772280163", 2)
|
||||
api.GetWayBillFee("1100486451772280163", 1)
|
||||
}
|
||||
|
||||
// 商家没有接入众包配送,无法进行众包配送相关操作
|
||||
func TestGetShippingFeeList(t *testing.T) {
|
||||
api.GetShippingFeeList("1300486314174032613,1100487300210228389", 1)
|
||||
api.GetShippingFeeList("1300486314174032613,1100487300210228389", 2)
|
||||
}
|
||||
|
||||
53
platformapi/mtwmapi/logistics_fee.go
Normal file
53
platformapi/mtwmapi/logistics_fee.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
)
|
||||
|
||||
// GetWayBillFee 获取美团众包配送费已经保险费
|
||||
func (a *API) GetWayBillFee(orderId string, serviceBrand int) (*GetOrderLogisticsFee, error) {
|
||||
data, err := a.AccessAPI("order/logistics/pt/preview", true, map[string]interface{}{"order_id": orderId, "service_brand": serviceBrand})
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("err := %v", err)
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(data)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
type GetOrderLogisticsFeeRes struct {
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
data string `json:"data"`
|
||||
}
|
||||
|
||||
type GetOrderLogisticsFee struct {
|
||||
WmOrderId int64 `json:"wm_order_id"` // 订单id
|
||||
ShippingFee float64 `json:"shipping_fee"` // 配送费(基础+临时)
|
||||
OriginalPrice float64 `json:"original_price"` // 订单的总原价,单位为元此字段数据为未扣减所有优惠前订单的总金额,含打包袋、配送费等。
|
||||
LogisticsStatus int64 `json:"logistics_status"` // 美团配送订单状态code
|
||||
ShippingTips string `json:"shipping_tips"` // 配送费浮动说明
|
||||
PayAmount float64 `json:"pay_amount"` // 实付金额
|
||||
Distance int `json:"distance"` // 配送距离(m)
|
||||
CouponViewId string `json:"coupon_view_id"` // 配送费优惠券id
|
||||
CouponName string `json:"coupon_name"` // 优惠券名称
|
||||
CouponAmount float64 `json:"coupon_amount"` // 优惠券金额
|
||||
ReduceDetail ReduceDetailObj
|
||||
}
|
||||
|
||||
type ReduceDetailObj struct {
|
||||
UserTaskId int64 `json:"user_task_id"` // 立减活动id
|
||||
TaskId int64 `json:"task_id"` // 立减活动task id
|
||||
BmlAmount float64 `json:"bml_amount"` // 立减金额(元)
|
||||
}
|
||||
|
||||
func (a *API) GetShippingFeeList(orderIds string, serviceBrand int) (*GetOrderLogisticsFeeRes, error) {
|
||||
data, err := a.AccessAPI("order/zhongbao/shippingFee", true, map[string]interface{}{"order_id": orderIds, "service_brand": serviceBrand})
|
||||
if err != nil {
|
||||
globals.SugarLogger.Debugf("err := %v", err)
|
||||
return nil, err
|
||||
}
|
||||
fmt.Println(data)
|
||||
return nil, nil
|
||||
}
|
||||
@@ -20,13 +20,13 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
|
||||
// 菜市
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
// api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw
|
||||
api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw
|
||||
cookieStr := `
|
||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
`
|
||||
@@ -60,7 +60,7 @@ func TestGetAccessToken(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetAccessToken2(t *testing.T) {
|
||||
result, err := api.GetAccessToken2("16708848") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
||||
result, err := api.GetAccessToken2("17371124") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -69,7 +69,7 @@ func TestGetAccessToken2(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRefreshAccessToken(t *testing.T) {
|
||||
result, err := api.RefreshAccessToken("refresh_token_jOp7ekeHrzjBUvLdVuZHIg") //token_qbAyE3ajWYT8ecwoI-FMjw
|
||||
result, err := api.RefreshAccessToken("refresh_token_jajfdTMzYvB28v-3q4RFgQ") //token_qbAyE3ajWYT8ecwoI-FMjw
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package mtwmapi
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -19,14 +18,18 @@ func TestOrderViewStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderGetOrderDetail(t *testing.T) {
|
||||
result, err := api.OrderGetOrderDetail(1100449970093397157, false)
|
||||
result, err := api.OrderGetOrderDetail(1300486314174032613, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(result) == 0 {
|
||||
t.Fatal("result should have value")
|
||||
}
|
||||
globals.SugarLogger.Debugf("%s", utils.Format4Output(result, false))
|
||||
|
||||
for k, v := range result {
|
||||
fmt.Println(fmt.Sprintf("%s=%v", k, v))
|
||||
}
|
||||
//globals.SugarLogger.Debugf("%s", utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestOrderGetOrderDetail2(t *testing.T) {
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
// "authority_id": ""
|
||||
//}`
|
||||
|
||||
var token = `{"access_token":"cf5c39a7-969a-4a54-8528-e3d9479c202f","expires_in":1681065425,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"4f54e08d-1d62-4f96-935d-20b938c19f96","authority_id":""}`
|
||||
var token = `{"access_token":"d04f3829-3ee5-4886-bdcd-70f928055cbe","expires_in":1681311682,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"e0b7bc95-067c-4cfb-a59a-1c00344ab851","authority_id":""}`
|
||||
|
||||
//var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user