Commit be547d98 by 孙亚楠

dd

parent 6c8ff34a
......@@ -60,7 +60,9 @@ class ActionAPI extends APIBase {
case "accumulatedAmount": // 查询累计金额
opResult = await this.iinvoiceSve.accumulatedAmount(action_body);
break;
case "saveSaasInvoice": // 保存saasInvoice 信息
opResult = await this.saasinvoiceSve.saveSaasInvoice(action_body);
break;
case "merchantinvoicePage" : //发票列表(商户)
opResult = await this.saasinvoiceSve.merchantinvoicePage(action_body);
......
......@@ -50,7 +50,8 @@ module.exports = (db, DataTypes) => {
status: {type: DataTypes.INTEGER, field: 'status', allowNull: true,comment:'订单状态 业务进度' },
red_status: {type: DataTypes.STRING, field: 'red_status', allowNull: true,comment:'1 未红冲 2 已红冲 3 红冲中' },
bookkeeping: {type: DataTypes.STRING, field: 'bookkeeping', allowNull: true, defaultValue:0, comment:'是否记账 0未记账 1已记账' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
saas_deliver_api: {type: DataTypes.STRING, field: 'saas_deliver_api', allowNull: true, defaultValue:'', comment:'saas系统状态通知api' },
created_at: { type: DataTypes.DATE, field: 'created_at', allowNull: false, defaultValue: DataTypes.NOW },
updated_at: { type: DataTypes.DATE, field: 'updated_at', allowNull: false, defaultValue: DataTypes.NOW },
deleted_at: { type: DataTypes.DATE, allowNull: true },
}, {
......
......@@ -8,7 +8,8 @@ const moment = require('moment');
class SaasinvoiceService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(SaasinvoiceService));
this.dictionary = system.getObject("util.dictionary");
this.dictionary = system.getObject("util.dictionary");
this.saasinvoiceapplyDao = system.getObject("db.invoice.saasinvoiceapplyDao");
}
async merchantinvoicePage(params) {
......@@ -18,7 +19,7 @@ class SaasinvoiceService extends ServiceBase {
let total = await this.dao.countByParams(params);
if (total == 0) {
return system.getResult({count: 0, rows: []});
return system.getResult({ count: 0, rows: [] });
}
let list = await this.dao.pageByParams(params);
......@@ -26,10 +27,10 @@ class SaasinvoiceService extends ServiceBase {
for (var item of list) {
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
this.handleDate(item, ['invoice_time'], 'YYYY-MM-DD');
this.dictionary.setRowName("SAAS_INTEVOICE",item,["owner_type","fee_type","invoice_type","invoice_join"]);
this.dictionary.setRowName("SAAS_INTEVOICE", item, ["owner_type", "fee_type", "invoice_type", "invoice_join"]);
}
}
return system.getResultSuccess({count: total, rows: list});
return system.getResultSuccess({ count: total, rows: list });
}
async platforminvoicePage(params) {
......@@ -39,7 +40,7 @@ class SaasinvoiceService extends ServiceBase {
let total = await this.dao.countByParams(params);
if (total == 0) {
return system.getResult({count: 0, rows: []});
return system.getResult({ count: 0, rows: [] });
}
let list = await this.dao.pageByParams(params);
......@@ -47,12 +48,93 @@ class SaasinvoiceService extends ServiceBase {
for (var item of list) {
this.handleDate(item, ['updated_at', 'created_at'], 'YYYY-MM-DD HH:mm:ss');
this.handleDate(item, ['invoice_time'], 'YYYY-MM-DD');
this.dictionary.setRowName("SAAS_INTEVOICE",item,["owner_type","fee_type","invoice_type","invoice_join"]);
this.dictionary.setRowName("SAAS_INTEVOICE", item, ["owner_type", "fee_type", "invoice_type", "invoice_join"]);
}
}
return system.getResultSuccess({count: total, rows: list});
return system.getResultSuccess({ count: total, rows: list });
}
/**
* 保存saas发票记录
* @param {*} params
*/
async saveSaasInvoice(params) {
try {
let invoiceApply = await this.saasinvoiceapplyDao.findById(params.apply_no);
if (!invoiceApply) {
console.log(`${params.apply_no}发票申请不存在`);
return system.getResult(null, `发票申请不存在`);
}
let saasinvoice = {};
this.setInvoiceProperty(saasinvoice, params.invoicesummaryinfo);
saasinvoice.id = invoiceApply.id;
saasinvoice.saas_id = invoiceApply.saas_id;
saasinvoice.saas_merchant_id = invoiceApply.saas_merchant_id;
saasinvoice.batch_no = invoiceApply.batch_no;
saasinvoice.owner_type = invoiceApply.owner_type;
saasinvoice.fee_type = invoiceApply.fee_type;
saasinvoice.service_tax = invoiceApply.service_tax;
saasinvoice.invoice_type = invoiceApply.invoice_type;
saasinvoice.additional_tax = params.additional_tax;
saasinvoice.personal_invoice_tax =params.personal_invoice_tax;
saasinvoice.value_added_tax = params.value_added_tax;
saasinvoice.invoice_amount = params.invoice_amount;
saasinvoice.invoice_img = params.invoice_img;
saasinvoice.apply_no = params.apply_no;
saasinvoice.sve_invoice_id = params.deliver_id;
saasinvoice.mail_addr = params.invoiceinforeg.deliver_mail_addr;
saasinvoice.mail_no = params.invoiceinforeg.deliver_mail_no;
saasinvoice.mail_to = params.invoiceinforeg.deliver_mail_to;
saasinvoice.mail_mobile = params.invoiceinforeg.deliver_mail_mobile;
await this.dao.create(saasinvoice);
return system.getResultSuccess();
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误`);
}
}
setInvoiceProperty(saasinvoice, params) {
for (let key in params) {
if (key == "id" || key == "created_at" || key == "updated_at" || key == "deleted_at" || key == "version") {
continue;
}
if(key == "businessmen_name"){
saasinvoice["from_name"] = params[key];
}else if(key == "businessmen_credit_code"){
saasinvoice["from_credit_code"] = params[key];
}else if(key == "businessmen_addr"){
saasinvoice["from_addr"] = params[key];
}else if(key == "businessmen_mobile"){
saasinvoice["from_mobile"] = params[key];
}else if(key == "businessmen_bank"){
saasinvoice["from_bank"] = params[key];
}else if(key == "businessmen_account"){
saasinvoice["from_account"] = params[key];
}else if(key == "merchant_name"){
saasinvoice["to_name"] = params[key];
}else if(key == "merchant_credit_code"){
saasinvoice["to_credit_code"] = params[key];
}else if(key == "merchant_addr"){
saasinvoice["to_addr"] = params[key];
}else if(key == "merchant_mobile"){
saasinvoice["to_mobile"] = params[key];
}else if(key == "merchant_bank"){
saasinvoice["to_bank"] = params[key];
}else if(key == "merchant_account"){
saasinvoice["to_account"] = params[key];
}else if(key == "summary"){
saasinvoice['summary']=JSON.stringify(params['summary']);
}else{
saasinvoice[key] = params[key];
}
}
return saasinvoice;
}
}
......
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