mtwmapi.ParseErr4RetailDiscountDelete
This commit is contained in:
@@ -175,6 +175,11 @@ type CouponActInfo struct {
|
||||
Status int `json:"status"` // 活动状态
|
||||
}
|
||||
|
||||
type ActItemErrMsg struct {
|
||||
ActID int64 `json:"act_id"`
|
||||
ErrorMsg string `json:"error_msg"`
|
||||
}
|
||||
|
||||
// 批量创建指定商品满减活动或创建店内满减活动
|
||||
// http://developer.waimai.meituan.com/home/docDetail/255
|
||||
func (a *API) FullDiscountBatchSave(poiCode string, actInfo *FullDiscountActInfo, actList []*FullDiscountActDetail, actSkuList []*FullDiscountSku) (actIDList []int64, err error) {
|
||||
@@ -318,15 +323,19 @@ func (a *API) FulllDiscountShippingFeeBatchDelete(poiCode string, actIDList []st
|
||||
|
||||
// 批量创建或更新零售折扣商品
|
||||
// http://developer.waimai.meituan.com/home/docDetail/287
|
||||
func (a *API) RetailDiscountBatchSave(poiCode string, actData []*RetailDiscountActData) (actResult []*RetailDiscountActResult, err error) {
|
||||
func (a *API) RetailDiscountBatchSave(poiCode string, actData []*RetailDiscountActData) (actResult []*RetailDiscountActResult /*failedList []*AppFoodResult, */, err error) {
|
||||
result, err := a.AccessAPI2("act/retail/discount/batchsave", false, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"act_data": string(utils.MustMarshal(actData)),
|
||||
}, resultKeySuccessMsg, "")
|
||||
}, "", "")
|
||||
if err == nil {
|
||||
err = utils.UnmarshalUseNumber([]byte(result.(string)), &actResult)
|
||||
resultMap := result.(map[string]interface{})
|
||||
err = utils.UnmarshalUseNumber([]byte(resultMap[resultKeySuccessMsg].(string)), &actResult)
|
||||
// if err == nil {
|
||||
// failedList, err = handleRetailBatchResult(resultMap[resultKeyMsg])
|
||||
// }
|
||||
}
|
||||
return actResult, err
|
||||
return actResult /*failedList, */, err
|
||||
}
|
||||
|
||||
// 查询门店零售折扣商品
|
||||
@@ -367,6 +376,16 @@ func (a *API) RetailDiscountDelete(poiCode string, actIDList []string) (err erro
|
||||
return err
|
||||
}
|
||||
|
||||
func ParseErr4RetailDiscountDelete(err error) (failedList []*ActItemErrMsg) {
|
||||
if errExt, ok := err.(*utils.ErrorWithCode); ok {
|
||||
var mapData map[string]interface{}
|
||||
if err := utils.UnmarshalUseNumber([]byte(errExt.ErrMsg()), &mapData); err == nil {
|
||||
utils.Map2StructByJson(mapData["error_list"], &failedList, false)
|
||||
}
|
||||
}
|
||||
return failedList
|
||||
}
|
||||
|
||||
// 批量修改零售折扣商品当日活动库存
|
||||
// http://developer.waimai.meituan.com/home/docDetail/290
|
||||
func (a *API) RetailDiscountBatchStock(poiCode, actDataList []*RetailDiscountActDataLimit) (err error) {
|
||||
|
||||
@@ -65,14 +65,14 @@ func TestFulllDiscountShippingFeeList(t *testing.T) {
|
||||
|
||||
func TestRetailDiscountBatchSave(t *testing.T) {
|
||||
result, err := api.RetailDiscountBatchSave(testPoiCode, []*RetailDiscountActData{&RetailDiscountActData{
|
||||
AppFoodCode: "5246",
|
||||
AppFoodCode: "1140",
|
||||
UserType: UserTypeAll,
|
||||
StartTime: time.Now().Unix(),
|
||||
EndTime: time.Now().Add(24 * time.Hour).Unix(),
|
||||
OrderLimit: 1,
|
||||
DayLimit: 1,
|
||||
SettingType: SettingTypeAsDiscount,
|
||||
DiscountCoefficient: 9.7,
|
||||
DiscountCoefficient: 0.97,
|
||||
}})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
@@ -102,3 +102,13 @@ func TestInStoreCouponList(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestParseErr4RetailDiscountDelete(t *testing.T) {
|
||||
errStr := `
|
||||
{"error_list":[{"act_id":1053302130,"error_msg":"活动ID不存在"},{"act_id":1053302127,"error_msg":"活动ID不存在"},{"act_id":1053302128,"error_msg":"活动ID不存在"},{"act_id":1053302129,"error_msg":"活动ID不存在"},{"act_id":1053302135,"error_msg":"活动ID不存在"},{"act_id":1053302132,"error_msg":"活动ID不存在"},{"act_id":1053302123,"error_msg":"活动ID不存在"},{"act_id":1053302125,"error_msg":"活动ID不存在"},{"act_id":1053302124,"error_msg":"活动ID不存在"},{"act_id":1053302133,"error_msg":"活动ID不存在"},{"act_id":1053302126,"error_msg":"活动ID不存在"},{"act_id":1053302134,"error_msg":"活动ID不存在"},{"act_id":1053302131,"error_msg":"活动ID不存在"}]}
|
||||
|
||||
`
|
||||
errExt := utils.NewErrorCode(errStr, "")
|
||||
failedList := ParseErr4RetailDiscountDelete(errExt)
|
||||
t.Log(utils.Format4Output(failedList, false))
|
||||
}
|
||||
|
||||
@@ -13,3 +13,10 @@ func TestCommentQuery(t *testing.T) {
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestCommentAddReply(t *testing.T) {
|
||||
err := api.CommentAddReply("24617232", 2947288966, "非常抱歉让您没有得到十分满意的购物体验,我们会及时与您联系进行确认并解决问题!")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,6 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
if jsonResult1 == nil {
|
||||
return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil")
|
||||
}
|
||||
retVal = jsonResult1[resultKey]
|
||||
if errObj, ok := jsonResult1["error"]; ok {
|
||||
baseapi.SugarLogger.Debugf("mtwm AccessAPI failed, jsonResult1:%s", utils.Format4Output(jsonResult1, true))
|
||||
errorInfo := errObj.(map[string]interface{})
|
||||
@@ -176,6 +175,10 @@ func (a *API) AccessAPI2(cmd string, isGet bool, bizParams map[string]interface{
|
||||
return platformapi.ErrLevelRecoverableErr, newErr
|
||||
}
|
||||
return platformapi.ErrLevelCodeIsNotOK, newErr
|
||||
} else if resultKey != "" {
|
||||
retVal = jsonResult1[resultKey]
|
||||
} else {
|
||||
retVal = jsonResult1
|
||||
}
|
||||
return platformapi.ErrLevelSuccess, nil
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user