Commit 93a17dd0 by 王昆

gsb

parent d4d4ebd8
...@@ -5,10 +5,11 @@ class ActionAPI extends APIBase { ...@@ -5,10 +5,11 @@ class ActionAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.iinvoiceSve = system.getObject("service.invoice.iinvoiceSve"); this.iinvoiceSve = system.getObject("service.invoice.iinvoiceSve");
this.iinvoicedeliverSve = system.getObject("service.invoice.iinvoicedeliverSve");
this.iproductSve = system.getObject("service.product.iproductSve"); this.iproductSve = system.getObject("service.product.iproductSve");
this.iprocessSve = system.getObject("service.product.iprocessSve"); this.iprocessSve = system.getObject("service.product.iprocessSve");
} }
/** /**
* 接口跳转 * 接口跳转
...@@ -36,7 +37,7 @@ class ActionAPI extends APIBase { ...@@ -36,7 +37,7 @@ class ActionAPI extends APIBase {
opResult = await this.iinvoiceSve.invoicePage(action_body); opResult = await this.iinvoiceSve.invoicePage(action_body);
break; break;
case "deliverInvoicePage": // 发票申请列表页(交付商) case "deliverInvoicePage": // 发票申请列表页(交付商)
opResult = await this.iinvoiceSve.deliverInvoicePage(action_body); opResult = await this.iinvoicedeliverSve.invoicePage(action_body);
break; break;
case "handleStatus": //进度处理 case "handleStatus": //进度处理
break; break;
......
...@@ -30,7 +30,7 @@ class IInvoiceDao extends Dao { ...@@ -30,7 +30,7 @@ class IInvoiceDao extends Dao {
this.setCondition(params, sql); this.setCondition(params, sql);
sql.push("ORDER BY id DESC"); sql.push("ORDER BY t1.id DESC");
sql.push("LIMIT :startRow, :pageSize"); sql.push("LIMIT :startRow, :pageSize");
params.startRow = startRow || 0; params.startRow = startRow || 0;
params.pageSize = pageSize || 10; params.pageSize = pageSize || 10;
...@@ -39,16 +39,16 @@ class IInvoiceDao extends Dao { ...@@ -39,16 +39,16 @@ class IInvoiceDao extends Dao {
setCondition(params, sql) { setCondition(params, sql) {
if(params.apply_no) { if(params.apply_no) {
sql.push("AND t2.`apply_no` = :apply_no"); sql.push("AND t1.`apply_no` = :apply_no");
} }
if(params.status) { if(params.status) {
sql.push("AND t2.`status` = :status"); sql.push("AND t1.`status` = :status");
} }
if(params.statuses && params.statuses.length > 0){ 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) { if(params.invoice_type) {
sql.push("AND t2.`invoice_type` = :invoice_type"); sql.push("AND t1.`invoice_type` = :invoice_type");
} }
if(params.invoiceTimeBegin) { if(params.invoiceTimeBegin) {
sql.push("AND t1.`invoice_time` >= :invoiceTimeBegin"); sql.push("AND t1.`invoice_time` >= :invoiceTimeBegin");
...@@ -61,14 +61,14 @@ class IInvoiceDao extends Dao { ...@@ -61,14 +61,14 @@ class IInvoiceDao extends Dao {
sql.push("AND t1.`red_status` = :red_status"); sql.push("AND t1.`red_status` = :red_status");
} }
if(params.deliver_id) { if(params.deliver_id) {
sql.push("AND t2.`deliver_id` = :deliver_id"); sql.push("AND t1.`deliver_id` = :deliver_id");
} }
if(params.bd_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) { if(params.bd_path) {
params.bd_path_like = 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");
} }
} }
......
...@@ -33,12 +33,12 @@ module.exports = (db, DataTypes) => { ...@@ -33,12 +33,12 @@ module.exports = (db, DataTypes) => {
businessmen_account: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方银行账号' }, businessmen_account: { type: DataTypes.STRING(45), allowNull: false, COMMENT: '销售方银行账号' },
apply_no: { type: DataTypes.STRING(45), allowNull: true, defaultValue: "", COMMENT: '发票申请编号' }, apply_no: { type: DataTypes.STRING(45), allowNull: true, defaultValue: "", COMMENT: '发票申请编号' },
apply_time: { type: DataTypes.DATE, allowNull: true, defaultValue: null, 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: '开票内容' }, invoice_content: { type: DataTypes.STRING(300), allowNull: false, defaultValue: null, COMMENT: '开票内容' },
contract: { type: DataTypes.STRING(500), allowNull: true,delaultValue:"", COMMENT: '合同' }, contract: { type: DataTypes.STRING(500), allowNull: true,delaultValue:"", COMMENT: '合同' },
personal_invoice_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '个税' }, personal_invoice_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '个税' },
additional_tax: { type: DataTypes.INTEGER, allowNull: false, defaultValue: null, COMMENT: '附加税' }, additional_tax: { type: DataTypes.BIGINT, allowNull: false, defaultValue: null, COMMENT: '附加税' },
value_added_tax: { type: DataTypes.INTEGER, 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_addr: { type: DataTypes.STRING(200), allowNull: true, defaultValue: null, COMMENT: '邮寄地址' },
mail_mobile: { type: DataTypes.STRING(20), 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: '邮寄人' }, mail_to: { type: DataTypes.STRING(20), allowNull: true, defaultValue: null, COMMENT: '邮寄人' },
......
...@@ -144,7 +144,6 @@ class IInvoiceService extends ServiceBase { ...@@ -144,7 +144,6 @@ class IInvoiceService extends ServiceBase {
return system.getResult(null,`系统错误`); return system.getResult(null,`系统错误`);
} }
} }
async invoicePage(params) { async invoicePage(params) {
params.currentPage = Number(params.currentPage || 1); params.currentPage = Number(params.currentPage || 1);
...@@ -161,7 +160,7 @@ class IInvoiceService extends ServiceBase { ...@@ -161,7 +160,7 @@ class IInvoiceService extends ServiceBase {
for (var item of 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.setDeliver(list); await this.setDeliver(list);
//格式化业务员 //格式化业务员
await this.setStatus(list); await this.setStatus(list);
...@@ -172,7 +171,7 @@ class IInvoiceService extends ServiceBase { ...@@ -172,7 +171,7 @@ class IInvoiceService extends ServiceBase {
} }
/** /**
* 格式化订单产品 * 格式化产品
* @param {*} list * @param {*} list
*/ */
async setProduct(list) { async setProduct(list) {
......
...@@ -4,9 +4,82 @@ const moment = require('moment'); ...@@ -4,9 +4,82 @@ const moment = require('moment');
/** /**
* 平台提交的信息 * 平台提交的信息
*/ */
class IinvoicedelivererService extends ServiceBase { class IinvoicedeliverService extends ServiceBase {
constructor() { 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; module.exports = IinvoicedeliverService;
\ No newline at end of file \ 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