京东商城店内分类修改
This commit is contained in:
@@ -85,7 +85,7 @@ func TestGetDistricts(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestGetCoordinateFromAddress(t *testing.T) {
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("天府广场", "成都市")
|
||||
lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("辽宁铁岭市铁岭县凡河新区3区3号楼4单元301", "")
|
||||
t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ func TestBatchWalkingDistance(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestAA(t *testing.T) {
|
||||
result, err := autonaviAPI.GetCoordinateAreaInfo(116.331471, 39.909837)
|
||||
result, err := autonaviAPI.GetCoordinateAreaInfo(123.715455, 42.221651)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,6 @@ func init() {
|
||||
baseapi.Init(sugarLogger)
|
||||
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||
api.SetCookieWithStr(`
|
||||
thor=80FAF09E9A09B6E618A68057BDFCFCB83C345398FC0EA96BB93E21F628E09F69ABC4812E3C973FC424A9790F0EFBB575F0B38D3D40ED8C7FE094307204922296A626E5E990526A84EEA9E1F52BE923D06899DA48B400EBFCDB1F7934C84EAE4AA0D9454C7173B79CE6780DC12463FF8101D2D81F1975356E1E062C3B7A5EA9CF6DB6EFEF59F75691F88E2E044ADA79EF;
|
||||
thor=80FAF09E9A09B6E618A68057BDFCFCB88A0E4CE7743FBEC84F10D992F9C6A4119DF98DA3CAAE9C7F17BEB62884625B4E7BC82422A90F45F02EA293572D951B055EF0B5F603AEA568DFD4234138F841EC1AC1F67B30B48AAC9EAD5FBAE7943E1DCC99E99D8358C82F7832B71A2BCB31624E16BBF561720443DE966BDA3588406233A90224D9089710B102AA98B979B9B3;
|
||||
`)
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package jdshopapi
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
//查询单个订单
|
||||
//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=2389&apiName=jingdong.pop.order.enGet
|
||||
func (a *API) EnGet(orderID int64) (err error) {
|
||||
dataMap := map[string]interface{}{
|
||||
"order_id": orderID,
|
||||
"optional_fields": "orderType,payType",
|
||||
}
|
||||
data, _ := json.Marshal(dataMap)
|
||||
_, err = a.AccessAPI("jingdong.pop.order.enGet", prodURL, map[string]interface{}{
|
||||
"360buy_param_json": string(data),
|
||||
// dataMap := map[string]interface{}{
|
||||
// "order_id": orderID,
|
||||
// "optional_fields": "orderType,payType",
|
||||
// }
|
||||
// data, _ := json.Marshal(dataMap)
|
||||
_, err = a.AccessAPI("jingdong.pop.order.shipment", prodURL, map[string]interface{}{
|
||||
"orderId": orderID,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ type UpdateWareParam struct {
|
||||
MobileDesc string `json:"mobileDesc"` // 是 无 移动版的商品介绍 长度限制10W个字符
|
||||
Introduction string `json:"introduction"` // 是 无 PC版的商品介绍 长度限制10W个字符
|
||||
Features []*CreateSkuParamFeatures `json:"features"` // 否 无 商品维度的特殊属性 目前两个特殊属性 IBS、FBP、FCS、SCF 4种商家类型【规格型号】 model和【销售单位】 unit 字段且为必填(如 个、盒、袋等)请勿填写公司名称。
|
||||
// ExtendFeatures []*CreateSkuParamFeatures `json:"extendFeatures"` // 否 无 商品维度的特殊属性 目前两个特殊属性 IBS、FBP、FCS、SCF 4种商家类型【规格型号】 model和【销售单位】 unit 字段且为必填(如 个、盒、袋等)请勿填写公司名称。
|
||||
}
|
||||
|
||||
type QueryPictureReuslt struct {
|
||||
|
||||
@@ -273,9 +273,14 @@ func TestUpOrDown(t *testing.T) {
|
||||
|
||||
func TestUpdateWare(t *testing.T) {
|
||||
err := api.UpdateWare(&UpdateWareParam{
|
||||
WareID: 14521014949,
|
||||
Title: "大青菜1",
|
||||
VenderID: 10374877,
|
||||
WareID: 14545996691,
|
||||
Title: "进口凤梨",
|
||||
Features: []*CreateSkuParamFeatures{
|
||||
&CreateSkuParamFeatures{
|
||||
Key: "fdms",
|
||||
Value: "1",
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
@@ -11,6 +12,11 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
regexpOrderDetailTable = regexp.MustCompile(`<table id="receiveData">([\s\S]*?)</table>`)
|
||||
regexpOrderDetailTd = regexp.MustCompile(`<td colspan="2">(.*?)</td>`)
|
||||
)
|
||||
|
||||
func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||
if a.GetCookieCount() == 0 {
|
||||
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
||||
@@ -65,6 +71,9 @@ func (a *API) AccessStorePage2(fullURL string, bizParams map[string]interface{})
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
if strings.Contains(bodyStr, "登录") {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!")
|
||||
}
|
||||
if err == nil {
|
||||
if jsonResult1["error_response"] != nil {
|
||||
errLevel = platformapi.ErrLevelGeneralFail
|
||||
@@ -90,12 +99,15 @@ type CreateShopCategoryParam struct {
|
||||
|
||||
//京东商城创建或修改店内分类
|
||||
//https://seller.shop.jd.com/vendershop/vendershop_shopCategory.action#
|
||||
func (a *API) CreateShopCategory(createShopCategoryParam []*CreateShopCategoryParam) (err error) {
|
||||
result, _ := json.MarshalIndent(createShopCategoryParam, "", "")
|
||||
_, err = a.AccessStorePage("https://seller.shop.jd.com/vendershop/vendershop_doShopCategory.action", map[string]interface{}{
|
||||
"categoryJson": string(result),
|
||||
func (a *API) CreateShopCategory(createShopCategoryParam []*CreateShopCategoryParam) (status int64, err error) {
|
||||
data, _ := json.MarshalIndent(createShopCategoryParam, "", "")
|
||||
result, err := a.AccessStorePage("https://seller.shop.jd.com/vendershop/vendershop_doShopCategory.action", map[string]interface{}{
|
||||
"categoryJson": string(data),
|
||||
}, true)
|
||||
return err
|
||||
if err == nil {
|
||||
status = utils.Interface2Int64WithDefault(result["fakeData"], -1)
|
||||
}
|
||||
return status, err
|
||||
}
|
||||
|
||||
//京东商城设置门店营业状态
|
||||
@@ -350,13 +362,37 @@ type AllOrdersResult struct {
|
||||
//https://porder.shop.jd.com/order/orderlist/allOrders
|
||||
func (a *API) AllOrders(allOrdersParam *AllOrdersParam) (allOrdersResult *AllOrdersResult, err error) {
|
||||
result, err := a.AccessStorePage2("https://porder.shop.jd.com/order/orderlist", map[string]interface{}{
|
||||
"current": allOrdersParam.Current,
|
||||
"pageSize": allOrdersParam.PageSize,
|
||||
"selectedTabName": "allOrders",
|
||||
"sortName": "desc",
|
||||
"current": allOrdersParam.Current,
|
||||
"pageSize": allOrdersParam.PageSize,
|
||||
"selectedTabName": "allOrders",
|
||||
"sortName": "desc",
|
||||
"orderCreateDateRange": allOrdersParam.OrderCreateDateRange,
|
||||
// "storeId": allOrdersParam.StoreID,
|
||||
"orderStatusArray": allOrdersParam.OrderStatusArray,
|
||||
})
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result, &allOrdersResult, false)
|
||||
}
|
||||
return allOrdersResult, err
|
||||
}
|
||||
|
||||
//订单详情
|
||||
//https://neworder.shop.jd.com/order/orderDetail?orderId=122367441996
|
||||
func (a *API) OrderDetail(orderId string) (consigneeName, consigneeAddress string, err error) {
|
||||
result, err := a.AccessStorePage("https://neworder.shop.jd.com/order/orderDetail", map[string]interface{}{
|
||||
"orderId": orderId,
|
||||
}, false)
|
||||
if err == nil {
|
||||
body := result["fakeData"].(string)
|
||||
consigneeTable := regexpOrderDetailTable.FindStringSubmatch(body)
|
||||
fmt.Println("test1", consigneeTable)
|
||||
if len(consigneeTable) > 0 {
|
||||
consigneeTd := regexpOrderDetailTd.FindAllStringSubmatch(consigneeTable[1], -1)
|
||||
if len(consigneeTd) > 0 {
|
||||
consigneeName = consigneeTd[0][1]
|
||||
consigneeAddress = consigneeTd[1][1]
|
||||
}
|
||||
}
|
||||
}
|
||||
return consigneeName, consigneeAddress, err
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ func TestCreateShopCategory(t *testing.T) {
|
||||
Type: "3",
|
||||
},
|
||||
}
|
||||
api.CreateShopCategory(CreateShopCategoryParams)
|
||||
result, _ := api.CreateShopCategory(CreateShopCategoryParams)
|
||||
fmt.Println(result)
|
||||
}
|
||||
|
||||
func TestUpdateStoreStatus(t *testing.T) {
|
||||
@@ -40,10 +41,10 @@ func TestNewInfoList(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test11(t *testing.T) {
|
||||
request, _ := http.NewRequest(http.MethodGet, "https://stores.shop.jd.com/stores/updateStoreStatus?storeId=24332466&storeStatus=1", nil)
|
||||
request, _ := http.NewRequest(http.MethodGet, "https://stores.shop.jd.com/stores/updateStoreStatus?storeId=24339301&storeStatus=1", nil)
|
||||
c := &http.Cookie{
|
||||
Name: "thor",
|
||||
Value: "80FAF09E9A09B6E618A68057BDFCFCB8C86E8252DC9F7D3B34572625904FBA0AB6BF053A5325612EC0407791BB05F5301356E71E8B282C40C06D0B5DF3439DEECB102A78FAFF7AC0FC4E2D1FA8DD8BBAE1A011E50B5C74F1870AD982D7BF453F470F31F2241B73AC4C25485025C2ABEBC8A538AF7257824D2FAEE300A1435175B0B451FB5C19B78D729FC83152CA3BAF",
|
||||
Value: "80FAF09E9A09B6E618A68057BDFCFCB88A0E4CE7743FBEC84F10D992F9C6A4119DF98DA3CAAE9C7F17BEB62884625B4E7BC82422A90F45F02EA293572D951B055EF0B5F603AEA568DFD4234138F841EC1AC1F67B30B48AAC9EAD5FBAE7943E1DCC99E99D8358C82F7832B71A2BCB31624E16BBF561720443DE966BDA3588406233A90224D9089710B102AA98B979B9B3",
|
||||
}
|
||||
request.AddCookie(c)
|
||||
client := &http.Client{}
|
||||
@@ -58,9 +59,18 @@ func TestAllOrders(t *testing.T) {
|
||||
result, err := api.AllOrders(&AllOrdersParam{
|
||||
Current: 1,
|
||||
PageSize: 10,
|
||||
StoreID: "24339648",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestOrderDetail(t *testing.T) {
|
||||
result1, result2, err := api.OrderDetail("122367441996")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
fmt.Println("test1", result1, result2)
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestGetCounty(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFindSkuSiteStock(t *testing.T) {
|
||||
result, err := api.FindSkuSiteStock(24340329, 69353633443)
|
||||
result, err := api.FindSkuSiteStock(24339305, 69353498265)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user