diff --git a/internal/logic/task/task.go b/internal/logic/task/task.go index 09009e1..e6c8d18 100644 --- a/internal/logic/task/task.go +++ b/internal/logic/task/task.go @@ -8,7 +8,6 @@ import ( "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/util/guid" "server/internal/consts" "server/internal/dao" "server/internal/model" @@ -390,7 +389,7 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge if err = dao.UserTasks.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) { // 创建任务记录 - id, err := dao.UserTasks.Ctx(ctx).InsertAndGetId(do.UserTasks{ + _, err = dao.UserTasks.Ctx(ctx).InsertAndGetId(do.UserTasks{ UserId: in.UserId, TaskId: in.TaskId, StoreId: storeId, @@ -405,25 +404,25 @@ func (s *sTask) GetTask(ctx context.Context, in *model.GetTaskIn) (out *model.Ge return ecode.Fail.Sub("创建用户任务记录失败") } - //查询该任务相关联的奖励, 创建对应奖励下发记录id - array, err := dao.TaskRewards.Ctx(ctx).LeftJoin(dao.Rewards.Table(), "rewards.id = task_rewards.reward_id").Where(do.TaskRewards{TaskId: in.TaskId}). - Fields(dao.TaskRewards.Columns().RewardId).Fields(dao.Rewards.Columns().Name).All() - if err != nil { - return ecode.Fail.Sub("获取任务关联奖励列表失败") - } - for _, v := range array { - _, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{ - UserTaskId: id, - RewardId: v["reward_id"].Int64(), - RewardName: v["name"].String(), - Status: consts.RewardInitStatus, - InnerOrderId: fmt.Sprintf("reward%s", guid.S()), - IssueQuantity: 1, - }).Insert() - if err != nil { - return ecode.Fail.Sub("创建用户任务奖励记录失败") - } - } + ////查询该任务相关联的奖励, 创建对应奖励下发记录id + //array, err := dao.TaskRewards.Ctx(ctx).LeftJoin(dao.Rewards.Table(), "rewards.id = task_rewards.reward_id").Where(do.TaskRewards{TaskId: in.TaskId}). + // Fields(dao.TaskRewards.Columns().RewardId).Fields(dao.Rewards.Columns().Name).All() + //if err != nil { + // return ecode.Fail.Sub("获取任务关联奖励列表失败") + //} + //for _, v := range array { + // _, err = dao.UserTaskRewards.Ctx(ctx).Data(do.UserTaskRewards{ + // UserTaskId: id, + // RewardId: v["reward_id"].Int64(), + // RewardName: v["name"].String(), + // Status: consts.RewardInitStatus, + // InnerOrderId: fmt.Sprintf("reward%s", guid.S()), + // IssueQuantity: 1, + // }).Insert() + // if err != nil { + // return ecode.Fail.Sub("创建用户任务奖励记录失败") + // } + //} return }); err != nil { return nil, err