diff --git a/platformapi/mtwmapi/act.go b/platformapi/mtwmapi/act.go index eb122e79..605393da 100644 --- a/platformapi/mtwmapi/act.go +++ b/platformapi/mtwmapi/act.go @@ -453,21 +453,50 @@ func (a *API) RetailDiscountDelete2(poiCode string, actType int, actIDList []str if actType == 0 { actType = RetailActTypeDirectDown } - globals.SugarLogger.Debugf("=========poiCode : %s ,%d ,%s", poiCode, actType, utils.Format4Output(actIDList, false)) - result, err := a.AccessAPI("act/retail/discount/batchdelete", false, map[string]interface{}{ - KeyAppPoiCode: poiCode, - "act_type": actType, - "item_ids": strings.Join(actIDList, ","), - }) - globals.SugarLogger.Debugf("==============resullt := %s", utils.Format4Output(result, false)) - globals.SugarLogger.Debugf("==============err := %v", err) - var msg string - if err == nil { - msg = getMsgFromResult(result) + if len(actIDList) > 100 { + actList := len(actIDList) % 100 + if actList != 0 { + actList = len(actIDList)/100 + 1 + } else { + actList = len(actIDList) + } + for i := 0; i < actList; i++ { + actParamList := "" + if i+1 == actList { + actParamList = strings.Join(actIDList[i*100:], ",") + } else { + actParamList = strings.Join(actIDList[i*100:(i+1)*100], ",") + } + result, err := a.AccessAPI("act/retail/discount/batchdelete", false, map[string]interface{}{ + KeyAppPoiCode: poiCode, + "act_type": actType, + "item_ids": actParamList, + }) + globals.SugarLogger.Debugf("==============resullt := %s", utils.Format4Output(result, false)) + globals.SugarLogger.Debugf("==============err := %v", err) + var msg string + if err == nil { + msg = getMsgFromResult(result) + } else { + msg = getMsgFromError(err) + } + failedList = append(failedList, parseErr4RetailDiscountDelete(msg)...) + } } else { - msg = getMsgFromError(err) + result, err := a.AccessAPI("act/retail/discount/batchdelete", false, map[string]interface{}{ + KeyAppPoiCode: poiCode, + "act_type": actType, + "item_ids": strings.Join(actIDList, ","), + }) + var msg string + if err == nil { + msg = getMsgFromResult(result) + } else { + msg = getMsgFromError(err) + } + failedList = append(failedList, parseErr4RetailDiscountDelete(msg)...) } - failedList = parseErr4RetailDiscountDelete(msg) + return failedList, err } diff --git a/platformapi/mtwmapi/act_test.go b/platformapi/mtwmapi/act_test.go index ca1a262d..068f1048 100644 --- a/platformapi/mtwmapi/act_test.go +++ b/platformapi/mtwmapi/act_test.go @@ -262,3 +262,8 @@ func TestDeleteActSku(t *testing.T) { fmt.Println(err2) } + +func TestCEA(t *testing.T) { + a := []int{1, 2, 3, 4, 5} + fmt.Println(a[2:]) +}