Skip to content

Commit

Permalink
#update: update store voucher
Browse files Browse the repository at this point in the history
  • Loading branch information
tdatIT committed Jun 24, 2024
1 parent 50e28fa commit 96bddad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/domain/dto/voucher_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type VoucherRequireResp struct {
}

type DiscountDataResp struct {
DiscountType int `json:"discount_type,omitempty"`
DiscountType int `json:"discount_type"`
ShippingValue uint `json:"shipping_value,omitempty"`
DiscountValue uint `json:"discount_value,omitempty"`
DiscountPercent float32 `json:"discount_percent,omitempty"`
Expand Down
5 changes: 4 additions & 1 deletion internal/services/voucherserv/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func (sh VoucherService) validateVoucherRequest(ctx context.Context, req *dto.Cr

if req.VoucherType == entities.STORE_DISCOUNT && !sh.validateStoreVoucherPolicy(ctx, req) {
return responses.ErrOutOfStorePolicy

}

if startTime.Before(currentTime) || endedTime.Before(currentTime) || startTime.After(endedTime) {
Expand Down Expand Up @@ -117,6 +116,10 @@ func (sh VoucherService) validateStoreVoucherPolicy(ctx context.Context, req *dt
return false
}

if req.DiscountData.DiscountType == entities.FREE_SHIP {
return false
}

if req.DiscountData.DiscountType == entities.FIXED_DISCOUNT &&
req.DiscountData.DiscountValue > entities.STORE_MAX_FIXED_VALUE_POLICY {
return false
Expand Down

0 comments on commit 96bddad

Please sign in to comment.