package orderstatus type Info struct { Label string Class string Step int Terminal bool } var statuses = map[string]Info{ "pending": {Label: "В ожидании", Class: "status--pending", Step: 1}, "unpaid": {Label: "Не оплачено", Class: "status--unpaid", Step: 1}, "paid": {Label: "Оплачено", Class: "status--paid", Step: 2}, "processing": {Label: "В обработке", Class: "status--processing", Step: 3}, "shipped": {Label: "Отправлен", Class: "status--shipped", Step: 4}, "delivered": {Label: "Доставлен", Class: "status--delivered", Step: 5}, "cancelled": {Label: "Отменён", Class: "status--cancelled", Step: 0, Terminal: true}, "refunded": {Label: "Возврат", Class: "status--refunded", Step: 0, Terminal: true}, // совместимость со старыми заказами "new": {Label: "В ожидании", Class: "status--pending", Step: 1}, "confirmed": {Label: "Оплачено", Class: "status--paid", Step: 2}, } // Timeline — основной путь доставки (для таймлайна в кабинете) var Timeline = []string{"pending", "paid", "processing", "shipped", "delivered"} // AllCodes — все статусы для выбора в админке var AllCodes = []string{ "pending", "unpaid", "paid", "processing", "shipped", "delivered", "cancelled", "refunded", } func Normalize(code string) string { if code == "new" { return "pending" } if code == "confirmed" { return "paid" } return code } func Get(code string) Info { code = Normalize(code) if s, ok := statuses[code]; ok { return s } return Info{Label: code, Class: "status--pending", Step: 1} } func Label(code string) string { return Get(code).Label } func Class(code string) string { return Get(code).Class } func Step(code string) int { return Get(code).Step } func IsTerminal(code string) bool { return Get(code).Terminal } func Valid(code string) bool { _, ok := statuses[Normalize(code)] return ok }