二次确认接口增加一些信息
This commit is contained in:
parent
b494aef6b8
commit
ad06ad0a65
10
docs/api.md
10
docs/api.md
@ -60,7 +60,15 @@ var sign = HmacSHA256(signStr, secretKey)
|
||||
// 3, // 已支付
|
||||
// 9 // 成功
|
||||
// 99, // 交易失败
|
||||
"id": "64b783f19cc05a67d33b4487" // 本地订单流水号
|
||||
"id": "64b783f19cc05a67d33b4487", // 本地订单流水号
|
||||
"fiat": "USD", // 法币名称
|
||||
"fiat_amount": "1.49", // 法币金额
|
||||
"country": "US", // ISO 3166-1 二位字母国家code
|
||||
"payway_code": "10001", // 支付方式代码
|
||||
"crypto": "CEG", // 购买的crypto名称
|
||||
"network": "ARBITRUM", // 购买的网络名称
|
||||
"crypto_amount": "7.6", // 实际支付的crypto数量
|
||||
"address": "0x123456...def", //实际转账地址
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -15,15 +15,11 @@ class AlchemyController extends BaseController {
|
||||
const user = req.user
|
||||
const { network, crypto, address, fiat, fiatAmount, payWayCode, country, accountId, orderId, env } = req.params
|
||||
let envStr = env || 'dev'
|
||||
if (fiat || fiatAmount || country) {
|
||||
if (!fiat || !fiatAmount || !country || !payWayCode) {
|
||||
throw new ZError(11, 'fiat, fiatAmount payWayCode and country must be provided')
|
||||
}
|
||||
if (!fiat || !fiatAmount || !country || !payWayCode) {
|
||||
throw new ZError(11, 'fiat, fiatAmount payWayCode and country must be provided')
|
||||
}
|
||||
if (network || crypto) {
|
||||
if (!network || !crypto) {
|
||||
throw new ZError(12, 'network and crypto must be provided')
|
||||
}
|
||||
if (!network || !crypto) {
|
||||
throw new ZError(12, 'network and crypto must be provided')
|
||||
}
|
||||
const tokenResult = await refreshToken(user.emailReal || user.email)
|
||||
if (!tokenResult.success || tokenResult.returnCode !== '0000') {
|
||||
@ -61,10 +57,11 @@ class AlchemyController extends BaseController {
|
||||
gameAccountId: accountId,
|
||||
gameOrderId: orderId,
|
||||
cryptoAmountEstimate: amountEstimate,
|
||||
fiat,
|
||||
fiatAmount,
|
||||
country,
|
||||
payWayCode,
|
||||
})
|
||||
if (fiat) record.fiat = fiat
|
||||
if (fiatAmount) record.fiatAmount = fiatAmount
|
||||
if (country) record.country = country
|
||||
await record.save()
|
||||
let payData: any = {
|
||||
side: 'BUY',
|
||||
|
@ -2,16 +2,14 @@ import logger from 'logger/logger'
|
||||
import BaseController, { ROLE_ANON } from 'common/base.controller'
|
||||
import { ZError } from 'common/ZError'
|
||||
import { role, router } from 'decorators/router'
|
||||
import { calcNetworkFee, checkPayResultSign, checkSha1Sign, checkSimpleSign } from 'service/alchemy.svr'
|
||||
import { calcNetworkFee, checkPayResultSign, checkSha1Sign } from 'service/alchemy.svr'
|
||||
import { PayRecord, PayStatus } from 'modules/PayRecord'
|
||||
import { TransferQueue } from 'queue/transfer.queue'
|
||||
import { TransferRecord } from 'modules/TransferRecord'
|
||||
import { reportPayResult } from 'service/game.svr'
|
||||
import { PriceSvr } from 'service/price.svr'
|
||||
import { OrderCacheSvr } from 'service/ordercache.svr'
|
||||
import { GasSvr } from 'service/gas.svr'
|
||||
import { parse } from 'dotenv'
|
||||
import { toBigInt, toWei, fromWei, EtherUnits, toBigWei } from 'utils/number.util'
|
||||
import { fromWei, toBigWei } from 'utils/number.util'
|
||||
|
||||
let errorRes = function (msg: string) {
|
||||
logger.info(`error res: ${msg}`)
|
||||
|
@ -109,7 +109,7 @@ export default class InternalController extends BaseController {
|
||||
if (!record) {
|
||||
throw new ZError(13, 'PayRecord not found')
|
||||
}
|
||||
const repData = assembleGameData(record)
|
||||
const repData = assembleGameData(record, false)
|
||||
return repData
|
||||
}
|
||||
}
|
||||
|
@ -78,6 +78,8 @@ export class PayRecordClass extends BaseModule {
|
||||
// 国家
|
||||
@prop()
|
||||
public country?: string
|
||||
@prop()
|
||||
public payWayCode?: string
|
||||
// 交易状态
|
||||
@prop({ required: true, default: PayStatus.PENDING })
|
||||
public status: PayStatus
|
||||
|
@ -12,13 +12,30 @@ export interface IPayResult {
|
||||
status: number
|
||||
}
|
||||
|
||||
export function assembleGameData(data: DocumentType<PayRecordClass>) {
|
||||
export function assembleGameData(data: DocumentType<PayRecordClass>, mini = true) {
|
||||
if (mini) {
|
||||
return {
|
||||
account_id: data.gameAccountId,
|
||||
order_id: data.gameOrderId,
|
||||
status: data.status,
|
||||
id: data.id,
|
||||
txhash: data.txHash || '',
|
||||
}
|
||||
}
|
||||
return {
|
||||
account_id: data.gameAccountId,
|
||||
order_id: data.gameOrderId,
|
||||
status: data.status,
|
||||
id: data.id,
|
||||
txhash: data.txHash,
|
||||
txhash: data.txHash || '',
|
||||
fiat: data.fiat,
|
||||
fiat_amount: data.fiatAmount,
|
||||
country: data.country,
|
||||
payway_code: data.payWayCode || '10001',
|
||||
crypto: data.crypto,
|
||||
network: data.network,
|
||||
crypto_amount: data.cryptoSend || data.cryptoAmountEstimate,
|
||||
address: data.address,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user