Commit 221f00aa by 王昆

gsb

parent f286e654
...@@ -4,6 +4,8 @@ const CtlBase = require("../../ctl.base"); ...@@ -4,6 +4,8 @@ const CtlBase = require("../../ctl.base");
class TransactioninCtl extends CtlBase { class TransactioninCtl extends CtlBase {
constructor() { constructor() {
super("all", CtlBase.getServiceName(TransactioninCtl)); super("all", CtlBase.getServiceName(TransactioninCtl));
this.merchantaccountSve = system.getObject("service.all.merchantaccountSve");
} }
async allList(qobj){ async allList(qobj){
...@@ -11,6 +13,7 @@ class TransactioninCtl extends CtlBase { ...@@ -11,6 +13,7 @@ class TransactioninCtl extends CtlBase {
this.doTimeCondition(params, ["signBegin", "signEnd"]); this.doTimeCondition(params, ["signBegin", "signEnd"]);
try { try {
var page = await this.service.signPage(params); var page = await this.service.signPage(params);
await this.merchantaccountSve.setAccount(page.rows);
return system.getResult2(page); return system.getResult2(page);
} catch (e) { } catch (e) {
console.log(e); console.log(e);
......
...@@ -6,15 +6,19 @@ class electroniccontractDao extends Dao { ...@@ -6,15 +6,19 @@ class electroniccontractDao extends Dao {
super(Dao.getModelName(electroniccontractDao)); super(Dao.getModelName(electroniccontractDao));
} }
async statCount(companyNames) { async statCount(companyNames, sign_body) {
var result = {}; var result = {};
if(!companyNames || companyNames.length == 0) { if(!companyNames || companyNames.length == 0) {
return result; return result;
} }
var sql = "SELECT company_name, COUNT(1) AS num FROM `electronic_contract_info` WHERE company_name IN (:companyNames) GROUP BY company_name"; let and = [];
and.push("company_name IN (:companyNames)");
let list = await this.customQuery(sql, {companyNames: companyNames}); if (sign_body) {
and.push("AND sign_body = :sign_body");
}
var sql = `SELECT company_name, COUNT(1) AS num FROM electronic_contract_info WHERE ${and.join(" ")} GROUP BY company_name`;
let list = await this.customQuery(sql, {companyNames: companyNames, sign_body: sign_body});
if(!list || list.length == 0) { if(!list || list.length == 0) {
return result; return result;
} }
......
...@@ -6,14 +6,20 @@ class LoadDao extends Dao { ...@@ -6,14 +6,20 @@ class LoadDao extends Dao {
super(Dao.getModelName(LoadDao)); super(Dao.getModelName(LoadDao));
} }
async statCount(companyNames) { async statCount(companyNames, sign_body) {
var result = {}; var result = {};
if(!companyNames || companyNames.length == 0) { if(!companyNames || companyNames.length == 0) {
return result; return result;
} }
var sql = "SELECT company_name, COUNT(1) AS num FROM `load_info` WHERE company_name IN (:companyNames) GROUP BY company_name"; let and = [];
and.push("company_name IN (:companyNames)");
if (sign_body) {
and.push("AND sign_body = :sign_body");
}
var sql = `SELECT company_name, COUNT(1) AS num FROM load_info WHERE ${and.join(" ")} GROUP BY company_name`;
let list = await this.customQuery(sql, {companyNames: companyNames}); let list = await this.customQuery(sql, {companyNames: companyNames, sign_body: sign_body});
if(!list || list.length == 0) { if(!list || list.length == 0) {
return result; return result;
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class MerchantAccountDao extends Dao {
constructor() {
super(Dao.getModelName(MerchantAccountDao));
}
async listByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
var sql = [];
sql.push("SELECT");
sql.push(attrs || "*");
sql.push("FROM");
sql.push(this.model.tableName);
sql.push("WHERE id IN (:ids)");
return await this.customQuery(sql.join(" "), {
ids: ids
}) || [];
}
async mapByIds(ids, attrs) {
var result = {};
if (!ids || ids.length == 0) {
return result;
}
var list = await this.listByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = MerchantAccountDao;
\ No newline at end of file
...@@ -6,14 +6,20 @@ class RecruitDao extends Dao { ...@@ -6,14 +6,20 @@ class RecruitDao extends Dao {
super(Dao.getModelName(RecruitDao)); super(Dao.getModelName(RecruitDao));
} }
async statCount(companyNames) { async statCount(companyNames, sign_body) {
var result = {}; var result = {};
if(!companyNames || companyNames.length == 0) { if(!companyNames || companyNames.length == 0) {
return result; return result;
} }
var sql = "SELECT company_name, COUNT(1) AS num FROM `recruit_info` WHERE company_name IN (:companyNames) GROUP BY company_name";
let list = await this.customQuery(sql, {companyNames: companyNames}); let and = [];
and.push("company_name IN (:companyNames)");
if (sign_body) {
and.push("AND sign_body = :sign_body");
}
var sql = `SELECT company_name, COUNT(1) AS num FROM recruit_info WHERE ${and.join(" ")} GROUP BY company_name `;
let list = await this.customQuery(sql, {companyNames: companyNames, sign_body: sign_body});
if(!list || list.length == 0) { if(!list || list.length == 0) {
return result; return result;
......
...@@ -5,14 +5,21 @@ class TaxinfoDao extends Dao { ...@@ -5,14 +5,21 @@ class TaxinfoDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(TaxinfoDao)); super(Dao.getModelName(TaxinfoDao));
} }
async statCount(companyNames) { async statCount(companyNames, sign_body) {
var result = {}; var result = {};
if(!companyNames || companyNames.length == 0) { if(!companyNames || companyNames.length == 0) {
return result; return result;
} }
var sql = "SELECT company_name, COUNT(1) AS num FROM `tax_info` WHERE company_name IN (:companyNames) GROUP BY company_name";
let list = await this.customQuery(sql, {companyNames: companyNames}); let and = [];
and.push("company_name IN (:companyNames)");
if (sign_body) {
and.push("AND sign_body = :sign_body");
}
var sql = `SELECT company_name, COUNT(1) AS num FROM tax_info WHERE ${and.join(" ")} GROUP BY company_name`;
let list = await this.customQuery(sql, {companyNames: companyNames, sign_body: sign_body});
if(!list || list.length == 0) { if(!list || list.length == 0) {
return result; return result;
...@@ -23,14 +30,19 @@ class TaxinfoDao extends Dao { ...@@ -23,14 +30,19 @@ class TaxinfoDao extends Dao {
} }
return result; return result;
} }
async statCounts(companyNames) { async statCounts(companyNames, sign_body) {
var result = {}; var result = {};
if(!companyNames || companyNames.length == 0) { if(!companyNames || companyNames.length == 0) {
return result; return result;
} }
var sql = "SELECT company_name, SUM(income_tax) AS num FROM `tax_info` WHERE company_name IN (:companyNames) GROUP BY company_name"; let and = [];
and.push("company_name IN (:companyNames)");
if (sign_body) {
and.push("AND sign_body = :sign_body");
}
var sql = `SELECT company_name, SUM(income_tax) AS num FROM tax_info WHERE ${and.join(" ")} GROUP BY company_name`;
let list = await this.customQuery(sql, {companyNames: companyNames}); let list = await this.customQuery(sql, {companyNames: companyNames, sign_body: sign_body});
if(!list || list.length == 0) { if(!list || list.length == 0) {
return result; return result;
...@@ -66,7 +78,7 @@ class TaxinfoDao extends Dao { ...@@ -66,7 +78,7 @@ class TaxinfoDao extends Dao {
if(!inno || inno.length == 0) { if(!inno || inno.length == 0) {
return result; return result;
} }
var sql = "SELECT id_no, SUM(actual_amount) AS num FROM `tax_info` WHERE company_name IN (:inno) GROUP BY name"; var sql = "SELECT id_no, SUM(income_tax) AS num FROM `tax_info` WHERE company_name IN (:inno) GROUP BY name";
let list = await this.customQuery(sql, {inno: inno}); let list = await this.customQuery(sql, {inno: inno});
......
...@@ -5,14 +5,21 @@ class TransactioninDao extends Dao { ...@@ -5,14 +5,21 @@ class TransactioninDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(TransactioninDao)); super(Dao.getModelName(TransactioninDao));
} }
async statCount(companyNames) { async statCount(companyNames, sign_body) {
var result = {}; var result = {};
if(!companyNames || companyNames.length == 0) { if(!companyNames || companyNames.length == 0) {
return result; return result;
} }
var sql = "SELECT company_name, COUNT(1) AS num FROM `transaction_info` WHERE company_name IN (:companyNames) GROUP BY company_name";
let list = await this.customQuery(sql, {companyNames: companyNames}); let and = [];
and.push("company_name IN (:companyNames)");
if (sign_body) {
and.push("AND sign_body = :sign_body");
}
var sql = `SELECT company_name, COUNT(1) AS num FROM transaction_info WHERE ${and.join(" ")} GROUP BY company_name`;
let list = await this.customQuery(sql, {companyNames: companyNames, sign_body: sign_body});
if(!list || list.length == 0) { if(!list || list.length == 0) {
return result; return result;
...@@ -24,14 +31,19 @@ class TransactioninDao extends Dao { ...@@ -24,14 +31,19 @@ class TransactioninDao extends Dao {
return result; return result;
} }
async statCounts(companyNames) { async statCounts(companyNames, sign_body) {
var result = {}; var result = {};
if(!companyNames || companyNames.length == 0) { if(!companyNames || companyNames.length == 0) {
return result; return result;
} }
var sql = "SELECT company_name, SUM(actual_amount) amount FROM `transaction_info` WHERE company_name IN (:companyNames) GROUP BY company_name"; let and = [];
and.push("company_name IN (:companyNames)");
if (sign_body) {
and.push("AND sign_body = :sign_body");
}
let list = await this.customQuery(sql, {companyNames: companyNames}); var sql = `SELECT company_name, SUM(actual_amount) amount FROM transaction_info WHERE ${and.join(" ")} GROUP BY company_name`;
let list = await this.customQuery(sql, {companyNames: companyNames, sign_body: sign_body});
if(!list || list.length == 0) { if(!list || list.length == 0) {
return result; return result;
......
/* jshint indent: 2 */
module.exports = function (sequelize, DataTypes) {
return sequelize.define('merchantaccount', {
merchant_id: DataTypes.INTEGER,
account_name: DataTypes.STRING,
account_no: DataTypes.STRING,
account_bank: DataTypes.STRING,
legal_name: DataTypes.STRING,
base_no: DataTypes.STRING,
}, {
tableName: 'merchant_account',
paranoid: true,//假的删除
underscored: true,
version: false,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
validate: {},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
};
...@@ -44,6 +44,10 @@ module.exports = function(sequelize, DataTypes) { ...@@ -44,6 +44,10 @@ module.exports = function(sequelize, DataTypes) {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true allowNull: true
}, },
merchant_account_id: {
type: DataTypes.INTEGER,
allowNull: true
},
created_at: { created_at: {
type: DataTypes.DATE, type: DataTypes.DATE,
allowNull: true allowNull: true
......
...@@ -16,6 +16,7 @@ class MerchantService extends ServiceBase { ...@@ -16,6 +16,7 @@ class MerchantService extends ServiceBase {
this.loadSve = system.getObject("service.all.loadSve"); this.loadSve = system.getObject("service.all.loadSve");
this.taxinfoSve = system.getObject("service.all.taxinfoSve"); this.taxinfoSve = system.getObject("service.all.taxinfoSve");
this.transactioninSve = system.getObject("service.all.transactioninSve"); this.transactioninSve = system.getObject("service.all.transactioninSve");
this.merchantaccountSve = system.getObject("service.all.merchantaccountSve");
} }
async signPage(params) { async signPage(params) {
...@@ -196,23 +197,23 @@ class MerchantService extends ServiceBase { ...@@ -196,23 +197,23 @@ class MerchantService extends ServiceBase {
companyNames.push(row.company_name); companyNames.push(row.company_name);
} }
// 电子签约数量 company_name --> num // 电子签约数量 company_name --> num
let electronMap = await this.electroniccontractDao.statCount(companyNames); let electronMap = await this.electroniccontractDao.statCount(companyNames, params.sign_body);
// 招工需求 // 招工需求
let recruitMap = await this.recruitDao.statCount(companyNames); let recruitMap = await this.recruitDao.statCount(companyNames, params.sign_body);
// 工作量确认单 // 工作量确认单
let loadMap = await this.loadDao.statCount(companyNames); let loadMap = await this.loadDao.statCount(companyNames, params.sign_body);
// 交易笔数、交易金额 // 交易笔数、交易金额
let traMap = await this.transactioninDao.statCount(companyNames); let traMap = await this.transactioninDao.statCount(companyNames, params.sign_body);
//交易金额 //交易金额
let traSUm = await this.transactioninDao.statCounts(companyNames); let traSUm = await this.transactioninDao.statCounts(companyNames, params.sign_body);
// 完税人次 // 完税人次
let taxMap = await this.taxinfoDao.statCount(companyNames); let taxMap = await this.taxinfoDao.statCount(companyNames, params.sign_body);
// 完税金额 // 完税金额
let taxSUm = await this.taxinfoDao.statCounts(companyNames); let taxSUm = await this.taxinfoDao.statCounts(companyNames, params.sign_body);
for (var row of rows) { for (var row of rows) {
row.dzCount = electronMap[row.company_name] || 0; row.dzCount = electronMap[row.company_name] || 0;
...@@ -252,6 +253,7 @@ class MerchantService extends ServiceBase { ...@@ -252,6 +253,7 @@ class MerchantService extends ServiceBase {
firlt = "transaction_time"; firlt = "transaction_time";
this.doTimeCondition(params, ["signBegin", "signEnd"]); this.doTimeCondition(params, ["signBegin", "signEnd"]);
page = await this.transactioninSve.signPage(params); page = await this.transactioninSve.signPage(params);
await this.merchantaccountSve.setAccount(page.rows);
} else {//完税 } else {//完税
db = "tax_info"; db = "tax_info";
firlt = "tax_time"; firlt = "tax_time";
...@@ -304,7 +306,7 @@ class MerchantService extends ServiceBase { ...@@ -304,7 +306,7 @@ class MerchantService extends ServiceBase {
// 完税人次 // 完税人次
let taxMap = await this.taxinfoDao.sCount(companyNames); let taxMap = await this.taxinfoDao.sCount(companyNames);
// 完税金额 // 完税金额
let taxSUm = await this.taxinfoDao.statCounts(companyNames); let taxSUm = await this.taxinfoDao.sCount(companyNames);
for (var row of rows) { for (var row of rows) {
row.dzCount = electronMap[row.id_no] || 0; row.dzCount = electronMap[row.id_no] || 0;
...@@ -338,6 +340,7 @@ class MerchantService extends ServiceBase { ...@@ -338,6 +340,7 @@ class MerchantService extends ServiceBase {
firlt = "transaction_time"; firlt = "transaction_time";
this.doTimeCondition(params, ["signBegin", "signEnd"]); this.doTimeCondition(params, ["signBegin", "signEnd"]);
page = await this.transactioninSve.signPage(params); page = await this.transactioninSve.signPage(params);
await this.merchantaccountSve.setAccount(page.rows);
} else {//完税 } else {//完税
db = "tax_info"; db = "tax_info";
firlt = "tax_time"; firlt = "tax_time";
...@@ -355,6 +358,9 @@ class MerchantService extends ServiceBase { ...@@ -355,6 +358,9 @@ class MerchantService extends ServiceBase {
if(params.idno){ if(params.idno){
sql = sql + " AND id_no = '" + params.idno + "'"; sql = sql + " AND id_no = '" + params.idno + "'";
} }
if(params.id_no){
sql = sql + " AND id_no = '" + params.id_no + "'";
}
sql = sql + " GROUP BY days ORDER BY days ASC"; sql = sql + " GROUP BY days ORDER BY days ASC";
var charts = [[], []]; var charts = [[], []];
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
/**
* 发票列表
*/
class MerchantAccountService extends ServiceBase {
constructor() {
super("all", ServiceBase.getDaoName(MerchantAccountService));
}
async setAccount(list, options) {
if (!list || list.length == 0) {
return;
}
options = options || {};
let field = options.field || "merchant_account_id";
let attrs = options.attrs || "id, merchant_id, account_name, account_no, account_bank, legal_name, base_no";
let ids = [-1];
for (let item of list) {
if (!item || !item[field]) {
continue;
}
ids.push(Number(item[field]));
}
let map = await this.dao.mapByIds(ids, attrs) || {};
for (let item of list) {
item.merchant_account = map[item[field]] || {};
}
}
}
module.exports = MerchantAccountService;
\ No newline at end of file
...@@ -43,7 +43,7 @@ class TransactioninService extends ServiceBase { ...@@ -43,7 +43,7 @@ class TransactioninService extends ServiceBase {
["id", 'desc'] ["id", 'desc']
]; ];
var attributes = [`id`, `company_name`, `id_name`, `id_no`, `bank_no`,`invoiceId`, `actual_amount`,`deduct_amt`, `transaction_time`, `sign_body`,`order_item_id`, `channel_rsp_no`]; var attributes = [`id`, `company_name`, `id_name`, `id_no`, `bank_no`,`invoiceId`, `actual_amount`,`deduct_amt`, `transaction_time`, `sign_body`,`order_item_id`, `channel_rsp_no`, `merchant_account_id`];
var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes); var page = await this.getPageList(currentPage, pageSize, where, orderby, attributes);
if (page && page.rows) { if (page && page.rows) {
for (var row of page.rows) { for (var row of page.rows) {
......
...@@ -30,6 +30,7 @@ module.exports = function (app) { ...@@ -30,6 +30,7 @@ module.exports = function (app) {
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild, bpostatsid'); res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild, bpostatsid');
res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS'); res.header('Access-Control-Allow-Methods', 'PUT, POST, GET, DELETE, OPTIONS');
// res.header('Access-Control-Allow-Credentials', 'true'); // res.header('Access-Control-Allow-Credentials', 'true');
res.header('content-type', 'text/html;charset=UTF-8');
if (req.method == 'OPTIONS') { if (req.method == 'OPTIONS') {
res.send(200); //让options请求快速返回/ res.send(200); //让options请求快速返回/
} }
......
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