完善套餐与账单接口 & 完善支付数据保存,记录实付价格并关联优惠券
This commit is contained in:
30
web/globals/orm/timez.go
Normal file
30
web/globals/orm/timez.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package orm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type DateTime struct {
|
||||
time.Time
|
||||
}
|
||||
|
||||
func (dt *DateTime) Scan(value any) error {
|
||||
switch v := value.(type) {
|
||||
case time.Time:
|
||||
dt.Time = v
|
||||
case string:
|
||||
t, err := time.Parse(time.RFC3339, v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dt.Time = t
|
||||
default:
|
||||
return fmt.Errorf("unsupported type: %T", value)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dt DateTime) Value() (any, error) {
|
||||
return dt.Time.Format(time.RFC3339), nil
|
||||
}
|
||||
Reference in New Issue
Block a user