Backend Development 11 min read

Design and Architecture of a Prepaid Card Marketing System

The article outlines the design of a prepaid‑card marketing platform that uses configurable rule templates, condition‑behavior chains, and rule orders to manage membership recharge rewards and gift‑card usage limits, providing a generic core engine with adapters for merchants while supporting future migration to payment systems.

Youzan Coder
Youzan Coder
Youzan Coder
Design and Architecture of a Prepaid Card Marketing System

1. Introduction

Marketing refers to the various means of attracting consumer attention and encouraging the use of a product or service. In the prepaid card ecosystem, marketing is essential for helping merchants quickly recover funds, leading to the emergence of a marketing system within the prepaid card context.

2. Membership Recharge and Gift

Youzan's prepaid card offers a membership recharge product. After a user recharges a certain amount, the merchant grants benefits such as points, membership cards, or coupons. The process is divided into three stages:

Pre‑stage : Display the benefits corresponding to the recharge amount to improve user experience.

During : Validate the configured amount, generate a rule order, and lock the benefits to prevent merchant changes.

Post‑stage : Confirm the rule order and issue the locked benefits one by one.

The resulting model includes:

Rule (contains benefits and version history) – merchants can create and edit multiple rules, each with several benefits.

Rule Order (contains issuance records) – generated when a user recharges; after payment, issuance records are created asynchronously.

The basic execution flow: user, store, and recharge amount constitute the context; defined rules match and execute, producing either a display result or a rule order.

3. Recharge Limitations

As the volume of recharge transactions grows, merchants need additional controls such as timed rule activation, monthly member‑day benefits, or limited‑quantity offers. This introduces the concepts of conditions and behaviors :

Conditions are matched against the context (e.g., amount, time, rank).

Behaviors are actions taken when conditions are satisfied (e.g., benefit issuance, discount application).

Both conditions and behaviors are designed to be reusable across different business scenarios, and they can be processed using a responsibility‑chain pattern.

4. Gift Card Usage Scope

Gift cards are another Youzan prepaid product focused on holidays and social sharing. Merchants may restrict which goods or product groups a gift card can be used for. Unlike recharge rules, gift‑card rules are tied to the card’s lifecycle and act as a “carrier” for conditions.

Two configuration modes are provided: a whitelist and a blacklist. The relationship between conditions differs from recharge rules (OR logic vs. AND logic). To handle this, a rule template layer is added:

Rule template – defines how conditions are combined (using AND, OR, NOT) to trigger behaviors.

Rule – an instance of a template with concrete parameters.

Rule order – records each application of a rule.

Examples of template expressions:

Condition1 && (Condition2 || !Condition3) -> Action1 && Action2

Condition1 && (Condition2 || !Condition3) ? Action1 && Action2 : Action3 && Action4

For gift‑card limits, a template might be: ProductScope || ProductGroupScope -> Available . For recharge rules, a template could be: PaidAmount && TimeWindow && TopNLimit -> GrantCash && GrantCoupon && GrantGift .

5. Core Modules

The system’s core modules are illustrated below. The lower dashed area provides generic rule‑matching and execution capabilities, while the upper area offers business‑specific wrappers.

Although the marketing system exposes a generic configuration and workflow, it hides internal models from business consumers. A lightweight adapter layer translates external parameters into rule configurations and converts execution results into business‑friendly responses.

6. Afterword

The marketing system enhances merchant operational efficiency and supports a wide range of scenarios. Rule templates bring flexibility, allowing sub‑rules and mutual exclusion to address complex cases. Future articles will discuss migrating core modules to payment systems and the new challenges that arise.

rule-enginesoftware architecturebusiness-logicmarketing systemprepaid card
Youzan Coder
Written by

Youzan Coder

Official Youzan tech channel, delivering technical insights and occasional daily updates from the Youzan tech team.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.