package dao import ( "youngee_b_api/app/entity" ) type SelectionTaskInfoDao struct{} func (s SelectionTaskInfoDao) CountBySelectionId(selectionId string) (int64, error) { var count int64 err := Db.Model(&entity.SelectionTaskInfo{}).Where("selection_id = ?", selectionId).Count(&count).Error return count, err } // 获取带货子任务中指定悬赏阶段的数据 func (s SelectionTaskInfoDao) GetRewardDetailByRewardStage(selectionId string, rewardStage int64, order int64, page int, pageSize int) ([]*entity.SelectionTaskInfo, int64, error) { selectionTaskInfos := []*entity.SelectionTaskInfo{} var total int64 query := Db.Debug().Model(&entity.SelectionTaskInfo{}).Where("selection_id = ? AND reward_stage = ?", selectionId, rewardStage) query.Count(&total) query = query.Select("talent_id, sale_actual, withdraw_date") offset := (page - 1) * pageSize var err error if order == 1 { err = query.Order("withdraw_date asc").Offset(offset).Limit(pageSize).Find(&selectionTaskInfos).Error } else { err = query.Order("withdraw_date desc").Offset(offset).Limit(pageSize).Find(&selectionTaskInfos).Error } if err != nil { return nil, 0, err } return selectionTaskInfos, total, nil }