aa
This commit is contained in:
@@ -328,6 +328,7 @@ var (
|
||||
regexpJDStoreSkuPage = regexp.MustCompile(`共1/(.*)页`)
|
||||
regexpJDTbody = regexp.MustCompile(`<tbody>([\s\S]*?)</tbody>`)
|
||||
regexpJDTr = regexp.MustCompile(`<tr>([\s\S]*?)</tr>`)
|
||||
regexpJDTr2 = regexp.MustCompile(`<tr([\s\S]*?)</tr>`)
|
||||
regexpJDTdInfo = regexp.MustCompile(`<td>([\s\S]*?)</td>`)
|
||||
regexpJDSkuID = regexp.MustCompile(`sku编码:(.*)`)
|
||||
regexpJDSkuID2 = regexp.MustCompile(`<p>SKU编码:(.*)</p>`)
|
||||
@@ -336,11 +337,13 @@ var (
|
||||
regexpJDStoreLevel = regexp.MustCompile(`门店分级 :(.*);`)
|
||||
regexpJDSkuDirectPrice = regexp.MustCompile(`<td style="max-width: 80px">([\s\S]*?)</td>`)
|
||||
regexpJDStoreID = regexp.MustCompile(`<input class="storeInfoId" type="hidden" value="(.*?)"/>`)
|
||||
regexpAppID = regexp.MustCompile(`onClick="backcode\((.*)\)"`)
|
||||
htmlResponeURLs = []string{
|
||||
"login-o2o.jddj.com/jpuser/",
|
||||
"sta-store.jddj.com/store/",
|
||||
"pms-store.jddj.com/ware",
|
||||
"sta-store.jddj.com",
|
||||
"openo2o.jddj.com",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -382,6 +385,7 @@ func (a *API) AccessStorePage2(fullURL string, params map[string]interface{}, is
|
||||
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if params[KeyImgName] == nil {
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
request.Header.Set("accept", "application/json, text/javascript, */*; q=0.01")
|
||||
} else {
|
||||
var b bytes.Buffer
|
||||
w := multipart.NewWriter(&b)
|
||||
@@ -1184,3 +1188,63 @@ func (a *API) ToOnline() (err error) {
|
||||
_, err = a.AccessStorePage2("https://openo2o.jddj.com/sandBox/toOnline.htm", nil, true, "")
|
||||
return err
|
||||
}
|
||||
|
||||
//京东开放平台未授权回填验证码app的id
|
||||
func (a *API) GetJdNoAuthAppID(vendorOrgCode string) (data string, err error) {
|
||||
nameMap := make(map[string]string)
|
||||
result, err := a.AccessStorePage2("https://openo2o.jddj.com/xmanager/listAppBaseAndAuthNoAuth.htm", nil, false, "")
|
||||
if result != nil {
|
||||
tbody := regexpJDTbody.FindStringSubmatch(result.(string))
|
||||
trs := regexpJDTr2.FindAllStringSubmatch(tbody[1], -1)
|
||||
for _, v := range trs {
|
||||
tds := regexpJDTdInfo.FindAllStringSubmatch(v[1], -1)
|
||||
if len(tds) > 0 {
|
||||
if tds[3][1] != "" {
|
||||
if len(regexpAppID.FindStringSubmatch(tds[5][1])) > 0 {
|
||||
name := strings.Map(func(r rune) rune {
|
||||
switch r {
|
||||
case 0x000A, 0x000B, 0x000C, 0x000D, 0x0085, 0x2028, 0x2029:
|
||||
return -1
|
||||
default:
|
||||
return r
|
||||
}
|
||||
}, tds[3][1])
|
||||
nameMap[strings.ReplaceAll(name, "\t", "")] = regexpAppID.FindStringSubmatch(tds[5][1])[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if nameMap[vendorOrgCode] != "" {
|
||||
return nameMap[vendorOrgCode], err
|
||||
}
|
||||
return "", err
|
||||
}
|
||||
|
||||
type GetJdAppInfoResult struct {
|
||||
CallBackURL string `json:"callBackUrl"`
|
||||
OrgCode string `json:"orgCode"`
|
||||
AppKey string `json:"appKey"`
|
||||
AppSecret string `json:"appSecret"`
|
||||
IsShowUpdateBtn string `json:"isShowUpdateBtn"`
|
||||
IsIsv string `json:"isIsv"`
|
||||
IsShow string `json:"isShow"`
|
||||
}
|
||||
|
||||
func (a *API) GetJdAppInfo() (getJdAppInfoResult *GetJdAppInfoResult, err error) {
|
||||
result, err := a.AccessStorePage2("https://openo2o.jddj.com/xmanager/auto/app/appInfo.htm", nil, true, "")
|
||||
if err == nil {
|
||||
utils.Map2StructByJson(result.(map[string]interface{})["data"], &getJdAppInfoResult, false)
|
||||
}
|
||||
return getJdAppInfoResult, err
|
||||
}
|
||||
|
||||
// https://openo2o.jddj.com/xmanager/isv/appManage.htm
|
||||
|
||||
func (a *API) SetCode(code, jdAppID string) (err error) {
|
||||
_, err = a.AccessStorePage2("https://openo2o.jddj.com/xmanager/isv/app/accesstoken.htm", map[string]interface{}{
|
||||
"id": jdAppID,
|
||||
"code": code,
|
||||
}, true, "")
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user