Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:A616567126 GPT WEB JAVA CardPinServiceImpl

From Leeroopedia
Knowledge Sources
Domains Payments, Billing
Last Updated 2026-10-13 00:00 GMT

Overview

Concrete tool for generating, managing, and redeeming prepaid card keys (vouchers) that carry platform credit values, provided by the Spring framework.

Description

The CardPinServiceImpl class implements the ICardPinService interface. Key methods:

  • add(CardPinAddReq) — Generates a batch of random card pins with a specified credit value using PasswordUtil.getRandomPassword()
  • add(Integer number) — Generates a single card pin (used by WeChat Pay callback for auto-generation)
  • getAllCardPin() — Returns all unused card pins
  • checkUseBatchCardPin(userId, cardPin) — Checks if a user already redeemed a pin in the same batch (prevents double-redemption)

Card pins are persisted in the CardPin table with state (0=unused, 1=used), userId, and number (credit value).

Usage

Import this service when you need to:

  • Generate card pin batches for distribution
  • Auto-generate a card pin on WeChat Pay success
  • Query unused card pins
  • Check batch redemption duplication

Code Reference

Source Location

  • Repository: GPT-WEB-JAVA
  • File: src/main/java/com/intelligent/bot/service/sys/impl/CardPinServiceImpl.java

Signature

@Service("CardPinService")
public class CardPinServiceImpl extends ServiceImpl<CardPinDao, CardPin> implements ICardPinService {
    public B<Void> add(CardPinAddReq req);
    public String add(Integer number);
    public B<List<String>> getAllCardPin();
    public int checkUseBatchCardPin(Long userId, String cardPin);
}

Import

import com.intelligent.bot.service.sys.ICardPinService;

I/O Contract

Inputs

Name Type Required Description
req CardPinAddReq Yes (batch) batch (count), number (credit value)
number Integer Yes (single) Credit value for the card pin

Outputs

Name Type Description
add (batch) returns B<Void> Batch saved to DB
add (single) returns String The generated card pin string

Usage Examples

Auto-Generating a Card Pin on WeChat Pay

// In OrderServiceImpl.wxCallBack()
Integer number = 100;  // 100 credits for ¥5
if (order.getTradeNo().equals("2")) number = 220;  // ¥10
if (order.getTradeNo().equals("3")) number = 1500; // ¥50
String cardPin = cardPinService.add(number);
// cardPin sent to user via WeChat kefu message

Batch Generation (Admin)

// Admin generates 100 card pins, each worth 50 credits
CardPinAddReq req = new CardPinAddReq();
req.setBatch(100);
req.setNumber(50);
cardPinService.add(req);

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment