zhangqian
2023-08-11 7f589e6514eb4074d9a558bf4ff7efef3143b9db
model/salesDetails.go
@@ -28,14 +28,14 @@
      Addressee           string            `json:"addressee" gorm:"column:addressee;type:varchar(255);comment:收件人"`
      Conditions          string            `json:"conditions" gorm:"column:conditions;type:text;comment:条件"`
      Remark              string            `json:"remark" gorm:"column:remark;type:text;comment:备注"`
      Products            []Product         `json:"products" gorm:"many2many:sales_details_product;"`
      Products            []*Product        `json:"products" gorm:"many2many:sales_details_product;"`
      LogisticCompany     string            `json:"logisticCompany" gorm:"column:logistic_company;type:varchar(255);comment:物流公司"`
      LogisticNumber      string            `json:"logisticNumber" gorm:"column:logistic_number;type:varchar(255);comment:物流单号"`
      LogisticCost        float64           `json:"logisticCost" gorm:"column:logistic_cost;type:decimal(10,2);comment:物流费用"`
      AmountReceivable    decimal.Decimal   `gorm:"amount_receivable" json:"amountReceivable"` // 应收金额
      AmountReceived      decimal.Decimal   `gorm:"amount_received" json:"amountReceived"`     // 已收金额
      AmountInvoiced      decimal.Decimal   `gorm:"amount_invoiced" json:"amountInvoiced"`     // 已开票金额
      AmountUnInvoiced    decimal.Decimal   `gorm:"-" json:"amountUnInvoiced"`                 // 未开票金额
      AmountReceivable    decimal.Decimal   `gorm:"column:amount_receivable;type:decimal(12,2);comment:应收金额" json:"amountReceivable"`    // 应收金额
      AmountReceived      decimal.Decimal   `gorm:"column:amount_received;type:decimal(12,2);comment:已收金额" json:"amountReceived"`        // 已收金额
      AmountInvoiced      decimal.Decimal   `gorm:"column:amount_invoiced;type:decimal(12,2);comment:已开票金额" json:"amountInvoiced"`       // 已开票金额
      AmountUnInvoiced    decimal.Decimal   `gorm:"column:amount_not_invoiced;type:decimal(12,2);comment:未开票金额" json:"amountUnInvoiced"` // 未开票金额
      gorm.Model          `json:"-"`
   }
@@ -111,7 +111,7 @@
   return slf
}
func (slf *SalesDetailsSearch) Find() (*SalesDetails, error) {
func (slf *SalesDetailsSearch) First() (*SalesDetails, error) {
   var db = slf.build()
   var record = new(SalesDetails)
   err := db.First(record).Error
@@ -161,3 +161,15 @@
   slf.OrderBy = order
   return slf
}
func (slf *SalesDetailsSearch) UpdateByMap(upMap map[string]interface{}) error {
   var (
      db = slf.build()
   )
   if err := db.Updates(upMap).Error; err != nil {
      return fmt.Errorf("update by map err: %v, upMap: %+v", err, upMap)
   }
   return nil
}