fix: set aofflimit only when offlimit
This commit is contained in:
parent
e16864d8d8
commit
65ea800a4c
@ -246,7 +246,7 @@ func (r *PromoCodeRepository) ActivatePromo(ctx context.Context, req *models.Act
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if promoCode.ActivationCount <= 0 && promoCode.DueTo > time.Now().Unix() {
|
if promoCode.ActivationCount <= 0 && promoCode.ActivationLimit > 0 {
|
||||||
if !promoCode.OffLimit {
|
if !promoCode.OffLimit {
|
||||||
update := bson.M{"$set": bson.M{"offLimit": true}}
|
update := bson.M{"$set": bson.M{"offLimit": true}}
|
||||||
_, err := r.mdb.UpdateOne(ctx, filter, update)
|
_, err := r.mdb.UpdateOne(ctx, filter, update)
|
||||||
@ -255,6 +255,15 @@ func (r *PromoCodeRepository) ActivatePromo(ctx context.Context, req *models.Act
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if promoCode.DueTo > 0 && promoCode.DueTo > time.Now().Unix() {
|
||||||
|
if !promoCode.OffLimit {
|
||||||
|
update := bson.M{"$set": bson.M{"outdated": true}}
|
||||||
|
_, err := r.mdb.UpdateOne(ctx, filter, update)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return &promoCode, nil
|
return &promoCode, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user