Commit f209a373 by 王昆

gsb

parent ed5135ca
...@@ -36,6 +36,15 @@ class EcompanyApi { ...@@ -36,6 +36,15 @@ class EcompanyApi {
return system.getResult2(list); return system.getResult2(list);
} }
async settleMerchantNameSuggest3(queryobj, qobj, req) {
let name = this.trim(queryobj.name);
if(!name) {
return system.getResult2([])
}
let list = await this.esettleSve.suggest3(name);
return system.getResult2(list);
}
trim(o) { trim(o) {
if (!o) { if (!o) {
......
...@@ -816,6 +816,58 @@ class EsettleService extends ServiceBase { ...@@ -816,6 +816,58 @@ class EsettleService extends ServiceBase {
return list; return list;
} }
async suggest3(name) {
if (!name) {
return [];
}
let sql = [];
sql.push("SELECT t1.id, t1.company_name, t3.invoice_type FROM tbl_busi t1");
sql.push("INNER JOIN tbl_busi_signed t2 ON t1.id = t2.busi_id");
sql.push("INNER JOIN tbl_admin_main t3 ON t2.main_id = t3.id");
sql.push("WHERE t1.company_name LIKE :queryLike LIMIT 50");
let list = await this.settledb.query(sql.join(" "), { replacements: { queryLike: "%" + name + "%" } });
if (list && list.length > 0) {
list = list[0, 0] || [];
}
return list;
}
async setBusiInvoiceType(list) {
if (!list || list.length == 0) {
return;
}
let ids = [];
for (let item of list) {
ids.push(item.id);
}
let map = await this.mapInvoiceTypeByIds(ids);
for (let item of list) {
item.invoice_type = map[item.id];
}
}
async mapInvoiceTypeByIds(ids) {
let result = {};
if (!ids || ids.length == 0) {
return result;
}
let sql = [];
sql.push("SELECT t1.busi_id, t2.invoice_type");
sql.push("FROM tbl_busi_signed t1");
sql.push("INNER JOIN tbl_admin_main t2 ON t1.main_id = t2.id ");
sql.push("WHERE t1.busi_id IN (:busiIds)");
let list = await this.settledb.query(sql.join(" "), { replacements: {busiIds: ids } });
if (list && list.length > 0) {
list = list[0, 0] || [];
}
for (let item of list) {
result[item.busi_id] = item.invoice_type;
}
return result;
}
async findcompanyid(id) { async findcompanyid(id) {
if (!id) { if (!id) {
return []; return [];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment