Merge branch 'master' of e.coding.net:rosydev/baseapi

This commit is contained in:
苏尹岚
2020-05-08 09:41:04 +08:00
3 changed files with 57 additions and 0 deletions

View File

@@ -339,6 +339,16 @@ func (a *API) UpdateStoreInfo4Open2(updateParams *OpStoreParams, modifyCloseStat
if !modifyCloseStatus {
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 {
delete(mapData, "serviceTimeStart1")
delete(mapData, "serviceTimeEnd1")

View File

@@ -22,6 +22,7 @@ const (
AccessStorePageCookieName2 = "lsp-store1.jddj.com"
accessStorePageCookieName3 = "josl-privilege1.jddj.com"
accessStorePageCookieName4 = "o2o-stock1.jddj.com"
accessStorePageCookieName5 = "sta-store.jddj.com"
)
type SkuPageImg struct {
@@ -305,10 +306,12 @@ var (
regexpJDUserIsManager = regexp.MustCompile(`<div class="list-mask">`)
regexpJDStoreLevel = regexp.MustCompile(`门店分级 (.*)`)
regexpJDSkuDirectPrice = regexp.MustCompile(`<td style="max-width: 80px">([\s\S]*?)</td>`)
regexpJDStoreID = regexp.MustCompile(`<input class="storeInfoId" type="hidden" value="(.*?)"/>`)
htmlResponeURLs = []string{
"login-o2o.jddj.com/jpuser/",
"sta-store.jddj.com/store/",
"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(accessStorePageCookieName3, 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) {
@@ -905,3 +910,35 @@ func (a *API) SearchDeleteWare(deleteTimeStart, deleteTimeEnd string, page, page
}
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
}

View File

@@ -254,3 +254,13 @@ func TestSearchDeleteWare(t *testing.T) {
}
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)
}