Commit 126153fd by 王昆

gsb

parent e78d9b7f
...@@ -75,6 +75,12 @@ class ActionAPI extends APIBase { ...@@ -75,6 +75,12 @@ class ActionAPI extends APIBase {
case "invoiceapplyById" : //发票申请列表(平台) case "invoiceapplyById" : //发票申请列表(平台)
opResult = await this.saasinvoiceapplySve.byId(action_body); opResult = await this.saasinvoiceapplySve.byId(action_body);
break; break;
case "invoiceapplyAudit" : //发票申请列表(平台)
opResult = await this.saasinvoiceapplySve.audit(action_body);
break;
case "invoiceapplyMakeOut" : //发票申请列表(平台)
opResult = await this.saasinvoiceapplySve.makeout(action_body);
break;
// case "verificationAndCalculation": // 发票试算接口 // case "verificationAndCalculation": // 发票试算接口
// opResult = await rule.dispatcher(action_body); // opResult = await rule.dispatcher(action_body);
......
/* jshint indent: 2 */ const system = require("../../../system");
const settings = require("../../../../config/settings");
module.exports = function (sequelize, DataTypes) { const uiconfig = system.getUiConfig2(settings.appKey);
return sequelize.define('saasinvoice', { module.exports = (db, DataTypes) => {
id: { return db.define("saasinvoice", {
type: DataTypes.STRING, saas_id: DataTypes.STRING,
allowNull: false, saas_merchant_id: DataTypes.STRING,
primaryKey: true parent_id: DataTypes.STRING,
}, batch_no: DataTypes.STRING,
saas_id: { owner_type: DataTypes.STRING,
type: DataTypes.STRING, fee_type: DataTypes.STRING,
allowNull: true invoice_type: DataTypes.STRING,
}, province: DataTypes.STRING,
saas_merchant_id: { invoice_join: DataTypes.STRING,
type: DataTypes.STRING, invoice_no: DataTypes.STRING,
allowNull: true, invoice_number: DataTypes.STRING,
defaultValue: '' invoice_time: DataTypes.DATE,
}, invoice_amount: DataTypes.BIGINT,
parent_id: { sve_invoice_id: DataTypes.STRING,
type: DataTypes.STRING, apply_no: DataTypes.STRING,
allowNull: true, from_name: DataTypes.STRING,
defaultValue: '' from_credit_code: DataTypes.STRING,
}, from_addr: DataTypes.STRING,
batch_no: { from_mobile: DataTypes.STRING,
type: DataTypes.STRING, from_bank: DataTypes.STRING,
allowNull: true from_account: DataTypes.STRING,
}, to_name: DataTypes.STRING,
owner_type: { to_credit_code: DataTypes.STRING,
type: DataTypes.STRING, to_addr: DataTypes.STRING,
allowNull: true, to_mobile: DataTypes.STRING,
defaultValue: '00' to_bank: DataTypes.STRING,
}, to_account: DataTypes.STRING,
fee_type: { mail_to: DataTypes.STRING,
type: DataTypes.STRING, mail_mobile: DataTypes.STRING,
allowNull: true, mail_addr: DataTypes.STRING,
defaultValue: '' mail_no: DataTypes.STRING,
}, personal_invoice_tax: DataTypes.INTEGER,
invoice_type: { additional_tax: DataTypes.BIGINT,
type: DataTypes.STRING, value_added_tax: DataTypes.BIGINT,
allowNull: true service_tax: DataTypes.BIGINT,
}, summary: DataTypes.STRING,
province: { }, {
type: DataTypes.STRING, paranoid: true, //假的删除
allowNull: true underscored: true,
}, version: true,
invoice_join: { freezeTableName: true,
type: DataTypes.STRING, //freezeTableName: true,
allowNull: true // define the table's name
}, tableName: 'saas_invoice',
invoice_no: { validate: {},
type: DataTypes.STRING, indexes: [
allowNull: true // Create a unique index on email
}, // {
invoice_number: { // unique: true,
type: DataTypes.STRING, // fields: ['email']
allowNull: true // },
}, //
invoice_time: { // // Creates a gin index on data with the jsonb_path_ops operator
type: DataTypes.DATE, // {
allowNull: true // fields: ['data'],
}, // using: 'gin',
invoice_amount: { // operator: 'jsonb_path_ops'
type: DataTypes.BIGINT, // },
allowNull: true //
}, // // By default index name will be [table]_[fields]
sve_invoice_id: { // // Creates a multi column partial index
type: DataTypes.STRING, // {
allowNull: true, // name: 'public_by_author',
defaultValue: '' // fields: ['author', 'status'],
}, // where: {
apply_no: { // status: 'public'
type: DataTypes.STRING, // }
allowNull: true // },
}, //
from_name: { // // A BTREE index with a ordered field
type: DataTypes.STRING, // {
allowNull: false // name: 'title_index',
}, // method: 'BTREE',
from_credit_code: { // fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
type: DataTypes.STRING, // }
allowNull: false ],
}, });
from_addr: { }
type: DataTypes.STRING,
allowNull: false
},
from_mobile: {
type: DataTypes.STRING,
allowNull: false
},
from_bank: {
type: DataTypes.STRING,
allowNull: false
},
from_account: {
type: DataTypes.STRING,
allowNull: false
},
to_name: {
type: DataTypes.STRING,
allowNull: false
},
to_credit_code: {
type: DataTypes.STRING,
allowNull: false
},
to_addr: {
type: DataTypes.STRING,
allowNull: false
},
to_mobile: {
type: DataTypes.STRING,
allowNull: false
},
to_bank: {
type: DataTypes.STRING,
allowNull: false
},
to_account: {
type: DataTypes.STRING,
allowNull: false
},
mail_to: {
type: DataTypes.STRING,
allowNull: true
},
mail_mobile: {
type: DataTypes.STRING,
allowNull: true
},
mail_addr: {
type: DataTypes.STRING,
allowNull: true
},
mail_no: {
type: DataTypes.STRING,
allowNull: true
},
personal_invoice_tax: {
type: DataTypes.INTEGER,
allowNull: true
},
additional_tax: {
type: DataTypes.BIGINT,
allowNull: true
},
value_added_tax: {
type: DataTypes.BIGINT,
allowNull: true
},
service_tax: {
type: DataTypes.BIGINT,
allowNull: true
},
summary: {
type: DataTypes.TEXT,
allowNull: true
},
created_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
updated_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
deleted_at: {
type: DataTypes.DATE,
allowNull: true
}
}, {
timestamps: false,
paranoid: true,
version: true,
tableName: 'saas_invoice',
comment: '发票列表',
});
};
...@@ -43,6 +43,10 @@ module.exports = function (sequelize, DataTypes) { ...@@ -43,6 +43,10 @@ module.exports = function (sequelize, DataTypes) {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true allowNull: true
}, },
audit_remark: {
type: DataTypes.STRING,
allowNull: true
},
sve_invoice_id: { sve_invoice_id: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
......
...@@ -8,6 +8,9 @@ const moment = require('moment'); ...@@ -8,6 +8,9 @@ const moment = require('moment');
class SaasinvoiceapplyService extends ServiceBase { class SaasinvoiceapplyService extends ServiceBase {
constructor() { constructor() {
super("invoice", ServiceBase.getDaoName(SaasinvoiceapplyService)); super("invoice", ServiceBase.getDaoName(SaasinvoiceapplyService));
this.saasinvoiceDao = system.getObject("db.invoice.saasinvoiceDao");
this.dictionary = system.getObject("util.dictionary"); this.dictionary = system.getObject("util.dictionary");
} }
async byId(params) { async byId(params) {
...@@ -67,6 +70,52 @@ class SaasinvoiceapplyService extends ServiceBase { ...@@ -67,6 +70,52 @@ class SaasinvoiceapplyService extends ServiceBase {
return system.getResultSuccess({count: total, rows: list}); return system.getResultSuccess({count: total, rows: list});
} }
async audit(params) {
let status = Number(params.status || 0);
let apply = await this.dao.findById(params.id);
if (!apply) {
return system.getResult(null, "发票申请不存在");
}
if (apply.status != "1000") {
return system.getResult(null, "发票申请已审核成功,不要重复审核");
}
apply.status = status ? "1010" : "1020";
apply.audit_remark = this.trim(params.remark);
await apply.save();
return system.getResultSuccess();
}
async makeout(params) {
let apply = await this.dao.findById(params.id);
if (!apply) {
return system.getResult(null, "发票申请不存在");
}
if (apply.status != "1010") {
return system.getResult(null, "发票已开具");
}
let invoice = {};
for (let idx in apply) {
if (idx == "created_at" || idx == "updated_at" || idx == "deleted_at" || idx == "version") {
continue;
}
invoice[idx] = apply[idx];
}
invoice.invoice_no = this.trim(params.invoice_no);
invoice.invoice_number = this.trim(params.invoice_number);
invoice.invoice_time = this.trim(params.invoice_time);
invoice.mail_no = this.trim(params.mail_no);
invoice.invoice_img = this.trim(params.invoice_img);
// await this.db.transaction(async t => {
// _invoice = await this.dao.create(_invoice, t);
// await this.iinvoiceprocessDao.model.bulkCreate(processList, { transaction: t });
// });
invoice = await this.saasinvoiceDao.create(invoice);
return system.getResultSuccess(invoice);
}
} }
......
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