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 OrderServiceImpl

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

Overview

Concrete tool for processing credit purchases through YiPay and WeChat Pay v3 gateways, including order creation, callback verification, card key redemption, and credit top-up, provided by the Spring framework.

Description

The OrderServiceImpl class implements the IOrderService interface and handles the full payment lifecycle:

  • YiPay: createYiOrder() creates an order with MD5-signed parameters; yiCallBack() verifies PID and amount; yiReturnUrl() queries YiPay API on user return
  • WeChat Pay v3: wxCallBack() decrypts AES/GCM ciphertext, verifies payment, generates card pin, sends via WeChat kefu
  • Card Pin: cardPin() redeems card keys with batch duplication check
  • Credit Top-up: okOrder() increases user credits and decreases product stock on successful payment

Usage

Import this service when you need to:

  • Create payment orders for YiPay or WeChat Pay
  • Handle payment gateway callbacks with signature/encryption verification
  • Redeem card keys for credit top-up

Code Reference

Source Location

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

Signature

@Service("orderService")
@Transactional(rollbackFor = Exception.class)
public class OrderServiceImpl extends ServiceImpl<OrderDao, Order> implements IOrderService {
    public synchronized B<CreateOrderRes> createYiOrder(CreateYiOrderReq req);
    public String yiCallBack(OrderYiCallBackReq req);
    public NativeCallBackRes wxCallBack(HttpServletRequest request, HttpServletResponse response) throws Exception;
    public B<Void> yiReturnUrl(OrderYiReturnReq req);
    public B<Void> cardPin(CreatePinOrderReq req);
    public static String createSign(CreateOrderRes res);
    private void okOrder(Order order);
}

Import

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

I/O Contract

Inputs

Name Type Required Description
req (createYiOrder) CreateYiOrderReq Yes productId, payNumber, payType
req (yiCallBack) OrderYiCallBackReq Yes out_trade_no, trade_no, money, pid, trade_status
request (wxCallBack) HttpServletRequest Yes POST with encrypted resource (ciphertext, nonce, associated_data)
req (cardPin) CreatePinOrderReq Yes cardPin string

Outputs

Name Type Description
createYiOrder returns B<CreateOrderRes> Signed payment params for gateway redirect
yiCallBack returns String "success" acknowledgment
wxCallBack returns NativeCallBackRes Empty response (kefu message sent separately)
cardPin returns B<Void> Success or "无效卡密" error

Usage Examples

YiPay Order Creation

B<CreateOrderRes> res = orderService.createYiOrder(req);
// res contains: outTradeNo, pid, money, name, url, notifyUrl, returnUrl, type, sign
// Client redirects to res.url with these params

WeChat Pay Callback Decryption

// wxCallBack decrypts the encrypted resource:
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
cipher.init(2, new SecretKeySpec(key.getBytes(), "AES"), new GCMParameterSpec(128, nonce.getBytes()));
JSONObject ciphertext = JSONObject.parseObject(new String(cipher.doFinal(decode)));
String tradeState = ciphertext.getString("trade_state");
// On SUCCESS: generates card pin, sends kefu message, updates order

Card Pin Redemption

orderService.cardPin(new CreatePinOrderReq("ABC1234"));
// 1. Check batch duplication via checkUseBatchCardPin()
// 2. Look up card pin in DB
// 3. If valid: increment user.remaining_times, mark card as used
// 4. If invalid: return error

Related Pages

Implements Principle

Requires Environment

Page Connections

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