This commit is contained in:
yan.y
2024-05-14 23:42:22 +08:00
parent 19f2cac258
commit 2f90ee9e17
10 changed files with 89 additions and 31 deletions
+3 -2
View File
@@ -22,7 +22,7 @@ type TimeObject struct {
func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum int, times []string) map[string][]TimeObject {
// 获取当前时间
currentTime := time.Now().AddDate(0, 0, 1)
currentTime := time.Now()
// 计算半小时后的时间
halfHourLater := currentTime.Add(time.Duration(minute) * time.Minute)
@@ -56,7 +56,8 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
orderNum, existOrderNum := orderNumMap[nextHour.Format("2006-01-02 15:04")]
if (nextHour.Hour() >= workStart && nextHour.Hour() < workEnd) && (!existsDay && !existsHour) && !existOrderTime {
key := nextHour.Format("2006-01-02")
if _, ok := serviceDaysMap[key]; len(serviceDaysMap) > 0 && !ok {
key1 := nextHour.Format("2006-01-02 15:04")
if _, ok := serviceDaysMap[key1]; len(serviceDaysMap) > 0 && !ok {
//不存在服务配置中返回false
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
Time: nextHour.Format("15:04"),
+12 -2
View File
@@ -2,6 +2,7 @@ package utils
import (
"fmt"
"math"
"pet-house.com/business/models"
"testing"
)
@@ -17,6 +18,15 @@ func TestGetStrDays(t *testing.T) {
Type: 2,
Content: "12",
}
days := GetStrDays(7, 30, ReserveMap, nil, 1, nil, 2)
fmt.Println(days)
//days := GetStrDays(7, 30, ReserveMap, nil, 1, nil, 2)
//fmt.Println(days)
}
func TestCalc(t *testing.T) {
i := math.Round(386 * (float64(85) / 100))
fmt.Println(i)
}
func TestCalc1(t *testing.T) {
i := float64(85) / 100
fmt.Println(i)
}