// Package asArtshow ----------------------------- // @file : dto_brokerOperation.go // @author : JJXu // @contact : wavingbear@163.com // @time : 2024/6/18 下午1:39 // ------------------------------------------- package asArtshow import ( "context" "encoding/json" "fmt" "github.com/fonchain_enterprise/fonchain-main/api/artistInfoArtwork" "github.com/fonchain_enterprise/fonchain-main/api/artistInfoUser" "github.com/fonchain_enterprise/fonchain-main/api/artwork" "github.com/fonchain_enterprise/fonchain-main/pkg/service" "github.com/fonchain_enterprise/fonchain-main/pkg/utils" "github.com/fonchain_enterprise/fonchain-main/pkg/utils/stime" "time" ) type GetArtistSupplementStatusRequest struct { ArtistUid string `json:"artistUid"` } type GetArtistSupplementStatusResp struct { ArtistUid string `json:"artistUid"` ArtistName string `json:"artistName"` TelNum string `json:"telNum"` Sex string `json:"sex"` ArtistShowCount string `json:"artistShowCount"` ArtistIndexEditStatus int `json:"artistIndexEditStatus"` //画家指数编辑状态 1已编辑 2未编辑 ArtistSupplementEditStatus int `json:"artistSupplementEditStatus"` //画家补充编辑状态 1已编辑 2未编辑 ArtistVideoEditStatus int `json:"artistVideoEditStatus"` //画家视频编辑状态 1已编辑 2未编辑 BankInfoEditStatus int `json:"artistBankInfoEditStatus"` //画家银行信息编辑状态 1已编辑 2未编辑 } type GetArtistSupplementDetailRequest struct { ArtistUid string `json:"artistUid"` } type GetArtistSupplementDetailResp struct { Id int64 `json:"id"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` DeletedAt int64 `json:"deletedAt"` ArtistUid string `json:"artistUid"` ArtistProfile string `json:"artistProfile"` // 个人简介 CountryArtLevel int64 `json:"countryArtLevel"` // 国家美术师级别: 1=无 2=1级 3=2级 ArtistCertPic string `json:"artistCertPic"` // 国家美术师证书 BankNum string `json:"bankNum"` // 银行卡号 BankName string `json:"bankName"` // 总行名称 LBankName string `json:"lBankName"` // 支行名称 Honor string `json:"honor"` // 获奖信息 CanEdit bool `json:"canEdit"` // 是否可以编辑 DEPRECATED EditStatus int64 `json:"editStatus"` // 编辑状态 } type GetArtworkSupplementStatusListReq struct { ArtistUid string `json:"artistUid"` Page int32 `json:"page"` PageSize int64 `json:"pageSize"` } type GetArtworkSupplementStatusListType struct { ArtworkUid string `json:"artworkUid"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` ArtworkName string `json:"artworkName"` HdPic string `json:"hdPic"` ArtistPhoto string `json:"artistPhoto"` EditStatus int64 `json:"editStatus"` } type GetArtistIndexSupplementDataRequest struct { ArtistUid string `json:"artistUid"` } type GetArtistIndexSupplementType struct { Id int64 `json:"id"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` ArtistUid string `json:"artistUid"` Title string `json:"title"` Class string `json:"class"` TitleScore float32 `json:"titleScore"` Score string `json:"score"` Types string `json:"types"` CanEdit bool `json:"canEdit"` // 是否可以编辑 Deprecated EditStatus int64 `json:"editStatus"` } type GetArtistVideoRequest struct { ArtistUid string `json:"artistUid"` } type GetArtistVideoReq struct { ArtistUid string `json:"artistUid"` } type GetArtworkSupplementInfoResp struct { Id int64 `json:"id"` CreatedAt string `json:"createdAt"` UpdatedAt string `json:"updatedAt"` ArtistUid string `json:"artistUid"` VideoUrl string `json:"videoUrl"` VideoCover string `json:"videoCover"` CanEdit bool `json:"canEdit"` // 是否可以编辑 Deprecated EditStatus int64 `json:"editStatus"` } type GetArtworkSupplementInfoRequest struct { ArtworkUid string `json:"artworkUid"` ArtistUid string `json:"artistUid"` } type ArtworkSupplementInfo struct { // 画作首选项 //Id int `json:"id"` ArtworkUuid string `json:"artworkUid"` ArtistName string `json:"artistName"` ArtistUid string `json:"artistUid"` ArtworkName string `json:"artworkName"` Length int32 `json:"length"` Width int32 `json:"width"` Ruler int32 `json:"ruler"` InscribeDate string `json:"inscribeDate"` //落款时间 Abstract string `json:"abstract"` //简介 HdPic string `json:"hdPic"` //高清图 ArtistPhoto string `json:"artistPhoto"` //画家画作合照 CreatedDate string `json:"createdDate"` //初始创作时间 PriceRun float32 `json:"priceRun"` CreatedAt string `json:"createdAt"` //todo 这几个字段没画作服务没返回,待处理 UpdatedAt string `json:"updatedAt"` //todo 这几个字段没画作服务没返回,待处理 DeletedAt int64 `json:"deletedAt"` //todo 这几个字段没画作服务没返回,待处理 //首次发表 FirstPublish string `gorm:"column:first_publish" json:"firstPublish"` // 画作荣誉 ArtistMarketDetail string `json:"artistMarketDetail"` //画作微服务ArtworkMarketData表 - Type: int32 =0 详情 ArtistMarketUrl1 string `json:"artistMarketUrl1"` //画作微服务ArtworkMarketData表 - Type: int32 =1 获奖 ArtistMarketUrl2 string `json:"artistMarketUrl2"` //画作微服务ArtworkMarketData表 - Type: int32 =1 拍卖 ArtistMarketId1 int32 `json:"artistMarketId1"` //对应上面三个字段的id ArtistMarketId2 int32 `json:"artistMarketId2"` ArtistMarketId3 int32 `json:"artistMarketId3"` // deprecated // 审核状态 SupplementAuditStatus int32 `json:"supplementAuditStatus"` SupplementAuditMark string `json:"supplementAuditMark"` SupplementAuditMark2 string `json:"supplementAuditMark2"` SealPic string `json:"sealPic"` //动态字段 CanEdit bool `json:"canEdit"` //该条数据是否可编辑 deprecated EditStatus int64 `json:"editStatus"` //可以编辑状态 IsFirstPublish bool `json:"isFirstPublish"` //是否首次发表 } func (a *ArtworkSupplementInfo) ConvertResponse(lockInfo *artistInfoArtwork.ArtworkLockInfo, profile *artwork.CreArtProRequest, marketInfo []*artwork.UpdateMInfoRequest, extDataInfo *artwork.UpdateExtDataRequest) error { //数据拼接 if lockInfo != nil { a.ArtworkUuid = lockInfo.ArtworkUid a.ArtistUid = lockInfo.ArtistUid a.SupplementAuditStatus = lockInfo.SupplementAuditStatus a.SupplementAuditMark = lockInfo.SupplementAuditMark a.SupplementAuditMark2 = lockInfo.SupplementAuditMark2 a.CreatedAt = stime.TimeToString(time.Unix(lockInfo.CreatedAt, 0), stime.Format_Normal_YMDhms) a.UpdatedAt = stime.TimeToString(time.Unix(lockInfo.UpdatedAt, 0), stime.Format_Normal_YMDhms) } if profile != nil { a.ArtworkUuid = profile.ArtworkUuid a.ArtistName = profile.ArtistName a.ArtworkName = profile.ArtworkName a.Length = profile.Length a.Width = profile.Width a.Ruler = profile.Ruler a.InscribeDate = profile.InscribeDate a.HdPic = profile.HdPic a.ArtistPhoto = profile.ArtistPhoto a.PriceRun = profile.PriceRun a.Abstract = profile.Abstract a.CreatedDate = profile.CreatedDate } if a.ArtistName == "" || a.ArtistName == " " { artistInfo, _ := service.GrpcArtistInfoUserImpl.FindUser(context.Background(), &artistInfoUser.FindUserRequest{ MgmtArtistUid: lockInfo.ArtistUid, IsArtist: true, }) if artistInfo != nil && artistInfo.RealName != nil { a.ArtistName = artistInfo.RealName.Name } } if marketInfo != nil && len(marketInfo) > 0 { for _, v := range marketInfo { switch v.Type { case 0: a.ArtistMarketDetail = v.Detail a.ArtistMarketId1 = v.MarketId case 2: if a.ArtistMarketUrl1 == "" { a.ArtistMarketUrl1 = v.Detail a.ArtistMarketId2 = v.MarketId } else if a.ArtistMarketUrl2 == "" { a.ArtistMarketUrl2 = v.Detail a.ArtistMarketId3 = v.MarketId break } } } } if extDataInfo != nil { a.FirstPublish = extDataInfo.FirstPublish a.IsFirstPublish = utils.If(extDataInfo.FirstPublish == "", false, true).(bool) } return nil } func (a *ArtworkSupplementInfo) ConvertGrpcRequest(artworkProfile *artwork.ArtworkDetailResponse) (profile *artwork.CreArtProRequest, marketInfo []*artwork.UpdateMInfoRequest, extDataInfo *artwork.UpdateExtDataRequest) { artworkProfile.ProfileInfo.ArtworkUuid = a.ArtworkUuid artworkProfile.ProfileInfo.ArtistName = a.ArtistName artworkProfile.ProfileInfo.ArtworkName = a.ArtworkName artworkProfile.ProfileInfo.Length = a.Length artworkProfile.ProfileInfo.Width = a.Width artworkProfile.ProfileInfo.Ruler = a.Ruler artworkProfile.ProfileInfo.InscribeDate = a.InscribeDate artworkProfile.ProfileInfo.HdPic = a.HdPic artworkProfile.ProfileInfo.ArtistPhoto = a.ArtistPhoto artworkProfile.ProfileInfo.PriceRun = a.PriceRun artworkProfile.ProfileInfo.CreatedDate = a.CreatedDate artworkProfile.ProfileInfo.Abstract = a.Abstract profile = artworkProfile.ProfileInfo marketInfo = []*artwork.UpdateMInfoRequest{} if a.ArtistMarketDetail != "" || a.ArtistMarketUrl1 != "" { var award = ArtworkAward{ AwardContent: a.ArtistMarketDetail, AwardCert: a.ArtistMarketUrl1, } detail, err := json.Marshal(&award) if err != nil { fmt.Println("获奖信息转json失败", err.Error()) } else { marketInfo = append(marketInfo, &artwork.UpdateMInfoRequest{ ArtworkUuid: a.ArtworkUuid, Type: 1, Detail: string(detail), MarketId: a.ArtistMarketId1, }) } } if a.ArtistMarketUrl2 != "" { var award = ArtworkAward{ AwardContent: a.ArtistMarketDetail, AwardCert: a.ArtistMarketUrl2, } detail, err := json.Marshal(&award) if err != nil { fmt.Println() } else { marketInfo = append(marketInfo, &artwork.UpdateMInfoRequest{ ArtworkUuid: a.ArtworkUuid, Type: 1, Detail: string(detail), MarketId: a.ArtistMarketId2, }) } } extDataInfo = &artwork.UpdateExtDataRequest{ FirstPublish: a.FirstPublish, ArtworkUuid: a.ArtworkUuid, } return } // 获奖信息修改为不管是否有值都更新 func (a *ArtworkSupplementInfo) ConvertGrpcRequest2(artworkProfile *artwork.ArtworkDetailResponse) (profile *artwork.CreArtProRequest, marketInfo []*artwork.UpdateMInfoRequest, extDataInfo *artwork.UpdateExtDataRequest) { artworkProfile.ProfileInfo.ArtworkUuid = a.ArtworkUuid artworkProfile.ProfileInfo.ArtistName = a.ArtistName artworkProfile.ProfileInfo.ArtworkName = a.ArtworkName artworkProfile.ProfileInfo.Length = a.Length artworkProfile.ProfileInfo.Width = a.Width artworkProfile.ProfileInfo.Ruler = a.Ruler artworkProfile.ProfileInfo.InscribeDate = a.InscribeDate artworkProfile.ProfileInfo.HdPic = a.HdPic artworkProfile.ProfileInfo.ArtistPhoto = a.ArtistPhoto artworkProfile.ProfileInfo.PriceRun = a.PriceRun artworkProfile.ProfileInfo.CreatedDate = a.CreatedDate artworkProfile.ProfileInfo.Abstract = a.Abstract profile = artworkProfile.ProfileInfo marketInfo = []*artwork.UpdateMInfoRequest{} var award = ArtworkAward{ AwardContent: a.ArtistMarketDetail, AwardCert: a.ArtistMarketUrl1, } detail, err := json.Marshal(&award) if err != nil { fmt.Println("获奖信息转json失败", err.Error()) } else { marketInfo = append(marketInfo, &artwork.UpdateMInfoRequest{ ArtworkUuid: a.ArtworkUuid, Type: 1, Detail: string(detail), MarketId: a.ArtistMarketId1, }) } var award2 = ArtworkAward{ AwardContent: a.ArtistMarketDetail, AwardCert: a.ArtistMarketUrl2, } detail2, err := json.Marshal(&award2) if err != nil { fmt.Println() } else { marketInfo = append(marketInfo, &artwork.UpdateMInfoRequest{ ArtworkUuid: a.ArtworkUuid, Type: 1, Detail: string(detail2), MarketId: a.ArtistMarketId2, }) } extDataInfo = &artwork.UpdateExtDataRequest{ FirstPublish: a.FirstPublish, ArtworkUuid: a.ArtworkUuid, } return } type UpdateArtistInfoRequest struct { GetArtistSupplementDetailResp } type UpdateArtistVideoSupplementRequest struct { Id int64 `json:"id"` VideoUrl string `json:"videoUrl"` VideoCover string `json:"videoCover"` ArtistUid string `json:"artistUid"` } type UpdateArtistIndexSupplementRequest struct { GetArtistIndexSupplementType } type PushArtistSupplementData struct { ArtistUid string `json:"artistUid"` ArtistProfile string `json:"artistProfile"` Honor string `json:"honor"` BankNum string `json:"bankNum"` BankName string `json:"bankName"` } type UpdateBankInfoRequest struct { ArtistUid string `json:"artistUid"` BankNum string `json:"bankNum"` BankName string `json:"bankName"` LBankName string `json:"lBankName"` BankCode string `json:"bankCode"` BankArea []string `json:"bankArea"` } type GetBankInfoResp struct { ArtistUid string `json:"artistUid"` BankNum string `json:"bankNum"` BankName string `json:"bankName"` EditStatus int64 `json:"editStatus"` LBankName string `json:"lBankName"` BankCode string `json:"bankCode"` BankArea []string `json:"bankArea"` }