|
|
|
@ -10,6 +10,7 @@ import (
|
|
|
|
|
"miniapp/model/app/request"
|
|
|
|
|
"miniapp/model/app/response"
|
|
|
|
|
"miniapp/model/common"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
@ -76,22 +77,64 @@ func (UserService) UpdateUserInfo(e *app.User) (err error) {
|
|
|
|
|
if len(hospital.Todos) != 0 {
|
|
|
|
|
var userTodos []common.UserTodo
|
|
|
|
|
for _, todo := range hospital.Todos {
|
|
|
|
|
//手术时间
|
|
|
|
|
parse, _ := time.Parse("2006-01-02", e.SurgeryTime)
|
|
|
|
|
//提醒时间
|
|
|
|
|
split := strings.Split(todo.RemindDay, "-")
|
|
|
|
|
a1, _ := strconv.Atoi(split[0])
|
|
|
|
|
a2, _ := strconv.Atoi(split[1])
|
|
|
|
|
|
|
|
|
|
//手术前
|
|
|
|
|
if todo.RemindPeriod == 0 {
|
|
|
|
|
t1 := parse.AddDate(0, 0, -a1)
|
|
|
|
|
t2 := parse.AddDate(0, 0, -a2)
|
|
|
|
|
|
|
|
|
|
days := t1.Sub(t2).Hours() / 24
|
|
|
|
|
for i := int(-days); i <= 0; i++ {
|
|
|
|
|
for _, s := range strings.Split(todo.RemindTime, ",") {
|
|
|
|
|
userTodos = append(userTodos, common.UserTodo{
|
|
|
|
|
Content: todo.Content,
|
|
|
|
|
UserId: int(e.ID),
|
|
|
|
|
IsFinish: 0,
|
|
|
|
|
RemindTime: s,
|
|
|
|
|
Frequency: todo.Frequency,
|
|
|
|
|
RemindPeriod: todo.RemindPeriod,
|
|
|
|
|
RemindDay: t1.AddDate(0, 0, i).Format("2006-01-02"),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//手术后
|
|
|
|
|
if todo.RemindPeriod == 1 {
|
|
|
|
|
{
|
|
|
|
|
t1 := parse.AddDate(0, 0, a1)
|
|
|
|
|
t2 := parse.AddDate(0, 0, a2)
|
|
|
|
|
|
|
|
|
|
days := t1.Sub(t2).Hours() / 24
|
|
|
|
|
for i := 0; i <= int(days*-1); i++ {
|
|
|
|
|
for _, s := range strings.Split(todo.RemindTime, ",") {
|
|
|
|
|
userTodos = append(userTodos, common.UserTodo{
|
|
|
|
|
Content: todo.Content,
|
|
|
|
|
UserId: int(e.ID),
|
|
|
|
|
IsFinish: 0,
|
|
|
|
|
RemindTime: s,
|
|
|
|
|
Frequency: todo.Frequency,
|
|
|
|
|
RemindPeriod: todo.RemindPeriod,
|
|
|
|
|
RemindDay: t1.AddDate(0, 0, i).Format("2006-01-02"),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
err = global.GVA_DB.Create(&userTodos).Error
|
|
|
|
|
if err != nil {
|
|
|
|
|
global.GVA_LOG.Error("创建用户Todo列表失败", zap.Error(err))
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err
|
|
|
|
|