func FormNotification(context *TaxiContext, ow *d.OrderWrapper, previous_state int, car_info CarInfo, deliv_time time.Time) *s.OutPkg { var text string switch ow.OrderState { case ORDER_ASSIGNED: if previous_state != ORDER_ASSIGNED { text = fmt.Sprintf("%v %v, время подачи %v.", nominated, car_info, deliv_time.Format("15:04")) } case ORDER_CAR_SET_OUT: if previous_state != ORDER_CAR_SET_OUT { if previous_state != ORDER_ASSIGNED { text = fmt.Sprintf("%v %v. %v, время подачи %v", nominated, car_info, car_set_out, deliv_time.Format("15:04")) } else { text = fmt.Sprintf("%v, время подачи %v", car_set_out, deliv_time.Format("15:04")) } } case ORDER_CLIENT_WAIT: if previous_state == ORDER_CREATED { text = fmt.Sprintf("%v %v %v %v.", car_arrived, good_passage, nominated, car_info) } else { text = fmt.Sprintf("%v %v", car_arrived, good_passage) } case ORDER_IN_PROCESS: if u.In(previous_state, []int{ORDER_CLIENT_WAIT, ORDER_DOWNTIME}) { return nil } else if previous_state == ORDER_CREATED { text = fmt.Sprintf("%v %v %v %v.", car_arrived, good_passage, nominated, car_info) } else { text = fmt.Sprintf("%v %v", car_arrived, good_passage) } case ORDER_PAYED: text = order_end context.DataBase.Orders.SetActive(ow.OrderId, ow.Source, false) case ORDER_CANCELED: if !u.In(previous_state, []int{ORDER_PAYED, ORDER_NOT_PAYED}) { text = order_end } else { text = order_canceled } context.DataBase.Orders.SetActive(ow.OrderId, ow.Source, false) } if text != "" { out := s.OutPkg{To: ow.Whom, Message: &s.OutMessage{ID: u.GenStringId(), Type: "chat", Body: text}} return &out } return nil }
func IsOrderNotActual(state int) bool { return utils.In(state, []int{0, ORDER_PAYED, ORDER_CANCELED, ORDER_NOT_CREATED, ORDER_NOT_PAYED}) }