Skip to content

Commit

Permalink
Merge branch 'develop' into 'main'
Browse files Browse the repository at this point in the history
chore: Update is first payment

See merge request locker/api-core!388
  • Loading branch information
khaitranquang committed Feb 28, 2024
2 parents b26bbd3 + 29ee6fe commit 4ac721d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 2 additions & 1 deletion locker_server/api/v1_micro_service/mobile_payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def upgrade_plan(self, request, *args, **kwargs):

is_first_annual = self.payment_service.is_first_payment(user_id=user_id, **{
"plans": [PLAN_TYPE_PM_PREMIUM, PLAN_TYPE_PM_FAMILY],
"durations": [DURATION_YEARLY]
"durations": [DURATION_YEARLY],
"status": PAYMENT_STATUS_PAID
})
return Response(status=status.HTTP_200_OK, data={
"success": True,
Expand Down
3 changes: 2 additions & 1 deletion locker_server/api/v1_micro_service/payments/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ def webhook_create(self, request, *args, **kwargs):
user_id = new_payment.user.user_id
is_first_annual = self.payment_service.is_first_payment(user_id=user_id, **{
"plans": [PLAN_TYPE_PM_PREMIUM, PLAN_TYPE_PM_FAMILY],
"durations": [DURATION_YEARLY]
"durations": [DURATION_YEARLY],
"status": PAYMENT_STATUS_PAID
})
return Response(status=status.HTTP_200_OK, data={
"success": True,
Expand Down
9 changes: 6 additions & 3 deletions locker_server/api_orm/repositories/payment_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,15 @@ def count_referral_payments(self, referral_user_ids: List[int]) -> int:
def is_first_payment(self, user_id: int, **filter_params) -> bool:
exclude_total_0 = filter_params.get("exclude_total_0", True)
plans_param = filter_params.get("plans", [])
durations = filter_params.get("durations", [])
durations_param = filter_params.get("durations", [])
status_param = filter_params.get("status")
payments = PaymentORM.objects.filter(user_id=user_id)
if exclude_total_0 is True:
payments = payments.exclude(total_price=0)
if plans_param and durations:
payments = payments.filter(plan__in=plans_param, duration__in=durations)
if plans_param and durations_param:
payments = payments.filter(plan__in=plans_param, duration__in=durations_param)
if status_param:
payments = payments.filter(status=status_param)
# if plans_param:
# payments = payments.filter(plan__in=plans_param)
# if durations:
Expand Down

0 comments on commit 4ac721d

Please sign in to comment.