Commit 4e16b406 by 王昆

gsb

parent ce817a76
...@@ -31,88 +31,107 @@ class ActionAPI extends APIBase { ...@@ -31,88 +31,107 @@ class ActionAPI extends APIBase {
async sjbOpActionProcess(action_process, action_type, action_body) { async sjbOpActionProcess(action_process, action_type, action_body) {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
case "invoiceApply": // 发票申请
case "verificationAndCalculation": // 发票试算接口
opResult = await rule.dispatcher(action_body); opResult = await rule.dispatcher(action_body);
break; break;
case "calculationValueAddedTax": // 计算增值税 case "invoicePage": // 发票申请列表页(平台)
let calValueAddedTax = new Calculation(action_body); opResult = await rule.dispatcher(action_body);
let vaInvoice = calValueAddedTax.getInvoice();
opResult = await vaInvoice.doActionValueAddedTax(action_body);
break; break;
case "calculationAdditionalTax": // 计算附加税 case "deliverInvoicePage": // 发票申请列表页(交付商)
let calAdditionalTax = new Calculation(action_body); opResult = await rule.dispatcher(action_body);
let addinvoice = calAdditionalTax.getInvoice();
opResult = await addinvoice.doActionAddtitionalTax(action_body);
break; break;
case "saveInvoice": // 发票保存 case "handleStatus": //进度处理
opResult = await this.applySve.apiSaveInvoice(action_body);
break; break;
case "queryTxPayment": //查看完税证明
opResult = await this.invoiceSve.apiQueryTxPayment(action_body); case "productDics": // 查询产品字典
opResult = await this.oproductSve.productDics(action_body);
break; break;
case "apiCancelInvoice": // 发票申请单撤回
opResult = await this.applySve.apiCancelInvoice(action_body); case "allProcess": // 查询业务进度
opResult = await this.oprocessSve.allNames(action_body);
break; break;
case "queryApplyInvoices": // 发票申请列表(平台) // case "verificationAndCalculation": // 发票试算接口
opResult = await this.applySve.apiQueryApplyInvoices(action_body); // opResult = await rule.dispatcher(action_body);
break; // break;
case "queryInvoices": // 发票列表(平台) // case "calculationValueAddedTax": // 计算增值税
opResult = await this.invoiceSve.apiQueryInvoices(action_body); // let calValueAddedTax = new Calculation(action_body);
break; // let vaInvoice = calValueAddedTax.getInvoice();
case "queryInvoice": // 发票明细(平台) // opResult = await vaInvoice.doActionValueAddedTax(action_body);
opResult = await this.applySve.apiQueryInvoice(action_body); // break;
break; // case "calculationAdditionalTax": // 计算附加税
case "platformAssignment": // 平台审批 // let calAdditionalTax = new Calculation(action_body);
opResult = await this.applySve.apiAssignment(action_body); // let addinvoice = calAdditionalTax.getInvoice();
break; // opResult = await addinvoice.doActionAddtitionalTax(action_body);
case "examineAndVerify": //审批(v2) // break;
opResult = await this.context.request(action_body); // case "saveInvoice": // 发票保存
break; // opResult = await this.applySve.apiSaveInvoice(action_body);
case "updateEmail": //平台更新邮寄地址 // break;
opResult = await this.delivererSve.apiUpEmNo(action_body); // case "queryTxPayment": //查看完税证明
break; // opResult = await this.invoiceSve.apiQueryTxPayment(action_body);
case "queryProcess": // 查看业务办理(平台) // break;
opResult = await this.delivererSve.apiQueryProcess(action_body); // case "apiCancelInvoice": // 发票申请单撤回
break; // opResult = await this.applySve.apiCancelInvoice(action_body);
case "redRushInvoice": //红冲 // break;
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;
case "statBusinessData": //发票办理
opResult = await this.applySve.apiStatBusinessData(action_body);
break;
case "statDeliverData": //交付商业务概览
opResult = await this.delivererSve.apiStatDeliverData(action_body);
break;
case "delivererApplyInvoices": //发票申请列表(交付商) // case "queryApplyInvoices": // 发票申请列表(平台)
opResult = await this.delivererSve.apiDelivererApplyInvoices(action_body); // opResult = await this.applySve.apiQueryApplyInvoices(action_body);
break; // break;
case "delivererInvoices": //发票列表(交付商) // case "queryInvoices": // 发票列表(平台)
opResult = await this.delivererSve.apiDelInvs(action_body); // opResult = await this.invoiceSve.apiQueryInvoices(action_body);
break; // break;
case "queryInvoiceDeliverer": // 发票明细(交付商) // case "queryInvoice": // 发票明细(平台)
opResult = await this.delivererSve.apiQueryInvoiceDeliverer(action_body); // opResult = await this.applySve.apiQueryInvoice(action_body);
break; // break;
case "delivererAssignment": //交付商审批 // case "platformAssignment": // 平台审批
opResult = await this.delivererSve.apiAssignment(action_body); // opResult = await this.applySve.apiAssignment(action_body);
break; // break;
case "txPayment": //完税证明更新 // case "examineAndVerify": //审批(v2)
opResult = await this.invoiceSve.apiTxPayment(action_body); // opResult = await this.context.request(action_body);
break; // break;
case "delStatTransData": //交易数据(交付商) // case "updateEmail": //平台更新邮寄地址
opResult = await this.delivererSve.apiDelStatTransData(action_body); // opResult = await this.delivererSve.apiUpEmNo(action_body);
break; // break;
case "delStatBusinessData": //发票办理(交付商) // case "queryProcess": // 查看业务办理(平台)
opResult = await this.delivererSve.apiDelStatBusinessData(action_body); // opResult = await this.delivererSve.apiQueryProcess(action_body);
break; // break;
// 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;
// case "statBusinessData": //发票办理
// opResult = await this.applySve.apiStatBusinessData(action_body);
// break;
// case "statDeliverData": //交付商业务概览
// opResult = await this.delivererSve.apiStatDeliverData(action_body);
// break;
// case "delivererApplyInvoices": //发票申请列表(交付商)
// opResult = await this.delivererSve.apiDelivererApplyInvoices(action_body);
// break;
// case "delivererInvoices": //发票列表(交付商)
// opResult = await this.delivererSve.apiDelInvs(action_body);
// break;
// case "queryInvoiceDeliverer": // 发票明细(交付商)
// opResult = await this.delivererSve.apiQueryInvoiceDeliverer(action_body);
// break;
// case "delivererAssignment": //交付商审批
// opResult = await this.delivererSve.apiAssignment(action_body);
// break;
// case "txPayment": //完税证明更新
// opResult = await this.invoiceSve.apiTxPayment(action_body);
// break;
// case "delStatTransData": //交易数据(交付商)
// opResult = await this.delivererSve.apiDelStatTransData(action_body);
// break;
// case "delStatBusinessData": //发票办理(交付商)
// opResult = await this.delivererSve.apiDelStatBusinessData(action_body);
// break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
......
const ServiceBase = require("../../sve.base");
const system = require("../../../system");
const moment = require('moment')
/**
* 交付商 提交的信息
*/
class InvoiceService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(InvoiceService));
let is = system.getObject("util.invoiceStatus");
this.invoiceStatus = is.status;
this.applyDao = system.getObject("db.invoice.applyDao");
this.delivererDao = system.getObject("db.invoice.delivererDao");
}
// /**
// * 完税证明
// * @param {*} params
// */
// async apiTxPayment(params) {
// if (!params.id) {
// return system.getResult(null, `参数错误 发票ID不合法`);
// }
// try {
// let res = await this.txPayment(params);
// return res;
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 查看完税证明
// * @param {*} params
// */
// async apiQueryTxPayment(params) {
// if (!params.id) {
// return system.getResult(null, `参数错误 发票ID不合法`);
// }
// try {
// return await this.queryTxPayment(params);
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 发票列表(平台)
// * @param {*} params
// */
// async apiQueryInvoices(params) {
// try {
// if(params.applyNo){params.applyNo=this.trim(params.applyNo)}
// if(params.type){params.type=this.trim(params.type);}
// if(params.invoiceTime){params.invoiceTime=this.trim(params.invoiceTime);}
// return await this.queryInvoices(params);
// } catch (error) {
// return system.getResult(null, `系统错误 错误信息 ${error}`);
// }
// }
// /**
// * 发票红冲列表
// * @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
// * {
// * id:xxx //完税证明
// * }
// */
// async txPayment(params) {
// try {
// let _invoice = await this.dao.findOne({
// id: this.trim(params.id)
// });
// if (!_invoice) {
// return system.getResult(null, `发票不存在`);
// }
// let res = await this.dao.update({
// id: this.trim(params.id),
// taxNo: this.trim(params.taxNo),
// complateTax: 1,
// taxTime: this.trim(params.taxTime),
// taxVoucher: this.trim(params.taxVoucher)
// });
// return system.getResult(res);
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 查看完税证明
// * @param {*} params
// * {
// * id:xxx //完税证明
// * }
// */
// async queryTxPayment(params) {
// try {
// let _invoice = await this.dao.model.findOne({
// where: {
// id: this.trim(params.id),
// complateTax: 1
// },
// attributes: ['id', 'taxNo', 'complateTax', 'taxTime', 'taxVoucher']
// });
// if (!_invoice) {
// return system.getResult(null, `完税证明不存在`);
// }
// return system.getResult(_invoice);
// } catch (error) {
// return system.getResult(null, `参数错误 错误信息 ${error}`);
// }
// }
// /**
// * 发票列表查询(平台)
// * @param {*} params
// * @param applyNo 发票的申请编号
// * @param invoiceTime 发票的申请时间
// * @param type 发票的类型
// * @param status 业务进度
// */
// async queryInvoices(params) {
// try {
// var pageIndex = Number(params.pageIndex || 1);
// var pageSize = Number(params.pageSize || 10);
// var total = await this.dao.countByParams(params);
// if (total == 0) {
// return system.getResultSuccess({
// count: 0,
// rows: []
// });
// }
// var startRow = (pageIndex - 1) * pageSize;
// var list = await this.dao.pageByParams(params, startRow, pageSize);
// await this.setApply(list);
// for (var item of list) {
// // item.redStatusName = this.dao.getRowCodeName(item, "red_status");
// if (item.red_status == 1) {
// item.red_status = '未红冲';
// } else if (item.red_status == 2) {
// item.red_status = '红冲中';
// } else if (item.red_status == 3) {
// item.red_status = '红冲失败'
// } else if (item.red_status == 4) {
// item.red_status = '红冲成功';
// } else {
// item.red_status = '';
// }
// this.dao.getRowCodeName(item.apply,"status");
// item.complate_tax = item.complate_tax == 1 ? '已完税' : '未完税';
// item.month = moment(item.invoice_time).month() + 1;
// this.handleDate(item,['invoice_time'],null,-8);
// if (item.apply['type'] == '10') {
// item.apply['type'] = "普通发票";
// } else if (item.apply['type'] == '20') {
// item.apply['type'] = "增值税专用发票";
// } else {
// item.apply['type'] = "电子发票";
// }
// }
// var page = {
// count: total,
// rows: list
// };
// return system.getResultSuccess(page);
// } catch (error) {
// console.log(error);
// return system.getResult(`系统错误 错误信息 ${error}`);
// }
// }
// async setApply(list) {
// if (!list || list.length == 0) {
// return;
// }
// var ids = [];
// for (var item of list) {
// ids.push(item.id);
// }
// var applyMap = await this.applyDao.findMapByIds(ids) || {};
// for (var item of list) {
// item.apply = applyMap[item.id] || {};
// }
// }
}
module.exports = InvoiceService;
\ No newline at end of file
const ServiceBase = require("../../sve.base");
const system = require("../../../system");
const moment = require('moment')
/**
* 交付商 提交的信息
*/
class InvoiceService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(InvoiceService));
let is = system.getObject("util.invoiceStatus");
this.invoiceStatus = is.status;
this.applyDao = system.getObject("db.invoice.applyDao");
this.delivererDao = system.getObject("db.invoice.delivererDao");
}
/**
* 完税证明
* @param {*} params
*/
async apiTxPayment(params) {
if (!params.id) {
return system.getResult(null, `参数错误 发票ID不合法`);
}
try {
let res = await this.txPayment(params);
return res;
} catch (error) {
return system.getResult(null, `参数错误 错误信息 ${error}`);
}
}
/**
* 查看完税证明
* @param {*} params
*/
async apiQueryTxPayment(params) {
if (!params.id) {
return system.getResult(null, `参数错误 发票ID不合法`);
}
try {
return await this.queryTxPayment(params);
} catch (error) {
return system.getResult(null, `参数错误 错误信息 ${error}`);
}
}
/**
* 发票列表(平台)
* @param {*} params
*/
async apiQueryInvoices(params) {
try {
if(params.applyNo){params.applyNo=this.trim(params.applyNo)}
if(params.type){params.type=this.trim(params.type);}
if(params.invoiceTime){params.invoiceTime=this.trim(params.invoiceTime);}
return await this.queryInvoices(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 发票红冲列表
* @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
* {
* id:xxx //完税证明
* }
*/
async txPayment(params) {
try {
let _invoice = await this.dao.findOne({
id: this.trim(params.id)
});
if (!_invoice) {
return system.getResult(null, `发票不存在`);
}
let res = await this.dao.update({
id: this.trim(params.id),
taxNo: this.trim(params.taxNo),
complateTax: 1,
taxTime: this.trim(params.taxTime),
taxVoucher: this.trim(params.taxVoucher)
});
return system.getResult(res);
} catch (error) {
return system.getResult(null, `参数错误 错误信息 ${error}`);
}
}
/**
* 查看完税证明
* @param {*} params
* {
* id:xxx //完税证明
* }
*/
async queryTxPayment(params) {
try {
let _invoice = await this.dao.model.findOne({
where: {
id: this.trim(params.id),
complateTax: 1
},
attributes: ['id', 'taxNo', 'complateTax', 'taxTime', 'taxVoucher']
});
if (!_invoice) {
return system.getResult(null, `完税证明不存在`);
}
return system.getResult(_invoice);
} catch (error) {
return system.getResult(null, `参数错误 错误信息 ${error}`);
}
}
/**
* 发票列表查询(平台)
* @param {*} params
* @param applyNo 发票的申请编号
* @param invoiceTime 发票的申请时间
* @param type 发票的类型
* @param status 业务进度
*/
async queryInvoices(params) {
try {
var pageIndex = Number(params.pageIndex || 1);
var pageSize = Number(params.pageSize || 10);
var total = await this.dao.countByParams(params);
if (total == 0) {
return system.getResultSuccess({
count: 0,
rows: []
});
}
var startRow = (pageIndex - 1) * pageSize;
var list = await this.dao.pageByParams(params, startRow, pageSize);
await this.setApply(list);
for (var item of list) {
// item.redStatusName = this.dao.getRowCodeName(item, "red_status");
if (item.red_status == 1) {
item.red_status = '未红冲';
} else if (item.red_status == 2) {
item.red_status = '红冲中';
} else if (item.red_status == 3) {
item.red_status = '红冲失败'
} else if (item.red_status == 4) {
item.red_status = '红冲成功';
} else {
item.red_status = '';
}
this.dao.getRowCodeName(item.apply,"status");
item.complate_tax = item.complate_tax == 1 ? '已完税' : '未完税';
item.month = moment(item.invoice_time).month() + 1;
this.handleDate(item,['invoice_time'],null,-8);
if (item.apply['type'] == '10') {
item.apply['type'] = "普通发票";
} else if (item.apply['type'] == '20') {
item.apply['type'] = "增值税专用发票";
} else {
item.apply['type'] = "电子发票";
}
}
var page = {
count: total,
rows: list
};
return system.getResultSuccess(page);
} catch (error) {
console.log(error);
return system.getResult(`系统错误 错误信息 ${error}`);
}
}
async setApply(list) {
if (!list || list.length == 0) {
return;
}
var ids = [];
for (var item of list) {
ids.push(item.id);
}
var applyMap = await this.applyDao.findMapByIds(ids) || {};
for (var item of list) {
item.apply = applyMap[item.id] || {};
}
}
}
module.exports = InvoiceService;
\ 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