From 3afa12c1e99544066a606a61b244f1bfa749d6d7 Mon Sep 17 00:00:00 2001 From: songchuang <192749120@qq.com> Date: Fri, 24 Mar 2023 11:50:20 +0800 Subject: [PATCH] =?UTF-8?q?StatementList=20=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/internal/dao/contract.go | 2 +- cmd/internal/dao/statement.go | 5 ++- cmd/internal/logic/statement.go | 4 --- cmd/model/contract.go | 47 ++++++++++++++------------ cmd/model/statement.go | 45 ++++++++++++++++++++++-- pb/artistinfoStatement/statement.pb.go | 10 +++--- pb/artistinfoStatement/statement.proto | 3 +- 7 files changed, 79 insertions(+), 37 deletions(-) diff --git a/cmd/internal/dao/contract.go b/cmd/internal/dao/contract.go index c1e5831..ab2f4f3 100644 --- a/cmd/internal/dao/contract.go +++ b/cmd/internal/dao/contract.go @@ -154,7 +154,7 @@ func ContractList(artist_uid string, state int32) (contractData []*contract.Cont // } var contracts []model.Contract - if err = db.DB.Where("artist_uid = ? AND type != 4 AND state = ?", artist_uid, state).Find(&contracts).Error; err != nil { + if err = db.DB.Where("artist_uid = ? AND type != 4 AND type != 7 AND state = ?", artist_uid, state).Find(&contracts).Error; err != nil { zap.L().Error("get contracts info err", zap.Error(err)) err = errors.New(m.ERROR_SELECT) return diff --git a/cmd/internal/dao/statement.go b/cmd/internal/dao/statement.go index 9ece648..bb57ac1 100644 --- a/cmd/internal/dao/statement.go +++ b/cmd/internal/dao/statement.go @@ -11,8 +11,9 @@ import ( ) func StatementList(artistUid string, state int32) (contractData []*statement.Contracts, err error) { + var contracts []model.Contract - if err = db.DB.Where("artist_uid = ? AND type == 4 AND state = ?", artistUid, state).Find(&contracts).Error; err != nil { + if err = db.DB.Where("artist_uid = ? AND state = ?", artistUid, state).Where("type == 4 OR type == 7").Find(&contracts).Error; err != nil { zap.L().Error("get contracts info err", zap.Error(err)) err = errors.New(m.ERROR_SELECT) return @@ -32,6 +33,8 @@ func StatementList(artistUid string, state int32) (contractData []*statement.Con Status: int32(v.Status), LockTime: v.LockTime, SignTime: v.SignTime, + BatchTime: v.BatchTime, + BatchUid: v.BatchUid, } contractData = append(contractData, Contract) diff --git a/cmd/internal/logic/statement.go b/cmd/internal/logic/statement.go index 9d40a34..30414fe 100644 --- a/cmd/internal/logic/statement.go +++ b/cmd/internal/logic/statement.go @@ -1,8 +1,6 @@ package logic import ( - "fmt" - "github.com/fonchain/fonchain-artistinfo/cmd/internal/dao" statement "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement" ) @@ -26,8 +24,6 @@ func (a *Statement) StatementList(req *statement.StatementListRequest) (rep *sta return } - fmt.Println("user:", user) - ContractData, err := dao.StatementList(user.MgmtArtistUid, req.State) if err != nil { return diff --git a/cmd/model/contract.go b/cmd/model/contract.go index 9bbfccf..c39d1e9 100644 --- a/cmd/model/contract.go +++ b/cmd/model/contract.go @@ -4,26 +4,29 @@ import "gorm.io/plugin/soft_delete" // Contract 用户模型 type Contract struct { - ID int32 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` - Uid string `gorm:"column:uid;type:varchar(100);comment:合同表的唯一表示;NOT NULL" json:"uid"` - ArtistUid string `gorm:"column:artist_uid;type:varchar(100);comment:画家uid;NOT NULL" json:"artist_uid"` - ArtworkUid string `gorm:"column:artwork_uid;type:varchar(1000);comment:画作uid" json:"artwork_uid"` - ContractId string `gorm:"column:contract_id;type:varchar(300);comment:合同id" json:"contract_id"` - TransactionId string `gorm:"column:transaction_id;type:varchar(300);comment:交易id" json:"transaction_id"` - Type int32 `gorm:"column:type;type:int(1);comment:合同类型 (1);NOT NULL" json:"type"` - ViewUrl string `gorm:"column:view_url;type:varchar(500);comment:在线查看合同链接" json:"view_url"` - DownloadUrl string `gorm:"column:download_url;type:varchar(500);comment:合同下载链接" json:"download_url"` - State int32 `gorm:"column:state;type:int(1);comment:合同状态,1:未签署2:已签署;NOT NULL" json:"state"` //1 未签署 2 已签署 - Status int32 `gorm:"column:status;default:2;comment:2=锁定 3=解锁" json:"status" ` //跟随用户的锁定和解锁状态,用于控制数据的展示 - LockTime string `gorm:"column:lock_time;comment:锁定时间" json:"lockTime"` - SignTime string `gorm:"column:sign_time;comment:签署时间" json:"sign_time"` - BatchTime string `gorm:"column:batch_time;comment:批次时间" json:"batch_time"` - BatchUid string `gorm:"column:batch_uid;comment:批次ID" json:"batch_uid"` - StType int32 `gorm:"column:st_type;unqiueIndex:sttype_uid_batchtime_idx;comment:对账单类型 1=版权 2=物权;"` - ArtworkTx *ArtworkTx `gorm:"foreignKey:BatchUid;references:Uid"` //当前批次的物权委托单 - ArtworkTxDetail []ArtworkTxDetail `gorm:"foreignKey:BatchUid;references:BatchUid"` //当前批次的物权委托单详情 - ArtworkSoldTxDetail []ArtworkSoldTxDetail `gorm:"foreignKey:BatchUid;references:BatchUid"` //当前批次的已被售卖物权委托单详情 - CreatedAt int32 `gorm:"column:created_at;autoCreateTime"` - UpdatedAt int32 `gorm:"column:updated_at;autoCreateTime"` - DeletedAt soft_delete.DeletedAt + ID int32 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + Uid string `gorm:"column:uid;type:varchar(100);comment:合同表的唯一表示;NOT NULL" json:"uid"` + ArtistUid string `gorm:"column:artist_uid;type:varchar(100);comment:画家uid;NOT NULL" json:"artist_uid"` + ArtworkUid string `gorm:"column:artwork_uid;type:varchar(1000);comment:画作uid" json:"artwork_uid"` + ContractId string `gorm:"column:contract_id;type:varchar(300);comment:合同id" json:"contract_id"` + TransactionId string `gorm:"column:transaction_id;type:varchar(300);comment:交易id" json:"transaction_id"` + Type int32 `gorm:"column:type;type:int(1);comment:合同类型 (1);NOT NULL" json:"type"` + ViewUrl string `gorm:"column:view_url;type:varchar(500);comment:在线查看合同链接" json:"view_url"` + DownloadUrl string `gorm:"column:download_url;type:varchar(500);comment:合同下载链接" json:"download_url"` + State int32 `gorm:"column:state;type:int(1);comment:合同状态,1:未签署2:已签署;NOT NULL" json:"state"` //1 未签署 2 已签署 + Status int32 `gorm:"column:status;default:2;comment:2=锁定 3=解锁" json:"status" ` //跟随用户的锁定和解锁状态,用于控制数据的展示 + LockTime string `gorm:"column:lock_time;comment:锁定时间" json:"lockTime"` + SignTime string `gorm:"column:sign_time;comment:签署时间" json:"sign_time"` + BatchTime string `gorm:"column:batch_time;comment:批次时间" json:"batch_time"` + BatchUid string `gorm:"column:batch_uid;comment:批次ID" json:"batch_uid"` + StType int32 `gorm:"column:st_type;unqiueIndex:sttype_uid_batchtime_idx;comment:对账单类型 1=版权 2=物权;"` + ArtworkTx *ArtworkTx `gorm:"foreignKey:BatchUid;references:Uid"` //当前批次的物权委托单 + ArtworkCopy *ArtworkCopy `gorm:"foreignKey:BatchUid;references:Uid"` //当前批次的版权委托单 + ArtworkTxDetail []ArtworkTxDetail `gorm:"foreignKey:BatchUid;references:BatchUid"` //当前批次的物权委托单详情 + ArtworkSoldTxDetail []ArtworkSoldTxDetail `gorm:"foreignKey:BatchUid;references:BatchUid"` //当前批次的已被售卖物权委托单详情 + ArtworkCopyDetail []ArtworkCopyDetail `gorm:"foreignKey:BatchUid;references:BatchUid"` //当前批次的版权委托单详情 + ArtworkSoldCopyDetail []ArtworkSoldCopyDetail `gorm:"foreignKey:BatchUid;references:BatchUid"` //当前批次的已被售卖版权委托单详情 + CreatedAt int32 `gorm:"column:created_at;autoCreateTime"` + UpdatedAt int32 `gorm:"column:updated_at;autoCreateTime"` + DeletedAt soft_delete.DeletedAt } diff --git a/cmd/model/statement.go b/cmd/model/statement.go index e09c9de..82fbb47 100644 --- a/cmd/model/statement.go +++ b/cmd/model/statement.go @@ -47,6 +47,47 @@ type ArtworkSoldTxDetail struct { DeletedAt soft_delete.DeletedAt } -func (ArtworkTxDetail) TableName() string { - return "artwork_tx_detail" +//对账单画作版权 +type ArtworkCopy struct { + ID int32 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + Uid string `gorm:"column:uid;type:varchar(100);comment:对账单画作版权表的唯一表示,即批次Uid;NOT NULL" json:"uid"` + ArtistUid string `gorm:"column:artist_uid;type:varchar(100);comment:画家Uid;NOT NULL" json:"artist_uid"` + ArtistName string `gorm:"column:artist_name;type:varchar(100);comment:画家名;NOT NULL" json:"artist_name"` + BatchTime string `gorm:"column:batch_time;comment:批次时间" json:"batch_time"` + CreatedAt int32 `gorm:"column:created_at;autoCreateTime"` + UpdatedAt int32 `gorm:"column:updated_at;autoCreateTime"` + DeletedAt soft_delete.DeletedAt +} + +// 对账单画作版权委托详情(该画家一个批次的全部画作) +type ArtworkCopyDetail struct { + ID int32 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + Uid string `gorm:"column:uid;type:varchar(100);comment:对账单画作版权详情表的唯一表示;NOT NULL" json:"uid"` + BatchUid string `gorm:"column:batch_uid;type:varchar(100);comment:对账单画作版权表的唯一表示,即批次Uid;NOT NULL" json:"batch_uid"` + TfNum string `gorm:"column:tf_num;unqiueIndex:batchid_tfnum_idx;comment:"泰丰画作编号"` + ArtworkName string `gorm:"column:artwork_name;comment:画作名称"` + Ruler string `gorm:"column:ruler;comment:平尺"` + MinPrice float32 `gorm:"column:min_price;comment:委托销售底价"` + GuaranteePrice float32 `gorm:"column:guarantee_price;comment:已收取保证金;"` + CreatedAt int32 `gorm:"column:created_at;autoCreateTime"` + UpdatedAt int32 `gorm:"column:updated_at;autoCreateTime"` + DeletedAt soft_delete.DeletedAt +} + +// 对账单画作版权委托详情(该画家一个批次的全部已被售卖了的画作) +type ArtworkSoldCopyDetail struct { + ID int32 `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + Uid string `gorm:"column:uid;type:varchar(100);comment:对账单画作版权详情表的唯一表示;NOT NULL" json:"uid"` + BatchUid string `gorm:"column:batch_uid;type:varchar(100);comment:对账单画作版权表的唯一表示,即批次Uid;NOT NULL" json:"batch_uid"` + TfNum string `gorm:"column:tf_num;unqiueIndex:batchid_tfnum_idx;comment:"泰丰画作编号"` + ArtworkName string `gorm:"column:artwork_name;comment:画作名称"` + Ruler string `gorm:"column:ruler;comment:平尺"` + SaleNo string `gorm:"column:sale_no;comment:销售单号"` + CompleteDate string `gorm:"column:complete_date;comment:成交日期"` + MinPrice float32 `gorm:"column:min_price;comment:委托销售底价"` + SalePrice float32 `gorm:"column:sale_price;comment:画作售价"` + GuaranteePrice float32 `gorm:"column:guarantee_price;comment:已收取保证金;"` + CreatedAt int32 `gorm:"column:created_at;autoCreateTime"` + UpdatedAt int32 `gorm:"column:updated_at;autoCreateTime"` + DeletedAt soft_delete.DeletedAt } diff --git a/pb/artistinfoStatement/statement.pb.go b/pb/artistinfoStatement/statement.pb.go index 89a85dc..ccaf9ff 100644 --- a/pb/artistinfoStatement/statement.pb.go +++ b/pb/artistinfoStatement/statement.pb.go @@ -38,7 +38,7 @@ type Contracts struct { ExpirationTime string `protobuf:"bytes,11,opt,name=ExpirationTime,json=expiration_time,proto3" json:"ExpirationTime,omitempty"` LockTime string `protobuf:"bytes,12,opt,name=LockTime,json=lock_time,proto3" json:"LockTime,omitempty"` SignTime string `protobuf:"bytes,13,opt,name=SignTime,json=sign_time,proto3" json:"SignTime,omitempty"` - BatchName string `protobuf:"bytes,14,opt,name=BatchName,json=batch_name,proto3" json:"BatchName,omitempty"` + BatchTime string `protobuf:"bytes,14,opt,name=BatchTime,json=batch_time,proto3" json:"BatchTime,omitempty"` BatchUid string `protobuf:"bytes,15,opt,name=BatchUid,json=batch_uid,proto3" json:"BatchUid,omitempty"` ArtistName string `protobuf:"bytes,16,opt,name=ArtistName,json=artist_name,proto3" json:"ArtistName,omitempty"` } @@ -166,9 +166,9 @@ func (x *Contracts) GetSignTime() string { return "" } -func (x *Contracts) GetBatchName() string { +func (x *Contracts) GetBatchTime() string { if x != nil { - return x.BatchName + return x.BatchTime } return "" } @@ -754,8 +754,8 @@ var file_statement_proto_rawDesc = []byte{ 0x52, 0x09, 0x6c, 0x6f, 0x63, 0x6b, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x53, 0x69, 0x67, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73, 0x69, 0x67, 0x6e, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1d, 0x0a, 0x09, 0x42, 0x61, 0x74, 0x63, - 0x68, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x61, 0x74, - 0x63, 0x68, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x42, 0x61, 0x74, 0x63, 0x68, + 0x68, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x0e, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x61, 0x74, + 0x63, 0x68, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x42, 0x61, 0x74, 0x63, 0x68, 0x55, 0x69, 0x64, 0x18, 0x0f, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f, 0x75, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x0a, 0x41, 0x72, 0x74, 0x69, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x10, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x61, 0x72, 0x74, 0x69, 0x73, 0x74, diff --git a/pb/artistinfoStatement/statement.proto b/pb/artistinfoStatement/statement.proto index 1eb298a..91c7dc6 100644 --- a/pb/artistinfoStatement/statement.proto +++ b/pb/artistinfoStatement/statement.proto @@ -22,9 +22,8 @@ message Contracts{ string ExpirationTime = 11 [json_name = "expiration_time"]; string LockTime = 12 [json_name = "lock_time"]; string SignTime = 13 [json_name = "sign_time"]; - string BatchName = 14 [json_name = "batch_name"]; + string BatchTime = 14 [json_name = "batch_time"]; string BatchUid = 15 [json_name = "batch_uid"]; - string ArtistName = 16 [json_name = "artist_name"]; } message ArtworkTxDetail{