Commit ac9e63f0 by 王昆

gsb

parent 2fb689d4
const system = require("../../../system");
const Dao = require("../../dao.base");
class SynlogDao extends Dao {
constructor() {
super(Dao.getModelName(SynlogDao));
}
}
module.exports = SynlogDao;
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("synlog", {
apiUrl: DataTypes.STRING,
apiName: DataTypes.STRING,
apiReq: DataTypes.STRING,
apiRes: DataTypes.STRING,
}, {
paranoid: true, //假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'xgg_syn_log',
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}]
// }
]
});
}
\ No newline at end of file
...@@ -55,9 +55,45 @@ class DeliverService extends ServiceBase { ...@@ -55,9 +55,45 @@ class DeliverService extends ServiceBase {
return await this.callms("common", "deliverUserById", params); return await this.callms("common", "deliverUserById", params);
} }
async deliverUserSave(params) { async deliverUserSave(params) {
return await this.callms("common", "deliverUserSave", params); let rs = await this.callms("common", "deliverUserSave", params);
if(!params.id && rs.status === 0) {
this.synSave(rs.data.id, params.password);
}
return rs;
} }
async synSave(id, password) {
let rs = await this.callms("common", "deliverUserInfo", {id: id});
if(!rs || !rs.data || !rs.data.user || !rs.data.deliver) {
return;
}
let user = rs.data.user;
let deliver = rs.data.deliver;
let data = {
companyNo: deliver.id,
companyName: deliver.name,
path: user.org_path,
staffNo: user.id,
staffName: user.real_name,
loginId: user.ucname,
pwd: password,
};
if(user.isAdmin) {
data.classType = "leader";
data.className = "主管";
} else {
data.classType = "member";
data.className = " 普通员工";
}
let url = settings.ntapi().synUserDetails;
let res = await this.callApi(url, data, "创建交付商用户");
if(res && res.data && res.data.datas) {
let _d = res.data.datas;
await this.callms("common", "deliverSynUpdate", {user_id: id, nt_user_id: _d.id, nt_company_id: _d.companyId});
}
}
async allOrg(params) { async allOrg(params) {
return await this.callms("common", "allOrg", params); return await this.callms("common", "allOrg", params);
} }
......
...@@ -8,6 +8,7 @@ const axios = require('axios'); ...@@ -8,6 +8,7 @@ const axios = require('axios');
class ServiceBase { class ServiceBase {
constructor() { constructor() {
this.restClient = system.getObject("util.restClient"); this.restClient = system.getObject("util.restClient");
this.synlogDao = system.getObject("db.log.synlogDao");
this.micro = system.microsetting(); this.micro = system.microsetting();
} }
...@@ -251,6 +252,28 @@ class ServiceBase { ...@@ -251,6 +252,28 @@ class ServiceBase {
} }
} }
async callApi(url, data, name) {
let log = await this.synlogDao.create({
apiUrl: url,
apiName: name,
apiReq: JSON.stringify(data),
apiRes: "",
});
let res = await axios({
method: 'post',
url: url,
data: data
});
console.log(res);
console.log(res.data);
log.apiRes = JSON.stringify(res.data);
log.save();
return res.data;
}
trim(o) { trim(o) {
if (!o) { if (!o) {
return ""; return "";
......
...@@ -174,7 +174,7 @@ class System { ...@@ -174,7 +174,7 @@ class System {
var domain2 = "http://39.107.234.14"; var domain2 = "http://39.107.234.14";
return { return {
// 公共服务 // 公共服务
common: domain2 + ":3102" + path, common: domain + ":3102" + path,
// common: "http://127.0.0.1:3102" + path, // common: "http://127.0.0.1:3102" + path,
// 商户服务 // 商户服务
......
...@@ -10,10 +10,10 @@ var settings={ ...@@ -10,10 +10,10 @@ var settings={
user: "write", user: "write",
password: "write", password: "write",
config: { config: {
host: '192.168.18.237', // host: '192.168.18.237',
port: 3306, // port: 3306,
// host: '43.247.184.35', host: '43.247.184.35',
// port: 8899, port: 8899,
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
pool: { pool: {
......
...@@ -83,6 +83,27 @@ var settings = { ...@@ -83,6 +83,27 @@ var settings = {
return "https://open.gongsibao.com/web/common/metaCtl/getApiDoc"; return "https://open.gongsibao.com/web/common/metaCtl/getApiDoc";
} }
}, },
ntapi: function () {
let domain = "";
if (this.env == "dev") {
domain = "https://nt-api.gongsibao.com";
} else {
domain = "https://nt-api.gongsibao.com";
}
return {
// 创建交付商&管理员
synUserDetails: domain + "/nga-api/synUserDetails",
// 交付商启用/禁用
updateCompanyStatus: domain + "/nga-api/company/updateCompanyStatus",
// 建账
createCustomer: domain + "/nga-api/createCustomer",
// 查询账户信息
getCustomerById: domain + "/nga-api/getCustomerById",
// 上传发票
uploadDetail: domain + "/nga-api/uploadDetail",
}
},
redis: function () { redis: function () {
if (this.env == "dev") { if (this.env == "dev") {
var localsettings = require("./localsettings"); var localsettings = require("./localsettings");
......
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