Commit 540564f7 by 王昆

gsb

parent 7d79ea60
/xgg-saas-merchant/node_modules/
/bd-analysis/node_modules/
.idea/*
\ No newline at end of file
......@@ -8,7 +8,7 @@
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/xgg-saas-merchant/main.js"
"program": "${workspaceFolder}/bd-analysis/main.js"
}
]
}
\ No newline at end of file
#!/bin/bash
FROM registry.cn-beijing.aliyuncs.com/hantang2/node105:v2
MAINTAINER jy "jiangyong@gongsibao.com"
ADD xgg-saas-merchant /apps/xgg-saas-merchant/
WORKDIR /apps/xgg-saas-merchant/
ADD bd-analysis /apps/bd-analysis/
WORKDIR /apps/bd-analysis/
RUN cnpm install -S
CMD ["node","/apps/xgg-saas-merchant/main.js"]
CMD ["node","/apps/bd-analysis/main.js"]
......
{
"name": "xgg-saas-merchant",
"name": "bd-analysis",
"version": "1.0.0",
"lockfileVersion": 1,
"requires": true,
......
{
"name": "xgg-saas-merchant",
"name": "bd-analysis",
"version": "1.0.0",
"description": "h5framework",
"main": "main.js",
......
......@@ -22,7 +22,7 @@
5、利用k8s上线镜像为运行容器(这一步后续会实现为自动化)
项目版本号段分配
19. xggsaasplatform release-v25.x.x
19. bdanalysis release-v50.x.x
后续号端请继续补充
查看自己项目号段到达的数字,执行git tag | grep v【号段前缀】
......
# Default ignored files
/workspace.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/xgg-saas-merchant.iml" filepath="$PROJECT_DIR$/.idea/xgg-saas-merchant.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/main.js"
}
]
}
\ No newline at end of file
{
"editor.tabSize": 2
}
\ No newline at end of file
const system = require("../system");
const settings = require("../../config/settings");
const DocBase = require("./doc.base");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase extends DocBase {
constructor() {
super();
this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("web.common.oplogCtl");
this.oplogSve = system.getObject("service.common.oplogSve");
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
if (!params.times_tamp) {
return system.getResult(null, "请求参数times_tamp为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey] && !(params[tKey] instanceof Array)) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "签名验证失败");
}
return system.getResultSuccess();
}
/**
* 白名单验证
* @param {*} gname 组名
* @param {*} methodname 方法名
*/
async isCheckWhiteList(gname, methodname) {
var fullname = gname + "." + methodname;
var lst = [
"test.testApi",
"inner.registerInner",
"inner.resetPasswordInner",
];
var x = lst.indexOf(fullname);
return x >= 0;
}
async checkAcck(gname, methodname, pobj, query, req) {
var appInfo = null;
var result = system.getResultSuccess();
var ispass = await this.isCheckWhiteList(gname, methodname);
var appkey = req.headers["accesskey"];
var app_id = req.headers["app_id"];
if (ispass) {
return result;
}//在白名单里面
if (app_id) {
appInfo = await this.cacheManager["ApiAppIdCheckCache"].cache(app_id, null, 3000);
if (!appInfo) {
result.status = system.appidFail;
result.msg = "请求头app_id值失效,请重新获取";
}
var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
if (signResult.status != 0) {
result.status = system.signFail;
result.msg = signResult.msg;
}
}//验签
else if (appkey) {
appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000);
if (!appInfo || !appInfo.app) {
result.status = system.tokenFail;
result.msg = "请求头accesskey失效,请重新获取";
}
}//验证accesskey
else {
result.status = -1;
result.msg = "请求头没有相关访问参数,请验证后在进行请求";
}
return result;
}
async doexec(gname, methodname, pobj, query, req) {
var requestid = this.getUUID();
try {
//验证accesskey或验签
var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
if (isPassResult.status != 0) {
isPassResult.requestid = "";
return isPassResult;
}
if (pobj && pobj.action_body) {
pobj.action_body.merchant_id = pobj.action_body.merchant_id || req.headers["app_id"];
}
if (query) {
query.merchant_id = req.headers["app_id"];
}
var rtn = await this[methodname](pobj, query, req);
rtn.requestid = requestid;
this.oplogSve.createDb({
appid: req.headers["app_id"] || "",
appkey: req.headers["accesskey"] || "",
requestId: requestid,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.error({
appid: req.headers["app_id"] || "",
appkey: req.headers["accesskey"] || "",
requestId: requestid,
op: pobj.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
rtnerror.requestid = requestid;
return rtnerror;
}
}
}
module.exports = APIBase;
const system=require("../system");
const uuidv4 = require('uuid/v4');
class DocBase{
constructor(){
this.apiDoc={
group:"逻辑分组",
groupDesc:"",
name:"",
desc:"请对当前类进行描述",
exam:"概要示例",
methods:[]
};
this.initClassDoc();
}
initClassDoc(){
this.descClass();
this.descMethods();
}
descClass(){
var classDesc= this.classDesc();
this.apiDoc.group=classDesc.groupName;
this.apiDoc.groupDesc=classDesc.groupDesc;
this.apiDoc.name=classDesc.name;
this.apiDoc.desc=classDesc.desc;
this.apiDoc.exam=this.examHtml();
}
examHtml(){
var exam= this.exam();
exam=exam.replace(/\\/g,"<br/>");
return exam;
}
exam(){
throw new Error("请在子类中定义类操作示例");
}
classDesc(){
throw new Error(`
请重写classDesc对当前的类进行描述,返回如下数据结构
{
groupName:"auth",
groupDesc:"认证相关的包"
desc:"关于认证的类",
exam:"",
}
`);
}
descMethods(){
var methoddescs=this.methodDescs();
for(var methoddesc of methoddescs){
for(var paramdesc of methoddesc.paramdescs){
this.descMethod(methoddesc.methodDesc,methoddesc.methodName
,paramdesc.paramDesc,paramdesc.paramName,paramdesc.paramType,
paramdesc.defaultValue,methoddesc.rtnTypeDesc,methoddesc.rtnType);
}
}
}
methodDescs(){
throw new Error(`
请重写methodDescs对当前的类的所有方法进行描述,返回如下数据结构
[
{
methodDesc:"生成访问token",
methodName:"getAccessKey",
paramdescs:[
{
paramDesc:"访问appkey",
paramName:"appkey",
paramType:"string",
defaultValue:"x",
},
{
paramDesc:"访问secret",
paramName:"secret",
paramType:"string",
defaultValue:null,
}
],
rtnTypeDesc:"xxxx",
rtnType:"xxx"
}
]
`);
}
descMethod(methodDesc,methodName,paramDesc,paramName,paramType,defaultValue,rtnTypeDesc,rtnType){
var mobj=this.apiDoc.methods.filter((m)=>{
if(m.name==methodName){
return true;
}else{
return false;
}
})[0];
var param={
pname:paramName,
ptype:paramType,
pdesc:paramDesc,
pdefaultValue:defaultValue,
};
if(mobj!=null){
mobj.params.push(param);
}else{
this.apiDoc.methods.push(
{
methodDesc:methodDesc?methodDesc:"",
name:methodName,
params:[param],
rtnTypeDesc:rtnTypeDesc,
rtnType:rtnType
}
);
}
}
}
module.exports=DocBase;
\ No newline at end of file
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
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ConfigAPI extends APIBase {
constructor() {
super();
this.metaS = system.getObject("service.common.metaSve");
}
//返回
async fetchAppConfig(pobj, qobj, req) {
var cfg = await this.metaS.getUiConfig(settings.appKey, null, 100);
if (cfg) {
return system.getResultSuccess(cfg);
}
return system.getResultFail();
}
exam(){
return "xxx";
}
classDesc() {
return {
groupName: "",
groupDesc: "",
name: "",
desc: "",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: "",
methodName: "",
paramdescs: [
{
paramDesc: "",
paramName: "",
paramType: "",
defaultValue: "",
}
],
rtnTypeDesc: "",
rtnType: ""
}
];
}
}
module.exports = ConfigAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class OpCacheAPI extends APIBase {
constructor() {
super();
this.cacheSve = system.getObject("service.common.cacheSve");
}
//返回
async opCacheData(pobj, qobj, req) {
if (pobj.action_type == "findAndCountAll") {
return await this.cacheSve.findAndCountAll(pobj.body);
} else if (pobj.action_type == "delCache") {
return await this.cacheSve.delCache(pobj.body);
} else if (pobj.action_type == "clearAllCache") {
return await this.cacheSve.clearAllCache(pobj.body);
} else {
return system.getResultFail();
}
}
exam() {
return "xxx";
}
classDesc() {
return {
groupName: "",
groupDesc: "",
name: "",
desc: "",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: "",
methodName: "",
paramdescs: [
{
paramDesc: "",
paramName: "",
paramType: "",
defaultValue: null,
}
],
rtnTypeDesc: "",
rtnType: ""
}
];
}
// exam() {
// return "";
// }
// classDesc() {
// return {
// groupName: "",
// groupDesc: "",
// name: "",
// desc: "",
// exam: "",
// };
// }
// methodDescs() {
// return [
// {
// methodDesc: "",
// methodName: "",
// paramdescs: [
// {
// paramDesc: "",
// paramName: "",
// paramType: "",
// defaultValue: "",
// }
// ],
// rtnTypeDesc: "",
// rtnType: ""
// }
// ];
// }
}
module.exports = OpCacheAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TestAPI extends APIBase {
constructor() {
super();
this.orderSve = system.getObject("service.order.orderSve");
this.platformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async test(pobj, query, req) {
// var tmp = await this.orderSve.createLicense(pobj.action_body);
//获取验证码
// await this.platformUtils.fetchVCode(pobj.action_body.mobile);
//创建用户
// var result = await this.platformUtils.createUserInfo("13075556691", "13075556693", "9366");
//创建用户
var result = await this.platformUtils.login("13075556691", "9366");
return result;
}
exam() {
return "";
}
classDesc() {
return {
groupName: "",
groupDesc: "",
name: "",
desc: "",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: "",
methodName: "",
paramdescs: [
{
paramDesc: "",
paramName: "",
paramType: "",
defaultValue: "",
}
],
rtnTypeDesc: "",
rtnType: ""
}
];
}
}
module.exports = TestAPI;
\ No newline at end of file
const system = require("../system");
const settings = require("../../config/settings");
class CtlBase {
constructor(gname, sname) {
this.serviceName = sname;
this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager");
this.md5 = require("MD5");
}
encryptPasswd(passwd) {
if (!passwd) {
throw new Error("请输入密码");
}
var md5 = this.md5(passwd + "_" + settings.salt);
return md5.toString().toLowerCase();
}
notify(req, msg) {
if (req.session) {
req.session.bizmsg = msg;
}
}
async findOne(queryobj, qobj) {
var rd = await this.service.findOne(qobj);
return system.getResult(rd, null);
}
async findAndCountAll(queryobj, obj, req) {
obj.codepath = req.codepath;
if (req.session.user) {
obj.uid = req.session.user.id;
obj.appid = req.session.user.app_id;
obj.onlyCode = req.session.user.unionId;
obj.account_id = req.session.user.account_id;
obj.ukstr = req.session.user.app_id + "¥" + req.session.user.id + "¥" + req.session.user.nickName + "¥" + req.session.user.headUrl;
}
var apps = await this.service.findAndCountAll(obj);
return system.getResult(apps, null);
}
async refQuery(queryobj, qobj) {
var rd = await this.service.refQuery(qobj);
return system.getResult(rd, null);
}
async bulkDelete(queryobj, ids) {
var rd = await this.service.bulkDelete(ids);
return system.getResult(rd, null);
}
async delete(queryobj, qobj) {
var rd = await this.service.delete(qobj);
return system.getResult(rd, null);
}
async create(queryobj, qobj, req) {
if (req && req.session && req.session.app) {
qobj.app_id = req.session.app.id;
qobj.onlyCode = req.session.user.unionId;
if (req.codepath) {
qobj.codepath = req.codepath;
}
}
var rd = await this.service.create(qobj);
return system.getResult(rd, null);
}
async update(queryobj, qobj, req) {
if (req && req.session && req.session.user) {
qobj.onlyCode = req.session.user.unionId;
}
if (req.codepath) {
qobj.codepath = req.codepath;
}
var rd = await this.service.update(qobj);
return system.getResult(rd, null);
}
static getServiceName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve";
}
async initNewInstance(queryobj, req) {
return system.getResult({}, null);
}
async findById(oid) {
var rd = await this.service.findById(oid);
return system.getResult(rd, null);
}
async timestampConvertDate(time) {
if (time == null) {
return "";
}
var date = new Date(Number(time * 1000));
var y = 1900 + date.getYear();
var m = "0" + (date.getMonth() + 1);
var d = "0" + date.getDate();
return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
}
async universalTimeConvertLongDate(time) {
if (time == null) {
return "";
}
var d = new Date(time);
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
}
async universalTimeConvertShortDate(time) {
if (time == null) {
return "";
}
var d = new Date(time);
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
}
async doexec(methodname, pobj, query, req, res) {
try {
var rtn = await this[methodname](pobj, query, req, res);
return rtn;
} catch (e) {
console.log(e.stack);
// this.logCtl.error({
// optitle: "Ctl调用出错",
// op: pobj.classname + "/" + methodname,
// content: e.stack,
// clientIp: pobj.clientIp
// });
return system.getResultFail(-200, "Ctl出现异常,请联系管理员");
}
}
trim(o) {
if(!o) {
return "";
}
return o.toString().trim();
}
doTimeCondition(params, fields) {
if (!params || !fields || fields.length == 0) {
return;
}
for (var f of fields) {
if (params[f]) {
var suffix = this.endWith(f, 'Begin') ? " 00:00:00" : " 23:59:59";
params[f] = params[f] + suffix;
}
}
}
endWith(source, str){
if(!str || !source || source.length == 0 || str.length > source.length) {
return false;
}
return source.substring(source.length - str.length) == str;
}
}
module.exports = CtlBase;
const system = require("../system");
const settings = require("../../config/settings");
class CtlBase {
constructor() {
this.restClient = system.getObject("util.restClient");
}
async doexec(methodname, pobj, query, req) {
try {
var rtn = await this[methodname](pobj, query, req);
return rtn;
} catch (e) {
console.log(e.stack);
return system.getResultFail(-200, "Ctl出现异常,请联系管理员");
}
}
encryptPasswd(passwd) {
if (!passwd) {
throw new Error("请输入密码");
}
var md5 = this.md5(passwd + "_" + settings.salt);
return md5.toString().toLowerCase();
}
trim(o) {
if(!o) {
return "";
}
return o.toString().trim();
}
doTimeCondition(params, fields) {
if (!params || !fields || fields.length == 0) {
return;
}
for (var f of fields) {
if (params[f]) {
var suffix = this.endWith(f, 'Begin') ? " 00:00:00" : " 23:59:59";
params[f] = params[f] + suffix;
}
}
}
endWith(source, str){
if(!str || !source || source.length == 0 || str.length > source.length) {
return false;
}
return source.substring(source.length - str.length) == str;
}
}
module.exports = CtlBase;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
var cacheBaseComp = null;
class UserCtl extends CtlBase {
constructor() {
super("auth", CtlBase.getServiceName(UserCtl));
this.redisClient = system.getObject("util.redisClient");
this.captchaSve = system.getObject("service.common.captchaSve");
this.platformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async smsCode(qobj, pobj, req) {
var mobile = this.trim(qobj.mobile);
try {
if (!/^1[23456789]\d{9}$/.test(mobile)) {
return system.getResult(null, "手机号码格式不正确");
}
// TODO 发送短信验证码
return system.getResultSuccess("发送成功");
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async login(pobj, pobj2, req, res) {
var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password);
var captchaKey = this.trim(pobj.captchaKey);
var captchaCode = this.trim(pobj.captchaCode);
try {
var vrs = await this.captchaSve.valid({
key: captchaKey,
code: captchaCode,
});
if (vrs.status !== 0) {
// return vrs;
}
// 查用户
var loginrs = await this.platformUtils.login(loginName, password);
if(loginrs.status !== 0) {
return loginrs;
}
var user = await this.service.authByCode(loginrs.data.opencode);
req.session.user = user;
var xggadminsid = await this.setLogin(user);
return system.getResultSuccess(xggadminsid);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async setLogin(user) {
var xggadminsid = uuidv4();
xggadminsid = "3cb49932-fa02-44f0-90db-9f06fe02e5c7";
await this.redisClient.setWithEx(xggadminsid, JSON.stringify(user), 60 * 60);
return xggadminsid;
}
async forgetPassword(qobj, pobj, req, res) {
var mobile = this.trim(pobj.mobile);
var vcode = this.trim(pobj.vcode);
var password = this.trim(qobj.password);
try {
} catch (error) {
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async currentUser(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser);
}
async getMenu(qobj, pobj, req) {
var menu = [{
"name": "首页",
"path": "/",
"submenu": []
},
{
"name": "商户中心",
"path": "/merchants",
"submenu": [{
"name": "客户管理",
"team": [{
"name": "商户信息",
"path": "/merchants/businessInformation"
},
{
"name": "签约信息",
"path": "/merchants/contractInformation"
},
{
"name": "地址信息",
"path": "/merchants/addressInformation"
},
{
"name": "抬头信息",
"path": "/merchants/lookUpInformation"
}
]
}]
},
{
"name": "业务中心",
"path": "/trading",
"submenu": [{
"name": "订单管理",
"team": [{
"name": "订单信息",
"path": "/trading/orderInformation"
}]
},
{
"name": "个体户管理",
"team": [{
"name": "用户信息",
"path": "/trading/userInformation"
},
{
"name": "用户签约",
"path": "/trading/usersSignUp"
}
]
},
{
"name": "发票管理",
"team": [{
"name": "发票申请",
"path": "/trading/invoiceApplyFor"
},
{
"name": "发票管理",
"path": "/trading/invoiceManagement"
}
]
}
]
},
{
"name": "财务中心",
"path": "/financial",
"submenu": [{
"name": "资金管理",
"team": [{
"name": "资金账户",
"path": "/financial/capitalAccount"
},
{
"name": "充值申请",
"path": "/financial/topUpApplication"
},
{
"name": "资金交易",
"path": "/financial/cashTransactions"
},
{
"name": "资金流水",
"path": "/financial/capitalFlows"
}
]
}]
},
{
"name": "数据中心",
"path": "/information",
"submenu": [{
"name": "暂无",
"team": [{
"name": "暂无",
"path": ""
}]
}]
},
{
"name": "系统中心",
"path": "/system",
"submenu": [{
"name": "信息维护",
"team": [{
"name": "注册地信息",
"path": "/system/registered"
},
{
"name": "经营范围信息",
"path": "/system/businessScope"
},
{
"name": "交付商信息",
"path": "/system/delivery"
},
{
"name": "发票内容信息",
"path": "/system/invoiceContent"
}
]
}]
}
]
return system.getResultSuccess(menu);
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(req) {
var opencode = req.query.code;
var user = await this.service.authByCode(opencode);
if (user) {
req.session.user = user;
} else {
req.session.user = null;
}
//缓存opencode,方便本应用跳转到其它应用
// /auth?code=xxxxx,缓存没有意义,如果需要跳转到其它应用,需要调用
//平台开放的登录方法,返回 <待跳转的目标地址>/auth?code=xxxxx
//this.cacheManager["OpenCodeCache"].cacheOpenCode(user.id,opencode);
return user;
}
async navSysSetting(pobj, qobj, req) {
//开始远程登录,返回code
var jumpobj = await this.service.navSysSetting(req.session.user);
if (jumpobj) {
return system.getResultSuccess(jumpobj);
}
return system.getResultFail();
}
async loginUser(qobj, pobj, req) {
return super.findById(req.session.user.id);
}
async initNewInstance(queryobj, req) {
var rtn = {};
rtn.roles = [];
if (rtn) {
return system.getResultSuccess(rtn);
}
return system.getResultFail();
}
async checkLogin(gobj, qobj, req) {
//当前如果缓存中存在user,还是要检查当前user所在的域名,如果不和来访一致,则退出重新登录
if (req.session.user) {
return system.getResultSuccess(req.session.user);
} else {
req.session.user = null;
return system.getResult(null, "用户未登录", req);
}
}
async exit(pobj, qobj, req) {
req.session.user = null;
req.session.destroy();
return system.getResultSuccess({
"env": settings.env
});
}
}
module.exports = UserCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class BusinessscopeCtl extends CtlBase {
constructor() {
super();
//this.appS=system.getObject("service.appSve");
this.businessscopeSve = system.getObject("service.common.businessscopeSve");
}
async page(pobj, pobj2, req) {
try {
return await this.businessscopeSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.businessscopeSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.businessscopeSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.businessscopeSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async byDomicile(pobj, pobj2, req) {
try {
return await this.businessscopeSve.byDomicile(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = BusinessscopeCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
class CaptchaCtl extends CtlBase {
constructor() {
super();
//this.appS=system.getObject("service.appSve");
this.captchaSve = system.getObject("service.common.captchaSve");
}
async captcha(pobj, pobj2, req) {
try {
return await this.captchaSve.captcha(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = CaptchaCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class DeliverCtl extends CtlBase {
constructor() {
super();
this.deliverSve = system.getObject("service.common.deliverSve");
}
async all(pobj, pobj2, req) {
try {
return await this.deliverSve.all(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async page(pobj, pobj2, req) {
try {
return await this.deliverSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.deliverSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.deliverSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.deliverSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverUserPage(pobj, pobj2, req) {
try {
return await this.deliverSve.deliverUserPage(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverUserById(pobj, pobj2, req) {
try {
return await this.deliverSve.deliverUserById(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverUserSave(pobj, pobj2, req) {
try {
return await this.deliverSve.deliverUserSave(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async allOrg(pobj, pobj2, req) {
try {
return await this.deliverSve.allOrg(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async orgTree(pobj, pobj2, req) {
try {
return await this.deliverSve.orgTree(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async orgById(pobj, pobj2, req) {
try {
return await this.deliverSve.orgById(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async orgSave(pobj, pobj2, req) {
try {
return await this.deliverSve.orgSave(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = DeliverCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class DomicileCtl extends CtlBase {
constructor() {
super();
//this.appS=system.getObject("service.appSve");
this.domicileSve = system.getObject("service.common.domicileSve");
}
async nameList(pobj, pobj2, req) {
try {
return await this.domicileSve.nameList(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async all(pobj, pobj2, req) {
try {
return await this.domicileSve.tree(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async page(pobj, pobj2, req) {
try {
return await this.domicileSve.page(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.domicileSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.domicileSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.domicileSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = DomicileCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
var svgCaptcha = require('svg-captcha');
class InvoicecontentCtl extends CtlBase {
constructor() {
super();
this.invoicecontentSve = system.getObject("service.common.invoicecontentSve");
}
async list(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.list(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async info(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.info(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async save(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.save(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async del(pobj, pobj2, req) {
try {
return await this.invoicecontentSve.del(pobj);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = InvoicecontentCtl;
\ No newline at end of file
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
class OplogCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(OplogCtl));
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(qobj) {
var u = uuidv4();
var aid = u.replace(/\-/g, "");
var rd = { name: "", appid: aid }
return system.getResultSuccess(rd, null);
}
async debug(obj) {
obj.logLevel = "debug";
return this.create(obj);
}
async info(obj) {
obj.logLevel = "info";
return this.create(obj);
}
async warn(obj) {
obj.logLevel = "warn";
return this.create(obj);
}
async error(obj) {
obj.logLevel = "error";
return this.create(obj);
}
async fatal(obj) {
obj.logLevel = "fatal";
return this.create(obj);
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid_Ctl(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo_Ctl(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
module.exports = OplogCtl;
var System = require("../../../system")
const crypto = require('crypto');
var fs = require("fs");
var accesskey = '3KV9nIwW8qkTGlrPmAe3HnR3fzM6r5';
var accessKeyId = 'LTAI4GC5tSKvqsH2hMqj6pvd';
var url = "https://gsb-zc.oss-cn-beijing.aliyuncs.com";
class UploadCtl {
constructor() {
this.cmdPdf2HtmlPattern = "docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 '{fileName}'";
this.restS = System.getObject("util.execClient");
this.cmdInsertToFilePattern = "sed -i 's/id=\"page-container\"/id=\"page-container\" contenteditable=\"true\"/'";
//sed -i 's/1111/&BBB/' /tmp/input.txt
//sed 's/{position}/{content}/g' {path}
}
async getOssConfig() {
var policyText = {
"expiration": "2119-12-31T16:00:00.000Z",
"conditions": [
["content-length-range", 0, 1048576000],
["starts-with", "$key", "zc"]
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha1', accesskey).update(policyBase64).digest().toString('base64'); //base64
var data = {
OSSAccessKeyId: accessKeyId,
policy: policyBase64,
Signature: signature,
Bucket: 'gsb-zc',
success_action_status: 201,
url: url
};
return data;
};
async upfile(srckey, dest) {
var oss = System.getObject("util.ossClient");
var result = await oss.upfile(srckey, "/tmp/" + dest);
return result;
};
async downfile(srckey) {
var oss = System.getObject("util.ossClient");
var downfile = await oss.downfile(srckey).then(function () {
downfile = "/tmp/" + srckey;
return downfile;
});
return downfile;
};
async pdf2html(obj) {
var srckey = obj.key;
var downfile = await this.downfile(srckey);
var cmd = this.cmdPdf2HtmlPattern.replace(/\{fileName\}/g, srckey);
var rtn = await this.restS.exec(cmd);
var path = "/tmp/" + srckey.split(".pdf")[0] + ".html";
var a = await this.insertToFile(path);
fs.unlink("/tmp/" + srckey);
var result = await this.upfile(srckey.split(".pdf")[0] + ".html", srckey.split(".pdf")[0] + ".html");
return result.url;
};
async insertToFile(path) {
var cmd = this.cmdInsertToFilePattern + " " + path;
return await this.restS.exec(cmd);
};
}
module.exports = UploadCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class ManagerCtl extends CtlBase {
constructor() {
super();
this.invoiceSve = system.getObject("service.invoice.invoiceSve");
}
/**
* 交易数据(平台)
* @param {*} pobj
*/
async transData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 交易数据
return await this.invoiceSve.statManageData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页业务数据(平台)
* @param {*} pobj
*/
async businessData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 业务数据
return await this.invoiceSve.statBusinessData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页交易数据(交付商)
* @param {*} pobj
*/
async delTransData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
delivererId:this.trim(pobj.delivererId)
};
// 交易数据
return await this.invoiceSve.delStatManageData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页业务数据(交付商)
* @param {*} pobj
*/
async delBusinessData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
delivererId:this.trim(pobj.delivererId)
};
// 业务数据
return await this.invoiceSve.delStatBusinessData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
//业务概览 (平台)
async deliverData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
currentPage: pobj.currentPage || 1,
pageSize: pobj.pageSize || 10,
}
// 业务办理概览
return await this.invoiceSve.statDeliverData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
}
module.exports = ManagerCtl;
\ No newline at end of file
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctlms.base");
const logCtl = system.getObject("web.common.oplogCtl");
var cacheBaseComp = null;
class ManagerCtl extends CtlBase {
constructor() {
super();
this.orderSve = system.getObject("service.order.orderSve");
this.invoiceSve = system.getObject("service.invoice.invoiceSve");
}
/**
* 首页交易数据
* @param {*} pobj
*/
async transData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 交易数据
return await this.orderSve.statManageData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
/**
* 首页业务数据
* @param {*} pobj
*/
async businessData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
};
// 业务数据
return await this.orderSve.statBusinessData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
async deliverData(pobj, pobj2, req) {
try {
var params = {
type: pobj.type || 1,
currentPage: pobj.currentPage || 1,
pageSize: pobj.pageSize || 10,
}
// 业务办理概览
return await this.orderSve.statDeliverData(params);
} catch (e) {
console.log(e);
return system.getResultFail(500, "接口错误");
}
}
// 交付商统计
async deliverStatTransData(pobj, pobj2, req) {
if(!pobj.current_date){
let nowTime =new Date();
let month = nowTime.getMonth() + 1;
month = month<10?"0"+month:month;
pobj.current_date = nowTime.getFullYear()+"-"+month;
}
pobj.deliver_id = req.body.deliver_id;
try {
return await this.orderSve.deliverStatTransData(pobj);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
// 业务办理
async businessManagement(pobj, pobj2, req) {
if(!pobj.current_date){
let nowTime =new Date();
let month = nowTime.getMonth() + 1;
month = month<10?"0"+month:month;
pobj.current_date = nowTime.getFullYear()+"-"+month;
}
pobj.deliver_id = req.body.deliver_id;
try {
return await this.orderSve.businessManagement(pobj);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = ManagerCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class BusinessmenCtl extends CtlBase {
constructor() {
super();
this.businessmenSve = system.getObject("service.saas.businessmenSve");
}
/**
* 个体户列表
* @param params
* @param pobj2
* @param req
* @returns {Promise<void>}
*/
async saasorderbusinessmenPage (params, pobj2, req){
if(!params.saas_merchant_id){
return system.getResult(null,`请重新登陆`)
}
params.merchant_id = params.saas_merchant_id;
return await this.businessmenSve.saasorderbusinessmenPage(params);
}
}
module.exports = BusinessmenCtl;
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class ChannelCtl extends CtlBase {
constructor() {
super();
this.channelSve = system.getObject("service.saas.channelSve");
}
async dics(params, pobj2, req) {
try {
return await this.channelSve.dics(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async info(params, pobj2, req) {
try {
return await this.channelSve.info(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async page(params, pobj2, req) {
try {
return await this.channelSve.page(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async save(params, pobj2, req) {
try {
return await this.channelSve.save(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = ChannelCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class MainCtl extends CtlBase {
constructor() {
super();
this.mainSve = system.getObject("service.saas.mainSve");
}
async dics(params, pobj2, req) {
try {
return await this.mainSve.dics(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async info(params, pobj2, req) {
try {
return await this.mainSve.info(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async page(params, pobj2, req) {
try {
return await this.mainSve.page(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async save(params, pobj2, req) {
try {
return await this.mainSve.save(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = MainCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class MerchantCtl extends CtlBase {
constructor() {
super();
this.merchantSve = system.getObject("service.saas.merchantSve");
}
async dics(params, pobj2, req) {
try {
return await this.merchantSve.dics(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
// 开票类型字典获取
async feeTypeDic(params, pobj2, req) {
try {
params.forceUpdate = true;
let feeType = await this.merchantSve.getFeeTypeWithCache(params);
// let dic = [{"type": "00", "name": "注册订单付款"}, {"type": "10", "name": "转账交易付款10(仅供测试)"}, {"type": "20", "name": "转账交易付款20(仅供测试)"}];
let dic = [{"type": "00", "name": "注册订单付款"}, {"type": feeType, "name": "转账交易付款"}];
return system.getResultSuccess(dic);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async info(params, pobj2, req) {
try {
return await this.merchantSve.info(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async page(params, pobj2, req) {
try {
this.doTimeCondition(params, ["createBegin", "createEnd"]);
return await this.merchantSve.page(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async signPage(params, pobj2, req) {
try {
params.is_sign = 1;
this.doTimeCondition(params, ["createBegin", "createEnd"]);
return await this.merchantSve.page(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async save(params, pobj2, req) {
try {
return await this.merchantSve.save(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async sign(params, pobj2, req) {
try {
params.bm_reg_price = system.y2f(params.bm_reg_price || 0);
params.invoice_service_rate = system.y2f(params.invoice_service_rate || 0);
params.trans_service_rate = system.y2f(params.trans_service_rate || 0);
return await this.merchantSve.sign(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async signInfo(params, pobj2, req) {
try {
return await this.merchantSve.signInfo(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async title(params, pobj2, req) {
try {
return await this.merchantSve.title(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async addr(params, pobj2, req) {
try {
return await this.merchantSve.addr(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async saveAddr(params, pobj2, req) {
try {
if(!params.id) {
return system.getResult(null, "编辑失败,请联系平台增加开票信息");
}
if(!params.mail_to) {
return system.getResult(null, `联系人不能为空`);
}
if(!params.mail_mobile) {
return system.getResult(null, `联系电话不能为空`);
}
if(!params.mail_addr) {
return system.getResult(null, `邮寄地址不能为空`);
}
return await this.merchantSve.saveAddr(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async getFeeTypeWithCache(params, pobj2, req){
let res = await this.merchantSve.getFeeTypeWithCache(params);
return system.getResult({type: res});
}
}
module.exports = MerchantCtl;
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class ChannelCtl extends CtlBase {
constructor() {
super();
this.orderSve = system.getObject("service.saas.orderSve");
this.merchantSve = system.getObject("service.saas.merchantSve");
}
async microAdd(params, pobj2, req) {
try {
return await this.orderSve.microAdd(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async info(params, pobj2, req) {
try {
return await this.orderSve.info(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async page(params, pobj2, req) {
try {
return await this.orderSve.page(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async checkPay(params, pobj2, req) {
try {
if(!params.ids || params.ids.length == 0) {
return system.getResult(null, "请至少选择一笔订单");
}
let omap = await this.orderSve.mapByIds({ids: params.ids, attrs: "id, pay_status, price"});
let totalPrice = 0;
let totalNum = 0;
for(let id of params.ids) {
let obj = omap[id];
if(!obj || obj.pay_status !== "10") {
return system.getResult(null , "选择的订单中存在已支付的订单");
}
totalPrice = totalPrice + Number(obj.price);
}
totalNum = params.ids.length;
totalPrice = system.f2y(totalPrice);
let info = await this.merchantSve.signInfo({id: params.saas_merchant_id}) || {};
info = info.data || {};
let main = info.main || {};
let result = {
totalNum : totalNum,
totalPrice : totalPrice,
account_name: main.bank_account,
account_bank_name: main.bank_name,
account_bank_no: main.bank_no,
}
// 获取商户信息
return system.getResult(result);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async offlinePay(params, pobj2, req) {
try {
if(!params.ids || params.ids.length == 0) {
return system.getResult(null, "请至少选择一笔订单");
}
if (!this.trim(params.pay_voucher_img)) {
return system.getResult(null, "请上传付款凭证");
}
if (!this.trim(params.merchant_deliver_man)) {
return system.getResult(null, "请填写交付联系人");
}
if (!this.trim(params.merchant_deliver_mobile)) {
return system.getResult(null, "请填写联系人电话");
}
if (!this.trim(params.merchant_deliver_addr)) {
return system.getResult(null, "请填写邮寄地址");
}
return await this.orderSve.offlinePay(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = ChannelCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class TaxCtl extends CtlBase {
constructor() {
super();
this.taxSve = system.getObject("service.tax.taxSve");
this.orderSve = system.getObject("service.saas.orderSve");
this.redisClient = system.getObject("util.redisClient");
}
/**
* 月账期
* @param {*} params
*/
async getReportData(params) {
try {
let res = await this.taxSve.getReportData(params);
return system.getResult(res);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 季度账期
* @param {*} params
*/
async getReportDataQuarter(params) {
try {
let res = await this.taxSve.getReportDataQuarter(params);
return system.getResult(res);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 获取账簿用户信息
* @param {*} pobj
* @param {*} pobj2
* @param {*} req
* @id
*/
async getCustomerById(pobj, pobj2, req) {
try {
// if (!pobj.id) {
// return system.getResult(null, `参数错误 ID 不能为空`);
// }
let res = await this.taxSve.getCustomerById(pobj);
return res;
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
async businessmenPage(pobj, pobj2, req) {
try {
let res = await this.orderSve.businessmenPage(pobj);
return res;
} catch (error) {
console.log(error);
return system.getResult(error);
}
}
}
module.exports = TaxCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class TradeCtl extends CtlBase {
constructor() {
super();
this.tradeSve = system.getObject("service.trade.tradeSve");
this.redisClient = system.getObject("util.redisClient");
}
async orderPage(params, pobj2, req) {
try {
this.doTimeCondition(params, ["createBegin", "createEnd"]);
return await this.tradeSve.orderPage(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async parseItems(params, pobj2, req) {
try {
params.fileName = req.loginUser.id;
return await this.tradeSve.parseItems(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async orderInfo(params, pobj2, req) {
try {
return await this.tradeSve.orderInfo(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async lockOrder(params, pobj2, req) {
try {
return await this.tradeSve.lockOrder(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async offlinePay(params, pobj2, req) {
try {
return await this.tradeSve.offlinePay(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async itemPage(params, pobj2, req) {
try {
this.doTimeCondition(params, ["createBegin", "createEnd"]);
return await this.tradeSve.itemPage(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = TradeCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class AuthCtl extends CtlBase {
constructor() {
super();
this.authSve = system.getObject("service.uc.authSve");
}
/**
* 菜单 添加
* @param {*} params
*/
async addAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
var auth = {
pid: Number(params.pid || 0),
saas_id: params.saas_id,
menuType: Number(params.menuType || 0),
name: this.trim(params.name),
icon: this.trim(params.icon),
path: this.trim(params.path),
sort: 99,
};
return await this.authSve.addAuth(auth);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 更新
* @param {*} params
*/
async updAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
var auth = {
id: Number(params.id),
pid: Number(params.pid || 0),
saas_id: params.saas_id,
menuType: Number(params.menuType || 0),
name: this.trim(params.name),
icon: this.trim(params.icon),
path: this.trim(params.path),
};
try {
return await this.authSve.updAuth(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 删除
* @param {*} params
*/
async delAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.delAuth(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 菜单 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async byPid(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.byPid(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询整个树结构
* @param {*} params
*/
async tree(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.authSve.tree(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = AuthCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class OrgCtl extends CtlBase {
constructor() {
super();
this.orgSve = system.getObject("service.uc.orgSve");
}
/**
* 组织机构 添加
* @param {*} params
*/
async addOrg(params, pobj2, req) {
try {
params.saas_id = req.loginUser.saas_id;
return await this.orgSve.addOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 更新
* @param {*} params
*/
async updOrg(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.updOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 删除
* @param {*} params
*/
async delOrg(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.delOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 查询列表
* @param {*} params
*/
async listOrg(params, pobj2, req) {
try {
params.saas_id = req.loginUser.saas_id;
return await this.orgSve.listOrg(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 组织机构 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.orgSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async byPid(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.byPid(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询整个树结构
* @param {*} params
*/
async tree(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.orgSve.tree(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = OrgCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class RoleCtl extends CtlBase {
constructor() {
super();
this.roleSve = system.getObject("service.uc.roleSve");
}
/**
* saas 添加
* @param {*} params
*/
async addRole(params, pobj2, req) {
try {
params.saas_id = req.loginUser.saas_id;
return await this.roleSve.addRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 更新
* @param {*} params
*/
async updRole(params, pobj2, req) {
try {
return await this.roleSve.updRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 删除
* @param {*} params
*/
async delRole(params, pobj2, req) {
try {
return await this.roleSve.delRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询列表
* @param {*} params
*/
async listRole(params, pobj2, req) {
try {
return await this.roleSve.listRole(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.roleSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async setAuth(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try {
return await this.roleSve.setAuth(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = RoleCtl;
\ No newline at end of file
var system = require("../../../system")
const CtlBase = require("../../ctlms.base");
class SaasCtl extends CtlBase {
constructor() {
super();
this.saasSve = system.getObject("service.uc.saasSve");
}
/**
* saas 添加
* @param {*} params
*/
async addSaas(params, pobj2, req) {
try {
return await this.saasSve.addSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 更新
* @param {*} params
*/
async updSaas(params, pobj2, req) {
try {
return await this.saasSve.updSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 删除
* @param {*} params
*/
async delSaas(params, pobj2, req) {
try {
return await this.saasSve.delSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询列表
* @param {*} params
*/
async listSaas(params, pobj2, req) {
try {
return await this.saasSve.listSaas(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* saas 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.saasSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = SaasCtl;
\ No newline at end of file
var system = require("../../../system")
const settings = require("../../../../config/settings")
const CtlBase = require("../../ctlms.base");
const md5 = require("MD5");
const uuidv4 = require('uuid/v4');
const logCtl = system.getObject("web.common.oplogCtl");
class UserCtl extends CtlBase {
constructor() {
super();
this.userSve = system.getObject("service.uc.userSve");
this.redisClient = system.getObject("util.redisClient");
this.captchaSve = system.getObject("service.common.captchaSve");
this.deliverSve = system.getObject("service.common.deliverSve");
}
async login(pobj, pobj2, req, res) {
var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password);
try {
var loginUser = await this.userSve.login({
ucname: loginName,
password: password,
});
if (loginUser.status != 0) {
return loginUser;
}
loginUser = loginUser.data;
var loginsid = await this.setLogin(loginUser);
let rs = {
key: loginsid,
loginname: loginUser.ucname,
menus: await this.getMenu(loginUser)
};
return system.getResultSuccess(rs);
} catch (error) {
console.log(error);
return system.getResultFail(500, "接口异常:" + error.message);
}
}
async setLogin(user) {
let loginsid = "saasmcth_" + uuidv4();
// if (settings.env = "dev") {
// loginsid = "saasmcth_" + "2cb49932-fa02-44f0-90db-9f06fe02e5c7";
// }
await this.redisClient.setWithEx(loginsid, JSON.stringify(user), 60 * 60 * 5);
return loginsid;
}
getMenu(loginUser) {
if (!loginUser) {
return [];
}
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"
}, ]
},
];
}
async currentUser(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser);
}
/**
* 启用禁用
* @param {*} params
* @param {*} pobj2
* @param {*} req
*/
async enabled(params, pobj2, req) {
try {
params.id = Number(params.id || 0);
params.enabled = Number(params.enabled || 0);
return await this.userSve.enabled(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async delUser(params, pobj2, req) {
try {
return await this.userSve.delUser(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 查询明细
* @param {*} params
*/
async queryById(params, pobj2, req) {
try {
return await this.userSve.queryById(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async updPassword(params, pobj2, req) {
params.password = this.trim(params.password);
if (!params.password) {
return system.getResult(null, `请填写密码`);
}
try {
return await this.userSve.updPassword(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
* @param {*} params
*/
async page(params, pobj2, req) {
try {
params.uctypeId = params.deliver_id;
return await this.userSve.page(params);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async salesmanList(params, pobj2, req) {
try {
if (!params.deliver_id) {
return system.getResultSuccess([]);
}
return await this.userSve.salesmanList(params);
} catch (error) {
console.log(error);
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = UserCtl;
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
function exp(db, DataTypes) {
var base = {
code: {
type: DataTypes.STRING(50),
unique: true
},
name: DataTypes.STRING(1000),
};
return base;
}
module.exports = exp;
const system = require("../../system");
const settings = require("../../../config/settings");
const uiconfig = system.getUiConfig2(settings.wxconfig.appId);
function exp(db, DataTypes) {
var base = {
//继承的表引用用户信息user_id
code: DataTypes.STRING(100),
name: DataTypes.STRING(500),
creator: DataTypes.STRING(100),//创建者
updator: DataTypes.STRING(100),//更新者
auditor: DataTypes.STRING(100),//审核者
opNotes: DataTypes.STRING(500),//操作备注
auditStatusName: {
type:DataTypes.STRING(50),
defaultValue:"待审核",
},
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.audit_status),
set: function (val) {
this.setDataValue("auditStatus", val);
this.setDataValue("auditStatusName", uiconfig.config.pdict.audit_status[val]);
},
defaultValue:"dsh",
},
sourceTypeName: DataTypes.STRING(50),
sourceType: {//来源类型 "order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单", "trademark": "商标单"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.source_type),
set: function (val) {
this.setDataValue("sourceType", val);
this.setDataValue("sourceTypeName", uiconfig.config.pdict.source_type[val]);
}
},
sourceOrderNo: DataTypes.STRING(100),//来源单号
};
return base;
}
module.exports = exp;
const system = require("../system")
const settings = require("../../config/settings.js");
class CacheBase {
constructor() {
this.redisClient = system.getObject("util.redisClient");
this.desc = this.desc();
this.prefix = this.prefix();
this.cacheCacheKeyPrefix = "s_sadd_appkeys:" + settings.appKey + "_cachekey";
this.isdebug = this.isdebug();
}
isdebug() {
return true;
}
desc() {
throw new Error("子类需要定义desc方法,返回缓存描述");
}
prefix() {
throw new Error("子类需要定义prefix方法,返回本缓存的前缀");
}
async cache(inputkey, val, ex, ...items) {
const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null" || this.isdebug) {
var objvalstr = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items);
if (!objvalstr) {
return null;
}
if (ex) {
await this.redisClient.setWithEx(cachekey, objvalstr, ex);
} else {
await this.redisClient.set(cachekey, objvalstr);
}
//缓存当前应用所有的缓存key及其描述
this.redisClient.sadd(this.cacheCacheKeyPrefix, [cachekey + "|" + this.desc]);
return JSON.parse(objvalstr);
} else {
return JSON.parse(cacheValue);
}
}
async invalidate(inputkey) {
const cachekey = this.prefix + inputkey;
this.redisClient.delete(cachekey);
return 0;
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
throw new Error("子类中实现构建缓存值的方法,返回字符串");
}
}
module.exports = CacheBase;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAccessKeyCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_accesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var acckapp = await this.restS.execPost({ appkey: settings.appKey, secret: settings.secret }, settings.paasUrl() + "api/auth/accessAuth/getAccessKey");
var s = acckapp.stdout;
if (s) {
var tmp = JSON.parse(s);
if (tmp.status == 0) {
return JSON.stringify(tmp.data);
}
}
return null;
}
}
module.exports = ApiAccessKeyCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiAccessKeyCheckCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_verify_reqaccesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var cacheManager = system.getObject("db.common.cacheManager");
//当来访key缓存不存在时,需要去开放平台检查是否存在来访key缓存
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
if (checkresult.status == 0) {
var s = checkresult.data;
return JSON.stringify(s);
} else {
await cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
var s = checkresult.data;
return JSON.stringify(s);
}
}
}
module.exports = ApiAccessKeyCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAppIdCheckCache extends CacheBase {
constructor() {
super();
// this.merchantSve = system.getObject("service.merchant.merchantSve");
}
desc() {
return "应用中来访访问appid缓存";
}
prefix() {
return settings.cacheprefix + "_verify_appid:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
// var item = await this.merchantSve.getById(inputkey);
// if (!item && item.data) {
// return null;
// }
// return JSON.stringify(item.data);
}
}
module.exports = ApiAppIdCheckCache;
\ No newline at end of file
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiUserCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_userdata:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var cacheManager = system.getObject("db.common.cacheManager");
//当来访key缓存不存在时,需要去开放平台检查是否存在来访key缓存
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
if (checkresult.status == 0) {
var s = checkresult.data;
return JSON.stringify(s);
} else {
await cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
var s = checkresult.data;
return JSON.stringify(s);
}
}
}
module.exports = ApiUserCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class MagCache extends CacheBase {
constructor() {
super();
this.prefix = "magCache";
}
desc() {
return "应用UI配置缓存";
}
//暂时没有用到,只是使用其帮助的方法
prefix() {
return settings.cacheprefix + "_uiconfig:";
}
async getCacheSmembersByKey(key) {
return this.redisClient.smembers(key);
}
async delCacheBySrem(key, value) {
return this.redisClient.srem(key, value)
}
async keys(p) {
return this.redisClient.keys(p);
}
async get(k) {
return this.redisClient.get(k);
}
async del(k) {
return this.redisClient.delete(k);
}
async clearAll() {
console.log("xxxxxxxxxxxxxxxxxxxclearAll............");
return this.redisClient.flushall();
}
}
module.exports = MagCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class UIConfigCache extends CacheBase {
constructor() {
super();
}
isdebug() {
return settings.env == "dev";
}
desc() {
return "应用UI配置缓存";
}
prefix() {
return settings.cacheprefix + "_appself_uiconfig:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var configValue = system.getUiConfig2(inputkey);
return JSON.stringify(configValue);
}
}
module.exports = UIConfigCache;
const system = require("../system");
class Dao {
constructor(modelName) {
this.modelName = modelName;
this.redisClient = system.getObject("util.redisClient");
var db = system.getObject("db.common.connection").getCon();
this.db = db;
console.log("........set dao model..........");
this.model = db.models[this.modelName];
}
async preCreate(u) {
u.id = await this.redisClient.genrateId(this.modelName);
return u;
}
async create(u, t) {
var u2 = await this.preCreate(u);
if (t) {
return this.model.create(u2, { transaction: t }).then(u => {
return u;
});
} else {
return this.model.create(u2, { transaction: t }).then(u => {
return u;
});
}
}
static getModelName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase();
}
async refQuery(qobj) {
var w = {};
if (qobj.likestr) {
w[qobj.fields[0]] = { [this.db.Op.like]: "%" + qobj.likestr + "%" };
return this.model.findAll({ where: w, attributes: qobj.fields });
} else {
return this.model.findAll({ attributes: qobj.fields });
}
}
async bulkDelete(ids) {
var en = await this.model.destroy({ where: { id: { [this.db.Op.in]: ids } } });
return en;
}
async delete(qobj) {
var en = await this.model.findOne({ where: qobj });
if (en != null) {
return en.destroy();
}
return null;
}
extraModelFilter() {
//return {"key":"include","value":{model:this.db.models.app}};
return null;
}
extraWhere(obj, where) {
return where;
}
orderBy() {
//return {"key":"include","value":{model:this.db.models.app}};
return [["created_at", "DESC"]];
}
buildQuery(qobj) {
var linkAttrs = [];
const pageNo = qobj.pageInfo.pageNo;
const pageSize = qobj.pageInfo.pageSize;
const search = qobj.search;
const orderInfo = qobj.orderInfo;//格式:[["created_at", 'desc']]
var qc = {};
//设置分页查询条件
qc.limit = pageSize;
qc.offset = (pageNo - 1) * pageSize;
//默认的查询排序
if (orderInfo) {
qc.order = orderInfo;
} else {
qc.order = this.orderBy();
}
//构造where条件
qc.where = {};
if (search) {
Object.keys(search).forEach(k => {
console.log(search[k], ":search[k]search[k]search[k]");
if (search[k] && search[k] != 'undefined' && search[k] != "") {
if ((k.indexOf("Date") >= 0 || k.indexOf("_at") >= 0)) {
if (search[k] != "" && search[k]) {
var stdate = new Date(search[k][0]);
var enddate = new Date(search[k][1]);
qc.where[k] = { [this.db.Op.between]: [stdate, enddate] };
}
}
else if (k.indexOf("id") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("channelCode") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("Type") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("Status") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("status") >= 0) {
qc.where[k] = search[k];
}
else {
if (k.indexOf("~") >= 0) {
linkAttrs.push(k);
} else {
qc.where[k] = { [this.db.Op.like]: "%" + search[k] + "%" };
}
}
}
});
}
this.extraWhere(qobj, qc.where, qc, linkAttrs);
var extraFilter = this.extraModelFilter();
if (extraFilter) {
qc[extraFilter.key] = extraFilter.value;
}
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
console.log(qc);
return qc;
}
async findAndCountAll(qobj, t) {
var qc = this.buildQuery(qobj);
var apps = await this.model.findAndCountAll(qc);
return apps;
}
preUpdate(obj) {
return obj;
}
async update(obj, tm) {
var obj2 = this.preUpdate(obj);
if (tm != null && tm != 'undefined') {
return this.model.update(obj2, { where: { id: obj2.id }, transaction: tm });
} else {
return this.model.update(obj2, { where: { id: obj2.id } });
}
}
async updateByWhere(setObj, whereObj, t) {
if (t && t != 'undefined') {
if (whereObj && whereObj != 'undefined') {
whereObj.transaction = t;
} else {
whereObj = { transaction: t };
}
}
return this.model.update(setObj, whereObj);
}
async customExecAddOrPutSql(sql, paras = null) {
return this.db.query(sql, paras);
}
async customQuery(sql, paras, t) {
var tmpParas = null;//||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT };
if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.SELECT };
tmpParas.transaction = t;
} else {
tmpParas = { replacements: paras, type: this.db.QueryTypes.SELECT };
tmpParas.transaction = t;
}
} else {
tmpParas = paras == null || paras == 'undefined' ? { type: this.db.QueryTypes.SELECT } : { replacements: paras, type: this.db.QueryTypes.SELECT };
}
return this.db.query(sql, tmpParas);
}
async customUpdate(sql, paras, t) {
var tmpParas = null;
if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.UPDATE };
tmpParas.transaction = t;
} else {
tmpParas = { replacements: paras, type: this.db.QueryTypes.UPDATE };
tmpParas.transaction = t;
}
} else {
tmpParas = paras == null || paras == 'undefined' ? { type: this.db.QueryTypes.UPDATE } : { replacements: paras, type: this.db.QueryTypes.UPDATE };
}
return this.db.query(sql, tmpParas);
}
async findCount(whereObj = null) {
return this.model.count(whereObj, { logging: false }).then(c => {
return c;
});
}
async findSum(fieldName, whereObj = null) {
return this.model.sum(fieldName, whereObj);
}
async getPageList(pageIndex, pageSize, whereObj = null, orderObj = null, attributesObj = null, includeObj = null) {
var tmpWhere = {};
tmpWhere.limit = pageSize;
tmpWhere.offset = (pageIndex - 1) * pageSize;
if (whereObj != null) {
tmpWhere.where = whereObj;
}
if (orderObj != null && orderObj.length > 0) {
tmpWhere.order = orderObj;
}
if (attributesObj != null && attributesObj.length > 0) {
tmpWhere.attributes = attributesObj;
}
if (includeObj != null && includeObj.length > 0) {
tmpWhere.include = includeObj;
tmpWhere.distinct = true;
}
tmpWhere.raw = true;
return await this.model.findAndCountAll(tmpWhere);
}
async findOne(obj, t) {
var params = { "where": obj };
if (t) {
params.transaction = t;
}
return this.model.findOne(params);
}
async findById(oid) {
return this.model.findById(oid);
}
async setListCodeName(list, field) {
if (!list) {
return;
}
for (item of list) {
await this.setRowCodeName(item, field);
}
}
async setRowCodeName(item, field) {
if (!item || !field) {
return;
}
var map = this[field + "Map"] || {};
if (!item) {
return;
}
item[field + "Name"] = map[item[field] || ""] || "";
}
async getRowCodeName(item, field) {
if (!item || !field) {
return "";
}
var map = this[field + "Map"] || {};
if (!item) {
return "";
}
return map[item[field] || ""] || "";
}
async getById(id, attrs) {
if (!id) {
return null;
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where id = :id ";
var list = await this.customQuery(sql, {
id: id
});
return list && list.length > 0 ? list[0] : null;
}
async getListByIds(ids, attrs) {
if (!ids || ids.length == 0) {
return [];
}
attrs = attrs || "*";
var sql = "SELECT " + attrs + " FROM " + this.model.tableName + " where id IN (:ids) ";
return await this.customQuery(sql, {
ids: ids
}) || [];
}
async getMapByIds(ids, attrs) {
var result = {};
var list = await this.getListByIds(ids, attrs);
if (!list || list.length == 0) {
return result;
}
for (var item of list) {
result[item.id] = item;
}
return result;
}
}
module.exports = Dao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class UserDao extends Dao{
constructor(){
super(Dao.getModelName(UserDao));
}
async getAuths(userid){
var self=this;
return this.model.findOne({
where:{id:userid},
include:[{model:self.db.models.account,attributes:["id","isSuper","referrerOnlyCode"]},
{model:self.db.models.role,as:"Roles",attributes:["id","code"],include:[
{model:self.db.models.product,as:"Products",attributes:["id","code"]}
]},
],
});
}
extraModelFilter(){
//return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"],joinTableAttributes:['created_at']}]};
return {"key":"include","value":[{model:this.db.models.app,},{model:this.db.models.role,as:"Roles",attributes:["id","name"]}]};
}
extraWhere(obj,w,qc,linkAttrs){
if(obj.codepath && obj.codepath!=""){
// if(obj.codepath.indexOf("userarch")>0){//说明是应用管理员的查询
// console.log(obj);
// w["app_id"]=obj.appid;
// }
}
if(linkAttrs.length>0){
var search=obj.search;
var lnkKey=linkAttrs[0];
var strq="$"+lnkKey.replace("~",".")+"$";
w[strq]= {[this.db.Op.like]:"%"+search[lnkKey]+"%"};
}
return w;
}
async preUpdate(u){
if(u.roles && u.roles.length>0){
var roles=await this.db.models.role.findAll({where:{id:{[this.db.Op.in]:u.roles}}});
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
console.log(roles);
u.roles=roles
}
return u;
}
async update(obj){
var obj2=await this.preUpdate(obj);
console.log("update....................");
console.log(obj2);
await this.model.update(obj2,{where:{id:obj2.id}});
var user=await this.model.findOne({where:{id:obj2.id}});
user.setRoles(obj2.roles);
return user;
}
async findAndCountAll(qobj,t){
var users=await super.findAndCountAll(qobj,t);
return users;
}
async preCreate(u){
// var roles=await this.db.models.role.findAll({where:{id:{[this.db.Op.like]:u.roles}}});
// console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// console.log(roles);
// console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// u.roles=roles
return u;
}
async create(u,t){
var self=this;
var u2=await this.preCreate(u);
if(t){
return this.model.create(u2,{transaction: t}).then(user=>{
return user;
});
}else{
return this.model.create(u2).then(user=>{
return user;
});
}
}
//修改用户(user表)公司的唯一码
async putUserCompanyOnlyCode(userId,company_only_code,result){
var customerObj={companyOnlyCode:company_only_code};
var putSqlWhere={where:{id:userId}};
this.updateByWhere(customerObj,putSqlWhere);
return result;
}
}
module.exports=UserDao;
// var u=new UserDao();
// var roledao=system.getObject("db.roleDao");
// (async ()=>{
// var users=await u.model.findAll({where:{app_id:1}});
// var role=await roledao.model.findOne({where:{code:"guest"}});
// console.log(role);
// for(var i=0;i<users.length;i++){
// await users[i].setRoles([role]);
// console.log(i);
// }
//
// })();
const system=require("../../../system");
const fs=require("fs");
const settings=require("../../../../config/settings");
var glob = require("glob");
class APIDocManager{
constructor(){
this.doc={};
this.buildAPIDocMap();
}
async buildAPIDocMap(){
var self=this;
//订阅任务频道
var apiPath=settings.basepath+"/app/base/api/impl";
var rs = glob.sync(apiPath + "/**/*.js");
if(rs){
for(let r of rs){
// var ps=r.split("/");
// var nl=ps.length;
// var pkname=ps[nl-2];
// var fname=ps[nl-1].split(".")[0];
// var obj=system.getObject("api."+pkname+"."+fname);
var ClassObj=require(r);
var obj=new ClassObj();
var gk=obj.apiDoc.group+"|"+obj.apiDoc.groupDesc
if(!this.doc[gk]){
this.doc[gk]=[];
this.doc[gk].push(obj.apiDoc);
}else{
this.doc[gk].push(obj.apiDoc);
}
}
}
}
}
module.exports=APIDocManager;
const fs=require("fs");
const settings=require("../../../../config/settings");
class CacheManager{
constructor(){
//await this.buildCacheMap();
this.buildCacheMap();
}
buildCacheMap(){
var self=this;
self.doc={};
var cachePath=settings.basepath+"/app/base/db/cache/";
const files=fs.readdirSync(cachePath);
if(files){
files.forEach(function(r){
var classObj=require(cachePath+"/"+r);
self[classObj.name]=new classObj();
var refTmp=self[classObj.name];
if(refTmp.prefix){
self.doc[refTmp.prefix]=refTmp.desc;
}
else{
console.log("请在"+classObj.name+"缓存中定义prefix");
}
});
}
}
}
module.exports=CacheManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
// console.log(x);
// });
// });
const Sequelize = require('sequelize');
const settings = require("../../../../config/settings")
const fs = require("fs")
const path = require("path");
var glob = require("glob");
class DbFactory {
constructor() {
const dbConfig = settings.database();
this.db = new Sequelize(dbConfig.dbname,
dbConfig.user,
dbConfig.password,
dbConfig.config);
this.db.Sequelize = Sequelize;
this.db.Op = Sequelize.Op;
this.initModels();
this.initRelations();
}
async initModels() {
var self = this;
var modelpath = path.normalize(path.join(__dirname, '../..')) + "/models/";
console.log("modelpath=====================================================");
console.log(modelpath);
var models = glob.sync(modelpath + "/**/*.js");
console.log(models.length);
models.forEach(function (m) {
console.log(m);
self.db.import(m);
});
console.log("init models....");
}
async initRelations() {
/**
一个账户对应多个登陆用户
一个账户对应一个commany
一个APP对应多个登陆用户
一个APP有多个角色
登陆用户和角色多对多
**/
/*建立账户和用户之间的关系*/
//account--不属于任何一个app,是统一用户
//用户登录时首先按照用户名和密码检查account是否存在,如果不存在则提示账号或密码不对,如果
//存在则按照按照accountid和应用key,查看user,后台实现对应user登录
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon() {
var that = this;
// await this.db.authenticate().then(()=>{
// console.log('Connection has been established successfully.');
// }).catch(err => {
// console.error('Unable to connect to the database:', err);
// throw err;
// });
//同步模型
if (settings.env == "dev") {
//console.log(pa);
// pconfigObjs.forEach(p=>{
// console.log(p.get({plain:true}));
// });
// await this.db.models.user.create({nickName:"dev","description":"test user",openId:"testopenid",unionId:"testunionid"})
// .then(function(user){
// var acc=that.db.models.account.build({unionId:"testunionid",nickName:"dev"});
// acc.save().then(a=>{
// user.setAccount(a);
// });
// });
}
return this.db;
}
getConhb() {
var that = this;
if (settings.env == "dev") {
}
return this.dbhb;
}
}
module.exports = DbFactory;
// const dbf=new DbFactory();
// dbf.getCon().then((db)=>{
// //console.log(db);
// // db.models.user.create({nickName:"jy","description":"cccc",openId:"xxyy",unionId:"zz"})
// // .then(function(user){
// // var acc=db.models.account.build({unionId:"zz",nickName:"jy"});
// // acc.save().then(a=>{
// // user.setAccount(a);
// // });
// // console.log(user);
// // });
// // db.models.user.findAll().then(function(rs){
// // console.log("xxxxyyyyyyyyyyyyyyyyy");
// // console.log(rs);
// // })
// });
// const User = db.define('user', {
// firstName: {
// type: Sequelize.STRING
// },
// lastName: {
// type: Sequelize.STRING
// }
// });
// db
// .authenticate()
// .then(() => {
// console.log('Co+nnection has been established successfully.');
//
// User.sync(/*{force: true}*/).then(() => {
// // Table created
// return User.create({
// firstName: 'John',
// lastName: 'Hancock'
// });
// });
//
// })
// .catch(err => {
// console.error('Unable to connect to the database:', err);
// });
//
// User.findAll().then((rows)=>{
// console.log(rows[0].firstName);
// });
const system=require("../../../system");
const Dao=require("../../dao.base");
class MetaDao{
constructor(){
//super(Dao.getModelName(AppDao));
}
}
module.exports=MetaDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class OplogDao extends Dao{
constructor(){
super(Dao.getModelName(OplogDao));
}
}
module.exports=OplogDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class TaskDao extends Dao{
constructor(){
super(Dao.getModelName(TaskDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
return qw;
}
async delete(task,qobj,t){
return task.destroy({where:qobj,transaction:t});
}
}
module.exports=TaskDao;
const system=require("../../../system");
const fs=require("fs");
const settings=require("../../../../config/settings");
var cron = require('node-cron');
class TaskManager{
constructor(){
this.taskDic={};
this.redisClient=system.getObject("util.redisClient");
this.buildTaskMap();
}
async buildTaskMap(){
var self=this;
//订阅任务频道
await this.redisClient.subscribeTask("task",this);
var taskPath=settings.basepath+"/app/base/db/task/";
const files=fs.readdirSync(taskPath);
if(files){
files.forEach(function(r){
var classObj=require(taskPath+"/"+r);
self[classObj.name]=new classObj();
});
}
}
async addTask(taskClassName,exp){
(async (tn,ep)=>{
if(!this.taskDic[tn]){
this.taskDic[tn]=cron.schedule(ep,()=>{
this[tn].doTask();
});
}
})(taskClassName,exp);
}
async deleteTask(taskClassName){
if(this.taskDic[taskClassName]){
this.taskDic[taskClassName].destroy();
delete this.taskDic[taskClassName];
}
}
async clearlist(){
var x=await this.redisClient.clearlist("tasklist");
return x;
}
async publish(channel,msg){
var x=await this.redisClient.publish(channel,msg);
return x;
}
async newTask(taskstr){
return this.redisClient.rpush("tasklist",taskstr);
}
}
module.exports=TaskManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
// console.log(x);
// });
// });
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.js");
const reclient=system.getObject("util.redisClient");
const md5 = require("MD5");
//获取平台配置兑换率
//初次登录的赠送数量
//创建一笔交易
//同时增加账户数量,增加系统平台账户
var dbf=system.getObject("db.common.connection");
var db=dbf.getCon();
db.sync({force:true}).then(async ()=>{
console.log("sync complete...");
//创建role
// if(settings.env=="prod"){
// reclient.flushall(()=>{
// console.log("clear caches ok.....");
// });
// }
// reclient.flushall(()=>{
// console.log("clear caches ok.....");
// });
});
const settings = require("../../../../config/settings");
module.exports = {
"appid": settings.appKey,
"label": "研发开放平台",
"config": {
"rstree": {
"code": "paasroot",
"label": "paas",
"children": [
// {
// "code": "register",
// "icon": "fa fa-power-off",
// "path": "register",
// "isMenu": false,
// "label": "注册",
// "isctl": "no"
// },
],
},
"bizs": {
},
"pdict": {
"logLevel": { "debug": 0, "info": 1, "warn": 2, "error": 3, "fatal": 4 },
}
}
}
\ No newline at end of file
module.exports={
"bizName":"oplogs",
"list":{
columnMetaData:[
{"width":"200","label":"应用","prop":"appname","isShowTip":true,"isTmpl":false},
{"width":"200","label":"时间","prop":"created_at","isShowTip":true,"isTmpl":false},
{"width":"100","label":"用户名","prop":"username","isShowTip":true,"isTmpl":false},
{"width":"100","label":"性别","prop":"sex","isShowTip":true,"isTmpl":false},
{"width":"200","label":"行为","prop":"op","isShowTip":true,"isTmpl":false},
{"width":"200","label":"内容","prop":"content","isShowTip":true,"isTmpl":false},
{"width":"200","label":"客户端IP","prop":"clientIp","isShowTip":true,"isTmpl":false},
{"width":"200","label":"客户端环境","prop":"agent","isShowTip":true,"isTmpl":false},
]
},
"form":[
{
"title":"应用名称",
"validProp":"name",
"rule": [
{ "required": true, "message": '请输入应用名称', "trigger": 'blur' },
],
ctls:[
{"type":"input","label":"应用名称","prop":"name","placeHolder":"应用名称","style":""},
]
},
{
"title":"应用ID",
"ctls":[
{"type":"input","label":"应用ID","prop":"appid","disabled":true,"placeHolder":"","style":""},
]
},
],
"search":[
{
"title":"应用名称",
ctls:[
{"type":"input","label":"操作用户","prop":"username","placeHolder":"请模糊输入应用名称","style":""},
]
},
{
"title":"客户环境",
ctls:[
{"type":"input","label":"客户环境","prop":"agent","placeHolder":"请模糊输入客户环境","style":""},
]
},
// {
// "title":"",
// "min":1,
// "max":1,
// ctls:[
// {"type":"check","dicKey":"sex","label":"客户环境","prop":"sex","style":""},
// ]
// },
// <gsb-select v-model="formModel[item.prop]"
// :dicKey="item.dicKey"
// :autoComplete="item.autoComplete"
// :isMulti="item.isMulti"
// :modelName="item.modelName"
// :isFilter="item.isFilter"
// :labelField="item.labelField"
// :valueField="item.valueField"></gsb-select>
{
"title":"性别",
ctls:[
{"type":"select","dicKey":"sex","label":"性别","prop":"sex","labelField":"label","valueField":"value","style":""},
]
},
],
"auth":{
"add":[
],
"edit":[
],
"delete":[
{"icon":"el-icon-remove","title":"删除","type":"default","key":"delete","isOnGrid":true},
],
"common":[
],
}
}
const fs=require("fs");
const path=require("path");
const appsPath=path.normalize(__dirname+"/apps");
const bizsPath=path.normalize(__dirname+"/bizs");
var appJsons={
}
function getBizFilePath(appJson,bizCode){
const filePath=bizsPath+"/"+"bizjs"+"/"+bizCode+".js";
return filePath;
}
//异常日志处理todo
function initAppBizs(appJson){
for(var bizCode in appJson.config.bizs)
{
const bizfilePath=getBizFilePath(appJson,bizCode);
try{
delete require.cache[bizfilePath];
const bizConfig=require(bizfilePath);
appJson.config.bizs[bizCode].config=bizConfig;
}catch(e){
console.log("bizconfig meta file not exist........");
}
}
return appJson;
}
//初始化资源树--objJson是rstree
function initRsTree(appjson,appidfolder,objJson,parentCodePath){
if(!parentCodePath){//说明当前是根结点
objJson.codePath=objJson.code;
}else{
objJson.codePath=parentCodePath+"/"+objJson.code;
}
if(objJson["bizCode"]){//表示叶子节点
objJson.auths=[];
if(appjson.config.bizs[objJson["bizCode"]]){
objJson.bizConfig=appjson.config.bizs[objJson["bizCode"]].config;
objJson.path=appjson.config.bizs[objJson["bizCode"]].path;
appjson.config.bizs[objJson["bizCode"]].codepath=objJson.codePath;
}
}else{
if(objJson.children){
objJson.children.forEach(obj=>{
initRsTree(appjson,appidfolder,obj,objJson.codePath);
});
}
}
}
fs.readdirSync(appsPath).forEach(f=>{
const ff=path.join(appsPath,f);
delete require.cache[ff];
var appJson=require(ff);
appJson= initAppBizs(appJson);
initRsTree(appJson,appJson.appid,appJson.config.rstree,null);
appJsons[appJson.appid]=appJson;
});
module.exports=appJsons;
module.exports={
"appid":"wx76a324c5d201d1a4",
"label":"企业服务工具箱",
"config":{
"rstree":{
"code":"toolroot",
"label":"工具箱",
"children":[
{
"code":"toggleHeader",
"icon":"el-icon-sort",
"isMenu":true,
"label":"折叠",
},
{
"code":"personCenter",
"label":"个人信息",
"src":"/imgs/logo.png",
"isSubmenu":true,
"children":[
{"code":"wallet","isGroup":true,"label":"账户","children":[
{"code":"mytraderecord","label":"交易记录","isMenu":true,"bizCode":"trades","bizConfig":null,"path":""},
{"code":"smallmoney","label":"钱包","isMenu":true,"bizCode":"oplogs","bizConfig":null,"path":""},
{"code":"fillmoney","label":"充值","isMenu":true,},
]},
{"code":"tool","isGroup":true,"label":"工具","children":[
{"code":"entconfirm","label":"企业用户认证","isMenu":true,"bizCode":"apps","bizConfig":null,"path":""},
{"code":"fav","label":"收藏夹","isMenu":true,"bizCode":"fav","bizConfig":null,"path":""},
{"code":"filebox","label":"文件柜","isMenu":true,"bizCode":"filebox","bizConfig":null,"path":""},
]},
],
},
{
"code":"fillmoney",
"icon":"fa fa-money",
"isMenu":true,
"label":"充值",
},
{
"code":"platformop",
"label":"平台运营",
"icon":"fa fa-cubes",
"isSubmenu":true,
"children":[
{"code":"papp","isGroup":true,"label":"平台数据","children":[
{"code":"papparch","label":"应用档案","isMenu":true,"bizCode":"apps","bizConfig":null,"path":""},
{"code":"userarch","label":"用户档案","isMenu":true,"bizCode":"pusers","bizConfig":null,"path":""},
{"code":"traderecord","label":"交易记录","isMenu":true,"bizCode":"trades","bizConfig":null,"qp":"my","path":""},
{"code":"pconfigs","label":"平台配置","isMenu":true,"bizCode":"pconfigs","bizConfig":null,"qp":"my","path":""},
]},
{"code":"pop","isGroup":true,"label":"平台运维","children":[
{"code":"cachearch","label":"缓存档案","isMenu":true,"bizCode":"cachearches","bizConfig":null,"path":""},
{"code":"oplogmag","label":"行为日志","isMenu":true,"bizCode":"oplogs","bizConfig":null,"path":""},
{"code":"machinearch","label":"机器档案","isMenu":true,"bizCode":"machines","bizConfig":null,"path":""},
{"code":"codezrch","label":"代码档案","isMenu":true,"bizCode":"codezrch","bizConfig":null,"path":""},
{"code":"imagearch","label":"镜像档案","isMenu":true},
{"code":"containerarch","label":"容器档案","isMenu":true},
]},
],
},
{
"code":"sysmag",
"label":"系统管理",
"icon":"fa fa-cube",
"isSubmenu":true,
"children":[
{"code":"usermag","isGroup":true,"label":"用户管理","children":[
{"code":"rolearch","label":"角色档案","isMenu":true,"bizCode":"roles","bizConfig":null},
{"code":"appuserarch","label":"用户档案","isMenu":true,"bizCode":"appusers","bizConfig":null},
]},
{"code":"productmag","isGroup":true,"label":"产品管理","children":[
{"code":"productarch","label":"产品档案","bizCode":"mgproducts","isMenu":true,"bizConfig":null},
{"code":"products","label":"首页产品档案","bizCode":"products","isMenu":false,"bizConfig":null},
]},
],
},
{
"code":"exit",
"icon":"fa fa-power-off",
"isMenu":true,
"label":"退出",
},
{
"code":"toolCenter",
"label":"工具集",
"src":"/imgs/logo.png",
"isSubmenu":false,
"isMenu":false,
"children":[
{"code":"tools","isGroup":true,"label":"查询工具","children":[
{"code":"xzquery","label":"续展查询","bizCode":"xzsearch","bizConfig":null,"path":""},
{"code":"xzgqquery","label":"续展过期查询","bizCode":"xzgqsearch","bizConfig":null,"path":""},
]},
],
},
],
},
"bizs":{
"cachearches":{"title":"首页产品档案","config":null,"path":"/platform/cachearches","comname":"cachearches"},
"products":{"title":"首页产品档案","config":null,"path":"/","comname":"products"},
"mgproducts":{"title":"产品档案","config":null,"path":"/platform/mgproducts","comname":"mgproducts"},
"codezrch":{"title":"代码档案","config":null,"path":"/platform/codezrch","comname":"codezrch"},
"machines":{"title":"机器档案","config":null,"path":"/platform/machines","comname":"machines"},
"pconfigs":{"title":"平台配置","config":null,"path":"/platform/pconfigs","comname":"pconfigs"},
"apps":{"title":"应用档案","config":null,"path":"/platform/apps","comname":"apps"},
"roles":{"title":"角色档案","config":null,"path":"/platform/roles","comname":"roles"},
"pusers":{"title":"平台用户档案","config":null,"path":"/platform/pusers","comname":"users"},
"appusers":{"title":"某应用用户档案","config":null,"path":"/platform/appusers","comname":"users"},
"oplogs":{"title":"行为日志","config":null,"path":"/platform/op/oplogs","comname":"oplogs"},
"trades":{"title":"交易记录","config":null,"path":"/platform/uc/trades","comname":"trades"},
"xzsearch":{"title":"续展查询","config":null,"isDynamicRoute":true,"path":"/products/xzsearch","comname":"xzsearch"},
"xzgqsearch":{"title":"续展过期查询","config":null,"isDynamicRoute":true,"path":"/products/xzgqsearch","comname":"xzgqsearch"},
},
"pauths":[
"add","edit","delete","export","show"
],
"pdict":{
"sex":{"male":"男","female":"女"},
"configType":{"price":"宝币兑换率","initGift":"初次赠送"},
"productCata":{"ip":"知产","ic":"工商","tax":"财税","hr":"人力","common":"常用"},
"logLevel":{"debug":0,"info":1,"warn":2,"error":3,"fatal":4},
"tradeType":{"fill":"充值","consume":"消费","gift":"赠送","giftMoney":"红包","refund":"退款"},
"tradeStatus":{"unSettle":"未结算","settled":"已结算"}
}
}
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const uiconfig=system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("user", {
ucid: {
type:DataTypes.INTEGER,
allowNull: false,
},
ucname: {
type:DataTypes.STRING,
allowNull: false,
},
lastLoginTime: {
type:DataTypes.DATE,
allowNull: true,
},
passwd: DataTypes.STRING,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
// freezeTableName: true,
// define the table's name
tableName: 'xgg_admin_user',
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}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("oplog", {
appid: DataTypes.STRING,
appkey: DataTypes.STRING,
requestId: DataTypes.STRING,
logLevel: {
type: DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.logLevel),
defaultValue: "info",
},
op: DataTypes.STRING,
content: DataTypes.STRING(5000),
resultInfo: DataTypes.TEXT,
clientIp: DataTypes.STRING,
agent: {
type: DataTypes.STRING,
allowNull: true,
},
opTitle: DataTypes.STRING(500),
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'xgg_op_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}]
// }
]
});
}
module.exports = (db, DataTypes) => {
return db.define("task", {
app_id:DataTypes.STRING,//需要在后台补充
taskClassName: {
type:DataTypes.STRING(100),
allowNull: false,
unique: true
},//和user的from相同,在注册user时,去创建
taskexp: {
type:DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
desc:DataTypes.STRING,//需要在后台补充
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_task',
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}]
// }
]
});
}
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
const system=require("../system")
const logCtl=system.getObject("web.common.oplogCtl");
class TaskBase{
constructor(className){
this.redisClient=system.getObject("util.redisClient");
this.serviceName=className;
}
async doTask(){
try {
await this.subDoTask();
//日志记录
logCtl.info({
optitle:this.serviceName+",任务成功执行完成",
op:"base/db/task.base.js",
content:"",
clientIp:""
});
} catch (e) {
//日志记录
logCtl.error({
optitle:this.serviceName+"任务执行异常",
op:"base/db/task.base.js",
content:e.stack,
clientIp:""
});
}
}
async subDoTask(){
console.log("请在子类中重写此方法进行操作业务逻辑............................!");
}
static getServiceName(ClassObj){
return ClassObj["name"];
}
}
module.exports=TaskBase;
const TaskBase=require("../task.base");
class TestTask extends TaskBase{
constructor(){
super(TaskBase.getServiceName(TestTask));
}
async subDoTask(){
console.log("TestTask1.....");
}
}
module.exports=TestTask;
const TaskBase=require("../task.base");
class TestTask extends TaskBase{
constructor(){
super();
}
async doTask(){
console.log("TestTask.....");
}
}
module.exports=TestTask;
const system = require("../../../system");
const ServiceBase = require("../../sve.base")
const settings = require("../../../../config/settings")
class UserService extends ServiceBase {
constructor() {
super("auth", ServiceBase.getDaoName(UserService));
this.platformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async saveUser(user) {
var u = await this.dao.findOne({
ucid: user.ucid,
}) || {};
u.ucid = user.ucid;
u.ucname = user.ucname;
u.passwd = user.passwd;
u.lastLoginTime = user.lastLoginTime;
if(u.id) {
u = await this.dao.create(ucid);
} else {
await u.save();
}
return u;
}
async authByCode(opencode) {
var existedUser = null;
var rawUser = null;
var openuser = await this.apiCallWithAk(settings.paasUrl() + "api/auth/accessAuth/authByCode", { opencode: opencode });
if (openuser) {
//先查看自己系统中是否已经存在当前用户
existedUser = await this.dao.model.findOne({ where: { ucname: openuser.userName, ucid: openuser.account_id }, raw: true });
if (!existedUser) {
existedUser = await this.register(openuser);
}
rawUser = existedUser;
rawUser.Roles = openuser.Roles;
}
return rawUser;
}
async getUserLoginInfo(token) {
var acckapp = await this.cacheManager["ApiUserCache"].cache(token, null, settings.usertimeout);
}
async register(openuser) {
var param = {
ucname: openuser.userName, ucid: openuser.account_id,
lastLoginTime: new Date()
}
var cruser = await this.dao.create(param);
return cruser;
}
//在平台进行登录,返回目标认证地址
async navSysSetting(user) {
var sysLoginUrl = settings.paasUrl() + "web/auth/userCtl/login?appKey=" + settings.appKey + "\&toKey=" + settings.paasKey;
var x = { userName: user.userName, password: user.password, mobile: user.mobile };
var restResult = await this.restS.execPost({ u: x }, sysLoginUrl);
if (restResult) {
var rtnres = JSON.parse(restResult.stdout);
if (rtnres.status == 0) {
return rtnres.data;
}
}
return null;
}
async getUserByUserNamePwd(u) {
var user = await this.dao.model.findOne({
where: { userName: u.userName, password: u.password, app_id: u.app_id },
include: [
{ model: this.db.models.role, as: "Roles", attributes: ["id", "code"] },
]
});
return user;
}
async checkSameName(uname, appid) {
var ac = await this.dao.model.findOne({ where: { userName: uname, app_id: appid } });
var rtn = { isExist: false };
if (ac) {
rtn.isExist = true;
}
return rtn;
}
}
module.exports = UserService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")
class BusinessmenService extends ServiceBase {
constructor() {
super();
}
async allPage(params) {
let rs = await this.callms("order", "businessmenPage", params);
if (rs.status != 0 || !rs.data || !rs.data.rows) {
return rs;
}
this.transField(rs.data.rows);
return rs;
}
async mapByCreditCodes(params) {
let rs = await this.callms("order", "businessmenMapByCreditCodes", params);
if(!rs || !rs.data) {
return {};
}
return rs.data;
}
transField(rows) {
if (!rows) {
return;
}
for (var row of rows) {
row.costRate = system.f2y(row.costRate);
row.taxRate = system.f2y(row.taxRate);
row.serviceRate = system.f2y(row.serviceRate);
row.serviceBeginTime = system.f2y(row.serviceRate);
row.serviceRate = system.f2y(row.serviceRate);
this.handleDate(row, ["service_begin_time", "service_end_time", "tax_reg_day", "reg_date", "sign_time"], "YYYY-MM-DD", -8);
this.parseJsonField(row, ["common_tax_ladder", "common_other_ladder", "special_tax_ladder", "special_other_ladder"]);
}
}
parseJsonField(row, fields) {
if (!row || !fields || fields.length == 0) {
return;
}
for (var f of fields) {
if (!f) {
continue;
}
if (!row[f]) {
row[f] = [];
continue;
}
try {
row[f] = JSON.parse(row[f]);
} catch (error) {
console.log(error);
}
}
}
}
module.exports = BusinessmenService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
// console.log((result));
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class BusinessscopeService extends ServiceBase {
constructor() {
super();
}
async page(params) {
return await this.callms("common", "businessscopePage", params);
}
async info(params) {
return await this.callms("common", "businessscopeInfo", params);
}
async save(params) {
return await this.callms("common", "businessscopeSave", params);
}
async del(params) {
return await this.callms("common", "businessscopeDelete", params);
}
async byDomicile(params) {
return await this.callms("common", "businessscopeByDomicileId", params);
}
}
module.exports = BusinessscopeService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
class CacheService {
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
}
async buildCacheRtn(pageValues) {
var ps = pageValues.map(k => {
var tmpList = k.split("|");
if (tmpList.length == 2) {
return { name: tmpList[0], val: tmpList[1], key: k };
}
});
return ps;
}
async findAndCountAll(obj) {
const pageNo = obj.pageInfo.pageNo;
const pageSize = obj.pageInfo.pageSize;
const limit = pageSize;
const offset = (pageNo - 1) * pageSize;
var search_name = obj.search && obj.search.name ? obj.search.name : "";
var cacheCacheKeyPrefix = "sadd_children_appkeys:" + settings.appKey + "_cachekey";
var cacheList = await this.cacheManager["MagCache"].getCacheSmembersByKey(cacheCacheKeyPrefix);
if (search_name) {
cacheList = cacheList.filter(f => f.indexOf(search_name) >= 0);
}
var pageValues = cacheList.slice(offset, offset + limit);
var kobjs = await this.buildCacheRtn(pageValues);
var tmpList = { results: { rows: kobjs, count: cacheList.length } };
return system.getResultSuccess(tmpList);
}
async delCache(obj) {
var keyList = obj.del_cachekey.split("|");
if (keyList.length == 2) {
var cacheCacheKeyPrefix = "sadd_children_appkeys:" + settings.appKey + "_cachekey";
await this.cacheManager["MagCache"].delCacheBySrem(cacheCacheKeyPrefix, obj.del_cachekey);
await this.cacheManager["MagCache"].del(keyList[0]);
return { status: 0 };
}
}
async clearAllCache(obj) {
await this.cacheManager["MagCache"].clearAll();
return { status: 0 };
}
}
module.exports = CacheService;
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class CaptchaService extends ServiceBase {
constructor() {
super();
}
async captcha(params) {
// "width": 120, // 验证码图片宽度 默认 120px
// "height": 36, // 验证码图片高度 默认 36px
// "background": "", // 验证码图片背景色,默认 #E8E8E8
// "expire": 0 // 验证码过期时间(秒)
var result = {};
var capthaData = await this.callms("common", "getCaptha", params);
if(capthaData.status === 0) {
result.key = capthaData.data.key;
result.captcha = capthaData.data.captcha;
console.log(result.key + " : " + result.text);
return system.getResultSuccess(result);
}
return system.getResult(null, "获取图片验证码失败");
}
async valid(params) {
var result = {};
return await this.callms("common", "validCaptha", params);
}
}
module.exports = CaptchaService;
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class DeliverService extends ServiceBase {
constructor() {
super();
}
async queryCourierTrace(params) {
var result = {
merchantId: "11111202101312",
courierNo: "222222222",
courierStatus: "配送中",
courierTime: "2019-10-01 10:10:10",
desc: "到达xxxxx",
applyNo: "100001",
}
return system.getResultSuccess(result);
}
}
module.exports = DeliverService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class DeliverService extends ServiceBase {
constructor() {
super();
}
async login(params) {
var rs = await this.callms("common", "deliverLogin", params);
return rs;
}
async all(params) {
var rs = await this.callms("common", "deliverAll", {});
await this.doPercent(rs.data);
return rs;
}
async page(params) {
var rs = await this.callms("common", "deliverPage", params);
await this.doPercent(rs.data.rows);
return rs;
}
async info(params) {
var rs = await this.callms("common", "deliverInfo", params);
await this.doPercent([rs.data]);
return rs;
}
async mayByIds(ids) {
var rs = await this.callms("common", "deliverUserMap", {ids: ids});
await this.doPercent([rs.data]);
return rs;
}
async save(params) {
params.invoiceDivide = system.y2f(params.invoiceDivide);
params.businessmenDivide = system.y2f(params.businessmenDivide);
var rs = await this.callms("common", "deliverSave", params);
await this.doPercent([rs.data]);
return rs;
}
async del(params) {
return await this.callms("common", "deliverDelete", params);
}
async deliverUserPage(params) {
return await this.callms("common", "deliverUserPage", params);
}
async deliverUserById(params) {
return await this.callms("common", "deliverUserById", params);
}
async 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) {
return await this.callms("common", "allOrg", params);
}
async orgTree(params) {
return await this.callms("common", "orgTree", params);
}
async orgById(params) {
return await this.callms("common", "orgById", params);
}
async orgSave(params) {
return await this.callms("common", "orgSave", params);
}
async doPercent(rows) {
if(!rows) {
return;
}
for(var row of rows) {
if(!row) {
continue;
}
row.invoiceDivide = system.f2y(row.invoiceDivide);
row.businessmenDivide = system.f2y(row.businessmenDivide);
}
}
}
module.exports = DeliverService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../svems.base");
var settings = require("../../../../config/settings");
class DomicileService extends ServiceBase {
constructor() {
super();
}
async nameList() {
return await this.callms("common", "domicileNameList", {});
}
async tree(params) {
return await this.callms("common", "domicileTree", {});
}
async page(params) {
return await this.callms("common", "domicilePage", params);
}
async info(params) {
return await this.callms("common", "domicileInfo", params);
}
async save(params) {
return await this.callms("common", "domicileSave", params);
}
async del(params) {
return await this.callms("common", "domicileDelete", params);
}
}
module.exports = DomicileService;
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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