up: Redemption Code
This commit is contained in:
@@ -100,6 +100,7 @@ func (l *CreateRedemptionCodeLogic) CreateRedemptionCode(req *types.CreateRedemp
|
||||
SubscribePlan: req.SubscribePlan,
|
||||
UnitTime: req.UnitTime,
|
||||
Quantity: req.Quantity,
|
||||
Status: 1, // Default to enabled
|
||||
}
|
||||
|
||||
err = l.svcCtx.RedemptionCodeModel.Insert(l.ctx, redemptionCode)
|
||||
|
||||
@@ -49,6 +49,7 @@ func (l *GetRedemptionCodeListLogic) GetRedemptionCodeList(req *types.GetRedempt
|
||||
SubscribePlan: item.SubscribePlan,
|
||||
UnitTime: item.UnitTime,
|
||||
Quantity: item.Quantity,
|
||||
Status: item.Status,
|
||||
CreatedAt: item.CreatedAt.Unix(),
|
||||
UpdatedAt: item.UpdatedAt.Unix(),
|
||||
})
|
||||
|
||||
@@ -54,6 +54,14 @@ func (l *RedeemCodeLogic) RedeemCode(req *types.RedeemCodeRequest) (resp *types.
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "find redemption code error: %v", err.Error())
|
||||
}
|
||||
|
||||
// Check if redemption code is enabled
|
||||
if redemptionCode.Status != 1 {
|
||||
l.Errorw("[RedeemCode] Redemption code is disabled",
|
||||
logger.Field("code", req.Code),
|
||||
logger.Field("status", redemptionCode.Status))
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.InvalidParams), "redemption code is disabled")
|
||||
}
|
||||
|
||||
// Check if redemption code has remaining count
|
||||
if redemptionCode.TotalCount > 0 && redemptionCode.UsedCount >= redemptionCode.TotalCount {
|
||||
l.Errorw("[RedeemCode] Redemption code has been fully used",
|
||||
|
||||
Reference in New Issue
Block a user