1
This commit is contained in:
@@ -3,6 +3,7 @@ package dadaapi
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -60,6 +61,16 @@ func TestComplaintRider(t *testing.T) {
|
|||||||
err := dadaapi.ComplaintRider("5000952191610480635", 69)
|
err := dadaapi.ComplaintRider("5000952191610480635", 69)
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
func TestComplaintList(t *testing.T) {
|
||||||
|
dadaapi.ComplaintList()
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test222222(t *testing.T) {
|
||||||
|
a := 57
|
||||||
|
fmt.Println(a&(model.SyncFlagNewMask|model.SyncFlagStoreName) != 0)
|
||||||
|
fmt.Println(a&2 != 0)
|
||||||
|
fmt.Println(a&4 != 0)
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//func TestTest(t *testing.T) {
|
//func TestTest(t *testing.T) {
|
||||||
|
|||||||
@@ -200,11 +200,17 @@ func (a *API) GetComplaintReasons() (complaintReasonList []*ComplaintReason, err
|
|||||||
//投诉骑手
|
//投诉骑手
|
||||||
func (a *API) ComplaintRider(orderID string, resonID int) (err error) {
|
func (a *API) ComplaintRider(orderID string, resonID int) (err error) {
|
||||||
mapData := utils.Params2Map("order_id", orderID, "reason_id", resonID)
|
mapData := utils.Params2Map("order_id", orderID, "reason_id", resonID)
|
||||||
data, err := a.AccessAPI("api/complaint/dada", mapData)
|
_, err = a.AccessAPI("api/complaint/dada", mapData)
|
||||||
fmt.Println(data)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取投诉列表
|
||||||
|
func (a *API) ComplaintList() {
|
||||||
|
data, err := a.AccessAPI("api/complaint/reasons", nil)
|
||||||
|
fmt.Println(data)
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
|
||||||
// 增加小费
|
// 增加小费
|
||||||
// http://newopen.imdada.cn/#/development/file/addTip?_k=5yerib
|
// http://newopen.imdada.cn/#/development/file/addTip?_k=5yerib
|
||||||
func (a *API) AddTip(orderID string, tips float64, cityCode, info string) (err error) {
|
func (a *API) AddTip(orderID string, tips float64, cityCode, info string) (err error) {
|
||||||
|
|||||||
@@ -629,7 +629,8 @@ func (a *API) OrderAgreeReturnGoods(param *RefundOrderExamine) (err error) {
|
|||||||
|
|
||||||
//售后 拒绝退货退款
|
//售后 拒绝退货退款
|
||||||
func (a *API) OrderDisagreeReturnGoods(param *RefundOrderExamine) (err error) {
|
func (a *API) OrderDisagreeReturnGoods(param *RefundOrderExamine) (err error) {
|
||||||
return a.EbaiRefundOrder(param)
|
err = a.EbaiRefundOrder(param)
|
||||||
|
return err
|
||||||
//data, err := a.AccessAPI("order.disagreereturngoods", map[string]interface{}{
|
//data, err := a.AccessAPI("order.disagreereturngoods", map[string]interface{}{
|
||||||
// "order_id": orderID,
|
// "order_id": orderID,
|
||||||
// "refund_order_id": refundOrderID,
|
// "refund_order_id": refundOrderID,
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package ebaiapi
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -13,7 +14,7 @@ func TestCancelOrder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderGet(t *testing.T) {
|
func TestOrderGet(t *testing.T) {
|
||||||
result, err := api.OrderGet("4015810058305234572")
|
result, err := api.OrderGet("4054310134272361023")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -23,33 +24,33 @@ func TestOrderGet(t *testing.T) {
|
|||||||
|
|
||||||
func TestOrderAgreePartRefund(t *testing.T) {
|
func TestOrderAgreePartRefund(t *testing.T) {
|
||||||
param := &RefundOrderExamine{
|
param := &RefundOrderExamine{
|
||||||
OrderId: "4003000128728616633",
|
ReverseOrderId: "",
|
||||||
IdempotentId: utils.Int64ToStr(time.Now().UnixNano()),
|
OrderId: "4016410136052874965",
|
||||||
ActionType: RefundTypeAgree,
|
IdempotentId: utils.Int64ToStr(time.Now().UnixNano()),
|
||||||
ReasonCode: "",
|
ActionType: RefundTypeRefuse,
|
||||||
ReasonRemarks: "",
|
ReasonCode: "7001",
|
||||||
|
ReasonRemarks: "1111",
|
||||||
}
|
}
|
||||||
refundProductList := make([]*RefundProductList, 0, 0)
|
refundProductList := make([]*RefundProductList, 0, 0)
|
||||||
date, _, _ := api.GetReverseOrder("4060630055899448055")
|
date, _, _ := api.GetReverseOrder("4016410136052874965")
|
||||||
for _, v := range date {
|
for _, v := range date {
|
||||||
v2 := v.(map[string]interface{})
|
v2 := v.(map[string]interface{})
|
||||||
refundProduct := &RefundProductList{
|
refundProduct := &RefundProductList{
|
||||||
SubBizOrderId: v2["sub_biz_order_id"].(string),
|
SubBizOrderId: v2["sub_biz_order_id"].(string),
|
||||||
PlatformSkuId: utils.Int64ToStr(utils.Interface2Int64WithDefault(v2["platform_sku_id"], 0)),
|
PlatformSkuId: utils.Int64ToStr(utils.Interface2Int64WithDefault(v2["platform_sku_id"], 0)),
|
||||||
}
|
}
|
||||||
|
param.ReverseOrderId = utils.Int64ToStr(utils.MustInterface2Int64(v2["refund_order_id"]))
|
||||||
switch utils.MustInterface2Int64(v2["fund_calculate_type"]) {
|
switch utils.MustInterface2Int64(v2["fund_calculate_type"]) {
|
||||||
case 0:
|
case 0:
|
||||||
refundProduct.Number = utils.Int64ToStr(utils.MustInterface2Int64(v2["refund_quantity"]))
|
refundProduct.Number = utils.Int64ToStr(utils.MustInterface2Int64(v2["refund_quantity"]))
|
||||||
case 1:
|
case 1:
|
||||||
refundProduct.RefundAmount = utils.Int64ToStr(utils.MustInterface2Int64(v2["refund_user_amount"]))
|
refundProduct.RefundAmount = utils.Int64ToStr(utils.MustInterface2Int64(v2["refund_user_amount"]))
|
||||||
}
|
}
|
||||||
if param.ReverseOrderId == "" {
|
|
||||||
param.ReverseOrderId = utils.Int64ToStr(utils.Interface2Int64WithDefault(v2["refund_order_id"], 0))
|
|
||||||
}
|
|
||||||
refundProductList = append(refundProductList, refundProduct)
|
refundProductList = append(refundProductList, refundProduct)
|
||||||
}
|
}
|
||||||
param.RefundProductList = refundProductList
|
param.RefundProductList = refundProductList
|
||||||
err := api.EbaiRefundOrder(param)
|
|
||||||
|
err := api.OrderDisagreeReturnGoods(param)
|
||||||
globals.SugarLogger.Debugf("err := %s", utils.Format4Output(err, false))
|
globals.SugarLogger.Debugf("err := %s", utils.Format4Output(err, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +65,10 @@ func TestOrderAgreeRefund(t *testing.T) {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Test11111(t *testing.T) {
|
||||||
|
fmt.Println(strings.Contains("[隐私保护]顾客地址已隐藏,您可登录饿了么商家端或骑手端查看", "隐私保护"))
|
||||||
|
}
|
||||||
|
|
||||||
func TestGetReverseOrder(t *testing.T) {
|
func TestGetReverseOrder(t *testing.T) {
|
||||||
date, isAll, err := api.GetReverseOrder("4037190131865481753")
|
date, isAll, err := api.GetReverseOrder("4037190131865481753")
|
||||||
fmt.Println(isAll)
|
fmt.Println(isAll)
|
||||||
@@ -73,7 +78,7 @@ func TestGetReverseOrder(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
func TestOrderGet2(t *testing.T) {
|
func TestOrderGet2(t *testing.T) {
|
||||||
result, err := api.OrderGet2("2147234624018417846")
|
result, err := api.OrderGet2("4043790061034194507")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -108,7 +113,7 @@ func TestOrderListAll(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderPartRefundGet(t *testing.T) {
|
func TestOrderPartRefundGet(t *testing.T) {
|
||||||
result, err := api.OrderPartRefundGet("4078740059114489451")
|
result, err := api.OrderPartRefundGet("4033790060039747082")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
} else {
|
} else {
|
||||||
@@ -154,7 +159,7 @@ func TestOrderSwitchselfdelivery(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestOrderComplete(t *testing.T) {
|
func TestOrderComplete(t *testing.T) {
|
||||||
err := api.OrderComplete("4087880039095667221", "")
|
err := api.OrderComplete("4016410136237474551", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package ebaiapi
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -223,13 +222,7 @@ func (a *API) ShopGet2(shopID string, baiduShopID int64) (shopDetail *ShopDetail
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) ShopUpdate(params map[string]interface{}) (err error) {
|
func (a *API) ShopUpdate(params map[string]interface{}) (err error) {
|
||||||
globals.SugarLogger.Debugf("================param := %s", utils.Format4Output(params, false))
|
_, err = a.AccessAPI("shop.update", params)
|
||||||
data, err := a.AccessAPI("shop.update", params)
|
|
||||||
globals.SugarLogger.Debugf("================err := %v", err)
|
|
||||||
globals.SugarLogger.Debugf("================err := %s", utils.Format4Output(data, false))
|
|
||||||
if err == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ func (a *API) ComplaintRider(partnerOrderCode string, orderId string, orderCompl
|
|||||||
"order_id": orderId,
|
"order_id": orderId,
|
||||||
"order_complaint_code": orderComplaintCode,
|
"order_complaint_code": orderComplaintCode,
|
||||||
"order_complaint_desc": resonDes,
|
"order_complaint_desc": resonDes,
|
||||||
"partner_order_code": partnerOrderCode,
|
//"partner_order_code": partnerOrderCode,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/globals"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CallBackInfo struct {
|
|
||||||
AppID string `json:"app_id"`
|
|
||||||
Data string `json:"data"`
|
|
||||||
Salt int `json:"salt"`
|
|
||||||
Signature string `json:"signature"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type WayBillInfo struct {
|
|
||||||
PartnerOrderCode string `json:"partner_order_code"`
|
|
||||||
OrderStatus int `json:"order_status"`
|
|
||||||
PushTime int64 `json:"push_time"`
|
|
||||||
CarrierDriverName string `json:"carrier_driver_name"`
|
|
||||||
CarrierDriverPhone string `json:"carrier_driver_phone"`
|
|
||||||
OpenOrderCode int64 `json:"open_order_code"`
|
|
||||||
PlatformCode string `json:"platform_code"`
|
|
||||||
ErrorScene string `json:"error_scene"`
|
|
||||||
Description string `json:"description"`
|
|
||||||
ErrorCode string `json:"error_code"`
|
|
||||||
DetailDescription string `json:"detail_description"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) GetOrderCallbackMsg(data []byte) (orderMsg *WayBillInfo) {
|
|
||||||
callbackInfo := &CallBackInfo{}
|
|
||||||
err := utils.UnmarshalUseNumber(data, callbackInfo)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
if str, err := url.QueryUnescape(callbackInfo.Data); err == nil {
|
|
||||||
orderMsg = &WayBillInfo{}
|
|
||||||
if err := utils.UnmarshalUseNumber([]byte(str), orderMsg); err == nil {
|
|
||||||
return orderMsg
|
|
||||||
} else {
|
|
||||||
globals.SugarLogger.Debugf("fn msg faild3 %v", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
globals.SugarLogger.Debugf("fn msg faild2 %v", err)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return orderMsg
|
|
||||||
}
|
|
||||||
@@ -1,148 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/md5"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"math/rand"
|
|
||||||
"net/http"
|
|
||||||
"net/url"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi"
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
sigKey = "signature"
|
|
||||||
|
|
||||||
TestURL = "https://exam-anubis.ele.me/anubis-webapi"
|
|
||||||
URL = "https://open-anubis.ele.me/anubis-webapi"
|
|
||||||
tokenAction = "get_access_token"
|
|
||||||
)
|
|
||||||
|
|
||||||
type API struct {
|
|
||||||
accessToken string
|
|
||||||
appID string
|
|
||||||
appSecret string
|
|
||||||
locker sync.RWMutex
|
|
||||||
client *http.Client
|
|
||||||
config *platformapi.APIConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) SetToken(token string) {
|
|
||||||
a.locker.Lock()
|
|
||||||
defer a.locker.Unlock()
|
|
||||||
a.accessToken = token
|
|
||||||
}
|
|
||||||
|
|
||||||
func New(appID, appSecret string, config ...*platformapi.APIConfig) *API {
|
|
||||||
curConfig := platformapi.DefAPIConfig
|
|
||||||
if len(config) > 0 {
|
|
||||||
curConfig = *config[0]
|
|
||||||
}
|
|
||||||
return &API{
|
|
||||||
appID: appID,
|
|
||||||
appSecret: appSecret,
|
|
||||||
client: &http.Client{Timeout: curConfig.ClientTimeout},
|
|
||||||
config: &curConfig,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) signParam(params map[string]interface{}) (sig string) {
|
|
||||||
var valueList []string
|
|
||||||
for k, v := range params {
|
|
||||||
if k != sigKey {
|
|
||||||
if str := fmt.Sprint(v); str != "" {
|
|
||||||
valueList = append(valueList, fmt.Sprintf("%s=%s", k, str))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort.Sort(sort.StringSlice(valueList))
|
|
||||||
valueList = append(valueList, fmt.Sprintf("secret_key=%s", a.appSecret))
|
|
||||||
sig = strings.Join(valueList, "&")
|
|
||||||
binSig := md5.Sum([]byte(url.QueryEscape(sig)))
|
|
||||||
sig = fmt.Sprintf("%x", binSig)
|
|
||||||
return sig
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) signParam2(params map[string]interface{}) (sig string) {
|
|
||||||
sb := new(strings.Builder)
|
|
||||||
sb.WriteString("app_id=")
|
|
||||||
sb.WriteString(a.appID)
|
|
||||||
sb.WriteString("&access_token=")
|
|
||||||
sb.WriteString(a.accessToken)
|
|
||||||
sb.WriteString("&data=")
|
|
||||||
sb.WriteString(params["data"].(string))
|
|
||||||
sb.WriteString("&salt=")
|
|
||||||
sb.WriteString(utils.Int64ToStr(utils.MustInterface2Int64(params["salt"])))
|
|
||||||
sig = sb.String()
|
|
||||||
binSig := md5.Sum([]byte(sig))
|
|
||||||
sig = fmt.Sprintf("%x", binSig)
|
|
||||||
return sig
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) AccessAPI(action string, url string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
|
||||||
params := make(map[string]interface{})
|
|
||||||
params["salt"] = GetSalt()
|
|
||||||
params["app_id"] = a.appID
|
|
||||||
if action != tokenAction {
|
|
||||||
data, _ := json.Marshal(bizParams)
|
|
||||||
params["data"] = string(data)
|
|
||||||
signStr := a.signParam2(params)
|
|
||||||
params[sigKey] = signStr
|
|
||||||
} else {
|
|
||||||
signStr := a.signParam(params)
|
|
||||||
params[sigKey] = signStr
|
|
||||||
}
|
|
||||||
data, _ := json.Marshal(params)
|
|
||||||
fullURL := utils.GenerateGetURL(url, action, nil)
|
|
||||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
|
||||||
func() *http.Request {
|
|
||||||
var request *http.Request
|
|
||||||
if isPost {
|
|
||||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data)))
|
|
||||||
} else {
|
|
||||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(url, action, params), nil)
|
|
||||||
}
|
|
||||||
request.Header.Set("Content-Type", "application/json")
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
if utils.MustInterface2Int64(jsonResult1["code"]) != 200 {
|
|
||||||
errLevel = platformapi.ErrLevelGeneralFail
|
|
||||||
err = utils.NewErrorCode(jsonResult1["msg"].(string), utils.Int64ToStr(utils.MustInterface2Int64(jsonResult1["code"])))
|
|
||||||
}
|
|
||||||
retVal = jsonResult1
|
|
||||||
}
|
|
||||||
return errLevel, err
|
|
||||||
})
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSalt() (salt int) {
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
return rand.Intn(8999) + 1000
|
|
||||||
}
|
|
||||||
|
|
||||||
type TokenInfo struct {
|
|
||||||
AccessToken string `json:"access_token"`
|
|
||||||
AppID string `json:"app_id"`
|
|
||||||
ExpireTime int64 `json:"expire_time"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) GetAccessToken() (tokenInfo *TokenInfo, err error) {
|
|
||||||
result, err := a.AccessAPI(tokenAction, URL, nil, false)
|
|
||||||
if err == nil {
|
|
||||||
utils.Map2StructByJson(result["data"], &tokenInfo, false)
|
|
||||||
}
|
|
||||||
return tokenInfo, err
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi"
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"go.uber.org/zap"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
api *API
|
|
||||||
apiv3 *APIv3
|
|
||||||
sugarLogger *zap.SugaredLogger
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
logger, _ := zap.NewDevelopment()
|
|
||||||
sugarLogger = logger.Sugar()
|
|
||||||
baseapi.Init(sugarLogger)
|
|
||||||
api = New("6a3e2073-1850-413b-9eb7-6c342ec36e1c", "a8248088-a742-4c33-a0db-03aeae00ca7d")
|
|
||||||
api.SetToken("n-606c907a-5117-4c64-bc32-291c3091cabd-w")
|
|
||||||
apiv3 = Newv3("6a3e2073-1850-413b-9eb7-6c342ec36e1c", "a8248088-a742-4c33-a0db-03aeae00ca7d")
|
|
||||||
apiv3.SetTokenv3("n-606c907a-5117-4c64-bc32-291c3091cabd-w")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetAccessToken(t *testing.T) {
|
|
||||||
result, err := api.GetAccessToken()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
@@ -1,137 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"crypto/sha1"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"git.rosy.net.cn/baseapi/platformapi"
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"net/http"
|
|
||||||
"sort"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
merchantID = "51658"
|
|
||||||
|
|
||||||
URLv3 = "https://open-anubis.ele.me/anubis-webapi/v3/invoke"
|
|
||||||
)
|
|
||||||
|
|
||||||
type APIv3 struct {
|
|
||||||
accessToken string
|
|
||||||
appID string
|
|
||||||
appSecret string
|
|
||||||
|
|
||||||
locker sync.RWMutex
|
|
||||||
client *http.Client
|
|
||||||
config *platformapi.APIConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func Newv3(appID, appSecret string, config ...*platformapi.APIConfig) *APIv3 {
|
|
||||||
curConfig := platformapi.DefAPIConfig
|
|
||||||
if len(config) > 0 {
|
|
||||||
curConfig = *config[0]
|
|
||||||
}
|
|
||||||
return &APIv3{
|
|
||||||
appID: appID,
|
|
||||||
appSecret: appSecret,
|
|
||||||
client: &http.Client{Timeout: curConfig.ClientTimeout},
|
|
||||||
config: &curConfig,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *APIv3) SetTokenv3(token string) {
|
|
||||||
a.locker.Lock()
|
|
||||||
defer a.locker.Unlock()
|
|
||||||
a.accessToken = token
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *APIv3) signParamv3(params map[string]interface{}) (sig string) {
|
|
||||||
var valueList []string
|
|
||||||
for k, v := range params {
|
|
||||||
if k != sigKey {
|
|
||||||
if str := fmt.Sprint(v); str != "" {
|
|
||||||
valueList = append(valueList, fmt.Sprintf("%s=%s", k, str))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort.Sort(sort.StringSlice(valueList))
|
|
||||||
sig = strings.Join(valueList, "&")
|
|
||||||
sig = a.appSecret + sig
|
|
||||||
binSig := sha1.Sum([]byte(sig))
|
|
||||||
sig = fmt.Sprintf("%x", binSig)
|
|
||||||
return sig
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *APIv3) AccessAPIv3(action string, url string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
|
||||||
params := make(map[string]interface{})
|
|
||||||
params["timestamp"] = time.Now().UnixNano()
|
|
||||||
params["app_id"] = a.appID
|
|
||||||
params["merchant_id"] = merchantID
|
|
||||||
params["version"] = "1.0"
|
|
||||||
params["access_token"] = a.accessToken
|
|
||||||
data, _ := json.Marshal(bizParams)
|
|
||||||
params["business_data"] = string(data)
|
|
||||||
signStr := a.signParamv3(params)
|
|
||||||
params[sigKey] = signStr
|
|
||||||
datas, _ := json.Marshal(params)
|
|
||||||
fullURL := utils.GenerateGetURL(url, action, nil)
|
|
||||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
|
||||||
func() *http.Request {
|
|
||||||
var request *http.Request
|
|
||||||
if isPost {
|
|
||||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(datas)))
|
|
||||||
} else {
|
|
||||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(url, action, params), nil)
|
|
||||||
}
|
|
||||||
request.Header.Set("Content-Type", "application/json")
|
|
||||||
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")
|
|
||||||
}
|
|
||||||
if err == nil {
|
|
||||||
if utils.MustInterface2Int64(jsonResult1["code"]) != 200 {
|
|
||||||
errLevel = platformapi.ErrLevelGeneralFail
|
|
||||||
err = utils.NewErrorCode(jsonResult1["msg"].(string), utils.Int64ToStr(utils.MustInterface2Int64(jsonResult1["code"])))
|
|
||||||
}
|
|
||||||
retVal = jsonResult1
|
|
||||||
}
|
|
||||||
return errLevel, err
|
|
||||||
})
|
|
||||||
return retVal, err
|
|
||||||
}
|
|
||||||
|
|
||||||
type PreCreateOrderParam struct {
|
|
||||||
PartnerOrderCode string `json:"partner_order_code"`
|
|
||||||
OutShopCode string `json:"out_shop_code"`
|
|
||||||
OrderType int `json:"order_type"`
|
|
||||||
PositionSource int `json:"position_source"` // 3:高德地图
|
|
||||||
ReceiverAddress string `json:"receiver_address"`
|
|
||||||
ReceiverLongitude float64 `json:"receiver_longitude"`
|
|
||||||
ReceiverLatitude float64 `json:"receiver_latitude"`
|
|
||||||
GoodsTotalAmountCent float64 `json:"goods_total_amount_cent"`
|
|
||||||
GoodsActualAmountCent float64 `json:"goods_actual_amount_cent"`
|
|
||||||
GoodsWeight float64 `json:"goods_weight"`
|
|
||||||
GoodsCount float64 `json:"goods_count"`
|
|
||||||
GoodsItemList []*ItemsJSON2 `json:"goods_item_list"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ItemsJSON2 struct {
|
|
||||||
ItemName string `json:"item_name"`
|
|
||||||
ItemQuantity int `json:"item_quantity"`
|
|
||||||
ItemAmountCent float64 `json:"item_amount_cent"`
|
|
||||||
ItemActualAmountCent float64 `json:"item_actual_amount_cent"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *APIv3) PreCreateOrder(preCreateOrderParam *PreCreateOrderParam) (queryOrderResult *QueryOrderResult, err error) {
|
|
||||||
result, err := a.AccessAPIv3("preCreateOrder", URLv3, utils.Struct2FlatMap(preCreateOrderParam), true)
|
|
||||||
if err == nil {
|
|
||||||
utils.Map2StructByJson(result["data"], &queryOrderResult, false)
|
|
||||||
}
|
|
||||||
return queryOrderResult, err
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestPreCreateOrder(t *testing.T) {
|
|
||||||
result, err := apiv3.PreCreateOrder(&PreCreateOrderParam{
|
|
||||||
PartnerOrderCode: "2118717546000352",
|
|
||||||
OutShopCode: "667002",
|
|
||||||
OrderType: 1,
|
|
||||||
PositionSource: 3,
|
|
||||||
ReceiverAddress: "徐州市泉山区大润发(欣欣店)一楼咔啦嘟熊童装店",
|
|
||||||
ReceiverLongitude: 117.195360,
|
|
||||||
ReceiverLatitude: 34.201010,
|
|
||||||
GoodsTotalAmountCent: 66.2,
|
|
||||||
GoodsActualAmountCent: 67.2,
|
|
||||||
GoodsWeight: 2.3,
|
|
||||||
GoodsCount: 6,
|
|
||||||
GoodsItemList: []*ItemsJSON2{
|
|
||||||
&ItemsJSON2{
|
|
||||||
ItemName: "巨峰葡萄约500g/份",
|
|
||||||
ItemQuantity: 2,
|
|
||||||
ItemAmountCent: 15.2,
|
|
||||||
ItemActualAmountCent: 15.2,
|
|
||||||
},
|
|
||||||
&ItemsJSON2{
|
|
||||||
ItemName: "[新鲜]苹果150g/个(约150g-250g)",
|
|
||||||
ItemQuantity: 2,
|
|
||||||
ItemAmountCent: 4.3,
|
|
||||||
ItemActualAmountCent: 4.3,
|
|
||||||
},
|
|
||||||
&ItemsJSON2{
|
|
||||||
ItemName: "脆桃 鲜,甜,脆约500g/份",
|
|
||||||
ItemQuantity: 2,
|
|
||||||
ItemAmountCent: 14.6,
|
|
||||||
ItemActualAmountCent: 14.6,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
OrderCancelReson1 = 1 // 1:物流原因:订单长时间未分配骑手,
|
|
||||||
OrderCancelReson2 = 2 // 2:物流原因:分配骑手后,骑手长时间未取件 ,
|
|
||||||
OrderCancelReson3 = 3 // 3:物流原因:骑手告知不配送,让取消订单,
|
|
||||||
OrderCancelReson4 = 4 // 4:商品缺货/无法出货/已售完,
|
|
||||||
OrderCancelReson5 = 5 // 5:商户联系不上门店/门店关门了,
|
|
||||||
OrderCancelReson6 = 6 // 6:商户发错单,
|
|
||||||
OrderCancelReson7 = 7 // 7:商户/顾客自身定位错误,
|
|
||||||
OrderCancelReson8 = 8 // 8:商户改其他第三方配送,
|
|
||||||
OrderCancelReson9 = 9 // 9:顾客下错单/临时不想要了,
|
|
||||||
OrderCancelReson10 = 10 // 10:顾客自取/不在家/要求另改时间配送)(0类型已下线)
|
|
||||||
|
|
||||||
OrderStatusAccept = 1 //系统已接单
|
|
||||||
OrderStatusAssigned = 20 //已分配骑手
|
|
||||||
OrderStatusArrived = 80 //已到店
|
|
||||||
OrderStatusDelivering = 2 //配送中
|
|
||||||
OrderStatusDelivered = 3 //已送达
|
|
||||||
OrderStatusException = 5 //异常
|
|
||||||
)
|
|
||||||
|
|
||||||
type CreateOrderParam struct {
|
|
||||||
PartnerRemark string `json:"partner_remark,omitempty"`
|
|
||||||
PartnerOrderCode string `json:"partner_order_code,omitempty"`
|
|
||||||
NotifyURL string `json:"notify_url,omitempty"`
|
|
||||||
OrderType int `json:"order_type,omitempty"`
|
|
||||||
ChainStoreCode string `json:"chain_store_code,omitempty"`
|
|
||||||
TransportInfo *TransportInfo `json:"transport_info,omitempty"`
|
|
||||||
OrderAddTime int64 `json:"order_add_time,omitempty"`
|
|
||||||
OrderTotalAmount float64 `json:"order_total_amount,omitempty"`
|
|
||||||
OrderActualAmount float64 `json:"order_actual_amount,omitempty"`
|
|
||||||
OrderWeight float64 `json:"order_weight,omitempty"`
|
|
||||||
OrderRemark string `json:"order_remark,omitempty"`
|
|
||||||
IsInvoiced int `json:"is_invoiced"`
|
|
||||||
Invoice string `json:"invoice,omitempty"`
|
|
||||||
OrderPaymentStatus int `json:"order_payment_status,omitempty"`
|
|
||||||
OrderPaymentMethod int `json:"order_payment_method,omitempty"`
|
|
||||||
IsAgentPayment int `json:"is_agent_payment"`
|
|
||||||
RequirePaymentPay float64 `json:"require_payment_pay,omitempty"`
|
|
||||||
GoodsCount int `json:"goods_count,omitempty"`
|
|
||||||
RequireReceiveTime int64 `json:"require_receive_time,omitempty"`
|
|
||||||
SerialNumber string `json:"serial_number,omitempty"`
|
|
||||||
ReceiverInfo *ReceiverInfo `json:"receiver_info,omitempty"`
|
|
||||||
ItemsJSON []*ItemsJSON `json:"items_json,omitempty"`
|
|
||||||
OrderSource string `json:"order_source,omitempty"` //饿百订单传109
|
|
||||||
ChannelOrderCode string `json:"channel_order_code,omitempty"`
|
|
||||||
CookingTime int64 `json:"cooking_time,omitempty"`
|
|
||||||
PlatformPaidTime int64 `json:"platform_paid_time,omitempty"`
|
|
||||||
PlatformCreatedTime int64 `json:"platform_created_time,omitempty"`
|
|
||||||
MerchantCode string `json:"merchant_code,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ReceiverInfo struct {
|
|
||||||
ReceiverName string `json:"receiver_name,omitempty"`
|
|
||||||
ReceiverPrimaryPhone string `json:"receiver_primary_phone,omitempty"`
|
|
||||||
ReceiverSecondPhone string `json:"receiver_second_phone,omitempty"`
|
|
||||||
ReceiverAddress string `json:"receiver_address,omitempty"`
|
|
||||||
ReceiverLongitude float64 `json:"receiver_longitude,omitempty"`
|
|
||||||
ReceiverLatitude float64 `json:"receiver_latitude,omitempty"`
|
|
||||||
PositionSource int `json:"position_source,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TransportInfo struct {
|
|
||||||
TransportName string `json:"transport_name,omitempty"`
|
|
||||||
TransportAddress string `json:"transport_address,omitempty"`
|
|
||||||
TransportLongitude float64 `json:"transport_longitude,omitempty"`
|
|
||||||
TransportLatitude float64 `json:"transport_latitude,omitempty"`
|
|
||||||
PositionSource int `json:"position_source,omitempty"`
|
|
||||||
TransportTel string `json:"transport_tel,omitempty"`
|
|
||||||
TransportRemark string `json:"transport_remark,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type ItemsJSON struct {
|
|
||||||
ItemID string `json:"item_id,omitempty"`
|
|
||||||
ItemName string `json:"item_name,omitempty"`
|
|
||||||
ItemQuantity int `json:"item_quantity,omitempty"`
|
|
||||||
ItemPrice float64 `json:"item_price"`
|
|
||||||
ItemActualPrice float64 `json:"item_actual_price"`
|
|
||||||
ItemSize int `json:"item_size,omitempty"`
|
|
||||||
ItemRemark string `json:"item_remark,omitempty"`
|
|
||||||
IsNeedPackage int `json:"is_need_package"`
|
|
||||||
IsAgentPurchase int `json:"is_agent_purchase"`
|
|
||||||
AgentPurchasePrice float64 `json:"agent_purchase_price,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
//https://open.ele.me/documents/%E5%88%9B%E5%BB%BA%E8%9C%82%E9%B8%9F%E8%AE%A2%E5%8D%95
|
|
||||||
func (a *API) CreateOrder(createOrderParam *CreateOrderParam) (err error) {
|
|
||||||
params := utils.Struct2FlatMap(createOrderParam)
|
|
||||||
_, err = a.AccessAPI("v2/order", URL, params, true)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
//order_cancel_reason_code 订单取消原因代码(1:用户取消,2:商家取消)
|
|
||||||
// order_cancel_code 订单取消编码(
|
|
||||||
// 1:物流原因:订单长时间未分配骑手,
|
|
||||||
// 2:物流原因:分配骑手后,骑手长时间未取件 ,
|
|
||||||
// 3:物流原因:骑手告知不配送,让取消订单,
|
|
||||||
// 4:商品缺货/无法出货/已售完, 5:商户联系不上门店/门店关门了, 6:商户发错单,
|
|
||||||
// 7:商户/顾客自身定位错误, 8:商户改其他第三方配送, 9:顾客下错单/临时不想要了,
|
|
||||||
// 10:顾客自取/不在家/要求另改时间配送)(0类型已下线)
|
|
||||||
|
|
||||||
type CancelOrderParam struct {
|
|
||||||
PartnerOrderCode string `json:"partner_order_code,omitempty"`
|
|
||||||
OrderCancelReasonCode int `json:"order_cancel_reason_code,omitempty"`
|
|
||||||
OrderCancelCode int `json:"order_cancel_code,omitempty"`
|
|
||||||
OrderCancelDescription string `json:"order_cancel_description,omitempty"`
|
|
||||||
OrderCancelTime int64 `json:"order_cancel_time,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) CancelOrder(cancelOrderParam *CancelOrderParam) (err error) {
|
|
||||||
params := utils.Struct2FlatMap(cancelOrderParam)
|
|
||||||
_, err = a.AccessAPI("v2/order/cancel", URL, params, true)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) ComplaintOrder(cancelOrderParam *CancelOrderParam) (err error) {
|
|
||||||
params := utils.Struct2FlatMap(cancelOrderParam)
|
|
||||||
_, err = a.AccessAPI("v2/order/complaint", URL, params, true)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
type QueryOrderResult struct {
|
|
||||||
AbnormalCode string `json:"abnormal_code"`
|
|
||||||
AbnormalDesc string `json:"abnormal_desc"`
|
|
||||||
CarrierDriverID int `json:"carrier_driver_id"`
|
|
||||||
CarrierDriverName string `json:"carrier_driver_name"`
|
|
||||||
CarrierDriverPhone string `json:"carrier_driver_phone"`
|
|
||||||
ComplaintDescription interface{} `json:"complaintDescription"`
|
|
||||||
ComplaintStatus interface{} `json:"complaintStatus"`
|
|
||||||
EstimateArriveTime int64 `json:"estimate_arrive_time"`
|
|
||||||
EventLogDetails []struct {
|
|
||||||
CarrierDriverName string `json:"carrier_driver_name"`
|
|
||||||
CarrierDriverPhone string `json:"carrier_driver_phone"`
|
|
||||||
OccurTime int64 `json:"occur_time"`
|
|
||||||
OrderStatus int `json:"order_status"`
|
|
||||||
} `json:"event_log_details"`
|
|
||||||
HandleID interface{} `json:"handleId"`
|
|
||||||
OrderID interface{} `json:"orderId"`
|
|
||||||
OrderStatus int `json:"order_status"`
|
|
||||||
OrderTotalDeliveryCost float64 `json:"order_total_delivery_cost"`
|
|
||||||
OrderTotalDeliveryDiscount interface{} `json:"order_total_delivery_discount"`
|
|
||||||
OvertimeCompensationCost float64 `json:"overtime_compensation_cost"`
|
|
||||||
Reason string `json:"reason"`
|
|
||||||
SupportClaims bool `json:"support_claims"`
|
|
||||||
TrackingID int64 `json:"trackingId"`
|
|
||||||
TrackingID2 int64 `json:"tracking_id"`
|
|
||||||
TransportStationID string `json:"transport_station_id"`
|
|
||||||
TransportStationTel string `json:"transport_station_tel"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) QueryOrder(partnerOrderCode string) (queryOrderResult *QueryOrderResult, err error) {
|
|
||||||
result, err := a.AccessAPI("v2/order/query", URL, map[string]interface{}{
|
|
||||||
"partner_order_code": partnerOrderCode,
|
|
||||||
}, true)
|
|
||||||
if err == nil {
|
|
||||||
utils.Map2StructByJson(result["data"], &queryOrderResult, false)
|
|
||||||
}
|
|
||||||
return queryOrderResult, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) ComplaintRider(partnerOrderCode string, orderComplaintCode int) (err error) {
|
|
||||||
_, err = a.AccessAPI("v2/order/complaint", URL, map[string]interface{}{
|
|
||||||
"partner_order_code": partnerOrderCode,
|
|
||||||
"order_complaint_code": orderComplaintCode,
|
|
||||||
"order_complaint_time": time.Now().UnixNano() / 1e6,
|
|
||||||
}, true)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestQueryOrder(t *testing.T) {
|
|
||||||
result, err := api.QueryOrder("134420892247000001")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCreateOrder(t *testing.T) {
|
|
||||||
params := &CreateOrderParam{
|
|
||||||
PartnerOrderCode: "2140252158517300353",
|
|
||||||
NotifyURL: "https://callback.test.jxc4.com/fn/msg",
|
|
||||||
ChainStoreCode: "667281",
|
|
||||||
OrderType: 1, //即时达
|
|
||||||
TransportInfo: &TransportInfo{
|
|
||||||
TransportName: "测试西南交大店",
|
|
||||||
TransportAddress: "成都市金牛区交大路银桂桥二巷60号",
|
|
||||||
TransportLongitude: 104.047773,
|
|
||||||
TransportLatitude: 30.695838,
|
|
||||||
PositionSource: 3,
|
|
||||||
TransportTel: "18160030913",
|
|
||||||
},
|
|
||||||
OrderAddTime: time.Now().UnixNano() / 1e6,
|
|
||||||
OrderTotalAmount: 12,
|
|
||||||
OrderActualAmount: 10,
|
|
||||||
OrderWeight: 1.2,
|
|
||||||
OrderRemark: utils.FilterMb4("客户电话:18160030913,测试取货失败或配送遇到问题请联系18048531223,禁止未配送直接完成定单!"),
|
|
||||||
IsInvoiced: 0,
|
|
||||||
OrderPaymentStatus: 1,
|
|
||||||
OrderPaymentMethod: 1,
|
|
||||||
IsAgentPayment: 0,
|
|
||||||
GoodsCount: 2,
|
|
||||||
ReceiverInfo: &ReceiverInfo{
|
|
||||||
ReceiverName: "苏尹岚",
|
|
||||||
ReceiverAddress: "武侯大道金色花园A区",
|
|
||||||
ReceiverLongitude: 104.01459,
|
|
||||||
ReceiverLatitude: 30.636258,
|
|
||||||
ReceiverPrimaryPhone: "18160030913",
|
|
||||||
ReceiverSecondPhone: "18160030913",
|
|
||||||
PositionSource: 3,
|
|
||||||
},
|
|
||||||
SerialNumber: "测试1#",
|
|
||||||
}
|
|
||||||
var skuInfo []*ItemsJSON
|
|
||||||
// for _, v := range order.Skus {
|
|
||||||
skuInfo = append(skuInfo, &ItemsJSON{
|
|
||||||
ItemID: "30677",
|
|
||||||
ItemName: "测试商品",
|
|
||||||
ItemQuantity: 1,
|
|
||||||
ItemPrice: 3.6,
|
|
||||||
ItemActualPrice: 2,
|
|
||||||
})
|
|
||||||
// }
|
|
||||||
params.ItemsJSON = skuInfo
|
|
||||||
//要求饿百的订单要传来源
|
|
||||||
// if order.VendorID == model.VendorIDEBAI {
|
|
||||||
// params.OrderSource = "109"
|
|
||||||
// params.ChannelOrderCode = order.VendorOrderID
|
|
||||||
// }
|
|
||||||
err := api.CreateOrder(params)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestComplaintRider(t *testing.T) {
|
|
||||||
err := api.ComplaintRider("2118635456000161", 130)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestCancelOrder(t *testing.T) {
|
|
||||||
err := api.CancelOrder(&CancelOrderParam{
|
|
||||||
PartnerOrderCode: "89296492736359287",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
StoreNotExist = "门店信息不存在"
|
|
||||||
StoreExist = "该门店已存在"
|
|
||||||
)
|
|
||||||
|
|
||||||
type CreateStoreParam struct {
|
|
||||||
ChainStoreCode string `json:"chain_store_code,omitempty"`
|
|
||||||
ChainStoreName string `json:"chain_store_name,omitempty"`
|
|
||||||
ChainStoreType int `json:"chain_store_type,omitempty"`
|
|
||||||
MerchantCode string `json:"merchant_code,omitempty"`
|
|
||||||
ContactPhone string `json:"contact_phone,omitempty"`
|
|
||||||
Address string `json:"address,omitempty"`
|
|
||||||
PositionSource int `json:"position_source,omitempty"`
|
|
||||||
Longitude string `json:"longitude,omitempty"`
|
|
||||||
Latitude string `json:"latitude,omitempty"`
|
|
||||||
ServiceCode string `json:"service_code,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) CreateStore(createStoreParam *CreateStoreParam) (err error) {
|
|
||||||
createStoreParam.ServiceCode = "1"
|
|
||||||
params := utils.Struct2FlatMap(createStoreParam)
|
|
||||||
_, err = a.AccessAPI("v2/chain_store", URL, params, true)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetStoreResult struct {
|
|
||||||
ChainStoreCode string `json:"chain_store_code"`
|
|
||||||
ChainStoreName string `json:"chain_store_name"`
|
|
||||||
Address string `json:"address"`
|
|
||||||
Latitude string `json:"latitude"`
|
|
||||||
Longitude string `json:"longitude"`
|
|
||||||
PositionSource int `json:"position_source"`
|
|
||||||
City string `json:"city"`
|
|
||||||
ContactPhone string `json:"contact_phone"`
|
|
||||||
ServiceCode string `json:"service_code"`
|
|
||||||
Status int `json:"status"` //1关店,2开店
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) GetStore(storeID string) (getStoreResult *GetStoreResult, err error) {
|
|
||||||
result, err := a.AccessAPI("v2/chain_store/query", URL, map[string]interface{}{
|
|
||||||
"chain_store_code": []string{storeID},
|
|
||||||
}, true)
|
|
||||||
if err == nil {
|
|
||||||
if data, ok := result["data"].([]interface{}); ok {
|
|
||||||
utils.Map2StructByJson(data[0], &getStoreResult, false)
|
|
||||||
} else {
|
|
||||||
err = fmt.Errorf(result["msg"].(string))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return getStoreResult, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsErrShopNotExist(err error) bool {
|
|
||||||
if err != nil {
|
|
||||||
if strings.Contains(err.Error(), StoreNotExist) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func IsErrShopExist(err error) bool {
|
|
||||||
if err != nil {
|
|
||||||
if strings.Contains(err.Error(), StoreExist) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *API) UpdateStore(createStoreParam *CreateStoreParam) (err error) {
|
|
||||||
params := utils.Struct2FlatMap(createStoreParam)
|
|
||||||
_, err = a.AccessAPI("v2/chain_store/update", URL, params, true)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package fnpsapi
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestCreateStore(t *testing.T) {
|
|
||||||
err := api.CreateStore(&CreateStoreParam{
|
|
||||||
ChainStoreCode: "667281",
|
|
||||||
ChainStoreName: "测试西南交大店",
|
|
||||||
ChainStoreType: 2,
|
|
||||||
ContactPhone: "18160030913",
|
|
||||||
Address: "成都市金牛区交大路银桂桥二巷60号",
|
|
||||||
PositionSource: 3,
|
|
||||||
Longitude: "104.047773",
|
|
||||||
Latitude: "30.695838",
|
|
||||||
ServiceCode: "1",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestGetStore(t *testing.T) {
|
|
||||||
result, err := api.GetStore("667281")
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdateStore(t *testing.T) {
|
|
||||||
err := api.UpdateStore(&CreateStoreParam{
|
|
||||||
ChainStoreCode: "667281",
|
|
||||||
Address: "1111111",
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
@@ -20,17 +20,17 @@ func init() {
|
|||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
|
|
||||||
// 菜市
|
// 菜市
|
||||||
api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
//api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "")
|
||||||
|
|
||||||
// 果园
|
// 果园
|
||||||
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
//api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "")
|
||||||
|
|
||||||
//商超
|
//商超
|
||||||
//api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_u368I2OxTY4ys4wWuVVMOQ") //token_n4TwqCntWWuvQwAawzxC0w
|
api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_u368I2OxTY4ys4wWuVVMOQ") //token_n4TwqCntWWuvQwAawzxC0w
|
||||||
//cookieStr := `
|
cookieStr := `
|
||||||
// acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1;
|
||||||
//`
|
`
|
||||||
//api.SetCookieWithStr(cookieStr)
|
api.SetCookieWithStr(cookieStr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAccessAPI(t *testing.T) {
|
func TestAccessAPI(t *testing.T) {
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MtwmSCTag = "13030000"
|
MtwmSCTag = "13030000"
|
||||||
MtwmC4Tag = "11010000"
|
MtwmC4Tag = "11010000"
|
||||||
MtwmSGTag = "10010000"
|
MtwmSGTag = "10010000"
|
||||||
AuditTypeStore = 1 //审核类型:1-门店入驻;2-门店logo(头图)
|
AuditTypeStore = 1 //审核类型:1-门店入驻;2-门店logo(头图)
|
||||||
AuditTypeStoreLogo = 2
|
AuditTypeStoreLogo = 2
|
||||||
|
MtStoreIsOnlineOffLine = 0 // 0 下线 3审核通过可上线
|
||||||
|
MtStoreIsOnlineOnLine = 1 // 1上线 2上单
|
||||||
)
|
)
|
||||||
|
|
||||||
type PoiCategoryInfo struct {
|
type PoiCategoryInfo struct {
|
||||||
@@ -33,7 +35,7 @@ type PoiInfo struct {
|
|||||||
InvoiceDescription string `json:"invoice_description,omitempt"`
|
InvoiceDescription string `json:"invoice_description,omitempt"`
|
||||||
InvoiceMinPrice int `json:"invoice_min_price,omitempt"`
|
InvoiceMinPrice int `json:"invoice_min_price,omitempt"`
|
||||||
InvoiceSupport int `json:"invoice_support,omitempt"`
|
InvoiceSupport int `json:"invoice_support,omitempt"`
|
||||||
IsOnline int `json:"is_online,omitempt"`
|
IsOnline int `json:"is_online,omitempt"` // 0-下线;1-上线;2-上单中;3-审核通过可上线。
|
||||||
Latitude float64 `json:"latitude,omitempt"`
|
Latitude float64 `json:"latitude,omitempt"`
|
||||||
LocationID int `json:"location_id,omitempt"`
|
LocationID int `json:"location_id,omitempt"`
|
||||||
Longitude float64 `json:"longitude,omitempt"`
|
Longitude float64 `json:"longitude,omitempt"`
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -301,13 +301,10 @@ func (a *API) RetailBatchInitData(trackInfo, poiCode string, foodDataList []map[
|
|||||||
KeyAppPoiCode: poiCode,
|
KeyAppPoiCode: poiCode,
|
||||||
"food_data": string(utils.MustMarshal(foodDataList)),
|
"food_data": string(utils.MustMarshal(foodDataList)),
|
||||||
}, resultKeyMsg, trackInfo)
|
}, resultKeyMsg, trackInfo)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
failedFoodList, err = handleRetailBatchResult(result)
|
failedFoodList, err = handleRetailBatchResult(result)
|
||||||
}
|
}
|
||||||
if err != nil {
|
|
||||||
globals.SugarLogger.Debugf("=============err := %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return failedFoodList, err
|
return failedFoodList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,47 +112,27 @@ func TestAddStoreSku(t *testing.T) {
|
|||||||
globals.SugarLogger.Debugf("err = %s", utils.Format4Output(err, false))
|
globals.SugarLogger.Debugf("err = %s", utils.Format4Output(err, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
var skucodeMap = []string{
|
|
||||||
"JX100829:25278",
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUpdateSku(t *testing.T) {
|
func TestUpdateSku(t *testing.T) {
|
||||||
data2 := make([]string, 0, 0)
|
StoreIds1 := "JX668420,JX667261,JX669067,JX667551,JX666736,JX102180,JX102147,JX668894,JX668523,JX668673,JX667364,JX669058,JX667354,JX669148,JX102818,JX100100,JX668123,JX102789,JX103037,JX668190,JX668078,JX668453,JX103086,JX668947,JX668358,JX667473,JX102303,JX667399,JX668951,JX668385,JX102938,JX667308,JX668932,JX102859,JX667559,JX667361,JX668399,JX103098,JX667476,JX668985,JX102962,JX668960,JX100720,JX668540,JX100517,JX668807,JX667562,JX668364,JX668380,JX666949,JX668125,JX100456,JX668113,JX669035,JX100292,JX103189,JX667315,JX667374,JX102562,JX668392,JX667268,JX102358,JX102790,JX668039,JX100446,JX666900,JX668444,JX103083,JX667305,JX102950,JX103029,JX102945,JX102676,JX101842,JX102824,JX668583,JX668569,JX668094,JX102542,JX667304,JX667468,JX102488,JX669202,JX668107,JX101870,JX667064,JX102784,JX100670,JX667211,JX668309,JX667357,JX667991,JX103085,JX102894,JX668397,JX100987,JX102981,JX103082,JX102969,JX666779,JX102496,JX103002,JX668352,JX103079,JX667127,"
|
||||||
for _, v := range skucodeMap {
|
storeCode := strings.Split(StoreIds1, ",")
|
||||||
storeCodeAndSkuCode := strings.Split(v, ":")
|
|
||||||
skuCode := []string{storeCodeAndSkuCode[1]}
|
for _, v := range storeCode {
|
||||||
storeCode1 := utils.String2Pointer(storeCodeAndSkuCode[0])
|
param := &request585.AlibabaWdkSkuUpdateRequest{}
|
||||||
result, err := apiTao.QueryStoreSKu(&request585.AlibabaWdkSkuQueryRequest{Param: &domain585.AlibabaWdkSkuQuerySkuQueryDo{
|
updateSkuList := make([]domain585.AlibabaWdkSkuUpdateSkuDo, 0, 0)
|
||||||
OuCode: storeCode1,
|
updateSku := domain585.AlibabaWdkSkuUpdateSkuDo{
|
||||||
SkuCodes: &skuCode,
|
OuCode: utils.String2Pointer(v),
|
||||||
}})
|
SkuCode: utils.String2Pointer("6108080"),
|
||||||
|
SkuPrice: utils.String2Pointer("0.1"), // 优先使用skuPrice 靠后SalePrice
|
||||||
|
}
|
||||||
|
updateSkuList = append(updateSkuList, updateSku)
|
||||||
|
param.ParamList = &updateSkuList
|
||||||
|
_, err := apiTao.UpdateStoreSku(param)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
data2 = append(data2, v)
|
fmt.Println(v)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
storeCode := *result
|
|
||||||
if len(storeCode) > 0 && utils.Str2Float64WithDefault(*storeCode[0].Model.SalePrice, 0) < 5 {
|
|
||||||
param := &request585.AlibabaWdkSkuUpdateRequest{}
|
|
||||||
updateSkuList := make([]domain585.AlibabaWdkSkuUpdateSkuDo, 0, 0)
|
|
||||||
updateSku := domain585.AlibabaWdkSkuUpdateSkuDo{
|
|
||||||
OuCode: storeCode1,
|
|
||||||
SkuCode: utils.String2Pointer(skuCode[0]),
|
|
||||||
SkuPrice: utils.String2Pointer(utils.Float64ToStr(utils.Str2Float64WithDefault(*storeCode[0].Model.SalePrice, 0) + 2)), // 优先使用skuPrice 靠后SalePrice
|
|
||||||
}
|
|
||||||
updateSkuList = append(updateSkuList, updateSku)
|
|
||||||
param.ParamList = &updateSkuList
|
|
||||||
_, err := apiTao.UpdateStoreSku(param)
|
|
||||||
if err != nil {
|
|
||||||
data2 = append(data2, v)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
globals.SugarLogger.Debugf("data2 :============ %s", utils.Format4Output(data2, false))
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品上下架
|
// 商品上下架
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// 京西速食(蔬菜)
|
// 京西速食(蔬菜)
|
||||||
var token1 = `{"access_token":"bbd3e475-2287-4498-9005-04efa541a24c","expires_in":1702502209,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"8dfa1c4a-153d-41a9-9fad-d9fcf2407cdf","authority_id":""}`
|
var token1 = `{"access_token":"11dc639e-d430-4523-884f-49f25b054e02","expires_in":1703705195,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"c5e48d77-9ab7-446e-90be-0af7ee797f7f","authority_id":""}`
|
||||||
|
|
||||||
// 美好菜市
|
// 美好菜市
|
||||||
//var token1 = `{"access_token":"9a315a03-c737-4a82-ae52-c9a6ce827007","expires_in":1699490747,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"8334c006-5301-4d25-911b-4d8cc7b70ebb","authority_id":""}`
|
//var token1 = `{"access_token":"9a315a03-c737-4a82-ae52-c9a6ce827007","expires_in":1699490747,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"8334c006-5301-4d25-911b-4d8cc7b70ebb","authority_id":""}`
|
||||||
@@ -19,7 +19,14 @@ var a = New("7267745202649957900", "51998fcf-d521-4553-8c0c-fa662c8dbd6e", token
|
|||||||
|
|
||||||
// 查询售后单详情
|
// 查询售后单详情
|
||||||
func TestAfsOrder(t *testing.T) {
|
func TestAfsOrder(t *testing.T) {
|
||||||
a.QueryAfsOrderDetail("6921428072500696298", true)
|
data, err := a.QueryAfsOrderDetail("146223529123133957", false)
|
||||||
|
globals.SugarLogger.Debugf("data=%s", utils.Format4Output(data, false))
|
||||||
|
globals.SugarLogger.Debugf("data=%s", err)
|
||||||
|
}
|
||||||
|
func TestAfsOrder2(t *testing.T) {
|
||||||
|
data, err := a.QueryAfsOrderDetail("146223488418888073", false)
|
||||||
|
globals.SugarLogger.Debugf("data=%s", utils.Format4Output(data, false))
|
||||||
|
globals.SugarLogger.Debugf("data=%s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同意/拒绝售后单
|
// 同意/拒绝售后单
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ func (a *API) OrderStatusAndPsInfoNew(param map[string]interface{}, vendorStoreI
|
|||||||
request.Param.DistributionCode = JxLogistics2Tiktok(param["logistics_provider_code"].(string))
|
request.Param.DistributionCode = JxLogistics2Tiktok(param["logistics_provider_code"].(string))
|
||||||
request.Param.RiderLatitude = utils.String2Pointer(param["latitude"].(string))
|
request.Param.RiderLatitude = utils.String2Pointer(param["latitude"].(string))
|
||||||
request.Param.RiderLongitude = utils.String2Pointer(param["longitude"].(string))
|
request.Param.RiderLongitude = utils.String2Pointer(param["longitude"].(string))
|
||||||
request.Param.DistributionDeliveryId = param["third_carrier_order_id"].(string)
|
request.Param.DistributionDeliveryId = param["order_id"].(string)
|
||||||
|
|
||||||
switch param["opcode"].(string) {
|
switch param["opcode"].(string) {
|
||||||
case TiktokLogisticsStatusCALLRIDER:
|
case TiktokLogisticsStatusCALLRIDER:
|
||||||
@@ -204,7 +204,7 @@ func (a *API) OrderStatusAndPsInfoNew(param map[string]interface{}, vendorStoreI
|
|||||||
logisticsEdit.Param = &order_logisticsEdit_request.OrderLogisticsEditParam{
|
logisticsEdit.Param = &order_logisticsEdit_request.OrderLogisticsEditParam{
|
||||||
OrderId: param["order_id"].(string),
|
OrderId: param["order_id"].(string),
|
||||||
CompanyCode: JxLogistics2Tiktok(param["logistics_provider_code"].(string)),
|
CompanyCode: JxLogistics2Tiktok(param["logistics_provider_code"].(string)),
|
||||||
LogisticsCode: param["third_carrier_order_id"].(string),
|
LogisticsCode: param["order_id"].(string),
|
||||||
StoreId: utils.Str2Int64(vendorStoreId),
|
StoreId: utils.Str2Int64(vendorStoreId),
|
||||||
}
|
}
|
||||||
logisticsData, err := logisticsEdit.Execute(a.accessTokenObj)
|
logisticsData, err := logisticsEdit.Execute(a.accessTokenObj)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package tiktok_api
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
brand_list_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/brand_list/request"
|
brand_list_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/brand_list/request"
|
||||||
order_batchSensitive_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchSensitive/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_GetRecommendCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_GetRecommendCategory/request"
|
||||||
@@ -304,6 +305,9 @@ func (a *API) GetSkuDetail(productId, outProductId string) (*product_detail_resp
|
|||||||
|
|
||||||
// GetSkuDetailLocalID 查询单个商品详情(这个只有京西平台商品id有效,查询到的商品可能为子商品也可能为主商品,主商品删除时,子商品和主商品状态不一致)
|
// GetSkuDetailLocalID 查询单个商品详情(这个只有京西平台商品id有效,查询到的商品可能为子商品也可能为主商品,主商品删除时,子商品和主商品状态不一致)
|
||||||
func (a *API) GetSkuDetailLocalID(vendorStoreId, outProductId string) (*product_detail_response.ProductDetailData, error) {
|
func (a *API) GetSkuDetailLocalID(vendorStoreId, outProductId string) (*product_detail_response.ProductDetailData, error) {
|
||||||
|
if vendorStoreId == "" && outProductId == "" {
|
||||||
|
return nil, fmt.Errorf("商品id和门店id不能为空")
|
||||||
|
}
|
||||||
request := product_detail_request_out.New()
|
request := product_detail_request_out.New()
|
||||||
param := request.GetParams()
|
param := request.GetParams()
|
||||||
param.OutProductId = outProductId
|
param.OutProductId = outProductId
|
||||||
@@ -692,8 +696,6 @@ func (a *API) CreateSubProduct(mainProductId int64, storeId int64) (int64, error
|
|||||||
request.Param.StoreId = storeId
|
request.Param.StoreId = storeId
|
||||||
|
|
||||||
result, err := request.Execute(a.accessTokenObj)
|
result, err := request.Execute(a.accessTokenObj)
|
||||||
globals.SugarLogger.Debugf("=========result := %s", utils.Format4Output(result, false))
|
|
||||||
globals.SugarLogger.Debugf("=========result := %s", utils.Format4Output(err, false))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ func (a *API) BatchUploadImages(imgs []Imgs) (map[string]material_batchUploadIma
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if result.Code != RequestSuccessCode {
|
if result.Code != RequestSuccessCode {
|
||||||
return nil, errors.New("==============logId" + result.LogId + ":" + result.SubMsg)
|
return nil, errors.New("logId" + result.LogId + ":" + result.SubMsg)
|
||||||
}
|
}
|
||||||
if len(result.Data.SuccessMap) > 0 {
|
if len(result.Data.SuccessMap) > 0 {
|
||||||
return result.Data.SuccessMap, nil
|
return result.Data.SuccessMap, nil
|
||||||
|
|||||||
@@ -430,7 +430,6 @@ func (a *API) GetWarehouseByStore(storeID int64) (*warehouse_getWarehouseByStore
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debugf("GetWarehouseByStore response=%s", utils.Format4Output(response, false))
|
|
||||||
if response.Code != RequestSuccessCode {
|
if response.Code != RequestSuccessCode {
|
||||||
globals.SugarLogger.Debugf("GetWarehouseByStore errMsg=%s", response.LogId+","+response.Msg+","+response.SubMsg)
|
globals.SugarLogger.Debugf("GetWarehouseByStore errMsg=%s", response.LogId+","+response.Msg+","+response.SubMsg)
|
||||||
return nil, errors.New(response.LogId + response.Msg + "," + response.SubMsg)
|
return nil, errors.New(response.LogId + response.Msg + "," + response.SubMsg)
|
||||||
|
|||||||
Reference in New Issue
Block a user