From e1d8f0becde545a9da7bc2cc3e1549621f54ba73 Mon Sep 17 00:00:00 2001 From: chy <2463300564@qq.com> Date: Thu, 26 Jun 2025 09:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=A5=96=E5=8A=B1=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E6=8E=A5=E5=8F=A3=EF=BC=8C=E8=B0=83=E6=95=B4=E5=A5=96?= =?UTF-8?q?=E5=8A=B1=E9=A2=86=E5=8F=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/dao/internal/reward_callback.go | 2 ++ internal/dao/internal/reward_waters.go | 2 ++ internal/logic/reward/reward.go | 46 +++++++++++++++++------- internal/model/do/reward_callback.go | 1 + internal/model/do/reward_waters.go | 1 + internal/model/entity/reward_callback.go | 1 + internal/model/entity/reward_waters.go | 1 + internal/model/reward.go | 1 + internal/model/rewardWater.go | 3 +- 9 files changed, 45 insertions(+), 13 deletions(-) diff --git a/internal/dao/internal/reward_callback.go b/internal/dao/internal/reward_callback.go index 05da9b0..249829d 100644 --- a/internal/dao/internal/reward_callback.go +++ b/internal/dao/internal/reward_callback.go @@ -30,6 +30,7 @@ type RewardCallbackColumns struct { PrizeSubType string // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 Num string // 奖励个数,默认 1,比如经验值 10 CustomInfo string // 透传字段 (json串) + AppId string // 业务 id(标识业务方,由游戏人生提供) } // rewardCallbackColumns holds the columns for the table reward_callback. @@ -43,6 +44,7 @@ var rewardCallbackColumns = RewardCallbackColumns{ PrizeSubType: "prize_sub_type", Num: "num", CustomInfo: "custom_info", + AppId: "app_id", } // NewRewardCallbackDao creates and returns a new DAO object for table data access. diff --git a/internal/dao/internal/reward_waters.go b/internal/dao/internal/reward_waters.go index 6534919..76237f5 100644 --- a/internal/dao/internal/reward_waters.go +++ b/internal/dao/internal/reward_waters.go @@ -30,6 +30,7 @@ type RewardWatersColumns struct { CreatedAt string // UpdatedAt string // DeletedAt string // + GameId string // 游戏唯一 id } // rewardWatersColumns holds the columns for the table reward_waters. @@ -43,6 +44,7 @@ var rewardWatersColumns = RewardWatersColumns{ CreatedAt: "created_at", UpdatedAt: "updated_at", DeletedAt: "deleted_at", + GameId: "game_id", } // NewRewardWatersDao creates and returns a new DAO object for table data access. diff --git a/internal/logic/reward/reward.go b/internal/logic/reward/reward.go index 432a27b..4b56d50 100644 --- a/internal/logic/reward/reward.go +++ b/internal/logic/reward/reward.go @@ -359,27 +359,27 @@ func (s *sReward) List(ctx context.Context, in *model.RewardListIn) (out *model. // GetLift 领取奖励 func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *model.GetRewardOut, err error) { + giftParam := model.GiftParam{} // 判断奖励类型 if in.Source == 1 { // 系统奖励处理 if in.RewradTypeId != 16 { // 需要大区角色 - + giftParam.AreaId = in.AreaId + giftParam.Gid = in.GameId + giftParam.RoleIdx = in.RoleIdx + giftParam.TaskId = in.TaskId } else { // 不需要 - + giftParam.TaskId = in.TaskId + giftParam.Gid = in.GameId } } else { // 门店奖励处理 } - activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: model.GiftParam{ - TaskId: in.TaskId, - AreaId: in.AreaId, - Gid: in.GameId, - RoleIdx: in.RoleIdx, - }}) + activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{PopenId: in.PopenId, ServiceName: consts.GetGift, GiftParam: giftParam}) if err != nil { return nil, err @@ -398,15 +398,26 @@ func (s *sReward) GetLift(ctx context.Context, in *model.GetRewardIn) (out *mode } _, err = dao.RewardWaters.Ctx(ctx).Insert(model.RewardWaters{ OrderId: item.Water.OrderId, - Status: int64(item.Water.Status), + Status: int64(item.Result), Uid: item.Water.Uid, - TaskId: "BZD", Water: string(marshal), + TaskId: in.TaskId, + GameId: int64(in.GameId), }) if err != nil { return nil, ecode.Fail.Sub("添加奖励领取记录异常") } + + // 根据 result判断 + if item.Result == 1 { + // 奖励发放成功,修改状态,扣除数量 + + } else if item.Result == 2 || item.Result == 3 { + // 发放背包成功,修改状态 + } else if item.Result == 4 { + // 奖励领取失败,不做操作,直接返回 + } } return nil, err @@ -504,7 +515,7 @@ func (s *sReward) OperateTaskReward(ctx context.Context, in *model.OperateTaskRe // CallBack 奖励回调 func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out *model.RewardCallbackOut, err error) { - dao.RewardCallback.Ctx(ctx).Insert(do.RewardCallback{ + _, err = dao.RewardCallback.Ctx(ctx).OmitEmptyData().Insert(do.RewardCallback{ OrderId: in.OrderId, PrizeId: in.PrizeId, PrizeType: in.PrizeType, @@ -512,6 +523,17 @@ func (s *sReward) CallBack(ctx context.Context, in *model.RewardCallbackIn) (out Uid: in.Uid, Num: in.Num, CustomInfo: in.CustomInfo, + AppId: in.AppId, }) - return nil, err + + if err != nil { + return nil, ecode.Fail.Sub("存储奖励回调数据异常") + } + + return &model.RewardCallbackOut{ + OrderId: in.OrderId, + AppId: in.AppId, + Errcode: 0, + Errmsg: "成功", + }, nil } diff --git a/internal/model/do/reward_callback.go b/internal/model/do/reward_callback.go index 9479999..4ce0b71 100644 --- a/internal/model/do/reward_callback.go +++ b/internal/model/do/reward_callback.go @@ -20,4 +20,5 @@ type RewardCallback struct { PrizeSubType interface{} // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 Num interface{} // 奖励个数,默认 1,比如经验值 10 CustomInfo interface{} // 透传字段 (json串) + AppId interface{} // 业务 id(标识业务方,由游戏人生提供) } diff --git a/internal/model/do/reward_waters.go b/internal/model/do/reward_waters.go index 82b9055..098a39d 100644 --- a/internal/model/do/reward_waters.go +++ b/internal/model/do/reward_waters.go @@ -21,4 +21,5 @@ type RewardWaters struct { CreatedAt *gtime.Time // UpdatedAt *gtime.Time // DeletedAt *gtime.Time // + GameId interface{} // 游戏唯一 id } diff --git a/internal/model/entity/reward_callback.go b/internal/model/entity/reward_callback.go index 8a88730..f810842 100644 --- a/internal/model/entity/reward_callback.go +++ b/internal/model/entity/reward_callback.go @@ -15,4 +15,5 @@ type RewardCallback struct { PrizeSubType int `json:"prizeSubType" orm:"prize_sub_type" description:"奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等"` // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 Num int `json:"num" orm:"num" description:"奖励个数,默认 1,比如经验值 10"` // 奖励个数,默认 1,比如经验值 10 CustomInfo string `json:"customInfo" orm:"custom_info" description:"透传字段 (json串)"` // 透传字段 (json串) + AppId string `json:"appId" orm:"app_id" description:"业务 id(标识业务方,由游戏人生提供)"` // 业务 id(标识业务方,由游戏人生提供) } diff --git a/internal/model/entity/reward_waters.go b/internal/model/entity/reward_waters.go index 9673b4b..f7142ba 100644 --- a/internal/model/entity/reward_waters.go +++ b/internal/model/entity/reward_waters.go @@ -19,4 +19,5 @@ type RewardWaters struct { CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` // UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` // DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` // + GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一 id"` // 游戏唯一 id } diff --git a/internal/model/reward.go b/internal/model/reward.go index cce534b..492e3bb 100644 --- a/internal/model/reward.go +++ b/internal/model/reward.go @@ -131,6 +131,7 @@ type RewardCallbackIn struct { PrizeSubType int `json:"prizeSubType"` // 奖励子类型,默认为 0,有多种子类型时可用,如 1,5 元网费充值券,2、满 30-5 满减券等 Num int `json:"num"` // 奖励个数,默认 1,比如经验值 10 CustomInfo string `json:"customInfo"` // 透传字段 (json串) + AppId string `json:"appId"` // 业务 id } type RewardCallbackOut struct { diff --git a/internal/model/rewardWater.go b/internal/model/rewardWater.go index 70a4bcf..669d90b 100644 --- a/internal/model/rewardWater.go +++ b/internal/model/rewardWater.go @@ -11,5 +11,6 @@ type RewardWaters struct { Status int64 `json:"status" orm:"status" description:"兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作"` // 兑换状态 1:奖励发放成功 2:奖励兑换失败(礼包发放背包环节成功,需重新引导领奖) 3:针对只需要发背包,然后引导用户到人生应用背包领奖的奖励类型,发奖成功了 4:water错误(一般是 orderid),不做兑换操作 CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` // UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` // - DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` // + DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` + GameId int64 `json:"gameId" orm:"game_id" description:"游戏ID"` }