From 2cf9d698fd1c1dda3ac56bf6649f3f0caabd5436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 26 May 2020 08:50:36 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=9D=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/autonavi/autonavi_test.go | 10 ++++++++- platformapi/jdshopapi/callback.go | 31 +++++++++++++++++++++++++++ platformapi/jdshopapi/sku_test.go | 28 ++++++++++++++++++++++-- platformapi/jdshopapi/store.go | 3 ++- platformapi/jdshopapi/store_test.go | 14 ++++++------ 5 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 platformapi/jdshopapi/callback.go diff --git a/platformapi/autonavi/autonavi_test.go b/platformapi/autonavi/autonavi_test.go index cac5cc94..465b9acd 100644 --- a/platformapi/autonavi/autonavi_test.go +++ b/platformapi/autonavi/autonavi_test.go @@ -74,7 +74,7 @@ func TestGetCoordinateTownInfo(t *testing.T) { } func TestGetDistricts(t *testing.T) { - districtList, err := autonaviAPI.GetDistricts(4, "常熟市") + districtList, err := autonaviAPI.GetDistricts(4, "成都") if err != nil { t.Fatal(err) } @@ -149,3 +149,11 @@ func TestBatchWalkingDistance(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestAA(t *testing.T) { + result, err := autonaviAPI.GetCoordinateAreaInfo(116.331471, 39.909837) + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +} diff --git a/platformapi/jdshopapi/callback.go b/platformapi/jdshopapi/callback.go new file mode 100644 index 00000000..f03f3492 --- /dev/null +++ b/platformapi/jdshopapi/callback.go @@ -0,0 +1,31 @@ +package jdshopapi + +import ( + "io/ioutil" + "net/http" + + "git.rosy.net.cn/baseapi/utils" +) + +type CallBackResult struct { + OrderCreateTime string `json:"orderCreateTime"` + OrderType string `json:"orderType"` + OrderPaymentType string `json:"orderPaymentType"` + VenderID string `json:"venderId"` + OrderStatus string `json:"orderStatus"` + OrderID string `json:"orderId"` +} + +func (a *API) GetCallbackMsg(request *http.Request) (call *CallBackResult, err error) { + data, err := ioutil.ReadAll(request.Body) + if err != nil { + return nil, err + } + values, err := utils.HTTPBody2Values(data, false) + if err != nil { + return nil, err + } + mapData := utils.URLValues2Map(values) + utils.Map2StructByJson(mapData, &call, false) + return call, err +} diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index abbec81d..4f2dcd76 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -10,6 +10,7 @@ import ( "image/jpeg" "image/png" "io/ioutil" + "math" "net/http" "testing" @@ -283,7 +284,7 @@ func TestUpdateWare(t *testing.T) { } func TestFindSkuStock(t *testing.T) { - err := api.FindSkuStock(69411607059) + err := api.FindSkuStock(69353673334) if err != nil { t.Fatal(err) } @@ -307,7 +308,7 @@ func TestImageUpdate(t *testing.T) { } func TestSearchWare4Valid(t *testing.T) { - result, err := api.SearchWare4Valid("红薯", 0, 0) + result, err := api.SearchWare4Valid("猕猴桃 奇异果", 0, 0) if err != nil { t.Fatal(err) } @@ -384,3 +385,26 @@ func TestFindOpReason(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestAAAA(t *testing.T) { + var ( + lng = 114.893295 + lat = 25.85793 + ) + const ( + maxRadius = 5000 + maxStoreCount4User = 5 + ) + lng2, _ := ConvertDistanceToLogLat(lng, lat, float64(maxRadius), 90) + _, lat2 := ConvertDistanceToLogLat(lng, lat, float64(maxRadius), 0) + lng1 := lng - (lng2 - lng) + lat1 := lat - (lat2 - lat) + fmt.Println(lng1, lng2, lat1, lat2) +} + +func ConvertDistanceToLogLat(lng, lat, distance, angle float64) (newLng, newLat float64) { + oneDu := 111319.55 // 单位为米 + newLng = lng + (distance*math.Sin(angle*math.Pi/180))/(oneDu*math.Cos(lat*math.Pi/180)) //将距离转换成经度的计算公式 + newLat = lat + (distance*math.Cos(angle*math.Pi/180))/oneDu //将距离转换成纬度的计算公式 + return newLng, newLat +} diff --git a/platformapi/jdshopapi/store.go b/platformapi/jdshopapi/store.go index 5fb6bcc8..fa8462f8 100644 --- a/platformapi/jdshopapi/store.go +++ b/platformapi/jdshopapi/store.go @@ -32,7 +32,8 @@ type UpdateEntityStoreParam struct { 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以内。 - CustomerID string `json:"customerId"` //否 商家门店Id,商家维度不可重复 + CustomerID string `json:"customerId,omitempty"` //否 商家门店Id,商家维度不可重复 + Status int `json:"status,omitempty"` //否 商家门店Id,商家维度不可重复 } type GetAddressCodeResult struct { diff --git a/platformapi/jdshopapi/store_test.go b/platformapi/jdshopapi/store_test.go index 7cff2501..06dac8f8 100644 --- a/platformapi/jdshopapi/store_test.go +++ b/platformapi/jdshopapi/store_test.go @@ -29,8 +29,8 @@ func TestCreateEntityStore(t *testing.T) { func TestUpdateEntityStore(t *testing.T) { err := api.UpdateEntityStore(&UpdateEntityStoreParam{ - StoreID: 24330156, - Name: "京西菜市门店1", + StoreID: 24339354, + Status: 6, }) if err != nil { t.Fatal(err) @@ -47,7 +47,7 @@ func TestGetProvince(t *testing.T) { } func TestGetCity(t *testing.T) { - result, err := api.GetCity(22) + result, err := api.GetCity(2) if err != nil { t.Fatal(err) } @@ -55,7 +55,7 @@ func TestGetCity(t *testing.T) { } func TestGetCounty(t *testing.T) { - result, err := api.GetCounty(1930) + result, err := api.GetCounty(2823) if err != nil { t.Fatal(err) } @@ -63,7 +63,7 @@ func TestGetCounty(t *testing.T) { } func TestFindSkuSiteStock(t *testing.T) { - result, err := api.FindSkuSiteStock(24332466, 69411607059) + result, err := api.FindSkuSiteStock(24337902, 69353673334) if err != nil { t.Fatal(err) } @@ -71,7 +71,7 @@ func TestFindSkuSiteStock(t *testing.T) { } func TestUpdateSkuSiteStock(t *testing.T) { - err := api.UpdateSkuSiteStock(69411607059, 0, 24332466) + err := api.UpdateSkuSiteStock(69353673334, 0, 24337902) if err != nil { t.Fatal(err) } @@ -79,7 +79,7 @@ func TestUpdateSkuSiteStock(t *testing.T) { } func TestQueryEntityStore(t *testing.T) { - result, err := api.QueryEntityStore(11) + result, err := api.QueryEntityStore(24339354) if err != nil { t.Fatal(err) } From 697fda029eae02f9649c32eef98cba515ae2584a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 26 May 2020 10:48:37 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=95=86=E5=93=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/order.go | 11 ++++++++ platformapi/jdshopapi/order_test.go | 13 ++++++++++ platformapi/jdshopapi/sku.go | 39 ++++++++++++++++------------- platformapi/jdshopapi/sku_test.go | 4 +-- 4 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 platformapi/jdshopapi/order.go create mode 100644 platformapi/jdshopapi/order_test.go diff --git a/platformapi/jdshopapi/order.go b/platformapi/jdshopapi/order.go new file mode 100644 index 00000000..939199f1 --- /dev/null +++ b/platformapi/jdshopapi/order.go @@ -0,0 +1,11 @@ +package jdshopapi + +//查询单个订单 +//https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=2389&apiName=jingdong.pop.order.enGet +func (a *API) EnGet(orderID int64) (err error) { + _, err = a.AccessAPI("jingdong.pop.order.enGet", prodURL, map[string]interface{}{ + "order_id": orderID, + "optional_fields": "ALL", + }) + return err +} diff --git a/platformapi/jdshopapi/order_test.go b/platformapi/jdshopapi/order_test.go new file mode 100644 index 00000000..23655aa2 --- /dev/null +++ b/platformapi/jdshopapi/order_test.go @@ -0,0 +1,13 @@ +package jdshopapi + +import ( + "testing" +) + +func TestEnGet(t *testing.T) { + err := api.EnGet(116889545275) + if err != nil { + t.Fatal(err) + } + // t.Log(utils.Format4Output(result, false)) +} diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index 47bbfc4e..9a9bf03a 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -113,8 +113,9 @@ type CreateSkuParamSkus struct { // Props []struct{} `json:"props"` //否 无 SKU属性(已废弃 请使用multiCateProps,已经按照类目限制使用3级类目修改,请及时迁移到多级类目) SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs"` //否 无 多级SKU属性,仅当属性可以下沉时才能设置,不验证必填!sku维度设置后,以sku上的属性为准! // Capacity string `json:"capacity"` // 否 20L 20T 容量,在有特殊要求的类目下必填!最多支持6位小数。 - Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku" - Type2 string `json:"@type"` + Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku" + Type2 string `json:"@type"` + MultiCateProps []*CreateSkuParamAttrs `json:"multiCateProps"` // 否 无 类目属性列表,类目属性中有必填项时,此字段必填;若未设置或设置错误,会有“通用属性必填”等错误提示! } type CreateSkuParamAttrs struct { @@ -142,12 +143,13 @@ type CreateSkuResult struct { } type UpdateWareParam struct { - WareID int64 `json:"wareId"` - Title string `json:"title"` //否 标题 商品名称 限制45个字符内 - VenderID int64 `json:"venderId"` - PromiseID int `json:"promiseId"` // 否 无 配送时效 - MobileDesc string `json:"mobileDesc"` // 是 无 移动版的商品介绍 长度限制10W个字符 - Introduction string `json:"introduction"` // 是 无 PC版的商品介绍 长度限制10W个字符 + WareID int64 `json:"wareId"` + Title string `json:"title"` //否 标题 商品名称 限制45个字符内 + VenderID int64 `json:"venderId"` + PromiseID int `json:"promiseId"` // 否 无 配送时效 + MobileDesc string `json:"mobileDesc"` // 是 无 移动版的商品介绍 长度限制10W个字符 + Introduction string `json:"introduction"` // 是 无 PC版的商品介绍 长度限制10W个字符 + Features []*CreateSkuParamFeatures `json:"features"` // 否 无 商品维度的特殊属性 目前两个特殊属性 IBS、FBP、FCS、SCF 4种商家类型【规格型号】 model和【销售单位】 unit 字段且为必填(如 个、盒、袋等)请勿填写公司名称。 } type QueryPictureReuslt struct { @@ -168,16 +170,17 @@ type UpdateSkusParam struct { } type UpdateSkusParamSkus struct { - WareID int64 `json:"wareId,omitempty"` //是 11111111111 商品ID(必填) - SkuID int64 `json:"skuId,omitempty"` //否 11111558987 skuID(新增的sku可不填写) - SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs,omitempty"` //是 无 SKU销售属性 - JdPrice float64 `json:"jdPrice,omitempty"` //是 无 京东价必填 单位:元 - OuterID string `json:"outerId,omitempty"` //否 ww_4567 外部ID,系统不保证唯一性,如需唯一性自行保证 - StockNum string `json:"stockNum,omitempty"` //是 10 总库存数 - BarCode string `json:"barCode,omitempty"` //否 45456467777 SKU的条形码 - Capacity string `json:"capacity,omitempty"` //否 20L 容量,在有特殊要求的类目下必填!最多支持6位小数。 - Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku" - Type2 string `json:"@type"` + WareID int64 `json:"wareId,omitempty"` //是 11111111111 商品ID(必填) + SkuID int64 `json:"skuId,omitempty"` //否 11111558987 skuID(新增的sku可不填写) + SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs,omitempty"` //是 无 SKU销售属性 + JdPrice float64 `json:"jdPrice,omitempty"` //是 无 京东价必填 单位:元 + OuterID string `json:"outerId,omitempty"` //否 ww_4567 外部ID,系统不保证唯一性,如需唯一性自行保证 + StockNum string `json:"stockNum,omitempty"` //是 10 总库存数 + BarCode string `json:"barCode,omitempty"` //否 45456467777 SKU的条形码 + Capacity string `json:"capacity,omitempty"` //否 20L 容量,在有特殊要求的类目下必填!最多支持6位小数。 + Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku" + Type2 string `json:"@type"` + MultiCateProps []*CreateSkuParamAttrs `json:"multiCateProps"` // 否 无 类目属性列表,类目属性中有必填项时,此字段必填;若未设置或设置错误,会有“通用属性必填”等错误提示! } //查询商家所有的店内分类 diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index 4f2dcd76..691e9c11 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -231,7 +231,7 @@ func TestCreateSku(t *testing.T) { } func TestFindAttrs(t *testing.T) { - result, err := api.FindAttrs(13573) + result, err := api.FindAttrs(13571) if err != nil { t.Fatal(err) } @@ -239,7 +239,7 @@ func TestFindAttrs(t *testing.T) { } func TestFindValuesByAttrId(t *testing.T) { - result, no, err := api.FindValuesByAttrId(1001027602) + result, no, err := api.FindValuesByAttrId(102241) if err != nil { t.Fatal(err) } From d011e532031d970dc1b7c11c9cdfb3c398e32396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 26 May 2020 14:08:18 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=95=86=E5=93=81=E9=80=8F=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/order.go | 10 ++++++++-- platformapi/jdshopapi/order_test.go | 2 +- platformapi/jdshopapi/sku.go | 12 ++++++++++++ platformapi/jdshopapi/sku_test.go | 16 ++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/platformapi/jdshopapi/order.go b/platformapi/jdshopapi/order.go index 939199f1..2db41987 100644 --- a/platformapi/jdshopapi/order.go +++ b/platformapi/jdshopapi/order.go @@ -1,11 +1,17 @@ package jdshopapi +import "encoding/json" + //查询单个订单 //https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=2389&apiName=jingdong.pop.order.enGet func (a *API) EnGet(orderID int64) (err error) { - _, err = a.AccessAPI("jingdong.pop.order.enGet", prodURL, map[string]interface{}{ + dataMap := map[string]interface{}{ "order_id": orderID, - "optional_fields": "ALL", + "optional_fields": "orderType,payType", + } + data, _ := json.Marshal(dataMap) + _, err = a.AccessAPI("jingdong.pop.order.enGet", prodURL, map[string]interface{}{ + "360buy_param_json": string(data), }) return err } diff --git a/platformapi/jdshopapi/order_test.go b/platformapi/jdshopapi/order_test.go index 23655aa2..8c02a36d 100644 --- a/platformapi/jdshopapi/order_test.go +++ b/platformapi/jdshopapi/order_test.go @@ -5,7 +5,7 @@ import ( ) func TestEnGet(t *testing.T) { - err := api.EnGet(116889545275) + err := api.EnGet(116925931738) if err != nil { t.Fatal(err) } diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index 9a9bf03a..cc996186 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -535,6 +535,7 @@ func (a *API) FindSkuById(skuId int64) (findSkuByIdParam *FindSkuByIdParam, err func (a *API) FindWareById(wareId int64) (err error) { _, err = a.AccessAPI2("jingdong.ware.read.findWareById", prodURL, map[string]interface{}{ "wareId": wareId, + "field": "features", }) return err } @@ -560,3 +561,14 @@ func (a *API) FindOpReason(wareId int64) (reason string, err error) { } return reason, err } + +//商品透图追加 +//https://open.jd.com/home/home#/doc/api?apiCateId=48&apiId=2504&apiName=jingdong.transparentImage.write.add +func (a *API) TransparentImageAdd(wareId int64, imageUrl string) (err error) { + _, err = a.AccessAPI2("jingdong.transparentImage.write.add", prodURL, map[string]interface{}{ + "wareId": wareId, + "colorId": "0000000000", + "imageUrl": imageUrl, + }) + return err +} diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index 691e9c11..1220d3b3 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -408,3 +408,19 @@ func ConvertDistanceToLogLat(lng, lat, distance, angle float64) (newLng, newLat newLat = lat + (distance*math.Cos(angle*math.Pi/180))/oneDu //将距离转换成纬度的计算公式 return newLng, newLat } + +func TestFindWareById(t *testing.T) { + err := api.FindWareById(14546096098) + if err != nil { + t.Fatal(err) + } + // t.Log(utils.Format4Output(result, false)) +} + +func TestTransparentImageAdd(t *testing.T) { + // err := api.TransparentImageAdd(wareId, imageUrl) + // if err != nil { + // t.Fatal(err) + // } + // t.Log(utils.Format4Output(result, false)) +} From 153b64ef9ef5337a5836b18422f3ac054c4da1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 26 May 2020 18:33:21 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/jdshopapi/jxshopapi_test.go | 2 +- platformapi/jdshopapi/store.go | 10 ++ platformapi/jdshopapi/store_page.go | 167 +++++++++++++++++++++++ platformapi/jdshopapi/store_page_test.go | 11 ++ platformapi/jdshopapi/store_test.go | 12 +- 5 files changed, 199 insertions(+), 3 deletions(-) diff --git a/platformapi/jdshopapi/jxshopapi_test.go b/platformapi/jdshopapi/jxshopapi_test.go index 96117255..753397fb 100644 --- a/platformapi/jdshopapi/jxshopapi_test.go +++ b/platformapi/jdshopapi/jxshopapi_test.go @@ -16,6 +16,6 @@ func init() { baseapi.Init(sugarLogger) api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608") api.SetCookieWithStr(` - thor=80FAF09E9A09B6E618A68057BDFCFCB8C86E8252DC9F7D3B34572625904FBA0A74B88873C7657CFD518E07B0319B489D0282895A6DF7C0E1C67590D2864D06769657402E80191AB425B126C59F29522AE1C00344E2CF8D60E007F25BB4C1DE11431856BF15070B700ACB33124EA2661AE6D93D1E1A2A4D18A838CB5664BD7DFE61C73899267AC2D01237897F6D808568; + thor=80FAF09E9A09B6E618A68057BDFCFCB83C345398FC0EA96BB93E21F628E09F69ABC4812E3C973FC424A9790F0EFBB575F0B38D3D40ED8C7FE094307204922296A626E5E990526A84EEA9E1F52BE923D06899DA48B400EBFCDB1F7934C84EAE4AA0D9454C7173B79CE6780DC12463FF8101D2D81F1975356E1E062C3B7A5EA9CF6DB6EFEF59F75691F88E2E044ADA79EF; `) } diff --git a/platformapi/jdshopapi/store.go b/platformapi/jdshopapi/store.go index fa8462f8..bbc27198 100644 --- a/platformapi/jdshopapi/store.go +++ b/platformapi/jdshopapi/store.go @@ -181,3 +181,13 @@ func (a *API) QueryEntityStore(storeId int64) (queryEntityStoreResult *QueryEnti } return queryEntityStoreResult, err } + +//获取门店信息2 +//https://open.jd.com/home/home#/doc/api?apiCateId=351&apiId=4972&apiName=jingdong.findStoreInfoByExtStoreId +func (a *API) FindStoreInfoByExtStoreId(storeID int) (queryEntityStoreResult *QueryEntityStoreResult, err error) { + _, err = a.AccessAPI("jingdong.findStoreInfoByExtStoreId", prodURL, map[string]interface{}{ + "extStoreId": storeID, + }) + + return queryEntityStoreResult, err +} diff --git a/platformapi/jdshopapi/store_page.go b/platformapi/jdshopapi/store_page.go index db7959c0..3b770aee 100644 --- a/platformapi/jdshopapi/store_page.go +++ b/platformapi/jdshopapi/store_page.go @@ -193,3 +193,170 @@ func (a *API) NewInfoList(storeID int64) (newInfoListResult *NewInfoListResult, newInfoListResult = newInfoListResult2[0] return newInfoListResult, err } + +type AllOrdersParam struct { + Current int `json:"current"` + PageSize int `json:"pageSize"` + SortName string `json:"sortName"` + OrderID string `json:"orderId"` + SkuName string `json:"skuName"` + OrderCreateDateRange []string `json:"orderCreateDateRange"` + OrderCompleteDateRange []interface{} `json:"orderCompleteDateRange"` + ReceiverName string `json:"receiverName"` + ReceiverTel string `json:"receiverTel"` + UserPin string `json:"userPin"` + SkuID string `json:"skuId"` + LogiNo string `json:"logiNo"` + PaymentType string `json:"paymentType"` + OrderType string `json:"orderType"` + OrderSource string `json:"orderSource"` + DeliveryType string `json:"deliveryType"` + StoreID string `json:"storeId"` + HuoHao string `json:"huoHao"` + OrderStatusArray []interface{} `json:"orderStatusArray"` + SelectedTabName string `json:"selectedTabName"` +} + +type AllOrdersResult struct { + TotalCount int `json:"totalCount"` + Current int `json:"current"` + OrderList []struct { + XiaDanTime interface{} `json:"xiaDanTime"` + ModifiedTime interface{} `json:"modifiedTime"` + CustomsName interface{} `json:"customsName"` + MerchantName interface{} `json:"merchantName"` + CustomsModelName interface{} `json:"customsModelName"` + ProcessStatus interface{} `json:"processStatus"` + StorageAndShipStatus interface{} `json:"storageAndShipStatus"` + ProcessStatusMsg interface{} `json:"processStatusMsg"` + OrderID int64 `json:"orderId"` + SelectedTabName interface{} `json:"selectedTabName"` + VenderID int `json:"venderId"` + OrderCreateTime string `json:"orderCreateTime"` + PaymentConfirmTime string `json:"paymentConfirmTime"` + OrderCompleteTime interface{} `json:"orderCompleteTime"` + OrderItems []struct { + WareID interface{} `json:"wareId"` + SkuID int64 `json:"skuId"` + SkuName string `json:"skuName"` + HuoHao interface{} `json:"huoHao"` + JdPrice float64 `json:"jdPrice"` + SkuNum int `json:"skuNum"` + SkuImg interface{} `json:"skuImg"` + URL string `json:"url"` + ServiceName string `json:"serviceName"` + Imei interface{} `json:"imei"` + SequenceFlag bool `json:"sequenceFlag"` + SequenceInfoList interface{} `json:"sequenceInfoList"` + UpdateCount interface{} `json:"updateCount"` + CertificateFlag bool `json:"certificateFlag"` + CertificateInfoList interface{} `json:"certificateInfoList"` + MedicalInfoFlag bool `json:"medicalInfoFlag"` + MedicalInfoParamVos interface{} `json:"medicalInfoParamVos"` + UniqueCode interface{} `json:"uniqueCode"` + InspectReportID interface{} `json:"inspectReportId"` + } `json:"orderItems"` + PaymentTypeName string `json:"paymentTypeName"` + ShouldPay float64 `json:"shouldPay"` + Freight float64 `json:"freight"` + ServiceFee interface{} `json:"serviceFee"` + Commission float64 `json:"commission"` + CouponFlag bool `json:"couponFlag"` + UserPin string `json:"userPin"` + UserRemark string `json:"userRemark"` + ConsigneeInfo interface{} `json:"consigneeInfo"` + LogiFlag bool `json:"logiFlag"` + LogisticsInfos []interface{} `json:"logisticsInfos"` + StoreName interface{} `json:"storeName"` + CodDT interface{} `json:"codDT"` + ScDT interface{} `json:"scDT"` + OrderStatusStrCN string `json:"orderStatusStrCN"` + OrderStatus int `json:"orderStatus"` + InvalidOrderFlag bool `json:"invalidOrderFlag"` + OrderType int `json:"orderType"` + CustomsModel interface{} `json:"customsModel"` + SalesPin interface{} `json:"salesPin"` + MdbStoreID interface{} `json:"mdbStoreId"` + SuspendType interface{} `json:"suspendType"` + SuspendReason interface{} `json:"suspendReason"` + SuspendReasonDesc interface{} `json:"suspendReasonDesc"` + SuspendDetailReasonFlag interface{} `json:"suspendDetailReasonFlag"` + StoreInfo interface{} `json:"storeInfo"` + IsDivShow bool `json:"isDivShow"` + IsMenDianOrder bool `json:"isMenDianOrder"` + IsMenDianBangOrder bool `json:"isMenDianBangOrder"` + IsMenDianZiTiOrder bool `json:"isMenDianZiTiOrder"` + IsPhoneOrder bool `json:"isPhoneOrder"` + IsReturnOrder bool `json:"isReturnOrder"` + IsPreSaleOrder bool `json:"isPreSaleOrder"` + IsVenderSplitOrder bool `json:"isVenderSplitOrder"` + IsAuctionOrder bool `json:"isAuctionOrder"` + IsLargeAmountOrder bool `json:"isLargeAmountOrder"` + IsMicroShopOrder bool `json:"isMicroShopOrder"` + IsRuralPromotionOrder bool `json:"isRuralPromotionOrder"` + IsHkMacaoOrder bool `json:"isHkMacaoOrder"` + IsTaiWanOrder bool `json:"isTaiWanOrder"` + IsOverseasOrder bool `json:"isOverseasOrder"` + IsDistributionOrder bool `json:"isDistributionOrder"` + IsJdDeliveryOrder bool `json:"isJdDeliveryOrder"` + IsEclpOrder bool `json:"isEclpOrder"` + IsYiPanHuoOrder bool `json:"isYiPanHuoOrder"` + IsJingZunDaOrder bool `json:"isJingZunDaOrder"` + IsBrandMall bool `json:"isBrandMall"` + IsPinGou bool `json:"isPinGou"` + IsYhd bool `json:"isYhd"` + IsXtl bool `json:"isXtl"` + IsSplitOrder bool `json:"isSplitOrder"` + IsCloudWarehouseOrder bool `json:"isCloudWarehouseOrder"` + IsTopLifeOrder bool `json:"isTopLifeOrder"` + IsTuanGou bool `json:"isTuanGou"` + IsDuoBaoDao bool `json:"isDuoBaoDao"` + IsJingPinShi bool `json:"isJingPinShi"` + BizLinkVo struct { + ShowModifyFee bool `json:"showModifyFee"` + ShowSingleOut bool `json:"showSingleOut"` + ShowModifyAddr bool `json:"showModifyAddr"` + ShowDelayDeliveryRemind bool `json:"showDelayDeliveryRemind"` + ShowSplitOrder bool `json:"showSplitOrder"` + ShowMoreLogisticsDelivery bool `json:"showMoreLogisticsDelivery"` + ShowMergeDelivery bool `json:"showMergeDelivery"` + ShowInfoCheck bool `json:"showInfoCheck"` + ShowLivingAuth bool `json:"showLivingAuth"` + ShowModifyWaybill bool `json:"showModifyWaybill"` + } `json:"bizLinkVo"` + IsOut bool `json:"isOut"` + IsMultiLogisticsOutShow bool `json:"isMultiLogisticsOutShow"` + PaimaiOrder int `json:"paimaiOrder"` + CannotModifyProvinceAndCity bool `json:"cannotModifyProvinceAndCity"` + CanWaitInnerShip bool `json:"canWaitInnerShip"` + ShowShangChuanHeTong bool `json:"showShangChuanHeTong"` + ShowManageCertificate bool `json:"showManageCertificate"` + OrderSeqFlag bool `json:"orderSeqFlag"` + CustomInfoFlag bool `json:"customInfoFlag"` + OrderDaYangFlag bool `json:"orderDaYangFlag"` + ShowMedicalInfo bool `json:"showMedicalInfo"` + Card3CFlag bool `json:"card3cFlag"` + ShowOrderPackage bool `json:"showOrderPackage"` + ShowWaybill bool `json:"showWaybill"` + IsGlobalZhiYouOrder bool `json:"isGlobalZhiYouOrder"` + IsGlobalBaoShuiOrder bool `json:"isGlobalBaoShuiOrder"` + ManageImeiFlag bool `json:"manageImeiFlag"` + SpecialViewOrder []interface{} `json:"specialViewOrder"` + } `json:"orderList"` + Cluster interface{} `json:"cluster"` +} + +//尝试扒订单 +//https://porder.shop.jd.com/order/orderlist/allOrders +func (a *API) AllOrders(allOrdersParam *AllOrdersParam) (allOrdersResult *AllOrdersResult, err error) { + result, err := a.AccessStorePage2("https://porder.shop.jd.com/order/orderlist", map[string]interface{}{ + "current": allOrdersParam.Current, + "pageSize": allOrdersParam.PageSize, + "selectedTabName": "allOrders", + "sortName": "desc", + }) + if err == nil { + utils.Map2StructByJson(result, &allOrdersResult, false) + } + return allOrdersResult, err +} diff --git a/platformapi/jdshopapi/store_page_test.go b/platformapi/jdshopapi/store_page_test.go index 36feb7ad..b0c1c855 100644 --- a/platformapi/jdshopapi/store_page_test.go +++ b/platformapi/jdshopapi/store_page_test.go @@ -53,3 +53,14 @@ func Test11(t *testing.T) { bodyData, _ := ioutil.ReadAll(response.Body) fmt.Println("test1", string(bodyData)) } + +func TestAllOrders(t *testing.T) { + result, err := api.AllOrders(&AllOrdersParam{ + Current: 1, + PageSize: 10, + }) + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +} diff --git a/platformapi/jdshopapi/store_test.go b/platformapi/jdshopapi/store_test.go index 06dac8f8..9e8649a4 100644 --- a/platformapi/jdshopapi/store_test.go +++ b/platformapi/jdshopapi/store_test.go @@ -63,7 +63,7 @@ func TestGetCounty(t *testing.T) { } func TestFindSkuSiteStock(t *testing.T) { - result, err := api.FindSkuSiteStock(24337902, 69353673334) + result, err := api.FindSkuSiteStock(24340329, 69353633443) if err != nil { t.Fatal(err) } @@ -71,7 +71,7 @@ func TestFindSkuSiteStock(t *testing.T) { } func TestUpdateSkuSiteStock(t *testing.T) { - err := api.UpdateSkuSiteStock(69353673334, 0, 24337902) + err := api.UpdateSkuSiteStock(69353633443, 0, 24340329) if err != nil { t.Fatal(err) } @@ -85,3 +85,11 @@ func TestQueryEntityStore(t *testing.T) { } t.Log(utils.Format4Output(result, false)) } + +func TestFindStoreInfoByExtStoreId(t *testing.T) { + result, err := api.FindStoreInfoByExtStoreId(666854) + if err != nil { + t.Fatal(err) + } + t.Log(utils.Format4Output(result, false)) +} From cbf0d8945536ca83a3aca31dda5cdd7f161ef1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 27 May 2020 17:04:34 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E5=95=86=E5=9F=8E?= =?UTF-8?q?=E5=BA=97=E5=86=85=E5=88=86=E7=B1=BB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/autonavi/autonavi_test.go | 4 +- platformapi/jdshopapi/jxshopapi_test.go | 2 +- platformapi/jdshopapi/order.go | 16 +++---- platformapi/jdshopapi/sku.go | 1 + platformapi/jdshopapi/sku_test.go | 11 +++-- platformapi/jdshopapi/store_page.go | 54 ++++++++++++++++++++---- platformapi/jdshopapi/store_page_test.go | 16 +++++-- platformapi/jdshopapi/store_test.go | 2 +- 8 files changed, 78 insertions(+), 28 deletions(-) diff --git a/platformapi/autonavi/autonavi_test.go b/platformapi/autonavi/autonavi_test.go index 465b9acd..8d6be7ca 100644 --- a/platformapi/autonavi/autonavi_test.go +++ b/platformapi/autonavi/autonavi_test.go @@ -85,7 +85,7 @@ func TestGetDistricts(t *testing.T) { } func TestGetCoordinateFromAddress(t *testing.T) { - lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("天府广场", "成都市") + lng, lat, districtCode := autonaviAPI.GetCoordinateFromAddress("辽宁铁岭市铁岭县凡河新区3区3号楼4单元301", "") t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode) } @@ -151,7 +151,7 @@ func TestBatchWalkingDistance(t *testing.T) { } func TestAA(t *testing.T) { - result, err := autonaviAPI.GetCoordinateAreaInfo(116.331471, 39.909837) + result, err := autonaviAPI.GetCoordinateAreaInfo(123.715455, 42.221651) if err != nil { t.Fatal(err) } diff --git a/platformapi/jdshopapi/jxshopapi_test.go b/platformapi/jdshopapi/jxshopapi_test.go index 753397fb..74304db3 100644 --- a/platformapi/jdshopapi/jxshopapi_test.go +++ b/platformapi/jdshopapi/jxshopapi_test.go @@ -16,6 +16,6 @@ func init() { baseapi.Init(sugarLogger) api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608") api.SetCookieWithStr(` - thor=80FAF09E9A09B6E618A68057BDFCFCB83C345398FC0EA96BB93E21F628E09F69ABC4812E3C973FC424A9790F0EFBB575F0B38D3D40ED8C7FE094307204922296A626E5E990526A84EEA9E1F52BE923D06899DA48B400EBFCDB1F7934C84EAE4AA0D9454C7173B79CE6780DC12463FF8101D2D81F1975356E1E062C3B7A5EA9CF6DB6EFEF59F75691F88E2E044ADA79EF; + thor=80FAF09E9A09B6E618A68057BDFCFCB88A0E4CE7743FBEC84F10D992F9C6A4119DF98DA3CAAE9C7F17BEB62884625B4E7BC82422A90F45F02EA293572D951B055EF0B5F603AEA568DFD4234138F841EC1AC1F67B30B48AAC9EAD5FBAE7943E1DCC99E99D8358C82F7832B71A2BCB31624E16BBF561720443DE966BDA3588406233A90224D9089710B102AA98B979B9B3; `) } diff --git a/platformapi/jdshopapi/order.go b/platformapi/jdshopapi/order.go index 2db41987..3eedd452 100644 --- a/platformapi/jdshopapi/order.go +++ b/platformapi/jdshopapi/order.go @@ -1,17 +1,15 @@ package jdshopapi -import "encoding/json" - //查询单个订单 //https://open.jd.com/home/home#/doc/api?apiCateId=55&apiId=2389&apiName=jingdong.pop.order.enGet func (a *API) EnGet(orderID int64) (err error) { - dataMap := map[string]interface{}{ - "order_id": orderID, - "optional_fields": "orderType,payType", - } - data, _ := json.Marshal(dataMap) - _, err = a.AccessAPI("jingdong.pop.order.enGet", prodURL, map[string]interface{}{ - "360buy_param_json": string(data), + // dataMap := map[string]interface{}{ + // "order_id": orderID, + // "optional_fields": "orderType,payType", + // } + // data, _ := json.Marshal(dataMap) + _, err = a.AccessAPI("jingdong.pop.order.shipment", prodURL, map[string]interface{}{ + "orderId": orderID, }) return err } diff --git a/platformapi/jdshopapi/sku.go b/platformapi/jdshopapi/sku.go index cc996186..8b2a7abe 100644 --- a/platformapi/jdshopapi/sku.go +++ b/platformapi/jdshopapi/sku.go @@ -150,6 +150,7 @@ type UpdateWareParam struct { MobileDesc string `json:"mobileDesc"` // 是 无 移动版的商品介绍 长度限制10W个字符 Introduction string `json:"introduction"` // 是 无 PC版的商品介绍 长度限制10W个字符 Features []*CreateSkuParamFeatures `json:"features"` // 否 无 商品维度的特殊属性 目前两个特殊属性 IBS、FBP、FCS、SCF 4种商家类型【规格型号】 model和【销售单位】 unit 字段且为必填(如 个、盒、袋等)请勿填写公司名称。 + // ExtendFeatures []*CreateSkuParamFeatures `json:"extendFeatures"` // 否 无 商品维度的特殊属性 目前两个特殊属性 IBS、FBP、FCS、SCF 4种商家类型【规格型号】 model和【销售单位】 unit 字段且为必填(如 个、盒、袋等)请勿填写公司名称。 } type QueryPictureReuslt struct { diff --git a/platformapi/jdshopapi/sku_test.go b/platformapi/jdshopapi/sku_test.go index 1220d3b3..3a228425 100644 --- a/platformapi/jdshopapi/sku_test.go +++ b/platformapi/jdshopapi/sku_test.go @@ -273,9 +273,14 @@ func TestUpOrDown(t *testing.T) { func TestUpdateWare(t *testing.T) { err := api.UpdateWare(&UpdateWareParam{ - WareID: 14521014949, - Title: "大青菜1", - VenderID: 10374877, + WareID: 14545996691, + Title: "进口凤梨", + Features: []*CreateSkuParamFeatures{ + &CreateSkuParamFeatures{ + Key: "fdms", + Value: "1", + }, + }, }) if err != nil { t.Fatal(err) diff --git a/platformapi/jdshopapi/store_page.go b/platformapi/jdshopapi/store_page.go index 3b770aee..7b15c03f 100644 --- a/platformapi/jdshopapi/store_page.go +++ b/platformapi/jdshopapi/store_page.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "net/http" + "regexp" "strings" "git.rosy.net.cn/baseapi" @@ -11,6 +12,11 @@ import ( "git.rosy.net.cn/baseapi/utils" ) +var ( + regexpOrderDetailTable = regexp.MustCompile(`