package gopkgs import ( "git.getensh.com/common/gopkgsv2/database" "git.getensh.com/common/gopkgsv2/logger" "go.uber.org/zap" "log" "testing" "time" ) // TOrder ... type Order struct { Id uint64 `gorm:"column:id" json:"id"` // OrderSn 订单编号 OrderSn string `gorm:"column:order_sn" json:"order_sn"` // OrderType 订单类型(1钥匙柜养车2预约养车3代驾养车4门店开单5年检6车险) OrderType uint8 `gorm:"column:order_type" json:"order_type"` // UID B端用户id Uid uint64 `gorm:"column:uid" json:"uid"` // YclUID C端用户id YclUid uint64 `gorm:"column:ycl_uid" json:"ycl_uid"` // Sid 商户id Sid uint64 `gorm:"column:sid" json:"sid"` // Shop 商户名称 Shop string `gorm:"column:shop" json:"shop"` // Cid 企业id Cid uint64 `gorm:"column:cid" json:"cid"` // Company 企业名称 Company string `gorm:"column:company" json:"company"` // Status 订单状态(10下单20存钥匙30服务中40第三方服务50已完成60已关闭70已过期) Status uint8 `gorm:"column:status" json:"status"` // SvcStatus 业务状态 SvcStatus uint32 `gorm:"column:svc_status" json:"svc_status"` // TotalAmount 订单金额 TotalAmount uint32 `gorm:"column:total_amount" json:"total_amount"` // DiscountAmount 折扣金额 DiscountAmount uint32 `gorm:"column:discount_amount" json:"discount_amount"` // PayAmount 实际支付金额 PayAmount uint32 `gorm:"column:pay_amount" json:"pay_amount"` ActualAmount uint32 `gorm:"column:actual_amount" json:"actual_amount"` Explain string `gorm:"column:explain" json:"explain"` ExplainUid uint64 `gorm:"column:explain_uid" json:"explain_uid"` ExplainName string `gorm:"column:explain_name" json:"explain_name"` ExplainTime time.Time `gorm:"column:explain_time" json:"explain_time"` // VehicleID 车辆id VehicleId uint64 `gorm:"column:vehicle_id" json:"vehicle_id"` // BrandID 品牌id BrandId string `gorm:"column:brand_id" json:"brand_id"` // PlateNo 车牌号 PlateNo string `gorm:"column:plate_no" json:"plate_no"` // Services 服务简要 Services string `gorm:"column:services" json:"services"` // Payed 支付状态 0-N,1-Y Payed uint8 `gorm:"column:payed" json:"payed"` // Commented 评论状态 0-N,1-Y Commented uint8 `gorm:"column:commented" json:"commented"` // ReservationStart 预约开始时间 ReservationStart time.Time `gorm:"column:reservation_start" json:"reservation_start"` // ReservationEnd 预约结束时间 ReservationEnd time.Time `gorm:"column:reservation_end" json:"reservation_end"` // CreatedTime 下单时间 CreatedTime time.Time `gorm:"column:created_time" json:"created_time"` // PayedTime 支付时间 PayedTime time.Time `gorm:"column:payed_time" json:"payed_time"` // CompletedTime 完成时间 CompletedTime time.Time `gorm:"column:completed_time" json:"completed_time"` IsDelete int64 `gorm:"column:is_delete"` UnPrice int32 `gorm:"column:un_price" json:"un_price"` VehicleSource int64 `gorm:"column:vehicle_source" json:"vehicle_source"` } func loggerNew() *zap.Logger { return logger.New("dev", "debug", "logs/text-access.log", 100, 100, 100, false, true) } func TestDB(t *testing.T) { loggerNew() database.Setup("root", "Pwd#123456", "47.103.130.208:3308", "db_order", "utf8", 100, 10, true) db := database.DB() order := &[]Order{} db = db.Table("t_order").Where(map[string]interface{}{"sid": 1}).Find(order) //if db.Error != nil { // //log.Fatal("err: ", db.Error) //} log.Fatal("err: ", db.Error) }