// Make sure order tracking number not conflict, by checking if tn exists, // change to another but not checked again. So, it's limited. func makeSureOrderTNUnique(tn int64) int64 { if order, err := orderdao.GetOrder("track_number", tn); err != nil { panic(err) } else if order == nil { return 0 // success } else { return model.GenerateOrderId() // try only once. } }
func (s *OrderService) GetOrder(id int) (*model.Order, error) { return orderdao.GetOrder("id", id) }
func (s *OrderService) GetOrderByTrackingNumber(trackNumber int64) (*model.Order, error) { return orderdao.GetOrder("track_number", trackNumber) }
// >> copied to service.order func GetOrder(id int) (*model.Order, error) { return orderdao.GetOrder("id", id) }