二次确认接口增加一些信息
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, // 已支付
|
// 3, // 已支付
|
||||||
// 9 // 成功
|
// 9 // 成功
|
||||||
// 99, // 交易失败
|
// 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 user = req.user
|
||||||
const { network, crypto, address, fiat, fiatAmount, payWayCode, country, accountId, orderId, env } = req.params
|
const { network, crypto, address, fiat, fiatAmount, payWayCode, country, accountId, orderId, env } = req.params
|
||||||
let envStr = env || 'dev'
|
let envStr = env || 'dev'
|
||||||
if (fiat || fiatAmount || country) {
|
if (!fiat || !fiatAmount || !country || !payWayCode) {
|
||||||
if (!fiat || !fiatAmount || !country || !payWayCode) {
|
throw new ZError(11, 'fiat, fiatAmount payWayCode and country must be provided')
|
||||||
throw new ZError(11, 'fiat, fiatAmount payWayCode and country must be provided')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (network || crypto) {
|
if (!network || !crypto) {
|
||||||
if (!network || !crypto) {
|
throw new ZError(12, 'network and crypto must be provided')
|
||||||
throw new ZError(12, 'network and crypto must be provided')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
const tokenResult = await refreshToken(user.emailReal || user.email)
|
const tokenResult = await refreshToken(user.emailReal || user.email)
|
||||||
if (!tokenResult.success || tokenResult.returnCode !== '0000') {
|
if (!tokenResult.success || tokenResult.returnCode !== '0000') {
|
||||||
@ -61,10 +57,11 @@ class AlchemyController extends BaseController {
|
|||||||
gameAccountId: accountId,
|
gameAccountId: accountId,
|
||||||
gameOrderId: orderId,
|
gameOrderId: orderId,
|
||||||
cryptoAmountEstimate: amountEstimate,
|
cryptoAmountEstimate: amountEstimate,
|
||||||
|
fiat,
|
||||||
|
fiatAmount,
|
||||||
|
country,
|
||||||
|
payWayCode,
|
||||||
})
|
})
|
||||||
if (fiat) record.fiat = fiat
|
|
||||||
if (fiatAmount) record.fiatAmount = fiatAmount
|
|
||||||
if (country) record.country = country
|
|
||||||
await record.save()
|
await record.save()
|
||||||
let payData: any = {
|
let payData: any = {
|
||||||
side: 'BUY',
|
side: 'BUY',
|
||||||
|
@ -2,16 +2,14 @@ import logger from 'logger/logger'
|
|||||||
import BaseController, { ROLE_ANON } from 'common/base.controller'
|
import BaseController, { ROLE_ANON } from 'common/base.controller'
|
||||||
import { ZError } from 'common/ZError'
|
import { ZError } from 'common/ZError'
|
||||||
import { role, router } from 'decorators/router'
|
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 { PayRecord, PayStatus } from 'modules/PayRecord'
|
||||||
import { TransferQueue } from 'queue/transfer.queue'
|
import { TransferQueue } from 'queue/transfer.queue'
|
||||||
import { TransferRecord } from 'modules/TransferRecord'
|
import { TransferRecord } from 'modules/TransferRecord'
|
||||||
import { reportPayResult } from 'service/game.svr'
|
import { reportPayResult } from 'service/game.svr'
|
||||||
import { PriceSvr } from 'service/price.svr'
|
import { PriceSvr } from 'service/price.svr'
|
||||||
import { OrderCacheSvr } from 'service/ordercache.svr'
|
import { OrderCacheSvr } from 'service/ordercache.svr'
|
||||||
import { GasSvr } from 'service/gas.svr'
|
import { fromWei, toBigWei } from 'utils/number.util'
|
||||||
import { parse } from 'dotenv'
|
|
||||||
import { toBigInt, toWei, fromWei, EtherUnits, toBigWei } from 'utils/number.util'
|
|
||||||
|
|
||||||
let errorRes = function (msg: string) {
|
let errorRes = function (msg: string) {
|
||||||
logger.info(`error res: ${msg}`)
|
logger.info(`error res: ${msg}`)
|
||||||
|
@ -109,7 +109,7 @@ export default class InternalController extends BaseController {
|
|||||||
if (!record) {
|
if (!record) {
|
||||||
throw new ZError(13, 'PayRecord not found')
|
throw new ZError(13, 'PayRecord not found')
|
||||||
}
|
}
|
||||||
const repData = assembleGameData(record)
|
const repData = assembleGameData(record, false)
|
||||||
return repData
|
return repData
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,8 @@ export class PayRecordClass extends BaseModule {
|
|||||||
// 国家
|
// 国家
|
||||||
@prop()
|
@prop()
|
||||||
public country?: string
|
public country?: string
|
||||||
|
@prop()
|
||||||
|
public payWayCode?: string
|
||||||
// 交易状态
|
// 交易状态
|
||||||
@prop({ required: true, default: PayStatus.PENDING })
|
@prop({ required: true, default: PayStatus.PENDING })
|
||||||
public status: PayStatus
|
public status: PayStatus
|
||||||
|
@ -12,13 +12,30 @@ export interface IPayResult {
|
|||||||
status: number
|
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 {
|
return {
|
||||||
account_id: data.gameAccountId,
|
account_id: data.gameAccountId,
|
||||||
order_id: data.gameOrderId,
|
order_id: data.gameOrderId,
|
||||||
status: data.status,
|
status: data.status,
|
||||||
id: data.id,
|
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