jds
This commit is contained in:
@@ -1139,3 +1139,12 @@ func (a *API) GetEbaiSku(upcID string, supplierID string) (ebaiSku *EbaiSku, err
|
||||
}
|
||||
return ebaiSku, err
|
||||
}
|
||||
|
||||
//饿百分享链接
|
||||
func (a *API) GetEbaiShopShareInfo() (err error) {
|
||||
_, err = a.AccessStorePage("commodity/getsku", "", nil, false)
|
||||
if err == nil {
|
||||
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package ebaiapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
@@ -179,3 +180,24 @@ func TestGetEbaiSku(t *testing.T) {
|
||||
result, _ := api.GetEbaiSku("1578500400097", EbaiWholeCountryStore)
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetEbaiShopShareInfo(t *testing.T) {
|
||||
req, err := http.NewRequest("GET", "https://kong.eleme.cn/h5/C3KHLTXHSEKQ3TGV?_ltraffic_share=clipboard", nil)
|
||||
req.Header.Set("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9")
|
||||
req.Header.Set("accept-encoding", "gzip, deflate, br")
|
||||
req.Header.Set("accept-language", "zh-CN,zh;q=0.9")
|
||||
req.Header.Set("sec-fetch-user", "?1")
|
||||
req.Header.Set("sec-fetch-dest", "document")
|
||||
req.Header.Set("sec-fetch-mode", "navigate")
|
||||
req.Header.Set("sec-fetch-site", "none")
|
||||
req.Header.Set("upgrade-insecure-requests", "1")
|
||||
req.Header.Set("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36")
|
||||
client := &http.Client{}
|
||||
res, err := client.Do(req)
|
||||
fmt.Println(res.Header)
|
||||
// err := api.GetEbaiShopShareInfo()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestQuerySingleOrder(t *testing.T) {
|
||||
retVal, err := api.QuerySingleOrder("921160248000222")
|
||||
retVal, err := api.QuerySingleOrder("2027681234000062")
|
||||
t.Log(utils.Format4Output(retVal, false))
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -36,6 +36,7 @@ const (
|
||||
UpdateCatType = "1"
|
||||
|
||||
VenderID = 10374877
|
||||
VendorID2 = 10569615
|
||||
TransportID = 2158480
|
||||
JxBrandId = 559853
|
||||
JdShopMaxStock = 9999
|
||||
|
||||
@@ -14,8 +14,9 @@ func init() {
|
||||
logger, _ := zap.NewDevelopment()
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||
// api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||
api = New("9ad9cf5fc8b140b19a1dbbb700b47676kown", "D5E8352BE0786ED16F77B4548F62F09A", "71e1061ac2f246f6ac27efb900edba12")
|
||||
api.SetCookieWithStr(`
|
||||
thor=00513FC363111586B2C0E065A90E33C1284E5BA68461D5ACC9B4830A54FE27F559AB1D4D2F6FBCD3F6FC99402F2C7C6CC65751CB0BB5AB39CBC12EFE762024EAFEC90B6F414373DDD6B07D72367A45E79C72A12A2B87F158020FA41387E6D34FF3BA71F33342994A47217C3D1C753CC79B6A98E8F78935F09D50A2AFDF34F666FAB9C0D159B6FCE72CAA929B8420F419;
|
||||
thor=5E1D1AE7BBC42FACA3496D9C54AF9F879CF4836860E75FF70BFCDEAC5A75C1C53633AB511CD9AA7FDDF502F48AE9683E660B3FCBF8EDC500734ADE8D7CE4BAB4B2947AD7610768EA07E5A6D3B88CDA3EBB7D998FEBA0B113F040A36B044CC4B9310C7953F2DDC2DE15C56C8839EFE493FE4CD8F9CECED7EE4097AE7F83EE6D447050842AB44A715BAB2666C6BE3AB085;
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ type CreateEntityStoreParam struct {
|
||||
Coordinate string `json:"coordinate"` //是 门店坐标 纬度在前,经度在后 例:39.786683,116.563075
|
||||
Phone string `json:"phone"` //是 门店电话
|
||||
// Item []int `json:"item"` //否 门店组ID
|
||||
CustomerID string `json:"customerId"` //否 商家门店Id,商家维度不可重复
|
||||
CategoryName string `json:"categoryName"` //否 门店扩展属性类目名称固定填为:popmendianSelfdelivery
|
||||
ExtendJSON string `json:"extendJson"` //是 扩展属性JSON如:{name1:'value1',name2:'value2'},营业时间必传固定json格式:{\'businessBeginTime\':\'09:00\',\'businessEndTime\':\'22:00\'}' ,可将中间的时间变更
|
||||
ImageFile string `json:"imageFile"` //否 门店图片,图片二进制文件流,允许png、jpg、gif、jpeg、bmp图片格式,1M以内。
|
||||
CustomerID string `json:"customerId"` //否 商家门店Id,商家维度不可重复
|
||||
CategoryName string `json:"categoryName,omitempty"` //否 门店扩展属性类目名称固定填为:popmendianSelfdelivery
|
||||
ExtendJSON string `json:"extendJson"` //是 扩展属性JSON如:{name1:'value1',name2:'value2'},营业时间必传固定json格式:{\'businessBeginTime\':\'09:00\',\'businessEndTime\':\'22:00\'}' ,可将中间的时间变更
|
||||
ImageFile string `json:"imageFile"` //否 门店图片,图片二进制文件流,允许png、jpg、gif、jpeg、bmp图片格式,1M以内。
|
||||
}
|
||||
|
||||
type UpdateEntityStoreParam struct {
|
||||
@@ -33,7 +33,7 @@ type UpdateEntityStoreParam struct {
|
||||
ExtendJSON string `json:"extendJson,omitempty"` //是 扩展属性JSON如:{name1:'value1',name2:'value2'},营业时间必传固定json格式:{\'businessBeginTime\':\'09:00\',\'businessEndTime\':\'22:00\'}' ,可将中间的时间变更
|
||||
ImageFile string `json:"imageFile,omitempty"` //否 门店图片,图片二进制文件流,允许png、jpg、gif、jpeg、bmp图片格式,1M以内。
|
||||
CustomerID string `json:"customerId,omitempty"` //否 商家门店Id,商家维度不可重复
|
||||
Status int `json:"status,omitempty"` //否 商家门店Id,商家维度不可重复
|
||||
CategoryID2 int `json:"categoryId2,omitempty"`
|
||||
}
|
||||
|
||||
type GetAddressCodeResult struct {
|
||||
|
||||
@@ -65,15 +65,20 @@ func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{},
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (a *API) AccessStorePage2(fullURL string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
func (a *API) AccessStorePage2(fullURL string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||
if a.GetCookieCount() == 0 {
|
||||
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
||||
}
|
||||
data, _ := json.Marshal(bizParams)
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
request, _ := http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data)))
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
var request *http.Request
|
||||
if isPost {
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(string(data)))
|
||||
request.Header.Set("Content-Type", "application/json;charset=UTF-8")
|
||||
} else {
|
||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(fullURL, "", bizParams), nil)
|
||||
}
|
||||
a.FillRequestCookies(request)
|
||||
return request
|
||||
},
|
||||
@@ -209,7 +214,7 @@ func (a *API) NewInfoList(storeID int64) (newInfoListResult *NewInfoListResult,
|
||||
"exStoreId": nil,
|
||||
"storeName": nil,
|
||||
"storeStatus": nil,
|
||||
})
|
||||
}, true)
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result["list"], &newInfoListResult2, false)
|
||||
}
|
||||
@@ -381,7 +386,7 @@ func (a *API) AllOrders(allOrdersParam *AllOrdersParam) (allOrdersResult *AllOrd
|
||||
// "storeId": allOrdersParam.StoreID,
|
||||
"orderStatusArray": allOrdersParam.OrderStatusArray,
|
||||
"orderId": allOrdersParam.OrderID,
|
||||
})
|
||||
}, true)
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result, &allOrdersResult, false)
|
||||
}
|
||||
@@ -477,7 +482,7 @@ func (a *API) UpdateWaybill(orderId, logiId, logiNo string) (err error) {
|
||||
"orderId": orderId,
|
||||
"globalOrder": false,
|
||||
"waybillList": waybiilList,
|
||||
})
|
||||
}, true)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -551,3 +556,129 @@ func (a *API) JdSSO() (err error) {
|
||||
_, err = a.AccessStorePage("https://sso.jd.com/setCookie?t=https://seller.shop.jd.com/seller/sellerinfo/seller_info.action&callback=https://seller.shop.jd.com/seller/sellerinfo/seller_info.action", nil, false)
|
||||
return err
|
||||
}
|
||||
|
||||
type UpdateBasicParam struct {
|
||||
Version string `json:"version"`
|
||||
Source string `json:"source"`
|
||||
RequestID int64 `json:"requestId"`
|
||||
StoreID int `json:"storeId"`
|
||||
StoreName string `json:"storeName"`
|
||||
CategoryID2 int `json:"categoryId2"`
|
||||
Lng string `json:"lng"`
|
||||
Lat string `json:"lat"`
|
||||
Coordinate string `json:"coordinate"`
|
||||
BussinessBeginTime string `json:"bussinessBeginTime"`
|
||||
BussinessEndTime string `json:"bussinessEndTime"`
|
||||
ImgURL string `json:"imgUrl"`
|
||||
StorePhone string `json:"storePhone"`
|
||||
AddName string `json:"addName"`
|
||||
AddCode1 int `json:"addCode1"`
|
||||
AddCode2 int `json:"addCode2"`
|
||||
AddCode3 int `json:"addCode3"`
|
||||
CategoryID1 int `json:"categoryId1"`
|
||||
QualificationRequests []*QualificationRequests `json:"qualificationRequests"`
|
||||
}
|
||||
|
||||
type QualificationRequests struct {
|
||||
QualificationID int `json:"qualificationId"`
|
||||
QualificationName string `json:"qualificationName"`
|
||||
Time []string `json:"time,omitempty"`
|
||||
StartTime string `json:"startTime,omitempty"`
|
||||
EndingTime string `json:"endingTime,omitempty"`
|
||||
QualificationNo string `json:"qualificationNo,omitempty"`
|
||||
QualificationURL string `json:"qualificationUrl,omitempty"`
|
||||
}
|
||||
|
||||
//更新门店信息
|
||||
//https://porder.shop.jd.com/order/orderlist/allOrders
|
||||
func (a *API) UpdateBasic(updateBasicParam *UpdateBasicParam) (err error) {
|
||||
reqID := time.Now().Unix()
|
||||
_, err = a.AccessStorePage2("https://o2o-stores.shop.jd.com/shop/updateBasic?version=1.0.0&source=pc&requestId="+utils.Int64ToStr(reqID), map[string]interface{}{
|
||||
"storeId": updateBasicParam.StoreID,
|
||||
"qualificationRequests": updateBasicParam.QualificationRequests,
|
||||
"storeName": updateBasicParam.StoreName,
|
||||
"categoryId2": updateBasicParam.CategoryID2,
|
||||
"lng": updateBasicParam.Lng,
|
||||
"lat": updateBasicParam.Lat,
|
||||
"coordinate": updateBasicParam.Coordinate,
|
||||
"bussinessBeginTime": updateBasicParam.BussinessBeginTime,
|
||||
"bussinessEndTime": updateBasicParam.BussinessEndTime,
|
||||
"imgUrl": updateBasicParam.ImgURL,
|
||||
"storePhone": updateBasicParam.StorePhone,
|
||||
"addName": updateBasicParam.AddName,
|
||||
"addCode1": updateBasicParam.AddCode1,
|
||||
"addCode2": updateBasicParam.AddCode2,
|
||||
"addCode3": updateBasicParam.AddCode3,
|
||||
"categoryId1": updateBasicParam.CategoryID1,
|
||||
"version": "1.0.0",
|
||||
"source": "pc",
|
||||
"requestId": reqID,
|
||||
}, true)
|
||||
return err
|
||||
}
|
||||
|
||||
type ShopDetailResult struct {
|
||||
StoreID int `json:"storeId"`
|
||||
StoreName string `json:"storeName"`
|
||||
CategoryID2 int `json:"categoryId2"`
|
||||
Coordinate string `json:"coordinate"`
|
||||
BussinessBeginTime string `json:"bussinessBeginTime"`
|
||||
BussinessEndTime string `json:"bussinessEndTime"`
|
||||
ImgURL string `json:"imgUrl"`
|
||||
Slogan interface{} `json:"slogan"`
|
||||
StorePhone string `json:"storePhone"`
|
||||
CustomerPhone interface{} `json:"customerPhone"`
|
||||
StoreMobile interface{} `json:"storeMobile"`
|
||||
AddCode1 int `json:"addCode1"`
|
||||
AddCode2 int `json:"addCode2"`
|
||||
AddCode3 int `json:"addCode3"`
|
||||
AddCode4 int `json:"addCode4"`
|
||||
AddName string `json:"addName"`
|
||||
QualificationInfoTOList []struct {
|
||||
QualificationID int `json:"qualificationId"`
|
||||
QualificationNo string `json:"qualificationNo"`
|
||||
QualificationName string `json:"qualificationName"`
|
||||
StartTime string `json:"startTime"`
|
||||
EndingTime string `json:"endingTime"`
|
||||
QualificationURL string `json:"qualificationUrl"`
|
||||
} `json:"qualificationInfoTOList"`
|
||||
Created string `json:"created"`
|
||||
Modified string `json:"modified"`
|
||||
FlowID int `json:"flowId"`
|
||||
CategoryID1 int `json:"categoryId1"`
|
||||
CategoryName1 string `json:"categoryName1"`
|
||||
CategoryName2 interface{} `json:"categoryName2"`
|
||||
AuditTime interface{} `json:"auditTime"`
|
||||
}
|
||||
|
||||
//查询门店信息
|
||||
//https://porder.shop.jd.com/order/orderlist/allOrders
|
||||
func (a *API) ShopDetail(storeID int) (shopDetailResult *ShopDetailResult, err error) {
|
||||
reqID := time.Now().Unix()
|
||||
result, err := a.AccessStorePage2("https://o2o-stores.shop.jd.com/shop/detail", map[string]interface{}{
|
||||
"t": reqID,
|
||||
"storeId": storeID,
|
||||
"version": "1.0.0",
|
||||
"source": "pc",
|
||||
"requestId": reqID,
|
||||
}, false)
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result["data"], &shopDetailResult, false)
|
||||
}
|
||||
return shopDetailResult, err
|
||||
}
|
||||
|
||||
//更新门店起送等
|
||||
//https://porder.shop.jd.com/order/orderlist/allOrders
|
||||
func (a *API) UpdateExpand(storeID int) (err error) {
|
||||
reqID := time.Now().Unix()
|
||||
_, err = a.AccessStorePage2("https://o2o-stores.shop.jd.com/shop/updateExpand?version=1.0.0&source=pc&requestId="+utils.Int64ToStr(reqID), map[string]interface{}{
|
||||
"storeId": storeID,
|
||||
"deliveryPrice": 10,
|
||||
"weightLimit": 30,
|
||||
"version": "1.0.0",
|
||||
"source": "pc",
|
||||
"requestId": reqID,
|
||||
}, true)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ func TestCreateShopCategory(t *testing.T) {
|
||||
var CreateShopCategoryParams = []*CreateShopCategoryParam{
|
||||
&CreateShopCategoryParam{
|
||||
HomeShow: "0",
|
||||
ID: "0",
|
||||
ID: "1",
|
||||
Open: "",
|
||||
OrderNo: "0",
|
||||
ParentID: "",
|
||||
@@ -132,3 +132,54 @@ func PKCS5UnPadding(decrypted []byte) []byte {
|
||||
unPadding := int(decrypted[length-1])
|
||||
return decrypted[:(length - unPadding)]
|
||||
}
|
||||
|
||||
func TestShopDetail(t *testing.T) {
|
||||
result, err := api.ShopDetail(24562992)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestUpdateBasic(t *testing.T) {
|
||||
err := api.UpdateBasic(&UpdateBasicParam{
|
||||
StoreID: 24562992,
|
||||
StoreName: "京西菜市温江旗舰生鲜店",
|
||||
CategoryID2: 62,
|
||||
Lng: "103.858781",
|
||||
Lat: "30.692941",
|
||||
Coordinate: "30.692941,103.858781",
|
||||
BussinessBeginTime: "08:30",
|
||||
BussinessEndTime: "20:00",
|
||||
ImgURL: "jfs/t1/141918/10/14803/148865/5fb4e8cbE95a606cb/08a8dc277eb97a16.png",
|
||||
StorePhone: "13706546496",
|
||||
AddName: "四川成都市温江区@!温江区锦泉街116号(优取舍)",
|
||||
AddCode1: 22,
|
||||
AddCode2: 1930,
|
||||
AddCode3: 49315,
|
||||
CategoryID1: 34,
|
||||
QualificationRequests: []*QualificationRequests{
|
||||
&QualificationRequests{
|
||||
QualificationID: 41,
|
||||
QualificationName: "营业执照",
|
||||
QualificationNo: "11111",
|
||||
QualificationURL: "jfs/t1/148622/37/14846/10266/5fb4e3e2Ef2f61870/a7cfba9c1513d95e.png",
|
||||
StartTime: "2020-11-04 00:00:00",
|
||||
EndingTime: "2020-11-06 23:59:59",
|
||||
Time: []string{"2020-11-04 00:00:00", "2020-11-06 23:59:59"},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestUpdateExpand(t *testing.T) {
|
||||
err := api.UpdateExpand(24562992)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
@@ -13,16 +13,17 @@ import (
|
||||
func TestCreateEntityStore(t *testing.T) {
|
||||
data, _, err := DownloadFileByURL("http://image.jxc4.com/image/b90ae8585e8cf2f3871f6e8318bde1dc.tem.png")
|
||||
result, err := api.CreateEntityStore(&CreateEntityStoreParam{
|
||||
Name: "京西菜市门店1",
|
||||
AddCode: 50946,
|
||||
AddCodeName: "金牛区",
|
||||
AddName: "成都金牛区@!加州湾v派",
|
||||
Coordinate: "29.707870,115.980868",
|
||||
Phone: "18160030913",
|
||||
ExtendJSON: `{"businessBeginTime":"9:00","businessEndTime":"22:00"}`,
|
||||
ImageFile: base64.StdEncoding.EncodeToString(data),
|
||||
CategoryName: "pop-mendian-Selfdelivery",
|
||||
CustomerID: "666934",
|
||||
Name: "京西菜市门店1",
|
||||
AddCode: 50946,
|
||||
AddCodeName: "金牛区",
|
||||
AddName: "成都金牛区@!加州湾v派",
|
||||
Coordinate: "29.707870,115.980868",
|
||||
Phone: "18160030913",
|
||||
ExtendJSON: `{"businessBeginTime":"9:00","businessEndTime":"22:00"}`,
|
||||
ImageFile: base64.StdEncoding.EncodeToString(data),
|
||||
// CategoryName: "生鲜店",
|
||||
CustomerID: "666934",
|
||||
// CategoryID2: 62,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -30,10 +31,25 @@ func TestCreateEntityStore(t *testing.T) {
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestDeleteStoresByID(t *testing.T) {
|
||||
err := api.DeleteStoresByID(24562344)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestUpdateEntityStore(t *testing.T) {
|
||||
err := api.UpdateEntityStore(&UpdateEntityStoreParam{
|
||||
StoreID: 24339354,
|
||||
Status: 6,
|
||||
data, _, err := DownloadFileByURL("http://image.jxc4.com/image/b90ae8585e8cf2f3871f6e8318bde1dc.tem.png")
|
||||
err = api.UpdateEntityStore(&UpdateEntityStoreParam{
|
||||
StoreID: 24562221,
|
||||
Name: "京西菜市门店1",
|
||||
AddCode: 50946,
|
||||
AddName: "成都金牛区@!加州湾v派",
|
||||
ExtendJSON: `{"businessBeginTime":"9:00","businessEndTime":"22:00"}`,
|
||||
Phone: "18160030913",
|
||||
ImageFile: base64.StdEncoding.EncodeToString(data),
|
||||
CategoryID2: 62,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -22,7 +22,7 @@ func TestPoiGetIDs(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPoiMGet(t *testing.T) {
|
||||
result, err := api.PoiMGet([]string{"2461723"})
|
||||
result, err := api.PoiMGet([]string{"10414069"})
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user