From 530fed8ec225453572d57b15c200ab062c335457 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期三, 01 十一月 2023 19:20:21 +0800 Subject: [PATCH] 公海member_id使用0 --- model/serviceCollectionPlan.go | 42 ++++++++++++++++++++++++++---------------- 1 files changed, 26 insertions(+), 16 deletions(-) diff --git a/model/serviceCollectionPlan.go b/model/serviceCollectionPlan.go index cfe065c..0e81b21 100644 --- a/model/serviceCollectionPlan.go +++ b/model/serviceCollectionPlan.go @@ -7,28 +7,28 @@ "fmt" "github.com/shopspring/decimal" "gorm.io/gorm" - "time" ) type ( // ServiceCollectionPlan 鏀舵璁″垝 ServiceCollectionPlan struct { Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - CollectionType int `gorm:"collection_type" json:"collectionType"` // 绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級 - SourceType constvar.CollectionSourceType `gorm:"source_type" json:"sourceType"` // 婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級 - SourceId int `gorm:"source_id" json:"sourceId"` // 婧愬崟id - PrincipalId int `gorm:"principal_id" json:"principalId"` // 鏀舵璐熻矗浜篒D - Term int `gorm:"term" json:"term"` // 鏈熸 - Percent decimal.Decimal `gorm:"percent" json:"percent"` // 姣斾緥 - Amount decimal.Decimal `gorm:"amount" json:"amount"` // 閲戦 - MoneyType string `gorm:"money_type" json:"moneyType"` // 甯佺 - CollectionDate time.Time `gorm:"collection_date" json:"collectionDate"` // 璁″垝鏀舵鏃ユ湡 - Remark string `gorm:"remark" json:"remark"` // 澶囨敞 - Status constvar.CollectionStatus `gorm:"status" json:"status"` // 鐘舵�侊紙1鏈敹2閮ㄥ垎宸叉敹3宸叉敹锛� - 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"` // 宸叉敹閲戦 - AmountTotal decimal.Decimal `gorm:"column:amount_total;type:decimal(12,2);comment:鎬婚" json:"amountTotal"` // 鎬婚 - FileId int `gorm:"file_id" json:"fileId"` // 闄勪欢id + CollectionType int `gorm:"column:collection_type;type:tinyint;not null;default 0;comment:绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級" json:"collectionType"` // 绫诲瀷锛�1 璁″垝鏀舵鏃ユ湡 2 椤圭洰鐘舵�侊級 + SourceType constvar.CollectionSourceType `gorm:"column:source_type;type:tinyint;not null;default 0;comment:婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級" json:"sourceType"` // 婧愬崟绫诲瀷锛�1閿�鍞槑缁�2鏈嶅姟鍚堝悓3閿�鍞彂绁級 + SourceId int `gorm:"column:source_id;type:int;not null;default 0;comment:婧愬崟id" json:"sourceId"` // 婧愬崟id + PrincipalId int `gorm:"column:principal_id;type:int;not null;default 0;comment:鏀舵璐熻矗浜篒D" json:"principalId"` // 鏀舵璐熻矗浜篒D + Principal User `gorm:"foreignKey:PrincipalId" json:"principal"` // 鏀舵璐熻矗浜篒D + Term int `gorm:"column:term;type:tinyint;not null;default 0;comment:鏈熸" json:"term"` // 鏈熸 + Percent decimal.Decimal `gorm:"column:percent;type:decimal(5,2);not null;default 0.00;comment:鏀舵姣斾緥" gorm:"" json:"percent"` // 姣斾緥 + Amount decimal.Decimal `gorm:"column:amount;type:decimal(12,2);not null;default '0.00';comment:閲戦" gorm:"" json:"amount"` // 閲戦 + MoneyType string `gorm:"column:money_type;type:varchar(255);not null;default '';comment:甯佺" json:"moneyType"` // 甯佺 + CollectionDate string `gorm:"column:collection_date;type:varchar(255);not null;default '';comment:璁″垝鏀舵鏃ユ湡" json:"collectionDate"` // 璁″垝鏀舵鏃ユ湡 + Remark string `gorm:"column:remark;type:varchar(512);not null;default '';comment:澶囨敞" json:"remark"` // 澶囨敞 + Status constvar.CollectionStatus `gorm:"column:status;type:tinyint;not null;default '';comment:鐘舵�侊紙1鏈敹2閮ㄥ垎宸叉敹3宸叉敹锛�" json:"status"` // 鐘舵�侊紙1鏈敹2閮ㄥ垎宸叉敹3宸叉敹锛� + 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"` // 宸叉敹閲戦 + AmountTotal decimal.Decimal `gorm:"column:amount_total;type:decimal(12,2);comment:鎬婚" json:"amountTotal"` // 鎬婚 + FileId int `gorm:"column:file_id;type:int;comment:闄勪欢id" json:"fileId"` // 闄勪欢id } // ServiceCollectionPlanSearch 鏀舵璁″垝鎼滅储鏉′欢 @@ -63,6 +63,11 @@ db = db.Where("source_id = ?", slf.SourceId) } + if slf.SourceType != 0 { + db = db.Where("source_type = ?", slf.SourceType) + } + + db = db.Preload("Principal") return db } @@ -108,6 +113,11 @@ return slf } +func (slf *ServiceCollectionPlanSearch) SetSourceType(sourceType constvar.CollectionSourceType) *ServiceCollectionPlanSearch { + slf.SourceType = sourceType + return slf +} + func (slf *ServiceCollectionPlanSearch) First() (*ServiceCollectionPlan, error) { var db = slf.build() var record = new(ServiceCollectionPlan) -- Gitblit v1.8.0