Commit a2e0e885 by 王昆

gsb

parent 294087d6
/xgg-deliver/node_modules/ /xgg-saas-platform/node_modules/
.idea/* .idea/*
\ No newline at end of file
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Launch Program", "name": "Launch Program",
"program": "${workspaceFolder}/xgg-deliver/main.js" "program": "${workspaceFolder}/xgg-saas-platform/main.js"
} }
] ]
} }
\ No newline at end of file
...@@ -59,7 +59,9 @@ class APIBase extends DocBase { ...@@ -59,7 +59,9 @@ class APIBase extends DocBase {
async isCheckWhiteList(gname, methodname) { async isCheckWhiteList(gname, methodname) {
var fullname = gname + "." + methodname; var fullname = gname + "." + methodname;
var lst = [ var lst = [
"test.testApi" "test.testApi",
"inner.registerInner",
"inner.resetPasswordInner",
]; ];
var x = lst.indexOf(fullname); var x = lst.indexOf(fullname);
return x >= 0; return x >= 0;
......
var APIBase = require("../../api.base");
var system = require("../../../system");
class PlatformuserAPI extends APIBase {
constructor() {
super();
this.userSve = system.getObject("service.uc.userSve");
}
async registerInner(pobj, query, req) {
var result = await this.userSve.registerInner(pobj);
return result;
}
async resetPasswordInner(pobj, query, req) {
var result = await this.userSve.resetPasswordInner(pobj);
return result;
}
exam() {
return "";
}
classDesc() {
return {
groupName: "",
groupDesc: "",
name: "",
desc: "",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: "",
methodName: "",
paramdescs: [
{
paramDesc: "",
paramName: "",
paramType: "",
defaultValue: "",
}
],
rtnTypeDesc: "",
rtnType: ""
}
];
}
}
module.exports = PlatformuserAPI;
\ No newline at end of file
...@@ -5,7 +5,6 @@ const md5 = require("MD5"); ...@@ -5,7 +5,6 @@ const md5 = require("MD5");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl"); const logCtl = system.getObject("web.common.oplogCtl");
class UserCtl extends CtlBase { class UserCtl extends CtlBase {
constructor() { constructor() {
super(); super();
...@@ -13,26 +12,13 @@ class UserCtl extends CtlBase { ...@@ -13,26 +12,13 @@ class UserCtl extends CtlBase {
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
this.captchaSve = system.getObject("service.common.captchaSve"); this.captchaSve = system.getObject("service.common.captchaSve");
this.deliverSve = system.getObject("service.common.deliverSve"); this.deliverSve = system.getObject("service.common.deliverSve");
this.redisClientTax = system.getObject("util.redisClientTax");
} }
async login(pobj, pobj2, req, res) { async login(pobj, pobj2, req, res) {
var loginName = this.trim(pobj.loginName); var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password); var password = this.trim(pobj.password);
// var captchaKey = this.trim(pobj.captchaKey);
// var captchaCode = this.trim(pobj.captchaCode);
try { try {
// var vrs = await this.captchaSve.valid({ var loginUser = await this.userSve.login({
// key: captchaKey,
// code: captchaCode,
// });
// if (vrs.status !== 0) {
// return vrs;
// }
var loginUser = await this.deliverSve.login({
ucname: loginName, ucname: loginName,
password: password, password: password,
}); });
...@@ -41,16 +27,11 @@ class UserCtl extends CtlBase { ...@@ -41,16 +27,11 @@ class UserCtl extends CtlBase {
} }
loginUser = loginUser.data; loginUser = loginUser.data;
var loginKey = await this.setLogin(loginUser); var loginsid = await this.setLogin(loginUser);
let ntapi = settings.ntapi();
let rs = { let rs = {
key: loginKey.xggadminsid, key: loginsid,
taxLoginUrl: ntapi.taxLoginUrl + `?username=${loginUser.ucname}&cookieId=${loginKey.subsid}&target=tax`,
finLoginUrl: ntapi.taxLoginUrl + `?username=${loginUser.ucname}&cookieId=${loginKey.subsid}`,
loginname: loginUser.ucname, loginname: loginUser.ucname,
auth: loginUser.auth, menus: await this.getMenu(loginUser)
isManager: loginUser.isManager,
menus: {gtArr: this.getOrderMenu(loginUser), pjArr: this.getInvoiceMenu(loginUser)}
}; };
return system.getResultSuccess(rs); return system.getResultSuccess(rs);
...@@ -61,217 +42,47 @@ class UserCtl extends CtlBase { ...@@ -61,217 +42,47 @@ class UserCtl extends CtlBase {
} }
async setLogin(user) { async setLogin(user) {
user.loginsid = "jfs_" + uuidv4(); let loginsid = "saasp_" + uuidv4();
user.subsid = "sub_" + uuidv4();
// if(settings.env == 'dev') { // if(settings.env == 'dev') {
// user.loginsid = "jfs_" + "3cb49932-fa02-44f0-90db-9f06fe02e5c7"; // user.loginsid = "jfs_" + "3cb49932-fa02-44f0-90db-9f06fe02e5c7";
// user.subsid = "sub_" + "3cb49932-fa02-44f0-90db-9f06fe02e5c7"; // user.subsid = "sub_" + "3cb49932-fa02-44f0-90db-9f06fe02e5c7";
// } // }
// xggadminsid = "jfs_" + "3cb49932-fa02-44f0-90db-9f06fe02e5c7"; loginsid = "saasp_" + "2cb49932-fa02-44f0-90db-9f06fe02e5c7";
await this.redisClient.setWithEx(user.loginsid, JSON.stringify(user), 60 * 60 * 5); await this.redisClient.setWithEx(loginsid, JSON.stringify(user), 60 * 60 * 5);
await this.redisClientTax.setWithEx(user.subsid, (user.nt_user_id || "").toString(), 60 * 60 * 5); return loginsid;
return {
xggadminsid: user.loginsid,
subsid: user.subsid,
};
}
async getMenu(qobj, pobj, req) {
// return system.getResultSuccess(req.loginUser.menus);
let loginUser = req.loginUser;
if (!loginUser) {
return system.getResultSuccess({gtArr: [], pjArr: []})
}
let gtArr = this.getOrderMenu(loginUser);
let pjArr = this.getInvoiceMenu(loginUser);
return system.getResultSuccess({gtArr: gtArr, pjArr: pjArr});
}
getOrderMenu(loginUser) {
if (!loginUser) {
return [];
}
if (loginUser.isAdmin) {
return [
{
"name": "数据概览",
"icon": "iconfont icon-gth-gsshujugailan",
"team": [
{
"name": "业务数据汇总",
"path": "/home"
}
]
},
{
"name": "订单中心",
"icon": "iconfont icon-gth-gsdingdanzhongxin",
"team": [
{
"name": "订单管理",
"path": "/trading/ordersAll"
},
]
},
{
"name": "个体户中心",
"icon": "iconfont icon-gth-gsgetihuzhongxin",
"team": [
{
"name": "个体户管理",
"path": "/trading/userInformation"
},
]
},
// {
// "name": "用户中心",
// "icon": "iconfont icon-gth-gsgetihuzhongxin",
// "team": [
// {
// "name": "用户管理",
// "path": "/user/userCenter"
// }
// ]
// }
];
} else {
return [
{
"name": "数据概览",
"icon": "iconfont icon-gth-gsshujugailan",
"team": [
{
"name": "业务数据汇总",
"path": "/home"
}
]
},
{
"name": "订单中心",
"icon": "iconfont icon-gth-gsdingdanzhongxin",
"team": [
{
"name": "我的业务订单",
"path": "/trading/orderInformation"
}
]
},
{
"name": "个体户中心",
"icon": "iconfont icon-gth-gsgetihuzhongxin",
"team": [
{
"name": "个体户",
"path": "/trading/userAll"
}
]
}
];
}
} }
getInvoiceMenu(loginUser) { getMenu(loginUser) {
if (!loginUser) { if (!loginUser) {
return []; return [];
} }
return [ return [{
"name": "数据概览",
"icon": "iconfont icon-gth-gsshujugailan",
"team": [{
"name": "业务数据汇总",
"path": "/home"
}]
},
{ {
name: "数据概览", "name": "订单中心",
icon: "iconfont icon-gth-gsshujugailan", "icon": "iconfont icon-gth-gsdingdanzhongxin",
team: [{name: "业务数据汇总", path: "/home"}] "team": [{
"name": "订单管理",
"path": "/trading/ordersAll"
}, ]
}, },
{ {
name: "发票中心", "name": "个体户中心",
icon: "iconfont icon-gth-gsfapiaozhongxin", "icon": "iconfont icon-gth-gsgetihuzhongxin",
team: [ "team": [{
{name: "发票申请", path: "/trading/invoiceApplyFor"}, "name": "个体户管理",
{name: "发票管理", path: "/trading/invoiceManagement"}, "path": "/trading/userInformation"
] }, ]
} },
]; ];
} }
/**
* 添加
* @param {*} params
*/
async addUser(params, pobj2, req) {
try {
var user = {
saas_id: params.saas_id,
org_id: Number(params.org_id || 0),
ucname: this.trim(params.ucname),
password: this.trim(params.password),
uctype: '3',
uctypeId: this.trim(params.deliverId),
mobile: this.trim(params.mobile),
realName: this.trim(params.realName),
roles: params.roles || [],
};
if (!user.ucname) {
return system.getResult(null, "请填写用户名");
}
if (!user.password) {
return system.getResult(null, "请填写密码");
}
if (!user.mobile) {
return system.getResult(null, "请填写手机号");
}
if (!user.realName) {
return system.getResult(null, "请填写姓名");
}
if (user.uctype != 1) {
user.org_id = null;
user.roles = [];
}
return await this.userSve.addUser(user);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 更新
* @param {*} params
*/
async updUser(params, pobj2, req) {
var user = {
id: Number(params.id || 0),
saas_id: params.saas_id,
org_id: Number(params.org_id || 0),
uctype: '3',
uctypeId: this.trim(params.deliverId),
mobile: this.trim(params.mobile),
realName: this.trim(params.realName),
roles: params.roles || [],
};
if (!user.id) {
return system.getResult(null, "用户不存在");
}
if (!user.mobile) {
return system.getResult(null, "请填写手机号");
}
if (!user.realName) {
return system.getResult(null, "请填写姓名");
}
if (user.uctype != 1) {
user.org_id = null;
user.roles = [];
}
try {
return await this.userSve.updUser(user);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async currentUser(qobj, pobj, req) { async currentUser(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser); return system.getResultSuccess(req.loginUser);
} }
......
...@@ -10,135 +10,52 @@ class UserService extends ServiceBase { ...@@ -10,135 +10,52 @@ class UserService extends ServiceBase {
async login(params) { async login(params) {
try { try {
return await this.callms("uc", "login", params); return await this.callms("uc", "platformLogin", params);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/** async registerInner(params) {
* 添加
* @param {*} params
*/
async addUser(params) {
try {
var relation = await this.opuserrelationDao.findOne({
ucname: params.ucname
});
if (!relation) {
var rs = await this.platformUtils.createUserInfo(params.ucname, params.ucname, params.password);
if (!rs.data || !rs.data.account_id) {
return rs;
}
params.ucid = rs.data.account_id;
this.opuserrelationDao.model.create({
ucname: params.ucname,
ucid: rs.data.account_id,
});
} else {
params.ucid = relation.ucid;
}
system.getResultSuccess();
return await this.callms("uc", "addUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 更新
* @param {*} params
*/
async updUser(params) {
try {
return await this.callms("uc", "updUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async enabled(params) {
try {
return await this.callms("uc", "enabled", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* @param {*} params
*/
async page(params) {
try { try {
return await this.callms("uc", "userPage", params); return await this.callms("uc", "platformRegisterInner", params);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/** async resetPasswordInner(params) {
* 删除
* @param {*} params
*/
async delUser(params) {
try { try {
return await this.callms("uc", "delUser", params); return await this.callms("uc", "platformResetPasswordInner", params);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/** async info(params) {
* 查询明细
* @param {*} params
*/
async queryById(params) {
try { try {
return await this.callms("uc", "userInfo", params); return await this.callms("uc", "platformInfo", params);
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
/** async enabled(params) {
* 修改密码
* @param {*} params
*/
async updPassword(params) {
try { try {
var user = await this.callms("uc", "userInfo", params); return await this.callms("uc", "platformEnabled", params);
user = user.data;
var rs = await this.platformUtils.modifyPassword(user.ucid, params.password);
if (rs.status !== 0) {
return rs;
}
await this.callms("uc", "updPassword", params);
return system.getResultSuccess();
} catch (error) { } catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
async mapByIds(params) { async mapByIds(params) {
try { try {
return await this.callms("uc", "mapUserByIds", params); return await this.callms("uc", "platforMapByIds", params);
} catch (error) { } catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`); return system.getResult(null, `系统错误 错误信息 ${error}`);
} }
} }
async salesmanList(params) {
try {
let rs = await this.callms("common", "deliverUsers", params);
return rs;
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
} }
module.exports = UserService; module.exports = UserService;
\ No newline at end of file
...@@ -189,8 +189,8 @@ class System { ...@@ -189,8 +189,8 @@ class System {
invoice: domain + ":3105" + path, invoice: domain + ":3105" + path,
// invoice: "http://127.0.0.1:3105" + path, // invoice: "http://127.0.0.1:3105" + path,
// 发票服务 // 用户服务
uc: domain2 + ":3106" + path, uc: domain + ":3106" + path,
// uc: "http://127.0.0.1:3106" + path, // uc: "http://127.0.0.1:3106" + path,
} }
} else { } else {
......
...@@ -27,7 +27,7 @@ module.exports = function (app) { ...@@ -27,7 +27,7 @@ module.exports = function (app) {
app.all('*', function (req, res, next) { app.all('*', function (req, res, next) {
req.objs = system; req.objs = system;
res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild, xggadminsid'); res.header('Access-Control-Allow-Headers', 'Content-Type, Content-Length, Authorization, Accept, X-Requested-With , yourHeaderFeild, xggsaasplatformsid');
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');
if (req.method == 'OPTIONS') { if (req.method == 'OPTIONS') {
......
...@@ -6,7 +6,8 @@ var marked = require("marked"); ...@@ -6,7 +6,8 @@ var marked = require("marked");
module.exports = function (app) { module.exports = function (app) {
app.get('/doc', function (req, res) { app.get('/doc', function (req, res) {
var path = process.cwd() + "/app/front/entry/public/apidoc/README.md"; // var path = process.cwd() + "/app/front/entry/public/apidoc/README.md";
var path = process.cwd() + "/xgg-saas-platform/app/front/entry/public/apidoc/README.md";
fs.readFile(path, function(err, data){ fs.readFile(path, function(err, data){
if(err){ if(err){
console.log(err); console.log(err);
...@@ -20,7 +21,8 @@ module.exports = function (app) { ...@@ -20,7 +21,8 @@ module.exports = function (app) {
}); });
app.get('/doc/:forder', function (req, res) { app.get('/doc/:forder', function (req, res) {
var path = process.cwd() + "/app/front/entry/public/apidoc/README.md"; // var path = process.cwd() + "/app/front/entry/public/apidoc/README.md";
var path = process.cwd() + "/xgg-saas-platform/app/front/entry/public/apidoc/README.md";
fs.readFile(path, function(err, data){ fs.readFile(path, function(err, data){
if(err){ if(err){
...@@ -37,7 +39,8 @@ module.exports = function (app) { ...@@ -37,7 +39,8 @@ module.exports = function (app) {
app.get('/doc/:forder/:fileName', function (req, res) { app.get('/doc/:forder/:fileName', function (req, res) {
var forder = req.params["forder"]; var forder = req.params["forder"];
var fileName = req.params["fileName"] || "README.md"; var fileName = req.params["fileName"] || "README.md";
var path = process.cwd() + "/app/front/entry/public/apidoc"; // var path = process.cwd() + "/app/front/entry/public/apidoc";
var path = process.cwd() + "/xgg-saas-platform/app/front/entry/public/apidoc";
if(forder) { if(forder) {
path = path + "/" + forder + "/" + fileName; path = path + "/" + forder + "/" + fileName;
} else { } else {
......
...@@ -6,20 +6,18 @@ const redisClient = system.getObject("util.redisClient"); ...@@ -6,20 +6,18 @@ const redisClient = system.getObject("util.redisClient");
module.exports = function (app) { module.exports = function (app) {
app.all("/web/*", async function (req, res, next) { app.all("/web/*", async function (req, res, next) {
var xggadminsid; var loginsid;
var jsonUser = req.session.user; var jsonUser = req.session.user;
// var jsonUser = null; // var jsonUser = null;
if(!jsonUser) { if(!jsonUser) {
xggadminsid = req.headers["xggadminsid"] || ""; loginsid = req.headers["xggsaasplatformsid"] || "";
jsonUser = await redisClient.get(xggadminsid); jsonUser = await redisClient.get(loginsid);
if(jsonUser) { if(jsonUser) {
jsonUser = JSON.parse(jsonUser); jsonUser = JSON.parse(jsonUser);
} }
} }
if (req.url.indexOf("auth/userCtl/login") > 0 || if (req.url.indexOf("uc/userCtl/login") > 0 ||
req.url.indexOf("uc/userCtl/login") > 0 ||
req.url.indexOf("auth/userCtl/smsCode") > 0 ||
req.url.indexOf("common/metaCtl/getApiDoc") > 0 || req.url.indexOf("common/metaCtl/getApiDoc") > 0 ||
req.url.indexOf("common/captchaCtl/captcha") > 0 || req.url.indexOf("common/captchaCtl/captcha") > 0 ||
...@@ -37,13 +35,9 @@ module.exports = function (app) { ...@@ -37,13 +35,9 @@ module.exports = function (app) {
return; return;
} }
if(xggadminsid) { if(loginsid) {
redisClient.setWithEx(xggadminsid, JSON.stringify(jsonUser), 60 * 60 * 5); redisClient.setWithEx(loginsid, JSON.stringify(jsonUser), 60 * 60 * 5);
if(jsonUser.subSid) {
redisClient.setWithEx(jsonUser.subSid, JSON.stringify(jsonUser), 60 * 60 * 5);
}
} }
req.loginUser = jsonUser; req.loginUser = jsonUser;
next(); next();
}); });
......
## index. 首页 ## index. 首页
  1 [首页1](/doc/index/index1.md)   1 [待开发](/doc/index/index1.md)
  1 [发票数据概览](/doc/index/index2.md)
  1 [发票业务汇总](/doc/index/index3.md)
  1 [交付商业务概览](/doc/index/deliver.md)
## 公共服务 ## 公共服务
  1 [公共服务](/doc/common/common.md)   1 [公共服务](/doc/common/common.md)
...@@ -22,25 +16,14 @@ ...@@ -22,25 +16,14 @@
## 登录相关 ## 登录相关
  1 [登录接口](/doc/user/login.md)   1 [登录接口](/doc/user/login.md)
## 公司管理 ## 渠道管理
  1 [公司管理](/doc/uc/manager.md)
## 订单相关接口
  1 [全部订单](/doc/order/order.md)   1 [全部订单](/doc/order/order.md)
  2 [订单办理](/doc/order/deliver.md) ## 签约主体
  3 [个体户+签约](/doc/business/businessmen.md)
## 发票接口
  1 [发票申请](/doc/invoice/apply.md)   1 [发票申请](/doc/invoice/apply.md)
  2 [全部发票](/doc/invoice/all.md) ## 商户管理
  1 [发票申请](/doc/invoice/apply.md)
  3 [交付商发票接口](/doc/invoice/deliver.md)
  4 [发票管理](/doc/invoice/info.md)
## 其他 ## 其他
......
...@@ -12,8 +12,6 @@ ...@@ -12,8 +12,6 @@
| -------- | -------- | ------------|---------| | -------- | -------- | ------------|---------|
| **loginName** | 是 | String | 登录名| | **loginName** | 是 | String | 登录名|
| **password** | 是 | String | 密码 | | **password** | 是 | String | 密码 |
| **captchaKey** | 是 | String | 图片验证码key |
| **captchaCode** | 是 | String | 图片验证码填入值 |
#### 返回结果 #### 返回结果
...@@ -22,12 +20,8 @@ ...@@ -22,12 +20,8 @@
"status": 0, "status": 0,
"msg": "success", "msg": "success",
"data": { "data": {
"auth": [1, 2, 3, 4], // 系统权限 1工商宝 2财务宝 3税务宝 4票据宝 "key": "3cb49932-fa02-44f0-90db-9f06fe02e5c7" // 登录key
"isManager": true,
"xggadminsid": "3cb49932-fa02-44f0-90db-9f06fe02e5c7" // 登录key
"menus": { "menus": {
"gtArr" : {} //个体宝菜单
"pjArr" : {} //票据宝菜单
} }
} }
} }
...@@ -35,7 +29,6 @@ ...@@ -35,7 +29,6 @@
``` ```
## **<a name="currentUser"> 当前用户信息查询</a>** ## **<a name="currentUser"> 当前用户信息查询</a>**
[返回到目录](#menu) [返回到目录](#menu)
##### URL ##### URL
...@@ -49,6 +42,11 @@ ...@@ -49,6 +42,11 @@
{ {
"status": 0, "status": 0,
"msg": "success", "msg": "success",
"data": {
"ucname": "18600440811", // 登录名
"mobile": "18600440811", // 手机号
"realName": "张三", // 姓名
}
} }
``` ```
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