Coupon table: Type: discount coupon or price coupon Value: discount percentage or coupon amount Random string: It is the coupon code, randomly generate one
Generate coupon: 1. Insert coupon table A record 2. Give the coupon code of the coupon to the user
When the user submits an order: 1. There is an input box for entering the coupon code on the order submission interface 2. In the code of creating the order, judge whether the coupon Whether the code is empty, if it is empty, add the order process normally 3. If the coupon code is not empty, use the coupon code submitted by the user to query the coupon table, obtain the discount amount, and update the amount to be paid for the order. 4. After modifying the order amount, delete this record in the coupon table to prevent the reuse of a coupon. 5. Normal adding order process
Coupon table:
Type: discount coupon or price coupon
Value: discount percentage or coupon amount
Random string: It is the coupon code, randomly generate one
Generate coupon:
1. Insert coupon table A record
2. Give the coupon code of the coupon to the user
When the user submits an order:
1. There is an input box for entering the coupon code on the order submission interface
2. In the code of creating the order, judge whether the coupon Whether the code is empty, if it is empty, add the order process normally
3. If the coupon code is not empty, use the coupon code submitted by the user to query the coupon table, obtain the discount amount, and update the amount to be paid for the order.
4. After modifying the order amount, delete this record in the coupon table to prevent the reuse of a coupon.
5. Normal adding order process