From 7f589e6514eb4074d9a558bf4ff7efef3143b9db Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 11 八月 2023 10:32:04 +0800 Subject: [PATCH] 新增,删除,和修改发票时修改销售明细未开票金额和已开票金额 --- model/salesDetails.go | 24 ++++++++++++++++++------ 1 files changed, 18 insertions(+), 6 deletions(-) diff --git a/model/salesDetails.go b/model/salesDetails.go index b318ab7..ff92423 100644 --- a/model/salesDetails.go +++ b/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 +} -- Gitblit v1.8.0