京东置顶商品
This commit is contained in:
@@ -298,10 +298,12 @@ var (
|
||||
regexpTable = regexp.MustCompile(`<table class="check-container" data-container="list1">([\s\S]*?)</table>`)
|
||||
regexpTd = regexp.MustCompile(`<td>([0-9].*)</td>`)
|
||||
regexpJDUserPage = regexp.MustCompile(`共([\s\S].*)页/([\s\S].*)条记录`)
|
||||
regexpJDStoreSkuPage = regexp.MustCompile(`共1/(.*)页`)
|
||||
regexpJDTbody = regexp.MustCompile(`<tbody>([\s\S]*?)</tbody>`)
|
||||
regexpJDTr = regexp.MustCompile(`<tr>([\s\S]*?)</tr>`)
|
||||
regexpJDTdInfo = regexp.MustCompile(`<td>([\s\S]*?)</td>`)
|
||||
regexpJDSkuID = regexp.MustCompile(`sku编码:(.*)`)
|
||||
regexpJDSkuID2 = regexp.MustCompile(`<p>SKU编码:(.*)</p>`)
|
||||
regexpJDUserID = regexp.MustCompile(`value="(.*)"`)
|
||||
regexpJDUserIsManager = regexp.MustCompile(`<div class="list-mask">`)
|
||||
regexpJDStoreLevel = regexp.MustCompile(`门店分级 :(.*);`)
|
||||
@@ -1074,3 +1076,29 @@ func (a *API) GetJdShopOrders(orderStartTime, orderEndTime, orgCode, loginName s
|
||||
}
|
||||
return getJdShopOrdersResult, err
|
||||
}
|
||||
|
||||
//获取京东的置顶门店商品
|
||||
//https://stock-store.jddj.com/storeproduct/query
|
||||
func (a *API) GetJdTopSkus(vendorStoreID string) (vendorSkuIDs []string, totalCount int, err error) {
|
||||
jdParams := map[string]interface{}{
|
||||
"fixedStatus": 1,
|
||||
"stationNo": vendorStoreID,
|
||||
"numStatus": 0,
|
||||
"currentPage": 1,
|
||||
"pageSize": 10,
|
||||
}
|
||||
body, err := a.AccessStorePage2("https://stock-store.jddj.com/storeproduct/query", jdParams, true, "")
|
||||
if body != nil {
|
||||
bodyStr := body.(map[string]interface{})["fakeData"].(string)
|
||||
result := regexpJDStoreSkuPage.FindStringSubmatch(bodyStr)
|
||||
totalCount = utils.Str2Int(result[1])
|
||||
resultTr := regexpJDTr.FindAllStringSubmatch(bodyStr, -1)
|
||||
for _, v := range resultTr {
|
||||
resultSkuID := regexpJDSkuID2.FindStringSubmatch(v[1])
|
||||
if strings.Contains(v[1], "取消置顶") {
|
||||
vendorSkuIDs = append(vendorSkuIDs, resultSkuID[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
return vendorSkuIDs, totalCount, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user