修改任务列表查询

This commit is contained in:
chy
2025-06-18 21:34:53 +08:00
parent 87d19b5fe2
commit 3c18686bf9
26 changed files with 316 additions and 344 deletions

View File

@ -23,8 +23,8 @@ type NonLoginTaskListReq struct {
Gid int `json:"gid" v:"required#游戏唯一id不能为空" dc:"游戏唯一id"`
Num int `json:"num" v:"required#不能为空" dc:""`
Pageidx string `json:"pageidx" dc:"分页索引"`
Source string `json:"source" v:"required#不能为空" dc:""`
BrandId string `json:"brandId" dc:"品牌id(可选)"`
//Source string `json:"source" v:"required#不能为空" dc:""`
//BrandId string `json:"brandId" dc:"品牌id(可选)"`
}
type NonLoginTaskListRes struct {

View File

@ -8,3 +8,8 @@ const (
GamelifeExtplatBoundTypeWX = "wx"
GamelifeMiniProgramBand = "1"
)
const (
GetNonLoginTaskList = "GetNonloginTaskList"
GetTaskList = "GetTaskList"
)

View File

@ -1,6 +0,0 @@
package consts
const (
TestAddr = "https://api-test.cafe.qq.com/netbar.cafe.open_api.open_api/"
ProAddr = "https://api.cafe.qq.com/netbar.cafe.open_api.open_api/"
)

View File

@ -17,8 +17,8 @@ func (c *ControllerV1) NonLoginTaskList(ctx context.Context, req *v1.NonLoginTas
Num: req.Num,
Pageidx: req.Pageidx,
Gid: req.Gid,
Source: req.Source,
BrandId: req.BrandId,
//Source: req.Source,
//BrandId: req.BrandId,
})
if err != nil {

View File

@ -16,6 +16,7 @@ type AdminsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns AdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// AdminsColumns defines and stores column names for the table admins.
@ -49,11 +50,12 @@ var adminsColumns = AdminsColumns{
}
// NewAdminsDao creates and returns a new DAO object for table data access.
func NewAdminsDao() *AdminsDao {
func NewAdminsDao(handlers ...gdb.ModelHandler) *AdminsDao {
return &AdminsDao{
group: "default",
table: "admins",
columns: adminsColumns,
handlers: handlers,
}
}
@ -79,7 +81,11 @@ func (dao *AdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *AdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type FeedbacksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns FeedbacksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// FeedbacksColumns defines and stores column names for the table feedbacks.
@ -51,11 +52,12 @@ var feedbacksColumns = FeedbacksColumns{
}
// NewFeedbacksDao creates and returns a new DAO object for table data access.
func NewFeedbacksDao() *FeedbacksDao {
func NewFeedbacksDao(handlers ...gdb.ModelHandler) *FeedbacksDao {
return &FeedbacksDao{
group: "default",
table: "feedbacks",
columns: feedbacksColumns,
handlers: handlers,
}
}
@ -81,7 +83,11 @@ func (dao *FeedbacksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *FeedbacksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type GamesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns GamesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// GamesColumns defines and stores column names for the table games.
@ -45,11 +46,12 @@ var gamesColumns = GamesColumns{
}
// NewGamesDao creates and returns a new DAO object for table data access.
func NewGamesDao() *GamesDao {
func NewGamesDao(handlers ...gdb.ModelHandler) *GamesDao {
return &GamesDao{
group: "default",
table: "games",
columns: gamesColumns,
handlers: handlers,
}
}
@ -75,7 +77,11 @@ func (dao *GamesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *GamesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type MerchantAdminsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// MerchantAdminsColumns defines and stores column names for the table merchant_admins.
@ -57,11 +58,12 @@ var merchantAdminsColumns = MerchantAdminsColumns{
}
// NewMerchantAdminsDao creates and returns a new DAO object for table data access.
func NewMerchantAdminsDao() *MerchantAdminsDao {
func NewMerchantAdminsDao(handlers ...gdb.ModelHandler) *MerchantAdminsDao {
return &MerchantAdminsDao{
group: "default",
table: "merchant_admins",
columns: merchantAdminsColumns,
handlers: handlers,
}
}
@ -87,7 +89,11 @@ func (dao *MerchantAdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *MerchantAdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type MerchantsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns MerchantsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// MerchantsColumns defines and stores column names for the table merchants.
@ -71,11 +72,12 @@ var merchantsColumns = MerchantsColumns{
}
// NewMerchantsDao creates and returns a new DAO object for table data access.
func NewMerchantsDao() *MerchantsDao {
func NewMerchantsDao(handlers ...gdb.ModelHandler) *MerchantsDao {
return &MerchantsDao{
group: "default",
table: "merchants",
columns: merchantsColumns,
handlers: handlers,
}
}
@ -101,7 +103,11 @@ func (dao *MerchantsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *MerchantsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type RewardTypesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RewardTypesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RewardTypesColumns defines and stores column names for the table reward_types.
@ -45,11 +46,12 @@ var rewardTypesColumns = RewardTypesColumns{
}
// NewRewardTypesDao creates and returns a new DAO object for table data access.
func NewRewardTypesDao() *RewardTypesDao {
func NewRewardTypesDao(handlers ...gdb.ModelHandler) *RewardTypesDao {
return &RewardTypesDao{
group: "default",
table: "reward_types",
columns: rewardTypesColumns,
handlers: handlers,
}
}
@ -75,7 +77,11 @@ func (dao *RewardTypesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RewardTypesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type RolesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns RolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// RolesColumns defines and stores column names for the table roles.
@ -47,11 +48,12 @@ var rolesColumns = RolesColumns{
}
// NewRolesDao creates and returns a new DAO object for table data access.
func NewRolesDao() *RolesDao {
func NewRolesDao(handlers ...gdb.ModelHandler) *RolesDao {
return &RolesDao{
group: "default",
table: "roles",
columns: rolesColumns,
handlers: handlers,
}
}
@ -77,7 +79,11 @@ func (dao *RolesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *RolesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type StoreAdminsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreAdminsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreAdminsColumns defines and stores column names for the table store_admins.
@ -57,11 +58,12 @@ var storeAdminsColumns = StoreAdminsColumns{
}
// NewStoreAdminsDao creates and returns a new DAO object for table data access.
func NewStoreAdminsDao() *StoreAdminsDao {
func NewStoreAdminsDao(handlers ...gdb.ModelHandler) *StoreAdminsDao {
return &StoreAdminsDao{
group: "default",
table: "store_admins",
columns: storeAdminsColumns,
handlers: handlers,
}
}
@ -87,7 +89,11 @@ func (dao *StoreAdminsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreAdminsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type StoreDesktopSettingsDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreDesktopSettingsColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreDesktopSettingsColumns defines and stores column names for the table store_desktop_settings.
@ -45,11 +46,12 @@ var storeDesktopSettingsColumns = StoreDesktopSettingsColumns{
}
// NewStoreDesktopSettingsDao creates and returns a new DAO object for table data access.
func NewStoreDesktopSettingsDao() *StoreDesktopSettingsDao {
func NewStoreDesktopSettingsDao(handlers ...gdb.ModelHandler) *StoreDesktopSettingsDao {
return &StoreDesktopSettingsDao{
group: "default",
table: "store_desktop_settings",
columns: storeDesktopSettingsColumns,
handlers: handlers,
}
}
@ -75,7 +77,11 @@ func (dao *StoreDesktopSettingsDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreDesktopSettingsDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type StoreRolesDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoreRolesColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoreRolesColumns defines and stores column names for the table store_roles.
@ -39,11 +40,12 @@ var storeRolesColumns = StoreRolesColumns{
}
// NewStoreRolesDao creates and returns a new DAO object for table data access.
func NewStoreRolesDao() *StoreRolesDao {
func NewStoreRolesDao(handlers ...gdb.ModelHandler) *StoreRolesDao {
return &StoreRolesDao{
group: "default",
table: "store_roles",
columns: storeRolesColumns,
handlers: handlers,
}
}
@ -69,7 +71,11 @@ func (dao *StoreRolesDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoreRolesDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type StoresDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns StoresColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// StoresColumns defines and stores column names for the table stores.
@ -51,11 +52,12 @@ var storesColumns = StoresColumns{
}
// NewStoresDao creates and returns a new DAO object for table data access.
func NewStoresDao() *StoresDao {
func NewStoresDao(handlers ...gdb.ModelHandler) *StoresDao {
return &StoresDao{
group: "default",
table: "stores",
columns: storesColumns,
handlers: handlers,
}
}
@ -81,7 +83,11 @@ func (dao *StoresDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *StoresDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,46 +16,54 @@ type TasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns TasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// TasksColumns defines and stores column names for the table tasks.
type TasksColumns struct {
Id string // 任务唯一标识符
QqNetbarTaskId string // QQ网吧任务ID
CreatedAt string // 创建时间
UpdatedAt string // 更新时间
DeletedAt string // 软删除时间戳
QqNetbarTaskName string // QQ网吧任务名称
QqNetbarTaskMemo string // 任务描述
QqNetbarTaskRules string // 任务规则
GameId string // 游戏唯一id
StoreId string // 门店 id
QqNetbarReward string //
Status string // 1启用 2禁用
QqNetbarTaskId string // QQ网吧任务ID
QqNetbarTaskRules string // 任务规则
QqNetbarTaskMemo string // 任务描述
QqNetbarTaskName string // QQ网吧任务名称
QqNetbarReward string // qq 网吧奖励名称
QqNetbarTargetTime string // qq 网吧任务指标
StartTime string // 任务开始时间
EndTime string // 任务结束时间
}
// tasksColumns holds the columns for the table tasks.
var tasksColumns = TasksColumns{
Id: "id",
QqNetbarTaskId: "qq_netbar_task_id",
CreatedAt: "created_at",
UpdatedAt: "updated_at",
DeletedAt: "deleted_at",
QqNetbarTaskName: "qq_netbar_task_name",
QqNetbarTaskMemo: "qq_netbar_task_memo",
QqNetbarTaskRules: "qq_netbar_task_rules",
GameId: "game_id",
StoreId: "store_id",
QqNetbarReward: "qq_netbar_reward",
Status: "status",
QqNetbarTaskId: "qq_netbar_task_id",
QqNetbarTaskRules: "qq_netbar_task_rules",
QqNetbarTaskMemo: "qq_netbar_task_memo",
QqNetbarTaskName: "qq_netbar_task_name",
QqNetbarReward: "qq_netbar_reward",
QqNetbarTargetTime: "qq_netbar_target_time",
StartTime: "start_time",
EndTime: "end_time",
}
// NewTasksDao creates and returns a new DAO object for table data access.
func NewTasksDao() *TasksDao {
func NewTasksDao(handlers ...gdb.ModelHandler) *TasksDao {
return &TasksDao{
group: "default",
table: "tasks",
columns: tasksColumns,
handlers: handlers,
}
}
@ -81,7 +89,11 @@ func (dao *TasksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *TasksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type UserTasksDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UserTasksColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UserTasksColumns defines and stores column names for the table user_tasks.
@ -47,11 +48,12 @@ var userTasksColumns = UserTasksColumns{
}
// NewUserTasksDao creates and returns a new DAO object for table data access.
func NewUserTasksDao() *UserTasksDao {
func NewUserTasksDao(handlers ...gdb.ModelHandler) *UserTasksDao {
return &UserTasksDao{
group: "default",
table: "user_tasks",
columns: userTasksColumns,
handlers: handlers,
}
}
@ -77,7 +79,11 @@ func (dao *UserTasksDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *UserTasksDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -16,6 +16,7 @@ type UsersDao struct {
table string // table is the underlying table name of the DAO.
group string // group is the database configuration group name of the current DAO.
columns UsersColumns // columns contains all the column names of Table for convenient usage.
handlers []gdb.ModelHandler // handlers for customized model modification.
}
// UsersColumns defines and stores column names for the table users.
@ -59,11 +60,12 @@ var usersColumns = UsersColumns{
}
// NewUsersDao creates and returns a new DAO object for table data access.
func NewUsersDao() *UsersDao {
func NewUsersDao(handlers ...gdb.ModelHandler) *UsersDao {
return &UsersDao{
group: "default",
table: "users",
columns: usersColumns,
handlers: handlers,
}
}
@ -89,7 +91,11 @@ func (dao *UsersDao) Group() string {
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
func (dao *UsersDao) Ctx(ctx context.Context) *gdb.Model {
return dao.DB().Model(dao.table).Safe().Ctx(ctx)
model := dao.DB().Model(dao.table)
for _, handler := range dao.handlers {
model = handler(model)
}
return model.Safe().Ctx(ctx)
}
// Transaction wraps the transaction logic using function f.

View File

@ -2,15 +2,15 @@ package task
import (
"context"
"encoding/json"
"fmt"
"server/internal/consts"
"server/internal/dao"
"server/internal/model"
"server/internal/model/do"
"server/internal/service"
"server/utility/ecode"
"server/utility/gamelife"
"server/utility/snowid"
"server/utility/tencent"
"sort"
"strconv"
"strings"
@ -147,85 +147,50 @@ func (s *sTask) UserTaskRankingList(ctx context.Context, in *model.UserTaskRanki
func (s *sTask) GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (out *model.GetNonLoginTaskListOut, err error) {
// 调用外部接口
data, err := tencent.GetNonLoginTaskList(ctx, in)
activity, err := gamelife.GetGamelifeClient(ctx).RequestActivity(ctx, &model.QQNetbarActivityIn{ServiceName: consts.GetNonLoginTaskList, TaskParam: model.TaskParam{Gid: in.Gid, NetBarAccount: in.NetBarAccount, Num: in.Num, Pageidx: in.Pageidx}})
if err != nil {
return nil, err
}
result, ok := activity.(*model.GameTaskResponse)
if !ok {
return nil, ecode.Fail.Sub("数据类型转换失败")
}
// 剔除不需要的任务数据
var tasks []model.Task
for _, task := range result.TaskList {
data := model.Task{
QqNetbarTaskId: task.TaskID,
QqNetbarTaskName: task.Title,
QqNetbarTaskMemo: task.TaskDesc,
QqNetbarTaskRules: task.RuleDesc,
QqNetbarReward: task.TargetName,
QqNetbarTargetTime: task.TargetTimes,
StartTime: task.CycleStart,
EndTime: task.CycleEnd,
}
var store *model.Store
// 获取网吧账号 id用作存储task
err = dao.Stores.Ctx(ctx).Where(dao.Stores.Columns().NetbarAccount, in.NetBarAccount).Scan(&store)
// 组装门店奖励数据
err := dao.Tasks.Ctx(ctx).InnerJoin(dao.StoreTaskRewards.Table(), fmt.Sprintf("%s.%s = %s.%s", dao.Tasks.Table(), dao.Tasks.Columns().Id, dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().TaskId)).
InnerJoin(dao.Rewards.Table(), fmt.Sprintf("%s.%s = %s.%s", dao.StoreTaskRewards.Table(), dao.StoreTaskRewards.Columns().RewardId, dao.Rewards.Table(), dao.Rewards.Columns().Id)).
Where(dao.Tasks.Columns().QqNetbarTaskId, task.TaskID).Fields(fmt.Sprintf("%s.*", dao.Rewards.Table())).Scan(&data.NetbarRewards)
if err != nil {
return nil, ecode.Fail.Sub("查找网吧失败")
}
if store == nil {
return nil, ecode.Fail.Sub("当前网吧不存在")
}
// 任务列表数据处理
if jsonData, ok := data.(map[string]interface{}); ok {
// 现在可以访问 jsonData 中的字段
list := jsonData["task_list"]
// 将 interface{} 转换为结构体
var result []model.MyData
jsonBytes, err := json.Marshal(list)
if err != nil {
return nil, ecode.Fail.Sub("JSON序列化失败")
}
err = json.Unmarshal(jsonBytes, &result)
if err != nil {
return nil, ecode.Fail.Sub("JSON反序列化失败")
}
for _, v := range result {
exist, err := dao.Tasks.Ctx(ctx).Where(dao.Tasks.Columns().QqNetbarTaskId, v.TaskId).Exist()
if err != nil {
return nil, ecode.Fail.Sub("查询该任务失败")
}
str := ""
for i, vv := range v.PrizeList {
str += vv.PrizeName
if i+1 != len(v.PrizeList) {
str += ","
}
}
// 数据库是否存在,无则添加
if !exist {
_, err := dao.Tasks.Ctx(ctx).Insert(do.Tasks{
QqNetbarTaskId: v.TaskId,
QqNetbarTaskMemo: v.QQNetBarTaskMemo,
QqNetbarTaskName: v.QQNetBarTaskName,
QqNetbarTaskRules: v.QQNetBarTaskRules,
GameId: in.Gid,
StoreId: store.Id,
QqNetbarReward: str,
})
if err != nil {
return nil, ecode.Fail.Sub("添加任务失败")
}
}
return nil, err
}
tasks = append(tasks, data)
}
return &model.GetNonLoginTaskListOut{
Data: data,
Data: tasks,
}, err
}
func (s *sTask) GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskListIn) (out *model.GetLoginTaskListOut, err error) {
// 调用外部接口
data, err := tencent.GetLoginTaskList(ctx, in)
if err != nil {
return nil, err
}
// 任务列表数据处理
return &model.GetLoginTaskListOut{
Data: data,
Data: nil,
}, err
}

View File

@ -13,15 +13,18 @@ import (
type Tasks struct {
g.Meta `orm:"table:tasks, do:true"`
Id interface{} // 任务唯一标识符
QqNetbarTaskId interface{} // QQ网吧任务ID
CreatedAt *gtime.Time // 创建时间
UpdatedAt *gtime.Time // 更新时间
DeletedAt *gtime.Time // 软删除时间戳
QqNetbarTaskName interface{} // QQ网吧任务名称
QqNetbarTaskMemo interface{} // 任务描述
QqNetbarTaskRules interface{} // 任务规则
GameId interface{} // 游戏唯一id
StoreId interface{} // 门店 id
QqNetbarReward interface{} //
Status interface{} // 1启用 2禁用
QqNetbarTaskId interface{} // QQ网吧任务ID
QqNetbarTaskRules interface{} // 任务规则
QqNetbarTaskMemo interface{} // 任务描述
QqNetbarTaskName interface{} // QQ网吧任务名称
QqNetbarReward interface{} // qq 网吧奖励名称
QqNetbarTargetTime interface{} // qq 网吧任务指标
StartTime interface{} // 任务开始时间
EndTime interface{} // 任务结束时间
}

View File

@ -11,15 +11,18 @@ import (
// Tasks is the golang structure for table tasks.
type Tasks struct {
Id int64 `json:"id" orm:"id" description:"任务唯一标识符"` // 任务唯一标识符
QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID
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:"软删除时间戳"` // 软删除时间戳
QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称
QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:""` //
Status int `json:"status" orm:"status" description:"1启用 2禁用"` // 1启用 2禁用
QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述
QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称
QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq 网吧奖励名称"` // qq 网吧奖励名称
QqNetbarTargetTime int `json:"qqNetbarTargetTime" orm:"qq_netbar_target_time" description:"qq 网吧任务指标"` // qq 网吧任务指标
StartTime int64 `json:"startTime" orm:"start_time" description:"任务开始时间"` // 任务开始时间
EndTime int64 `json:"endTime" orm:"end_time" description:"任务结束时间"` // 任务结束时间
}

View File

@ -50,8 +50,8 @@ type GameTaskResponse struct {
}
type TaskParam struct {
NetbarAccount string `json:"netbar_account"`
PageIds string `json:"pageidx"`
NetBarAccount string `json:"netbar_account"`
Pageidx string `json:"pageidx"`
Num int `json:"num"`
Gid int `json:"gid"`
BrandId string `json:"brand_id"`

View File

@ -1,11 +1,13 @@
package model
import (
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
// Reward 奖励表
type Reward struct {
g.Meta `orm:"table:reward"`
Id int64 `json:"id" dc:"奖励ID" orm:"id,primary"`
RewardTypeId int64 `json:"rewardTypeId" dc:"奖励类型ID" orm:"reward_type_id"`
RewardTypeName string `json:"rewardTypeName" dc:"奖励类型名称" orm:"reward_type_name"`

View File

@ -7,17 +7,20 @@ import (
type Task struct {
Id int64 `json:"id" orm:"id" description:"任务唯一标识符"` // 任务唯一标识符
QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID
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:"软删除时间戳"` // 软删除时间戳
QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称
QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
GameId int64 `json:"gameId" orm:"game_id" description:"游戏唯一id"` // 游戏唯一id
StoreId int64 `json:"storeId" orm:"store_id" description:"门店 id"` // 门店 id
Status int `json:"status" orm:"status" description:"状态"` // 状态
QQNetBarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq网吧奖励名称"` // 任务奖励
Status int `json:"status" orm:"status" description:"1启用 2禁用"` // 1启用 2禁用
QqNetbarTaskId string `json:"qqNetbarTaskId" orm:"qq_netbar_task_id" description:"QQ网吧任务ID"` // QQ网吧任务ID
QqNetbarTaskRules string `json:"qqNetbarTaskRules" orm:"qq_netbar_task_rules" description:"任务规则"` // 任务规则
QqNetbarTaskMemo string `json:"qqNetbarTaskMemo" orm:"qq_netbar_task_memo" description:"任务描述"` // 任务描述
QqNetbarTaskName string `json:"qqNetbarTaskName" orm:"qq_netbar_task_name" description:"QQ网吧任务名称"` // QQ网吧任务名称
QqNetbarReward string `json:"qqNetbarReward" orm:"qq_netbar_reward" description:"qq 网吧奖励名称"` // qq 网吧奖励名称
QqNetbarTargetTime int `json:"qqNetbarTargetTime" orm:"qq_netbar_target_time" description:"qq 网吧任务指标"` // qq 网吧任务指标
StartTime int64 `json:"startTime" orm:"start_time" description:"任务开始时间"` // 任务开始时间
EndTime int64 `json:"endTime" orm:"end_time" description:"任务结束时间"` // 任务结束时间
NetbarRewards []Reward `json:"netbarRewards" orm:"-"`
}

View File

@ -309,10 +309,10 @@ func (s *gamelifeClient) GetBound(ctx context.Context, popenid string) (*model.U
return &result, nil
}
func (s *gamelifeClient) RequestNetbarTaskByGameID(ctx context.Context, in *model.QQNetbarActivityIn) (interface{}, error) {
func (s *gamelifeClient) RequestActivity(ctx context.Context, in *model.QQNetbarActivityIn) (interface{}, error) {
client := resty.New()
switch in.ServiceName {
case "GetNonloginTaskList":
case consts.GetNonLoginTaskList:
result := model.GameTaskResponse{}
in.TaskParam.Source = s.PlatId
in.TaskParam.BrandId = s.BrandId
@ -320,7 +320,7 @@ func (s *gamelifeClient) RequestNetbarTaskByGameID(ctx context.Context, in *mode
SetContext(ctx).
SetBody(in.TaskParam).
SetResult(&result).
Post(s.taskUrlMap[s.Mode] + "GetNonloginTaskList")
Post(s.taskUrlMap[s.Mode] + consts.GetNonLoginTaskList)
if err != nil {
return nil, ecode.Fail.Sub("请求出现异常")
}

View File

@ -1,93 +0,0 @@
package tencent
import (
"bytes"
"context"
"encoding/json"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"golang.org/x/net/context/ctxhttp"
"io"
"net/http"
"server/internal/consts"
"server/internal/model"
"server/utility/ecode"
)
// GetNonLoginTaskList 获取下发到指定网吧的任务列表(未登录)
func GetNonLoginTaskList(ctx context.Context, in *model.GetNonLoginTaskListIn) (data interface{}, err error) {
// 请求参数
jsonStr, err := json.Marshal(in)
if err != nil {
return nil, ecode.Fail.Sub("参数序列化失败")
}
resp, err := ctxhttp.Post(ctx, http.DefaultClient, consts.TestAddr+"GetNonloginTaskList", "application/json", bytes.NewBuffer(jsonStr))
if err != nil {
return nil, ecode.Fail.Sub("请求失败")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, ecode.Fail.Sub("读取响应失败")
}
err = json.Unmarshal(body, &data)
if err != nil {
return nil, ecode.Fail.Sub("解析响应失败")
}
return data, err
}
// GetLoginTaskList 获取下发到指定网吧的任务列表(已登录)
func GetLoginTaskList(ctx context.Context, in *model.GetLoginTaskListIn) (data interface{}, err error) {
value, err := g.Redis().Get(ctx, fmt.Sprintf(consts.GameLifeUserKey, in.POpenId))
if value.IsEmpty() {
return nil, ecode.Fail.Sub("从redis获取值异常")
}
if err != nil {
return nil, ecode.Fail.Sub("从redis读取数据失败")
}
var cache model.UserGamelifeCache
err = json.Unmarshal(value.Bytes(), &cache)
if err != nil {
return nil, ecode.Fail.Sub("获取用户信息失败")
}
req := &model.GetTenCentLoginTaskListIn{
Gid: in.Gid,
NetBarAccount: in.NetBarAccount,
Num: 10,
Pageidx: "",
BrandId: "",
}
// 请求参数
jsonStr, err := json.Marshal(req)
if err != nil {
return nil, ecode.Fail.Sub("参数序列化失败")
}
resp, err := ctxhttp.Post(ctx, http.DefaultClient, consts.TestAddr+"GetTaskList"+"?"+cache.Params, "application/json", bytes.NewBuffer(jsonStr))
if err != nil {
return nil, ecode.Fail.Sub("请求失败")
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, ecode.Fail.Sub("解析响应体失败")
}
err = json.Unmarshal(body, &data)
if err != nil {
return nil, ecode.Fail.Sub("反序列化异常")
}
return data, err
}