美团cookie取消
This commit is contained in:
@@ -74,7 +74,7 @@ func TestGetCoordinateTownInfo(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetDistricts(t *testing.T) {
|
func TestGetDistricts(t *testing.T) {
|
||||||
districtList, err := autonaviAPI.GetDistricts(4, "常熟市")
|
districtList, err := autonaviAPI.GetDistricts(4, "成都")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ func TestGetDistricts(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCoordinateFromAddress(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)
|
t.Logf("lng:%f, lat:%f, districtCode:%d", lng, lat, districtCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,3 +149,11 @@ func TestBatchWalkingDistance(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAA(t *testing.T) {
|
||||||
|
result, err := autonaviAPI.GetCoordinateAreaInfo(123.715455, 42.221651)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|||||||
31
platformapi/jdshopapi/callback.go
Normal file
31
platformapi/jdshopapi/callback.go
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -48,6 +48,8 @@ const (
|
|||||||
JdsSkuStatus1032 = 1032 //在售 审核不通过
|
JdsSkuStatus1032 = 1032 //在售 审核不通过
|
||||||
|
|
||||||
PassReason = "审核通过"
|
PassReason = "审核通过"
|
||||||
|
|
||||||
|
JdsOtherMeatCatID = 15245
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ func init() {
|
|||||||
baseapi.Init(sugarLogger)
|
baseapi.Init(sugarLogger)
|
||||||
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
api = New("de8157b447584885910f429011e49cb93yjq", "E1D746D42474D5F1F1A10CECE75D99F6", "efa7e1d1a22640fa990e6cf164b28608")
|
||||||
api.SetCookieWithStr(`
|
api.SetCookieWithStr(`
|
||||||
thor=80FAF09E9A09B6E618A68057BDFCFCB8C86E8252DC9F7D3B34572625904FBA0A74B88873C7657CFD518E07B0319B489D0282895A6DF7C0E1C67590D2864D06769657402E80191AB425B126C59F29522AE1C00344E2CF8D60E007F25BB4C1DE11431856BF15070B700ACB33124EA2661AE6D93D1E1A2A4D18A838CB5664BD7DFE61C73899267AC2D01237897F6D808568;
|
thor=00513FC363111586B2C0E065A90E33C1356AC072AA79A28628FF01BE8B2903995775FF61D2F25840E8BAFB9ED95AF7978DAEDCE30A5A110010D64FEA48F85BB83677488A7432DE90F646CFF6D42A4BAD652ACAF7AE179C5C698CBB31F65EFECCAD53871820D05835E7F794768F7F046E75BE2E9350A2E78AC98970EEB4FCBD6EE51EF9DB61864A5777850F88564E7D42;
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|||||||
15
platformapi/jdshopapi/order.go
Normal file
15
platformapi/jdshopapi/order.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
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) {
|
||||||
|
// 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
|
||||||
|
}
|
||||||
13
platformapi/jdshopapi/order_test.go
Normal file
13
platformapi/jdshopapi/order_test.go
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
package jdshopapi
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestEnGet(t *testing.T) {
|
||||||
|
err := api.EnGet(116925931738)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
// t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
@@ -113,8 +113,9 @@ type CreateSkuParamSkus struct {
|
|||||||
// Props []struct{} `json:"props"` //否 无 SKU属性(已废弃 请使用multiCateProps,已经按照类目限制使用3级类目修改,请及时迁移到多级类目)
|
// Props []struct{} `json:"props"` //否 无 SKU属性(已废弃 请使用multiCateProps,已经按照类目限制使用3级类目修改,请及时迁移到多级类目)
|
||||||
SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs"` //否 无 多级SKU属性,仅当属性可以下沉时才能设置,不验证必填!sku维度设置后,以sku上的属性为准!
|
SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs"` //否 无 多级SKU属性,仅当属性可以下沉时才能设置,不验证必填!sku维度设置后,以sku上的属性为准!
|
||||||
// Capacity string `json:"capacity"` // 否 20L 20T 容量,在有特殊要求的类目下必填!最多支持6位小数。
|
// Capacity string `json:"capacity"` // 否 20L 20T 容量,在有特殊要求的类目下必填!最多支持6位小数。
|
||||||
Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku"
|
Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku"
|
||||||
Type2 string `json:"@type"`
|
Type2 string `json:"@type"`
|
||||||
|
MultiCateProps []*CreateSkuParamAttrs `json:"multiCateProps"` // 否 无 类目属性列表,类目属性中有必填项时,此字段必填;若未设置或设置错误,会有“通用属性必填”等错误提示!
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateSkuParamAttrs struct {
|
type CreateSkuParamAttrs struct {
|
||||||
@@ -142,12 +143,14 @@ type CreateSkuResult struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateWareParam struct {
|
type UpdateWareParam struct {
|
||||||
WareID int64 `json:"wareId"`
|
WareID int64 `json:"wareId"`
|
||||||
Title string `json:"title"` //否 标题 商品名称 限制45个字符内
|
Title string `json:"title"` //否 标题 商品名称 限制45个字符内
|
||||||
VenderID int64 `json:"venderId"`
|
VenderID int64 `json:"venderId"`
|
||||||
PromiseID int `json:"promiseId"` // 否 无 配送时效
|
PromiseID int `json:"promiseId"` // 否 无 配送时效
|
||||||
MobileDesc string `json:"mobileDesc"` // 是 无 移动版的商品介绍 长度限制10W个字符
|
MobileDesc string `json:"mobileDesc"` // 是 无 移动版的商品介绍 长度限制10W个字符
|
||||||
Introduction string `json:"introduction"` // 是 无 PC版的商品介绍 长度限制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 {
|
type QueryPictureReuslt struct {
|
||||||
@@ -168,16 +171,17 @@ type UpdateSkusParam struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type UpdateSkusParamSkus struct {
|
type UpdateSkusParamSkus struct {
|
||||||
WareID int64 `json:"wareId,omitempty"` //是 11111111111 商品ID(必填)
|
WareID int64 `json:"wareId,omitempty"` //是 11111111111 商品ID(必填)
|
||||||
SkuID int64 `json:"skuId,omitempty"` //否 11111558987 skuID(新增的sku可不填写)
|
SkuID int64 `json:"skuId,omitempty"` //否 11111558987 skuID(新增的sku可不填写)
|
||||||
SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs,omitempty"` //是 无 SKU销售属性
|
SaleAttrs []*CreateSkuParamAttrs `json:"saleAttrs,omitempty"` //是 无 SKU销售属性
|
||||||
JdPrice float64 `json:"jdPrice,omitempty"` //是 无 京东价必填 单位:元
|
JdPrice float64 `json:"jdPrice,omitempty"` //是 无 京东价必填 单位:元
|
||||||
OuterID string `json:"outerId,omitempty"` //否 ww_4567 外部ID,系统不保证唯一性,如需唯一性自行保证
|
OuterID string `json:"outerId,omitempty"` //否 ww_4567 外部ID,系统不保证唯一性,如需唯一性自行保证
|
||||||
StockNum string `json:"stockNum,omitempty"` //是 10 总库存数
|
StockNum string `json:"stockNum,omitempty"` //是 10 总库存数
|
||||||
BarCode string `json:"barCode,omitempty"` //否 45456467777 SKU的条形码
|
BarCode string `json:"barCode,omitempty"` //否 45456467777 SKU的条形码
|
||||||
Capacity string `json:"capacity,omitempty"` //否 20L 容量,在有特殊要求的类目下必填!最多支持6位小数。
|
Capacity string `json:"capacity,omitempty"` //否 20L 容量,在有特殊要求的类目下必填!最多支持6位小数。
|
||||||
Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku"
|
Type string `json:"type"` //"com.jd.pop.ware.ic.api.domain.sku"
|
||||||
Type2 string `json:"@type"`
|
Type2 string `json:"@type"`
|
||||||
|
MultiCateProps []*CreateSkuParamAttrs `json:"multiCateProps"` // 否 无 类目属性列表,类目属性中有必填项时,此字段必填;若未设置或设置错误,会有“通用属性必填”等错误提示!
|
||||||
}
|
}
|
||||||
|
|
||||||
//查询商家所有的店内分类
|
//查询商家所有的店内分类
|
||||||
@@ -532,6 +536,7 @@ func (a *API) FindSkuById(skuId int64) (findSkuByIdParam *FindSkuByIdParam, err
|
|||||||
func (a *API) FindWareById(wareId int64) (err error) {
|
func (a *API) FindWareById(wareId int64) (err error) {
|
||||||
_, err = a.AccessAPI2("jingdong.ware.read.findWareById", prodURL, map[string]interface{}{
|
_, err = a.AccessAPI2("jingdong.ware.read.findWareById", prodURL, map[string]interface{}{
|
||||||
"wareId": wareId,
|
"wareId": wareId,
|
||||||
|
"field": "features",
|
||||||
})
|
})
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -557,3 +562,14 @@ func (a *API) FindOpReason(wareId int64) (reason string, err error) {
|
|||||||
}
|
}
|
||||||
return reason, err
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"image/jpeg"
|
"image/jpeg"
|
||||||
"image/png"
|
"image/png"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@@ -34,14 +35,6 @@ func TestDeleteShopCategory(t *testing.T) {
|
|||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFindVendorCategories(t *testing.T) {
|
|
||||||
result, err := api.FindVendorCategories()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
t.Log(utils.Format4Output(result, false))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestUploadPicture(t *testing.T) {
|
func TestUploadPicture(t *testing.T) {
|
||||||
data, _, err := DownloadFileByURL("https://image.jxc4.com/noGoodsImg.jpg")
|
data, _, err := DownloadFileByURL("https://image.jxc4.com/noGoodsImg.jpg")
|
||||||
// img, outMimeType, _ := Binary2Image(data, "")
|
// img, outMimeType, _ := Binary2Image(data, "")
|
||||||
@@ -229,8 +222,16 @@ func TestCreateSku(t *testing.T) {
|
|||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFindVendorCategories(t *testing.T) {
|
||||||
|
result, err := api.FindVendorCategories()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
func TestFindAttrs(t *testing.T) {
|
func TestFindAttrs(t *testing.T) {
|
||||||
result, err := api.FindAttrs(13573)
|
result, err := api.FindAttrs(15245)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -238,7 +239,7 @@ func TestFindAttrs(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindValuesByAttrId(t *testing.T) {
|
func TestFindValuesByAttrId(t *testing.T) {
|
||||||
result, no, err := api.FindValuesByAttrId(1001027602)
|
result, no, err := api.FindValuesByAttrId(123060)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -272,9 +273,14 @@ func TestUpOrDown(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateWare(t *testing.T) {
|
func TestUpdateWare(t *testing.T) {
|
||||||
err := api.UpdateWare(&UpdateWareParam{
|
err := api.UpdateWare(&UpdateWareParam{
|
||||||
WareID: 14521014949,
|
WareID: 14545996691,
|
||||||
Title: "大青菜1",
|
Title: "进口凤梨",
|
||||||
VenderID: 10374877,
|
Features: []*CreateSkuParamFeatures{
|
||||||
|
&CreateSkuParamFeatures{
|
||||||
|
Key: "fdms",
|
||||||
|
Value: "1",
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -283,7 +289,7 @@ func TestUpdateWare(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindSkuStock(t *testing.T) {
|
func TestFindSkuStock(t *testing.T) {
|
||||||
err := api.FindSkuStock(69411607059)
|
err := api.FindSkuStock(69353673334)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -307,7 +313,7 @@ func TestImageUpdate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestSearchWare4Valid(t *testing.T) {
|
func TestSearchWare4Valid(t *testing.T) {
|
||||||
result, err := api.SearchWare4Valid("红薯", 0, 0)
|
result, err := api.SearchWare4Valid("猕猴桃 奇异果", 0, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -384,3 +390,42 @@ func TestFindOpReason(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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))
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ type UpdateEntityStoreParam struct {
|
|||||||
Phone string `json:"phone,omitempty"` //是 门店电话
|
Phone string `json:"phone,omitempty"` //是 门店电话
|
||||||
ExtendJSON string `json:"extendJson,omitempty"` //是 扩展属性JSON如:{name1:'value1',name2:'value2'},营业时间必传固定json格式:{\'businessBeginTime\':\'09:00\',\'businessEndTime\':\'22:00\'}' ,可将中间的时间变更
|
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以内。
|
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 {
|
type GetAddressCodeResult struct {
|
||||||
@@ -180,3 +181,13 @@ func (a *API) QueryEntityStore(storeId int64) (queryEntityStoreResult *QueryEnti
|
|||||||
}
|
}
|
||||||
return queryEntityStoreResult, err
|
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
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
@@ -11,6 +12,17 @@ import (
|
|||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
regexpOrderDetailTable = regexp.MustCompile(`<table id="receiveData">([\s\S]*?)</table>`)
|
||||||
|
regexpOrderDetailTd = regexp.MustCompile(`<td colspan="2">(.*?)</td>`)
|
||||||
|
regexpOrderDetailMobile = regexp.MustCompile(`<span id="mobile">(.*?)</span>`)
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
JdsOrderDeliverTypeStore = 1274
|
||||||
|
JdsOrderDeleverTypeSelf = 332098
|
||||||
|
)
|
||||||
|
|
||||||
func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||||
if a.GetCookieCount() == 0 {
|
if a.GetCookieCount() == 0 {
|
||||||
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
||||||
@@ -32,7 +44,7 @@ func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{},
|
|||||||
if jsonResult1 == nil {
|
if jsonResult1 == nil {
|
||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
}
|
}
|
||||||
if strings.Contains(bodyStr, "登录") {
|
if strings.Contains(bodyStr, "登录") || strings.Contains(bodyStr, "访问的内容") {
|
||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!")
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -65,6 +77,9 @@ func (a *API) AccessStorePage2(fullURL string, bizParams map[string]interface{})
|
|||||||
if jsonResult1 == nil {
|
if jsonResult1 == nil {
|
||||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
}
|
}
|
||||||
|
if strings.Contains(bodyStr, "登录") || strings.Contains(bodyStr, "访问的内容") {
|
||||||
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!")
|
||||||
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if jsonResult1["error_response"] != nil {
|
if jsonResult1["error_response"] != nil {
|
||||||
errLevel = platformapi.ErrLevelGeneralFail
|
errLevel = platformapi.ErrLevelGeneralFail
|
||||||
@@ -90,12 +105,15 @@ type CreateShopCategoryParam struct {
|
|||||||
|
|
||||||
//京东商城创建或修改店内分类
|
//京东商城创建或修改店内分类
|
||||||
//https://seller.shop.jd.com/vendershop/vendershop_shopCategory.action#
|
//https://seller.shop.jd.com/vendershop/vendershop_shopCategory.action#
|
||||||
func (a *API) CreateShopCategory(createShopCategoryParam []*CreateShopCategoryParam) (err error) {
|
func (a *API) CreateShopCategory(createShopCategoryParam []*CreateShopCategoryParam) (status int64, err error) {
|
||||||
result, _ := json.MarshalIndent(createShopCategoryParam, "", "")
|
data, _ := json.MarshalIndent(createShopCategoryParam, "", "")
|
||||||
_, err = a.AccessStorePage("https://seller.shop.jd.com/vendershop/vendershop_doShopCategory.action", map[string]interface{}{
|
result, err := a.AccessStorePage("https://seller.shop.jd.com/vendershop/vendershop_doShopCategory.action", map[string]interface{}{
|
||||||
"categoryJson": string(result),
|
"categoryJson": string(data),
|
||||||
}, true)
|
}, true)
|
||||||
return err
|
if err == nil {
|
||||||
|
status = utils.Interface2Int64WithDefault(result["fakeData"], -1)
|
||||||
|
}
|
||||||
|
return status, err
|
||||||
}
|
}
|
||||||
|
|
||||||
//京东商城设置门店营业状态
|
//京东商城设置门店营业状态
|
||||||
@@ -193,3 +211,205 @@ func (a *API) NewInfoList(storeID int64) (newInfoListResult *NewInfoListResult,
|
|||||||
newInfoListResult = newInfoListResult2[0]
|
newInfoListResult = newInfoListResult2[0]
|
||||||
return newInfoListResult, err
|
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",
|
||||||
|
"orderCreateDateRange": allOrdersParam.OrderCreateDateRange,
|
||||||
|
// "storeId": allOrdersParam.StoreID,
|
||||||
|
"orderStatusArray": allOrdersParam.OrderStatusArray,
|
||||||
|
"orderId": allOrdersParam.OrderID,
|
||||||
|
})
|
||||||
|
if err == nil {
|
||||||
|
utils.Map2StructByJson(result, &allOrdersResult, false)
|
||||||
|
}
|
||||||
|
return allOrdersResult, err
|
||||||
|
}
|
||||||
|
|
||||||
|
type OrderDetailResult struct {
|
||||||
|
ConsigneeName string `json:"consigneeName"`
|
||||||
|
ConsigneeAddress string `json:"consigneeAddress"`
|
||||||
|
ConsigneeMobile string `json:"consigneeMobile"`
|
||||||
|
}
|
||||||
|
|
||||||
|
//订单详情
|
||||||
|
//https://neworder.shop.jd.com/order/orderDetail?orderId=122367441996
|
||||||
|
func (a *API) OrderDetail(orderId string) (orderDetailResult *OrderDetailResult, err error) {
|
||||||
|
result, err := a.AccessStorePage("https://neworder.shop.jd.com/order/orderDetail", map[string]interface{}{
|
||||||
|
"orderId": orderId,
|
||||||
|
}, false)
|
||||||
|
if err == nil {
|
||||||
|
orderDetailResult = &OrderDetailResult{}
|
||||||
|
body := result["fakeData"].(string)
|
||||||
|
consigneeTable := regexpOrderDetailTable.FindStringSubmatch(body)
|
||||||
|
if len(consigneeTable) > 0 {
|
||||||
|
consigneeTd := regexpOrderDetailTd.FindAllStringSubmatch(consigneeTable[1], -1)
|
||||||
|
consigneeMobiles := regexpOrderDetailMobile.FindStringSubmatch(consigneeTable[1])
|
||||||
|
if len(consigneeTd) > 0 {
|
||||||
|
orderDetailResult.ConsigneeName = consigneeTd[0][1]
|
||||||
|
orderDetailResult.ConsigneeAddress = consigneeTd[1][1]
|
||||||
|
}
|
||||||
|
if len(consigneeMobiles) > 0 {
|
||||||
|
orderDetailResult.ConsigneeMobile = consigneeMobiles[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return orderDetailResult, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ func TestCreateShopCategory(t *testing.T) {
|
|||||||
Type: "3",
|
Type: "3",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
api.CreateShopCategory(CreateShopCategoryParams)
|
result, _ := api.CreateShopCategory(CreateShopCategoryParams)
|
||||||
|
fmt.Println(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateStoreStatus(t *testing.T) {
|
func TestUpdateStoreStatus(t *testing.T) {
|
||||||
@@ -40,10 +41,10 @@ func TestNewInfoList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Test11(t *testing.T) {
|
func Test11(t *testing.T) {
|
||||||
request, _ := http.NewRequest(http.MethodGet, "https://stores.shop.jd.com/stores/updateStoreStatus?storeId=24332466&storeStatus=1", nil)
|
request, _ := http.NewRequest(http.MethodGet, "https://stores.shop.jd.com/stores/updateStoreStatus?storeId=24339301&storeStatus=1", nil)
|
||||||
c := &http.Cookie{
|
c := &http.Cookie{
|
||||||
Name: "thor",
|
Name: "thor",
|
||||||
Value: "80FAF09E9A09B6E618A68057BDFCFCB8C86E8252DC9F7D3B34572625904FBA0AB6BF053A5325612EC0407791BB05F5301356E71E8B282C40C06D0B5DF3439DEECB102A78FAFF7AC0FC4E2D1FA8DD8BBAE1A011E50B5C74F1870AD982D7BF453F470F31F2241B73AC4C25485025C2ABEBC8A538AF7257824D2FAEE300A1435175B0B451FB5C19B78D729FC83152CA3BAF",
|
Value: "80FAF09E9A09B6E618A68057BDFCFCB88A0E4CE7743FBEC84F10D992F9C6A4119DF98DA3CAAE9C7F17BEB62884625B4E7BC82422A90F45F02EA293572D951B055EF0B5F603AEA568DFD4234138F841EC1AC1F67B30B48AAC9EAD5FBAE7943E1DCC99E99D8358C82F7832B71A2BCB31624E16BBF561720443DE966BDA3588406233A90224D9089710B102AA98B979B9B3",
|
||||||
}
|
}
|
||||||
request.AddCookie(c)
|
request.AddCookie(c)
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
@@ -53,3 +54,22 @@ func Test11(t *testing.T) {
|
|||||||
bodyData, _ := ioutil.ReadAll(response.Body)
|
bodyData, _ := ioutil.ReadAll(response.Body)
|
||||||
fmt.Println("test1", string(bodyData))
|
fmt.Println("test1", string(bodyData))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestAllOrders(t *testing.T) {
|
||||||
|
result, err := api.AllOrders(&AllOrdersParam{
|
||||||
|
Current: 1,
|
||||||
|
PageSize: 1,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestOrderDetail(t *testing.T) {
|
||||||
|
result1, result2, result3, err := api.OrderDetail("122367441996")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
fmt.Println("test1", result1, result2, result3)
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ func TestCreateEntityStore(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdateEntityStore(t *testing.T) {
|
func TestUpdateEntityStore(t *testing.T) {
|
||||||
err := api.UpdateEntityStore(&UpdateEntityStoreParam{
|
err := api.UpdateEntityStore(&UpdateEntityStoreParam{
|
||||||
StoreID: 24330156,
|
StoreID: 24339354,
|
||||||
Name: "京西菜市门店1",
|
Status: 6,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@@ -55,7 +55,11 @@ func TestGetCity(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestGetCounty(t *testing.T) {
|
func TestGetCounty(t *testing.T) {
|
||||||
|
<<<<<<< HEAD
|
||||||
result, err := api.GetCounty(2815)
|
result, err := api.GetCounty(2815)
|
||||||
|
=======
|
||||||
|
result, err := api.GetCounty(2823)
|
||||||
|
>>>>>>> 6b4ee9a49b7be7d021c71cd098aeef6c9e75e5c2
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -63,7 +67,7 @@ func TestGetCounty(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestFindSkuSiteStock(t *testing.T) {
|
func TestFindSkuSiteStock(t *testing.T) {
|
||||||
result, err := api.FindSkuSiteStock(24332466, 69411607059)
|
result, err := api.FindSkuSiteStock(24339305, 69353498265)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -71,7 +75,7 @@ func TestFindSkuSiteStock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdateSkuSiteStock(t *testing.T) {
|
func TestUpdateSkuSiteStock(t *testing.T) {
|
||||||
err := api.UpdateSkuSiteStock(69411607059, 0, 24332466)
|
err := api.UpdateSkuSiteStock(69353633443, 0, 24340329)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -79,7 +83,15 @@ func TestUpdateSkuSiteStock(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestQueryEntityStore(t *testing.T) {
|
func TestQueryEntityStore(t *testing.T) {
|
||||||
result, err := api.QueryEntityStore(11)
|
result, err := api.QueryEntityStore(24339354)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestFindStoreInfoByExtStoreId(t *testing.T) {
|
||||||
|
result, err := api.FindStoreInfoByExtStoreId(666854)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ type API struct {
|
|||||||
|
|
||||||
appKey string
|
appKey string
|
||||||
secret string
|
secret string
|
||||||
|
token string
|
||||||
client *http.Client
|
client *http.Client
|
||||||
config *platformapi.APIConfig
|
config *platformapi.APIConfig
|
||||||
}
|
}
|
||||||
@@ -227,9 +228,9 @@ func (a *API) signParams(params url.Values) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *API) AccessAPI2(baseURL, action string, params map[string]interface{}) (retVal *ResponseResult, err error) {
|
func (a *API) AccessAPI2(baseURL, action string, params map[string]interface{}) (retVal *ResponseResult, err error) {
|
||||||
if params == nil {
|
// if params == nil {
|
||||||
panic("params is nil!")
|
// panic("params is nil!")
|
||||||
}
|
// }
|
||||||
|
|
||||||
params2 := utils.Map2URLValues(params)
|
params2 := utils.Map2URLValues(params)
|
||||||
if baseURL == mtpsAPIURL {
|
if baseURL == mtpsAPIURL {
|
||||||
@@ -248,6 +249,7 @@ func (a *API) AccessAPI2(baseURL, action string, params map[string]interface{})
|
|||||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
||||||
request.Header.Set("Referer", "https://page.peisong.meituan.com/open/admin/poilist")
|
request.Header.Set("Referer", "https://page.peisong.meituan.com/open/admin/poilist")
|
||||||
if baseURL != mtpsAPIURL {
|
if baseURL != mtpsAPIURL {
|
||||||
|
request.Header.Set("csrfToken", a.token)
|
||||||
a.FillRequestCookies(request)
|
a.FillRequestCookies(request)
|
||||||
}
|
}
|
||||||
return request
|
return request
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func init() {
|
|||||||
// prod
|
// prod
|
||||||
// api = New("3c0a05d464c247c19d7ec13accc78605", "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE")
|
// api = New("3c0a05d464c247c19d7ec13accc78605", "b1M}9?:sTbsB[OF2gNORnN(|(iy9rB8(`7]|[wGLnbmt`evfM>E:A90DjHAW:UPE")
|
||||||
|
|
||||||
api.SetCookie("token", "GsfR99YCT8leEBnY39YxPeWTJiSmetA3NGl8G8u1Mv29V4KLYIA9rH3fhw-uDL7VwM4jKPfNwH8D_vOPg3cRYg")
|
api.SetCookie("token", "oo3x6pAld4SskzvbEOnSslWUUQwc6w2m7uCfppCEnvRWzHVqctujL0xzLCkro6qj7mowU51zl99ExVUxgJjJ_Q")
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleError(t *testing.T, err error) {
|
func handleError(t *testing.T, err error) {
|
||||||
|
|||||||
@@ -1,10 +1,58 @@
|
|||||||
package mtpsapi
|
package mtpsapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi"
|
||||||
|
"git.rosy.net.cn/baseapi/platformapi"
|
||||||
|
>>>>>>> 6b4ee9a49b7be7d021c71cd098aeef6c9e75e5c2
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (a *API) AccessStorePage(fullURL string, bizParams map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
|
||||||
|
if a.GetCookieCount() == 0 {
|
||||||
|
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
||||||
|
}
|
||||||
|
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||||
|
func() *http.Request {
|
||||||
|
var request *http.Request
|
||||||
|
if isPost {
|
||||||
|
request, _ = http.NewRequest(http.MethodPost, fullURL, strings.NewReader(utils.Map2URLValues(bizParams).Encode()))
|
||||||
|
request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
||||||
|
request.Header.Set("Referer", "https://page.peisong.meituan.com/open/admin/poilist")
|
||||||
|
} else {
|
||||||
|
request, _ = http.NewRequest(http.MethodGet, utils.GenerateGetURL(fullURL, "", bizParams), nil)
|
||||||
|
}
|
||||||
|
a.FillRequestCookies(request)
|
||||||
|
return request
|
||||||
|
},
|
||||||
|
a.config,
|
||||||
|
func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) {
|
||||||
|
if jsonResult1 == nil {
|
||||||
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||||
|
}
|
||||||
|
if strings.Contains(bodyStr, "登录") || strings.Contains(bodyStr, "访问的内容") {
|
||||||
|
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("cookie可能过期了!")
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
if jsonResult1["error_response"] != nil {
|
||||||
|
errLevel = platformapi.ErrLevelGeneralFail
|
||||||
|
err = utils.NewErrorCode(jsonResult1["error_response"].(map[string]interface{})["zh_desc"].(string), jsonResult1["error_response"].(map[string]interface{})["code"].(string))
|
||||||
|
baseapi.SugarLogger.Debugf("jdeclp AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||||
|
}
|
||||||
|
retVal = jsonResult1
|
||||||
|
}
|
||||||
|
return errLevel, err
|
||||||
|
})
|
||||||
|
return retVal, err
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) PagePoiUpdate(outerPoiID, contactName, contactPhone, contactEmail string) (err error) {
|
func (a *API) PagePoiUpdate(outerPoiID, contactName, contactPhone, contactEmail string) (err error) {
|
||||||
|
<<<<<<< HEAD
|
||||||
// if outerPoiID == "" || contactName == "" || contactPhone == "" || contactEmail == "" {
|
// if outerPoiID == "" || contactName == "" || contactPhone == "" || contactEmail == "" {
|
||||||
// return fmt.Errorf("所有参数必须都要有值")
|
// return fmt.Errorf("所有参数必须都要有值")
|
||||||
// }
|
// }
|
||||||
@@ -15,9 +63,32 @@ func (a *API) PagePoiUpdate(outerPoiID, contactName, contactPhone, contactEmail
|
|||||||
// "contactEmail": contactEmail,
|
// "contactEmail": contactEmail,
|
||||||
// }
|
// }
|
||||||
// _, err = a.AccessAPI2("https://page.peisong.meituan.com/api", "haikuiopen/haikui/open/partner/poi/update", params)
|
// _, err = a.AccessAPI2("https://page.peisong.meituan.com/api", "haikuiopen/haikui/open/partner/poi/update", params)
|
||||||
|
=======
|
||||||
|
if outerPoiID == "" || contactName == "" || contactPhone == "" || contactEmail == "" {
|
||||||
|
return fmt.Errorf("所有参数必须都要有值")
|
||||||
|
}
|
||||||
|
params := map[string]interface{}{
|
||||||
|
"outerPoiId": outerPoiID,
|
||||||
|
"contactName": contactName,
|
||||||
|
"contactPhone": contactPhone,
|
||||||
|
"contactEmail": contactEmail,
|
||||||
|
}
|
||||||
|
if token, err := a.RefreshToken(); err == nil {
|
||||||
|
a.token = token
|
||||||
|
}
|
||||||
|
_, err = a.AccessAPI2("https://page.peisong.meituan.com/api", "haikuiopen/haikui/open/partner/poi/update", params)
|
||||||
|
>>>>>>> 6b4ee9a49b7be7d021c71cd098aeef6c9e75e5c2
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *API) RefreshToken() (token string, err error) {
|
||||||
|
result, err := a.AccessStorePage("https://peisong.meituan.com/api/haikuiopen/haikui/open/auth/csrf/token/refresh", nil, true)
|
||||||
|
if err == nil {
|
||||||
|
token = result["tokens"].(map[string]interface{})["csrfToken"].(string)
|
||||||
|
}
|
||||||
|
return token, err
|
||||||
|
}
|
||||||
|
|
||||||
func (a *API) GetAccountDetail() (err error) {
|
func (a *API) GetAccountDetail() (err error) {
|
||||||
params := map[string]interface{}{}
|
params := map[string]interface{}{}
|
||||||
_, err = a.AccessAPI2("https://peisong.meituan.com/api", "haikuiopen/haikui/open/partner/base/detail", params)
|
_, err = a.AccessAPI2("https://peisong.meituan.com/api", "haikuiopen/haikui/open/partner/base/detail", params)
|
||||||
|
|||||||
@@ -27,3 +27,11 @@ func TestGetStoreStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(utils.Format4Output(result, false))
|
t.Log(utils.Format4Output(result, false))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRefreshToken(t *testing.T) {
|
||||||
|
result, err := api.RefreshToken()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(utils.Format4Output(result, false))
|
||||||
|
}
|
||||||
|
|||||||
@@ -44,3 +44,13 @@ func TestCreateH5UnitorderOrder(t *testing.T) {
|
|||||||
Body: "test",
|
Body: "test",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPayRefund(t *testing.T) {
|
||||||
|
api.PayRefund(&PayRefundParam{
|
||||||
|
Trxamt: 1250,
|
||||||
|
Reqsn: utils.GetUUID(),
|
||||||
|
// OldReqsn: orderPay.VendorOrderID,
|
||||||
|
Remark: "系统退款,商品数量错误",
|
||||||
|
OldTrxID: "122094350000087981",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user