Commit 5c9e8a25 by 孙亚楠

dd

parent 2fc0231c
......@@ -4,37 +4,37 @@ class DelivererDao extends Dao {
constructor() {
super(Dao.getModelName(DelivererDao));
this.statusMap = {
"0090":"未付款",
"1000":"待审核",
"1010":"审核不通过",
"1020":"待分配",
"1030":"待处理",
"1040":"交付商关闭",
"1050":"已开具",
"1060":"待审核",
"1070":"审核通过",
"1080":"已邮寄",
"1090":"完成",
"1100":"发票撤回",
"1200":"红冲",
"1300":"审核失败(平台第二次审核)"
"0090": "未付款",
"1000": "待审核",
"1010": "审核不通过",
"1020": "待分配",
"1030": "待处理",
"1040": "交付商关闭",
"1050": "已开具",
"1060": "待审核",
"1070": "审核通过",
"1080": "已邮寄",
"1090": "完成",
"1100": "发票撤回",
"1200": "红冲",
"1300": "审核失败(平台第二次审核)"
};
this.customerMap = {
"0090":"未付款",
"1000":"待审核",
"1030":"待处理",
"1050":"已开具",
"1090":"完成"
"0090": "未付款",
"1000": "待审核",
"1030": "待处理",
"1050": "已开具",
"1090": "完成"
};
this.deliverMap = {
"1030":"待处理",
"1040":"交付商关闭",
"1050":"已开具",
"1060":"待审核",
"1080":"已邮寄",
"1300":"审核失败(平台第二次审核)"
"1030": "待处理",
"1040": "交付商关闭",
"1050": "已开具",
"1060": "待审核",
"1080": "已邮寄",
"1300": "审核失败(平台第二次审核)"
}
}
......@@ -46,8 +46,8 @@ class DelivererDao extends Dao {
var list = await this.customQuery(sql.join(" "), params);
return {
total:list.length || 0,
list:list
total: list.length || 0,
list: list
};
}
......@@ -65,7 +65,7 @@ class DelivererDao extends Dao {
sql.push("SELECT");
sql.push("b.id, b.deliverer_id, b.deliverer_name,sum(b.deliverer_amount) as totalAmount");
sql.push("FROM invoice_deliverer b inner join invoice_apply a on a.deliverer_id=b.id ");
sql.push("WHERE 1 = 1 and b.deliverer_id in ("+params.list+")");
sql.push("WHERE 1 = 1 and b.deliverer_id in (" + params.list + ")");
if (params.begin) {
sql.push("AND b.created_at >= :begin");
......@@ -89,7 +89,7 @@ class DelivererDao extends Dao {
sql.push("FROM `invoice_apply` a inner join `invoice_deliverer` b on a.deliverer_id=b.id");
sql.push("WHERE 1 = 1");
if(params.delivererIds) {
if (params.delivererIds) {
sql.push("AND a.deliverer_id IN (:delivererIds)")
}
if (params.begin) {
......@@ -113,7 +113,7 @@ class DelivererDao extends Dao {
}
//按天来计算(交付商)
async delStatDayByTime(begin, end,delivererId) {
async delStatDayByTime(begin, end, delivererId) {
var result = {};
var sql = [];
sql.push("SELECT");
......@@ -124,7 +124,7 @@ class DelivererDao extends Dao {
var params = {
begin: begin,
end: end,
delivererId:delivererId
delivererId: delivererId
};
if (begin) {
sql.push("AND created_at >= :begin");
......@@ -148,7 +148,7 @@ class DelivererDao extends Dao {
}
//安月来计算(交付商)
async delStatMonthByTime(begin, end,delivererId) {
async delStatMonthByTime(begin, end, delivererId) {
var result = {};
var sql = [];
sql.push("SELECT");
......@@ -192,7 +192,7 @@ class DelivererDao extends Dao {
}
async delStatInvoiceByTime(begin, end,delivererId) {
async delStatInvoiceByTime(begin, end, delivererId) {
var sql = [];
sql.push("SELECT");
sql.push("COUNT(1) AS invoiceCount, SUM(deliverer_amount) AS delivererAmount");
......@@ -202,7 +202,7 @@ class DelivererDao extends Dao {
var params = {
begin: begin,
end: end,
delivererId:delivererId
delivererId: delivererId
};
if (begin) {
sql.push("AND created_at >= :begin");
......@@ -255,14 +255,97 @@ class DelivererDao extends Dao {
var result = {};
var list = await this.customQuery(sql.join(" "), params);
if(!list || list.length == 0) {
if (!list || list.length == 0) {
return result;
}
for(var item of list) {
for (var item of list) {
result[item.status] = item.invoiceCount || 0;
}
return result;
}
/**
* 发票申请表(交付商)
*/
async countApplyByParams(params) {
let sql = [];
sql.push(`select count(1) as count 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.setParams(sql, params);
return await this.customQuery(sql.join(" "),params);
}
/**
* 发票列表(交付商)
*/
async countInvoiceByParams(params) {
let sql = [];
sql.push(`select count(1) as count from invoice_apply a inner join invoice c on a.id=c.id
inner join invoice_deliverer b on a.deliverer_id = b.id where 1=1 `);
this.setParams(sql, params);
if (params.status) {
sql.push(`and c.status = :status`);
}else{
sql.push(` and c.status in('1070','1080','1090')`);
}
return await this.customQuery(sql.join(" "),params);
}
/**
* 发票申请列表
* @param {*} params
*/
async delivererApplyInvoices(params) {
let sql = [];
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);
sql.push(`order by id desc limit ${params.statRow},${params.pageSize}`);
return await this.customQuery(sql.join(" "),params);
}
/**
* 发票列表
* @param {*} params
*/
async delivererInvoices(params) {
let sql = [];
sql.push(`select a.id, a.apply_no,a.type,c.invoice_no,c.invoice_time,a.invoice_amount,a.merchant_id,a.merchant_name,
a.merchant_credit_code,a.merchant_addr,a.merchant_mobile,a.merchant_bank,a.merchant_account,a.businessmen_id,
a.businessmen_credit_code,a.businessmen_name,a.businessmen_addr,a.businessmen_mobile,a.businessmen_bank,
a.businessmen_account,a.is_bank,a.tax_authoritioes,a.is_invalid,c.complate_tax, c.status,c.red_status from invoice_apply a
inner join invoice c on a.id=c.id inner join invoice_deliverer b on b.id = a.deliverer_id where 1=1 `);
this.setParams(sql, params);
if (params.status) {
sql.push(` and c.status = :status`);
}else{
sql.push(` and c.status in('1070','1080','1090')`);
}
sql.push(`order by id desc limit ${params.statRow},${params.pageSize}`);
return await this.customQuery(sql.join(" "),params);
}
setParams(sql, params) {
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`);
}
}
}
module.exports = DelivererDao;
......@@ -611,42 +611,38 @@ class DelivererService extends ServiceBase {
*/
async delivererApplyInvoices(params) {
try {
// if (!params.delivererId) { return system.getResult({ rows: 0, data: {} }); }
// let where = `where b.deliverer_id = ${this.trim(params.delivererId)}`;
let where = "where 1=1 ";
if (params.delivererId) {
params.delivererId=this.trim(params.delivererId);
}
if (this.trim(params.applyNo)) {
where += ` and a.apply_no='${this.trim(params.applyNo)}'`;
params.applyNo=this.trim(params.applyNo);
}
if (this.trim(params.invoiceTime)) {
where += `and a.invoice_time>='${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)) {
where += `and a.type='${this.trim(params.type)}'`;
params.type=this.trim(params.type);
}
if (this.trim(params.status)) {
where += `and c.status='${this.trim(params.status)}'`;
params.status=this.trim(params.status);
}
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 countSql = "";
countSql = countSql + "select count(1) as count ";
countSql = countSql + "from invoice_deliverer b ";
countSql = countSql + "inner join invoice_apply a on b.invoice_id = a.id ";
countSql = countSql + "inner join invoice c on c.id = b.invoice_id ";
countSql = countSql + where;
let total = await this.customQuery(countSql);
let total = await this.dao.countApplyByParams(params);
if (total[0].count == 0) {
return { rows: [], count: 0 }
}
let dataSql = `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.invoice_id = a.id
inner join invoice c on c.id = b.invoice_id ${where}`
dataSql += `order by id desc limit ${params.statRow},${params.pageSize}`;
let rows = await this.customQuery(dataSql);
let rows = await this.dao.delivererApplyInvoices(params);
for (let item of rows) {
if (item.type == "10") {
item.type = "普通发票";
......@@ -744,49 +740,43 @@ class DelivererService extends ServiceBase {
* @param {*} params
*/
async delInvs(params) {
let where = '';
// if (this.trim(params.delivererId)) {
// where += `and deliverer_id = '${this.trim(params.delivererId)}`;
// }
if (params.delivererId) {
params.delivererId=this.trim(params.delivererId);
}
if (this.trim(params.applyNo)) {
where += ` and a.apply_no='${this.trim(params.applyNo)}'`;
params.applyNo=this.trim(params.applyNo);
}
if (this.trim(params.invoiceTime)) {
where += `and a.invoice_time >= '${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)) {
where += ` and a.type='${this.trim(params.type)}'`;
params.type=this.trim(params.type);
}
if (this.trim(params.status)) {
where += `and b.status = '${this.trim(params.status)}'`;
} else {
where += `and b.status in('1070','1080','1090')`;
params.status=this.trim(params.status);
}
if (this.trim(params.complateTax) == "1" || this.trim(params.complateTax) == "0") {
where += ` and b.complate_tax='${this.trim(params.complateTax)}'`;
params.complateTax=this.trim(params.complateTax);
}
if (this.trim(params.redStatus)) {
where += ` and b.red_status='${this.trim(params.redStatus)}'`;
params.red_status=this.trim(params.red_status);
}
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));
try {
let sql = `select count(1) as total from invoice_apply a inner join invoice b on a.id=b.id where 1=1 ${where}`;
let total = await this.customQuery(sql);
// let sqlData=`select a.apply_no,a.type,a.invoice_amount,a.invoice_time,b.status,a.merchant_name,a.businessmen_name,a.id from invoice_apply a, invoice b where 1=1 ` ;
let sqlData = `select a.id, a.apply_no,a.type,b.invoice_no,b.invoice_time,a.invoice_amount,a.merchant_id,a.merchant_name,
a.merchant_credit_code,a.merchant_addr,a.merchant_mobile,a.merchant_bank,a.merchant_account,a.businessmen_id,
a.businessmen_credit_code,a.businessmen_name,a.businessmen_addr,a.businessmen_mobile,a.businessmen_bank,
a.businessmen_account,a.is_bank,a.tax_authoritioes,a.is_invalid,b.complate_tax, b.status,b.red_status from invoice_apply a
inner join invoice b on a.id=b.id where 1=1 ` ;
if (where) {
sqlData += ` ${where}`;
}
sqlData += ` limit ${params.statRow},${params.pageSize}`;
let rows = await this.customQuery(sqlData);
//查总数
let total = await this.dao.countInvoiceByParams(params);
//查列表信息
let rows = await this.dao.delivererInvoices(params);
for (let item of rows) {
if (item.type == 10) {
item.type = '普通发票';
......@@ -812,7 +802,7 @@ class DelivererService extends ServiceBase {
this.handleDate(item, ["invoice_time"], "YYYY-MM-DD HH:mm:ss", -8);
this.dao.setRowCodeName(item, "status");
}
let res = { count: total[0].total, rows: rows };
let res = { count: total[0].count, rows: rows };
return system.getResult(res);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
......
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