Parcourir la source

预约功能优化

guodj il y a 4 ans
Parent
commit
db81c54896
1 fichiers modifiés avec 6 ajouts et 0 suppressions
  1. 6 0
      service/reservation/reservation.go

+ 6 - 0
service/reservation/reservation.go

@@ -114,9 +114,15 @@ func (s Service) Cancel(userInfo request.UserInfo, id int) error {
 	if err != nil {
 		return err
 	}
+	if entity == nil {
+		return errors.New("未找到当前预约信息,请重试")
+	}
 	if int32(entity.UserId) != userInfo.Id {
 		return errors.New("当前预约只能由预约人取消")
 	}
+	if entity.StartTime.Sub(gtime.Now()) > 0 {
+		return errors.New("预约开始不允许取消")
+	}
 	updatedMap := service.SetUpdatedMap(&userInfo)
 	updatedMap["Status"] = 2
 	_, err = s.Dao.M.Data(updatedMap).WherePri(id).Update()