添加修改SN号数量功能

This commit is contained in:
2026-06-11 13:15:04 +08:00
parent 2997f49dd7
commit 11e35b034a
4 changed files with 53 additions and 33 deletions

View File

@@ -64,6 +64,28 @@ class SNAdminService extends Service {
}
}
// 修改可管理的SN号数量
async editSNCount(uid, body) {
const { ctx } = this;
try {
const result = await ctx.model3.Insiders.findOne({ where: { uid } });
if (!result || result.dataValues.role < 6) return false;
const { user_uid, length } = body;
const existence = await ctx.model.BuserSNAdmin.findOne({ attributes: ['length'], where: { user_uid: user_uid } });
if (existence) {
const adminResult = await ctx.model.BuserSNAdmin.update({ length }, { where: { user_uid: user_uid } });
return adminResult[0] == 0 ? false : adminResult;
} else {
const adminResult = await ctx.model.BuserSNAdmin.create({ user_uid, length, sn_set: '' });
return adminResult == 0 ? false : adminResult;
}
} catch (error) {
const blockName = fileName + "--" + "editSNCount";
ctx.app.middleware.log('../../serviceLog', blockName + ">>>>" + error);
return 'error';
}
}
// B端分配SN号
async allocationSN(uid, body) {
const { ctx } = this;
@@ -135,42 +157,9 @@ class SNAdminService extends Service {
order.push([element, 'DESC']);
}
});
// const [bside, bsideSNRecord] = await Promise.all([
// ctx.model.BSide.findAll({ attributes: ['uid', 'account_name'] }),
// ctx.model.BindBSNrecord.findAll({ attributes: ['user_uid', 'sn_number', 'type'] })
// ]);
// if (searchOptions.account_name) {
// if (searchOptions.account_name == '*空') {
// where.user_uid = [null, ''];
// } else {
// let userArr = [], lengthArr = [], SNArr = [];
// bside.filter(item => {
// if (item.dataValues.account_name.includes(searchOptions.account_name)) {
// bsideSNRecord.filter(item2 => {
// if (item2.dataValues.user_uid == item.dataValues.uid) {
// userArr.push(item2.dataValues.user_uid);
// lengthArr.push(item2.dataValues.length);
// SNArr.push(item2.dataValues.sn_set);
// }
// });
// }
// });
// where.user_uid = [...userArr];
// where.length = [...lengthArr];
// where.sn_set = [...SNArr];
// }
// }
dbOptions = { attributes, offset, limit, where, order };
// let result;
dbOptions.limit = Math.floor(limit / 2);
dbOptions.offset = Math.floor(offset / 2);
// const [bresult] = await Promise.all([
// ctx.model.BuserSNAdmin.findAndCountAll(dbOptions)
// ]);
// result = {
// count: bresult.count,
// rows: bresult.rows
// };
const bside = await ctx.model.BSide.findAll({ attributes: ['uid', 'account_name'] });
const result = await ctx.model.BuserSNAdmin.findAndCountAll(dbOptions);
result.rows.forEach(element => {