im
This commit is contained in:
@@ -9,14 +9,14 @@ import (
|
||||
"encoding/base64"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -100,8 +100,7 @@ func (a *API) signParams(params map[string]interface{}) (sign string) {
|
||||
finalStr := strings.Join(strList, "&")
|
||||
d := sha256.Sum256([]byte(finalStr))
|
||||
signature, _ := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, d[:])
|
||||
sign = base64.StdEncoding.EncodeToString(signature)
|
||||
return sign
|
||||
return base64.StdEncoding.EncodeToString(signature)
|
||||
}
|
||||
|
||||
func method2ResponseKey(method string) (responseKey string) {
|
||||
@@ -126,7 +125,7 @@ func (a *API) AccessAPI(method string, params, bizContent map[string]interface{}
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
var request *http.Request
|
||||
params["timestamp"] = utils.GetCurTimeStr()
|
||||
params["timestamp"] = utils.Time2Str(time.Now())
|
||||
params[signKey] = a.signParams(params)
|
||||
|
||||
fullURL := utils.GenerateGetURL(prodURL, "", params)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package alipayapi
|
||||
|
||||
import "git.rosy.net.cn/baseapi/utils"
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
const (
|
||||
GrantTypeCode = "authorization_code"
|
||||
@@ -42,13 +44,13 @@ func (a *API) SystemAuthToken(grantType, code, refreshToken string) (tokenInfo *
|
||||
params["refresh_token"] = refreshToken
|
||||
}
|
||||
// 获取证书
|
||||
appCertSN, aliPayRootCertSN, aliPayPublicCertSN, err := SetCertSnByPath(AppCertPath, AliPayRootCertPath, AliPayPublicCertPath)
|
||||
appCertSN, aliPayRootCertSN, _, err := SetCertSnByPath(AppCertPath, AliPayRootCertPath, AliPayPublicCertPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params["app_cert_sn"] = appCertSN
|
||||
params["alipay_public_cert_sn"] = aliPayPublicCertSN
|
||||
//params["alipay_public_cert_sn"] = aliPayPublicCertSN
|
||||
params["alipay_root_cert_sn"] = aliPayRootCertSN
|
||||
|
||||
retVal, err := a.AccessAPI("alipay.system.oauth.token", params, nil, false)
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func TestSystemAuthToken(t *testing.T) {
|
||||
result, err := api.SystemAuthToken(GrantTypeCode, "85636904854946afa6890299e0a1VX17", "")
|
||||
result, err := api.SystemAuthToken(GrantTypeCode, "e4f95e2065a84625aaf01dea2703NA17", "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -362,6 +362,35 @@ func (a *API) OrderselfDeliveryStateSync(orderID, phone string) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
type PushRiderInfo struct {
|
||||
DistributorId int `json:"distributor_id"` // 固定值:201
|
||||
Knight Knight `json:"knight"`
|
||||
OrderId string // 订单id
|
||||
State int // 配送状态,传固定值:21 开始配送(已废弃,已接入商家不影响)
|
||||
SelfStatus int `json:"selfStatus"` // 配送状态
|
||||
SelfStatusDesc string `json:"selfStatusDesc"` // 配送状态文案描述
|
||||
SelfSubStatus int `json:"selfSubStatus"` // 配送取消(6)子原因:
|
||||
SelfSubStatusDesc string `json:"selfSubStatusDesc"` // 配送异常子状态文案描述
|
||||
DistributorInfoDTO DistributorInfoDTO `json:"distributorInfoDTO"` // 配送服务商信息
|
||||
}
|
||||
type Knight struct {
|
||||
Id int64 `json:"id"` // 骑手id,商家自定义
|
||||
Name string `json:"name"` // 骑手姓名
|
||||
Phone string `json:"phone"` // 骑手手机号码
|
||||
}
|
||||
|
||||
type DistributorInfoDTO struct {
|
||||
DistributorTypeId string `json:"distributorTypeId"` // 配送商类型id:
|
||||
DistributorName string `json:"distributorName"` // 配送商名称
|
||||
DistributorPhone string `json:"distributorPhone"` // 配送商电话
|
||||
}
|
||||
|
||||
// OrderselfDeliveryStateSync2 饿了么自配送订单接入骑手状态
|
||||
func (a *API) OrderselfDeliveryStateSync2(info *PushRiderInfo) (err error) {
|
||||
_, err = a.AccessAPI("order.selfDeliveryStateSync", utils.Struct2MapByJson(info))
|
||||
return err
|
||||
}
|
||||
|
||||
// 饿了么自配送订单回传订单已送出状态
|
||||
// 此接口目前只支持饿了么侧订单调用
|
||||
func (a *API) OrderSendOut(orderID, phone string) (err error) {
|
||||
|
||||
@@ -211,7 +211,7 @@ func TestC(t *testing.T) {
|
||||
//}
|
||||
//
|
||||
func TestGetJdUpcCodeByName(t *testing.T) {
|
||||
result, err := api.GetJdUpcCodeByName("", "6909931247116", 1, 5)
|
||||
result, err := api.GetJdUpcCodeByName("", "6924343516087", 1, 5)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package kuaishou_mini
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"net/http"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
@@ -14,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 {
|
||||
@@ -75,7 +83,27 @@ func (a *API) GetToken() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AccessAPI2 发送请求
|
||||
// AccessAPI1 发送请求(支付)
|
||||
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;charset=UTF-8")
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
retVal = jsonResult1
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// AccessAPI2 发送请求(登录)
|
||||
func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
@@ -93,3 +121,35 @@ func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[
|
||||
})
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// sign 签名
|
||||
func (a *API) sign(param map[string]interface{}) string {
|
||||
param["app_id"] = a.appId
|
||||
var paramsArr []string
|
||||
for k, v := range param {
|
||||
if k == "sign" || k == "access_token" {
|
||||
continue
|
||||
}
|
||||
value := strings.TrimSpace(fmt.Sprintf("%v", v))
|
||||
if strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"") && len(value) > 1 {
|
||||
value = value[1 : len(value)-1]
|
||||
}
|
||||
value = strings.TrimSpace(value)
|
||||
if value == "" || value == "nil" {
|
||||
continue
|
||||
}
|
||||
paramsArr = append(paramsArr, k)
|
||||
}
|
||||
|
||||
sort.Strings(paramsArr)
|
||||
|
||||
signParma := make([]string, len(paramsArr))
|
||||
for k, v := range paramsArr {
|
||||
if !utils.IsNil(param[v]) {
|
||||
signParma[k] = v + "=" + fmt.Sprintf("%v", param[v])
|
||||
}
|
||||
}
|
||||
sign := strings.Join(signParma, "&") + a.appSecret
|
||||
return fmt.Sprintf("%x", md5.Sum([]byte(sign)))
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
//}
|
||||
@@ -24,8 +24,8 @@ type GetAutoTokenRes struct {
|
||||
TokenType string `json:"token_type"`
|
||||
}
|
||||
|
||||
// PreCreateOrderRes 快手预发单
|
||||
type PreCreateOrderRes struct {
|
||||
// PreCreateOrderReq 快手预发单
|
||||
type PreCreateOrderReq struct {
|
||||
OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一
|
||||
OpenId string `json:"open_id"` // 快手用户在当前小程序的open_id
|
||||
TotalAmount int64 `json:"total_amount"` // 用户支付金额,单位为[分]。
|
||||
@@ -41,3 +41,159 @@ type PreCreateOrderRes struct {
|
||||
MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景 "[{"copies":2}]"
|
||||
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,32 +1,161 @@
|
||||
package kuaishou_mini
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// PreCreateOrder 预下单生成支付信息
|
||||
//func (a *API) PreCreateOrder(param *PreCreateOrderRes) error {
|
||||
// if a.appId == "" || a.appSecret == "" {
|
||||
// return error
|
||||
// }
|
||||
//
|
||||
// result, err := a.AccessAPI2(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param))
|
||||
// if err != nil {
|
||||
// return "", "", err
|
||||
// }
|
||||
//
|
||||
// auth := GetLoginAuth{}
|
||||
// if err := utils.Map2StructByJson(result, &auth, false); err != nil {
|
||||
// return "", "", err
|
||||
// }
|
||||
//
|
||||
// if auth.Error != "" {
|
||||
// return "", "", errors.New(auth.ErrorMsg)
|
||||
// }
|
||||
//
|
||||
// return auth.SessionKey, auth.OpenId, nil
|
||||
//}
|
||||
func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) {
|
||||
if a.appId == "" || a.appSecret == "" {
|
||||
return "", errors.New("appId/appSecret 不能为空")
|
||||
}
|
||||
|
||||
param.Sign = a.sign(utils.Struct2MapByJson(param))
|
||||
result, err := a.AccessAPI1(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
order := PreCreateOrderResponse{}
|
||||
if err := utils.Map2StructByJson(result, &order, false); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if order.Result != 1 {
|
||||
return "", errors.New(order.ErrorMsg)
|
||||
}
|
||||
|
||||
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()
|
||||
}
|
||||
return fmt.Sprintf(bashUrl+"?app_id=%s&access_token=%s", a.appId, a.accessToken)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package kuaishou_mini
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
@@ -67,3 +68,38 @@ func DecryptUserMsg(sessionKey, iv, msg string) (string, error) {
|
||||
func TestCreateToken(t *testing.T) {
|
||||
api.GetToken()
|
||||
}
|
||||
|
||||
// 快手预下单获取支付参数
|
||||
func TestPreCreateOrder(t *testing.T) {
|
||||
param := &PreCreateOrderReq{
|
||||
OutOrderNo: "1024028220",
|
||||
OpenId: "f198f59711c9785314bf5724f7ab9f47",
|
||||
TotalAmount: 1,
|
||||
Subject: "这是一个测试商品",
|
||||
Detail: "大白菜,小白菜,中白菜",
|
||||
TypeDetail: 1832, // 素菜
|
||||
ExpireTime: 10 * 60,
|
||||
Sign: "",
|
||||
Attach: "1111",
|
||||
NotifyUrl: "https://callback.jxc4.com/tictoc/tiktokMsg",
|
||||
GoodsId: "1122",
|
||||
GoodsDetailUrl: "/page/index/anima",
|
||||
MultiCopiesGoodsInfo: "[{\"copies\":2}]",
|
||||
CancelOrder: 0,
|
||||
}
|
||||
data, err := api.PreCreateOrder(param)
|
||||
globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false))
|
||||
globals.SugarLogger.Debugf("err := %s", utils.Format4Output(err, false))
|
||||
}
|
||||
|
||||
func TestAaww(t *testing.T) {
|
||||
aa := make(map[string]interface{}, 1)
|
||||
aa["a"] = ""
|
||||
if value, ok := aa["a"].(int64); ok {
|
||||
fmt.Println(value)
|
||||
}
|
||||
if value, ok := aa["a"].(string); ok {
|
||||
|
||||
fmt.Println(utils.Str2Int64(value))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) // 此门店正在进行的折扣(爆款)活动商品
|
||||
|
||||
143
platformapi/mtwmapi/bill_list.go
Normal file
143
platformapi/mtwmapi/bill_list.go
Normal file
@@ -0,0 +1,143 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
type Bill struct {
|
||||
AppPoiCode string `json:"app_poi_code"` // APP方门店id,传商家中台系统里门店的编码。如商家在操作绑定门店至开放平台应用中时,未绑定三方门店id信息,则默认APP方门店id与美团门店id相同。
|
||||
StartDate int64 `json:"start_date"` // 秒级时间戳
|
||||
EndDate int64 `json:"end_date"` // 秒级时间戳
|
||||
Offset int64 `json:"offset"`
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
||||
// GetStoreBillList 获取门店的订单账单
|
||||
/*
|
||||
1.金额类字段单位使用“分”
|
||||
2.当日10点前不能查询昨日账单。
|
||||
3.开始日期和结束日期相隔不能超过7天。
|
||||
4.仅支持查询90天内的账单。
|
||||
5.如订单在状态完成之前取消了,则该订单不会记账,本接口不会查询到该订单的账单信息。
|
||||
6.商家如需对接,请按如下流程申请开通接口权限:请商家发送邮件至 MT.lingshou.open@meituan.com邮件标题:【appid+appname】开通日账单接口权限申请 邮件内容:需包括但不限于以下几点:
|
||||
1)需开通账单接口调用权限的应用appid、appname;
|
||||
2)开通的目的或背景;
|
||||
3)想要实现的效果;
|
||||
4)预计开发周期和上线时间;
|
||||
5)商家公司授权开通日账单接口的证明。(点击下载授权证明模板,授权证明以附件形式提供。)*/
|
||||
func (a *API) GetStoreBillList(param *Bill) (*StoreBillListRes, error) {
|
||||
result, err := a.AccessAPI3("bill/list", true, utils.Struct2Map(param, "", false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var data *StoreBillListRes
|
||||
if err := utils.Map2StructByJson(result, &data, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
// StoreBillListReq 门店结算查询条件
|
||||
type StoreBillListReq struct {
|
||||
AppPoiCode string `json:"app_poi_code"` // APP方门店id
|
||||
StartDate int64 `json:"start_date"` // 开始时间
|
||||
EndDate int64 `json:"end_date"` // 结束时间
|
||||
Offset int64 `json:"offset"` // 偏移量
|
||||
Limit int64 `json:"limit"` // 最大返回条数 (200)
|
||||
}
|
||||
|
||||
// StoreBillListRes 门店结算返回值
|
||||
type StoreBillListRes struct {
|
||||
ExtraInfo ExtraInfoData `json:"extra_info"`
|
||||
Data []*BillListData `json:"data"`
|
||||
}
|
||||
|
||||
type ExtraInfoData struct {
|
||||
TotalCount int `json:"total_count"` // 当前查询时间条件下返回的账单数据总条数
|
||||
SettleSum string `json:"settle_sum"` // 当前查询时间条件下返回的账单数据总结算金额(settleMilli汇总),单位分
|
||||
}
|
||||
|
||||
type BillListData struct {
|
||||
Id string `json:"id"` // 账单的唯一标识id
|
||||
WmPoiName string `json:"wmPoiName"` // 门店名称
|
||||
BillChargeType int `json:"billChargeType"` // 结算类型
|
||||
ChargeFeeDesc string `json:"chargeFeeDesc"` // 结算类型描述
|
||||
UserPayType int `json:"userPayType"` // 用户支付方式
|
||||
WmPoiOrderPushDayseq string `json:"wmPoiOrderPushDayseq"` // 订单流水号
|
||||
WmOrderViewId string `json:"wmOrderViewId"` // 订单展示ID
|
||||
OrderTime string `json:"orderTime"` // 下单时间
|
||||
FinishTime string `json:"finishTime"` // 完成时间
|
||||
RefundTime string `json:"refundTime"` // 退款时间
|
||||
OrderState int `json:"orderState"` // 订单当前状态
|
||||
ShippingType int `json:"shippingType"` // 订单配送方式,以订单完成时刻的配送方式为准。参考值:10-商家自配;20-美团快送;30-美团跑腿;40-美团专送;50-代理商配送;60-到店取餐;70-聚合配送;80-企客光速达;90-企客快速达;100-企客及时达;120-企客全城送。
|
||||
ShippingStatus int `json:"shippingStatus"` // 配送状态,参考值:0-未知;1-已推单;10-已抢单;15-已取餐;20-派送中;40-已送达;100-已取消。如为自配送订单,则配送状态默认为0。
|
||||
AccountState int `json:"accountState"` // 结算状态,参考值:0-已入账;1-未入账。
|
||||
DaliyBillDate string `json:"daliyBillDate"` // 账单日期
|
||||
SettleBillDesc string `json:"settleBillDesc"` // 归账日期,返回结算周期。商家在美团平台上建店时,与美团协议约定的门店结算周期(自外卖信息首次发布之日起算)。如订单未入账(accountState=1),此字段返回null。
|
||||
SettleAmount int64 `json:"settleAmount"` // 商家应收款,单位分。
|
||||
TotalFoodAmount int64 `json:"totalFoodAmount"` // 商品总价(不含商品包装盒费),单位分。公式:商品总价=商品原价+赠品原价
|
||||
BoxAmount int64 `json:"boxAmount"` // 商品包装盒费总价,单位分。
|
||||
ActivityPoiAmount int64 `json:"activityPoiAmount"` // 商家活动总支出金额(含赠品成本),单位分。
|
||||
ActivityMeituanAmount int64 `json:"activityMeituanAmount"` // 美团活动补贴总金额,单位分。
|
||||
ActivityAgentAmount int64 `json:"activityAgentAmount"` // 代理商活动承担金额,单位分。
|
||||
PlatformChargeFee int64 `json:"platformChargeFee"` // 平台服务费,单位分。
|
||||
PerformanceServiceFee int64 `json:"performanceServiceFee"` // 订单履约服务费金额,单位分。如订单无履约服务费,则返回0。(订单履约服务费金额=基础价格+距离收费+重量收费+节假日收费+品类收费+时段收费)
|
||||
BaseShippingAmount int64 `json:"baseShippingAmount"` // 履约服务费-基础价格,单位分
|
||||
Distance int64 `json:"distance"` // 履约服务费-导航距离,获取的导航距离,单位米
|
||||
DistanceFee int64 `json:"distanceFee"` // 履约服务费-距离收费,距离加价费用,单位分
|
||||
WeightChargeFee int64 `json:"weightChargeFee"` // 履约服务费-重量收费,重量加价费用,单位分
|
||||
HolidayChargeFee int64 `json:"holidayChargeFee"` // 履约服务费-节假日收费,单位分
|
||||
CategoryChargeFee int64 `json:"categoryChargeFee"` // 履约服务费-品类收费,单位分
|
||||
SlaFee int64 `json:"slaFee"` // 履约服务费-时段收费,时段加价费用,单位分
|
||||
UserPayShippingAmount int64 `json:"userPayShippingAmount"` // 用户支付配送费,为运费优惠前的金额,单位分。
|
||||
UserOnlinePayAmount int64 `json:"userOnlinePayAmount"` // 用户在线支付金额,为用户实际支付的订单总金额,单位分。
|
||||
UserOfflinePayAmount int64 `json:"userOfflinePayAmount"` // 用户线下支付金额,单位分。目前美团订单仅支持在线支付。
|
||||
Rate int64 `json:"rate"` // 平台服务费的费率,单位百分比(%)。是商家在美团平台建店时,与美团协议约定的每单抽佣比例。
|
||||
Bottom int64 `json:"bottom"` // 保底金额,单位元。是商家在美团平台建店时,与美团协议约定的每单保底抽佣金额。
|
||||
RefundId int64 `json:"refund_id"` // 退款id,与订单退款消息接口中退款id的值相对应。 目前只有在结算类型(billChargeType)为:2,6,7,26,27时,该字段会有合法值;其他结算类型下,该字段值无意义。当billChargeType=2时,该字段的取值与订单ID相同。
|
||||
Discount int64 `json:"discount"` // 分成折扣,目前默认返回100。
|
||||
SettleMilli int64 `json:"settleMilli"` // 结算金额,单位毫。
|
||||
SettleSettingId string `json:"settleSettingId"` // 结算id,表示账期等信息的结算设置id。同一门店的结算设置不变的情况下,结算id不变。
|
||||
WmDonationAmount int64 `json:"wmDonationAmount"` // 青山计划-公益捐赠金额,单位分。
|
||||
WmDoggyBagAmount int64 `json:"wmDoggyBagAmount"` // 商超-打包袋金额,单位分。注意,打包袋费用规则为: (1)订单打包袋如由美团提供给商家,费用结算美团平台,则打包袋字段wmDoggyBagAmount为0; (2)订单打包袋如由商家自己提供,费用结算给商家,则打包袋字段wmDoggyBagAmount为商家设置金额。
|
||||
DealTip int64 `json:"dealTip"` // 配送小费,单位分。
|
||||
ProductPreferences float64 `json:"productPreferences"` // 商家活动支出分摊到商品上的优惠总金额,单位分。
|
||||
NotProductPreferences float64 `json:"notProductPreferences"` // 商家活动支出的未分摊到商品上的总金额,单位分。
|
||||
WmAppOrderSkuBenefitDetailList []WmAppOrderSkuBenefitDetailList `json:"wmAppOrderSkuBenefitDetailList"` // 商家承担成本的商品优惠分摊明细,json格式数组。
|
||||
WmAppOrderSkuShippingDetailList []MedicalInsuranceFee `json:"wmAppOrderSkuShippingDetailList"` // 商家承担配送费活动分摊明细。
|
||||
ChargeFeeType int64 `json:"chargeFeeType"` // 用来标识退款是部分退还是退差价,billChargeType为26时,该值为1代表 退差价,0为部分退。billChargeType为其他值得情况,忽略该字段
|
||||
MedicalInsuranceFee string `json:"medicalInsuranceFee"` // 医保报销费用字段(单位分),只有医保报销的商家这个字段有值
|
||||
}
|
||||
|
||||
type WmAppOrderSkuBenefitDetailList struct {
|
||||
AppSpuCode string `json:"app_spu_code"` // (原app_food_code字段)APP方商品的id,即商家中台系统里商品的编码:(1) 同一门店内商品id不允许重复;(2)字段信息限定长度不超过128个字符。
|
||||
Name string `json:"name"` // 商品名称。
|
||||
SkuId string `json:"sku_id"` // 商品sku的规格编码,SKU码/货号。
|
||||
Count int `json:"count"` // 商品数量 注:当字段count=0时,此账单记录为商家发起的按重量退差价,但结算类型仍为“26-闪购品类订单部分退款”(billChargeType=26)。
|
||||
TotalOriginPrice float64 `json:"totalOriginPrice"` // 商品原价总价(含商品包装盒费),单位分。
|
||||
TotalActivityPrice float64 `json:"totalActivityPrice"` //商品优惠总金额,包括商家承担金额和美团承担金额,单位分。
|
||||
TotalReducePrice float64 `json:"totalReducePrice"` // 商品优惠总金额,包括商家承担金额和美团承担金额,单位分。
|
||||
WmAppOrderActDetails []wmAppOrderActDetails // 商品参与活动详情,json格式数组。
|
||||
|
||||
}
|
||||
|
||||
type wmAppOrderActDetails struct {
|
||||
actId int64 `json:"act_id"` // 商品参与活动的活动id
|
||||
MTType int `json:"type"` // 参与活动的活动类型,参考值:1-首单立减;2-满减优惠;4-套餐惠赠优惠;9-美团红包;11-提前下单减优惠;17-折扣商品;18-美团专送再减;20-第二份半价优惠;22-门店新客立减;27-指定商品满减;40-加价购;43-X元M件;46-超值换购;66-会员折扣商品;101-商家代金券优惠;117-商品优惠券;118-商品折扣券;900-首单红包优惠。
|
||||
PoiCharge float64 `json:"poiCharge"` // 本活动id及活动类型下商家承担的金额,单位分。
|
||||
}
|
||||
|
||||
type MedicalInsuranceFee struct {
|
||||
Name string `json:"name"` // 商品名称。
|
||||
SkuId string `json:"sku_id"` // 商品sku的规格编码,SKU码/货号。
|
||||
Count int `json:"count"` // 商品数量 注:当字段count=0时,此账单记录为商家发起的按重量退差价,但结算类型仍为“26-闪购品类订单部分退款”(billChargeType=26)。
|
||||
totalOriginPrice float64 `json:"totalOriginPrice"` // 商品原价总价(含商品包装盒费),单位分。
|
||||
totalPoiCharge float64 `json:"totalPoiCharge"` // 配送费优惠商家承担总金额,单位分。
|
||||
wmAppOrderShippingActDetailList []wmAppOrderShippingActDetailList `json:"wmAppOrderShippingActDetailList"` // sku商品参与的配送费活动详情。
|
||||
}
|
||||
|
||||
type wmAppOrderShippingActDetailList struct {
|
||||
MTType int `json:"type"` // 参与配送费活动的活动类型,参考值:9-美团红包,21-会员免配送费,25-立减配送费,30-满减配送费,36-新人减配送费,54-新客专享减配送费,59-新客专享减配送费,300-商家会员减配送费,302-预订单减配送费,304-减免运费券,101-商家代金券优惠,305-津贴优惠。
|
||||
PoiCharge float64 `json:"poiCharge"` // 商家承担金额,单位分。
|
||||
}
|
||||
26
platformapi/mtwmapi/bill_list_test.go
Normal file
26
platformapi/mtwmapi/bill_list_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package mtwmapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestBillList(t *testing.T) {
|
||||
now := time.Now()
|
||||
from := time.Date(now.Year(), now.Month(), now.Day()-5, 0, 0, 0, 0, time.Local)
|
||||
to := time.Date(now.Year(), now.Month(), now.Day()-5, 23, 59, 59, 59, time.Local)
|
||||
param := &Bill{
|
||||
AppPoiCode: "16967920",
|
||||
StartDate: from.Unix(),
|
||||
EndDate: to.Unix(),
|
||||
Offset: 0,
|
||||
Limit: 200,
|
||||
}
|
||||
|
||||
data, _ := api.GetStoreBillList(param)
|
||||
globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data.Data[0], false))
|
||||
// performanceServiceFee 订单配送费
|
||||
// userPayShippingAmount 用户支付配送费
|
||||
}
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
MsgTypeUserUrgeOrder = "userUrgeOrder"
|
||||
MsgTypePrivateNumberDowngrade = "numberDowngrade"
|
||||
MsgTypeOrderModified = "orderModified" // 这个不是订单调整,是订单信息(地址、联系人等)变化后推送的消息
|
||||
MsgTypeOrderRefund = "orderRefund" // 订单退款
|
||||
MsgTypeOrderRefund = "orderRefund" // 订单退款(全额)
|
||||
MsgTypeOrderPartialRefund = "orderPartialRefund" // /订单部分退款
|
||||
MsgTypeOrderFinishedPickup = "orderFinishedPickup"
|
||||
|
||||
|
||||
@@ -265,3 +265,16 @@ func TestGetClient(t *testing.T) {
|
||||
func TestMal(t *testing.T) {
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
@@ -245,11 +245,21 @@ func (a *API) AccessAPI3(cmd string, isGet bool, bizParams map[string]interface{
|
||||
// 不管有无错误,都尝试取得数据(因为有出错,但有有效数据返回的情况),比如ecommerce/order/getOrderIdByDaySeq
|
||||
retVal = jsonResult1
|
||||
if errObj, ok := jsonResult1["data"]; ok {
|
||||
errorInfo := errObj.(string)
|
||||
if errorInfo != "ok" {
|
||||
newErr := utils.NewErrorIntCode(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["code"])))
|
||||
return errLevel, newErr
|
||||
switch errObj.(type) {
|
||||
case string:
|
||||
errorInfo := errObj.(string)
|
||||
if errorInfo != "ok" {
|
||||
var newErr *utils.ErrorWithCode
|
||||
if cmd == "bill/list" {
|
||||
newErr = utils.NewErrorIntCode(jsonResult1["error"].(interface{}).(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error"].(interface{}).(map[string]interface{})["code"])))
|
||||
} else {
|
||||
newErr = utils.NewErrorIntCode(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["code"])))
|
||||
}
|
||||
return errLevel, newErr
|
||||
}
|
||||
case interface{}:
|
||||
}
|
||||
|
||||
}
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
})
|
||||
|
||||
@@ -23,10 +23,10 @@ func init() {
|
||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||
|
||||
// 果园
|
||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
// api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||
|
||||
//商超
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw
|
||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w
|
||||
cookieStr := `
|
||||
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||
`
|
||||
@@ -42,7 +42,7 @@ func TestAccessAPI(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetOAuthCode(t *testing.T) {
|
||||
result, err := api.GetOAuthCode("12422751")
|
||||
result, err := api.GetOAuthCode("17395411")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -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("17395411") //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)
|
||||
}
|
||||
|
||||
@@ -19,14 +19,19 @@ func TestOrderViewStatus(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestOrderGetOrderDetail(t *testing.T) {
|
||||
result, err := api.OrderGetOrderDetail(1100449970093397157, false)
|
||||
result, err := api.OrderGetOrderDetail(1100496043552579025, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
globals.SugarLogger.Debugf("====%s", utils.Format4Output(result["poi_receive_detail_yuan"], false))
|
||||
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) {
|
||||
|
||||
@@ -45,8 +45,9 @@ func TestPoiSave(t *testing.T) {
|
||||
poiParams := map[string]interface{}{}
|
||||
//utils.FilterMapNilMembers(utils.Struct2FlatMap(result[0]))
|
||||
//poiParams["address"] = "成都市温江区柳城学海路585号"
|
||||
poiParams["pic_url"] = "http://image.jxc4.com/image/5c9fc4fffb4d5ff1aecf85a2d2543e00.jpg"
|
||||
err := api.PoiSave("17218722", poiParams)
|
||||
//poiParams["pic_url"] = "http://image.jxc4.com/image/5c9fc4fffb4d5ff1aecf85a2d2543e00.jpg"
|
||||
poiParams["name"] = "京西菜市(礼嘉桥村市场店)"
|
||||
err := api.PoiSave("17395411", poiParams)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ const ( // {"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId
|
||||
MtwmSkuAttr200000592 = `[{"attrId":1200000088,"attrName":"品牌","valueList":[{"valueId":1000001,"value":"其他品牌"}]}]`
|
||||
//200002704
|
||||
MtwmSkuAttr200002731 = `[{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]`
|
||||
MtwmSkuAttr200002716 = `[{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300003951,"value":"非特产品种"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]`
|
||||
MtwmSkuAttr200002716 = `[{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300016304,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]`
|
||||
//200002667,200002713
|
||||
MtwmSkuAttr200002670 = `[{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300003951,"value":"非特产品种"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]`
|
||||
MtwmSkuAttr200002670 = `[{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300016304,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]`
|
||||
//MtwmSkuAttr200002680 = `[{"attrId":1200000289,"attrName":"品规","valueList":[{"valueId":1300004255,"value":"未区分品规"}]},{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]`
|
||||
MtwmSkuAttr200002680 = `[{"attrId":1200004607,"attrName":"水果形态","valueList":[{"valueId":1300017364,"value":"新鲜整果"}]},{"attrId":1200004608,"attrName":"单果重量","valueList":[{"valueId":1300017449,"value":"约4.5kg~5kg"}]},{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]`
|
||||
)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package product_qualificationConfig_response
|
||||
|
||||
import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core"
|
||||
|
||||
type ProductQualificationConfigResponse struct {
|
||||
doudian_sdk.BaseDoudianOpApiResponse
|
||||
Data *ProductQualificationConfigData `json:"data"`
|
||||
|
||||
@@ -95,7 +95,7 @@ func (a *API) RefreshToken() (*doudian_sdk.CreateTokenData, error) {
|
||||
return nil, err
|
||||
}
|
||||
if createToken.Code != RequestSuccessCode {
|
||||
return nil, errors.New(createToken.SubMsg)
|
||||
return nil, errors.New(createToken.SubMsg + ":" + createToken.LogId)
|
||||
}
|
||||
a.accessToken = createToken.Data.AccessToken
|
||||
a.refreshToken = createToken.Data.RefreshToken
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestApi(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestQueryOrderDetail(t *testing.T) {
|
||||
data, err := a.GetTiktokOrderDetail("5042953882665211095")
|
||||
data, err := a.GetTiktokOrderDetail("6917547162766021688")
|
||||
globals.SugarLogger.Debugf("=====%s", utils.Format4Output(data, false))
|
||||
globals.SugarLogger.Debugf("=====%s", err)
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func (a *APIExpress) CreateToken() (*token_create_response.TokenCreateData, erro
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
|
||||
a.accessToken = response.Data.AccessToken
|
||||
@@ -98,7 +98,7 @@ func (a *APIExpress) RefreshToken() (*doudian_sdk.CreateTokenData, error) {
|
||||
return nil, err
|
||||
}
|
||||
if createToken.Code != RequestSuccessCode {
|
||||
return nil, errors.New(createToken.SubMsg)
|
||||
return nil, errors.New(createToken.SubMsg + ":" + createToken.LogId)
|
||||
}
|
||||
a.accessToken = createToken.Data.AccessToken
|
||||
a.refreshToken = createToken.Data.RefreshToken
|
||||
@@ -160,7 +160,7 @@ func (a *APIExpress) OrderStatusAndPsInfo(param map[string]interface{}) error {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func (a *API) GetTiktokOrderDetail(orderId string) (*order_orderDetail_response.
|
||||
return nil, err
|
||||
}
|
||||
if orderDetail.Code != RequestSuccessCode {
|
||||
return nil, errors.New(orderDetail.SubMsg)
|
||||
return nil, errors.New(orderDetail.SubMsg + ":" + orderDetail.LogId)
|
||||
}
|
||||
|
||||
return orderDetail.Data.ShopOrderDetail, nil
|
||||
@@ -54,7 +54,7 @@ func (a *API) QueryAfsOrderDetail(afterSaleId string, needOperationRecord bool)
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -72,7 +72,7 @@ func (a *API) ApplyMarketAfterSale(skuOrderId, count int64, afterSaleReason int3
|
||||
return "", err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return "", errors.New(result.SubMsg)
|
||||
return "", errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return result.Data.AfterSaleId, nil
|
||||
}
|
||||
@@ -155,7 +155,7 @@ func (a *API) AfterSaleOperate(refundType int32, refundId, remark string, storeI
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -175,7 +175,7 @@ func (a *API) GetRefundAddressId(storeID int64) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
return 0, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
if len(result.Data.AddressList) < 1 {
|
||||
return 0, errors.New("门店详细地址获取错误")
|
||||
@@ -196,7 +196,7 @@ func (a *API) QueryAllReason(afterSaleId int64) ([]afterSale_rejectReasonCodeLis
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return result.Data.Items, nil
|
||||
}
|
||||
@@ -218,7 +218,7 @@ func (a *API) GetStoreOrderList(queryData time.Time, storeId int64) ([]string, e
|
||||
return nil, err
|
||||
}
|
||||
if orderDetailList.Code != RequestSuccessCode {
|
||||
return nil, errors.New(orderDetailList.Msg)
|
||||
return nil, errors.New(orderDetailList.Msg + ":" + orderDetailList.LogId)
|
||||
}
|
||||
|
||||
orderList := make([]string, 0, 0)
|
||||
@@ -251,7 +251,7 @@ func (a *API) GetStoreOrderList(queryData time.Time, storeId int64) ([]string, e
|
||||
return nil, err
|
||||
}
|
||||
if orderDetailList.Code != RequestSuccessCode {
|
||||
return nil, errors.New(orderDetailList.Msg)
|
||||
return nil, errors.New(orderDetailList.Msg + ":" + orderDetailList.LogId)
|
||||
}
|
||||
for _, v := range orderDetailList.Data.ShopOrderList {
|
||||
if v.ShopId == storeId {
|
||||
@@ -278,7 +278,7 @@ func (a *API) ReturnGoodsToWareHouseSuccess(afsOrderId string) error {
|
||||
return err // 202210141114300102101071350D6F3847
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -298,9 +298,6 @@ func (a *API) ConfirmReceivedReturnGoods(afsOrderId int64, agree bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// CancelSendGoodsSuccess 商家在未发货仅退款途中发送取消发货状态
|
||||
func (a *API) CancelSendGoodsSuccess() {}
|
||||
|
||||
// OrderDelivering 订单发货
|
||||
// 暂时只支持整单出库,即接口调用时入参只能传父订单号。
|
||||
// Tips:部分发货状态下的父订单,调此接口发货,会报错:该订单当前为“部分发货”状态,无法调用此接口
|
||||
@@ -317,7 +314,7 @@ func (a *API) OrderDelivering(param *order_logisticsAdd_request.OrderLogisticsAd
|
||||
return nil
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -592,11 +589,11 @@ func (a *API) GetCallbackOrderId(msgId string, data interface{}) (string, int64,
|
||||
}
|
||||
return utils.Int64ToStr(create.PId), int64(create.ShopId), Err2CallbackResponse(nil, "")
|
||||
case CallbackReturnRefundAgreedMsgTagId: // 同意退款消息
|
||||
create := AppointmentChangeData{}
|
||||
create := BusinessRefundSuccessData{}
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
return "", 0, CallbackResponseErr(false)
|
||||
}
|
||||
return create.PId, create.ShopId, Err2CallbackResponse(nil, "")
|
||||
return utils.Int64ToStr(create.PId), create.ShopId, Err2CallbackResponse(nil, "")
|
||||
case CallbackRefundClosedMsgTagId: // 当买家取消申请或系统超时机制导致退款取消时,会推送此消息
|
||||
create := UserCancelRefundOrderData{}
|
||||
if err := utils.Map2StructByJson(data, &create, false); err != nil {
|
||||
|
||||
@@ -411,16 +411,16 @@ type BusinessRefundSuccessCallback struct {
|
||||
|
||||
type BusinessRefundSuccessData struct {
|
||||
AftersaleId int64 `json:"aftersale_id"`
|
||||
AftersaleStatus int `json:"aftersale_status"`
|
||||
AftersaleType int `json:"aftersale_type"`
|
||||
AftersaleStatus int64 `json:"aftersale_status"`
|
||||
AftersaleType int64 `json:"aftersale_type"`
|
||||
PId int64 `json:"p_id"`
|
||||
ReasonCode int `json:"reason_code"`
|
||||
RefundAmount int `json:"refund_amount"`
|
||||
RefundPostAmount int `json:"refund_post_amount"`
|
||||
RefundVoucherNum int `json:"refund_voucher_num"`
|
||||
ReasonCode int64 `json:"reason_code"`
|
||||
RefundAmount int64 `json:"refund_amount"`
|
||||
RefundPostAmount int64 `json:"refund_post_amount"`
|
||||
RefundVoucherNum int64 `json:"refund_voucher_num"`
|
||||
SId int64 `json:"s_id"`
|
||||
ShopId int `json:"shop_id"`
|
||||
SuccessTime int `json:"success_time"`
|
||||
ShopId int64 `json:"shop_id"`
|
||||
SuccessTime int64 `json:"success_time"`
|
||||
UpdateTime time.Time `json:"update_time"`
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ func (a *API) GetSettleBillDetailV3(param *order_getSettleBillDetailV3_request.O
|
||||
return 0, "", err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, "", errors.New(result.SubMsg)
|
||||
return 0, "", errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
if len(result.Data.Data) == 0 {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package tiktok_api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
brand_list_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/brand_list/request"
|
||||
order_batchDecrypt_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchDecrypt/request"
|
||||
order_batchSensitive_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchSensitive/request"
|
||||
product_GetRecommendCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_GetRecommendCategory/request"
|
||||
product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request"
|
||||
@@ -21,6 +21,8 @@ import (
|
||||
product_getProductUpdateRule_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_getProductUpdateRule/request"
|
||||
product_listV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/request"
|
||||
product_listV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/response"
|
||||
product_qualificationConfig_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/request"
|
||||
product_qualificationConfig_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/response"
|
||||
product_setOffline_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_setOffline/request"
|
||||
shop_getShopCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getShopCategory/request"
|
||||
sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request"
|
||||
@@ -30,7 +32,10 @@ import (
|
||||
superm_product_batchRedistributeStoreProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_batchRedistributeStoreProduct/request"
|
||||
superm_product_createSubProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_createSubProduct/request"
|
||||
superm_product_launchProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_launchProduct/request"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -48,7 +53,7 @@ func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) err
|
||||
return err
|
||||
}
|
||||
if resp.Code != RequestSuccessCode {
|
||||
return errors.New(resp.Msg)
|
||||
return errors.New(resp.SubMsg + ":" + resp.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -69,7 +74,7 @@ func (a *API) GetShopCategory(cid int64) ([]*RetailCategoryInfo, error) {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
categoryAll := make([]*RetailCategoryInfo, 0, 0)
|
||||
@@ -107,13 +112,52 @@ func (a *API) GetCatePropertyV2(categoryLeftId int64) (*product_getCatePropertyV
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// CreateStoreCommodity (新增总部商品)
|
||||
func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2Param) (*product_addV2_response.ProductAddV2Data, error) {
|
||||
qualityList := make([]product_addV2_request.QualityListItem, 0, 0)
|
||||
switch a.accessTokenObj.ShopId {
|
||||
case TiktokFloderKeyVegetableKey: // 京西速食
|
||||
qualityList = append(qualityList, product_addV2_request.QualityListItem{
|
||||
QualityKey: QualificationsSuShiPackageId,
|
||||
QualityName: QualificationsSuShiPackageName,
|
||||
QualityAttachments: []product_addV2_request.QualityAttachmentsItem{
|
||||
product_addV2_request.QualityAttachmentsItem{
|
||||
MediaType: 1,
|
||||
Url: QualificationsPackageImg,
|
||||
},
|
||||
},
|
||||
})
|
||||
case TiktokFloderKeyShoppingKey: // 京西超市
|
||||
qualityList = append(qualityList, product_addV2_request.QualityListItem{
|
||||
QualityKey: QualificationsShopPackageId,
|
||||
QualityName: QualificationsShopPackageName,
|
||||
QualityAttachments: []product_addV2_request.QualityAttachmentsItem{
|
||||
product_addV2_request.QualityAttachmentsItem{
|
||||
MediaType: 1,
|
||||
Url: QualificationsShopPackageImg,
|
||||
},
|
||||
},
|
||||
})
|
||||
case TiktokFloderKeyBeautifulKey: // 美好菜市
|
||||
qualityList = append(qualityList, product_addV2_request.QualityListItem{
|
||||
QualityKey: QualificationsBeautifulPackageId,
|
||||
QualityName: QualificationsBeautifulPackageName,
|
||||
QualityAttachments: []product_addV2_request.QualityAttachmentsItem{
|
||||
product_addV2_request.QualityAttachmentsItem{
|
||||
MediaType: 1,
|
||||
Url: QualificationsBeautifulPackageImg,
|
||||
},
|
||||
},
|
||||
})
|
||||
default:
|
||||
return nil, errors.New("创建商品是,资质获取异常")
|
||||
}
|
||||
skuParam.QualityList = qualityList
|
||||
request := product_addV2_request.New()
|
||||
request.Param = skuParam
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
@@ -121,11 +165,37 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return result.Data, nil
|
||||
}
|
||||
|
||||
func (a *API) QualityList(categoryId int64) ([]*product_qualificationConfig_response.ConfigListItem, error) {
|
||||
if categoryId <= 0 {
|
||||
return nil, errors.New("categoryId 不能为0")
|
||||
}
|
||||
|
||||
request := product_qualificationConfig_request.New()
|
||||
request.Param.CategoryId = categoryId
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
configListRequired := make([]*product_qualificationConfig_response.ConfigListItem, 0)
|
||||
for _, v := range result.Data.ConfigList {
|
||||
if v.IsRequired == false {
|
||||
continue
|
||||
}
|
||||
configListRequired = append(configListRequired, &v)
|
||||
}
|
||||
globals.SugarLogger.Debugf("configListRequired=== :%s", utils.Format4Output(configListRequired, false))
|
||||
return configListRequired, nil
|
||||
}
|
||||
|
||||
// SyncStockBatch 库存批量同步
|
||||
func (a *API) SyncStockBatch(param *sku_syncStockBatch_request.SkuSyncStockBatchParam) error {
|
||||
request := sku_syncStockBatch_request.New()
|
||||
@@ -135,7 +205,7 @@ func (a *API) SyncStockBatch(param *sku_syncStockBatch_request.SkuSyncStockBatch
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -150,7 +220,7 @@ func (a *API) EditStoreCommodity(sku *product_editV2_request.ProductEditV2Param)
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -165,16 +235,13 @@ func (a *API) EditStoreCommodityCommit(sku *product_editV2_commit_request.Produc
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// DeleteStoreCommodity 删除商品
|
||||
func (a *API) DeleteStoreCommodity(productId int64) error {
|
||||
globals.SugarLogger.Debugf("----打印看看是否是定时任务删除:%d", productId)
|
||||
return nil
|
||||
|
||||
request := product_del_request.New()
|
||||
param := request.GetParams()
|
||||
param.ProductId = productId
|
||||
@@ -185,7 +252,7 @@ func (a *API) DeleteStoreCommodity(productId int64) error {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -202,7 +269,7 @@ func (a *API) ProductSetOffline(productId int64) error {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -224,7 +291,7 @@ func (a *API) GetSkuDetail(productId, outProductId string) (*product_detail_resp
|
||||
return nil, nil
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
if result.Data.Status == 2 {
|
||||
return nil, nil
|
||||
@@ -250,7 +317,7 @@ func (a *API) GetSkuDetailLocalID(productId, outProductId string) (*product_deta
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
if result.Data.Status == 2 {
|
||||
return nil, nil
|
||||
@@ -269,7 +336,7 @@ func (a *API) GetSkuDetailList(param *product_listV2_request.ProductListV2Param)
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
return result.Data, nil
|
||||
@@ -285,7 +352,7 @@ func (a *API) EditPrice(skuPrice *sku_editPrice_request.SkuEditPriceParam) error
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -328,51 +395,103 @@ func (a *API) GetSkuBrand(categoryId int64, brandName string) (int64, error) {
|
||||
return BrandNameMap[brandNameLen], nil
|
||||
}
|
||||
|
||||
// OrderUserInfoDecrypt 用户信息解密
|
||||
type YunDecrypt struct {
|
||||
Code string `json:"code"`
|
||||
Data string `json:"data"`
|
||||
Err string `json:"err"`
|
||||
}
|
||||
|
||||
// OrderUserInfoDecrypt 用户信息解密(此接口转入云鼎服务器,将不再直接通信)
|
||||
func (a *API) OrderUserInfoDecrypt(orderId, name, tel, address string) (string, string, string, error) {
|
||||
request := order_batchDecrypt_request.New()
|
||||
|
||||
cipherInfos := make([]order_batchDecrypt_request.CipherInfosItem, 0, 0)
|
||||
for i := 1; i <= 3; i++ {
|
||||
cipher := order_batchDecrypt_request.CipherInfosItem{}
|
||||
cipher.AuthId = orderId
|
||||
switch i {
|
||||
case 1: // 姓名
|
||||
cipher.CipherText = name
|
||||
cipherInfos = append(cipherInfos, cipher)
|
||||
case 2: // 手机号
|
||||
cipher.CipherText = tel
|
||||
cipherInfos = append(cipherInfos, cipher)
|
||||
case 3: // 地址
|
||||
cipher.CipherText = address
|
||||
cipherInfos = append(cipherInfos, cipher)
|
||||
}
|
||||
}
|
||||
request.Param.CipherInfos = cipherInfos
|
||||
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
url := "http://ddy.jxc4.com/tt/decrypt"
|
||||
accessToken, err := json.Marshal(a.accessTokenObj.CreateTokenData)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return "", "", "", errors.New(result.SubCode)
|
||||
|
||||
param := make(map[string]string, 5)
|
||||
param["token"] = string(accessToken)
|
||||
param["encrypt_post_tel"] = tel
|
||||
param["encrypt_post_receiver"] = address
|
||||
param["encrypt_post_name"] = name
|
||||
param["order_id"] = orderId
|
||||
param["app_key"] = a.appKey
|
||||
param["app_secret"] = a.appSecret
|
||||
|
||||
data, err := json.Marshal(param)
|
||||
if err != nil {
|
||||
return "", "", "", nil
|
||||
}
|
||||
payload := strings.NewReader(string(data))
|
||||
req, _ := http.NewRequest("POST", url, payload)
|
||||
req.Header.Add("content-type", "application/json")
|
||||
res, err := http.DefaultClient.Do(req)
|
||||
if err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
body, _ := ioutil.ReadAll(res.Body)
|
||||
|
||||
var result *YunDecrypt
|
||||
if err := json.Unmarshal(body, &result); err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
if result.Code != "200" {
|
||||
return "", "", "", errors.New(result.Err)
|
||||
}
|
||||
|
||||
var (
|
||||
userName, userTel, userAddress = "", "", ""
|
||||
)
|
||||
for _, v := range result.Data.DecryptInfos {
|
||||
if v.CipherText != "" && v.CipherText == name {
|
||||
userName = v.DecryptText
|
||||
}
|
||||
if v.CipherText != "" && v.CipherText == tel {
|
||||
userTel = v.DecryptText
|
||||
}
|
||||
if v.CipherText != "" && v.CipherText == address {
|
||||
userAddress = v.DecryptText
|
||||
if len(result.Data) != 0 {
|
||||
var decryData map[string]string
|
||||
if err := json.Unmarshal([]byte(result.Data), &decryData); err != nil {
|
||||
return "", "", "", err
|
||||
}
|
||||
return decryData["name"], decryData["tel"], decryData["address"], nil
|
||||
}
|
||||
return userName, userTel, userAddress, err
|
||||
return "", "", "", errors.New("返回值为空")
|
||||
//request := order_batchDecrypt_request.New()
|
||||
//
|
||||
//cipherInfos := make([]order_batchDecrypt_request.CipherInfosItem, 0, 0)
|
||||
//for i := 1; i <= 3; i++ {
|
||||
// cipher := order_batchDecrypt_request.CipherInfosItem{}
|
||||
// cipher.AuthId = orderId
|
||||
// switch i {
|
||||
// case 1: // 姓名
|
||||
// cipher.CipherText = name
|
||||
// cipherInfos = append(cipherInfos, cipher)
|
||||
// case 2: // 手机号
|
||||
// cipher.CipherText = tel
|
||||
// cipherInfos = append(cipherInfos, cipher)
|
||||
// case 3: // 地址
|
||||
// cipher.CipherText = address
|
||||
// cipherInfos = append(cipherInfos, cipher)
|
||||
// }
|
||||
//}
|
||||
//request.Param.CipherInfos = cipherInfos
|
||||
//
|
||||
//result, err := request.Execute(a.accessTokenObj)
|
||||
//globals.SugarLogger.Debugf("OrderUserInfoDecrypt======:%s", utils.Format4Output(result, false))
|
||||
//if err != nil {
|
||||
// return "", "", "", err
|
||||
//}
|
||||
//if result.Code != RequestSuccessCode {
|
||||
// return "", "", "", errors.New(result.SubCode)
|
||||
//}
|
||||
//
|
||||
//var (
|
||||
// userName, userTel, userAddress = "", "", ""
|
||||
//)
|
||||
//for _, v := range result.Data.DecryptInfos {
|
||||
// if v.CipherText != "" && v.CipherText == name {
|
||||
// userName = v.DecryptText
|
||||
// }
|
||||
// if v.CipherText != "" && v.CipherText == tel {
|
||||
// userTel = v.DecryptText
|
||||
// }
|
||||
// if v.CipherText != "" && v.CipherText == address {
|
||||
// userAddress = v.DecryptText
|
||||
// }
|
||||
//}
|
||||
//return userName, userTel, userAddress, err
|
||||
}
|
||||
|
||||
// OrderUserInfoSensitive 用户信息脱敏
|
||||
@@ -445,7 +564,7 @@ func (a *API) GetProductAuditList(page, pageSize, status int64) ([]product_audit
|
||||
return nil, 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, 0, errors.New(result.SubMsg)
|
||||
return nil, 0, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
return result.Data.Records, result.Data.Total, nil
|
||||
@@ -469,7 +588,7 @@ func (a *API) GetRecommendCategory(picParams []string) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
return 0, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
if len(result.Data.CategoryDetails) == 0 {
|
||||
@@ -522,7 +641,7 @@ func (a *API) CreateSubProduct(mainProductId int64, storeId int64) (int64, error
|
||||
}
|
||||
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
return 0, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
return result.Data.SubProductId, nil
|
||||
@@ -538,7 +657,7 @@ func (a *API) BatchRedistributeStoreProduct(param *superm_product_batchRedistrib
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, err
|
||||
return 0, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
return result.Data.RootTaskId, nil
|
||||
@@ -554,7 +673,7 @@ func (a *API) BatchApplyStoreProductPrice(mainProductId int64) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
return 0, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
|
||||
return result.Data.RootTaskId, nil
|
||||
@@ -569,7 +688,7 @@ func (a *API) LaunchProduct(productId int64) error {
|
||||
return err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return errors.New(result.SubMsg)
|
||||
return errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -68,3 +68,7 @@ func TestGetSkuBrand(t *testing.T) {
|
||||
globals.SugarLogger.Debugf("data ========= %v", data)
|
||||
globals.SugarLogger.Debugf("data ========= %s", err)
|
||||
}
|
||||
|
||||
func TestQualityList(t *testing.T) {
|
||||
a.QualityList(33079)
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ func TestGetSkuDetailLocalId(t *testing.T) {
|
||||
|
||||
func TestUpdateSkuStore(t *testing.T) {
|
||||
err := a.UpdateSkuStock(&sku_syncStock_request.SkuSyncStockParam{
|
||||
ProductId: 3605142143867471418,
|
||||
OutSkuId: 6045168,
|
||||
StockNum: 2,
|
||||
ProductId: 3602878545761816498,
|
||||
OutSkuId: 25250,
|
||||
StockNum: 0,
|
||||
Incremental: false,
|
||||
})
|
||||
fmt.Println(err)
|
||||
@@ -120,13 +120,15 @@ func TestProductSetOffline(t *testing.T) {
|
||||
|
||||
// 解密购买用户电话,名字,地址
|
||||
func TestBatchDecrypt(t *testing.T) {
|
||||
token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}`
|
||||
|
||||
a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token)
|
||||
encrypt_post_tel := `##3aVwfhe5fJHdlO0UijiOA3GbeZYsIZppi+Y9bpYZ9gRBshpl555DP9B1FFp8R0fbyiTaeU9LAck8nkzKNMp5frZUO0w2ba8lsm+1zwYZrBkFlQ==*CgkIARCtHCABKAESPgo8d1IWxRMUZ/3UM2wAbb6m8jXa0z/h/RDf4NnIrUK3Zfiqg+/rrvoo/3DX9DQfmAW/5DkNVk2beqYZx0tYGgA=#1##`
|
||||
encrypt_post_receiver := `##K3dJts44TlQGmLNQAHud1Iivzu6rWDeFx8EwQYK35oMXVtlLGgN+ZmQDIa7K6rVzXYReq3dgKz8Vi4VGVR8kR45BpHZdaVJUx2tCwM0=*CgkIARCtHCABKAESPgo8X7FrpSxbV2yGA29uxewKEdHW+Rp1tiqWGxRZgwirlJX2uOILTwCWTN6Q1sT3JHeTjXgXslRTEqqWcdd/GgA=#1##`
|
||||
encrypt_post_tel := "##mjApaTO5LNGFDnAU2UmRwu1zhlDQH2+NjIc9kTlQzUYpf1XXrxyxUzd1nWdTPb9H3iFNAdFG66zReSdhf6qUtNVBwNEn5RnIM8wQapxFjh4v+g==*CgkIARCtHCABKAESPgo81dqD65kMclp62fAJBLUpNOP22AKtaL8/7CHDPtDCS8wVtCp/TWhRNLsuFrq/Pmhhz+fe3GDtG8R/L0O0GgA=#1##"
|
||||
encrypt_post_receiver := "##Cg8e7Ks78U0rSX7AO6NxoD9pPtISczJdulakYdCJDNqXLsFMfhG/0mz7CoxJJyY7zRvx1dkFKahgRk0NCsAxApns7NaaGDu9tyEXloBu9Sc=*CgkIARCtHCABKAESPgo8ja2mXE+INEhReF2W0+deMN0qb/ZoPtaxS98YbR4a1smRO4WPj+jSiYsBv00+DxiXfJTW3DdxusF6TVS3GgA=#1##"
|
||||
encrypt_post_name := ``
|
||||
a.OrderUserInfoDecrypt("4988546918828606694", encrypt_post_name, encrypt_post_tel, encrypt_post_receiver)
|
||||
name, tel, address, err := a.OrderUserInfoDecrypt("6917547162766021688", encrypt_post_name, encrypt_post_tel, encrypt_post_receiver)
|
||||
fmt.Println(name)
|
||||
fmt.Println(tel)
|
||||
fmt.Println(address)
|
||||
fmt.Println(err)
|
||||
}
|
||||
|
||||
//// 脱敏购买用户电话,名字,地址
|
||||
|
||||
@@ -10,10 +10,25 @@ const (
|
||||
TiktokFolder1 = "71847620611255503751570" // 文件夹(京西菜市)
|
||||
TiktokFolder2 = "71482723234545339291960"
|
||||
TiktokFolder3 = "71762017122139835211688" // (方案二测试文件夹)
|
||||
TiktokFolder4 = "72213403043425651541645" // (美好菜市)
|
||||
TiktokShoppingFolder = "71802347591117703711619" // (方案二测试文件夹)
|
||||
TiktokFloderKeyVegetableKey = 57939570 // (菜市的文件夹id)
|
||||
TiktokFloderKeyVegetableKey = 57939570 // (菜市的文件夹id)速食
|
||||
TiktokFloderKeyShoppingKey = 68023619 // (商超账号的文件夹id)
|
||||
TiktokFloderKeyTestKey = 63141688 // (测试账号)
|
||||
TiktokFloderKeyBeautifulKey = 68032645 // (美好菜市)
|
||||
)
|
||||
|
||||
const (
|
||||
QualificationsSuShiPackageId = "7129700904345125135" // 京西速食包装标签id
|
||||
QualificationsSuShiPackageName = "包装标签图_20220809_104106" // 京西速食包装标签名称
|
||||
QualificationsPackageImg = "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/VqGYBUaL_m_e40ed809c2231a95197db39c86fe70e6_sx_463300_www1040-1034" // 速食包装标签图
|
||||
QualificationsShopPackageId = "7182777418275832098" // 京西超市包装标签id
|
||||
QualificationsShopPackageName = "包装标签图_20220809_104107" // 京西超市包装标签名称
|
||||
QualificationsShopPackageImg = "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/TGUZigMc_m_e40ed809c2231a95197db39c86fe70e6_sx_463300_www1040-1034" // 京西超市包装标签名称
|
||||
QualificationsBeautifulPackageId = "7221409845910470964" // 美好菜市包装标签id
|
||||
QualificationsBeautifulPackageName = "包装标签图_20220809_104106" // 美好菜市包装标签名称
|
||||
QualificationsBeautifulPackageImg = "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/yneNVdDN_m_e40ed809c2231a95197db39c86fe70e6_sx_463300_www1040-1034" // 京西超市包装标签名称
|
||||
|
||||
)
|
||||
|
||||
// 商品减库存类型
|
||||
|
||||
@@ -28,7 +28,7 @@ func (a *API) CreateFolder(fileName string) (*material_createFolder_response.Mat
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
@@ -55,6 +55,8 @@ func (a *API) BatchUploadImages(imgs []Imgs) (map[string]material_batchUploadIma
|
||||
img.FolderId = TiktokShoppingFolder
|
||||
case TiktokFloderKeyVegetableKey:
|
||||
img.FolderId = TiktokFolder1
|
||||
case TiktokFloderKeyBeautifulKey:
|
||||
img.FolderId = TiktokFolder4
|
||||
}
|
||||
param = append(param, img)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ func init() {
|
||||
}
|
||||
|
||||
func TestCreateFolad(t *testing.T) {
|
||||
data, err := a.CreateFolder("京西菜市图片文件库2")
|
||||
data, err := a.CreateFolder("美好菜市图片文件")
|
||||
fmt.Println("err=====", err)
|
||||
fmt.Println("LogId====", data.LogId) //2022092811422001020812109607601B77
|
||||
fmt.Println("data====", data.Data.Name) // jxcs_folder
|
||||
|
||||
@@ -72,7 +72,7 @@ func (a *API) GetStoreDetail(param *shop_getStoreDetail_request.ShopGetStoreDeta
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -87,7 +87,7 @@ func (a *API) BatchCreateStore(param *shop_batchCreateStore_request.ShopBatchCre
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
//return nil, errors.New(response.Data.ResultList[0].Msg)
|
||||
return nil, errors.New(response.Msg)
|
||||
return nil, errors.New(response.Msg + ":" + response.LogId)
|
||||
}
|
||||
//if response.Data.ResultList[0].Store.StoreId == 0 {
|
||||
// return nil, errors.New(response.Msg + "," + response.SubMsg)
|
||||
@@ -104,7 +104,7 @@ func (a *API) EditStore(param *shop_editStore_request.ShopEditStoreParam) error
|
||||
return err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return errors.New(response.SubMsg)
|
||||
return errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -118,7 +118,7 @@ func (a *API) StoreSuspend(param *shop_storeSuspend_request.ShopStoreSuspendPara
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -131,7 +131,7 @@ func (a *API) StoreSuspend2(storeID int64) (*shop_storeSuspend_response.ShopStor
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func (a *API) UnsuspendStore(param *shop_unsuspendStore_request.ShopUnsuspendSto
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -157,7 +157,7 @@ func (a *API) UnsuspendStore2(storeID int64) (*shop_unsuspendStore_response.Shop
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -176,7 +176,7 @@ func (a *API) GetStoreList(param *shop_getStoreList_request.ShopGetStoreListPara
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
//测试用
|
||||
resp := map[int64]string{}
|
||||
@@ -197,7 +197,7 @@ func (a *API) GetStoreList2(param *shop_getStoreList_request.ShopGetStoreListPar
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
|
||||
return response, err
|
||||
@@ -212,7 +212,7 @@ func (a *API) CreateTradeLimitTemplate(param *trade_createTradeLimitTemplate_req
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -226,7 +226,7 @@ func (a *API) UpdateTradeLimitTemplate(param *trade_UpdateTradeLimitTemplate_req
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -240,7 +240,7 @@ func (a *API) BindStoreSaleLimit(param *shop_bindStoreSaleLimit_request.ShopBind
|
||||
return err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return errors.New(response.SubMsg)
|
||||
return errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -254,7 +254,7 @@ func (a *API) StoreQuerySaleLimitTemp(storeId int64) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
return 0, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
if result.Data == nil || len(result.Data.StoreSaleLimits) == 0 {
|
||||
return 0, errors.New("未绑定限售模板,请先绑定")
|
||||
@@ -271,7 +271,7 @@ func (a *API) GetSaleLimitDetail(saleLimitId *[]int64) (*trade_batchGetTradeLimi
|
||||
return nil, err
|
||||
}
|
||||
if result.Code != RequestSuccessCode {
|
||||
return nil, errors.New(result.SubMsg)
|
||||
return nil, errors.New(result.SubMsg + ":" + result.LogId)
|
||||
}
|
||||
if result.Data == nil || len(result.Data.TradeLimitTemplateList) == 0 {
|
||||
return nil, errors.New("未查找到限售模板详情")
|
||||
|
||||
@@ -30,7 +30,7 @@ func (a *API) GetDispatcherInfo(storeID int64, shopOrderID string, dispatcherFee
|
||||
return 0, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return 0, errors.New(response.SubMsg)
|
||||
return 0, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data.DispatcherFee, nil
|
||||
}
|
||||
@@ -48,7 +48,7 @@ func (a *API) ShopOrderDispatcher(storeID int64, shopOrderID string, dispatcherT
|
||||
return err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return errors.New(response.SubMsg)
|
||||
return errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -62,7 +62,7 @@ func (a *API) SetStoreAutoCallRider(params *superm_setStoreAutoCallRider_request
|
||||
return err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return errors.New(response.SubMsg)
|
||||
return errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -78,7 +78,7 @@ func (a *API) GetStoreAutoCallRiderInfo(storeID int64) (*superm_getStoreAutoCall
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data.AutoCallInfo, nil
|
||||
}
|
||||
@@ -94,7 +94,7 @@ func (a *API) CreateVirtualMobile(shopOrderID int64) (*superm_createVirtualMobil
|
||||
return nil, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data, nil
|
||||
}
|
||||
@@ -111,7 +111,7 @@ func (a *API) GetPlatformPickUpEstimatedCharge(afterSaleID int64, inquiryType in
|
||||
return 0, err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return 0, errors.New(response.SubMsg)
|
||||
return 0, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data.PlatformPickupEstimatedCharge, err
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func (a *API) ApplyPlatformPickUp(afterSaleID int64) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return "", errors.New(response.SubMsg)
|
||||
return "", errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data.LogisticsID, err
|
||||
}
|
||||
@@ -161,7 +161,7 @@ func (a *API) GetShipmentInfo(shopOrderID, afterSaleID, shipmentType int64) (*su
|
||||
}
|
||||
|
||||
if response.Code != RequestSuccessCode {
|
||||
return nil, errors.New(response.SubMsg)
|
||||
return nil, errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return response.Data.ShipmentInfo, err
|
||||
}
|
||||
@@ -177,7 +177,7 @@ func (a *API) CancelPlatformPickUp(afterSaleID int64) error {
|
||||
return err
|
||||
}
|
||||
if response.Code != RequestSuccessCode {
|
||||
return errors.New(response.SubMsg)
|
||||
return errors.New(response.SubMsg + ":" + response.LogId)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user