京东修改门店状态无效,临时修改
This commit is contained in:
@@ -338,6 +338,15 @@ func (a *API) UpdateStoreInfo4Open2(updateParams *OpStoreParams, modifyCloseStat
|
|||||||
mapData := utils.Struct2MapByJson(updateParams)
|
mapData := utils.Struct2MapByJson(updateParams)
|
||||||
if !modifyCloseStatus {
|
if !modifyCloseStatus {
|
||||||
delete(mapData, "closeStatus")
|
delete(mapData, "closeStatus")
|
||||||
|
} else {
|
||||||
|
jdStoreID, err := a.GetJdStoreID(int(utils.Str2Int64(updateParams.OutSystemID)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = a.UpdateClosetStatus(jdStoreID, updateParams.CloseStatus)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if updateParams.ServiceTimeStart1 == 0 && updateParams.ServiceTimeEnd1 == 0 {
|
if updateParams.ServiceTimeStart1 == 0 && updateParams.ServiceTimeEnd1 == 0 {
|
||||||
delete(mapData, "serviceTimeStart1")
|
delete(mapData, "serviceTimeStart1")
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ const (
|
|||||||
AccessStorePageCookieName2 = "lsp-store1.jddj.com"
|
AccessStorePageCookieName2 = "lsp-store1.jddj.com"
|
||||||
accessStorePageCookieName3 = "josl-privilege1.jddj.com"
|
accessStorePageCookieName3 = "josl-privilege1.jddj.com"
|
||||||
accessStorePageCookieName4 = "o2o-stock1.jddj.com"
|
accessStorePageCookieName4 = "o2o-stock1.jddj.com"
|
||||||
|
accessStorePageCookieName5 = "sta-store.jddj.com"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SkuPageImg struct {
|
type SkuPageImg struct {
|
||||||
@@ -305,10 +306,12 @@ var (
|
|||||||
regexpJDUserIsManager = regexp.MustCompile(`<div class="list-mask">`)
|
regexpJDUserIsManager = regexp.MustCompile(`<div class="list-mask">`)
|
||||||
regexpJDStoreLevel = regexp.MustCompile(`门店分级 :(.*);`)
|
regexpJDStoreLevel = regexp.MustCompile(`门店分级 :(.*);`)
|
||||||
regexpJDSkuDirectPrice = regexp.MustCompile(`<td style="max-width: 80px">([\s\S]*?)</td>`)
|
regexpJDSkuDirectPrice = regexp.MustCompile(`<td style="max-width: 80px">([\s\S]*?)</td>`)
|
||||||
|
regexpJDStoreID = regexp.MustCompile(`<input class="storeInfoId" type="hidden" value="(.*?)"/>`)
|
||||||
htmlResponeURLs = []string{
|
htmlResponeURLs = []string{
|
||||||
"login-o2o.jddj.com/jpuser/",
|
"login-o2o.jddj.com/jpuser/",
|
||||||
"sta-store.jddj.com/store/",
|
"sta-store.jddj.com/store/",
|
||||||
"pms-store.jddj.com/ware",
|
"pms-store.jddj.com/ware",
|
||||||
|
"sta-store.jddj.com",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -329,6 +332,8 @@ func (a *API) SetJdCookie(cookieValue string) {
|
|||||||
a.SetCookie(AccessStorePageCookieName2, cookieValue)
|
a.SetCookie(AccessStorePageCookieName2, cookieValue)
|
||||||
a.SetCookie(accessStorePageCookieName3, cookieValue)
|
a.SetCookie(accessStorePageCookieName3, cookieValue)
|
||||||
a.SetCookie(accessStorePageCookieName4, cookieValue)
|
a.SetCookie(accessStorePageCookieName4, cookieValue)
|
||||||
|
a.SetCookie(accessStorePageCookieName5, cookieValue)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) AccessStorePage2(fullURL string, params map[string]interface{}, isPost bool, resultKey string) (retVal interface{}, err error) {
|
func (a *API) AccessStorePage2(fullURL string, params map[string]interface{}, isPost bool, resultKey string) (retVal interface{}, err error) {
|
||||||
@@ -905,3 +910,35 @@ func (a *API) SearchDeleteWare(deleteTimeStart, deleteTimeEnd string, page, page
|
|||||||
}
|
}
|
||||||
return searchDeleteWareResults, err
|
return searchDeleteWareResults, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取京东的门店信息(内部id)
|
||||||
|
//https://sta-store.jddj.com/store/query
|
||||||
|
func (a *API) GetJdStoreID(storeID int) (jdStoreID int, err error) {
|
||||||
|
jdParams := map[string]interface{}{
|
||||||
|
"outSystemId": storeID,
|
||||||
|
"pageSize": 10,
|
||||||
|
}
|
||||||
|
body, err := a.AccessStorePage2("https://sta-store.jddj.com/store/query", jdParams, true, "")
|
||||||
|
if body != nil {
|
||||||
|
result := regexpJDStoreID.FindStringSubmatch(body.(string))
|
||||||
|
if len(result) > 0 {
|
||||||
|
if result[1] != "" {
|
||||||
|
return int(utils.Str2Int64(result[1])), err
|
||||||
|
} else {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
|
||||||
|
//更新京东门店营业状态
|
||||||
|
//https://sta-store.jddj.com/store/updateClosetStatus
|
||||||
|
func (a *API) UpdateClosetStatus(jdStoreID, closeStatus int) (err error) {
|
||||||
|
jdParams := map[string]interface{}{
|
||||||
|
"id": jdStoreID,
|
||||||
|
"closeStatus": closeStatus,
|
||||||
|
}
|
||||||
|
_, err = a.AccessStorePage2("https://sta-store.jddj.com/store/updateClosetStatus", jdParams, true, "")
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -254,3 +254,13 @@ func TestSearchDeleteWare(t *testing.T) {
|
|||||||
}
|
}
|
||||||
fmt.Println(utils.Format4Output(searchResults, false))
|
fmt.Println(utils.Format4Output(searchResults, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetJdStoreID(t *testing.T) {
|
||||||
|
result, err := api.GetJdStoreID(801246)
|
||||||
|
fmt.Println("test1", result, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestUpdateClosetStatus(t *testing.T) {
|
||||||
|
err := api.UpdateClosetStatus(801246, 1)
|
||||||
|
fmt.Println("test1", err)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user