Split user
This commit is contained in:
@@ -9,13 +9,10 @@ const serialChecker = (serial, type = 'guaranteeSerial', g = 1) => {
|
||||
if (type === 'guaranteeSerial') exelsPath = guaranteeSerialsPath + `/${g}`;
|
||||
if (type === 'orginality') exelsPath = productSerialsPath + `/${g}`;
|
||||
|
||||
const newTxt = serial.toLowerCase().split("-")
|
||||
let lowerSerial = ""
|
||||
for(const item of newTxt){
|
||||
|
||||
lowerSerial += item
|
||||
|
||||
}
|
||||
console.log("s");
|
||||
|
||||
const lowerSerial = serial.toString().toLowerCase().trim().replace("-","")
|
||||
|
||||
try {
|
||||
const serialFiles = await fs.readdirSync(exelsPath);
|
||||
if ((serialFiles?.length) <= 0) {
|
||||
@@ -23,20 +20,24 @@ const serialChecker = (serial, type = 'guaranteeSerial', g = 1) => {
|
||||
reject("این کد در سامانه موجود نیست")
|
||||
}
|
||||
serialFiles.forEach(async (file, i) => {
|
||||
const exelFile = await readXlsxFile(`${exelsPath}/${file}`);
|
||||
if(file.split('.').some(item => ['xlsx', 'xltx', 'xlsm', 'xlsb'].includes(item))){
|
||||
const exelFile = await readXlsxFile(`${exelsPath}/${file}`);
|
||||
console.log(file);
|
||||
|
||||
for (const row of exelFile) {
|
||||
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if ((row[1].toString()).toLowerCase() == lowerSerial) {
|
||||
resolve(row[2]);
|
||||
return; // Serial found, exit loop
|
||||
}
|
||||
|
||||
}
|
||||
if ((serialFiles.length - 1) <= i) {
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
reject("این کد در سامانه موجود نیست")
|
||||
for (const row of exelFile) {
|
||||
console.log(row);
|
||||
|
||||
// eslint-disable-next-line eqeqeq
|
||||
if ((row[1].toString()).toLowerCase().trim() == lowerSerial) {
|
||||
resolve(row[2]);
|
||||
return; // Serial found, exit loop
|
||||
}
|
||||
|
||||
}
|
||||
if ((serialFiles.length - 1) <= i) {
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
reject("این کد در سامانه موجود نیست")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user