修改绑定接口, 运行address和accountid为空(删除绑定关系)
This commit is contained in:
parent
49fa01ce7e
commit
2a3c5dae0b
@ -39,6 +39,8 @@ const queryCECClaimStatus = async (address: string) => {
|
|||||||
let claimed = 0n
|
let claimed = 0n
|
||||||
let unavailable = 0n
|
let unavailable = 0n
|
||||||
const records = await CECRecordTotal.find({ address })
|
const records = await CECRecordTotal.find({ address })
|
||||||
|
//@ts-ignore
|
||||||
|
await updateClaimStatus({ address, token: CEC_ADDRESS, records})
|
||||||
const bindRecord = await BitgetBindInfo.findOne({ wallet: address })
|
const bindRecord = await BitgetBindInfo.findOne({ wallet: address })
|
||||||
let bit = 0n
|
let bit = 0n
|
||||||
for (const record of records) {
|
for (const record of records) {
|
||||||
@ -96,8 +98,6 @@ class CECController extends BaseController {
|
|||||||
let available = 0n
|
let available = 0n
|
||||||
let claimed = 0n
|
let claimed = 0n
|
||||||
const records = await CECRecord.find({ address })
|
const records = await CECRecord.find({ address })
|
||||||
//@ts-ignore
|
|
||||||
await updateClaimStatus({ address, token: CEC_ADDRESS, records})
|
|
||||||
const now = Date.now()
|
const now = Date.now()
|
||||||
const stages = []
|
const stages = []
|
||||||
const lists = []
|
const lists = []
|
||||||
@ -212,12 +212,19 @@ class CECController extends BaseController {
|
|||||||
|
|
||||||
@router('post /api/cec/bind_account')
|
@router('post /api/cec/bind_account')
|
||||||
async bindAccount(req: any) {
|
async bindAccount(req: any) {
|
||||||
|
await new SyncLocker().checkLock(req)
|
||||||
|
logger.db('bind_bitget_acc', req)
|
||||||
const user = req.user
|
const user = req.user
|
||||||
const { accid, address } = req.body
|
const { accid, address } = req.body
|
||||||
if (!accid || !address) {
|
if (CEC_CLAIM_STAGE !== 0) {
|
||||||
throw new ZError(11, 'accid is required')
|
throw new ZError(14, 'bind parse ended')
|
||||||
}
|
}
|
||||||
if (!ethers.utils.isAddress(address)) {
|
|
||||||
|
if (accid && !address || !accid && address) {
|
||||||
|
throw new ZError(11, 'address and accid are required')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (address && !ethers.utils.isAddress(address)) {
|
||||||
throw new ZError(12, 'address is invalid')
|
throw new ZError(12, 'address is invalid')
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,15 +245,11 @@ class CECController extends BaseController {
|
|||||||
|
|
||||||
const records = await CECRecordTotal.find({ address: wallet })
|
const records = await CECRecordTotal.find({ address: wallet })
|
||||||
if (records.length === 0) {
|
if (records.length === 0) {
|
||||||
throw new ZError(15, 'record not found')
|
throw new ZError(15, 'no claimable record found')
|
||||||
}
|
}
|
||||||
|
|
||||||
let record = await BitgetBindInfo.findOne({ wallet })
|
await BitgetBindInfo.insertOrUpdate({ wallet }, {address, biggetAcc: accid})
|
||||||
if (record) {
|
|
||||||
throw new ZError(17, 'already bind')
|
|
||||||
}
|
|
||||||
record = new BitgetBindInfo({ address, wallet, biggetAcc: accid })
|
|
||||||
await record.save()
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Contract } from 'ethers'
|
import { Contract } from 'ethers'
|
||||||
import { CECRecordTotalClass, CECStatusEnum } from 'models/CECRecordTotal'
|
import { CECRecordTotalClass, CECStatusEnum, ClaimStatusEnum } from 'models/CECRecordTotal'
|
||||||
import { CheckIn } from 'models/chain/CheckIn'
|
import { CheckIn } from 'models/chain/CheckIn'
|
||||||
import { NftHolder } from 'models/chain/NftHolder'
|
import { NftHolder } from 'models/chain/NftHolder'
|
||||||
import { NftStake } from 'models/chain/NftStake'
|
import { NftStake } from 'models/chain/NftStake'
|
||||||
@ -177,17 +177,15 @@ export const updateClaimStatus = async (
|
|||||||
if (!record) {
|
if (!record) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
const bitTotal = BigInt(record.bit)
|
||||||
for (let item of records) {
|
for (let item of records) {
|
||||||
let bit = BigInt(item.bit * 2)
|
|
||||||
let bit1 = bit + 1n
|
|
||||||
let changed = false
|
let changed = false
|
||||||
if (item.status == CECStatusEnum.NORMAL && (BigInt(record.bit) & 1n << bit) > 0n ) {
|
for ( let value of item.claimStatus.values()) {
|
||||||
item.status = CECStatusEnum.STAGE1_CLAIMED
|
let bit = BigInt(value.bit)
|
||||||
changed = true
|
if (value.status == ClaimStatusEnum.NORMAL && (bitTotal & 1n << bit) > 0n ) {
|
||||||
}
|
value.status = ClaimStatusEnum.CLAIMED
|
||||||
if (item.firstRate < 100 && item.status != CECStatusEnum.STAGE2_CLAIMED && (BigInt(record.bit) & 1n << bit1) > 0n) {
|
changed = true
|
||||||
item.status = CECStatusEnum.STAGE2_CLAIMED
|
}
|
||||||
changed = true
|
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
|
Loading…
x
Reference in New Issue
Block a user