Commit daec2d04 by zhaoxiqing

gsb

parent 6412071d
......@@ -11,7 +11,8 @@ class ActionAPI extends APIBase {
this.iproductSve = system.getObject("service.product.iproductSve");
this.iprocessSve = system.getObject("service.product.iprocessSve");
this.saasinvoiceSve = system.getObject("service.invoice.saasinvoiceSve")
this.saasinvoiceSve = system.getObject("service.invoice.saasinvoiceSve");
this.saasinvoiceapplySve = system.getObject("service.invoice.saasinvoiceapplySve");
}
/**
* 接口跳转
......@@ -62,7 +63,12 @@ class ActionAPI extends APIBase {
case "platforminvoicePage" : //发票列表(平台)
opResult = await this.saasinvoiceSve.platforminvoicePage(action_body);
break;
case "merchantinvoiceapplyPage" :
opResult = await this.saasinvoiceapplySve.merchantinvoiceapplyPage(action_body);
break;
case "platforminvoiceapplyPage" : //发票列表(平台)
opResult = await this.saasinvoiceapplySve.platforminvoiceapplyPage(action_body);
break;
// case "verificationAndCalculation": // 发票试算接口
// opResult = await rule.dispatcher(action_body);
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class SaasinvoiceapplyDao extends Dao {
constructor() {
super(Dao.getModelName(SaasinvoiceapplyDao));
}
async countByParams(params) {
var sql = [];
sql.push("SELECT COUNT(1) as total FROM saas_invoice_apply t1 WHERE 1 = 1");
this.setCondition(params, sql);
var counts = await this.customQuery(sql.join(" "), params);
if (!counts || counts.length == 0) {
return 0;
}
return counts[0].total || 0;
}
async pageByParams(params, startRow, pageSize) {
var sql = [];
sql.push("SELECT * FROM saas_invoice_apply t1 WHERE 1 = 1 ");
this.setCondition(params, sql);
sql.push("ORDER BY t1.id DESC");
sql.push("LIMIT :startRow, :pageSize");
params.startRow = startRow || 0;
params.pageSize = pageSize || 10;
return await this.customQuery(sql.join(" "), params);
}
setCondition(params, sql) {
if(params.saas_merchant_id){
sql.push("AND t1.`saas_merchant_id` = :saas_merchant_id");
}
if (params.apply_no) {
sql.push("AND t1.`apply_no` = :apply_no");
}
if (params.begin_time) {
sql.push("AND t1.`created_at` >= :begin_time");
}
if (params.end_time) {
sql.push("AND t1.`created_at` <= :end_time");
}
};
}
module.exports = SaasinvoiceapplyDao;
......@@ -3,51 +3,51 @@
module.exports = function (sequelize, DataTypes) {
return sequelize.define('saasinvoice', {
id: {
type: DataTypes.STRING(32),
type: DataTypes.STRING,
allowNull: false,
primaryKey: true
},
saas_id: {
type: DataTypes.STRING(32),
type: DataTypes.STRING,
allowNull: true
},
saas_merchant_id: {
type: DataTypes.STRING(32),
type: DataTypes.STRING,
allowNull: true,
defaultValue: ''
},
batch_no: {
type: DataTypes.STRING(32),
type: DataTypes.STRING,
allowNull: true
},
owner_type: {
type: DataTypes.STRING(4),
type: DataTypes.STRING,
allowNull: true,
defaultValue: '00'
},
fee_type: {
type: DataTypes.STRING(2),
type: DataTypes.STRING,
allowNull: true,
defaultValue: ''
},
invoice_type: {
type: DataTypes.STRING(4),
type: DataTypes.STRING,
allowNull: true
},
province: {
type: DataTypes.STRING(10),
type: DataTypes.STRING,
allowNull: true
},
invoice_join: {
type: DataTypes.STRING(4),
type: DataTypes.STRING,
allowNull: true
},
invoice_no: {
type: DataTypes.STRING(20),
type: DataTypes.STRING,
allowNull: true
},
invoice_number: {
type: DataTypes.STRING(20),
type: DataTypes.STRING,
allowNull: true
},
invoice_time: {
......@@ -59,76 +59,76 @@ module.exports = function (sequelize, DataTypes) {
allowNull: true
},
sve_invoice_id: {
type: DataTypes.STRING(32),
type: DataTypes.STRING,
allowNull: true,
defaultValue: ''
},
apply_no: {
type: DataTypes.STRING(32),
type: DataTypes.STRING,
allowNull: true
},
from_name: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
from_credit_code: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
from_addr: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
from_mobile: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
from_bank: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
from_account: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
to_name: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
to_credit_code: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
to_addr: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
to_mobile: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
to_bank: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
to_account: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: false
},
mail_to: {
type: DataTypes.STRING(45),
type: DataTypes.STRING,
allowNull: true
},
mail_mobile: {
type: DataTypes.STRING(20),
type: DataTypes.STRING,
allowNull: true
},
mail_addr: {
type: DataTypes.STRING(200),
type: DataTypes.STRING,
allowNull: true
},
personal_invoice_tax: {
type: DataTypes.INTEGER(11),
type: DataTypes.INTEGER,
allowNull: true
},
additional_tax: {
......@@ -166,6 +166,6 @@ module.exports = function (sequelize, DataTypes) {
paranoid: true,
version: true,
tableName: 'saas_invoice',
comment: '发票列表(商户)',
comment: '发票列表',
});
};
/* jshint indent: 2 */
module.exports = function (sequelize, DataTypes) {
return sequelize.define('saasinvoiceapply', {
id: {
type: DataTypes.STRING,
allowNull: false,
primaryKey: true
},
saas_id: {
type: DataTypes.STRING,
allowNull: true
},
saas_merchant_id: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: ''
},
batch_no: {
type: DataTypes.STRING,
allowNull: true
},
owner_type: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: '00'
},
fee_type: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: ''
},
invoice_type: {
type: DataTypes.STRING,
allowNull: true
},
status: {
type: DataTypes.STRING,
allowNull: true
},
sve_invoice_id: {
type: DataTypes.STRING,
allowNull: true,
defaultValue: ''
},
apply_no: {
type: DataTypes.STRING,
allowNull: true
},
from_name: {
type: DataTypes.STRING,
allowNull: false
},
from_credit_code: {
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
},
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
},
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
},
version: {
type: DataTypes.INTEGER,
allowNull: false,
defaultValue: '0'
}
}, {
timestamps: false,
paranoid: true,
version: true,
tableName: 'saas_invoice_apply',
comment: '发票申请列表',
});
};
const ServiceBase = require("../../sve.base");
const system = require("../../../system");
const moment = require('moment');
/**
* 平台提交的信息
*/
class SaasinvoiceapplyService extends ServiceBase {
constructor() {
super("invoice", ServiceBase.getDaoName(SaasinvoiceapplyService));
this.dictionary = system.getObject("util.dictionary");
}
async merchantinvoiceapplyPage(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = Number((params.currentPage - 1) * params.pageSize);
let total = await this.dao.countByParams(params);
if (total == 0) {
return system.getResult({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, ['invoice_time'], 'YYYY-MM-DD');
this.dictionary.setRowName("SAAS_INVOICE_APPLY",item,["owner_type","fee_type","invoice_type","invoice_join"]);
}
}
return system.getResultSuccess({count: total, rows: list});
}
async platforminvoiceapplyPage(params) {
params.currentPage = Number(params.currentPage || 1);
params.pageSize = Number(params.pageSize || 10);
params.startRow = Number((params.currentPage - 1) * params.pageSize);
let total = await this.dao.countByParams(params);
if (total == 0) {
return system.getResult({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, ['invoice_time'], 'YYYY-MM-DD');
this.dictionary.setRowName("SAAS_INVOICE_APPLY",item,["owner_type","fee_type","invoice_type","invoice_join"]);
}
}
return system.getResultSuccess({count: total, rows: list});
}
}
module.exports = SaasinvoiceapplyService;
const system = require("../system");
class Dictionary {
constructor() {
this.SAAS_INTEVOICE = {
owner_type: {"00": "商户发票", "10": "平台发票"},
fee_type: {"00": "注册订单费用", "10": "平台转账费用", "20": "商户转账费用"},
invoice_type :{"10" : "增值税专用发票", "20":" 增值税普通发票", "30" :"普通发票"},
invoice_join : {"10":"记账联","20":"发票联","30":"抵扣联","40":"销售方次"},
};
// this.SAAS_INVOICE_APPLY = {
// trade_status: {"00": "成功", "01": "待处理", "02": "失败"}
// }
}
getDict(module, field) {
return (this[(module || "")] || {})[field] || {};
}
// setRowName("ORDER", order, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]);
setRowName(module, row, fields) {
if(!module || !row || !fields || fields.length == 0) {
return;
constructor() {
this.SAAS_INTEVOICE = {
owner_type: {"00": "商户发票", "10": "平台发票"},
fee_type: {"00": "注册订单费用", "10": "平台转账费用", "20": "商户转账费用"},
invoice_type: {"10": "增值税专用发票", "20": " 增值税普通发票", "30": "普通发票"},
invoice_join: {"10": "记账联", "20": "发票联", "30": "抵扣联", "40": "销售方次"},
};
this.SAAS_INVOICE_APPLY = {
owner_type: {"00": "商户发票", "10": "平台发票"},
fee_type: {"00": "注册订单费用", "10": "平台转账费用", "20": "商户转账费用"},
invoice_type: {"10": "增值税专用发票", "20": " 增值税普通发票", "30": "普通发票"},
}
}
for (let field of fields) {
row[field] = this.getDict(module, field)[row[field] || ""] || "";
getDict(module, field) {
return (this[(module || "")] || {})[field] || {};
}
}
// setRowsName("ORDER", orders, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]);
setRowsName(module, rows, fields, concat) {
if(!module || !rows || !fields || fields.length == 0) {
return;
//调用方法: setRowName("ORDER", order, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]);
setRowName(module, row, fields) {
if (!module || !row || !fields || fields.length == 0) {
return;
}
for (let field of fields) {
row[field] = this.getDict(module, field)[row[field] || ""] || "";
}
}
for(let row of rows) {
this.setRowName(module, row, fields, concat)
// setRowsName("ORDER", orders, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]);
setRowsName(module, rows, fields) {
if (!module || !rows || !fields || fields.length == 0) {
return;
}
for (let row of rows) {
this.setRowName(module, row, fields)
}
}
}
}
module.exports = Dictionary;
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