contract 修改代码提交

This commit is contained in:
songchuang 2023-03-17 21:17:15 +08:00
parent f36d9a5cfa
commit 2405afd6f7
3 changed files with 15 additions and 5 deletions

View File

@ -40,6 +40,7 @@ func GetMgmtContractByArtistUid(artistUid string, contractType int32) (err error
}
func CreateArtistContract(tx *gorm.DB, contract *model.Contract) (err error) {
fmt.Println("第一处1111222")
if err = tx.Create(contract).Error; err != nil {
zap.L().Error("create contract err", zap.Error(err))
err = errors.New(m.CREATE_ERROR)
@ -191,6 +192,7 @@ func GetContractInfo(contractUid string) (contractInfo model.Contract, err error
}
func UpdateContract(tx *gorm.DB, req *contract.SignContractRequest) (err error) {
fmt.Println("第一处1111")
if err = tx.Model(&model.Contract{}).Where("uid = ?", req.ContractUid).Updates(model.Contract{ViewUrl: req.ViewPdfUrl, DownloadUrl: req.DownloadUrl, ContractId: req.ContractNo, TransactionId: req.TransactionId, State: 1}).Error; err != nil {
zap.L().Error("update contract info err", zap.Error(err))
err = errors.New(m.UPDATE_FAILED)
@ -208,16 +210,16 @@ func UpdateContractTx(tx *gorm.DB, contractUid, transactionId string) (err error
return
}
func FinishContract(tx *gorm.DB, id string) (contracts *contract.Contracts, err error) {
func FinishContract(tx *gorm.DB, transactionId string) (contracts *contract.Contracts, err error) {
var modelContract model.Contract
if err = tx.Where("transaction_id = ?", id).First(&modelContract).Error; err != nil {
if err = tx.Where("transaction_id = ?", transactionId).First(&modelContract).Error; err != nil {
zap.L().Error("get contract info err", zap.Error(err))
err = errors.New(m.ERROR_SELECT)
return
}
if err = db.DB.Model(&modelContract).Update("state", 3).Error; err != nil {
if err = db.DB.Model(&modelContract).Update("state", 2).Error; err != nil {
zap.L().Error("update user contract failed", zap.Error(err))
err = errors.New(m.UPDATE_FAILED)
return

View File

@ -57,6 +57,7 @@ func (a *Contract) CreateContract(req *contract.CreateContractRequest) (rep *con
//查看画家合同是否已经存在,不存在继续
if err = dao.GetMgmtContractByArtistUid(req.ArtistUid, req.Type); err == gorm.ErrRecordNotFound {
fmt.Println("第一处111")
var uid uuid.UUID
if uid, err = uuid.NewV4(); err != nil {
err = errors.New(m.ERROR_UID)
@ -77,6 +78,7 @@ func (a *Contract) CreateContract(req *contract.CreateContractRequest) (rep *con
return
}
} else {
fmt.Println("第一处112")
return
}
@ -206,9 +208,15 @@ func (a *Contract) ContractList(req *contract.ContractListRequest) (rep *contrac
func (a *Contract) SignContract(req *contract.SignContractRequest) (rep *contract.SignContractRespond, err error) {
rep = &contract.SignContractRespond{}
fmt.Println("SignContractReq", req)
tx := db.DB.Begin()
//更新合同状态并获取合同信息
err = dao.UpdateContract(tx, req)
if err != nil {
tx.Rollback()
}
tx.Commit()
return
}

View File

@ -8,8 +8,8 @@ type Contract struct {
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(100);comment:合同id" json:"contract_id"`
TransactionId string `gorm:"column:transaction_id;type:varchar(100);comment:交易id" json:"transaction_id"`
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:合同类型;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"`