新增 获取问诊订单列表-分页,修正取消问诊订单
This commit is contained in:
@@ -2,6 +2,7 @@ package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"hospital-admin-api/api/dao"
|
||||
"hospital-admin-api/api/model"
|
||||
@@ -68,10 +69,19 @@ func (r *OrderInquiryService) CancelOrderInquiry(orderInquiryId int64) (bool, er
|
||||
}
|
||||
|
||||
// 订单完成时间预留5分钟进行操作
|
||||
if !orderInquiry.CompleteTime.IsZero() {
|
||||
if !orderInquiry.CompleteTime.IsEmpty() {
|
||||
// 计算三天后的时间
|
||||
threeDaysLater := orderInquiry.CompleteTime.Add(3 * 24 * time.Hour)
|
||||
if time.Since(threeDaysLater) > 5*time.Minute {
|
||||
threeDaysLater := time.Time(orderInquiry.CompleteTime).Add(3 * 24 * time.Hour)
|
||||
|
||||
// 计算三天后的时间与当前时间的时间差
|
||||
timeDifference := threeDaysLater.Sub(time.Now())
|
||||
fmt.Println(timeDifference)
|
||||
|
||||
if timeDifference < 0 {
|
||||
return false, errors.New("订单已完成,无法取消")
|
||||
}
|
||||
|
||||
if 5*time.Minute > timeDifference {
|
||||
return false, errors.New("距离订单完成时间不足5分钟,无法取消")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user