add ServiceKey

This commit is contained in:
Pavel 2024-04-09 22:03:20 +03:00
parent 5846da07fc
commit 11d85ac864
4 changed files with 9 additions and 0 deletions

@ -491,6 +491,9 @@ components:
amount:
type: integer
description: Количество привилегии
serviceKey:
type: string
description: Тип сервиса
Discount:
type: object

@ -17,6 +17,7 @@ type PromoCode struct {
Privilege struct {
PrivilegeID string `json:"privilegeID" bson:"privilegeID"` // айдишник привилегии, которая будет выдаваться
Amount uint64 `json:"amount" bson:"amount"` // количество
ServiceKey string `json:"serviceKey" bson:"serviceKey"` // тип сервиса
} `json:"privilege" bson:"privilege"`
Discount struct {
Layer uint32 `json:"layer" bson:"layer"` // 1|2
@ -47,6 +48,7 @@ type ReqEditPromoCode struct {
Privilege *struct {
PrivilegeID string `json:"privilegeID,omitempty" bson:"privilegeID"`
Amount uint64 `json:"amount,omitempty" bson:"amount"`
ServiceKey string `json:"serviceKey,omitempty" bson:"serviceKey"` // тип сервиса
} `json:"privilege,omitempty" bson:"privilege"`
Discount *struct {

@ -110,6 +110,9 @@ func (r *PromoCodeRepository) EditPromoCode(ctx context.Context, req *models.Req
if req.Bonus.Privilege.Amount != 0 {
updateFields["bonus.privilege.amount"] = req.Bonus.Privilege.Amount
}
if req.Bonus.Privilege.ServiceKey != "" {
updateFields["bonus.privilege.serviceKey"] = req.Bonus.Privilege.ServiceKey
}
}
if req.Bonus.Discount != nil {
if req.Bonus.Discount.Layer != 0 {

@ -142,6 +142,7 @@ func (s *PromoCodeService) ActivatePromo(ctx context.Context, req *models.Activa
privilege := models.Privilege{
PrivilegeID: promoCode.Bonus.Privilege.PrivilegeID,
Amount: promoCode.Bonus.Privilege.Amount,
ServiceKey: promoCode.Bonus.Privilege.ServiceKey,
}
privileges = append(privileges, privilege)