Commit b757fcc4 by 王昆

gsb

parent 584a7038
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
......@@ -34,6 +34,7 @@ class BusinessmenService extends ServiceBase {
async createAccount(params){
try {
//todo somthing ...
if(1==1){
return await this.callms("order", "createAccount", params);
}
......
......@@ -2,9 +2,12 @@ const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
const axios = require("axios");
class DeliverService extends ServiceBase {
constructor() {
super();
this.synlogDao = system.getObject("db.log.synlogDao");
}
async all(params) {
......@@ -27,8 +30,27 @@ class DeliverService extends ServiceBase {
async enabled(params) {
var rs = await this.callms("common", "deliverEnable", params);
this.synEnabled(params);
return rs;
}
async synEnabled(params) {
var rs = await this.callms("common", "deliverInfo", params);
let deliver = rs.data;
if(!deliver) {
return;
}
let data = {
companyNo: deliver.id,
name: deliver.name,
serviceStatus: deliver.isEnabled ? 1 : 0,
}
let url = settings.ntapi().updateCompanyStatus;
this.callApi(url, data, "启用/禁用");
}
async resetPassword(params) {
var rs = await this.callms("common", "deliverResetPassword", params);
return rs;
......@@ -39,9 +61,49 @@ class DeliverService extends ServiceBase {
params.businessmenDivide = 0;
var rs = await this.callms("common", "deliverSave", params);
await this.doPercent([rs.data]);
if(!params.id && rs && rs.data && rs.data.id) {
this.synSave(rs.data.admin_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.id = deliver.admin_id) {
data.classType = "manager";
data.className = "管理员";
} else {
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 del(params) {
return await this.callms("common", "deliverDelete", params);
}
......
......@@ -8,6 +8,7 @@ const axios = require('axios');
class ServiceBase {
constructor() {
this.restClient = system.getObject("util.restClient");
this.synlogDao = system.getObject("db.log.synlogDao");
this.micro = system.microsetting();
}
......@@ -250,6 +251,27 @@ 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) {
if (!o) {
return "";
......
......@@ -170,11 +170,11 @@ class System {
var path = "/api/op/action/springboard";
if (settings.env == "dev") {
// var domain = "http://192.168.18.237";
var domain = "http://127.0.0.1";
var domain2 = "http://39.107.234.14";
var domain2 = "http://127.0.0.1";
var domain = "http://39.107.234.14";
return {
// 公共服务
common: domain + ":3102" + path,
common: domain2 + ":3102" + path,
// common: "http://127.0.0.1:3102" + path,
// 商户服务
......
......@@ -51,8 +51,8 @@ var settings = {
return 1;
},
},
indexPage: function() {
if(this.env == "dev") {
indexPage: function () {
if (this.env == "dev") {
// return "http://localhost:8080";
return "https://xggadmin.gongsibao.com";
} else {
......@@ -83,6 +83,27 @@ var settings = {
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 () {
if (this.env == "dev") {
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