96 lines
3.2 KiB
Go
96 lines
3.2 KiB
Go
|
// Package asArtwork -----------------------------
|
|||
|
// @file : supplementService.go
|
|||
|
// @author : JJXu
|
|||
|
// @contact : wavingbear@163.com
|
|||
|
// @time : 2024/6/19 上午10:25
|
|||
|
// -------------------------------------------
|
|||
|
package asArtwork
|
|||
|
|
|||
|
import (
|
|||
|
"context"
|
|||
|
"fmt"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/api/artistInfoArtwork"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/api/artistInfoUser"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/service"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/service/artistInfo/asPush"
|
|||
|
"github.com/fonchain_enterprise/fonchain-main/pkg/utils"
|
|||
|
"time"
|
|||
|
)
|
|||
|
|
|||
|
var SupplementService = new(supplementService)
|
|||
|
|
|||
|
type supplementService struct {
|
|||
|
}
|
|||
|
|
|||
|
func (s supplementService) GenerateSupplementInfo(ArtworkUids []string) error {
|
|||
|
_, err := service.GrpcArtistInfoArtworkImpl.GenerateArtworkSupplementInfo(context.Background(), &artistInfoArtwork.ArtworkUidsRequest{
|
|||
|
ArtworkUids: ArtworkUids,
|
|||
|
})
|
|||
|
if err != nil {
|
|||
|
return err
|
|||
|
}
|
|||
|
//添加流转记录 发送通知
|
|||
|
if len(ArtworkUids) > 0 {
|
|||
|
go func() {
|
|||
|
var userIds []int64
|
|||
|
{
|
|||
|
//添加流转记录
|
|||
|
var nowStamp = time.Now().Unix()
|
|||
|
artworkRecords, err := service.GrpcArtistInfoArtworkImpl.GetArtworkViewList(context.Background(), &artistInfoArtwork.ArtworkViewRequest{
|
|||
|
ArtworkUids: ArtworkUids,
|
|||
|
Page: 1,
|
|||
|
PageSize: int64(len(ArtworkUids)),
|
|||
|
})
|
|||
|
if err != nil {
|
|||
|
fmt.Println("GenerateSupplementInfo: GetArtworkLockRecords Err", err.Error())
|
|||
|
} else {
|
|||
|
for _, w := range artworkRecords.Datas {
|
|||
|
//如果不是锁定状态,则不添加流转记录,最新状态还是已通过。等到用户锁定时,再添加画作信息待补充的流转记录
|
|||
|
if w.LockStatus != 2 {
|
|||
|
continue
|
|||
|
}
|
|||
|
_, err = service.GrpcArtistInfoArtworkImpl.AddArtworkFlowRecord(context.Background(), &artistInfoArtwork.AddArtworkFlowRecordRequest{
|
|||
|
ArtistUid: w.ArtistUid,
|
|||
|
ArtworkUid: w.ArtworkUid,
|
|||
|
TimeStamp: nowStamp,
|
|||
|
FlowState: artistInfoArtwork.FlowState_ArtWorkSupplementBegin,
|
|||
|
Operator: artistInfoArtwork.Operator_Backend,
|
|||
|
})
|
|||
|
if err != nil {
|
|||
|
fmt.Println("GenerateSupplementInfo: AddArtworkFlowRecord Err", err.Error())
|
|||
|
}
|
|||
|
userData, err := service.GrpcArtistInfoUserImpl.FindUser(context.Background(), &artistInfoUser.FindUserRequest{
|
|||
|
MgmtArtistUid: w.ArtistUid,
|
|||
|
})
|
|||
|
userIds = append(userIds, userData.Id)
|
|||
|
if err != nil {
|
|||
|
fmt.Println("GenerateSupplementInfo: FindUser Err", err.Error())
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//发送消息推送
|
|||
|
{
|
|||
|
if len(userIds) > 0 {
|
|||
|
userIds = utils.ArrayDeduplicate(userIds)
|
|||
|
fmt.Println("notice artistInfo userIds:", userIds)
|
|||
|
puser := asPush.NewPusher()
|
|||
|
for _, id := range userIds {
|
|||
|
//err = asUser.ArtistInfoPushNotice.ArtworkSupplementNotice(id)
|
|||
|
//if err != nil {
|
|||
|
// fmt.Println("GenerateSupplementInfo: ArtworkSupplementNotice Err", err.Error())
|
|||
|
//}
|
|||
|
err = puser.ArtworkSupplementNotice(id)
|
|||
|
if err != nil {
|
|||
|
fmt.Println("GenerateSupplementInfo: ArtworkSupplementNotice Err", err.Error())
|
|||
|
} else {
|
|||
|
fmt.Println("画作补充信息通知成功. userId:", id)
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}()
|
|||
|
}
|
|||
|
return err
|
|||
|
}
|