2024-01-11 16:29:53 +00:00
|
|
|
|
package models
|
|
|
|
|
|
2024-01-11 18:20:33 +00:00
|
|
|
|
import (
|
|
|
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
2024-01-11 16:29:53 +00:00
|
|
|
|
|
|
|
|
|
type PromoCode struct {
|
2024-01-11 18:20:33 +00:00
|
|
|
|
ID primitive.ObjectID `json:"id" bson:"_id"`
|
|
|
|
|
Codeword string `json:"codeword" bson:"codeword"` // то, что будет вводить пользователь, чтобы получить плюшки
|
|
|
|
|
Description string `json:"description" bson:"description"` // описание, необходимое менеджеру в админке
|
|
|
|
|
Greetings string `json:"greetings" bson:"greetings"` // текст, выдаваемый пользователю в ответ на активацию промокода
|
|
|
|
|
DueTo int64 `json:"dueTo" bson:"dueTo"` // таймштамп времени окончания работы активации промокода
|
|
|
|
|
ActivationCount int64 `json:"activationCount" bson:"activationCount"` // предел количества активаций промокода
|
2024-04-08 17:42:04 +00:00
|
|
|
|
ActivationLimit int64 `json:"activationLimit" bson:"activationLimit"` // лимит если 0 то без лимита
|
2024-01-11 16:29:53 +00:00
|
|
|
|
Bonus struct {
|
|
|
|
|
Privilege struct {
|
2024-01-11 18:20:33 +00:00
|
|
|
|
PrivilegeID string `json:"privilegeID" bson:"privilegeID"` // айдишник привилегии, которая будет выдаваться
|
|
|
|
|
Amount uint64 `json:"amount" bson:"amount"` // количество
|
2024-04-09 19:03:20 +00:00
|
|
|
|
ServiceKey string `json:"serviceKey" bson:"serviceKey"` // тип сервиса
|
2024-01-11 18:20:33 +00:00
|
|
|
|
} `json:"privilege" bson:"privilege"`
|
2024-01-11 16:29:53 +00:00
|
|
|
|
Discount struct {
|
2024-01-17 18:50:50 +00:00
|
|
|
|
Layer uint32 `json:"layer" bson:"layer"` // 1|2
|
2024-01-11 18:20:33 +00:00
|
|
|
|
Factor float64 `json:"factor" bson:"factor"` // процент скидки, вернее множитель, при котором достигается этот процент скидки
|
|
|
|
|
Target string `json:"target" bson:"target"` // PrivilegeID или ServiceKey в зависимости от слоя
|
|
|
|
|
Threshold int64 `json:"threshold" bson:"threshold"` // граничное значение, при пересечении которого применяется эта скидка
|
|
|
|
|
} `json:"discount" bson:"discount"`
|
|
|
|
|
} `json:"bonus" bson:"bonus"`
|
|
|
|
|
Outdated bool `json:"outdated" bson:"outdated"`
|
|
|
|
|
OffLimit bool `json:"offLimit" bson:"offLimit"`
|
|
|
|
|
Delete bool `json:"delete" bson:"delete"`
|
|
|
|
|
CreatedAt time.Time `json:"createdAt" bson:"createdAt"`
|
2024-01-14 14:18:36 +00:00
|
|
|
|
FastLinks []string `json:"fastLinks" bson:"fastLinks"`
|
2024-01-11 16:29:53 +00:00
|
|
|
|
}
|
2024-01-11 19:47:54 +00:00
|
|
|
|
|
|
|
|
|
type ReqEditPromoCode struct {
|
2024-02-22 09:18:24 +00:00
|
|
|
|
ID string `json:"id" bson:"_id"` // айдишник промокода, который обновляем
|
2024-01-12 09:42:56 +00:00
|
|
|
|
Description *string `json:"description,omitempty" bson:"description"` // описание, необходимое менеджеру в админке
|
|
|
|
|
Greetings *string `json:"greetings,omitempty" bson:"greetings"` // текст, выдаваемый пользователю в ответ на активацию промокода
|
2024-01-11 19:47:54 +00:00
|
|
|
|
|
2024-01-12 09:42:56 +00:00
|
|
|
|
DueTo *int64 `json:"dueTo,omitempty" bson:"dueTo"` // таймштамп времени окончания работы активации промокода
|
|
|
|
|
ActivationCount *int64 `json:"activationCount,omitempty" bson:"activationCount"` // предел количества активаций промокода
|
2024-04-08 17:42:04 +00:00
|
|
|
|
ActivationLimit *int64 `json:"activationLimit,omitempty" bson:"activationLimit"` // лимит если 0 то без лимита
|
2024-01-11 19:47:54 +00:00
|
|
|
|
|
2024-01-12 09:42:56 +00:00
|
|
|
|
Delete *bool `json:"delete,omitempty" bson:"delete"`
|
2024-02-22 09:18:24 +00:00
|
|
|
|
|
|
|
|
|
Bonus *struct {
|
|
|
|
|
Privilege *struct {
|
|
|
|
|
PrivilegeID string `json:"privilegeID,omitempty" bson:"privilegeID"`
|
|
|
|
|
Amount uint64 `json:"amount,omitempty" bson:"amount"`
|
2024-04-09 19:03:20 +00:00
|
|
|
|
ServiceKey string `json:"serviceKey,omitempty" bson:"serviceKey"` // тип сервиса
|
2024-02-22 09:18:24 +00:00
|
|
|
|
} `json:"privilege,omitempty" bson:"privilege"`
|
|
|
|
|
|
|
|
|
|
Discount *struct {
|
|
|
|
|
Layer int `json:"layer,omitempty" bson:"layer"`
|
|
|
|
|
Factor float64 `json:"factor,omitempty" bson:"factor"`
|
|
|
|
|
Target string `json:"target,omitempty" bson:"target"`
|
|
|
|
|
Threshold int64 `json:"threshold,omitempty" bson:"threshold"`
|
|
|
|
|
} `json:"discount,omitempty" bson:"discount"`
|
|
|
|
|
} `json:"bonus,omitempty" bson:"bonus"`
|
2024-01-11 19:47:54 +00:00
|
|
|
|
}
|
2024-01-12 11:28:22 +00:00
|
|
|
|
|
|
|
|
|
type GetPromoCodesListReqFilter struct {
|
|
|
|
|
Text string `json:"text"` // полнотекстовый поиск пo Codeword, Decription, Greetings полям
|
|
|
|
|
Active bool `json:"active"` // если true, то выбирать deleted==false && outdated== false && offlimit == false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GetPromoCodesListReq struct {
|
|
|
|
|
Page int `json:"page"` //номер страницы выборки. начинается с 0. по сути, skip для выборки из mongodb
|
|
|
|
|
Limit int `json:"limit"` //размер страницы выборки. больше 10, меньше 250. отвечает за skip = page*limit, и за limit
|
|
|
|
|
Filter GetPromoCodesListReqFilter `json:"filter"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GetPromoCodesListResp struct {
|
|
|
|
|
Count int64 `json:"count"` // количество в выборке всего
|
|
|
|
|
Items []PromoCode `json:"items"` // "страница" промокодов
|
|
|
|
|
}
|
2024-01-12 13:46:36 +00:00
|
|
|
|
|
|
|
|
|
type ActivateReq struct {
|
|
|
|
|
Codeword string `json:"codeword"`
|
2024-01-14 14:18:36 +00:00
|
|
|
|
FastLink string `json:"fastLink"`
|
2024-01-12 13:46:36 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ActivateResp struct {
|
|
|
|
|
Greetings string `json:"greetings"` // поле из активированного промокода
|
|
|
|
|
}
|
2024-01-27 12:51:32 +00:00
|
|
|
|
|
2024-03-27 12:29:49 +00:00
|
|
|
|
type PromoStatReq struct {
|
|
|
|
|
PromoCodeID string `json:"id,omitempty"`
|
|
|
|
|
From uint64 `json:"from"`
|
|
|
|
|
To uint64 `json:"to"`
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-27 12:51:32 +00:00
|
|
|
|
type PromoCodeStats struct {
|
2024-03-27 12:29:49 +00:00
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
|
UsageMap map[string][]Usage `json:"usageMap"`
|
2024-03-03 18:24:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Usage struct {
|
2024-03-27 12:29:49 +00:00
|
|
|
|
UserID string `bson:"userID" json:"userID"`
|
|
|
|
|
Time uint64 `bson:"time" json:"time"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PromoCodeStatsResp struct {
|
|
|
|
|
ID string `json:"id,omitempty"`
|
|
|
|
|
UsageCount int `json:"usageCount"`
|
|
|
|
|
UsageMap map[string]int `json:"usageMap"`
|
2024-01-27 12:51:32 +00:00
|
|
|
|
}
|