diff --git a/internal/biz/businesserr/err.go b/internal/biz/businesserr/err.go index 3bd9943..dcc3558 100644 --- a/internal/biz/businesserr/err.go +++ b/internal/biz/businesserr/err.go @@ -13,6 +13,9 @@ func (e *BusinessErr) Error() string { } var ( + BatchNotSetStartedError = &BusinessErr{Code: ErrCode("400"), Message: "批次开始时间未设置"} + BatchSetEndedError = &BusinessErr{Code: ErrCode("400"), Message: "批次已结束时间未设置"} + BatchNotStartedError = &BusinessErr{Code: ErrCode("400"), Message: "批次未开始"} BatchEndedError = &BusinessErr{Code: ErrCode("400"), Message: "批次已结束"} ) diff --git a/internal/biz/order.go b/internal/biz/order.go index 1d8c3c3..c08c612 100644 --- a/internal/biz/order.go +++ b/internal/biz/order.go @@ -34,6 +34,13 @@ func (this *VoucherBiz) CmbOrder(ctx context.Context, req *bo.OrderCreateReqBo) return nil, product, err3 } + if product.StartTime == nil { + return nil, product, businesserr.BatchNotSetStartedError + } + if product.EndTime == nil { + return nil, product, businesserr.BatchSetEndedError + } + nowTime := time.Now() if nowTime.Before(*product.StartTime) { return nil, product, businesserr.BatchNotStartedError