jiangshuai
2023-12-15 fda60dd56911c03330eb7330ebabd5d46e9d7622
models/operation.go
@@ -33,9 +33,15 @@
      WaybillNumber     string                   `json:"waybillNumber" gorm:"type:varchar(255);comment:运单号"`    //运单号
      Weight            decimal.Decimal          `gorm:"type:decimal(20,2);comment:重量" json:"weight"`           //重量
      LogisticWeight    decimal.Decimal          `gorm:"type:decimal(20,2);comment:物流重量" json:"logisticWeight"` //物流重量
      Source            string                   `json:"source" gorm:"type:varchar(255);comment:来源系统,用于返回修改状态"`
      Details           []*OperationDetails        `json:"details" gorm:"foreignKey:OperationID;references:Id"`
      BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型
      AuditDate     string `json:"auditDate" gorm:"type:varchar(31);comment:审批时间"`
      ReceiverName  string `json:"receiverName" gorm:"type:varchar(31);comment:收货人姓名"`
      ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:联系电话"`
      ReceiverAddr  string `json:"receiverAddr" gorm:"type:varchar(255);comment:收货地址"`
   }
   OperationSearch struct {
@@ -48,6 +54,7 @@
      Preload  bool
      Disuse   bool
      Ids      []int
      Numbers  []string
   }
)
@@ -151,8 +158,7 @@
   }
   if slf.Preload {
      db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation").
         Preload("ToLocation").Preload("LogisticCompany")
      db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("LogisticCompany").Preload("FromLocation").Preload("ToLocation")
   }
   if slf.Disuse {
@@ -331,3 +337,15 @@
   return records, nil
}
func (slf *OperationSearch) MaxAutoIncr() (int, error) {
   var (
      db    = slf.build()
      total int64
   )
   if err := db.Count(&total).Error; err != nil {
      return int(total), fmt.Errorf("max err: %v", err)
   }
   return int(total), nil
}