Merge branch 'dev-lzh-0905' into dev

This commit is contained in:
lzh 2025-09-23 14:19:20 +08:00
commit 5d46b21645
10 changed files with 1313 additions and 1084 deletions

View File

@ -49,3 +49,7 @@ func (b *BundleProvider) ToBeComfirmedWorks(_ context.Context, req *bundle.ToBeC
func (b *BundleProvider) ConfirmWork(_ context.Context, req *bundle.ConfirmWorkReq) (*bundle.ConfirmWorkResp, error) {
return logic.ConfirmWork(req)
}
func (b *BundleProvider) BundleActivate(_ context.Context, req *bundle.BundleActivateReq) (*bundle.BundleActivateResp, error) {
return nil, logic.BundleActivate(req)
}

View File

@ -218,8 +218,10 @@ func CreateBundleBalance(data model.BundleBalance) error {
return app.ModuleClients.BundleDB.Create(&data).Error
}
func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLog, total int64, err error) {
session := app.ModuleClients.BundleDB.Model(&model.CostLog{})
func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLogPo, total int64, err error) {
session := app.ModuleClients.BundleDB.Table("cast_cost_log as ccl").Select("ccl.*,cwe.artist_confirmed_time").
Joins("left join cast_work_extra as cwe on cwe.work_uuid = ccl.work_uuid").
Where("ccl.deleted_at = 0")
if req.Title != "" {
session = session.Where("title = ?", req.Title)
}
@ -230,10 +232,10 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLog, tota
session = session.Where(fmt.Sprintf(`JSON_CONTAINS(media_names,'"%s"')`, req.Account))
}
if req.SubmitTimeEnd != 0 {
session = session.Where("submit_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
session = session.Where("artist_confirmed_time <= ?", time.UnixMilli(req.SubmitTimeEnd))
}
if req.SubmitTimeStart != 0 {
session = session.Where("submit_time >= ?", time.UnixMilli(req.SubmitTimeStart))
session = session.Where("artist_confirmed_time >= ?", time.UnixMilli(req.SubmitTimeStart))
}
if req.User != "" {
if utils.IsPhoneNumber(req.User) {
@ -258,7 +260,7 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (data []model.CostLog, tota
if req.Page != 0 && req.PageSize != 0 {
session = session.Offset(int(req.Page-1) * int(req.PageSize)).Limit(int(req.PageSize))
}
err = session.Order("updated_at desc").Find(&data).Error
err = session.Order("ccl.updated_at desc").Find(&data).Error
return
}
@ -307,3 +309,11 @@ func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (data []model.CastWor
func ConfirmWork(req *bundle.ConfirmWorkReq) error {
return app.ModuleClients.BundleDB.Model(&model.CastWorkLog{}).Where(&model.CastWorkLog{WorkUuid: req.WorkUuid}).Update("confirmed_at", time.Now().Unix()).Error
}
func BundleActivate(ids []uint32) error {
batch := []model.BundleActivate{}
for _, v := range ids {
batch = append(batch, model.BundleActivate{UserId: int(v), Activate: true})
}
return app.ModuleClients.BundleDB.Model(&model.BundleActivate{}).Where("user_id = ?").Save(batch).Error
}

View File

@ -123,7 +123,7 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (*bundle.GetUsedRecordListR
}
resp := &bundle.GetUsedRecordListResp{}
resp.Total = total
resp.Data = lo.Map(data, func(m model.CostLog, _ int) *bundle.WorkCastItem {
resp.Data = lo.Map(data, func(m model.CostLogPo, _ int) *bundle.WorkCastItem {
result := &bundle.WorkCastItem{}
copier.Copy(result, &m)
return result
@ -174,3 +174,7 @@ func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (*bundle.ToBeComfirme
func ConfirmWork(req *bundle.ConfirmWorkReq) (*bundle.ConfirmWorkResp, error) {
return nil, dao.ConfirmWork(req)
}
func BundleActivate(req *bundle.BundleActivateReq) error {
return dao.BundleActivate(req.Ids)
}

View File

@ -205,3 +205,14 @@ type BundleBalance struct {
func (*BundleBalance) TableName() string {
return "bundle_balance"
}
type BundleActivate struct {
gorm.Model
UserId int `gorm:"column:user_id;not null;unique"`
Activate bool `gorm:"column:activate"`
}
// TableName 表名称
func (*BundleActivate) TableName() string {
return "bundle_activate"
}

View File

@ -31,6 +31,23 @@ func (CostLog) TableName() string {
return "cast_cost_log"
}
type CastWorkExtra struct {
WorkUuid string `gorm:"column:work_uuid;type:varchar(50);primary_key;comment:作品uuid" json:"work_uuid"`
CreatedAt int `gorm:"column:created_at;type:int(11)" json:"created_at"`
UpdatedAt int `gorm:"column:updated_at;type:int(11)" json:"updated_at"`
DeletedAt uint64 `gorm:"column:deleted_at;type:bigint(20) unsigned" json:"deleted_at"`
ArtistConfirmedTime int64 `gorm:"column:artist_confirmed_time;type:bigint(20);default:0;comment:艺人确认时间;NOT NULL" json:"artist_confirmed_time"`
}
func (m *CastWorkExtra) TableName() string {
return "cast_work_extra"
}
type CostLogPo struct {
CostLog
ArtistConfirmedTime int64 `gorm:"column:artist_confirmed_time;type:bigint(20);default:0;comment:艺人确认时间;NOT NULL" json:"artist_confirmed_time"`
}
type CastWorkImage struct {
Uuid string `json:"uuid" gorm:"uuid"`
WorkUuid string `json:"work_uuid" gorm:"work_uuid"` // 作品uuid

View File

@ -60,6 +60,7 @@ service Bundle {
rpc GetBundleBalanceByUserId(GetBundleBalanceByUserIdReq) returns (GetBundleBalanceByUserIdResp) {} //
rpc CreateBundleBalance(CreateBundleBalanceReq) returns (CreateBundleBalanceResp) {} //
rpc AddBundleBalance(AddBundleBalanceReq) returns (AddBundleBalanceResp) {} //
rpc BundleActivate(BundleActivateReq) returns (BundleActivateResp) {} //
// 使
rpc GetUsedRecordList(GetUsedRecordListReq) returns (GetUsedRecordListResp) {} // 使
@ -1084,4 +1085,13 @@ message ArtistBundleBalanceResponse {
int32 remainingVideoCount = 1 [json_name = "remainingVideoCount"]; //
int32 remainingImageCount = 2 [json_name = "remainingImageCount"]; //
int32 remainingDataAnalysisCount = 3 [json_name = "remainingDataAnalysisCount"]; //
}
message BundleActivateReq{
repeated uint32 ids = 1; // id
}
message BundleActivateResp{
}

File diff suppressed because it is too large Load Diff

View File

@ -555,3 +555,9 @@ func (this *ArtistBundleBalanceRequest) Validate() error {
func (this *ArtistBundleBalanceResponse) Validate() error {
return nil
}
func (this *BundleActivateReq) Validate() error {
return nil
}
func (this *BundleActivateResp) Validate() error {
return nil
}

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.5
// - protoc v5.26.0
// - protoc-gen-go-triple v1.0.8
// - protoc v3.12.4
// source: pb/bundle.proto
package bundle
@ -69,6 +69,7 @@ type BundleClient interface {
GetBundleBalanceByUserId(ctx context.Context, in *GetBundleBalanceByUserIdReq, opts ...grpc_go.CallOption) (*GetBundleBalanceByUserIdResp, common.ErrorWithAttachment)
CreateBundleBalance(ctx context.Context, in *CreateBundleBalanceReq, opts ...grpc_go.CallOption) (*CreateBundleBalanceResp, common.ErrorWithAttachment)
AddBundleBalance(ctx context.Context, in *AddBundleBalanceReq, opts ...grpc_go.CallOption) (*AddBundleBalanceResp, common.ErrorWithAttachment)
BundleActivate(ctx context.Context, in *BundleActivateReq, opts ...grpc_go.CallOption) (*BundleActivateResp, common.ErrorWithAttachment)
// 使用记录
GetUsedRecordList(ctx context.Context, in *GetUsedRecordListReq, opts ...grpc_go.CallOption) (*GetUsedRecordListResp, common.ErrorWithAttachment)
GetImageWorkDetail(ctx context.Context, in *GetImageWorkDetailReq, opts ...grpc_go.CallOption) (*GetImageWorkDetailResp, common.ErrorWithAttachment)
@ -138,6 +139,7 @@ type BundleClientImpl struct {
GetBundleBalanceByUserId func(ctx context.Context, in *GetBundleBalanceByUserIdReq) (*GetBundleBalanceByUserIdResp, error)
CreateBundleBalance func(ctx context.Context, in *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error)
AddBundleBalance func(ctx context.Context, in *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
BundleActivate func(ctx context.Context, in *BundleActivateReq) (*BundleActivateResp, error)
GetUsedRecordList func(ctx context.Context, in *GetUsedRecordListReq) (*GetUsedRecordListResp, error)
GetImageWorkDetail func(ctx context.Context, in *GetImageWorkDetailReq) (*GetImageWorkDetailResp, error)
GetVedioWorkDetail func(ctx context.Context, in *GetVedioWorkDetailReq) (*GetVedioeWorkDetailResp, error)
@ -400,6 +402,12 @@ func (c *bundleClient) AddBundleBalance(ctx context.Context, in *AddBundleBalanc
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/AddBundleBalance", in, out)
}
func (c *bundleClient) BundleActivate(ctx context.Context, in *BundleActivateReq, opts ...grpc_go.CallOption) (*BundleActivateResp, common.ErrorWithAttachment) {
out := new(BundleActivateResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/BundleActivate", in, out)
}
func (c *bundleClient) GetUsedRecordList(ctx context.Context, in *GetUsedRecordListReq, opts ...grpc_go.CallOption) (*GetUsedRecordListResp, common.ErrorWithAttachment) {
out := new(GetUsedRecordListResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
@ -565,6 +573,7 @@ type BundleServer interface {
GetBundleBalanceByUserId(context.Context, *GetBundleBalanceByUserIdReq) (*GetBundleBalanceByUserIdResp, error)
CreateBundleBalance(context.Context, *CreateBundleBalanceReq) (*CreateBundleBalanceResp, error)
AddBundleBalance(context.Context, *AddBundleBalanceReq) (*AddBundleBalanceResp, error)
BundleActivate(context.Context, *BundleActivateReq) (*BundleActivateResp, error)
// 使用记录
GetUsedRecordList(context.Context, *GetUsedRecordListReq) (*GetUsedRecordListResp, error)
GetImageWorkDetail(context.Context, *GetImageWorkDetailReq) (*GetImageWorkDetailResp, error)
@ -711,6 +720,9 @@ func (UnimplementedBundleServer) CreateBundleBalance(context.Context, *CreateBun
func (UnimplementedBundleServer) AddBundleBalance(context.Context, *AddBundleBalanceReq) (*AddBundleBalanceResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method AddBundleBalance not implemented")
}
func (UnimplementedBundleServer) BundleActivate(context.Context, *BundleActivateReq) (*BundleActivateResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method BundleActivate not implemented")
}
func (UnimplementedBundleServer) GetUsedRecordList(context.Context, *GetUsedRecordListReq) (*GetUsedRecordListResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetUsedRecordList not implemented")
}
@ -1901,6 +1913,35 @@ func _Bundle_AddBundleBalance_Handler(srv interface{}, ctx context.Context, dec
return interceptor(ctx, in, info, handler)
}
func _Bundle_BundleActivate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(BundleActivateReq)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("BundleActivate", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
func _Bundle_GetUsedRecordList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(GetUsedRecordListReq)
if err := dec(in); err != nil {
@ -2640,6 +2681,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "AddBundleBalance",
Handler: _Bundle_AddBundleBalance_Handler,
},
{
MethodName: "BundleActivate",
Handler: _Bundle_BundleActivate_Handler,
},
{
MethodName: "GetUsedRecordList",
Handler: _Bundle_GetUsedRecordList_Handler,

View File

@ -60,6 +60,7 @@ func loadMysqlConn(conn string) *gorm.DB {
&model.BundleExtensionRecords{},
&model.BundleBalance{},
&model.Reconciliation{},
&model.BundleActivate{},
)
if err != nil {