卫星通信服务平台
This commit is contained in:
@@ -222,7 +222,10 @@ class HomeController extends Controller {
|
||||
}
|
||||
const uid = JSON.parse(rdmcode).uid;
|
||||
const body = ctx.request.body;
|
||||
const result = await ctx.service.home.unBindingSN(uid, body);
|
||||
const model = decryptRequest(body.model);
|
||||
const password = decryptRequest(body.password);
|
||||
const requestMsg = body.userMsg;
|
||||
const result = await ctx.service.home.unBindingSN(uid, model, password, requestMsg);
|
||||
if(result == "error") {
|
||||
setResponse(ctx, 500, '服务器错误', "none");
|
||||
return;
|
||||
|
||||
@@ -96,13 +96,12 @@ class HomeService extends Service {
|
||||
bindUser.push(element.dataValues);
|
||||
});
|
||||
const resultData = [];
|
||||
const bindUserUids = new Set(resultBindUser.map(element => element.dataValues.user_uid));
|
||||
resultAdminUser.forEach(item => {
|
||||
resultBindUser.forEach(element => {
|
||||
if (item.dataValues.uid !== element.dataValues.user_uid) {
|
||||
if (!bindUserUids.has(item.dataValues.uid)) {
|
||||
resultData.push(item);
|
||||
}
|
||||
});
|
||||
});
|
||||
return resultData;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "searchBindUser";
|
||||
@@ -160,41 +159,50 @@ class HomeService extends Service {
|
||||
}
|
||||
|
||||
// 解绑SN号
|
||||
async unBindingSN(uid, body) {
|
||||
async unBindingSN(uid, modelType, password, requestMsg) {
|
||||
const { ctx } = this;
|
||||
try {
|
||||
const result = await ctx.model.BSide.findOne({ where: { uid, status: { [Op.not]: 2 }, role: 1 } });
|
||||
if (!result || result.organization == null) return false;
|
||||
const { snNumber, userUid } = body;
|
||||
const snWhere = { sn_number: snNumber };
|
||||
const snResult = await ctx.model3.SNNumber.update({ status: 0 }, { where: snWhere });
|
||||
if (snResult[0] !== 0) {
|
||||
const where = {
|
||||
user_uid: userUid,
|
||||
sn_number: snNumber
|
||||
};
|
||||
const form = {
|
||||
user_uid: userUid,
|
||||
sn_number: snNumber,
|
||||
type: 0,
|
||||
created_at: new Date()
|
||||
};
|
||||
const uidLastCode = shunt(userUid);
|
||||
const model = {
|
||||
"B": ctx.model.BuserSNBind,
|
||||
"C": ctx.model2.CuserSNBind,
|
||||
"T": ctx.model2.TuserSNBind,
|
||||
};
|
||||
const modelName = {
|
||||
"B": ctx.model.BindBSNrecord,
|
||||
"C": ctx.model2.BindCSNrecord
|
||||
};
|
||||
const bindResult = await model[uidLastCode].destroy({ where });
|
||||
const recordResult = await modelName[uidLastCode].create(form);
|
||||
return bindResult && recordResult ? true : false;
|
||||
} else {
|
||||
return false;
|
||||
if (!result || result.dataValues.password !== this.shaForm(password, this.decryptRequest(result.dataValues.salt))) return false;
|
||||
let where = {};
|
||||
let attributes = ['uid'];
|
||||
if (modelType == "single") {
|
||||
where = requestMsg;
|
||||
} else if (modelType == "multiple") {
|
||||
let account_name = [], user_name = [], phone = [];
|
||||
for (const key in requestMsg) {
|
||||
requestMsg[key].forEach(element => {
|
||||
account_name.push(element.account_name),
|
||||
user_name.push(element.user_name),
|
||||
phone.push(element.phone)
|
||||
});
|
||||
}
|
||||
where = { account_name, user_name, phone };
|
||||
} else if (modelType == "all") {
|
||||
where = { organization: result.dataValues.organization };
|
||||
}
|
||||
|
||||
const userResult = await ctx.model.BSide.findAll({ attributes, where });
|
||||
if (!userResult[0]) return false;
|
||||
let user_uid = [];
|
||||
userResult.forEach(element => {
|
||||
user_uid.push(element.dataValues.uid);
|
||||
});
|
||||
attributes = ['sn_number'];
|
||||
where = { user_uid };
|
||||
const bindResult = await ctx.model.BuserSNBind.findAll({ attributes, where });
|
||||
if (!bindResult[0]) return false;
|
||||
let sn_number = [], recordForm = [];
|
||||
bindResult.forEach((element, index) => {
|
||||
sn_number.push(element.dataValues.sn_number);
|
||||
recordForm.push({ user_uid: user_uid[index], sn_number: sn_number[index], type: 0, created_at: new Date() });
|
||||
});
|
||||
where = { user_uid, sn_number };
|
||||
const unbindResult = await ctx.model.BuserSNBind.destroy({ where });
|
||||
const recordResult = await ctx.model.BindBSNrecord.bulkCreate(recordForm);
|
||||
where = { sn_number };
|
||||
const cardResult = await ctx.model3.SNNumber.update({ status: 4 }, { where });
|
||||
return unbindResult !== 0 && recordResult[0] && cardResult[0] !== 0 ? true : false;
|
||||
} catch (error) {
|
||||
const blockName = fileName + "--" + "unBindingSN";
|
||||
ctx.app.middleware.utils.log('../../../serviceLog', blockName + ">>>>" + error);
|
||||
@@ -209,7 +217,7 @@ class HomeService extends Service {
|
||||
let { offset, limit, searchOptions, sortOptions } = body;
|
||||
offset = (offset - 1) * limit;
|
||||
let attributes = ['user_uid', 'sn_number', 'type', 'created_at'],
|
||||
where = { user_uid: uid }, order = [], dbOptions, joinSubstring = [],
|
||||
where = {}, order = [], dbOptions, joinSubstring = [],
|
||||
substring = ['user_uid', 'sn_number'], key = ['type'], between = ['created_at'];
|
||||
const uidLastCode = shunt(uid);
|
||||
attributes.forEach(element => {
|
||||
@@ -393,7 +401,7 @@ class HomeService extends Service {
|
||||
let { offset, limit, searchOptions } = body;
|
||||
offset = (offset - 1) * limit;
|
||||
let attributes = ['account_name', 'user_name', 'phone'],
|
||||
where = { organization: result.organization, role: { [Op.not]: 1 } }, dbOptions, joinSubstring = [];
|
||||
where = { organization: result.organization }, dbOptions, joinSubstring = [];
|
||||
attributes.forEach(element => {
|
||||
if (searchOptions[element]) {
|
||||
if(searchOptions[element] == '*空') {
|
||||
|
||||
1
controllerLog/2026/4/8.txt
Normal file
1
controllerLog/2026/4/8.txt
Normal file
@@ -0,0 +1 @@
|
||||
[2026-4-8>>>15:45:36]>>>home--unBindingSN>>>>Error: WHERE parameter "sn_number" has invalid "undefined" value
|
||||
1
serviceLog/2026/4/8.txt
Normal file
1
serviceLog/2026/4/8.txt
Normal file
@@ -0,0 +1 @@
|
||||
[2026-4-8>>>15:28:20]>>>home--unBindingSN>>>>Error: WHERE parameter "sn_number" has invalid "undefined" value
|
||||
Reference in New Issue
Block a user