English 中文(简体)
Managing Coupon Usage for Multiple Staff in E-commerce Project
原标题:

I m developing an e-commerce project where end users are companies, and the system utilizes coupons to boost sales. I need assistance with implementing the following coupon usage logic:

  1. Each company has multiple staff members.
  2. Each coupon can be applied to multiple companies.
  3. Only one staff member per company can use the coupon once.

Here s the desired flow of the coupon application process:

  1. On the initial screen, a staff member can input the coupon code and click the "Apply" button.
  2. Upon clicking "Apply", the system automatically redirects them to the transaction screen.
  3. On the transaction screen, the staff member has a limited time of 20 minutes to complete the transaction by clicking the "Submit" button. If they fail to do so, the transaction expires, and they are redirected back to the initial screen.

Additionally, I have the following business requirements:

  1. If a staff member (let s say Staff A) from a particular company uses the coupon, no other staff members from the same company should be able to use it temporarily.

  2. If Staff A applies the coupon, submits the transaction, and completes the process, no other staff members from the same company should be able to use the coupon anymore.

  3. If Staff A is on the transaction screen (coupon code applied and "Apply" button clicked), and they encounter any of the following situations:

    • Fail to complete the transaction within 20 minutes due to network errors, being AFK, etc.
    • Intentionally close the browser or current tab.
    • Intentionally click the logout button in the page header.
    • Any other method of leaving the page.

    => In such cases, other staff members from the same company should immediately regain the ability to use the coupon.

I have done all other logic implementation (authentication, authorization, coupon release, same company staff detected, price calculating,...) but still can not find out the best way how to handle the coupon usage as the business requirements.

Here are some solution that I can think of:

  • Option 1: Utilizing socket technology to continuously update the coupon usage status. However, setting this up seems time-consuming. Is there a more efficient alternative?
  • Option 2: Implementing periodic updates of the coupon usage status by calling an update usage status API at regular intervals (e.g., every 30 seconds). However, given that my system may have approximately 1000-2000 companies with numerous staff members, this solution may not be the most efficient.

The technologies used in my project include:

  • Front-end: ReactJS
  • Back-end: NestJS
  • Database: PostgreSQL

I would appreciate any guidance or suggestions on how to implement this coupon management functionality effectively. Thank you!

问题回答

暂无回答




相关问题
Automatic Sales Tax Tables

A client needs the ability for their shopping cart to automatically retrieve and keep up to date sales tax tables for at least the US, and preferably all countries with which the US has tax treaties. ...

ecommerce stock management with external payment gateway

this question is similar to this one but with a twist (so the answer accepted for the older question is not valid in the following scenario) i have a site for selling tickets (PHP/MYSQL). Suppose i ...

are automated recurring billings really automated?

"roll your own recurring billing in your rails app with a cron job, a date field for when they are paid through, and amount each person is paying" I just saw this entry here in SO and wonder if ...

ECommerce solution in php and ror [closed]

I m a developer but I never used php nor ruby on rails. I would like to create a small e-commerce website. I found out 2 solutions that seems very good, Prestahop and Spree. Which one would you ...

How to link username in site to PayPal information email?

It s not a problem but i don t know how to do this; let s say that I have a sign up form with some fields: username, password, email, as you know the user clicks on the BUY BUTTON and pay s up. Well, ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

热门标签