waybill_logistics.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. package model
  2. import (
  3. amap "cold-delivery/common/amap"
  4. model2 "cold-delivery/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. CoolerBoxId int `json:"coolerBoxId" gorm:"size:128"` // 保温箱id
  15. UserId int `json:"userId" gorm:"size:128"` // 司机/仓管id
  16. Lng string `json:"lng" gorm:"size:128;"` // 经度
  17. Lat string `json:"lat" gorm:"size:128;"` // 纬度
  18. Address string `json:"address" gorm:"size:128;"` // 地址
  19. //Warehouse WarehouseOmit `json:"warehouse" gorm:"->;foreignkey:WarehouseId;references:Id"`
  20. //Car CarOmit `json:"car" gorm:"->;foreignkey:CarId;references:Id"`
  21. CoolerBox CoolerBoxOmit `json:"coolerBox" gorm:"->;foreignkey:CoolerBoxId;references:Id"`
  22. model2.ControlBy
  23. model2.ModelTime
  24. model2.DeptBy
  25. }
  26. func (WaybillLogistics) TableName() string {
  27. return "waybill_logistics"
  28. }
  29. func (u *WaybillLogistics) BeforeCreate(tx *gorm.DB) (err error) {
  30. address := amap.GeocodeRegeo(u.Lng, u.Lat)
  31. ac := address.Regeocode.AddressComponent
  32. u.Address = ac.City + ac.District
  33. return
  34. }