From b0d1fe4e0acb0fa40c684069c0e9d77d7a65ace3 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 17 十月 2023 15:53:53 +0800 Subject: [PATCH] fix --- model/salesReturn.go | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 40 insertions(+), 2 deletions(-) diff --git a/model/salesReturn.go b/model/salesReturn.go index 88af11a..df99ba7 100644 --- a/model/salesReturn.go +++ b/model/salesReturn.go @@ -16,7 +16,7 @@ Client Client `json:"client" gorm:"foreignKey:ClientId"` SourceType constvar.SalesReturnSourceType `gorm:"source_type" json:"sourceType"` // 婧愬崟绫诲瀷锛�1閿�鍞槑缁嗭級 SourceId int `gorm:"source_id" json:"sourceId"` // 婧愬崟id - Source SalesDetails `gorm:"foreignKey:SourceId" json:"Source"` + Source SalesDetails `gorm:"foreignKey:SourceId" json:"source"` Number string `json:"number" gorm:"column:number;type:varchar(255);comment:閫�璐у崟鍙�"` Repository string `json:"repository" gorm:"column:repository;type:varchar(255);comment:浠撳簱"` MemberId int `json:"memberId" gorm:"column:member_id;type:int;comment:璐熻矗浜篿d"` @@ -31,6 +31,7 @@ AmountShouldRefund decimal.Decimal `gorm:"column:amount_should_refund;type:decimal(12,2);comment:搴旈��娆鹃噾棰�" json:"amountShouldRefund"` // 搴旈��娆鹃噾棰� AmountHasRefund decimal.Decimal `gorm:"column:amount_has_refund;type:decimal(12,2);comment:宸查��娆鹃噾棰�" json:"amountHasRefund"` // 宸查��娆鹃噾棰� AmountTotal decimal.Decimal `gorm:"column:amount_total;type:decimal(12,2);comment:閫�璐т骇鍝佹�婚噾棰�" json:"-"` + CodeStandID string `json:"codeStandID" gorm:"column:code_stand_id;type:varchar(255);comment:缂栫爜id"` CrmModel } @@ -45,6 +46,7 @@ PageSize int Preload bool Ids []int + MemberIds []int } ) @@ -70,7 +72,15 @@ if len(slf.Ids) != 0 { db = db.Where("id in ?", slf.Ids) } - + if slf.SourceType != 0 { + db = db.Where("source_type = ?", slf.SourceType) + } + if slf.SourceId != 0 { + db = db.Where("source_id = ?", slf.SourceId) + } + if slf.ClientId != 0 { + db = db.Where("client_id = ?", slf.ClientId) + } if slf.Preload { db = db.Preload("Client"). Preload("Member"). @@ -99,6 +109,10 @@ db = db.Where("amount_has_refund = ?", slf.Keyword) } + } + + if len(slf.MemberIds) > 0 { + db = db.Where("sales_return.member_id in ?", slf.MemberIds) } return db @@ -188,3 +202,27 @@ slf.Preload = preload return slf } +func (slf *SalesReturnSearch) SetSourceType(sourceType constvar.SalesReturnSourceType) *SalesReturnSearch { + slf.SourceType = sourceType + return slf +} + +func (slf *SalesReturnSearch) SetSourceId(sourceId int) *SalesReturnSearch { + slf.SourceId = sourceId + return slf +} + +func (slf *SalesReturnSearch) SetClientId(clientId int) *SalesReturnSearch { + slf.ClientId = clientId + return slf +} + +func (slf *SalesReturnSearch) UpdateByMap(data map[string]interface{}) error { + var db = slf.build() + return db.Updates(data).Error +} + +func (slf *SalesReturnSearch) SetMemberIds(memberIds []int) *SalesReturnSearch { + slf.MemberIds = memberIds + return slf +} -- Gitblit v1.8.0