|
@@ -128,6 +128,11 @@ func (c *LeaveController) Leave_Add() {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+ if startTime.After(endTime) {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "开始时间不能大于结束时间"}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
if T_type == Attendance.AttendanceDaysOff {
|
|
|
duration := Attendance.GetRemainingDaysOff(c.User.T_uuid)
|
|
|
if T_duration > duration {
|
|
@@ -383,6 +388,37 @@ func (c *LeaveController) Leave_Duration() {
|
|
|
c.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
+ endTime2 := time.Date(endTime.Year(), endTime.Month(), endTime.Day()-1, 17, 30, 0, 0, time.Local)
|
|
|
+ endTime3 := time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 9, 0, 0, 0, time.Local)
|
|
|
+
|
|
|
+ endTime4 := time.Date(endTime.Year(), endTime.Month(), endTime.Day(), 17, 30, 0, 0, time.Local)
|
|
|
+ endTime5 := time.Date(endTime.Year(), endTime.Month(), endTime.Day()+1, 9, 0, 0, 0, time.Local)
|
|
|
+ if endTime.After(endTime2) && endTime.Before(endTime3) {
|
|
|
+ endTime = endTime2
|
|
|
+ }
|
|
|
+
|
|
|
+ if endTime.After(endTime4) && endTime.Before(endTime5) {
|
|
|
+ endTime = endTime4
|
|
|
+ }
|
|
|
+
|
|
|
+ startTime2 := time.Date(startTime.Year(), startTime.Month(), startTime.Day()-1, 17, 30, 0, 0, time.Local)
|
|
|
+ startTime3 := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 9, 0, 0, 0, time.Local)
|
|
|
+
|
|
|
+ startTime4 := time.Date(startTime.Year(), startTime.Month(), startTime.Day(), 17, 30, 0, 0, time.Local)
|
|
|
+ startTime5 := time.Date(startTime.Year(), startTime.Month(), startTime.Day()+1, 9, 0, 0, 0, time.Local)
|
|
|
+ if startTime.After(startTime2) && startTime.Before(startTime3) {
|
|
|
+ startTime = startTime3
|
|
|
+ }
|
|
|
+
|
|
|
+ if startTime.After(startTime4) && startTime.Before(startTime5) {
|
|
|
+ startTime = startTime5
|
|
|
+ }
|
|
|
+
|
|
|
+ if startTime.After(endTime) {
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: 0}
|
|
|
+ c.ServeJSON()
|
|
|
+ return
|
|
|
+ }
|
|
|
|
|
|
//开始时间的小时和分钟
|
|
|
s_h := startTime.Hour()
|
|
@@ -392,16 +428,7 @@ func (c *LeaveController) Leave_Duration() {
|
|
|
diff_day := int(endTime.Sub(startTime).Hours() / 24) // 间隔天数
|
|
|
var diff_hours float32 // 间隔小时
|
|
|
var diff_minutes float32 // 间隔分钟
|
|
|
- if s_h < 9 {
|
|
|
- // 开始小时早于9点,从9点起算
|
|
|
- s_h = 9
|
|
|
- s_mm = 0
|
|
|
- }
|
|
|
- if e_h >= 17 && e_mm > 30 {
|
|
|
- // 结束时间晚于17:30点,到17:30点止
|
|
|
- e_h = 17
|
|
|
- e_mm = 30
|
|
|
- }
|
|
|
+
|
|
|
if e_mm < s_mm {
|
|
|
// 结束分钟数<开始分钟数,向小时借
|
|
|
e_mm += 60
|