diff --git a/platformapi/mtwmapi/im.go b/platformapi/mtwmapi/im.go index 0266902c..e24295ac 100644 --- a/platformapi/mtwmapi/im.go +++ b/platformapi/mtwmapi/im.go @@ -79,17 +79,17 @@ func (a *API) MsgSend(pushContent string) (interface{}, error) { } // GetConnectionToken 获取长连接的token https://developer.waimai.meituan.com/home/docDetail/461 -func (a *API) GetConnectionToken() (retVal interface{}, err error) { - retVal, err = a.AccessAPI("wm/IM/getConnectionToken", false, nil) - return retVal, err -} +//func (a *API) GetConnectionToken() (retVal interface{}, err error) { +// retVal, err = a.AccessAPI("wm/IM/getConnectionToken", false, nil) +// return retVal, err +//} // MsgRead 设置消息已读 https://open-shangou.meituan.com/home/docDetail/465 -func (a *API) MsgRead(appPoiCode string, msgID, openUserID int) error { - _, err := a.AccessAPI("/wm/IM/msgRead", false, map[string]interface{}{ - "app_poi_code": appPoiCode, - "msg_id": msgID, - "open_user_id": openUserID, - }) - return err -} +//func (a *API) MsgRead(appPoiCode string, msgID, openUserID int) error { +// _, err := a.AccessAPI("/wm/IM/msgRead", false, map[string]interface{}{ +// "app_poi_code": appPoiCode, +// "msg_id": msgID, +// "open_user_id": openUserID, +// }) +// return err +//} diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 423260b6..9378e3f9 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -20,13 +20,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") + api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_ovSLnyKTsMNx0RxMzJ1C7w") //token_n4TwqCntWWuvQwAawzxC0w + //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_ovSLnyKTsMNx0RxMzJ1C7w") //token_n4TwqCntWWuvQwAawzxC0w cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index b6770ec2..0477d849 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -20,6 +20,14 @@ const ( const ( SellStatusOnline = 0 // 上架 SellStatusOffline = 1 // 下架 + + SpecialAttrBrand = "1200000088" //属性id,取值范围仅支持两个:1200000088-品牌, 1200000094-产地 + SpecialAttrProducer = "1200000094" + + TypeCategory = 1 //1-类目,2-类目属性 不传默认1 + TypeCategoryAttr = 2 + + NeedYes = "1" //1-必传,2-非必传 ) const ( // {"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId":1300005199,"value":"非有机"}]}, @@ -445,12 +453,12 @@ type CategoryAttrValueListResult struct { //category/attr/value/list 查询特殊属性的属性值列表 //https://open-shangou.meituan.com/home/docDetail/387 -func (a *API) CategoryAttrValueList(attr_id int64, keyword string, page_num, page_size int) (categoryAttrValueListResult []*CategoryAttrValueListResult, err error) { +func (a *API) CategoryAttrValueList(attr_id int64, keyword string) (categoryAttrValueListResult []*CategoryAttrValueListResult, err error) { result, err := a.AccessAPI("gw/category/attr/value/list", true, map[string]interface{}{ "attr_id": attr_id, "keyword": keyword, - "page_num": page_num, - "page_size": page_size, + "page_num": 1, + "page_size": 20, }) if err == nil { utils.Map2StructByJson(result, &categoryAttrValueListResult, false) @@ -458,6 +466,39 @@ func (a *API) CategoryAttrValueList(attr_id int64, keyword string, page_num, pag return categoryAttrValueListResult, err } +type RetailRecommendTagResp struct { + UpcCode string `json:"upc_code"` //条形码编号 如类目匹配失败,返回null + Name string `json:"name"` //商品名称 如类目匹配失败,返回null + TagID int `json:"tag_id"` //美团内部类目id + GeneralAttrs []GeneralAttrs +} + +type GeneralAttrs struct { + AttrID string `json:"attr_id"` //属性id + AttrName string `json:"attr_name"` //属性名称 + ValueList []ValueList +} +type ValueList struct { + ValueID string `json:"value_id"` //属性值id + Value string `json:"value"` //属性值 +} + +// RetailRecommendTag 根据商品UPC或商品名称或类目ID查询平台推荐类目及类目属性信息 +func (a *API) RetailRecommendTag(name, appPoiCode string, tagID, tagType int) (retVal *RetailRecommendTagResp, err error) { + result, err := a.AccessAPI("retail/recommend/tag", true, map[string]interface{}{ + "name": name, + "app_poi_code": appPoiCode, + "tag_id": tagID, + "type": tagType, + }) + if err == nil { + if err = utils.Map2StructByJson(result, &retVal, false); err == nil { + return retVal, nil + } + } + return nil, err +} + // 就是厂商商品类别 func (a *API) RetailGetSpTagIds() (tagIds []*RetailTag, err error) { result, err := a.AccessAPI("retail/getSpTagIds", true, nil) diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index 7470b5ae..77cfa38c 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -376,7 +376,8 @@ func TestRetailSellStatus2(t *testing.T) { } func TestCategoryAttrList(t *testing.T) { - result, err := api.CategoryAttrList(200002680) + //result, err := api.CategoryAttrList(200002680) + result, err := api.CategoryAttrList(200005621) if err != nil { t.Fatal(err) } @@ -384,13 +385,24 @@ func TestCategoryAttrList(t *testing.T) { } func TestCategoryAttrValueList(t *testing.T) { - result, err := api.CategoryAttrValueList(100002442, "是", 1, 5) + result, err := api.CategoryAttrValueList(1200000088, "苹果", 1, 5) if err != nil { t.Fatal(err) } t.Log(utils.Format4Output(result, false)) } +func TestRetailRecommendTag(t *testing.T) { + result, err := api.RetailRecommendTag("飞利浦电吹风", "", 0, 1) + if err != nil { + t.Fatal(err) + } + if result == nil { + t.Fatal("should have items") + } + t.Log(utils.Format4Output(result, false)) +} + func TestSplit(t *testing.T) { param := "门店内存在重复的分类:【柑桔柚类】 【底料】 【火锅】,请先删除重复分类后再操作。" firstIndex := strings.Index(param, "【") diff --git a/platformapi/tao_vegetable/store_test.go b/platformapi/tao_vegetable/store_test.go index cb4f02f6..f9aa2a8e 100644 --- a/platformapi/tao_vegetable/store_test.go +++ b/platformapi/tao_vegetable/store_test.go @@ -3,6 +3,7 @@ package tao_vegetable import ( "fmt" "git.rosy.net.cn/baseapi" + "git.rosy.net.cn/baseapi/platformapi/sfps2" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability587/domain" "git.rosy.net.cn/baseapi/platformapi/tao_vegetable/sdk/ability587/request" "git.rosy.net.cn/baseapi/utils" @@ -136,9 +137,17 @@ func TestUpdateStoreTest(t *testing.T) { } } -func TestDelete(t *testing.T) { - err := apiTao.ShopUpdateStatus("JX668594", 1) +func TestShopUpdateStatus(t *testing.T) { + err := apiTao.ShopUpdateStatus("JX667321", 1) if err != nil { fmt.Println(err) } } + +func TestSFStore(t *testing.T) { + var ans string + for k, _ := range sfps2.SFCityStoreIDs { + ans += `"` + k + `",` + } + fmt.Printf("%s", ans) +}