Skip to content

充值(開發文檔)

最後更新:2026-04-10

📖 功能說明請參考 充值


架構

相關檔案

ViewController(3 個)
檔案說明
.../Recharge/C/RechargeViewController.swift充值主頁
.../Recharge/C/RechargeInfoViewController.swift充值確認頁
.../Recharge/C/RechargeInputInfoViewController.swift充值輸入確認頁

基礎路徑:BBSport/Tab/我的/Mine/

View(25 個)
檔案說明
.../V/Tab/RechargeTabView.swift支付方式 Tab
.../V/input/RechargeContentView.swift充值內容區
.../V/input/RechargeFastAmountView.swift快捷金額
.../V/input/RechargeView.swift充值主視圖
.../V/input/RechargeBottomView.swift充值底部
.../V/input/RechargeInputInfoView.swift充值輸入資訊
.../V/input/RechargeInputUserInfoView.swift充值用戶資訊輸入
.../V/input/RechargeAnnouncementView.swift充值公告
.../V/input/CoinRechargeCheckView.swift加密貨幣確認
.../V/input/CyptoInputView.swift加密貨幣輸入
.../V/input/NBPayWayView.swiftNB 支付方式
.../V/Info/RechargeInfoView.swift充值資訊
.../V/Info/RechargeC2CInfoView.swiftC2C 資訊
.../V/Info/RechargeActivityView.swift充值活動
.../V/Info/RechargeBottomCellView.swift充值底部 Cell
.../V/Info/RechargeTopView.swift充值頂部
.../V/Info/RechargeUsdtInfoTopView.swiftUSDT 資訊頂部
.../V/CustomerService/KefuRechargeView.swift客服充值
.../V/CustomerService/KefuRechargeTipView.swift客服充值提示
.../V/ChatView/RechargeChatView.swift客服聊天
.../V/Live/RechargeFloatingLiveView.swift浮動直播
.../V/Live/RechargeLiveView.swift直播
.../V/hud/RechargeBaseAlert.swift基底彈窗
.../V/hud/RechargeC2CUploadAlert.swiftC2C 上傳彈窗
.../V/hud/RechargeChangeAmountAlert.swift金額變更彈窗

基礎路徑:BBSport/Tab/我的/Mine/Recharge/

View — 其他(5 個)
檔案說明
.../V/hud/RechargeFailAlertView.swift充值失敗彈窗
.../V/hud/RechargeSystemAlert.swift系統彈窗
.../V/hud/STC2CPushBoardView.swiftC2C 推送面板
.../V/hud/SelectBankView.swift選擇銀行
.../V/Cell/BBBankCell.swift銀行 Cell

基礎路徑:BBSport/Tab/我的/Mine/Recharge/

Cell / ViewModel / Extension(4 個)
檔案說明
.../V/Cell/PaymentMethodCell.swift支付方式 Cell
.../V/ChatView/RechargeChatViewModel.swift聊天 ViewModel
.../C/RechargeViewController+BallView.swift浮動球擴展
.../M/UserDefault+Recharge.swiftUserDefaults 擴展

基礎路徑:BBSport/Tab/我的/Mine/Recharge/

Model(5 個)
檔案說明
.../M/PaymentMethodModel.swift支付方式
.../M/RechargeFastConfigModel.swift快捷充值配置
.../M/RechargeOperateModel.swift充值運營位
.../M/RecharegeStatusModel.swift充值狀態
.../M/RechargePaymentIdType.swift支付方式 ID 枚舉

基礎路徑:BBSport/Tab/我的/Mine/Recharge/

API Request(5 個)
檔案說明
BBSport/API/STAPI/Recharge/STAPI+ElasticAmountListRequest.swiftC2C 彈性金額
BBSport/API/STAPI/Recharge/STAPI+RechargeCodeRequest.swift充值代碼
BBSport/API/STAPI/Recharge/STAPI+RechargeFastListRequest.swift快捷充值列表
BBSport/API/STAPI/Recharge/STAPI+RechargeOperatePicRequest.swift運營位圖片
BBSport/API/STAPI/Recharge/STAPI+RechargeRateRequest.swift充值匯率

API

初始化充值


取得快捷充值金額列表

POST api/forehead/fund/recharge/fastAmount/list — urlForm — STAPI.RechargeFastListRequest

用途

載入充值頁快捷金額按鈕。

無參數,靠 Header token/uid 認證。

Response:

欄位型別說明
common[Int]普通快捷金額列表
large[Int]大額快捷金額列表
largeMerchantBool是否顯示大額充值
showMerchantBool是否讓用戶選擇通道

C2C 彈性快捷金額

POST api/forehead/fund/recharge/elasticAmount/list — urlForm — STAPI.ElasticAmountListRequest

用途

C2C 充值時取得可選金額。

無參數,靠 Header token/uid 認證。

Response:

欄位型別說明
list[Int]金額列表(元)
amountTags[String]金額標籤文字
elasticAmtExpireTimeCountInt過期時間計數

關鍵數字

C2C 彈性金額有過期時間限制(elasticAmtExpireTimeCount),過期後需重新請求。


取得充值支付方式列表

POST api/forehead/fund/recharge/payment/info — POST — HttpService

用途

載入充值頁所有可用支付方式。

無參數,靠 Header token/uid 認證。

Response:

欄位型別說明
normal[PaymentMethodModel]普通充值方式列表
large[PaymentMethodModel]大額充值方式列表
protocols4normal[PaymentProtocol]普通協議列表(如 TRC20/ERC20)
protocols4large[PaymentProtocol]大額協議列表
c2cBBMerchantModel?C2C 商戶資訊
c2cOpenStatusBoolC2C 是否開啟
c2cRechargeManualInputAmountSwitchIntC2C 是否開啟手動輸入金額
PaymentMethodModel 完整欄位
欄位型別說明
limitTypeInt限額類型(0=普通, 1=大額)
paymentIdInt(private)支付方式 ID,透過 paymentIdType 轉為 RechargePaymentIdType 枚舉
paymentNameString支付方式名稱
paymentLogoStringLogo 圖片路徑(透過 logoName 取得完整 URL)
protocolsSort[PaymentProtocol]該支付方式支援的協議排序
merchantList[BBMerchantModel]商戶列表(含金額範圍、快捷金額等)
tempBankTransferAppIdInt銀行轉帳臨時 AppId
tempC2CBankCardAppIdIntC2C 銀行卡臨時 AppId
currentAmountOptions[Int]當前可選金額列表

計算屬性:jisuAllFastAmounts(極速轉卡快捷金額)、commonFastAmounts(推薦快捷金額)、amountRange()(可用金額範圍)

BBMerchantModel 完整欄位
欄位型別說明
actualOrderInt實際排序
aisleNameString通道名稱
appIdInt商戶應用 ID
channelIdInt通道 ID
channelNameString通道名稱
merchantIdInt商戶 ID
bankList[BBRechargeBankModel]可用銀行列表(bankId, bankName)
nameList[String]姓名列表(NB 支付需要)
cardList[String]卡號列表(NB 支付需要)
quickAmount[Int]快捷金額選項
recommendAmount[Int]推薦金額選項
innerPayBool是否為內部支付(true=走 /do/transfer,false=走 /do/submit 第三方)
needCardNoBool是否需要輸入卡號
needNameBool是否需要輸入姓名
maxAmountDouble最大充值金額
minAmountDouble最小充值金額
protocolMap[String: String]加密貨幣協議映射(如 "TRC20": "提示文字")

提交充值


校驗充值金額

POST api/forehead/fund/recharge/amount — POST — HttpService

Request:

參數型別必填說明
merchantAppIdint商戶應用 ID
paymentIdint支付方式 ID
amountdouble充值金額

Response: 無 data,僅含 code 和 message。


提交充值訂單(第三方跳轉)

GET api/forehead/fund/recharge/do/submit — URL 拼接 — HttpService

Request:

參數型別必填說明
tokenstring用戶認證 token
paymentIdint支付方式 ID
merchantAppIdint商戶應用 ID
limitTypeint限額類型(0=普通, 1=大額)
amountdouble充值金額
bankCodestring銀行代碼(銀行轉帳時傳入)
uidstring用戶 ID
device-idstring設備 ID

Response: 回傳第三方支付頁面 URL,由 WebView 開啟,非標準 JSON 格式。


充值內部轉帳(內部支付)

POST api/forehead/fund/recharge/do/transfer — POST — HttpService

Request:

參數型別必填說明
paymentIdint支付方式 ID
amountdouble充值金額
merchantAppIdint商戶應用 ID
limitTypeint限額類型(0=普通, 1=大額)
appTypestringApp 類型
changePayTypebool是否切換支付方式
cardNostring銀行卡號(銀行轉帳)
namestring持卡人姓名(銀行轉帳)
bankIdint銀行 ID(銀行轉帳)
protocolstring加密貨幣協議(如 TRC20)
paymentTypeIdstring支付類型 ID

Response:充值狀態查詢


充值狀態追蹤


充值狀態查詢

POST api/forehead/fund/recharge/status — POST — HttpService

用途

訂單建立後每秒輪詢,追蹤充值進度。Socket 推送(type 407/401/433/435/437)也會即時更新。

無參數,靠 Header token/uid 認證。

Response:

Response 完整欄位(18 個)
欄位型別說明
onOffString是否驗證身份(0=不驗證, 1=驗證)
telephoneString綁定的電話號碼
bankCards[BankCards]綁定的銀行卡列表
bankInfoBankInfo?銀行收款資訊(卡號、戶名、附言、支行)
digitalInfoDigitalInfo?數字幣收款資訊(地址、匯率、協議)
showTypeString充值方式類型
amountDouble充值金額
orderIdString訂單號
paymentNameString支付方式名稱
statusInt訂單主狀態(0=待支付, 1=成功, 2=失敗, 3=補單審核中)
subStatusInt訂單子狀態(7=待確認到帳, 8=超時未確認等)
expiredTtlInt倒計時剩餘秒數
needUploadAttachmentBool是否需要上傳附件
alreadyUploadAttachmentBool是否已上傳附件
alreadyHastenBool是否已催單
hastenTTLInt催單倒計時
alertTimeInt極速轉卡訂單提醒時間
agentTypeInt充值方式(0=普通, 1=代客, 2=極速轉卡)

確認付款(普通充值)

POST api/forehead/fund/recharge/submit/confirm/payment — POST — HttpService

參數型別必填說明
orderIdstring充值訂單 ID
receiptFileIdstring收據檔案 ID
txDetailsFileIdstring交易詳情檔案 ID

Response: 無 data,僅含 code 和 message。


確認付款(C2C)

POST api/forehead/fund/c2c/submit/confirm/payment — POST — HttpService

Request: 同普通充值確認付款。

Response: 無 data,僅含 code 和 message。


催單(普通充值)

POST api/forehead/fund/recharge/submit/hasten — POST — HttpService

參數型別必填說明
orderIdstring充值訂單 ID
receiptFileIdstring收據檔案 ID
txDetailsFileIdstring交易詳情檔案 ID

Response: 無 data,僅含 code 和 message。


催單(C2C)

POST api/forehead/fund/c2c/submit/hasten — POST — HttpService

Request: 同普通充值催單。

Response: 無 data,僅含 code 和 message。


取消充值訂單

POST api/forehead/fund/recharge/cancel — POST — HttpService

參數型別必填說明
orderIdstring充值訂單 ID

Response: 無 data,僅含 code 和 message。


匯率與運營


取得 USDT 即時匯率

POST api/forehead/fund/recharge/rate — urlForm — STAPI.RechargeRateRequest

參數型別必填說明
coinstring幣種代碼(如 "USDT"

Response: dataDecimal,即時匯率。


USDT 匯率(HttpService)

POST api/forehead/fund/recharge/usdt/rate — POST — HttpService

無參數,靠 Header token/uid 認證。

Response: 原始 JSON Dictionary,含匯率數值。


取得充值運營位圖片

POST api/forehead/system/config/images/query — urlForm — STAPI.RechargeOperatePicRequest

參數型別必填說明
categoryIdstring圖片分類 ID,多個以逗號分隔

Response: data 為 JSON 字串,解析為 RechargeOperateModel 陣列,含 images(URL)、actionContent(跳轉連結)、categoryId


取得代理充值代碼

POST api/forehead/fund/agency/recharge/getCode — urlForm — STAPI.RechargeCodeRequest

無參數,靠 Header token/uid 認證。

Response: dataString?,代理充值代碼。


C2C 充值金額

POST api/forehead/fund/recharge/c2c/amount — POST — HttpService

無參數,靠 Header token/uid 認證。

Response: 原始 JSON Dictionary,含金額相關欄位。


清除充值姓名

POST api/forehead/fund/recharge/clear/name — POST — HttpService

無參數,靠 Header token/uid 認證。

Response: 無 data,僅含 code 和 message。


術語說明

術語說明
運營位後台可配置的廣告/活動圖片位,透過 categoryId 區分位置(如充值頁頂部 Banner),由 /system/config/images/query API 取得
NB(支付)一種需要用戶輸入姓名和卡號的轉帳支付方式,對應 needName=true / needCardNo=true 的商戶,View 為 NBPayWayView
極速轉卡agentType=2 的充值方式,訂單建立後有 alertTime 提醒倒計時,用戶需在限時內完成轉帳

實作重點

  • 金額匹配:固定金額類型從 quickAmount 比對;範圍金額類型遍歷 merchantList 找包含該金額的商戶
  • 快捷金額去重:透過 enumerated().filter 去除重複值並排序
  • 加密貨幣協議:USDT 支援 TRC20/ERC20 等,透過 protocolMap 存儲
  • 金額驗證:先檢查快捷選項,再檢查範圍
  • 直播嵌入:充值頁面可嵌入直播流

錯誤碼速查

錯誤碼處理
1成功
金額超出限額前端攔截,Toast 提示最小/最大限額
網路錯誤錯誤訊息提示
通道維護中後端返回 message,前端 Toast 顯示,該商戶暫時不可用
帳戶凍結後端返回 message,前端 Toast 顯示並阻止提交
重複提交已有進行中訂單時後端拒絕,前端跳轉至充值資訊頁顯示現有訂單
未綁定手機號前端攔截(onOff=="1"telephone 為空),彈窗引導綁定
未綁定銀行卡前端攔截(非隱私模式下 bankCards 為空),彈窗引導綁卡
三方創建訂單失敗第三方支付 URL 未返回,Toast 提示「三方创建订单失败」