对账单代码测试修改

This commit is contained in:
songchuang 2023-04-18 16:51:32 +08:00
parent 354394d518
commit 01f94832bb
2 changed files with 20 additions and 20 deletions

View File

@ -11,9 +11,9 @@ import (
"gorm.io/gorm"
)
func IsExistArtworkTx(batchTime, artistUid string) (exist bool, artworkTx *model.ArtworkTx, err error) {
func IsExistArtworkTx(tx *gorm.DB, batchTime, artistUid string) (exist bool, artworkTx *model.ArtworkTx, err error) {
if err = db.DB.Where("batch_time = ? AND artist_uid = ?", batchTime, artistUid).First(&artworkTx).Error; err != nil {
if err = tx.Where("batch_time = ? AND artist_uid = ?", batchTime, artistUid).First(&artworkTx).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return true, nil, nil
} else {
@ -26,9 +26,9 @@ func IsExistArtworkTx(batchTime, artistUid string) (exist bool, artworkTx *model
return
}
func IsExistArtworkCopy(batchTime, artistUid string) (exist bool, artworkCopy *model.ArtworkCopy, err error) {
func IsExistArtworkCopy(tx *gorm.DB, batchTime, artistUid string) (exist bool, artworkCopy *model.ArtworkCopy, err error) {
if err = db.DB.Where("batch_time = ? AND artist_uid = ?", batchTime, artistUid).First(&artworkCopy).Error; err != nil {
if err = tx.Where("batch_time = ? AND artist_uid = ?", batchTime, artistUid).First(&artworkCopy).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return true, nil, nil
} else {
@ -115,8 +115,8 @@ func CreateArtworkCopyDetail(tx *gorm.DB, uid1, uid2 string, excelOneInfo *state
return
}
func IsExistArtworkTxDetail(uid, tfNum string) (count int64, err error) {
if err = db.DB.Model(&model.ArtworkTxDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
func IsExistArtworkTxDetail(tx *gorm.DB, uid, tfNum string) (count int64, err error) {
if err = tx.Model(&model.ArtworkTxDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
zap.L().Error("get artworkTxDetail num err", zap.Error(err))
err = errors.New(m.ERROR_SELECT)
return
@ -124,8 +124,8 @@ func IsExistArtworkTxDetail(uid, tfNum string) (count int64, err error) {
return
}
func IsExistArtworkCopyDetail(uid, tfNum string) (count int64, err error) {
if err = db.DB.Model(&model.ArtworkCopyDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
func IsExistArtworkCopyDetail(tx *gorm.DB, uid, tfNum string) (count int64, err error) {
if err = tx.Model(&model.ArtworkCopyDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
zap.L().Error("get artworkCopyDetail num err", zap.Error(err))
err = errors.New(m.ERROR_SELECT)
return
@ -133,8 +133,8 @@ func IsExistArtworkCopyDetail(uid, tfNum string) (count int64, err error) {
return
}
func IsExistArtworkSoldTxDetail(uid, tfNum string) (count int64, err error) {
if err = db.DB.Model(&model.ArtworkSoldTxDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
func IsExistArtworkSoldTxDetail(tx *gorm.DB, uid, tfNum string) (count int64, err error) {
if err = tx.Model(&model.ArtworkSoldTxDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
zap.L().Error("get artworkSoldTxDetail num err", zap.Error(err))
err = errors.New(m.ERROR_SELECT)
return
@ -142,8 +142,8 @@ func IsExistArtworkSoldTxDetail(uid, tfNum string) (count int64, err error) {
return
}
func IsExistArtworkSoldCopyDetail(uid, tfNum string) (count int64, err error) {
if err = db.DB.Model(&model.ArtworkSoldCopyDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
func IsExistArtworkSoldCopyDetail(tx *gorm.DB, uid, tfNum string) (count int64, err error) {
if err = tx.Model(&model.ArtworkSoldCopyDetail{}).Where("batch_uid = ? AND tf_num = ?", uid, tfNum).Count(&count).Error; err != nil {
zap.L().Error("get artworkSoldCopyDetail num err", zap.Error(err))
err = errors.New(m.ERROR_SELECT)
return

View File

@ -43,7 +43,7 @@ func (a *Statement) UploadExcelOneTx(req *statement.UploadExcelOneTxRequest) (re
}()
for _, v := range req.ExcelOneInfo {
//查看是否已经被生成了批次,没有的就生成物权批次
exist, artworkTx, err := dao.IsExistArtworkTx(v.BatchTime, v.ArtistUid)
exist, artworkTx, err := dao.IsExistArtworkTx(tx, v.BatchTime, v.ArtistUid)
if err != nil {
return rep, err
}
@ -71,7 +71,7 @@ func (a *Statement) UploadExcelOneTx(req *statement.UploadExcelOneTxRequest) (re
}
} else {
//查看画作是否已经被该批次录入过,被录入过就跳过
count, err := dao.IsExistArtworkTxDetail(artworkTx.Uid, v.TfNum)
count, err := dao.IsExistArtworkTxDetail(tx, artworkTx.Uid, v.TfNum)
if err != nil {
return rep, err
}
@ -108,7 +108,7 @@ func (a *Statement) UploadExcelTwoTx(req *statement.UploadExcelTwoTxRequest) (re
}()
for _, v := range req.ExcelTwoInfo {
//查看是否已经被生成了物权批次
exist, artworkTx, err := dao.IsExistArtworkTx(v.BatchTime, v.ArtistUid)
exist, artworkTx, err := dao.IsExistArtworkTx(tx, v.BatchTime, v.ArtistUid)
if err != nil {
return rep, err
}
@ -137,7 +137,7 @@ func (a *Statement) UploadExcelTwoTx(req *statement.UploadExcelTwoTxRequest) (re
}
} else {
//查看画作是否已经被该批次录入过,被录入过就跳过
count, err := dao.IsExistArtworkSoldTxDetail(artworkTx.Uid, v.TfNum)
count, err := dao.IsExistArtworkSoldTxDetail(tx, artworkTx.Uid, v.TfNum)
if err != nil {
return rep, err
}
@ -175,7 +175,7 @@ func (a *Statement) UploadExcelOneCopy(req *statement.UploadExcelOneCopyRequest)
for _, v := range req.ExcelOneInfo {
//查看是否已经被生成了批次,没有的就生成版权批次
exist, artworkCopy, err := dao.IsExistArtworkCopy(v.BatchTime, v.ArtistUid)
exist, artworkCopy, err := dao.IsExistArtworkCopy(tx, v.BatchTime, v.ArtistUid)
if err != nil {
return rep, err
}
@ -205,7 +205,7 @@ func (a *Statement) UploadExcelOneCopy(req *statement.UploadExcelOneCopyRequest)
}
} else {
count, err := dao.IsExistArtworkCopyDetail(artworkCopy.Uid, v.TfNum)
count, err := dao.IsExistArtworkCopyDetail(tx, artworkCopy.Uid, v.TfNum)
if err != nil {
return rep, err
}
@ -243,7 +243,7 @@ func (a *Statement) UploadExcelTwoCopy(req *statement.UploadExcelTwoCopyRequest)
for _, v := range req.ExcelTwoInfo {
//查看是否已经被生成了物权批次
exist, artworkCopy, err := dao.IsExistArtworkCopy(v.BatchTime, v.ArtistUid)
exist, artworkCopy, err := dao.IsExistArtworkCopy(tx, v.BatchTime, v.ArtistUid)
if err != nil {
return rep, err
}
@ -274,7 +274,7 @@ func (a *Statement) UploadExcelTwoCopy(req *statement.UploadExcelTwoCopyRequest)
} else {
//查看画作是否已经被该批次录入过,被录入过就跳过
count, err := dao.IsExistArtworkSoldCopyDetail(artworkCopy.Uid, v.TfNum)
count, err := dao.IsExistArtworkSoldCopyDetail(tx, artworkCopy.Uid, v.TfNum)
if err != nil {
return rep, err
}