Merge branch 'dev-lzh' into dev

This commit is contained in:
lzh 2025-06-17 14:15:36 +08:00
commit 19ac6f4bf3
8 changed files with 2123 additions and 744 deletions

View File

@ -44,4 +44,8 @@ func (b *BundleProvider) GetVedioWorkDetail(_ context.Context, req *bundle.GetVe
func (b *BundleProvider) ToBeComfirmedWorks(_ context.Context, req *bundle.ToBeComfirmedWorksReq) (*bundle.ToBeComfirmedWorksResp, error) {
return logic.ToBeComfirmedWorks(req)
}
}
func (b *BundleProvider) ConfirmWork(_ context.Context, req *bundle.ConfirmWorkReq) (*bundle.ConfirmWorkResp, error) {
return logic.ConfirmWork(req)
}

View File

@ -245,7 +245,7 @@ func GetVedioWorkDetail(req *bundle.GetVedioWorkDetailReq) (data model.CastWorkV
return
}
func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (data []model.CastWorkLog, total int64, err error) {
func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (data []model.CastWorkLog, total int64, unconfirmed int64, err error) {
session := app.ModuleClients.BundleDB.Model(&model.CastWorkLog{}).Where(&model.CastWorkLog{
ArtistUuid: req.ArtistUuid,
})
@ -253,10 +253,17 @@ func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (data []model.CastWor
if err != nil {
return
}
err = session.Where("confirmed_at = ?", 0).Count(&unconfirmed).Error
if err != nil {
return
}
if req.Page != 0 && req.PageSize != 0 {
session.Limit(int(req.PageSize)).Offset(int(req.Page-1) * int(req.PageSize))
}
err = session.Find(&data).Error
return
}
func ConfirmWork(req *bundle.ConfirmWorkReq) error {
return app.ModuleClients.BundleDB.Model(&model.CastWorkLog{}).Where(&model.CastWorkLog{WorkUuid: req.WorkUuid}).Update("confirmed_at", time.Now().UnixMilli()).Error
}

View File

@ -1,11 +1,13 @@
package logic
import (
"errors"
"micro-bundle/internal/dao"
"micro-bundle/internal/model"
"micro-bundle/pb/bundle"
"time"
"dubbo.apache.org/dubbo-go/v3/common/logger"
"github.com/jinzhu/copier"
"github.com/samber/lo"
)
@ -23,15 +25,21 @@ func BundleExtend(req *bundle.BundleExtendRequest) (*bundle.BundleExtendResponse
AccountNumber: int(req.AccountAdditional),
ExpansionPacksNumber: 1,
}); err != nil {
return nil, err
return nil, errors.New("用户没有余量信息")
}
return nil, dao.AddBundleExtendRecord(data)
err := dao.AddBundleExtendRecord(data)
if err != nil {
logger.Error(err)
return nil, errors.New("创建扩展记录失败")
}
return nil, nil
}
func BundleExtendRecordsList(req *bundle.BundleExtendRecordsListRequest) (*bundle.BundleExtendRecordsListResponse, error) {
data, total, err := dao.GetBundleExtendRecordList(req)
if err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("查询失败")
}
resp := &bundle.BundleExtendRecordsListResponse{}
resp.Total = total
@ -46,7 +54,8 @@ func BundleExtendRecordsList(req *bundle.BundleExtendRecordsListRequest) (*bundl
func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (*bundle.GetBundleBalanceListResp, error) {
data, total, err := dao.GetBundleBalanceList(req)
if err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("查询失败")
}
resp := &bundle.GetBundleBalanceListResp{}
resp.Total = total
@ -61,7 +70,8 @@ func GetBundleBalanceList(req *bundle.GetBundleBalanceListReq) (*bundle.GetBundl
func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (*bundle.GetBundleBalanceByUserIdResp, error) {
data, err := dao.GetBundleBalanceByUserId(req)
if err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("查询失败")
}
result := &bundle.GetBundleBalanceByUserIdResp{}
copier.Copy(result, &data)
@ -75,7 +85,8 @@ func GetBundleBalanceByUserId(req *bundle.GetBundleBalanceByUserIdReq) (*bundle.
func AddBundleBalance(req *bundle.AddBundleBalanceReq) (*bundle.AddBundleBalanceResp, error) {
var data model.BundleBalance
if err := copier.Copy(&data, req); err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("操作失败")
}
return nil, dao.AddBundleBalanceByUserId(data)
}
@ -83,15 +94,22 @@ func AddBundleBalance(req *bundle.AddBundleBalanceReq) (*bundle.AddBundleBalance
func CreateBundleBalance(req *bundle.CreateBundleBalanceReq) (*bundle.CreateBundleBalanceResp, error) {
var data model.BundleBalance
if err := copier.Copy(&data, req); err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("操作失败")
}
return nil, dao.CreateBundleBalance(data)
err := dao.CreateBundleBalance(data)
if err != nil {
logger.Error(err)
return nil, errors.New("创建余量信息失败")
}
return nil, nil
}
func GetUsedRecord(req *bundle.GetUsedRecordListReq) (*bundle.GetUsedRecordListResp, error) {
data, total, err := dao.GetUsedRecord(req)
if err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("查询失败")
}
resp := &bundle.GetUsedRecordListResp{}
resp.Total = total
@ -106,7 +124,8 @@ func GetUsedRecord(req *bundle.GetUsedRecordListReq) (*bundle.GetUsedRecordListR
func GetImageWorkDetail(req *bundle.GetImageWorkDetailReq) (*bundle.GetImageWorkDetailResp, error) {
data, err := dao.GetImageWorkDetail(req)
if err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("查询失败")
}
result := &bundle.GetImageWorkDetailResp{}
err = copier.Copy(result, &data)
@ -116,7 +135,8 @@ func GetImageWorkDetail(req *bundle.GetImageWorkDetailReq) (*bundle.GetImageWork
func GetVedioWorkDetail(req *bundle.GetVedioWorkDetailReq) (*bundle.GetVedioeWorkDetailResp, error) {
data, err := dao.GetVedioWorkDetail(req)
if err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("查询失败")
}
result := &bundle.GetVedioeWorkDetailResp{}
err = copier.Copy(result, &data)
@ -124,12 +144,15 @@ func GetVedioWorkDetail(req *bundle.GetVedioWorkDetailReq) (*bundle.GetVedioeWor
}
func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (*bundle.ToBeComfirmedWorksResp, error) {
data, total, err := dao.ToBeComfirmedWorks(req)
data, total, unconfirmed, err := dao.ToBeComfirmedWorks(req)
if err != nil {
return nil, err
logger.Error(err)
return nil, errors.New("查询失败")
}
result := &bundle.ToBeComfirmedWorksResp{
Total: total,
Unconfirmed: unconfirmed,
}
result := &bundle.ToBeComfirmedWorksResp{}
result.Total = total
result.Data = lo.Map(data, func(m model.CastWorkLog, _ int) *bundle.WorkItem {
result := &bundle.WorkItem{}
copier.Copy(result, &m)
@ -137,3 +160,7 @@ func ToBeComfirmedWorks(req *bundle.ToBeComfirmedWorksReq) (*bundle.ToBeComfirme
})
return result, nil
}
func ConfirmWork(req *bundle.ConfirmWorkReq) (*bundle.ConfirmWorkResp, error) {
return nil, dao.ConfirmWork(req)
}

View File

@ -1,6 +1,8 @@
package model
import "gorm.io/plugin/soft_delete"
import (
"gorm.io/plugin/soft_delete"
)
type CostLog struct {
Uuid string `gorm:"column:uuid;type:varchar(50);NOT NULL;primary_key;" json:"id"`
@ -86,7 +88,6 @@ func (*CastWork) TableName() string {
return "cast_work"
}
type CastWorkLog struct {
Uuid string `gorm:"column:uuid;type:varchar(50);primary_key" json:"uuid"`
WorkUuid string `gorm:"column:work_uuid;type:varchar(50);comment:作品uuid;NOT NULL" json:"work_uuid"`
@ -100,6 +101,7 @@ type CastWorkLog struct {
ArtistUuid string `gorm:"column:artist_uuid;type:varchar(50);comment:艺人ID;NOT NULL" json:"artist_uuid"`
MediaAccUserIds string `gorm:"column:media_acc_user_ids;type:json;comment:自媒体账号user_ids集合;NOT NULL" json:"media_acc_user_ids"`
MediaNames string `gorm:"column:media_names;type:varchar(600);comment:自媒体账号名称集合;NOT NULL" json:"media_names"`
ConfirmedAt int64 `gorm:"column:confirmed_at;type:int(11)" json:"confirmedAt"`
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"`

View File

@ -63,6 +63,7 @@ service Bundle {
rpc GetVedioWorkDetail(GetVedioWorkDetailReq) returns (GetVedioeWorkDetailResp) {} //
rpc ToBeComfirmedWorks(ToBeComfirmedWorksReq) returns (ToBeComfirmedWorksResp) {} //
rpc ConfirmWork(ConfirmWorkReq) returns (ConfirmWorkResp) {} //
//
rpc GetReconciliationList(GetReconciliationListReq) returns (GetReconciliationListResp) {} //
@ -736,14 +737,16 @@ message workItem{
string platformIDs = 7;
string mediaNames = 8;
string mediaAccUserIds = 9;
int64 createdAt = 10; //
string artistName = 11;
string artistUuid = 12;
int64 confirmedAt = 10;
int64 createdAt = 11; //
string artistName = 12;
string artistUuid = 13;
}
message ToBeComfirmedWorksResp{
int64 total = 1;
repeated workItem data =2;
int64 unconfirmed = 2;
repeated workItem data = 3;
}
message GetBundleBalanceByUserIdReq{
@ -794,4 +797,12 @@ message UpdateStatusAndPayTimeBySerialNumber {
string serialNumber = 1;
string payTime = 2;
int32 paymentStatus = 3;
}
message ConfirmWorkReq{
string workUuid = 1;
}
message ConfirmWorkResp{
}

File diff suppressed because it is too large Load Diff

View File

@ -438,3 +438,9 @@ func (this *AddBundleInfo) Validate() error {
func (this *UpdateStatusAndPayTimeBySerialNumber) Validate() error {
return nil
}
func (this *ConfirmWorkReq) Validate() error {
return nil
}
func (this *ConfirmWorkResp) Validate() error {
return nil
}

View File

@ -71,6 +71,7 @@ type BundleClient interface {
GetImageWorkDetail(ctx context.Context, in *GetImageWorkDetailReq, opts ...grpc_go.CallOption) (*GetImageWorkDetailResp, common.ErrorWithAttachment)
GetVedioWorkDetail(ctx context.Context, in *GetVedioWorkDetailReq, opts ...grpc_go.CallOption) (*GetVedioeWorkDetailResp, common.ErrorWithAttachment)
ToBeComfirmedWorks(ctx context.Context, in *ToBeComfirmedWorksReq, opts ...grpc_go.CallOption) (*ToBeComfirmedWorksResp, common.ErrorWithAttachment)
ConfirmWork(ctx context.Context, in *ConfirmWorkReq, opts ...grpc_go.CallOption) (*ConfirmWorkResp, common.ErrorWithAttachment)
// 对账单
GetReconciliationList(ctx context.Context, in *GetReconciliationListReq, opts ...grpc_go.CallOption) (*GetReconciliationListResp, common.ErrorWithAttachment)
CreateReconciliation(ctx context.Context, in *ReconciliationInfo, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment)
@ -122,6 +123,7 @@ type BundleClientImpl struct {
GetImageWorkDetail func(ctx context.Context, in *GetImageWorkDetailReq) (*GetImageWorkDetailResp, error)
GetVedioWorkDetail func(ctx context.Context, in *GetVedioWorkDetailReq) (*GetVedioeWorkDetailResp, error)
ToBeComfirmedWorks func(ctx context.Context, in *ToBeComfirmedWorksReq) (*ToBeComfirmedWorksResp, error)
ConfirmWork func(ctx context.Context, in *ConfirmWorkReq) (*ConfirmWorkResp, error)
GetReconciliationList func(ctx context.Context, in *GetReconciliationListReq) (*GetReconciliationListResp, error)
CreateReconciliation func(ctx context.Context, in *ReconciliationInfo) (*CommonResponse, error)
UpdateReconciliation func(ctx context.Context, in *ReconciliationInfo) (*CommonResponse, error)
@ -374,6 +376,12 @@ func (c *bundleClient) ToBeComfirmedWorks(ctx context.Context, in *ToBeComfirmed
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ToBeComfirmedWorks", in, out)
}
func (c *bundleClient) ConfirmWork(ctx context.Context, in *ConfirmWorkReq, opts ...grpc_go.CallOption) (*ConfirmWorkResp, common.ErrorWithAttachment) {
out := new(ConfirmWorkResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ConfirmWork", in, out)
}
func (c *bundleClient) GetReconciliationList(ctx context.Context, in *GetReconciliationListReq, opts ...grpc_go.CallOption) (*GetReconciliationListResp, common.ErrorWithAttachment) {
out := new(GetReconciliationListResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
@ -445,6 +453,7 @@ type BundleServer interface {
GetImageWorkDetail(context.Context, *GetImageWorkDetailReq) (*GetImageWorkDetailResp, error)
GetVedioWorkDetail(context.Context, *GetVedioWorkDetailReq) (*GetVedioeWorkDetailResp, error)
ToBeComfirmedWorks(context.Context, *ToBeComfirmedWorksReq) (*ToBeComfirmedWorksResp, error)
ConfirmWork(context.Context, *ConfirmWorkReq) (*ConfirmWorkResp, error)
// 对账单
GetReconciliationList(context.Context, *GetReconciliationListReq) (*GetReconciliationListResp, error)
CreateReconciliation(context.Context, *ReconciliationInfo) (*CommonResponse, error)
@ -575,6 +584,9 @@ func (UnimplementedBundleServer) GetVedioWorkDetail(context.Context, *GetVedioWo
func (UnimplementedBundleServer) ToBeComfirmedWorks(context.Context, *ToBeComfirmedWorksReq) (*ToBeComfirmedWorksResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ToBeComfirmedWorks not implemented")
}
func (UnimplementedBundleServer) ConfirmWork(context.Context, *ConfirmWorkReq) (*ConfirmWorkResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ConfirmWork not implemented")
}
func (UnimplementedBundleServer) GetReconciliationList(context.Context, *GetReconciliationListReq) (*GetReconciliationListResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetReconciliationList not implemented")
}
@ -1746,6 +1758,35 @@ func _Bundle_ToBeComfirmedWorks_Handler(srv interface{}, ctx context.Context, de
return interceptor(ctx, in, info, handler)
}
func _Bundle_ConfirmWork_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ConfirmWorkReq)
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("ConfirmWork", 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_GetReconciliationList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(GetReconciliationListReq)
if err := dec(in); err != nil {
@ -2025,6 +2066,10 @@ var Bundle_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "ToBeComfirmedWorks",
Handler: _Bundle_ToBeComfirmedWorks_Handler,
},
{
MethodName: "ConfirmWork",
Handler: _Bundle_ConfirmWork_Handler,
},
{
MethodName: "GetReconciliationList",
Handler: _Bundle_GetReconciliationList_Handler,