对账单测试代码提交

This commit is contained in:
songchuang 2023-04-19 15:09:21 +08:00
parent f4695ffd6b
commit 4e0e4f4463
4 changed files with 2 additions and 301 deletions

View File

@ -1,44 +0,0 @@
package controller
// import (
// "context"
// "github.com/fonchain/fonchain-artistinfo/cmd/internal/logic"
// "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement"
// emptypb "google.golang.org/protobuf/types/known/emptypb"
// )
// //go:generate mockgen -destination .\artistinfoStatement_triple.pb.go -package controller -source ..\..\..\pb\artistinfoStatement\artistinfoStatement_triple.pb.go StatementServer
// type StatementServerProvider struct {
// artistinfoStatement.UnimplementedStatementServer
// logic logic.StatementServerLogic
// }
// func (s *StatementServerProvider) CreateStatementBatch(ctx context.Context, in *artistinfoStatement.StatementBatchRequest) (res *artistinfoStatement.CreateStatementBatchResponse, err error) {
// return s.logic.CreateStatementBatch(in)
// }
// func (s *StatementServerProvider) BatchCreateStatementBatch(ctx context.Context, in *artistinfoStatement.BatchCreateStatementBatchRequest) (*emptypb.Empty, error) {
// return s.logic.BatchCreateStatementBatch(in)
// }
// func (s *StatementServerProvider) GetStatementBatchList(ctx context.Context, in *artistinfoStatement.GetStatementBatchListRequest) (*artistinfoStatement.GetStatementBatchListResponse, error) {
// return s.logic.GetStatementBatchList(in)
// }
// func (s *StatementServerProvider) CreateStatementDetail(ctx context.Context, in *artistinfoStatement.StatementDetailRequest) (*artistinfoStatement.CreateStatementDetailResponse, error) {
// return s.logic.CreateStatementDetail(in)
// }
// func (s *StatementServerProvider) BatchCreateStatementDetail(ctx context.Context, in *artistinfoStatement.BatchCreateStatementDetailRequest) (*emptypb.Empty, error) {
// return s.logic.BatchCreateStatementDetail(in)
// }
// func (s *StatementServerProvider) GetStatementDetailList(ctx context.Context, in *artistinfoStatement.GetStatementDetailListRequest) (*artistinfoStatement.GetStatementDetailListResponse, error) {
// return s.logic.GetStatementDetailList(in)
// }
// func (s *StatementServerProvider) GetStatementBatchTimeMenus(ctx context.Context, in *artistinfoStatement.GetStatementBatchListRequest) (*artistinfoStatement.GetStatementBatchTimeMenusResponse, error) {
// return s.logic.GetStatementBatchTimeMenus(in)
// }

View File

@ -1,160 +0,0 @@
package dao
// import (
// "github.com/fonchain/fonchain-artistinfo/cmd/model"
// "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement"
// )
// =====================================
//
// 对账单批次
// func CreateStatementBatch(in *artistinfoStatement.StatementBatchRequest) (res model.StatementBatch, err error) {
// res = model.StatementBatch{
// StType: in.StType,
// ArtistUid: in.ArtistUid,
// ArtistRealName: in.ArtistRealName,
// FlowStatus: in.FlowStatus,
// BatchTime: in.BatchTime,
// MinPrice: in.MinPrice,
// GuaranteePrice: in.GuaranteePrice,
// FileUrl: in.FileUrl,
// }
// err = db.DB.Clauses(clause.OnConflict{
// Columns: []clause.Column{{Name: "st_type"}, {Name: "artist_uid"}, {Name: "batch_time"}},
// UpdateAll: true,
// }).Create(&res).Error
// return
// }
// func BatchCreateStatementBatch(in *artistinfoStatement.BatchCreateStatementBatchRequest) error {
// var datas = []model.StatementBatch{}
// for _, in := range in.Data {
// datas = append(datas, model.StatementBatch{
// StType: in.StType,
// ArtistUid: in.ArtistUid,
// ArtistRealName: in.ArtistRealName,
// FlowStatus: in.FlowStatus,
// BatchTime: in.BatchTime,
// MinPrice: in.MinPrice,
// GuaranteePrice: in.GuaranteePrice,
// FileUrl: in.FileUrl,
// })
// }
// err := db.DB.Clauses(clause.OnConflict{
// Columns: []clause.Column{{Name: "st_type"}, {Name: "artist_uid"}, {Name: "batch_time"}},
// UpdateAll: true,
// }).Create(&datas).Error
// return err
// }
// func GetStatementBatchList(in *artistinfoStatement.GetStatementBatchListRequest) (res []model.StatementBatch, total int64, err error) {
// res = []model.StatementBatch{}
// var orm = db.DB.Model(model.StatementBatch{}).Order("created_at desc").Preload("ArtworkList")
// if in.Condition.StType != 0 {
// orm = orm.Where("st_type = ?", in.Condition.StType)
// }
// if in.Condition.ArtistUid != "" {
// orm = orm.Where("artist_uid = ?", in.Condition.ArtistUid)
// }
// if in.Condition.ArtistRealName != "" {
// orm = orm.Where("artist_real_name = ?", in.Condition.ArtistRealName)
// }
// if in.Condition.FlowStatus != 0 {
// orm = orm.Where("flow_status = ?", in.Condition.FlowStatus)
// }
// if in.Condition.BatchTime != "" {
// orm = orm.Where("batch_time = ?", in.Condition.BatchTime)
// }
// if in.Condition.MinPrice != 0 {
// orm = orm.Where("min_price = ?", in.Condition.MinPrice)
// }
// if in.Condition.GuaranteePrice != 0 {
// orm = orm.Where("guarantee_price = ?", in.Condition.GuaranteePrice)
// }
// if in.Condition.Id != 0 {
// orm = orm.Where("id = ?", in.Condition.Id)
// }
// if in.Condition.FileUrl != "" {
// orm = orm.Where("file_url = ?", in.Condition.FileUrl)
// }
// if len(in.Ids) > 0 {
// orm = orm.Where("id in ?", in.Ids)
// }
// if len(in.BatchTimeList) > 0 {
// orm = orm.Where("batch_time in ?", in.BatchTimeList)
// }
// err = orm.Count(&total).Scopes(db.Pagination(in.Page, in.PageSize)).Find(&res).Error
// return
// }
// func GetStatementBatchTimeMenus(in *artistinfoStatement.GetStatementBatchListRequest) (res []string, err error) {
// res = []string{}
// err = db.DB.Model(model.StatementBatch{}).Pluck("batch_time", &res).Error
// return
// }
// //=====================================
// // 对账单详情
// func CreateStatementDetail(in *artistinfoStatement.StatementDetailRequest) (res model.StatementDetail, err error) {
// res = model.StatementDetail{
// BatchId: in.BatchId,
// TfNum: in.TfNum,
// ArtworkName: in.ArtworkName,
// Ruler: in.Ruler,
// SaleNo: in.SaleNo,
// CompleteDate: in.CompleteDate,
// }
// err = db.DB.Clauses(clause.OnConflict{
// Columns: []clause.Column{{Name: "tf_num"}, {Name: "batch_id"}},
// UpdateAll: true,
// }).Create(&res).Error
// return
// }
// func BatchCreateStatementDetail(in *artistinfoStatement.BatchCreateStatementDetailRequest) error {
// var datas = []model.StatementDetail{}
// for _, in := range in.Data {
// datas = append(datas, model.StatementDetail{
// BatchId: in.BatchId,
// TfNum: in.TfNum,
// ArtworkName: in.ArtworkName,
// Ruler: in.Ruler,
// SaleNo: in.SaleNo,
// CompleteDate: in.CompleteDate,
// })
// }
// err := db.DB.Clauses(clause.OnConflict{
// Columns: []clause.Column{{Name: "tf_num"}, {Name: "batch_id"}},
// UpdateAll: true,
// }).Create(&datas).Error
// return err
// }
// func GetStatementDetailList(in *artistinfoStatement.GetStatementDetailListRequest) (res []model.StatementDetail, total int64, err error) {
// res = []model.StatementDetail{}
// var orm = db.DB.Model(model.StatementDetail{}).Order("created_at desc")
// if in.Condition.BatchId != 0 {
// orm = orm.Where("batch_id = ?", in.Condition.BatchId)
// }
// if in.Condition.TfNum != "" {
// orm = orm.Where("tf_num = ?", in.Condition.TfNum)
// }
// if in.Condition.ArtworkName != "" {
// orm = orm.Where("artwork_name like = ?", "%"+in.Condition.ArtworkName+"%")
// }
// if in.Condition.Ruler != "" {
// orm = orm.Where("ruler = ?", in.Condition.Ruler)
// }
// if in.Condition.SaleNo != "" {
// orm = orm.Where("sale_no = ?", in.Condition.SaleNo)
// }
// if in.Condition.CompleteDate != "" {
// orm = orm.Where("complete_date = ?", in.Condition.CompleteDate)
// }
// if in.Condition.Id != 0 {
// orm = orm.Where("id = ?", in.Condition.Id)
// }
// err = orm.Count(&total).Scopes(db.Pagination(in.Page, in.PageSize)).Find(&res).Error
// return
// }

View File

@ -1,95 +0,0 @@
package logic
// import (
// "github.com/fonchain/fonchain-artistinfo/cmd/internal/dao"
// "github.com/fonchain/fonchain-artistinfo/pb/artistinfoStatement"
// "github.com/fonchain/fonchain-artistinfo/pkg/util/stime"
// "google.golang.org/protobuf/types/known/emptypb"
// )
// type StatementServerLogic struct{}
// func (s *StatementServerLogic) CreateStatementBatch(in *artistinfoStatement.StatementBatchRequest) (res *artistinfoStatement.CreateStatementBatchResponse, err error) {
// res = &artistinfoStatement.CreateStatementBatchResponse{}
// data, err := dao.CreateStatementBatch(in)
// res.Id = data.ID
// return
// }
// func (s *StatementServerLogic) BatchCreateStatementBatch(in *artistinfoStatement.BatchCreateStatementBatchRequest) (*emptypb.Empty, error) {
// return nil, dao.BatchCreateStatementBatch(in)
// }
// func (s *StatementServerLogic) GetStatementBatchList(in *artistinfoStatement.GetStatementBatchListRequest) (res *artistinfoStatement.GetStatementBatchListResponse, err error) {
// datas, total, err := dao.GetStatementBatchList(in)
// res = &artistinfoStatement.GetStatementBatchListResponse{
// Page: &artistinfoStatement.StatementPageInfo{
// Page: in.Page,
// PageSize: in.PageSize,
// Total: total,
// },
// Data: []*artistinfoStatement.StatementBatchRequest{},
// }
// for _, v := range datas {
// res.Data = append(res.Data, &artistinfoStatement.StatementBatchRequest{
// StType: v.StType,
// ArtistUid: v.ArtistUid,
// ArtistRealName: v.ArtistRealName,
// FlowStatus: v.FlowStatus,
// BatchTime: v.BatchTime,
// MinPrice: v.MinPrice,
// GuaranteePrice: v.GuaranteePrice,
// Id: v.ID,
// CreatedAt: stime.TimeToString(v.CreatedAt, stime.Format_Normal_YMDhms),
// UpdatedAt: stime.TimeToString(v.UpdatedAt, stime.Format_Normal_YMDhms),
// DeletedAt: int64(v.DeletedAt),
// FileUrl: v.FileUrl,
// })
// }
// return
// }
// func (s *StatementServerLogic) CreateStatementDetail(in *artistinfoStatement.StatementDetailRequest) (res *artistinfoStatement.CreateStatementDetailResponse, err error) {
// res = &artistinfoStatement.CreateStatementDetailResponse{}
// data, err := dao.CreateStatementDetail(in)
// res.Id = data.ID
// return
// }
// func (s *StatementServerLogic) BatchCreateStatementDetail(in *artistinfoStatement.BatchCreateStatementDetailRequest) (*emptypb.Empty, error) {
// return nil, dao.BatchCreateStatementDetail(in)
// }
// func (s *StatementServerLogic) GetStatementDetailList(in *artistinfoStatement.GetStatementDetailListRequest) (res *artistinfoStatement.GetStatementDetailListResponse, err error) {
// datas, total, err := dao.GetStatementDetailList(in)
// res = &artistinfoStatement.GetStatementDetailListResponse{
// Data: []*artistinfoStatement.StatementDetailRequest{},
// Page: &artistinfoStatement.StatementPageInfo{
// Page: in.Page,
// PageSize: in.PageSize,
// Total: total,
// },
// }
// for _, v := range datas {
// res.Data = append(res.Data, &artistinfoStatement.StatementDetailRequest{
// BatchId: v.BatchId,
// TfNum: v.TfNum,
// ArtworkName: v.ArtworkName,
// Ruler: v.Ruler,
// SaleNo: v.SaleNo,
// CompleteDate: v.CompleteDate,
// Id: v.ID,
// CreatedAt: stime.TimeToString(v.CreatedAt, stime.Format_Normal_YMDhms),
// UpdatedAt: stime.TimeToString(v.UpdatedAt, stime.Format_Normal_YMDhms),
// DeletedAt: int64(v.DeletedAt),
// })
// }
// return
// }
// func (s *StatementServerLogic) GetStatementBatchTimeMenus(in *artistinfoStatement.GetStatementBatchListRequest) (res *artistinfoStatement.GetStatementBatchTimeMenusResponse, err error) {
// res = &artistinfoStatement.GetStatementBatchTimeMenusResponse{}
// res.Data, err = dao.GetStatementBatchTimeMenus(in)
// return
// }

View File

@ -332,7 +332,7 @@ func (a *Statement) GetArtworkSoldTxDetailList(req *statement.GetArtworkSoldTxDe
artistList := &statement.ArtistList{}
var query *gorm.DB = db.DB // 初始化query变量
fmt.Println("req.ArtistName值为:", req.ArtistName)
//画家姓名不为空,模糊查询(根据画家姓名的某个字也可以查询)
if req.ArtistName != "" {
query = query.Where("artist_name LiKE ?", "%"+req.ArtistName+"%")
@ -405,7 +405,6 @@ func (a *Statement) GetArtworkSoldTxDetailList(req *statement.GetArtworkSoldTxDe
func (a *Statement) GetArtworkSoldCopyDetailList(req *statement.GetArtworkSoldCopyDetailListRequest) (rep *statement.GetArtworkSoldCopyDetailListRespond, err error) {
rep = &statement.GetArtworkSoldCopyDetailListRespond{}
artistList := &statement.ArtistList{}
artworkSoldDetailList := &statement.ArtworkSoldDetailList{}
var query *gorm.DB = db.DB // 初始化query变量
@ -464,6 +463,7 @@ func (a *Statement) GetArtworkSoldCopyDetailList(req *statement.GetArtworkSoldCo
//获取该画家该批次所有的已售出的画信息
for _, m := range artworkSoldTxDetail {
artworkSoldDetailList := &statement.ArtworkSoldDetailList{}
artworkSoldDetailList.ArtworkName = m.ArtworkName
artworkSoldDetailList.TfNum = m.TfNum
artworkSoldDetailList.Ruler = m.Ruler