修改门店
This commit is contained in:
@@ -21,6 +21,10 @@ const (
|
||||
JdsStoreImg = "http://image.jxc4.com/image/b90ae8585e8cf2f3871f6e8318bde1dc.tem.png"
|
||||
JdsStoreCategoryName = "pop-mendian-Selfdelivery"
|
||||
|
||||
JdsStoreStatusRest = 6
|
||||
JdsStoreStatusOnline = 1
|
||||
JdsStoreStatusDisable = 2
|
||||
|
||||
CreateCatType = "3"
|
||||
UpdateCatType = "1"
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ func init() {
|
||||
sugarLogger = logger.Sugar()
|
||||
baseapi.Init(sugarLogger)
|
||||
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||
api.SetCookie("thor", "80FAF09E9A09B6E618A68057BDFCFCB8B87C1706FE86F2E8F20251DD598C89ABC8F03DCAB3F5BE7A0CDD0F812D17258CA4603C28541A12C7183F098906F2EBD451175D5A5E341996FDBE3D23CA1D8B847A98C67F3533705D0757AFF57A4B0B4D1D6AD40D1E4AD9AF90E6BE6F807C2802DF5072847E20C96602C459A17166562FF47B9F01900825FF8EFE50C0FA08092F")
|
||||
api.SetCookie("thor", "80FAF09E9A09B6E618A68057BDFCFCB8A8C57DD560CF7359196563E623D38D86645912FA6F45288311E43F3C66E9B482E154A262CA6F647D9A7541EFD9D246A8391A25C4771B7AA6FCA60D3A745F62BD7903251BD5C9013167682D66528039829E46183AACE0BB4104BFB0D7FA948D689CAF9F13995067DAD9AE6B89E24DAB9E918504749B3331C8E2974A5C2994424D")
|
||||
}
|
||||
|
||||
@@ -21,8 +21,15 @@ type CreateEntityStoreParam struct {
|
||||
}
|
||||
|
||||
type UpdateEntityStoreParam struct {
|
||||
StoreID int `json:"storeId"` //门店ID(京东)
|
||||
CreateEntityStoreParam
|
||||
StoreID int `json:"storeId"` //门店ID(京东)
|
||||
Name string `json:"name,omitempty"` //是 门店名称
|
||||
AddCode int `json:"addCode,omitempty"` //是 门店三级标准地址编码(京东)
|
||||
AddCodeName string `json:"addCodeName,omitempty"` //否 门店三级标准地址名称(京东)
|
||||
AddName string `json:"addName,omitempty"` //是 标准地址加扩展地址以@!分隔 必填 例:北京大兴区亦庄经济开发区@!京东大厦
|
||||
Coordinate string `json:"coordinate,omitempty"` //是 门店坐标 纬度在前,经度在后 例:39.786683,116.563075
|
||||
Phone string `json:"phone,omitempty"` //是 门店电话
|
||||
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以内。
|
||||
}
|
||||
|
||||
type GetAddressCodeResult struct {
|
||||
|
||||
@@ -11,13 +11,18 @@ import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
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才能使用此方法")
|
||||
}
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
func() *http.Request {
|
||||
request, _ := http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(bizParams).Encode()))
|
||||
var request *http.Request
|
||||
if isPost {
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(bizParams).Encode()))
|
||||
} else {
|
||||
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(fullURL, "", bizParams), nil)
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
a.FillRequestCookies(request)
|
||||
return request
|
||||
@@ -56,6 +61,16 @@ func (a *API) CreateShopCategory(createShopCategoryParam []*CreateShopCategoryPa
|
||||
result, _ := json.MarshalIndent(createShopCategoryParam, "", "")
|
||||
_, err = a.AccessStorePage("https://seller.shop.jd.com/vendershop/vendershop_doShopCategory.action", map[string]interface{}{
|
||||
"categoryJson": string(result),
|
||||
})
|
||||
}, true)
|
||||
return err
|
||||
}
|
||||
|
||||
//京东商城设置门店营业状态
|
||||
//https://stores.shop.jd.com/stores/updateStoreStatus?storeId=24330156&storeStatus=6
|
||||
func (a *API) UpdateStoreStatus(storeID, storeStatus int) (err error) {
|
||||
_, err = a.AccessStorePage("https://stores.shop.jd.com/stores/updateStoreStatus", map[string]interface{}{
|
||||
"storeId": storeID,
|
||||
"storeStatus": storeStatus,
|
||||
}, false)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -18,3 +18,10 @@ func TestCreateShopCategory(t *testing.T) {
|
||||
}
|
||||
api.CreateShopCategory(CreateShopCategoryParams)
|
||||
}
|
||||
|
||||
func TestUpdateStoreStatus(t *testing.T) {
|
||||
err := api.UpdateStoreStatus(24330156, 6)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,17 @@ func TestCreateEntityStore(t *testing.T) {
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestUpdateEntityStore(t *testing.T) {
|
||||
err := api.UpdateEntityStore(&UpdateEntityStoreParam{
|
||||
StoreID: 24330156,
|
||||
Name: "京西菜市门店1",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestGetProvince(t *testing.T) {
|
||||
result, err := api.GetProvince()
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user