Commit e80f7d0c by 孙亚楠

dd

parent 5c9e8a25
......@@ -79,6 +79,9 @@ class ActionAPI extends APIBase {
case "redRushInvoice": //红冲
opResult = await this.applySve.apiRedRushInvoice(action_body);
break;
case "redrushList":
opResult = await this.invoiceSve.apiRedRushList(action_body);
break;
case "statTransData": //交易数据
opResult = await this.applySve.apiStatTransData(action_body);
break;
......
......@@ -301,7 +301,7 @@ class DelivererDao extends Dao {
sql.push(`select a.id, a.apply_no,a.type,a.invoice_amount,a.invoice_time,c.status,a.merchant_name,a.businessmen_name
from invoice_deliverer b inner join invoice_apply a on b.id = a.deliverer_id
inner join invoice c on c.id = b.invoice_id where 1=1 `);
this.setInvoiceParams(sql, params);
this.setParams(sql, params);
sql.push(`order by id desc limit ${params.statRow},${params.pageSize}`);
return await this.customQuery(sql.join(" "),params);
}
......@@ -334,6 +334,9 @@ class DelivererDao extends Dao {
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`);
}
......@@ -346,6 +349,9 @@ class DelivererDao extends Dao {
if (params.type) {
sql.push(`and a.type = :type`);
}
if (params.status) {
sql.push(`and c.status = :status`);
}
}
}
module.exports = DelivererDao;
......@@ -116,5 +116,83 @@ class InvoiceDao extends Dao {
sql.push("AND t2.`status` in (:statuses)");
}
}
/**
* 红冲列表总计
* @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 = InvoiceDao;
\ No newline at end of file
......@@ -58,7 +58,7 @@ class DelivererService extends ServiceBase {
*/
async apiDelivererApplyInvoices(params) {
try {
// if (!params.delivererId) { return system.getResult(null, `参数错误 ID不能为空`); }
if (!params.delivererId) { return system.getResult(null, `参数错误 ID不能为空`); }
return await this.delivererApplyInvoices(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
......@@ -639,7 +639,8 @@ class DelivererService extends ServiceBase {
let total = await this.dao.countApplyByParams(params);
if (total[0].count == 0) {
return { rows: [], count: 0 }
let res = { rows: [], count: 0 };
return system.getResult(res);
}
let rows = await this.dao.delivererApplyInvoices(params);
......@@ -747,6 +748,9 @@ class DelivererService extends ServiceBase {
if (this.trim(params.applyNo)) {
params.applyNo=this.trim(params.applyNo);
}
if (this.trim(params.invoiceNo)) {
params.invoiceNo=this.trim(params.invoiceNo);
}
if (this.trim(params.invoiceTime)) {
params.invoiceTime=this.trim(params.invoiceTime);
}
......
......@@ -60,8 +60,95 @@ class InvoiceService extends ServiceBase {
}
}
/**
* 发票红冲列表
* @param {*} params
*/
async apiRedRushList(params) {
try {
if(params){}
let res = await this.redRushList(params);
return res;
} catch (error) {
return system.getResult(null, `参数错误 错误信息 ${error}`);
}
}
//==============================================================
/**
* 红冲列表
* @param {*} params
*/
async redRushList(params){
try {
if (params.delivererId) {
params.delivererId=this.trim(params.delivererId);
}
if (this.trim(params.applyNo)) {
params.applyNo=this.trim(params.applyNo);
}
if (this.trim(params.invoiceNo)) {
params.invoiceNo=this.trim(params.invoiceNo);
}
if (this.trim(params.invoiceTime)) {
params.invoiceTime=this.trim(params.invoiceTime);
}
if (this.trim(params.startTime)) {
params.startTime=this.trim(params.startTime);
}
if (this.trim(params.endTime)) {
params.endTime=this.trim(params.endTime);
}
if (this.trim(params.type)) {
params.type=this.trim(params.type);
}
if (this.trim(params.status)) {
params.status=this.trim(params.status);
}
if (this.trim(params.redStatus)) {
params.redStatus=this.trim(params.redStatus);
}
params.statRow = (Number(this.trim(params.pageIndex)) - 1) * Number(this.trim(params.pageSize));
if (params.statRow <= 0) { params.statRow = 0; }
params.pageSize = Number(this.trim(params.pageSize)) <= 0 ? 10 : Number(this.trim(params.pageSize));
let total = await this.dao.countRedRushListByParams(params);
if (total == 0 || total[0].count == 0) {
let res = { rows: [], count: 0 };
return system.getResult(res);
}
let rows = await this.dao.redRushListByParams(params);
for (let item of rows) {
if (item.type == "10") {
item.type = "普通发票";
} else if (item.type == "20") {
item.type = "增值税专用发票";
} else if (item.type == "30") {
item.type = "电子发票";
} else {
item.type = "";
}
this.handleDate(item, ["invoice_time"], "YYYY-MM-DD HH:mm:ss", -8);
this.dao.setRowCodeName(item, "status");
}
let res = { count: total[0].count, rows: rows };
return system.getResult(res);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 完税证明
* @param {*} params
......
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