Commit 93a17dd0 by 王昆

gsb

parent d4d4ebd8
......@@ -5,10 +5,11 @@ class ActionAPI extends APIBase {
constructor() {
super();
this.iinvoiceSve = system.getObject("service.invoice.iinvoiceSve");
this.iinvoicedeliverSve = system.getObject("service.invoice.iinvoicedeliverSve");
this.iproductSve = system.getObject("service.product.iproductSve");
this.iprocessSve = system.getObject("service.product.iprocessSve");
}
/**
* 接口跳转
......@@ -36,7 +37,7 @@ class ActionAPI extends APIBase {
opResult = await this.iinvoiceSve.invoicePage(action_body);
break;
case "deliverInvoicePage": // 发票申请列表页(交付商)
opResult = await this.iinvoiceSve.deliverInvoicePage(action_body);
opResult = await this.iinvoicedeliverSve.invoicePage(action_body);
break;
case "handleStatus": //进度处理
break;
......
......@@ -30,7 +30,7 @@ class IInvoiceDao extends Dao {
this.setCondition(params, sql);
sql.push("ORDER BY id DESC");
sql.push("ORDER BY t1.id DESC");
sql.push("LIMIT :startRow, :pageSize");
params.startRow = startRow || 0;
params.pageSize = pageSize || 10;
......@@ -39,16 +39,16 @@ class IInvoiceDao extends Dao {
setCondition(params, sql) {
if(params.apply_no) {
sql.push("AND t2.`apply_no` = :apply_no");
sql.push("AND t1.`apply_no` = :apply_no");
}
if(params.status) {
sql.push("AND t2.`status` = :status");
sql.push("AND t1.`status` = :status");
}
if(params.statuses && params.statuses.length > 0){
sql.push("AND t2.`status` in (:statuses)");
sql.push("AND t1.`status` in (:statuses)");
}
if(params.invoice_type) {
sql.push("AND t2.`invoice_type` = :invoice_type");
sql.push("AND t1.`invoice_type` = :invoice_type");
}
if(params.invoiceTimeBegin) {
sql.push("AND t1.`invoice_time` >= :invoiceTimeBegin");
......@@ -61,14 +61,14 @@ class IInvoiceDao extends Dao {
sql.push("AND t1.`red_status` = :red_status");
}
if(params.deliver_id) {
sql.push("AND t2.`deliver_id` = :deliver_id");
sql.push("AND t1.`deliver_id` = :deliver_id");
}
if(params.bd_id) {
sql.push("AND t2.`bd_id` = :bd_id");
sql.push("AND t1.`bd_id` = :bd_id");
}
if(params.bd_path) {
params.bd_path_like = params.bd_path + "%";
sql.push("AND t2.`bd_path` = :bd_path_like");
sql.push("AND t1.`bd_path` = :bd_path_like");
}
}
......
......@@ -3,12 +3,11 @@ const system = require("../../../system");
class IinvoicedeliverDao extends Dao {
constructor() {
super(Dao.getModelName(IinvoicedeliverDao));
this.tableName = this.model.tableName;
}
async findMapByIds(ids) {
var result = {};
var sql = `SELECT * FROM ${this.tableName} WHERE id IN (:ids)`;
var sql = `SELECT * FROM ${this.model.tableName} WHERE id IN (:ids)`;
var list = await this.customQuery(sql, {
ids: ids
});
......@@ -21,320 +20,395 @@ class IinvoicedeliverDao extends Dao {
return result;
}
//交付商业务概览
async countStat(params) {
var sql = [];
sql.push("select distinct deliverer_id from `xgg-invoice`.invoice_deliverer where 1=1");
this.setCondition(params, sql);
var list = await this.customQuery(sql.join(" "), params);
return {
total: list.length || 0,
list: list
};
}
setCondition(params, sql) {
if (params.begin) {
sql.push("AND created_at >= :begin");
}
if (params.end) {
sql.push("AND created_at <= :end");
}
}
//获取名字 id等信息
async queryStat(params, startRow, pageSize) {
var sql = [];
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 + ")");
if (params.begin) {
sql.push("AND b.created_at >= :begin");
}
if (params.end) {
sql.push("AND b.created_at <= :end");
}
sql.push("GROUP BY b.deliverer_id");
sql.push("LIMIT :startRow, :pageSize");
params.startRow = startRow;
params.pageSize = pageSize;
var list = await this.customQuery(sql.join(" "), params);
return list;
}
async statDeliverByStatus(params) {
async countByParams(params) {
var sql = [];
sql.push("SELECT");
sql.push("a.deliverer_id,a.status,COUNT(1) AS invoiceCount");
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) {
sql.push("AND a.deliverer_id IN (:delivererIds)")
}
if (params.begin) {
sql.push("AND b.created_at >= :begin");
}
if (params.end) {
sql.push("AND b.created_at <= :end");
}
sql.push("GROUP BY a.`status`");
var result = {};
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.deliverer_id + "_" + item.status] = item.invoiceCount || 0;
}
return result;
}
sql.push("COUNT(1) as total");
sql.push("FROM i_invoice_deliver t2");
sql.push("INNER JOIN i_invoice t1 on t1.id = t2.invoice_id");
sql.push("WHERE 1 = 1 ");
//按天来计算(交付商)
async delStatDayByTime(begin, end, delivererId) {
var result = {};
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(created_at, '%Y-%m-%d') AS `day`, SUM(deliverer_amount) AS delivererAmount, COUNT(1) AS invoiceCount");
sql.push("FROM `invoice_deliverer`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end,
delivererId: delivererId
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
if (delivererId) {
sql.push("AND deliverer_id = :delivererId");
}
sql.push("GROUP BY `day` ORDER BY `day` ASC");
var list = await this.customQuery(sql.join(" "), params);
this.setCondition(params, sql);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.day] = item;
var counts = await this.customQuery(sql.join(" "), params);
if (!counts || counts.length == 0) {
return 0;
}
return result;
return counts[0].total || 0;
}
//安月来计算(交付商)
async delStatMonthByTime(begin, end, delivererId) {
var result = {};
async pageByParams(params, startRow, pageSize) {
var sql = [];
sql.push("SELECT");
sql.push("DATE_FORMAT(created_at, '%Y-%m') AS `month`, SUM(deliverer_amount) AS delivererAmount, COUNT(1) AS invoiceCount");
sql.push("FROM `invoice_deliverer`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
}
if (end) {
sql.push("AND created_at <= :end");
}
if (delivererId) {
sql.push("AND deliverer_id = :delivererId");
}
sql.push("GROUP BY `month` ORDER BY `month` ASC");
var list = await this.customQuery(sql.join(" "), params);
sql.push("t1.`product_id`, ");
sql.push("t1.`apply_no`, t1.`invoice_type`, t1.`invoice_join`, t1.`invoice_amount`, ");
sql.push("t1.`apply_time`, t1.invoice_time, t1.`created_at`, t1.`status`, ");
sql.push("t1.`merchant_name`, t1.businessmen_name");
sql.push("FROM i_invoice_deliver t2");
sql.push("INNER JOIN i_invoice t1 on t1.id = t2.invoice_id");
sql.push("WHERE 1 = 1 ");
if (!list || list.length == 0) {
return result;
}
for (var idx = 0; idx < list.length; idx++) {
var item = list[idx];
result[item.month] = item;
if (idx == 0) {
result.begin = item.month;
}
this.setCondition(params, sql);
if (idx == list.length - 1) {
result.end = item.month;
}
}
return result;
sql.push("ORDER BY t2.id DESC");
sql.push("LIMIT :startRow, :pageSize");
params.startRow = startRow || 0;
params.pageSize = pageSize || 10;
return await this.customQuery(sql.join(" "), params);
}
async delStatInvoiceByTime(begin, end, delivererId) {
var sql = [];
sql.push("SELECT");
sql.push("COUNT(1) AS invoiceCount, SUM(deliverer_amount) AS delivererAmount");
sql.push("FROM `invoice_deliverer`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end,
delivererId: delivererId
};
if (begin) {
sql.push("AND created_at >= :begin");
setCondition(params, sql) {
if (params.apply_no) {
sql.push("AND t1.`apply_no` = :apply_no");
}
if (end) {
sql.push("AND created_at <= :end");
if (params.status) {
sql.push("AND t1.`status` = :status");
}
if (delivererId) {
sql.push("AND deliverer_id = :delivererId");
if (params.statuses && params.statuses.length > 0) {
sql.push("AND t1.`status` in (:statuses)");
}
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return {
invoiceCount: 0,
delivererAmount: 0,
}
if (params.invoice_type) {
sql.push("AND t1.`invoice_type` = :invoice_type");
}
var item = list[0];
return {
invoiceCount: item.invoiceCount || 0,
delivererAmount: item.delivererAmount || 0,
if (params.invoiceTimeBegin) {
sql.push("AND t1.`invoice_time` >= :invoiceTimeBegin");
}
}
/**
* 发票办理
* @param {*} begin
* @param {*} end
*/
async delStatByStatus(begin, end) {
var sql = [];
sql.push("SELECT");
sql.push("`status`, COUNT(1) AS invoiceCount ");
sql.push("FROM `invoice_deliverer`");
sql.push("WHERE 1 = 1");
var params = {
begin: begin,
end: end
};
if (begin) {
sql.push("AND created_at >= :begin");
if (params.invoiceTimeEnd) {
sql.push("AND t1.`invoice_time` <= :invoiceTimeEnd");
}
if (end) {
sql.push("AND created_at <= :end");
if (params.red_status) {
sql.push("AND t1.`red_status` = :red_status");
}
sql.push("GROUP BY `status`");
var result = {};
var list = await this.customQuery(sql.join(" "), params);
if (!list || list.length == 0) {
return result;
if (params.deliver_id) {
sql.push("AND t1.`deliver_id` = :deliver_id");
}
for (var item of list) {
result[item.status] = item.invoiceCount || 0;
if (params.bd_id) {
sql.push("AND t1.`bd_id` = :bd_id");
}
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')`);
if (params.bd_path) {
params.bd_path_like = params.bd_path + "%";
sql.push("AND t1.`bd_path` = :bd_path_like");
}
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.setParams(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')`);
if (params.operator_id) {
sql.push("AND t2.`operator_id` = :operator_id");
}
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.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.status) {
sql.push(`and c.status = :status`);
}
}
// //交付商业务概览
// async countStat(params) {
// var sql = [];
// sql.push("select distinct deliverer_id from `xgg-invoice`.invoice_deliverer where 1=1");
// this.setCondition(params, sql);
// var list = await this.customQuery(sql.join(" "), params);
// return {
// total: list.length || 0,
// list: list
// };
// }
// setCondition(params, sql) {
// if (params.begin) {
// sql.push("AND created_at >= :begin");
// }
// if (params.end) {
// sql.push("AND created_at <= :end");
// }
// }
// //获取名字 id等信息
// async queryStat(params, startRow, pageSize) {
// var sql = [];
// 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 + ")");
// if (params.begin) {
// sql.push("AND b.created_at >= :begin");
// }
// if (params.end) {
// sql.push("AND b.created_at <= :end");
// }
// sql.push("GROUP BY b.deliverer_id");
// sql.push("LIMIT :startRow, :pageSize");
// params.startRow = startRow;
// params.pageSize = pageSize;
// var list = await this.customQuery(sql.join(" "), params);
// return list;
// }
// async statDeliverByStatus(params) {
// var sql = [];
// sql.push("SELECT");
// sql.push("a.deliverer_id,a.status,COUNT(1) AS invoiceCount");
// 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) {
// sql.push("AND a.deliverer_id IN (:delivererIds)")
// }
// if (params.begin) {
// sql.push("AND b.created_at >= :begin");
// }
// if (params.end) {
// sql.push("AND b.created_at <= :end");
// }
// sql.push("GROUP BY a.`status`");
// var result = {};
// var list = await this.customQuery(sql.join(" "), params);
// if (!list || list.length == 0) {
// return result;
// }
// for (var item of list) {
// result[item.deliverer_id + "_" + item.status] = item.invoiceCount || 0;
// }
// return result;
// }
// //按天来计算(交付商)
// async delStatDayByTime(begin, end, delivererId) {
// var result = {};
// var sql = [];
// sql.push("SELECT");
// sql.push("DATE_FORMAT(created_at, '%Y-%m-%d') AS `day`, SUM(deliverer_amount) AS delivererAmount, COUNT(1) AS invoiceCount");
// sql.push("FROM `invoice_deliverer`");
// sql.push("WHERE 1 = 1");
// var params = {
// begin: begin,
// end: end,
// delivererId: delivererId
// };
// if (begin) {
// sql.push("AND created_at >= :begin");
// }
// if (end) {
// sql.push("AND created_at <= :end");
// }
// if (delivererId) {
// sql.push("AND deliverer_id = :delivererId");
// }
// sql.push("GROUP BY `day` ORDER BY `day` ASC");
// var list = await this.customQuery(sql.join(" "), params);
// if (!list || list.length == 0) {
// return result;
// }
// for (var item of list) {
// result[item.day] = item;
// }
// return result;
// }
// //安月来计算(交付商)
// async delStatMonthByTime(begin, end, delivererId) {
// var result = {};
// var sql = [];
// sql.push("SELECT");
// sql.push("DATE_FORMAT(created_at, '%Y-%m') AS `month`, SUM(deliverer_amount) AS delivererAmount, COUNT(1) AS invoiceCount");
// sql.push("FROM `invoice_deliverer`");
// sql.push("WHERE 1 = 1");
// var params = {
// begin: begin,
// end: end
// };
// if (begin) {
// sql.push("AND created_at >= :begin");
// }
// if (end) {
// sql.push("AND created_at <= :end");
// }
// if (delivererId) {
// sql.push("AND deliverer_id = :delivererId");
// }
// sql.push("GROUP BY `month` ORDER BY `month` ASC");
// var list = await this.customQuery(sql.join(" "), params);
// if (!list || list.length == 0) {
// return result;
// }
// for (var idx = 0; idx < list.length; idx++) {
// var item = list[idx];
// result[item.month] = item;
// if (idx == 0) {
// result.begin = item.month;
// }
// if (idx == list.length - 1) {
// result.end = item.month;
// }
// }
// return result;
// }
// async delStatInvoiceByTime(begin, end, delivererId) {
// var sql = [];
// sql.push("SELECT");
// sql.push("COUNT(1) AS invoiceCount, SUM(deliverer_amount) AS delivererAmount");
// sql.push("FROM `invoice_deliverer`");
// sql.push("WHERE 1 = 1");
// var params = {
// begin: begin,
// end: end,
// delivererId: delivererId
// };
// if (begin) {
// sql.push("AND created_at >= :begin");
// }
// if (end) {
// sql.push("AND created_at <= :end");
// }
// if (delivererId) {
// sql.push("AND deliverer_id = :delivererId");
// }
// var list = await this.customQuery(sql.join(" "), params);
// if (!list || list.length == 0) {
// return {
// invoiceCount: 0,
// delivererAmount: 0,
// }
// }
// var item = list[0];
// return {
// invoiceCount: item.invoiceCount || 0,
// delivererAmount: item.delivererAmount || 0,
// }
// }
// /**
// * 发票办理
// * @param {*} begin
// * @param {*} end
// */
// async delStatByStatus(begin, end) {
// var sql = [];
// sql.push("SELECT");
// sql.push("`status`, COUNT(1) AS invoiceCount ");
// sql.push("FROM `invoice_deliverer`");
// sql.push("WHERE 1 = 1");
// var params = {
// begin: begin,
// end: end
// };
// if (begin) {
// sql.push("AND created_at >= :begin");
// }
// if (end) {
// sql.push("AND created_at <= :end");
// }
// sql.push("GROUP BY `status`");
// var result = {};
// var list = await this.customQuery(sql.join(" "), params);
// if (!list || list.length == 0) {
// return result;
// }
// 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.setParams(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.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.status) {
// sql.push(`and c.status = :status`);
// }
// }
}
module.exports = IinvoicedeliverDao;
......@@ -33,12 +33,12 @@ module.exports = (db, DataTypes) => {
businessmen_account: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方银行账号' },
apply_no: { type: DataTypes.STRING(45), allowNull: true, defaultValue: "", COMMENT: '发票申请编号' },
apply_time: { type: DataTypes.DATE, allowNull: true, defaultValue: null, COMMENT: '发票申请时间' },
invoice_amount: { type: DataTypes.INTEGER, allowNull: true, defaultValue: 0, COMMENT: '价税合计总金额' },
invoice_amount: { type: DataTypes.BIGINT, allowNull: true, defaultValue: 0, COMMENT: '价税合计总金额' },
invoice_content: { type: DataTypes.STRING(300), allowNull: false, defaultValue: null, COMMENT: '开票内容' },
contract: { type: DataTypes.STRING(500), allowNull: true,delaultValue:"", COMMENT: '合同' },
personal_invoice_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '个税' },
additional_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '附加税' },
value_added_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '增值税' },
additional_tax: { type: DataTypes.BIGINT, allowNull: false, defaultValue: null, COMMENT: '附加税' },
value_added_tax: { type: DataTypes.BIGINT, allowNull: false, defaultValue: null, COMMENT: '增值税' },
mail_addr: { type: DataTypes.STRING(200), allowNull: true, defaultValue: null, COMMENT: '邮寄地址' },
mail_mobile: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄电话' },
mail_to: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄人' },
......
......@@ -144,7 +144,6 @@ class IInvoiceService extends ServiceBase {
return system.getResult(null,`系统错误`);
}
}
async invoicePage(params) {
params.currentPage = Number(params.currentPage || 1);
......@@ -161,7 +160,7 @@ class IInvoiceService extends ServiceBase {
for (var item of list) {
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
}
//格式化订单产品
//格式化产品
await this.setDeliver(list);
//格式化业务员
await this.setStatus(list);
......@@ -172,7 +171,7 @@ class IInvoiceService extends ServiceBase {
}
/**
* 格式化订单产品
* 格式化产品
* @param {*} list
*/
async setProduct(list) {
......
......@@ -4,9 +4,82 @@ const moment = require('moment');
/**
* 平台提交的信息
*/
class IinvoicedelivererService extends ServiceBase {
class IinvoicedeliverService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(DelivererService));
super("invoice", ServiceBase.getDaoName(IinvoicedeliverService));
this.iinvoiceDao = system.getObject("db.invoice.iinvoiceDao");
this.iinvoiceprocessDao = system.getObject("db.invoice.iinvoiceprocessDao");
this.iinvoiceinforegDao = system.getObject("db.invoice.iinvoiceinforegDao");
this.iproductDao = system.getObject("db.product.iproductDao");
this.iprocessDao = system.getObject("db.product.iprocessDao");
this.iproductprocessDao = system.getObject("db.product.iproductprocessDao");
}
async invoicePage(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = Number((params.currentPage - 1) * params.pageSize);
let deliver_id = params.deliver_id;
let total = await this.dao.countByParams(params);
if (total == 0) {
return { count: 0, rows: [] };
}
let list = await this.dao.pageByParams(params);
if (list) {
for (var item of list) {
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
}
await this.setStatus(list);
await this.setProduct(list);
}
return { count: total, rows: list };
}
/**
* 格式化产品
* @param {*} list
*/
async setProduct(list) {
let productIdList = [];
for (let item of list) {
if (item.product_id) {
productIdList.push(item.product_id);
}
}
let productMap = await this.iproductDao.mapByIds(productIdList);
for (let item of list) {
item.oproduct = productMap[item.product_id] || {}
}
}
/**
* 处理状态数据
* @param list
* @returns {Promise<void>}
*/
async setStatus(list) {
let ids = [];
let statuses = [];
for (let item of list) {
ids.push(item.id);
statuses.push(item.status);
}
let map = await this.iinvoiceprocessDao.mapByInvoiceIdsAndStatus(ids, statuses);
for (let item of list) {
let key = item.id + "_" + item.status;
let v = map[key] || {};
item.status_name = v.name;
item.next_status = JSON.parse(v.next_status || "[]");
}
console.log(list);
}
}
module.exports = IinvoicedelivererService;
\ No newline at end of file
module.exports = IinvoicedeliverService;
\ No newline at end of file
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