This commit is contained in:
邹宗楠
2024-02-28 18:41:19 +08:00
parent cd893ad98a
commit a69daacbee
2 changed files with 47 additions and 13 deletions

View File

@@ -453,21 +453,50 @@ func (a *API) RetailDiscountDelete2(poiCode string, actType int, actIDList []str
if actType == 0 { if actType == 0 {
actType = RetailActTypeDirectDown actType = RetailActTypeDirectDown
} }
globals.SugarLogger.Debugf("=========poiCode : %s ,%d ,%s", poiCode, actType, utils.Format4Output(actIDList, false)) if len(actIDList) > 100 {
result, err := a.AccessAPI("act/retail/discount/batchdelete", false, map[string]interface{}{ actList := len(actIDList) % 100
KeyAppPoiCode: poiCode, if actList != 0 {
"act_type": actType, actList = len(actIDList)/100 + 1
"item_ids": strings.Join(actIDList, ","), } else {
}) actList = len(actIDList)
globals.SugarLogger.Debugf("==============resullt := %s", utils.Format4Output(result, false)) }
globals.SugarLogger.Debugf("==============err := %v", err) for i := 0; i < actList; i++ {
var msg string actParamList := ""
if err == nil { if i+1 == actList {
msg = getMsgFromResult(result) 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 { } 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 return failedList, err
} }

View File

@@ -262,3 +262,8 @@ func TestDeleteActSku(t *testing.T) {
fmt.Println(err2) fmt.Println(err2)
} }
func TestCEA(t *testing.T) {
a := []int{1, 2, 3, 4, 5}
fmt.Println(a[2:])
}