Sfoglia il codice sorgente

预约功能优化

guodj 4 anni fa
parent
commit
db81c54896
1 ha cambiato i file con 6 aggiunte e 0 eliminazioni
  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()