From b45b8ce8051e2ad9c80aafa42d1a5892f6a36bce Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 17 十月 2023 15:27:44 +0800 Subject: [PATCH] 初始化一些表shuju --- model/serviceContract.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 47 insertions(+), 2 deletions(-) diff --git a/model/serviceContract.go b/model/serviceContract.go index 9d253af..8c8db4e 100644 --- a/model/serviceContract.go +++ b/model/serviceContract.go @@ -42,7 +42,8 @@ AmountUnInvoiced decimal.Decimal `gorm:"column:amount_not_invoiced;type:decimal(12,2);comment:鏈紑绁ㄩ噾棰�" json:"amountUnInvoiced"` // 鏈紑绁ㄩ噾棰� AmountTotal decimal.Decimal `gorm:"column:amount_total;type:decimal(12,2);comment:浠风◣鍚堣" json:"amountTotal"` // 浠风◣鍚堣 Products []*Product `json:"products" gorm:"many2many:service_contract_product;"` - gorm.Model `json:"-"` + CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"` + CrmModel } ServiceContractSearch struct { @@ -55,10 +56,11 @@ PageNum int PageSize int Preload bool + MemberIds []int } ) -func (ServiceContract) TableName() string { +func (slf *ServiceContract) TableName() string { return "service_contract" } @@ -108,6 +110,11 @@ db = db.Where("amount_receivable = ?", slf.Keyword) } + + if len(slf.MemberIds) > 0 { + db = db.Where("service_contract.member_id in ?", slf.MemberIds) + } + if slf.Preload { db = db. Preload("Client"). @@ -125,6 +132,19 @@ Preload("Contact") } + if slf.SalesDetailsId != 0 { + db = db.Where("sales_details_id = ?", slf.SalesDetailsId) + } + + if slf.QuotationId != 0 { + db = db.Where("quotation_id = ?", slf.QuotationId) + } + if slf.SaleChanceId != 0 { + db = db.Where("sale_chance_id = ?", slf.SaleChanceId) + } + if slf.ContactId != 0 { + db = db.Where("contact_id = ?", slf.ContactId) + } return db } @@ -198,6 +218,31 @@ return slf } +func (slf *ServiceContractSearch) SetMemberIds(memberIds []int) *ServiceContractSearch { + slf.MemberIds = memberIds + return slf +} + +func (slf *ServiceContractSearch) SetSalesDetailsId(salesDetailsId int) *ServiceContractSearch { + slf.SalesDetailsId = salesDetailsId + return slf +} + +func (slf *ServiceContractSearch) SetQuotationId(quotationId int) *ServiceContractSearch { + slf.QuotationId = quotationId + return slf +} + +func (slf *ServiceContractSearch) SetSaleChanceId(saleChanceId int) *ServiceContractSearch { + slf.SaleChanceId = saleChanceId + return slf +} + +func (slf *ServiceContractSearch) SetContactId(contactId int) *ServiceContractSearch { + slf.ContactId = contactId + return slf +} + func (slf *ServiceContractSearch) SetPreload(preload bool) *ServiceContractSearch { slf.Preload = preload return slf -- Gitblit v1.8.0