feat: 迁移渠道激活列表和绑定期间流水
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package business
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"kra/internal/biz/business"
|
||||
"kra/internal/service/dto"
|
||||
)
|
||||
|
||||
type ActivationUsecase interface {
|
||||
List(context.Context, business.ActivationFilter, ...business.ListOption) (*business.ActivationPage, error)
|
||||
SpendDetail(context.Context, uint64) (*business.ActivationSpendDetail, error)
|
||||
}
|
||||
type ActivationService struct{ uc ActivationUsecase }
|
||||
|
||||
func NewActivationService(uc *business.ActivationUsecase) *ActivationService {
|
||||
return &ActivationService{uc: uc}
|
||||
}
|
||||
|
||||
func splitQueryValues(values []string) []string {
|
||||
result := []string{}
|
||||
seen := map[string]bool{}
|
||||
for _, value := range values {
|
||||
for _, part := range strings.Split(value, ",") {
|
||||
part = strings.TrimSpace(part)
|
||||
if part != "" && !seen[part] {
|
||||
result = append(result, part)
|
||||
seen[part] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (s *ActivationService) List(ctx context.Context, req *dto.ActivationQuery) (*dto.ActivationPage, error) {
|
||||
if req == nil {
|
||||
return nil, business.ErrActivationInput
|
||||
}
|
||||
page, size := req.Page, req.PageSize
|
||||
if page < 1 {
|
||||
page = 1
|
||||
}
|
||||
if size < 1 {
|
||||
size = 10
|
||||
}
|
||||
if size > 500 {
|
||||
size = 500
|
||||
}
|
||||
if page > int(^uint(0)>>1)/size {
|
||||
return nil, business.ErrActivationInput
|
||||
}
|
||||
filter := business.ActivationFilter{PlatformNames: splitQueryValues(req.PlatformNames), Statuses: splitQueryValues(req.Statuses), PromoteAccount: strings.TrimSpace(req.PromoteAccount), BusierAccount: strings.TrimSpace(req.BusierAccount)}
|
||||
result, err := s.uc.List(ctx, filter, business.ListOffset((page-1)*size), business.ListLimit(size))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := &dto.ActivationPage{Rows: []*dto.ActivationResponse{}, Total: result.Total, Available: result.Available}
|
||||
for _, r := range result.Rows {
|
||||
out.Rows = append(out.Rows, &dto.ActivationResponse{ID: r.ID, PromoteAccount: r.PromoteAccount, PlatformName: r.PlatformName, PlatformTitle: business.PlatformName(r.PlatformName), BusierAccount: r.BusierAccount, ApplicantOA: r.ApplicantOA, BindAt: localTime(r.BindAt), UnbindAt: localTime(r.UnbindAt), ReachAt: localTime(r.ReachAt), EndAt: localTime(r.EndAt()), AccumAmount: r.AccumAmount, Status: r.Status, StatusText: business.ActivationStatusLabel(r.Status)})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
func (s *ActivationService) SpendDetail(ctx context.Context, id uint64) (*dto.ActivationSpendDetail, error) {
|
||||
if id == 0 {
|
||||
return nil, business.ErrActivationNotFound
|
||||
}
|
||||
result, err := s.uc.SpendDetail(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
a := result.Activation
|
||||
out := &dto.ActivationSpendDetail{PromoteAccount: a.PromoteAccount, BindAt: localTime(a.BindAt), EndAt: localTime(a.EndAt()), List: []*dto.ActivationSpendItem{}, TotalAmount: result.TotalAmount}
|
||||
for _, item := range result.Items {
|
||||
out.List = append(out.List, &dto.ActivationSpendItem{PlatformTitle: business.PlatformName(a.PlatformName), GameName: item.GameName, TotalAmount: item.Amount})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package dto
|
||||
|
||||
type ActivationQuery struct {
|
||||
Page int `form:"pageNum"`
|
||||
PageSize int `form:"pageSize"`
|
||||
PlatformNames []string `form:"platformNames"`
|
||||
Statuses []string `form:"statuses"`
|
||||
PromoteAccount string `form:"promoteAccount"`
|
||||
BusierAccount string `form:"busierAccount"`
|
||||
}
|
||||
type ActivationResponse struct {
|
||||
ID uint64 `json:"id,string"`
|
||||
PromoteAccount string `json:"promoteAccount"`
|
||||
PlatformName string `json:"platformName"`
|
||||
PlatformTitle string `json:"platformTitle"`
|
||||
BusierAccount string `json:"busierAccount"`
|
||||
ApplicantOA string `json:"applicantOa"`
|
||||
BindAt *string `json:"bindAt"`
|
||||
UnbindAt *string `json:"unbindAt"`
|
||||
ReachAt *string `json:"reachAt"`
|
||||
EndAt *string `json:"endAt"`
|
||||
AccumAmount string `json:"accumAmount"`
|
||||
Status string `json:"status"`
|
||||
StatusText string `json:"statusText"`
|
||||
}
|
||||
type ActivationPage struct {
|
||||
Rows []*ActivationResponse `json:"rows"`
|
||||
Total int64 `json:"total"`
|
||||
Available bool `json:"available"`
|
||||
}
|
||||
type ActivationSpendItem struct {
|
||||
PlatformTitle string `json:"platformTitle"`
|
||||
GameName string `json:"gameName"`
|
||||
TotalAmount string `json:"totalAmount"`
|
||||
}
|
||||
type ActivationSpendDetail struct {
|
||||
PromoteAccount string `json:"promoteAccount"`
|
||||
BindAt *string `json:"bindAt"`
|
||||
EndAt *string `json:"endAt"`
|
||||
List []*ActivationSpendItem `json:"list"`
|
||||
TotalAmount string `json:"totalAmount"`
|
||||
}
|
||||
@@ -19,6 +19,7 @@ var ProviderSet = wire.NewSet(
|
||||
businessservice.NewBusinessPromoteService,
|
||||
businessservice.NewAlertRuleService,
|
||||
businessservice.NewAlertRecordService,
|
||||
businessservice.NewActivationService,
|
||||
systemservice.ProviderSet,
|
||||
paymentservice.ProviderSet,
|
||||
integrationservice.ProviderSet,
|
||||
|
||||
Reference in New Issue
Block a user