waybill_logistics.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. package model
  2. import (
  3. amap "cold-logistics/common/amap"
  4. model2 "cold-logistics/common/model"
  5. "gorm.io/gorm"
  6. )
  7. // 运单物流
  8. type WaybillLogistics struct {
  9. model2.Model
  10. WaybillNo string `json:"waybillNo" gorm:"size:128"` // 单号
  11. Status int `json:"status" gorm:"size:128"` //订单状态:1待派单 2待装车 3待入库 4已装车 5已入库 6已下车 7已出库 8已签收
  12. WarehouseId int `json:"warehouseId" gorm:"size:128"` // 仓库id
  13. CarId int `json:"carId" gorm:"size:128"` // 仓库id
  14. UserId int `json:"userId" gorm:"size:128"` // 司机/仓管id
  15. Lng string `json:"lng" gorm:"size:128;"` // 经度
  16. Lat string `json:"lat" gorm:"size:128;"` // 纬度
  17. Address string `json:"address" gorm:"size:128;"` // 地址
  18. Warehouse WarehouseOmit `json:"warehouse" gorm:"->;foreignkey:WarehouseId;references:Id"`
  19. Car CarOmit `json:"car" gorm:"->;foreignkey:CarId;references:Id"`
  20. model2.ControlBy
  21. model2.ModelTime
  22. model2.DeptBy
  23. }
  24. func (WaybillLogistics) TableName() string {
  25. return "waybill_logistics"
  26. }
  27. func (u *WaybillLogistics) BeforeCreate(tx *gorm.DB) (err error) {
  28. address := amap.GeocodeRegeo(u.Lng, u.Lat)
  29. ac := address.Regeocode.AddressComponent
  30. u.Address = ac.City + ac.District
  31. return
  32. }