Commit d5456c53 by 孙亚楠

dd

parent 9d30a104
......@@ -109,6 +109,27 @@ class IInvoiceDao extends Dao {
return {personal_invoice_tax_total:res[0].personal_invoice_tax_total || 0,personal_invoice_amount_total:res[0].personal_invoice_amount_total || 0};
}
async countByParamsBycreditCode(params){
var sql = [];
sql.push("SELECT count(1) as count");
sql.push("FROM `saas_invoice` t1 INNER JOIN `saas_invoice_apply` t2 ON t1.id = t2.id ");
sql.push("WHERE 1 = 1 AND t1.`from_credit_code` in(:credit_code_array)");
if(params.from_name){
sql.push("AND t1.`from_name` = :from_name");
}
if(params.status){
sql.push("AND t2.`status` = :status")
}
if(params.statusArray){
sql.push("AND t2.`status` in (:statusArray)")
}
let list = await this.customQuery(sql.join(" "), params);
if(list.length ==0){
return {count: 0};
}
return list[0];
}
/**
* 根据统一社会信用代码获取发票
* @param params
......@@ -131,82 +152,5 @@ class IInvoiceDao extends Dao {
sql.push("ORDER BY t1.invoice_time DESC");
return await this.customQuery(sql.join(" "), params);
}
// /**
// * 红冲列表总计
// * @param {*} params
// */
// async countRedRushListByParams(params){
// var sql = [];
// sql.push(`select count(1) as count from invoice_apply a inner join invoice_deliverer b on a.deliverer_id =b.id
// inner join invoice c on b.invoice_id =c.id where a.id = c.id `);
// if (params.delivererId) {
// sql.push(` AND b.deliverer_id = :delivererId`);
// }
// if (params.applyNo) {
// sql.push(` AND a.apply_no = :applyNo`);
// }
// if (params.invoiceNo) {
// sql.push(` AND c.invoice_no = :invoiceNo`);
// }
// if (params.startTime) {
// sql.push(`and a.invoice_time >= :startTime`);
// }
// if (params.endTime) {
// sql.push(`and a.invoice_time <= :endTime`);
// }
// if(params.invoiceTime){
// sql.push(`and a.invoice_time >= :invoiceTime`);
// }
// if (params.type) {
// sql.push(`and a.type = :type`);
// }
// if (params.redStatus) {
// sql.push(`and c.red_status = :redStatus`);
// }
// if (params.status) {
// sql.push(`and c.status = :status`);
// }
// return await this.customQuery(sql.join(" "), params);
// }
// /**
// * 红冲列表
// * @param {*} params
// */
// async redRushListByParams(params){
// var sql = [];
// sql.push(`select a.apply_no,a.type,a.invoice_amount,a.invoice_time,c.status,
// a.merchant_name,a.businessmen_name,a.id,b.deliverer_id from invoice_apply a
// inner join invoice_deliverer b on a.deliverer_id =b.id
// inner join invoice c on b.invoice_id =c.id where a.id = c.id `);
// if (params.delivererId) {
// sql.push(` AND b.deliverer_id = :delivererId`);
// }
// if (params.applyNo) {
// sql.push(` AND a.apply_no = :applyNo`);
// }
// if (params.startTime) {
// sql.push(`and a.invoice_time >= :startTime`);
// }
// if (params.endTime) {
// sql.push(`and a.invoice_time <= :endTime`);
// }
// if(params.invoiceTime){
// sql.push(`and a.invoice_time >= :invoiceTime`);
// }
// if (params.type) {
// sql.push(`and a.type = :type`);
// }
// if (params.redStatus) {
// sql.push(`and c.red_status = :redStatus`);
// }
// sql.push("ORDER BY c.id DESC");
// sql.push("LIMIT :statRow, :pageSize");
// return await this.customQuery(sql.join(" "), params);
// }
}
module.exports = IInvoiceDao;
\ No newline at end of file
......@@ -481,6 +481,19 @@ class IInvoiceService extends ServiceBase {
return system.getResult(null, `参数错误 统一社会信用代码格式不正确`);
}
try{
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = Number((params.currentPage - 1) * params.pageSize);
let totalRes = await this.dao.countByParamsBycreditCode(params);
if (totalRes.count == 0) {
return system.getResult({
count: 0,
rows: []
});
}
let list = await this.dao.invoiceBycreditCode(params);
if(!list || list.length==0){
return system.getResult([]);
......@@ -492,7 +505,7 @@ class IInvoiceService extends ServiceBase {
}
item.invoice_amount = system.f2y(item.invoice_amount);
}
return system.getResult(list);
return system.getResult({count:totalRes.count,rows:list});
}catch (e) {
console.log(e);
return system.getResult(null, `系统错误`);
......
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