特朗普头像任务

This commit is contained in:
lianghuanjie
2025-01-20 21:55:43 +08:00
parent 38bb283fa1
commit 9c742c50c3
18 changed files with 266 additions and 32 deletions

View File

@@ -45,6 +45,7 @@ type ServiceContext struct {
AmbassadorModel model.NhTaskAmbassadorModel
GameReportModel model.NhGameReportModel
RoleModel model.NhRoleModel
GamesPropertyModel model.NhGamesPropertyLogsModel
ApiKeyCheck rest.Middleware
AdminSecretCheck rest.Middleware
@@ -84,6 +85,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
AmbassadorModel: model.NewNhTaskAmbassadorModel(dbConn),
GameReportModel: model.NewNhGameReportModel(dbConn),
RoleModel: model.NewNhRoleModel(dbConn),
GamesPropertyModel: model.NewNhGamesPropertyLogsModel(dbConn),
ApiKeyCheck: middleware.NewApiKeyCheckMiddleware(configModel).Handle,
AdminSecretCheck: middleware.NewAdminSecretCheckMiddleware(configModel).Handle,
@@ -154,15 +156,18 @@ func (s *ServiceContext) GetUidByEmail(ctx context.Context, email string) (uint,
return u.Id, nil
}
func (s *ServiceContext) AddUserAssetWithSession(ctx context.Context, session sqlx.Session, uid uint, asset consts.AssetType, amount decimal.Decimal, remark string, eventId uint64, provideUid uint, referralReward bool) error {
func (s *ServiceContext) AddUserAssetWithSession(ctx context.Context, session sqlx.Session, uid uint, role int64, asset consts.AssetType, assetId string, amount decimal.Decimal, remark string, eventId uint64, provideUid uint, referralReward bool) error {
var assetModel model.NhTaskAssetModel
var recordModel model.NhTaskAssetRecordModel
var gamesPropertyModel model.NhGamesPropertyLogsModel
if session != nil {
assetModel = s.taskAssetModel.WithSession(session)
recordModel = s.taskAssetRecordModel.WithSession(session)
gamesPropertyModel = s.GamesPropertyModel.WithSession(session)
} else {
assetModel = s.taskAssetModel
recordModel = s.taskAssetRecordModel
gamesPropertyModel = s.GamesPropertyModel
}
var err error
switch asset {
@@ -174,6 +179,14 @@ func (s *ServiceContext) AddUserAssetWithSession(ctx context.Context, session sq
err = assetModel.AddElitePoints(ctx, uid, amount)
case consts.AssetType_Keys:
err = assetModel.AddKeys(ctx, uid, int(amount.IntPart()))
case consts.AssetType_Property:
_, err = gamesPropertyModel.Insert(ctx, &model.NhGamesPropertyLogs{
Uid: uid,
RoleId: int64(role),
PropertyId: assetId,
PropertyNum: uint(amount.IntPart()),
})
return err
default:
return errors.New("unknown asset type")
}
@@ -214,9 +227,9 @@ func (s *ServiceContext) AddUserAssetWithSession(ctx context.Context, session sq
}
rated := decimal.NewFromFloat(float64(rate) / 100)
rewardAmount := amount.Mul(rated)
return s.AddUserAssetWithSession(ctx, session, pb.ShareUid, asset, rewardAmount, fmt.Sprintf("分享返利,比例%s", rated.String()), 7, uid, false)
return s.AddUserAssetWithSession(ctx, session, pb.ShareUid, 0, asset, assetId, rewardAmount, fmt.Sprintf("分享返利,比例%s", rated.String()), 7, uid, false)
}
func (s *ServiceContext) AddUserAsset(ctx context.Context, uid uint, asset consts.AssetType, amount decimal.Decimal, remark string, eventId uint64, provideUid uint, referralReward bool) error {
return s.AddUserAssetWithSession(ctx, nil, uid, asset, amount, remark, eventId, provideUid, referralReward)
func (s *ServiceContext) AddUserAsset(ctx context.Context, uid uint, role int64, asset consts.AssetType, assetId string, amount decimal.Decimal, remark string, eventId uint64, provideUid uint, referralReward bool) error {
return s.AddUserAssetWithSession(ctx, nil, uid, role, asset, assetId, amount, remark, eventId, provideUid, referralReward)
}