From 78b49f03c4dc2e5b6b00d99475e582834e4b5238 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期一, 07 八月 2023 20:14:20 +0800 Subject: [PATCH] 销售发票管理 --- model/serviceContract.go | 64 +++++++++++++++++++++++-------- 1 files changed, 47 insertions(+), 17 deletions(-) diff --git a/model/serviceContract.go b/model/serviceContract.go index d6a9c5f..f001ccf 100644 --- a/model/serviceContract.go +++ b/model/serviceContract.go @@ -3,29 +3,34 @@ import ( "aps_crm/constvar" "aps_crm/pkg/mysqlx" + "fmt" + "github.com/shopspring/decimal" "gorm.io/gorm" "time" ) type ( ServiceContract struct { - Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"` - Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"` - MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"` - ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:鑱旂郴浜篿d"` - SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"` - ContractId int `json:"contractId" gorm:"column:contract_id;type:int;comment:鍚堝悓id"` - QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"` - ServiceContractTypeId int `json:"serviceContractTypeId" gorm:"column:service_contract_type_id;type:int;comment:鍚堝悓绫诲瀷id"` - SignTime time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛剧害鏃堕棿"` - StartTime time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:寮�濮嬫椂闂�"` - EndTime time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:缁撴潫鏃堕棿"` - ServiceContractStatusId int `json:"serviceContractStatusId" gorm:"column:service_contract_status_id;type:int;comment:鍚堝悓鐘舵�乮d"` - ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:鏈嶅姟娆℃暟"` - Terms string `json:"terms" gorm:"column:terms;type:text;comment:鏉℃"` - Remark string `json:"remark" gorm:"column:remark;type:text;comment:澶囨敞"` - Products []Product `json:"products" gorm:"many2many:serviceContract_product;"` + Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` + ClientId int `json:"clientId" gorm:"column:client_id;type:int;comment:瀹㈡埛id"` + Number string `json:"number" gorm:"column:number;type:varchar(255);comment:鍚堝悓缂栧彿"` + MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"` + ContactId int `json:"contactId" gorm:"column:contact_id;type:int;comment:鑱旂郴浜篿d"` + SaleChanceId int `json:"saleChanceId" gorm:"column:sale_chance_id;type:int;comment:閿�鍞満浼歩d"` + ContractId int `json:"contractId" gorm:"column:contract_id;type:int;comment:鍚堝悓id"` + QuotationId int `json:"quotationId" gorm:"column:quotation_id;type:int;comment:鎶ヤ环鍗昳d"` + ServiceContractTypeId int `json:"serviceContractTypeId" gorm:"column:service_contract_type_id;type:int;comment:鍚堝悓绫诲瀷id"` + SignTime time.Time `json:"signTime" gorm:"column:sign_time;type:datetime;comment:绛剧害鏃堕棿"` + StartTime time.Time `json:"startTime" gorm:"column:start_time;type:datetime;comment:寮�濮嬫椂闂�"` + EndTime time.Time `json:"endTime" gorm:"column:end_time;type:datetime;comment:缁撴潫鏃堕棿"` + ServiceContractStatusId int `json:"serviceContractStatusId" gorm:"column:service_contract_status_id;type:int;comment:鍚堝悓鐘舵�乮d"` + ServiceTimes int `json:"serviceTimes" gorm:"column:service_times;type:int;comment:鏈嶅姟娆℃暟"` + Terms string `json:"terms" gorm:"column:terms;type:text;comment:鏉℃"` + Remark string `json:"remark" gorm:"column:remark;type:text;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"` // 宸插紑绁ㄩ噾棰� + Products []Product `json:"products" gorm:"many2many:serviceContract_product;"` gorm.Model `json:"-"` } @@ -166,3 +171,28 @@ slf.OrderBy = order return slf } + +func (slf *ServiceContractSearch) 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 +} + +func (slf *ServiceContractSearch) First() (*ServiceContract, error) { + var ( + record = new(ServiceContract) + db = slf.build() + ) + + if err := db.First(record).Error; err != nil { + return record, err + } + + return record, nil +} -- Gitblit v1.8.0