mtwmapi由RetailSellStatus取代RetailSkuSellStatus

This commit is contained in:
gazebo
2019-10-14 18:41:56 +08:00
parent 8b6fc21c28
commit c5b0e1a847
4 changed files with 74 additions and 4 deletions

View File

@@ -106,6 +106,11 @@ type AppFoodResult struct {
ErrorMsg string `json:"error_msg"`
}
type AppFoodResult4SellStatus struct {
AppFoodCode string `json:"appFoodCode"`
Msg string `json:"msg"`
}
// 美团分类没有ID就以名字为唯一标识不论级别都必须不能重名
// name和originName的长度不能超过10个字符字符不是字节
// 创建一级分类originName为空name为新分类名secondaryName为空
@@ -243,6 +248,9 @@ func (a *API) RetailSkuStock(trackInfo, poiCode string, foodData []*BareStoreFoo
}
// retail/sku/sellStatus在部分失败时会返回错误其它相应的批处理函数则会返回成功
// 此接口已准备废弃
// 2019年9月17日开放平台已上线新接口【retail/sellStatus】用于零售类商家批量更新商品售卖状态。请已接入老接口retail/sku/sellStatus的开发者在2019年10月31日前完成接口迁移使用新接口的请求地址https://waimaiopen.meituan.com/api/v1/retail/sellStatus。
// 开放平台将于2019年11月1日开始全面下线老接口retail/sku/sellStatus如开发者逾期未完成接口迁移调用老接口失败所造成的相关问题或损失由商家自行承担。
func (a *API) RetailSkuSellStatus(trackInfo, poiCode string, foodData []*BareStoreFoodInfo, sellStatus int) (failedFoodList []*AppFoodResult, err error) {
_, err = a.AccessAPI2("retail/sku/sellStatus", false, map[string]interface{}{
KeyAppPoiCode: poiCode,
@@ -257,6 +265,29 @@ func (a *API) RetailSkuSellStatus(trackInfo, poiCode string, foodData []*BareSto
return failedFoodList, err
}
// 此接口部分失败也返回成功但错误消息格式errorMsg, appFoodCode与其它两个不一样
func (a *API) RetailSellStatus(trackInfo, poiCode string, foodData []*BareStoreFoodInfo, sellStatus int) (failedFoodList []*AppFoodResult, err error) {
result, err := a.AccessAPI2("retail/sellStatus", false, map[string]interface{}{
KeyAppPoiCode: poiCode,
"food_data": string(utils.MustMarshal(foodData)),
"sell_status": sellStatus,
}, resultKeyMsg, trackInfo)
if err == nil {
var tmpFailedFoodList []*AppFoodResult4SellStatus
if msg, ok := result.(string); ok && msg != "" {
if err = utils.UnmarshalUseNumber([]byte(msg), &tmpFailedFoodList); err == nil {
for _, v := range tmpFailedFoodList {
failedFoodList = append(failedFoodList, &AppFoodResult{
AppFoodCode: v.AppFoodCode,
ErrorMsg: v.Msg,
})
}
}
}
}
return failedFoodList, err
}
func (a *API) RetailGet(poiCode, foodCode string) (food *AppFood, err error) {
result, err := a.AccessAPI("retail/get", true, map[string]interface{}{
KeyAppPoiCode: poiCode,