|
@@ -45,22 +45,22 @@ export class durian extends GetNumberService {
|
|
|
|
|
|
|
|
async getNumber(country: string, num?: number): Promise<GetNumberResponse> {
|
|
async getNumber(country: string, num?: number): Promise<GetNumberResponse> {
|
|
|
// 缓存中是否有值
|
|
// 缓存中是否有值
|
|
|
- const resString = await this.redis.rpop(`durian_${country.toUpperCase()}`)
|
|
|
|
|
- let cacheRes = resString ? JSON.parse(resString) : null
|
|
|
|
|
- let attempts = 0
|
|
|
|
|
- while (
|
|
|
|
|
- cacheRes !== null &&
|
|
|
|
|
- new Date(cacheRes.expiryTime).getTime() - 120000 < new Date().getTime() &&
|
|
|
|
|
- attempts < 20
|
|
|
|
|
- ) {
|
|
|
|
|
- attempts++
|
|
|
|
|
- const newVar = await this.redis.rpop(`durian_${country.toUpperCase()}`)
|
|
|
|
|
- cacheRes = newVar ? JSON.parse(newVar) : null
|
|
|
|
|
- }
|
|
|
|
|
- if (cacheRes !== null) {
|
|
|
|
|
- Logger.log(`${country.toUpperCase()} - ${cacheRes.source}\t Get the number from the cache`, 'GetNumber')
|
|
|
|
|
- return cacheRes
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // const resString = await this.redis.rpop(`durian_${country.toUpperCase()}`)
|
|
|
|
|
+ // let cacheRes = resString ? JSON.parse(resString) : null
|
|
|
|
|
+ // let attempts = 0
|
|
|
|
|
+ // while (
|
|
|
|
|
+ // cacheRes !== null &&
|
|
|
|
|
+ // new Date(cacheRes.expiryTime).getTime() - 120000 < new Date().getTime() &&
|
|
|
|
|
+ // attempts < 20
|
|
|
|
|
+ // ) {
|
|
|
|
|
+ // attempts++
|
|
|
|
|
+ // const newVar = await this.redis.rpop(`durian_${country.toUpperCase()}`)
|
|
|
|
|
+ // cacheRes = newVar ? JSON.parse(newVar) : null
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (cacheRes !== null) {
|
|
|
|
|
+ // Logger.log(`${country.toUpperCase()} - ${cacheRes.source}\t Get the number from the cache`, 'GetNumber')
|
|
|
|
|
+ // return cacheRes
|
|
|
|
|
+ // }
|
|
|
|
|
|
|
|
const res = await durianInstance.get('getMobile', {
|
|
const res = await durianInstance.get('getMobile', {
|
|
|
params: {
|
|
params: {
|
|
@@ -68,7 +68,7 @@ export class durian extends GetNumberService {
|
|
|
ApiKey: ApiKey1,
|
|
ApiKey: ApiKey1,
|
|
|
cuy: country.toUpperCase(),
|
|
cuy: country.toUpperCase(),
|
|
|
pid,
|
|
pid,
|
|
|
- num: 10,
|
|
|
|
|
|
|
+ num: 1,
|
|
|
noblack: 1,
|
|
noblack: 1,
|
|
|
serial: 2
|
|
serial: 2
|
|
|
}
|
|
}
|
|
@@ -76,15 +76,7 @@ export class durian extends GetNumberService {
|
|
|
if (res.data.code !== 200) {
|
|
if (res.data.code !== 200) {
|
|
|
throw new InternalServerErrorException(res.data.msg)
|
|
throw new InternalServerErrorException(res.data.msg)
|
|
|
}
|
|
}
|
|
|
- const numbers = res.data.data
|
|
|
|
|
- let number
|
|
|
|
|
- // 判断numbers是否是数组
|
|
|
|
|
- if (!Array.isArray(numbers)) {
|
|
|
|
|
- number = numbers[0]
|
|
|
|
|
- } else {
|
|
|
|
|
- number = numbers
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
|
|
+ const number = res.data.data
|
|
|
// const imsiRes = await durianInstance.get('getMobileUserCode', {
|
|
// const imsiRes = await durianInstance.get('getMobileUserCode', {
|
|
|
// params: {
|
|
// params: {
|
|
|
// name,
|
|
// name,
|