Commit a0fa347a by 王勇飞

init

parent 3b2be2a9
......@@ -14,8 +14,21 @@ class APIBase {
companyid: custtags ? custtags[0].split("_")[1] : null,
password: custtags ? custtags[1].split("_")[1] : null,
username: req.headers["x-consumer-username"],
userid: req.headers["x-consumer-custom-id"],
credid: req.headers["x-credential-identifier"],
companykey: req.headers["x-company-key"],//专用于自由用户注册,自由用户用于一定属于某个存在的公司
opath: req.headers['xopath'],
ptags: req.headers['xptags'],
}
//添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") {
pobj.opath = req.xctx.ptags
} else {
pobj.opath = req.xctx.opath
}
if (req.xctx.userid) {//在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid;
pobj.username = req.xctx.username
}
if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"]
......@@ -29,7 +42,10 @@ class APIBase {
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if (!req.xctx.companyid && req.xctx.companykey && req.xctx.companykey != 'null' && req.xctx.companykey != 'undefined') {
let comptmp = await this.cacheManager["CompanyCache"].cache(req.xctx.companykey);
req.xctx.companyid = comptmp.id;
}
if (req.xctx.companyid) {//在请求传递数据对象注入公司id
pobj.company_id = req.xctx.companyid;
}
......@@ -40,6 +56,7 @@ class APIBase {
if (xarg && xarg[0] < 0) {
return system.getResultFail(...xarg);
}
var rtn = await this[methodname](pobj, query, req);
this.logClient.log(pobj, req, rtn)
return rtn;
......
const APIBase = require("../../api.base");
const system = require("../../../system");
const settings = require("../../../../config/settings");
/**
* 用户端调用订单相关接口
*/
class Template extends APIBase {
constructor() {
super();
this.templateinfoSve = system.getObject("service.template.templateinfoSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
var self = this;
pobj.xctx = req.xctx;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess("测试接口");
break;
case "createTemplate"://创建模板
opResult = await this.templateinfoSve.createTemplate(pobj);
break;
case "editTemplateContent"://修改模板内容
opResult = await this.templateinfoSve.editTemplateContent(pobj);
break;
case "updateSwitchStatus"://修改模板启用状态
opResult = await this.templateinfoSve.updateSwitchStatus(pobj);
break;
case "findAndCountAll"://模板列表查询
opResult = await this.templateinfoSve.findAndCountAll(pobj.actionBody);
break;
case "findOneByCode"://模板查询
opResult = await this.templateinfoSve.findOneByCode(pobj);
break;
case "editTemplateTdk"://编辑模板TDK
opResult = await this.templateinfoSve.editTemplateTdk(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = Template;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class BizChanceAPI extends APIBase {
constructor() {
super();
this.bizChanceS = system.getObject("service.bizchance.bizoptSve");
this.dateUtil = system.getObject("util.dateClient");
}
/**
* 按照服务商进行分组统计
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizChanceCountBySp(p, q, req) {
let bizStatus = p.bizStatus
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChanceCountBySp(bizStatus, betweenTime)
return system.getResult(rtn)
}
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizChance(p, q, req) {
let companyId = p.company_id
let userid = p.userid
let username = p.username
let opath = p.opath
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizChanceS.statBizChance(companyId, opath, username, userid, betweenTime);
return system.getResult(rtn)
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回JSON对象字符串",
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam() {
return ``
}
}
module.exports = BizChanceAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class BizDeliverAPI extends APIBase {
constructor() {
super();
this.bizDeliveryS = system.getObject("service.bizchance.deliverybillSve")
this.dateUtil = system.getObject("util.dateClient");
}
async statBizDeliveryCountBySp(p, q, req) {
let bizStatus = p.bizStatus;
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDeliveryCountBySp(bizStatus, betweenTime)
return system.getResult(rtn)
}
async statBizDeliverySettleAmountBySp(p, q, req) {
let bizStatus = p.bizStatus
let rtn = await this.bizDeliveryS.statBizDeliverySettleAmountBySp(bizStatus)
return system.getResult(rtn)
}
/**
* 待处理商机beforeSubmission
* 处理中商机 beforeConfirmation
*累计处理商机 包括成单和关闭
* @param {*} p
* @param {*} q
* @param {*} req
*/
async statBizDelivery(p, q, req) {
let companyId = p.company_id
let userid = p.userid
let username = p.username
let opath = p.opath
let betweenTime = this.dateUtil.betweenTime(p.dateType);
let rtn = await this.bizDeliveryS.statBizDelivery(companyId, opath, username, userid, betweenTime)
return system.getResult(rtn)
}
classDesc() {
return {
groupName: "auth",
groupDesc: "认证相关的包",
name: "AccessAuthAPI",
desc: "关于认证的类",
exam: `
post http://p.apps.com/api/auth/accessAuth/getAccessKey
{
appKey:xxxxx,
secret:yyyyyy
}
`,
};
}
methodDescs() {
return [
{
methodDesc: "生成访问token,访问地址:http://......../api/auth/accessAuth/getAccessKey,访问token需要放置到后续API方法调用的请求头中",
methodName: "getAccessKey",
paramdescs: [
{
paramDesc: "访问appkey",
paramName: "appkey",
paramType: "string",
defaultValue: "",
},
{
paramDesc: "访问secret",
paramName: "secret",
paramType: "string",
defaultValue: "",
}
],
rtnTypeDesc: "返回JSON对象字符串",
rtnType: "json object {accessKey: xxxxxx, app: {xxx:xxx}},注意app,是当前app信息,详细见后面示例"
},
];
}
exam() {
return ``
}
}
module.exports = BizDeliverAPI;
......@@ -26,7 +26,7 @@ class CtlBase {
}
async findAndCountAll(pobj, qobj, req) {
//设置查询条件
pobj.search.company_id = pobj.company_id;
console.log(pobj)
const rs = await this.service.findAndCountAll(pobj);
return system.getResult(rs);
}
......@@ -56,12 +56,12 @@ class CtlBase {
codename: req.headers["xcodename"],
codetitle: req.headers["xcodetitle"] ? decodeURI(req.headers["xcodetitle"]) : '',
}
//添加组织结构路径,如果是上级,取上级
if (req.xctx.ptags && req.xctx.ptags != "") {
pobj.opath = req.xctx.ptags
} else {
pobj.opath = req.xctx.opath
}
if (!req.xctx.appkey) {
return [-200, "请求头缺少应用x-app-key"]
} else {
......@@ -76,7 +76,7 @@ class CtlBase {
// if(!req.xctx.companyid && !req.xctx.companykey){
// return [-200,"请求头缺少应用x-app-key"]
// }
if (!req.xctx.companyid && req.xctx.fromcompanykey && req.xctx.fromcompanykey != "null" && req.xctx.fromcompanykey != "undefined") {
if (!req.xctx.companyid && req.xctx.fromcompanykey && req.xctx.fromcompanykey != "null" && req.xctx.fromcompanykey != 'undefined') {
let comptmp = await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey);
req.xctx.companyid = comptmp.id;
}
......@@ -85,9 +85,7 @@ class CtlBase {
}
if (req.xctx.userid) {//在请求传递数据对象注入公司id
pobj.userid = req.xctx.userid;
}
if (req.xctx.username) {//在请求传递数据对象注入公司名称
pobj.username = req.xctx.username;
pobj.username = req.xctx.username
}
pobj.bizpath = req.xctx.bizpath;
}
......
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings=require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
class AuthCtl extends CtlBase{
constructor(){
super("auth",CtlBase.getServiceName(AuthCtl));
}
async saveAuths(pobj,query,req){
var auths=pobj.auths;
var xrtn=await this.service.saveAuths(auths,pobj.app_id,pobj.company_id);
return system.getResult(xrtn);
}
async findAuthsByRoles(pobj,query,req){
var roleids=pobj.roleids;
var xrtn=await this.service.findAuthsByRole(roleids,pobj.app_id,pobj.company_id);
return system.getResult(xrtn);
}
}
module.exports=AuthCtl;
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");
class DataauthCtl extends CtlBase{
constructor(){
super("auth",CtlBase.getServiceName(DataauthCtl));
}
async saveauth(qobj,querybij,req){
var arys=qobj.arys;
var uid=qobj.uid;
var refmodel=qobj.modelname;
var u=await this.service.saveauth({
user_id:uid,
modelname:refmodel,
auths:arys.join(","),
app_id:req.appid,
});
return system.getResult(u);
}
async fetchInitAuth(qobj,querybij,req){
var uid=qobj.uid;
var refmodel=qobj.modelname;
var authtmp=await this.service.findOne({user_id:uid,modelname:refmodel,app_id:req.appid});
if(authtmp){
var auths= authtmp.auths;
var arys=auths.split(",");
return system.getResult(arys);
}else{
return system.getResultSuccess([]);
}
}
}
module.exports=DataauthCtl;
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");
class OrgCtl extends CtlBase{
constructor(){
super("auth",CtlBase.getServiceName(OrgCtl));
// this.compSvr=system.getObject("service.common.companySve");
}
//检查是否已经存在主要岗位
async checkMainPosition(p,q,req){
return this.service.checkMainPosition(p,q,req);
}
async changePos(p,q,req){
var toorgid=p.orgid;
var uid=p.uid;
var rtn= await this.service.changePos(toorgid,uid);
return system.getResult(rtn);
}
async create(p,q,req){
return super.create(p,q,req);
}
async delete(p,q,req){
return super.delete(p,q,req);
}
async update(p,q,req){
return super.update(p,q,req);
}
async initOrgs(p,q,req){
var tocompany=req.session.tocompany;
var cmkey=p.comkey;
if(cmkey){
tocompany =await this.compSvr.findOne({companykey:cmkey});
}
//按照公司名称查询,是否存在节点,不存在,就创建根节点
//如果存在就按照名称查询出当前和她的字节点
var rtn=await this.service.initOrgs(tocompany,req.appid);
return system.getResult(rtn);
}
async findOrgById(p,q,req){
var rtn=await this.service.findOrgById(p.id);
return system.getResult(rtn);
}
}
module.exports=OrgCtl;
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");
var cacheBaseComp = null;
class RoleCtl extends CtlBase {
constructor() {
super("auth",CtlBase.getServiceName(RoleCtl));
this.redisClient=system.getObject("util.redisClient");
}
async initNewInstance(pobj,queryobj, req) {
var rtn = {};
rtn.roles = [];
return system.getResultSuccess(rtn);
}
async create(pobj,queryobj, req) {
let r=await super.create(pobj,queryobj, req)
return system.getResult(r);
}
}
module.exports = RoleCtl;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
class UserCtl extends CtlBase {
constructor() {
super("auth", CtlBase.getServiceName(UserCtl));
}
async resetPassword(pobj, qobj, req){
await this.service.resetPassword(req.xctx.username,pobj.onepassword)
return system.getResult({});
}
async allowOrNot(pobj, qobj, req){
await this.service.updateByWhere({isEnabled:!pobj.isEnabled},{company_id:pobj.company_id})
return system.getResult({});
}
async initNewInstance(queryobj, req) {
var rtn = {};
rtn.roles = [];
return system.getResultSuccess(rtn);
}
//获取验证码,发送给指定手机
// async sendVCode(pobj, qobj, req) {
// var mobile = pobj.mobile;
// let v = await this.smsS.sendVCode(mobile);
// return system.getResult({ vcodestr: v });
// }
async exit(pobj, qobj, req) {
}
//应用的自由用户注册,无需验证,需要前端头设置公司KEY
async pmregisterByFreeUser(p, q, req) {
//检查是否有用户名和密码
if (!pobj.userName || !pobj.password) {
return system.getResult(null, "请检查用户名和密码是否存在")
}
//p.company_id = req.xctx.companyid;//控制基类里已经添加
if (!p.company_id) {
return system.getResultFail(-201, "自有用户创建需要提供公司KEY");
}
let rtn = await this.service.pmregisterByFreeUser(p, q);
return rtn;
}
async create(p, q, req){
//检查是否有用户名和密码
if (!p.userName) {
return system.getResult(null, "请检查用户名和密码是否存在")
}
let rtn = await this.service.registerByTantent(p, q);
return system.getResult(rtn);
}
//登录后的租户创建属于租户的用户
//需要在控制器里取出公司ID
//和租户绑定同一家公司
//按照用户名和密码进行注册
//控制器端检查用户名和密码非空
async registerByTantent(p, q, req) {
//检查是否有用户名和密码
if (!pobj.userName) {
return system.getResult(null, "请检查用户名和密码是否存在")
}
let rtn = await this.service.registerByTantent(p, q);
return rtn;
}
//租户用户名和密码的租户注册
async pmregister(pobj, qobj, req) {
//平台注册设置平台的应用ID
pobj.app_id = settings.pmappid;
//检查是否有用户名和密码
if (!pobj.userName || !pobj.password) {
return system.getResult(null, "请检查用户名和密码是否存在")
}
var rtn = await this.service.pmregister(pobj);
return system.getResult(rtn);
}
async pmlogin(pobj, qobj, req) {
//平台注册设置平台的应用ID
let rtn = await this.service.pmlogin(pobj, qobj, req);
return system.getResult(rtn);
}
async getUserInfo(pobj, qobj, req) {
let uname = req.xctx.username;
let rtn = await this.service.getUserInfo(uname);
return system.getResult(rtn);
}
//按照电话创建自由用户
async pmloginByVCodeForFreeUser(p, q, req) {
if (!pobj.mobile || !pobj.vcode) {
return system.getResult(null, "请检查手机号和验证码是否存在")
}
p.companykey = req.xctx.companykey;
if (!p.companykey) {
return system.getResult(null, "自有用户创建需要提供公司KEY");
}
let rtn = await this.service.pmloginByVCodeForFreeUser(p, q);
return rtn;
}
async pmloginByVCode(pobj, qobj, req) {
let rtn = await this.service.pmloginByVCode(pobj, qobj);
return system.getResult(rtn);
}
async pmSendVCode(pobj, qobj, req) {
let rtn = await this.service.sendVCode(pobj, qobj);
return system.getResult(rtn);
}
}
module.exports = UserCtl;
var system = require("../../../system");
const http = require("http");
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const moment = require('moment');
class CacheInfoCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(CacheInfoCtl));
this.deliverService = system.getObject("service.bizchance.deliverybillSve");
}
/*根据交付单id获取缓存详情*/
async findInfoByDeliverId(mobj,qobj,req){
var pobj = mobj.d;
if (pobj.deliverNumber && pobj.deliverNumber != 'undefined')
{
try{
var rs = await this.service.findInfoByDeliverId(pobj);
var divInfo = await this.deliverService.findInfoByDeliverCode(pobj);
var rarr = {};
if (rs && rs != 'undefined'){
rarr.deliverNumber = rs.deliver_id;
rarr.cacheInfo = rs.cache_info;
if (rarr.cacheInfo && rarr.cacheInfo != 'undefined'){
if (rarr.cacheInfo.cmpContactInfo.contactsPhone && rarr.cacheInfo.cmpContactInfo.contactsPhone != 'undefined'){
rarr.cacheInfo.cmpContactInfo.contactsPhone = system.decryptStr(rarr.cacheInfo.cmpContactInfo.contactsPhone);
}
if (rarr.cacheInfo.positionData && rarr.cacheInfo.positionData.length > 0){
for (var i =0; i< rarr.cacheInfo.positionData.length;i++){
if (rarr.cacheInfo.positionData[i].fixedPhone && rarr.cacheInfo.positionData[i].fixedPhone != 'undefined'){
rarr.cacheInfo.positionData[i].fixedPhone = system.decryptStr(rarr.cacheInfo.positionData[i].fixedPhone);
}
if (rarr.cacheInfo.positionData[i].mobilePhone && rarr.cacheInfo.positionData[i].mobilePhone != 'undefined'){
rarr.cacheInfo.positionData[i].mobilePhone = system.decryptStr(rarr.cacheInfo.positionData[i].mobilePhone);
}
}
}
if (rarr.cacheInfo.contributionData && rarr.cacheInfo.contributionData.length > 0){
for (var i =0; i< rarr.cacheInfo.contributionData.length;i++){
if (rarr.cacheInfo.contributionData[i].phoneNumber && rarr.cacheInfo.contributionData[i].phoneNumber != 'undefined'){
rarr.cacheInfo.contributionData[i].phoneNumber = system.decryptStr(rarr.cacheInfo.contributionData[i].phoneNumber);
}
if (rarr.cacheInfo.contributionData[i].IdentificationNumber && rarr.cacheInfo.contributionData[i].IdentificationNumber != 'undefined'){
rarr.cacheInfo.contributionData[i].IdentificationNumber = system.decryptStr(rarr.cacheInfo.contributionData[i].IdentificationNumber);
}
}
}
}
rarr.statusInfo = {};
if (divInfo && divInfo != 'undefined'){
rarr.statusInfo.deliverStatus = divInfo.delivery_status;//状态
rarr.statusInfo.statusReason = divInfo.close_reason;//状态原因
rarr.statusInfo.createdTime = this.timeFormat(divInfo.created_at);
rarr.statusInfo.updateTime = this.timeFormat(divInfo.updated_at)
}
}
return system.getResult(rarr);
}
catch(error){
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
}
}
/*根据交付单id更新缓存信息*/
async updateInfoByDeliverId(mobj,qobj,req){
var pobj = mobj.d;
console.log("cache---------------------------------------" + JSON.stringify(pobj));
if (pobj.deliverNumber && pobj.deliverNumber != 'undefined' && pobj.cacheInfo && pobj.cacheInfo != 'undefined'){
try{
if (pobj.cacheInfo.cmpContactInfo && pobj.cacheInfo.cmpContactInfo != 'undefined'){
if (pobj.cacheInfo.cmpContactInfo.contactsPhone && pobj.cacheInfo.cmpContactInfo.contactsPhone != 'undefined'){
pobj.cacheInfo.cmpContactInfo.contactsPhone = system.encryptStr(pobj.cacheInfo.cmpContactInfo.contactsPhone);
}
}
if (pobj.cacheInfo.positionData && pobj.cacheInfo.positionData.length > 0){
for (var i =0; i< pobj.cacheInfo.positionData.length;i++){
if (pobj.cacheInfo.positionData[i].fixedPhone && pobj.cacheInfo.positionData[i].fixedPhone != 'undefined'){
pobj.cacheInfo.positionData[i].fixedPhone = system.encryptStr(pobj.cacheInfo.positionData[i].fixedPhone);
}
if (pobj.cacheInfo.positionData[i].mobilePhone && pobj.cacheInfo.positionData[i].mobilePhone != 'undefined'){
pobj.cacheInfo.positionData[i].mobilePhone = system.encryptStr(pobj.cacheInfo.positionData[i].mobilePhone);
}
}
}
if (pobj.cacheInfo.contributionData && pobj.cacheInfo.contributionData.length > 0){
for (var i =0; i< pobj.cacheInfo.contributionData.length;i++){
if (pobj.cacheInfo.contributionData[i].phoneNumber && pobj.cacheInfo.contributionData[i].phoneNumber != 'undefined'){
pobj.cacheInfo.contributionData[i].phoneNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].phoneNumber);
}
if (pobj.cacheInfo.contributionData[i].IdentificationNumber && pobj.cacheInfo.contributionData[i].IdentificationNumber != 'undefined'){
pobj.cacheInfo.contributionData[i].IdentificationNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].IdentificationNumber);
}
}
}
var res = await this.service.updateInfoByDeliverId(pobj);
return system.getResult("更新成功!");
}
catch (error){
console.log("error----------------------------" + error);
return system.getResultError(error);
}
}
else{
console.log("-----------------------------------------参数错误");
return system.getResultError("参数错误!");
}
}
/*插入或更新缓存信息 */
async createInfo(mobj,qobj,req){
var pobj = mobj.d;
if (pobj.deliverNumber && pobj.deliverNumber != 'undefined' && pobj.cacheInfo && pobj.cacheInfo != 'undefined'){
try{
if (pobj.cacheInfo.cmpContactInfo && pobj.cacheInfo.cmpContactInfo != 'undefined'){
if (pobj.cacheInfo.cmpContactInfo.contactsPhone && pobj.cacheInfo.cmpContactInfo.contactsPhone != 'undefined'){
pobj.cacheInfo.cmpContactInfo.contactsPhone = system.encryptStr(pobj.cacheInfo.cmpContactInfo.contactsPhone);
}
}
if (pobj.cacheInfo.positionData && pobj.cacheInfo.positionData.length > 0){
for (var i =0; i< pobj.cacheInfo.positionData.length;i++){
if (pobj.cacheInfo.positionData[i].fixedPhone && pobj.cacheInfo.positionData[i].fixedPhone != 'undefined'){
pobj.cacheInfo.positionData[i].fixedPhone = system.encryptStr(pobj.cacheInfo.positionData[i].fixedPhone);
}
if (pobj.cacheInfo.positionData[i].mobilePhone && pobj.cacheInfo.positionData[i].mobilePhone != 'undefined'){
pobj.cacheInfo.positionData[i].mobilePhone = system.encryptStr(pobj.cacheInfo.positionData[i].mobilePhone);
}
}
}
if (pobj.cacheInfo.contributionData && pobj.cacheInfo.contributionData.length > 0){
for (var i =0; i< pobj.cacheInfo.contributionData.length;i++){
if (pobj.cacheInfo.contributionData[i].phoneNumber && pobj.cacheInfo.contributionData[i].phoneNumber != 'undefined'){
pobj.cacheInfo.contributionData[i].phoneNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].phoneNumber);
}
if (pobj.cacheInfo.contributionData[i].IdentificationNumber && pobj.cacheInfo.contributionData[i].IdentificationNumber != 'undefined'){
pobj.cacheInfo.contributionData[i].IdentificationNumber = system.encryptStr(pobj.cacheInfo.contributionData[i].IdentificationNumber);
}
}
}
var rs = await this.service.findInfoByDeliverId(pobj);
if (rs){
await this.service.updateInfoByDeliverId(pobj);
}
else{
await this.service.insertInfo(pobj);
}
return system.getResult("操作成功!");
}
catch (error){
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
}
}
timeFormat(date) {
let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD");
return localTime;
}
}
module.exports = CacheInfoCtl;
// var task = new CacheInfoCtl();
// var obj={"demand_code":"30030302992","business_status":"isFinished"};
// task.updateStatusByDemandCode(obj,{},{}).then(d=>{
// console.log(d);
// //console.log(d[0].analyse);
// })
var system = require("../../../system");
const http = require("http");
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const moment = require('moment');
class MaterialCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(MaterialCtl));
}
/*根据交付单id获取材料信息*/
async findInfoByDeliverId(mobj, qobj, req) {
var pobj = mobj.d;
if (pobj.deliverId && pobj.deliverId != 'undefined') {
try {
var rs = await this.service.findInfoByDeliverId(pobj);
var rarr = {};
if (rs) {
rarr.deliverId = rs.delivery_id;
rarr.deliverNumber = rs.delivery_code;
rarr.companyInfo = rs.company_info;
rarr.registeredInfo = rs.registered_info;
rarr.contributionInfo = rs.contribution_info;
rarr.positionInfo = rs.position_info;
rarr.regInfo = rs.file_info;
rarr.expressInfo = rs.express_info;
}
return system.getResult(rarr);
}
catch (error) {
return system.getResultError(error);
}
}
else {
return system.getResultError("参数错误!");
}
}
/*根据交付单id更新交付单编号信息*/
async updateInfoByDeliverId(mobj, qobj, req) {
var pobj = mobj.d;
if (pobj.deliverId && pobj.deliverId != 'undefined' && pobj.deliverNumber && pobj.deliverNumber != 'undefined') {
try {
var res = await this.service.updateInfoByDeliverId(pobj);
return system.getResult("更新成功!");
}
catch (error) {
return system.getResultError(error);
}
}
else {
return system.getResultError("参数错误!");
}
}
/*插入缓存信息 */
async insertInfo(mobj, qobj, req) {
var pobj = mobj.d;
if (pobj.deliverId && pobj.deliverId != 'undefined') {
try {
var res = await this.service.insertInfo(pobj);
return system.getResult("插入成功!");
}
catch (error) {
return system.getResultError(error);
}
}
else {
return system.getResultError("参数错误!");
}
}
/* 获取待压缩文件的信息*/
async waitGenerate() {
try {
var res = await this.service.findnoUrlInfo();
if (res && res != 'undefined') {
return system.getResult(res);
}
else {
return system.getResultError("没有待压缩的数据");
}
}
catch (error) {
return system.getResultError(error);
}
}
/* 根据id更新zip信息 */
async updateZipById(pobj, qobj, req) {
console.log("zip------------------" + JSON.stringify(pobj));
if (pobj.id && pobj.id != 'undefined' && pobj.url && pobj.url != 'undefined'){
try{
await this.service.updateZipById(pobj);
return system.getResult("更新压缩信息成功");
}
catch(error){
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
}
}
timeFormat(date) {
let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD");
return localTime;
}
}
module.exports = MaterialCtl;
// var task = new MaterialCtl();
// var obj={"id":2,"url":"http://test-1258715722.cos.ap-beijing.myqcloud.com/materials/90c263e0-b9d6-11ea-9e11-29abb292cf5f.png"};
// task.updateZipById(obj).then(d=>{
// console.log(JSON.stringify(d));
// //console.log(d[0].analyse);
// })
var system = require("../../../system");
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const appconfig = system.getSysConfig();
class SettleBillCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(SettleBillCtl));
}
async advice(p,q,req){
let sid= p.advice.settleId
let msg=p.advice.memo
let userid=p.userid
let userName=p.username
let rtn=await this.service.advice(sid,msg,userid,userName)
return system.getResult(rtn)
}
async auditPass(p,q,req){
let sid= p.pass.settleId
let rtn=await this.service.auditPass(sid,p.userid,p.username)
return system.getResult(rtn)
}
async pay(p,q,req){
let sid= p.pay.settleId
let rtn=await this.service.pay(sid,p.userid,p.username)
return system.getResult(rtn)
}
}
module.exports = SettleBillCtl;
var system = require("../../../system");
const http = require("http");
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const moment = require('moment');
class StatusLogCtl extends CtlBase {
constructor() {
super("bizchance", CtlBase.getServiceName(StatusLogCtl));
}
/*插入缓存信息 */
async insertInfo(mobj,qobj,req){
var pobj = mobj.d;
if (pobj.flowType && pobj.flowType != 'undefined' && pobj.flowId && pobj.flowId != 'undefined'
&& pobj.statusCode && pobj.statusCode != 'undefined'){
try{
var res = await this.service.insertInfo(pobj);
return system.getResult("插入成功!");
}
catch (error){
return system.getResultError(error);
}
}
else{
return system.getResultError("参数错误!");
}
}
timeFormat(date) {
let localTime = moment.utc(date).toDate();
localTime = moment(localTime).format("YYYY-MM-DD");
return localTime;
}
}
module.exports = StatusLogCtl;
// var task = new CacheInfoCtl();
// var obj={"demand_code":"30030302992","business_status":"isFinished"};
// task.updateStatusByDemandCode(obj,{},{}).then(d=>{
// console.log(d);
// //console.log(d[0].analyse);
// })
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
class CompanyCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(CompanyCtl));
}
async update(p,q,req){
let u= await super.update(p,q,req)
//缓存失效
await this.cacheManager["CompanyCache"].invalidate(p.companykey)
let company=await this.cacheManager["CompanyCache"].cache(p.companykey)
return system.getResult(company)
}
async setOrgs(p,q,req){
let orgs=await this.service.setOrgs(p,req.xctx.fromcompanykey)
return system.getResult(orgs)
}
async getOrgs(p,q,req){
let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey)
return system.getResult({orgJson:JSON.parse(companynew.orgJson)})
}
}
module.exports = CompanyCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class FormInfoCtl extends CtlBase {
constructor() {
super("formmag", CtlBase.getServiceName(FormInfoCtl));
}
}
module.exports = FormInfoCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class FormsubrecordCtl extends CtlBase {
constructor() {
super("formsubrecordmag", CtlBase.getServiceName(FormsubrecordCtl));
}
}
module.exports = FormsubrecordCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class ImgInfoCtl extends CtlBase {
constructor() {
super("configmag", CtlBase.getServiceName(ImgInfoCtl));
}
}
module.exports = ImgInfoCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class LaunchchannelCtl extends CtlBase {
constructor() {
super("launchchannelmag", CtlBase.getServiceName(LaunchchannelCtl));
this.launchchannelSve = system.getObject('service.configmag.launchchannelSve');
}
/**
* 重写添加方法
* @param pobj
* @returns {Promise<{msg: string, data: *, bizmsg: string, status: number}>}
*/
async create(pobj){
const result = await this.launchchannelSve.createChannel(pobj);
return system.getResult(result);
}
}
module.exports = LaunchchannelCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class LaunchtypeCtl extends CtlBase {
constructor() {
super("launchtypemag", CtlBase.getServiceName(LaunchtypeCtl));
}
}
module.exports = LaunchtypeCtl;
......@@ -15,6 +15,8 @@ class Dao {
async create(u, t) {
var u2 = this.preCreate(u);
if (t) {
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
//console.log( this.model);
return this.model.create(u2, { transaction: t }).then(u => {
return u;
});
......@@ -28,7 +30,7 @@ class Dao {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase()
}
async refQuery(qobj) {
var w = qobj.refwhere ? qobj.refwhere : {};
var w =qobj.refwhere? qobj.refwhere:{};
if (qobj.levelinfo) {
w[qobj.levelinfo.levelfield] = qobj.levelinfo.level;
}
......@@ -36,8 +38,8 @@ class Dao {
w[qobj.parentinfo.parentfield] = qobj.parentinfo.parentcode;
}
//如果需要控制数据权限
if (qobj.datapriv) {
w["id"] = { [this.db.Op.in]: qobj.datapriv };
if(qobj.datapriv){
w["id"]={ [this.db.Op.in]: qobj.datapriv};
}
if (qobj.likestr) {
w[qobj.fields[0]] = { [this.db.Op.like]: "%" + qobj.likestr + "%" };
......@@ -62,18 +64,18 @@ class Dao {
async delete(qobj, t) {
var en = null
if (t != null && t != 'undefined') {
en = await this.model.findOne({ where: { id: qobj.id }, transaction: t });
en=await this.model.findOne({ where: {id:qobj.id},transaction:t});
if (en != null) {
await en.destroy({ transaction: t });
return en
}
} else {
en = await this.model.findOne({ where: { id: qobj.id } });
en=await this.model.findOne({ where: {id:qobj.id}});
if (en != null) {
return en.destroy();
}
return en
}
return null;
}
extraModelFilter(pobj) {
//return {"key":"include","value":{model:this.db.models.app}};
......@@ -101,8 +103,8 @@ class Dao {
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] != "") || search[k] === 0) {
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]);
......@@ -110,9 +112,6 @@ class Dao {
qc.where[k] = { [this.db.Op.between]: [stdate, enddate] };
}
}
else if (k.indexOf("is_enabled") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("id") >= 0) {
qc.where[k] = search[k];
}
......@@ -143,7 +142,7 @@ class Dao {
if (extraFilter) {
qc[extraFilter.key] = extraFilter.value;
}
console.log(" ------------ 传入 的 查询 条件 ------------- ");
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
console.log(qc);
return qc;
}
......@@ -151,11 +150,11 @@ class Dao {
var aggsinfos = [];
if (qobj.aggsinfo) {
qobj.aggsinfo.sum.forEach(aggitem => {
var t1 = [this.db.fn('SUM', this.db.col(aggitem.field)), aggitem.field + "_" + "sum"];
var t1 = [this.db.fn('SUM', this.db.col(aggitem.field)), aggitem.field + "~" + "sum"];
aggsinfos.push(t1);
});
qobj.aggsinfo.avg.forEach(aggitem => {
var t2 = [this.db.fn('AVG', this.db.col(aggitem.field)), aggitem.field + "_" + "avg"];
var t2 = [this.db.fn('AVG', this.db.col(aggitem.field)), aggitem.field + "~" + "avg"];
aggsinfos.push(t2);
});
}
......@@ -203,22 +202,40 @@ class Dao {
}
async updateByWhere(setObj, whereObj, t) {
let inWhereObj = {}
let inWhereObj={}
if (t && t != 'undefined') {
if (whereObj && whereObj != 'undefined') {
inWhereObj["where"] = whereObj;
inWhereObj["where"]=whereObj;
inWhereObj["transaction"] = t;
} else {
inWhereObj["transaction"] = t;
}
} else {
inWhereObj["where"] = whereObj;
}else{
inWhereObj["where"]=whereObj;
}
return this.model.update(setObj, inWhereObj);
}
async customExecAddOrPutSql(sql, paras = null) {
return this.db.query(sql, paras);
}
/**
* p.group.fields=['','']
* p.group.sumField=''
* p.group.aliasField=' as xxx'
* @param {*} p
*/
async statGroupBy(p,paras,t){
let groupFields=p.group.byFields.join(",")
let aggField=p.group.aggField?p.group.aggField:''
let tblName=p.group.tblName?p.group.tblName:''
let where=p.group.where?p.group.where:''
let having=p.group.having?p.group.having:''
let aliasField=p.group.aliasField?p.group.aliasField:''
let actionType=p.group.actionType?p.group.actionType:'count'
let sql=`select ${groupFields},${actionType}(${aggField}) ${aliasField} from ${tblName} ${where} group by ${groupFields} ${having} WITH ROLLUP`
return this.customQuery(sql,paras,t)
}
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') {
......@@ -258,23 +275,16 @@ class Dao {
if (includeObj != null && includeObj.length > 0) {
tmpWhere.include = includeObj;
tmpWhere.distinct = true;
} else {
}else{
tmpWhere.raw = true;
}
return await this.model.findAndCountAll(tmpWhere);
}
async findOne(obj, attributes = []) {
if (attributes.length > 0) {
return this.model.findOne({ "where": obj, attributes, row: true });
} else {
return this.model.findOne({ "where": obj, row: true });
}
async findOne(obj) {
return this.model.findOne({ "where": obj });
}
async findById(oid) {
return this.model.findById(oid);
}
async findAll(obj, include = []) {
return this.model.findAll({ "where": obj, include, row: true });
}
}
module.exports = Dao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class ForminfoDao extends Dao{
class AuthDao extends Dao{
constructor(){
super(Dao.getModelName(ForminfoDao));
super(Dao.getModelName(AuthDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
return qw;
}
}
module.exports=ForminfoDao;
module.exports=AuthDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class FormitemDao extends Dao{
class DataauthDao extends Dao{
constructor(){
super(Dao.getModelName(FormitemDao));
super(Dao.getModelName(DataauthDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
return qw;
}
}
module.exports=FormitemDao;
module.exports=DataauthDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class OrgDao extends Dao{
constructor(){
super(Dao.getModelName(OrgDao));
}
extraWhere(qobj,qw,qc){
qc.raw=true;
return qw;
}
}
module.exports=OrgDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class RoleDao extends Dao{
constructor(){
super(Dao.getModelName(RoleDao));
}
async findOne(paramappid,t){
var app= await this.model.findOne({where:{appid:paramappid}},{transaction:t});
return app;
}
extraWhere(obj,w,qc,linkAttrs){
// if(obj.codepath && obj.codepath!=""){
// // if(obj.codepath.indexOf("userarch")>0){//说明是应用管理员的查询
// // console.log(obj);
// // w["app_id"]=obj.appid;
// // }
// }
w["app_id"]=obj.app_id;
w["company_id"]=obj.company_id;
return w;
}
extraModelFilter(){
return {"key":"include","value":[{model:this.db.models.app,}]};
}
async preUpdate(u){
return u;
}
async update(obj){
var obj2=await this.preUpdate(obj);
await this.model.update(obj2,{where:{id:obj2.id}});
var role=await this.model.findOne({where:{id:obj2.id}});
return role;
}
async preCreate(u){
return u;
}
async create(u,t){
var self=this;
var u2= await this.preCreate(u);
if(t){
var role= await this.model.create(u2,{transaction: t});
return role;
}else{
var role= await this.model.create(u2);
return role;
}
}
}
module.exports=RoleDao;
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"]}
]},
],
});
}
async getUserByUsername(username,appkey,t){
var app=await this.appDao.findOne(appkey);
var tUser=await this.model.findOne({
where:{userName:username,app_id:app.id},
include:[{model:this.db.models.app,raw:true},
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{model:this.db.models.account,attributes:["id","isSuper","referrerOnlyCode"],raw:true},
{model:this.db.models.role,as:"Roles",attributes:["id","code"],include:[
{model:this.db.models.product,as:"Products",attributes:["id","code"],raw:true}
]},
]},{transaction:t});
// if(tUser!=null){
// tUser=tUser.get({plain:true});
// tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
// }
return tUser;
}
async getUserByOpenId(popenid,appkey,t){
var app=await this.appDao.findOne(appkey);
var tUser=await this.model.findOne({
where:{openId:popenid},
include:[{model:this.db.models.app,raw:true},
// {model:this.db.models.partnerinfo,attributes:["id","user_id","app_id","userName","applyType","applyName","workPic","tagInfo","mobile","tel","applyProvince","applyCity",
// "applyArea","applyAddr","identityCardPic","identityCard","businessLicensePic","businessLicenseNum","entName","cardNo","realName"]},
{model:this.db.models.account,attributes:["id","isSuper","referrerOnlyCode"],raw:true},
{model:this.db.models.role,as:"Roles",attributes:["id","code"],include:[
{model:this.db.models.product,as:"Products",attributes:["id","code"],raw:true}
]},
]},{transaction:t});
if(tUser!=null){
tUser=tUser.get({plain:true});
tUser.partnerinfo=await this.partnerinfoDao.model.findOne({where:{onlyCode:tUser.onlyCode},raw:true});
}
// console.log("tUser.partnerinfo...................................>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>999sy");
// console.log(tUser);
return tUser;
}
async setAccount(user,account,t){
var user=await user.setAccount(account,{transaction: t});
return user;
}
async setApp(user,app,t){
//按照APPId,获取app对象
var user=await user.setApp(app,{transaction: t});
return user;
}
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.bizpath && obj.bizpath!=""){
if(obj.bizpath.indexOf("tanents_info")>0){//说明是超级管理员的查询
w["isAdmin"]=true;
}else{
w["isAdmin"]=false;
w["company_id"]=obj.company_id;
}
}
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}}});
u.roles=roles
}
return u;
}
async update(obj){
var obj2=await this.preUpdate(obj);
await this.model.update(obj2,{where:{id:obj2.id}});
var user=await this.model.findOne({where:{id:obj2.id}});
if(obj2.roles){
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){
console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
console.log(u2);
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 Dao = require("../../dao.base");
class BizoptDao extends Dao {
constructor() {
super(Dao.getModelName(BizoptDao));
}
extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件
qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) {
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") {
qw["salesman_opcode"] = { [this.db.Op.like]: `%${qobj.opath}%` }
}
//不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
qc.where.business_type = qc.where.business_type || {
[this.db.Op.notIn]: ["ICP", "EDI"]
}
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("myChance") > 0) {//说明是从商机列表过来的
qw["salesman_id"] = qobj.userid;
}
}
}
}
return qw;
}
/*根据商机编号获取商机详情*/
async findInfoByDemandCode(qobj) {
var qcwhere = { "demand_code": qobj.businessMode };
return await this.findOne(qcwhere);
}
/*更新商机状态*/
async updateStatusByDemandCode(qobj, t) {
var setobj = { "business_status": qobj.currentStatus };
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj["close_reason"] = qobj.statusReason;
}
else {
setobj["close_reason"] = "";
}
var whereobj = { "demand_code": qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
}
/*更新业务员信息*/
async updateSalesmanInfoByDemandCode(qobj,t){
var setobj = {};
if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
setobj.salesman_id = qobj.salesmanId;
};
if (qobj.salesmanName && qobj.salesmanName != 'undefined') {
setobj.salesman_name = qobj.salesmanName;
};
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
setobj.salesman_opcode = qobj.salesmanOpcode;
};
if (qobj.salesmanPhone && qobj.salesmanPhone != 'undefined') {
setobj.salesman_phone = qobj.salesmanPhone;
};
if (qobj.facilitatorId && qobj.facilitatorId != 'undefined') {
setobj.facilitator_id = qobj.facilitatorId;
};
if (qobj.facilitatorName && qobj.facilitatorName != 'undefined') {
setobj.facilitator_name = qobj.facilitatorName;
};
var whereobj = { "demand_code": qobj.businessMode };
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入商机信息*/
async insertInfo(qobj, t) {
var obj = {
"demand_code": qobj.businessMode,
"business_type": qobj.businessType,
"business_status": qobj.currentStatus,
"business_info": {}
};
if (qobj.channelSource && qobj.channelSource != 'undefined') {
obj.source_name = qobj.channelSource;
}
if (qobj.sourceNumber && qobj.sourceNumber != 'undefined') {
obj.source_number = qobj.sourceNumber;
}
if (qobj.serviceCode && qobj.serviceCode != 'undefined') {
obj.service_address = qobj.serviceCode;
}
if (qobj.memoInfo && qobj.memoInfo != 'undefined') {
obj.business_info.memoInfo = qobj.memoInfo;
}
if (qobj.statusReason && qobj.statusReason != 'undefined') {
obj.close_reason = qobj.statusReason;
}
if (qobj.contactsName && qobj.contactsName != 'undefined') {
obj.business_info.contactsName = qobj.contactsName;
}
if (qobj.contactsPhone && qobj.contactsPhone != 'undefined') {
obj.business_info.contactsPhone = qobj.contactsPhone;//已经加密
}
if (qobj.serviceName && qobj.serviceName != 'undefined') {
obj.business_info.serviceName = qobj.serviceName;
}
if (qobj.businessName && qobj.businessName != 'undefined') {
obj.business_info.businessName = qobj.businessName;
}
if (qobj.UserName && qobj.UserName != 'undefined') {
obj.business_info.userName = qobj.UserNames;
}
if (qobj.companyName && qobj.companyName != 'undefined') {
obj.business_info.companyName = qobj.companyName;
}
if (qobj.servicerCode && qobj.servicerCode != 'undefined') {
obj.facilitator_id = qobj.servicerCode;
}
if (qobj.servicerName && qobj.servicerName != 'undefined') {
obj.facilitator_name = qobj.servicerName;
}
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
obj.salesman_opcode = qobj.salesmanOpcode;
}
if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
obj.salesman_id = qobj.salesmanId;
}
if (qobj.clerkName && qobj.clerkName != 'undefined') {
obj.salesman_name = qobj.clerkName;
}
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined') {
obj.salesman_phone = qobj.clerkPhone;
}
return await this.create(obj, t);
}
}
module.exports = BizoptDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CacheinfoDao extends Dao {
constructor() {
super(Dao.getModelName(CacheinfoDao));
}
// extraWhere(qobj, qw, qc) {//根据业务员id获取商机信息的组装条件
// qc.raw = true;
// qc.where.business_type = qc.where.business_type || {
// [this.db.Op.notIn]: ["ICP", "EDI"]
// }
// if(qobj.bizpath && qobj.bizpath!=""){
// if(qobj.bizpath.indexOf("myChance")>0){//说明是从商机列表过来的
// qw["salesman_id"]=qobj.userid;
// }
// }
// return qw;
// }
/*根据订单id获取缓存信息详情*/
async findInfoByDeliverId(qobj){
var qcwhere = {"deliver_id":qobj.deliverNumber};
return await this.findOne(qcwhere);
}
/*更加订单id更新缓存信息*/
async updateInfoByDeliverId(qobj,t){
var setobj = {"cache_info":qobj.cacheInfo};
var whereobj = {"deliver_id":qobj.deliverNumber};
return await this.updateByWhere(setobj,whereobj,t);
}
/*插入缓存信息*/
async insertInfo(qobj,t){
var obj = {
"deliver_id":qobj.deliverNumber,
"cache_info":qobj.cacheInfo
};
return await this.create(obj,t);
}
}
module.exports = CacheinfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class DeliverybillDao extends Dao {
constructor() {
super(Dao.getModelName(DeliverybillDao));
}
extraModelFilter(pobj) {
return { "key": "include", "value": { model: this.db.models.settlebill, raw: true, attributes: ['memo'] } };
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
//qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qw["delivery_status"] == "handling") {//解决首页多状态查询
qw["delivery_status"] = { [this.db.Op.notIn]: ['received', 'success', 'closed'] }
}
if (qobj.company_id == 1) {
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("pmxdeliverrequest") > 0) {//说明是从商机列表过来的
qw["delivery_status"] = "success";
qw["settle_status"] = "waittosettle";
}
}
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
// 为空说明是管理员,不需设置组织结构过滤
if (qobj.opath && qobj.opath != "") {
qw["delivery_man_opcode"] = { [this.db.Op.like]: `%${qobj.opath}%` }
} else {//说明是租户管理员,给租户自己核销结算的功能,
if (qobj.bizpath.indexOf("pmxdeliverrequest") > 0) {//说明是结算核销路由过来的
qw["delivery_status"] = "success";
qw["settle_status"] = "waittosettle";
}
}
//不是来自平台前端查询
if (qobj.bizpath && qobj.bizpath.indexOf("pmx") < 0) {
qc.where.product_code = qc.where.product_code || {
[this.db.Op.notIn]: ["ICP", "EDI", "ICPANNUALREPORT", "EDIANNUALREPORT"]
}
if (qobj.bizpath && qobj.bizpath != "") {
if (qobj.bizpath.indexOf("myDeliver") > 0) {//说明是从商机列表过来的
qw["delivery_man_id"] = qobj.userid;
}
}
}
}
return qw;
}
/*根据交付单编号获取订单详情*/
async findInfoByDeliverCode(qobj) {
var qcwhere = { "delivery_code": qobj.deliverNumber };
return await this.findOne(qcwhere);
}
/*根据交付单编号更新状态信息*/
async updateStatusByDeliverCode(qobj, t) {
var setobj = { "delivery_status": qobj.deliverStatus };
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.close_reason = qobj.statusReason;
}
else {
setobj.close_reason = "";
}
var whereobj = { "delivery_code": qobj.deliverNumber };
var rs = await this.findOne(whereobj);
if (rs && rs != 'undefined') {
if (qobj.deliverStatus == "collecting" || qobj.deliverStatus == "received" || qobj.deliverStatus == "paid" || qobj.deliverStatus == "userConfirmationReject") {//兼顾阿里
rs.delivery_info.payStatus = "待交付";
}
else if (qobj.deliverStatus == "closed") {
rs.delivery_info.payStatus = "已关闭";
}
else {
rs.delivery_info.payStatus = "已交付";
}
setobj.delivery_info = rs.delivery_info;
}
return await this.updateByWhere(setobj, whereobj, t);
}
/*更新交付人员信息*/
async updateSalesmanInfoByDeliverCode(qobj, t) {
var setobj = {};
if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
setobj.delivery_man_id = qobj.salesmanId;
};
if (qobj.salesmanName && qobj.salesmanName != 'undefined') {
setobj.delivery_man_name = qobj.salesmanName;
};
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
setobj.delivery_man_opcode = qobj.salesmanOpcode;
};
// if (qobj.salesmanPhone && qobj.salesmanPhone != 'undefined') {
// setobj.salesman_phone = qobj.salesmanPhone;
// };
if (qobj.facilitatorId && qobj.facilitatorId != 'undefined') {
setobj.facilitator_id = qobj.facilitatorId;
};
if (qobj.facilitatorName && qobj.facilitatorName != 'undefined') {
setobj.facilitator_name = qobj.facilitatorName;
};
var whereobj = { "delivery_code": qobj.deliverNumber };
return await this.updateByWhere(setobj, whereobj, t);
}
/*根据交付单更新交付材料信息*/
async updateInfoByDeliverCode(qobj, t) {//公司注册、云上园区注册时填写交付材料
var whereobj = { "delivery_code": qobj.deliverNumber };
var setobj = { "delivery_info": qobj.baseInfo };
if (qobj.deliverStatus && qobj.deliverStatus != 'undefined') {
setobj.delivery_status = qobj.deliverStatus;
}
if (qobj.statusReason && qobj.statusReason != 'undefined') {
setobj.close_reason = qobj.statusReason;
}
else {
setobj.close_reason = "";
}
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入交付单信息*/
async insertInfo(qobj, t) {//到时候看交付单信息后再确定
var obj = {
"delivery_code": qobj.deliverNumber,
"delivery_status": qobj.deliverStatus,
"delivery_info": qobj.baseInfo
};
if (qobj.businessMode && qobj.businessMode != 'undefined') {
obj.demand_code = qobj.businessMode;
}
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined') {
obj.scheme_number = qobj.schemeNumber;
}
if (qobj.businessName && qobj.businessName != 'undefined') {
obj.product_name = qobj.businessName;
}
if (qobj.businessType && qobj.businessType != 'undefined') {
obj.product_code = qobj.businessType;
}
if (qobj.txOrderNum && qobj.txOrderNum != 'undefined') {
obj.master_source_number = qobj.txOrderNum;
}
if (qobj.channelSource && qobj.channelSource != 'undefined') {
obj.source_name = qobj.channelSource;
}
if (qobj.channelNumber && qobj.channelNumber != 'undefined') {
obj.source_number = qobj.channelNumber;
}
if (qobj.skuCode && qobj.skuCode != 'undefined') {
obj.sku_code = qobj.skuCode;
}
if (qobj.serviceCode && qobj.serviceCode != 'undefined') {
obj.service_address = qobj.serviceCode;
}
if (qobj.servicerCode && qobj.servicerCode != 'undefined') {
obj.facilitator_id = qobj.servicerCode;
}
if (qobj.servicerName && qobj.servicerName != 'undefined') {
obj.facilitator_name = qobj.servicerName;
}
if (qobj.clerkName && qobj.clerkName != 'undefined') {
obj.delivery_man_name = qobj.clerkName;
}
if (qobj.salesmanName && qobj.salesmanName != undefined){
obj.salesman_name = qobj.salesmanName;
}
if (qobj.salesmanPhone && qobj.salesmanPhone != 'undefined') {
obj.salesman_phone = qobj.salesmanPhone
}
if (qobj.salesmanOpcode && qobj.salesmanOpcode != 'undefined') {
obj.salesman_opcode = qobj.salesmanOpcode;
}
if (qobj.clerkOpcode && qobj.clerkOpcode != 'undefined') {
obj.delivery_man_opcode = qobj.clerkOpcode;
}
if (qobj.salesmanId && qobj.salesmanId != 'undefined') {
obj.salesman_id = qobj.salesmanId;
}
if (qobj.clerkId && qobj.clerkId != 'undefined') {
obj.delivery_man_id = qobj.clerkId;
}
if (qobj.sellingPrice && qobj.sellingPrice != 'undefined') {
obj.selling_price = qobj.sellingPrice;
}
if (qobj.costPrice && qobj.costPrice != 'undefined') {
obj.cost_price = qobj.costPrice;
}
if (qobj.statusReason && qobj.statusReason != 'undefined') {
obj.close_reason = qobj.statusReason;
}
return await this.create(obj, t);
}
}
module.exports = DeliverybillDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class MaterialDao extends Dao {
constructor() {
super(Dao.getModelName(MaterialDao));
}
/*根据交付单编号获取注册材料信息详情*/
async findInfoByDeliverNumber(qobj) {
var qcwhere = { "delivery_code": qobj.deliverNumber };
return await this.findOne(qcwhere);
}
/* 根据id更新zip信息 */
async updateZipById(qobj, t) {
try{
var whereobj = { "id": qobj.id };
var setobj= {
"is_download":1,
"download_url":qobj.url
};
return await this.updateByWhere(setobj, whereobj, t);
}
catch(error){
console.log("error----------" + error);
return error;
}
}
/*根据交付单编号更新交材料详情*/
async updateInfoByDeliverNumber(qobj, t) {
var whereobj = { "delivery_code": qobj.deliverNumber };
var setobj = {};
if (qobj.companyInfo && qobj.companyInfo != 'undefined') {
setobj.company_info = qobj.companyInfo;
}
if (qobj.registeredInfo && qobj.registeredInfo != 'undefined') {
setobj.registered_info = qobj.registeredInfo;
}
if (qobj.contributionInfo && qobj.contributionInfo != 'undefined') {
setobj.contribution_info = qobj.contributionInfo;
}
if (qobj.positionInfo && qobj.positionInfo != 'undefined') {
setobj.position_info = qobj.positionInfo;
}
if (qobj.managerInfo && qobj.managerInfo != 'undefined') {
setobj.position_info = qobj.managerInfo;
}
if (qobj.regInfo && qobj.regInfo != 'undefined') {
setobj.file_info = qobj.regInfo;
}
if (qobj.expressInfo && qobj.expressInfo != 'undefined') {
setobj.express_info = qobj.expressInfo;
}
return await this.updateByWhere(setobj, whereobj, t);
}
/*插入注册材料信息*/
async insertInfo(pobj, t) {//公司注册,云上园区注册时的信息
var obj = {
"delivery_code": pobj.deliverNumber
};
if (pobj.deliverId && pobj.deliverId != 'undefined') {
obj["delivery_id"] = pobj.deliverId;
}
if (pobj.companyInfo && pobj.companyInfo != 'undefined') {
obj.company_info = pobj.companyInfo;
}
if (pobj.registeredInfo && pobj.registeredInfo != 'undefined') {
obj.registered_info = pobj.registeredInfo;
}
if (pobj.positionInfo && pobj.positionInfo != 'undefined') {
obj.position_info = pobj.positionInfo;
}
if (pobj.regInfo && pobj.regInfo != 'undefined') {
obj.file_info = pobj.regInfo;
}
if (pobj.expressInfo && pobj.expressInfo != 'undefined') {
obj.express_info = pobj.expressInfo;
}
return await this.create(obj, t);
}
}
module.exports = MaterialDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class SalesmanhisDao extends Dao {
constructor() {
super(Dao.getModelName(SalesmanhisDao));
}
/*插入状态信息信息*/
async insertInfo(qobj,t){
var obj = {
"flow_type":qobj.flowType,
"flow_id":qobj.flowId,
"flow_code":qobj.flowCode,
"salesman_info":qobj.salesmanInfo
};
return await this.create(obj,t);
}
}
module.exports = SalesmanhisDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class SchemeDao extends Dao {
constructor() {
super(Dao.getModelName(SchemeDao));
}
/*根据商机编号获取方案信息详情*/
async findInfoByDemandCode(qobj){
var qcwhere = {"demand_code":qobj.businessMode};
return await this.findOne(qcwhere);
}
/*根据方案编号更新方案状态及原因*/
async updateStatusByDemandCode(qobj,t){
var setobj = {"scheme_status":qobj.currentStatus};
if (qobj.statusReason && qobj.statusReason != 'undefined'){
setobj["reject_reason"] = qobj.statusReason;
}
else{
setobj["reject_reason"] = "";
}
var whereobj = {"demand_code":qobj.businessMode};
return await this.updateByWhere(setobj,whereobj,t);
}
/*根据商机编号更新方案详情*/
async updateInfoByDemandCode(qobj,t){
var whereobj = {"demand_code":qobj.businessMode};
var setobj = {"scheme_info":qobj.baseInfo,"scheme_status":qobj.currentStatus};
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined'){
setobj.scheme_number = qobj.schemeNumber;
}
if (qobj.statusReason && qobj.statusReason != 'undefined'){
setobj.reject_reason = qobj.statusReason;
}
else{
setobj.reject_reason = "";
}
return await this.updateByWhere(setobj,whereobj,t);
}
/*根据方案编号更新方案编号*/
async updateSchemeNumberByDemandCode(qobj,t){
var setobj = {"scheme_number":qobj.schemeNumber};
var whereobj = {"demand_code":qobj.businessMode};
return await this.updateByWhere(setobj,whereobj,t);
}
/*插入方案信息*/
async insertInfo(qobj,t){
var obj = {
"demand_code":qobj.businessMode,
"scheme_info":qobj.baseInfo
};
if (qobj.currentStatus && qobj.currentStatus != 'undefined'){
obj["scheme_status"] = qobj.currentStatus;
}
if (qobj.schemeNumber && qobj.schemeNumber != 'undefined'){
obj["scheme_number"] = qobj.schemeNumber;
}
if (qobj.statusReason && qobj.statusReason != 'undefined'){
obj["reject_reason"] = qobj.statusReason;
}
if (qobj.memoInfo && qobj.memoInfo != 'undefined'){
obj["remark_info"] = qobj.memoInfo;
}
if (qobj.businessId && qobj.businessId != 'undefined'){
obj["bizopt_id"] = qobj.businessId;
}
if (qobj.servicerCode && qobj.servicerCode != 'undefined'){
obj["facilitator_id"] = qobj.servicerCode;
}
if (qobj.servicerName && qobj.servicerName != 'undefined'){
obj["facilitator_name"] = qobj.servicerName;
}
if (qobj.clerkOpcode && qobj.clerkOpcode != 'undefined'){
obj["salesman_opcode"] = qobj.clerkOpcode;
}
if (qobj.clerkId && qobj.clerkId != 'undefined'){
obj["salesman_id"] = qobj.clerkId;
}
if (qobj.clerkName && qobj.clerkName != 'undefined'){
obj["salesman_name"] = qobj.clerkName;
}
if (qobj.clerkPhone && qobj.clerkPhone != 'undefined'){
obj["salesman_phone"] = qobj.clerkPhone;
}
return await this.create(obj,t);
}
}
module.exports = SchemeDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class SettlebillDao extends Dao {
constructor() {
super(Dao.getModelName(SettlebillDao));
}
extraWhere(qobj, qw, qc) {//根据业务员id获取交付单信息的组装条件
//qc.raw = true;
//检查查询的用户所属公司是否是平台运营公司-1,如果是则不添加公司查询条件, 不添加路径条件,返回所有数据
if (qobj.company_id == 1) {
return qw
} else {
//需要添加公司查询条件
qw["facilitator_id"] = Number(qobj.company_id)
}
return qw;
}
}
module.exports = SettlebillDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class StatuslogDao extends Dao {
constructor() {
super(Dao.getModelName(StatuslogDao));
}
/*插入状态信息信息*/
async insertInfo(qobj,t){
var obj = {
"flow_type":qobj.flowType,
"flow_id":qobj.flowId,
"status_code":qobj.statusCode
};
if (qobj.statusReason && qobj.statusReason != 'undefined'){
obj.status_reason = qobj.statusReason;
}
else{
obj.status_reason = "";
}
if (qobj.clerkName && qobj.clerkName != 'undefined'){
obj.salesman_name = qobj.clerkName;
}
if (qobj.clerkId && qobj.clerkId != 'undefined'){
obj.salesman_id = qobj.clerkId;
}
return await this.create(obj,t);
}
}
module.exports = StatuslogDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class AppDao extends Dao{
constructor(){
super(Dao.getModelName(AppDao));
}
extraWhere(obj,w,qc,linkAttrs){
if(obj.bizpath && obj.bizpath!=""){
if(obj.bizpath.indexOf("my_app")>0){//说明是租户查询自己创建的应用
w["creator_id"]=obj.userid;
}
}
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;
}
}
module.exports=AppDao;
// 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 Sequelize = require('sequelize');
const settings = require("../../../../config/settings")
const Op = Sequelize.Op
const fs = require("fs")
const path = require("path");
var glob = require("glob");
......@@ -10,47 +9,9 @@ class DbFactory {
this.db = new Sequelize(dbConfig.dbname,
dbConfig.user,
dbConfig.password,
{
...dbConfig.config,
operatorsAliases: {
$eq: Op.eq,
$ne: Op.ne,
$gte: Op.gte,
$gt: Op.gt,
$lte: Op.lte,
$lt: Op.lt,
$not: Op.not,
$in: Op.in,
$notIn: Op.notIn,
$is: Op.is,
$like: Op.like,
$notLike: Op.notLike,
$iLike: Op.iLike,
$notILike: Op.notILike,
$regexp: Op.regexp,
$notRegexp: Op.notRegexp,
$iRegexp: Op.iRegexp,
$notIRegexp: Op.notIRegexp,
$between: Op.between,
$notBetween: Op.notBetween,
$overlap: Op.overlap,
$contains: Op.contains,
$contained: Op.contained,
$adjacent: Op.adjacent,
$strictLeft: Op.strictLeft,
$strictRight: Op.strictRight,
$noExtendRight: Op.noExtendRight,
$noExtendLeft: Op.noExtendLeft,
$and: Op.and,
$or: Op.or,
$any: Op.any,
$all: Op.all,
$values: Op.values,
$col: Op.col
}
});
dbConfig.config);
this.db.Sequelize = Sequelize;
this.db.Op = Op;
this.db.Op = Sequelize.Op;
this.initModels();
this.initRelations();
}
......@@ -66,8 +27,49 @@ class DbFactory {
console.log("init models....");
}
async initRelations() {
this.db.models.dataauth.belongsTo(this.db.models.user, { constraints: false, });
/*建立用户和角色之间的关系*/
this.db.models.user.belongsToMany(this.db.models.role, { as: "Roles", through: 'p_userrole', constraints: false, });
this.db.models.role.belongsToMany(this.db.models.user, { as: "Users", through: 'p_userrole', constraints: false, });
/*组织机构自引用*/
//this.db.models.org.belongsTo(this.db.models.org,{constraints: false,});
//this.db.models.org.hasMany(this.db.models.org,{constraints: false,});
//组织机构和角色是多对多关系,建立兼职岗位,给岗位赋予多个角色,从而同步修改用户的角色
//通过岗位接口去修改用户的角色
//this.db.models.role.belongsToMany(this.db.models.org,{through: this.db.models.orgrole,constraints: false,});
//this.db.models.org.belongsToMany(this.db.models.role,{through: this.db.models.orgrole,constraints: false,});
//组织机构和用户是1对多,
// this.db.models.user.belongsTo(this.db.models.org,{constraints: false,});
// this.db.models.org.hasMany(this.db.models.user,{constraints: false,});
this.db.models.user.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.role.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.company, { constraints: false, });
this.db.models.auth.belongsTo(this.db.models.role, { constraints: false, });
this.db.models.app.belongsTo(this.db.models.user, { as: "creator", constraints: false, });
this.db.models.user.belongsTo(this.db.models.company, { constraints: false, });
this.db.models.role.belongsTo(this.db.models.company, { constraints: false, });
// this.db.models.org.belongsTo(this.db.models.company,{constraints: false,});
this.db.models.route.belongsTo(this.db.models.app, { constraints: false, });
this.db.models.plugin.belongsTo(this.db.models.app, { constraints: false, });
// 商机表 1:1 方案表
this.db.models.scheme.belongsTo(this.db.models.bizopt, { constraints: false, });
this.db.models.bizopt.hasOne(this.db.models.scheme, { constraints: false, });
//交付单关联结算单deliverybill
this.db.models.deliverybill.belongsTo(this.db.models.settlebill, { constraints: false, });
this.db.models.settlebill.hasMany(this.db.models.deliverybill,{as:"dbs",constraints: false,});
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon() {
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class MsgHistoryDao extends Dao{
constructor(){
super(Dao.getModelName(MsgHistoryDao));
}
extraWhere(obj,w){
if(obj.ukstr && obj.ukstr!=""){
// w={[this.db.Op.or]:[
// {[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]},
// {[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]},
// ]
// };
w[this.db.Op.or]=[
{[this.db.Op.and]:[{sender:obj.ukstr},{target:obj.extra}]},
{[this.db.Op.and]:[{sender:obj.extra},{target:obj.ukstr}]},
];
}
return w;
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]];
}
}
module.exports=MsgHistoryDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class MsgNoticeDao extends Dao{
constructor(){
super(Dao.getModelName(MsgNoticeDao));
}
async saveNotice(msg, t) {
var noticeFrom = await super.findOne({fromId : msg.senderId, toId : msg.targetId});
if(noticeFrom) {
var set = {lastMsgId:msg.id};
if(msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id;
}
await super.updateByWhere(set, {where:{id:noticeFrom.id}}, t);
} else {
noticeFrom = {
fromuser: msg.sender,
fromId:msg.senderId,
touser: msg.target,
toId:msg.targetId,
isAccepted:true,
lastMsgId:msg.id,
businessLicense_id : msg.businessLicense_id || 0
};
await super.create(noticeFrom, t);
}
var noticeTo = await super.findOne({fromId : msg.targetId, toId : msg.senderId});
if(noticeTo) {
var set = {lastMsgId:msg.id};
if(msg.businessLicense_id) {
set.businessLicense_id = msg.businessLicense_id;
}
await super.updateByWhere(set, {where:{id:noticeTo.id}}, t);
} else {
noticeTo = {
fromuser: msg.target,
fromId:msg.targetId,
touser: msg.sender,
toId:msg.senderId,
isAccepted:true,
lastMsgId:msg.id,
businessLicense_id : msg.businessLicense_id || 0
};
await super.create(noticeTo, t);
}
}
orderBy(){
//return {"key":"include","value":{model:this.db.models.app}};
return [["id","DESC"]];
}
}
module.exports=MsgNoticeDao;
module.exports = (db, DataTypes) => {
return db.define("auth", {
rolecode: DataTypes.STRING,
bizcode: DataTypes.STRING,
codepath: DataTypes.STRING,
authstrs: DataTypes.STRING
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_auths',
validate: {
}
});
}
module.exports = (db, DataTypes) => {
return db.define("dataauth", {
modelname: DataTypes.STRING,
auths: DataTypes.STRING,
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_dataauths',
validate: {
}
});
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("org", {
code: {
type:DataTypes.STRING(64),
allowNull: false,
},
name: {
type:DataTypes.STRING(64),
allowNull: false,
},
isLeaf:{
type:DataTypes.BOOLEAN,
defaultValue: true
},
orgpath: {
type:DataTypes.STRING,
allowNull: false,
},
nodeType: {//默认为组织
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(appconfig.pdict.node_type),
defaultValue:'org'
},
isPosition:{//是否是岗位
type:DataTypes.BOOLEAN,
defaultValue: false
},
isMain:{//是否是主岗
type:DataTypes.BOOLEAN,
defaultValue: false
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_org',
validate: {
}
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("orgrole", {
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'p_orgrole',
validate: {
},
});
}
\ No newline at end of file
module.exports = (db, DataTypes) => {
return db.define("role", {
name: DataTypes.STRING,
code: DataTypes.STRING,
description: DataTypes.STRING,
isSystem: {//是否系统数据,0否,1是
type: DataTypes.BOOLEAN,
defaultValue: false,
},
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_role',
validate: {
}
});
}
const system=require("../../../system");
const settings=require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("user", {
userName: {
type:DataTypes.STRING,
allowNull: false,
},
password: {
type:DataTypes.STRING,
allowNull: false,
},
nickName: {
type:DataTypes.STRING,
allowNull: true,
},
sex: {
type:DataTypes.ENUM,
allowNull: true,
values: Object.keys(appconfig.pdict.sex),
},
mobile:DataTypes.STRING,
mail: {
type:DataTypes.STRING,
allowNull: true,
},
headUrl: DataTypes.STRING,
isAdmin:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
isSuper:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
isSystem:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
center_id:DataTypes.STRING,
jwtkey:DataTypes.STRING,
jwtsecret:DataTypes.STRING,
isEnabled:{
type:DataTypes.BOOLEAN,
defaultValue: true
},
opath:DataTypes.STRING,//作业务时,需要在业务表冗余当前处理人的opath
ptags:DataTypes.STRING,//权限标签,逗号分隔,可以按照标签查看opath中含有标签的数据
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_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 appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("app", {
appkey:{
type: DataTypes.STRING,
allowNull: true,
},
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
domainName: DataTypes.STRING,//域名
backend:DataTypes.STRING,//域名
homePage: DataTypes.STRING,//首页
functionJSON: DataTypes.TEXT,//功能清单地址--前端通过loadJson下载数据
docUrl: DataTypes.STRING,//前端路由配置文件
configUrl: DataTypes.STRING,//基础信息配置信息地址
logoUrl: DataTypes.STRING,//应用Logo
bkimageUrl: DataTypes.STRING,//应用背景图
showimgUrl: DataTypes.STRING,//应用显示图标
detailimgUrl: DataTypes.STRING,//应用详情介绍地址
opCacheUrl: DataTypes.STRING,//操作缓存地址
description: DataTypes.STRING,//应用描述
isSystem: {
type: DataTypes.BOOLEAN,
defaultValue: false
},//是否启用
isEnabled: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否启用
isPublish: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},//是否对外
appType: {
type: DataTypes.ENUM,
allowNull: true,
values: Object.keys(appconfig.pdict.app_type),
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_app',
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 appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("company", {
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
companykey: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from
address: {
type: DataTypes.STRING,
allowNull: true,
},//和user的from
mail: {
type: DataTypes.STRING,
allowNull: true,
},//和user的from
phone: {
type: DataTypes.STRING,
allowNull: true,
},
licenseUrl: {
type: DataTypes.STRING,
allowNull: true,
},
orgJson: DataTypes.TEXT,//功能清
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_company',
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 appconfig = system.getSysConfig();
/**
* 模板信息表
*/
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
//TODO:
return db.define("templateinfo", {
code: DataTypes.STRING,
name: DataTypes.STRING,
title: DataTypes.STRING,
keyword: DataTypes.STRING,
describe: DataTypes.STRING,
pic_url: DataTypes.STRING,
is_enabled: DataTypes.INTEGER,
template_content: DataTypes.JSON,
form_id: DataTypes.INTEGER,
notes: DataTypes.STRING,
user_id: DataTypes.STRING(100),
user_name: DataTypes.STRING(100), //user_name 用户名称
company_id: DataTypes.INTEGER,
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'b_template_info',
validate: {
return db.define("plugin", {
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_plugin',
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}]
// }
]
},
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 appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("route", {
name: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
center_id: {
type: DataTypes.STRING,
allowNull: false,
},//和user的from相同,在注册user时,去创建
shosts:{
type: DataTypes.STRING,
allowNull: false,
},
spaths:{
type: DataTypes.STRING,
allowNull: false,
}
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'p_route',
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 appconfig = system.getSysConfig();
/**
* 商机表
*/
module.exports = (db, DataTypes) => {
return db.define("bizopt", {
demand_code: { // 需求编码
allowNull: false,
type: DataTypes.STRING
},
business_type: { // 商机类型
allowNull: false,
type: DataTypes.STRING
},
business_status: { // 商机状态
allowNull: false,
type: DataTypes.STRING
},
business_info: { // 商机详情
allowNull: false,
type: DataTypes.JSON
},
v_coname: { // 联系人-虚拟字段
allowNull: true,
type: DataTypes.STRING
},
v_cophone: { // 联系电话-虚拟字段
allowNull: true,
type: DataTypes.STRING
},
source_number: { // 来源单号 (下单时产生的编号)
allowNull: true,
type: DataTypes.STRING
},
source_name: { //渠道来源
allowNull: true,
type: DataTypes.STRING
},
service_address: { // 区域地址
allowNull: false,
type: DataTypes.STRING
},
close_reason: { // 关闭理由
allowNull: true,
type: DataTypes.STRING
},
facilitator_id: { // 服务商id
allowNull: true,
type: DataTypes.STRING
},
facilitator_name: { // 服务商名称
allowNull: true,
type: DataTypes.STRING
},
salesman_opcode: { // 组织架构路径
allowNull: true,
type: DataTypes.STRING
},
salesman_id: {// 业务员id
allowNull: true,
type: DataTypes.STRING
},
salesman_name: { // 业务员姓名
allowNull: true,
type: DataTypes.STRING
},
salesman_phone: { // 业务员联系方式
allowNull: true,
type: DataTypes.STRING
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'bussiness_opportunity',
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}]
// }
]
});
}
......@@ -2,65 +2,60 @@ const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 表单信息
* 交付信息缓存
*/
module.exports = (db, DataTypes) => {
return db.define("imginfo", {
code: {
allowNull: false,
type: DataTypes.STRING
},
name: {
allowNull: false,
type: DataTypes.STRING
},
pic_url: {
allowNull: false,
type: DataTypes.STRING
}
return db.define("cacheinfo", {
deliver_id: { // 交付单id
allowNull: false,
type: DataTypes.STRING
},
cache_info: { // 缓存信息
allowNull: false,
type: DataTypes.JSON
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'cache_information',
validate: {
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_picture_warehouse',
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}]
// }
]
});
},
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 appconfig = system.getSysConfig();
/**
* 交付单表
*/
module.exports = (db, DataTypes) => {
return db.define("deliverybill", {
delivery_code: { //交付单编号
allowNull: true,
type: DataTypes.STRING
},
source_number: { // 来源单号
allowNull: true,
type: DataTypes.STRING
},
source_name: { // 渠道名称
allowNull: true,
type: DataTypes.STRING
},
pay_status: { // 交付状态-虚拟字段
allowNull: true,
type: DataTypes.STRING
},
v_coname: { // 联系人-虚拟字段
allowNull: true,
type: DataTypes.STRING
},
v_cophone: { // 联系电话-虚拟字段
allowNull: true,
type: DataTypes.STRING
},
demand_code: {// 商机编号
allowNull: true,
type: DataTypes.STRING
},
sku_code: {// sku编码
allowNull: true,
type: DataTypes.STRING
},
scheme_number: {// 方案编号
allowNull: true,
type: DataTypes.STRING
},
product_code: { // 产品编码
allowNull: false,
type: DataTypes.STRING
},
product_name: { // 产品名称
allowNull: false,
type: DataTypes.STRING
},
service_address: { // 区域地址
allowNull: false,
type: DataTypes.STRING
},
delivery_info: { //服务概况
allowNull: false,
type: DataTypes.JSON
},
delivery_status: {// 服务单流转状态
allowNull: false,
type: DataTypes.STRING
},
master_source_number:{//主订单号
allowNull: false,
type: DataTypes.STRING
},
settle_status: {// 服务单流转状态
allowNull: false,
type: DataTypes.STRING,
defaultValue:'waittosettle'
},
selling_price: {//售价
allowNull: false,
type: DataTypes.INTEGER
},
cost_price: {//成本价
allowNull: true,
type: DataTypes.INTEGER
},
close_reason: {//关闭理由
allowNull: true,
type: DataTypes.STRING
},
facilitator_id: { // 服务商id
allowNull: true,
type: DataTypes.STRING
},
facilitator_name: { // 服务商名称
allowNull: true,
type: DataTypes.STRING
},
salesman_opcode: { // 组织架构路径
allowNull: true,
type: DataTypes.STRING
},
salesman_id: {// 业务员id
allowNull: true,
type: DataTypes.STRING
},
salesman_name: { // 业务员姓名
allowNull: true,
type: DataTypes.STRING
},
salesman_phone: { // 业务员联系方式
allowNull: true,
type: DataTypes.STRING
},
delivery_man_id: {// 交付员id
allowNull: true,
type: DataTypes.STRING
},
delivery_man_name: {// 交付员姓名
allowNull: true,
type: DataTypes.STRING
},
delivery_man_opcode: {// 交付员opcode
allowNull: true,
type: DataTypes.STRING
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'delivery_bill',
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 moment = require('moment');
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 材料信息表
*/
module.exports = (db, DataTypes) => {
return db.define("material", {
delivery_id: { // 交付单id
allowNull: true,
type: DataTypes.INTEGER
},
delivery_code: { // 交付单编号
allowNull: true,
type: DataTypes.STRING
},
company_info: { // 企业信息
allowNull: true,
type: DataTypes.JSON
},
registered_info: { // 注册资本信息
allowNull: true,
type: DataTypes.JSON
},
contribution_info: { // 出资比例信息
allowNull: true,
type: DataTypes.JSON
},
position_info: { // 任职信息
allowNull: true,
type: DataTypes.JSON
},
file_info: { // 注册文件信息
allowNull: true,
type: DataTypes.JSON
},
express_info: { // 邮寄信息
allowNull: true,
type: DataTypes.JSON
},
is_download: { // 是否已有压缩文件的路径
allowNull: true,
type: DataTypes.INTEGER
},
download_url: { // 压缩文件的路径
allowNull: true,
type: DataTypes.STRING
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'material_information',
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 moment = require('moment');
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 方案表
*/
module.exports = (db, DataTypes) => {
return db.define("salesmanhis", {
flow_type: { // 流程类型(商机、方案、交付单)
allowNull: false,
type: DataTypes.STRING
},
flow_id: { //流程对应id(各种表里对应的id)
allowNull: false,
type: DataTypes.STRING
},
flow_code: {//类型的编号
allowNull: false,
type: DataTypes.STRING
},
salesman_info: {//业务员信息
allowNull: false,
type: DataTypes.JSON
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'salesman_his',
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 moment = require('moment');
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 方案表
*/
module.exports = (db, DataTypes) => {
return db.define("scheme", {
demand_code: { // 需求编码
allowNull: false,
type: DataTypes.STRING
},
scheme_number: { //方案编号
allowNull: true,
type: DataTypes.STRING
},
scheme_info: {//方案详情
allowNull: false,
type: DataTypes.JSON
},
scheme_status: { //方案状态
allowNull: false,
type: DataTypes.STRING
},
reject_reason: {//驳回理由
allowNull: true,
type: DataTypes.STRING
},
remark_info: { //备注
allowNull: true,
type: DataTypes.STRING
},
bizopt_id: { //商机id
allowNull: true,
type: DataTypes.STRING
},
facilitator_id: { //服务商id
allowNull: true,
type: DataTypes.STRING
},
facilitator_name: { //服务商名称
allowNull: true,
type: DataTypes.STRING
},
salesman_opcode: { //组织架构路径
allowNull: true,
type: DataTypes.STRING
},
salesman_id: { //业务员id
allowNull: true,
type: DataTypes.STRING
},
salesman_name: { //业务员名称
allowNull: true,
type: DataTypes.STRING
},
salesman_phone: { //业务员联系方式
allowNull: true,
type: DataTypes.STRING
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'scheme_information',
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 appconfig = system.getSysConfig();
/**
* 交付单表
*/
module.exports = (db, DataTypes) => {
return db.define("settlebill", {
code: { //交付单编号
allowNull: true,
type: DataTypes.STRING
},
auditedStatus: {// 审核状态
type:DataTypes.BOOLEAN,
defaultValue: false
},
settle_amount: {//结算金额
allowNull: true,
type: DataTypes.INTEGER
},
isPayedStatus:{
type:DataTypes.BOOLEAN,
defaultValue: false
},
memo:{//结算建议
allowNull: true,
type:DataTypes.STRING,
},
creator_id:{//申请人
allowNull: true,
type: DataTypes.INTEGER
},
creator:{
allowNull: true,
type: DataTypes.STRING,
},
auditor_id:{//审核人
allowNull: true,
type: DataTypes.INTEGER
},
auditor:{//审核人
allowNull: true,
type: DataTypes.STRING,
},
payer_id:{//付款人
allowNull: true,
type: DataTypes.INTEGER
},
payer:{
allowNull: true,
type: DataTypes.STRING,
},
facilitator_id:{
allowNull: true,
type: DataTypes.INTEGER,
},
facilitator_name:{
allowNull: true,
type: DataTypes.STRING,
},
}, {
paranoid: true,//真的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'fi_settlebill',
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 appconfig = system.getSysConfig();
/**
* 状态流转记录表
*/
module.exports = (db, DataTypes) => {
return db.define("statuslog", {
flow_type: { // 流程类型 (商机、方案、交付单)
allowNull: false,
type: DataTypes.STRING
},
flow_id: { // 流程对应id
allowNull: false,
type: DataTypes.STRING
},
status_reason: { // 状态原因
allowNull: true,
type: DataTypes.STRING
},
status_code: { // 流转状态
allowNull: false,
type: DataTypes.STRING
},
salesman_id: {// 业务员id
allowNull: true,
type: DataTypes.STRING
},
salesman_name: { // 业务员姓名
allowNull: true,
type: DataTypes.STRING
}
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'status_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}]
// }
]
});
}
/**
* 业务类型表
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("businesstype", {
p_id: DataTypes.INTEGER(11),//产品一类id
code: DataTypes.STRING(100),//渠道编码
name: DataTypes.STRING(100),//渠道名称
notes: DataTypes.STRING(255),//备注
user_id: DataTypes.INTEGER(11),//创建用户id
user_name: DataTypes.STRING(60),//创建用户名称
company_id: DataTypes.INTEGER(11)
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updated_at: true,
tableName: 'c_launch_channel',
validate: {},
indexes: []
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
/**
* 表单信息表
*/
module.exports = (db, DataTypes) => {
return db.define("forminfo", {
code: {
allowNull: false,
type: DataTypes.STRING
},
name: {
allowNull: false,
type: DataTypes.STRING
},
form_items: {
allowNull: true,
type: DataTypes.STRING
},
form_describe: {
allowNull: true,
type: DataTypes.STRING
},
notes: {
allowNull: true,
type: DataTypes.STRING
},
user_id: DataTypes.STRING(100),
user_name: DataTypes.STRING(100), //user_name 用户名称
company_id: DataTypes.INTEGER(11) //user_name 用户名称
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'c_form_info',
validate: {},
indexes: [
]
});
}
/**
* 表单信息表
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("formitem", {
form_id: {//表单id
allowNull: false,
type: DataTypes.INTEGER
},
code: {//表单编码
allowNull: false,
type: DataTypes.STRING
},
name: {//表单名称
allowNull: false,
type: DataTypes.STRING
},
item_type: {//表单类型
allowNull: false,
type: DataTypes.STRING
},
item_type_name: {//表单类型名称
allowNull: false,
type: DataTypes.STRING
},
config_params: {//表单配置参数
allowNull: false,
type: DataTypes.JSON
},
is_enableed: {//显示状态
allowNull: false,
type: DataTypes.INTEGER
},
is_required: {//是否必填
allowNull: false,
type: DataTypes.INTEGER
},
sequence: {//次序
allowNull: false,
type: DataTypes.INTEGER
},
notes: {//备注
allowNull: false,
type: DataTypes.STRING()
},
company_id: DataTypes.INTEGER(11)
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
tableName: 'c_form_item',
validate: {},
indexes: []
});
}
/**
* 表单提交记录表
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("formsubmitrecord", {
form_id:DataTypes.INTEGER(11),//表单id
record_status:DataTypes.STRING(60),//记录状态 1未读 2已读 3无效
record_status_name:DataTypes.STRING(60),//记录状态名称
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updated_at: true,
tableName: 'c_form_submit_record',
validate: {
},
indexes: [
]
});
}
/**
* 投放渠道信息表
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("launchchannel", {
code: DataTypes.STRING(100),//表单编码
name: DataTypes.STRING(100),//表单名称
notes: DataTypes.STRING(255),//备注
user_id: DataTypes.INTEGER(11),//创建用户id
user_name: DataTypes.STRING(60),//创建用户名称
company_id: DataTypes.INTEGER(11)
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updated_at: true,
tableName: 'c_launch_channel',
validate: {},
indexes: []
});
}
/**
* 投放渠道信息表
* @param db
* @param DataTypes
* @returns {Model|void|*}
*/
module.exports = (db, DataTypes) => {
return db.define("launchtype", {
code: DataTypes.STRING(100),//表单编码
name: DataTypes.STRING(100),//表单名称
notes: DataTypes.STRING(255),//备注
user_id: DataTypes.INTEGER(11),//创建用户id
user_name: DataTypes.STRING(60),//创建用户名称
company_id: DataTypes.INTEGER(11)
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updated_at: true,
tableName: 'c_launch_type',
validate: {},
indexes: []
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const appconfig=system.getSysConfig();
module.exports = (db, DataTypes) => {
return db.define("msghistory", {
msgType:{
type:DataTypes.ENUM,
allowNull: false,
values: Object.keys(appconfig.pdict.msgType),
},
app_id:DataTypes.INTEGER,
company_id:DataTypes.INTEGER,
sender:DataTypes.STRING,
senderId:DataTypes.INTEGER,
target:DataTypes.STRING,
targetId:DataTypes.INTEGER,
content: {
type: DataTypes.TEXT('long'),
allowNull: false,
},//需要在后台补充
isRead:{
type:DataTypes.BOOLEAN,
defaultValue: false,
}
},{
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'msghistory',
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("msgnotice", {
fromuser: DataTypes.STRING,//需要在后台补充
fromId:DataTypes.INTEGER,
touser: DataTypes.STRING,//需要在后台补充
toId:DataTypes.INTEGER,
isAccepted:DataTypes.BOOLEAN,
lastMsgId:DataTypes.INTEGER
},{
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'msgnotice',
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 ServiceBase=require("../../sve.base");
class AccountService extends ServiceBase{
constructor(){
super("auth",ServiceBase.getDaoName(AccountService));
//this.appDao=system.getObject("db.appDao");
}
}
module.exports=AccountService;
const system=require("../../../system");
const ServiceBase=require("../../sve.base");
class AuthService extends ServiceBase{
constructor(){
super("auth",ServiceBase.getDaoName(AuthService));
}
//字符串数组参数
//前端角色查询,按照来源应用和来源公司查询
async findAuthsByRole(roleids,appid,comid){
//{where:{id:{[this.db.Op.in]:ids}}}
//var newattrs=rolecodestr.split(",");
var aths=await this.dao.model.findAll({
attributes:["bizcode","authstrs","codepath"],
where:{role_id:{[this.db.Op.in]:roleids},app_id:appid,company_id:comid}});
return aths;
}
async saveAuths(auths,appid,cmid){
//先按照code 和 bizcode查询
var self=this;
console.log("yyyyyyyyyvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
console.log(auths);
return self.db.transaction(async function (t){
for(var i=0;i<auths.length;i++){
var tmpAuth=auths[i];
tmpAuth.app_id=appid;
tmpAuth.company_id=cmid;
var objrtn=await self.dao.model.findOrCreate({
defaults:tmpAuth,
where:{role_id:tmpAuth.role_id,bizcode:tmpAuth.bizcode},//注意这里bizcode存储的是节点的code值
transaction:t,
});
console.log("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
console.log(objrtn);
if(!objrtn[1].created){
//就执行更新操作
await objrtn[0].update(tmpAuth,{where:{role_id:tmpAuth.role_id,bizcode:tmpAuth.bizcode},transaction:t})
}
}
var aths=await self.dao.model.findAll({where:{role_id:tmpAuth.role_id,app_id:tmpAuth.app_id},transaction:t});
return aths;
});
}
}
module.exports=AuthService;
const system=require("../../../system");
const ServiceBase=require("../../sve.base")
const settings=require("../../../../config/settings")
class DataauthService extends ServiceBase{
constructor(){
super("auth",ServiceBase.getDaoName(DataauthService));
}
async saveauth(obj){
//先按照uid,modelname,检查是否存在,不存在创建,存在更新
var oldauth= await this.dao.findOne({user_id:obj.user_id,modelname:obj.modelname,app_id:obj.add_id});
if(!oldauth){
return this.dao.create(obj);
}else{
obj.id=oldauth.id;
return this.dao.update(obj);
}
}
}
module.exports=DataauthService;
const system=require("../../../system");
const ServiceBase=require("../../sve.base");
class OrgService extends ServiceBase{
constructor(){
super("auth",ServiceBase.getDaoName(OrgService));
}
async delete(p,q,req){
var self=this;
var orgid=p.id;
var uone=await this.db.models.user.findOne({where:{org_id:orgid}});
if(!uone){
//先检查是否组织下有人员存在
return this.db.transaction(async function (t) {
var inst=await self.dao.model.findById(orgid);
var parentid=inst.org_id;
await inst.destroy({force:true,transaction:t});
//删除组织对应的角色
self.db.models.orgrole.destroy({where:{org_id:orgid},force:true,transaction:t});
//查询出父元素
var orgparent=await self.dao.model.findOne({
order:[["code","ASC"]],
where:{id:parentid},transaction:t,
include:[
{model:self.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:self.db.models.org,as:"orgs",order:[["code","ASC"]]}
]}
]});
return orgparent.orgs;
});
}else{
return null;
}
}
async update(p,q,req){
var self=this;
var cmkey=p.comkey;//如果是来自租户界面的修改
return this.db.transaction(async function (t) {
p.isLeaf=p.isPosition;
var orgupdate=await self.dao.model.findOne({where:{id:p.id},transaction:t});
await self.dao.model.update(p,{where:{id:p.id},transaction:t});
var usersupdate=await self.db.models.user.findAll({where:{org_id:orgupdate.id}});
//如果节点名称或岗位性质发生变化
//if(p.name!=orgupdate.name || p.isMain!=orgupdate.isMain){
for(var ud of usersupdate){
ud.opath=p.orgpath;
var n=p.orgpath.lastIndexOf("/");
ud.ppath=p.isMain?p.orgpath.substring(0,n):p.orgpath;
await ud.save({transaction:t});
}
//}
if(p.Roles && !cmkey){//如果不是来自租户界面的修改
var roles=await self.db.models.role.findAll({where:{id:{[self.db.Op.in]:p.Roles}}});
await orgupdate.setRoles(roles,{transaction:t});
//同时要给这个岗位下的user,更新角色 todo
for(var ud of usersupdate){
await ud.setRoles(roles,{transaction:t});
}
}
var orgparent=await self.dao.model.findOne({
order:[["code","ASC"]],
where:{id:orgupdate.org_id},transaction:t,
include:[
{model:self.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:self.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]});
return orgparent.orgs;
});
}
async checkMainPosition(p,q,req){
var orgmain=await this.dao.model.findOne({where:{org_id:p.org_id,isMain:true}});
if(orgmain){
return {"isHave":true};
}else{
return null;
}
}
async changePos(toorgid,uid){
//查询出当前用户,设置当前用户的orgid为修改目标
var self=this;
return this.db.transaction(async function (t) {
var ufind=await self.db.models.user.findById(uid);
var org=await self.dao.model.findOne({
where:{id:toorgid},
include:[
{model:self.db.models.role,as:"roles"},
]});
ufind.org_id=toorgid;
ufind.opath=org.orgpath;
if(org.isMain){//如果是主岗
var n=org.orgpath.lastIndexOf("/");
ufind.ppath=org.orgpath.substring(0,n);
}else{
ufind.ppath= org.orgpath;
}
await ufind.save({transaction:t});
await ufind.setRoles(org.roles,{transaction:t});
return ufind;
});
//查询出目标org,关联查询出角色
//设置当前用户的角色
}
async create(p,q,req){
var self=this;
var cmkey=p.comkey;
return this.db.transaction(async function (t) {
if(cmkey){
var tmpcompany =await self.db.models.company.findOne({where:{companykey:cmkey},transaction:t});
p.company_id=tmpcompany.id;
}
var roles=await self.db.models.role.findAll({where:{id:{[self.db.Op.in]:p.Roles}}});
p.isLeaf=p.isPosition;
p.app_id=null;
var orgnew=await self.dao.model.create(p,{transaction:t});
if(roles && roles.length>0){
await orgnew.setRoles(roles,{transaction:t});
}
var orgparent=await self.dao.model.findOne({
order:[["code","ASC"]],
where:{id:orgnew.org_id},transaction:t,
include:[
{model:self.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:self.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]});
return orgparent.orgs;
});
}
async findOrgById(id){
var org=await this.dao.model.findOne({
order:[["code","ASC"]],
where:{id:id},
include:[
{model:this.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:this.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:this.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:this.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:this.db.models.role,as:"roles",attributes:['id','code','name']},
]});
return org.orgs;
}
async initOrgs(company,appid){
var self=this;
return this.db.transaction(async function (t) {
var org=await self.dao.model.findOne({
order:[["code","ASC"]],
//where:{name:company.name,company_id:company.id,app_id:appid},transaction:t,
where:{name:company.name,company_id:company.id},transaction:t,
include:[
{model:self.db.models.org,as:"orgs", order:[["code","ASC"]],include:[
{model:self.db.models.org,as:"orgs",order:[["code","ASC"]],include:[
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]},
{model:self.db.models.role,as:"roles",attributes:['id','code','name']},
]});
if(org!=null){
return org;
}else{
var root= await self.dao.model.create({
code:"root"+company.id,
name:company.name,
isLeaf:false,
isPostion:false,
isMain:false,
orgpath:"/",
company_id:company.id,
app_id:null,
},{transaction:t});
return root;
}
});
}
}
module.exports=OrgService;
const system=require("../../../system");
const ServiceBase=require("../../sve.base");
class RoleService extends ServiceBase{
constructor(){
super("auth",ServiceBase.getDaoName(RoleService));
//this.appDao=system.getObject("db.appDao");
}
async findOneByCode(code){
return this.dao.model.findOne({where:{code:code}});
}
}
module.exports=RoleService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class SchemeService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(SchemeService));
}
async findById(qobj){//根据id获取方案信息
var oid = qobj.id;
return await this.dao.findById(oid);
}
async findInfoByDemandCode(qobj){//根据方案编号获取方案详情
return await this.dao.findInfoByDemandCode(qobj);
}
async updateStatusByDemandCode(qobj){//根据商机编号号更新方案状态及原因
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.updateStatusByDemandCode(qobj,t);
});
}
async updateInfoByDemandCode(qobj){//根据商机编号更新方案详情
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateInfoByDemandCode(qobj,t);
});
}
async updateSchemeNumberByDemandCode(qobj){//根据商机编号更新方案编号
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateSchemeNumberByDemandCode(qobj,t);
});
}
async insertInfo(qobj){//插入方案信息
var self = this;
return await self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
}
module.exports = SchemeService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class BizOptService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(BizOptService));
}
async statBizChanceCountBySp(bizStatus, betweenTime) {
let params = {}
params.group = {
byFields: ['facilitator_name'],
actionType: 'count',
aggField: 'id',
aliasField: ' as chanceCount',
tblName: 'bussiness_opportunity',
where: bizStatus != "" ? `where business_status='${bizStatus}'` : '',
having: '',
}
if (betweenTime.length > 0) {
params.group.where = `${params.group.where} ${params.group.where ? 'AND' : "WHERE"} (created_at BETWEEN '${betweenTime[0]}' AND '${betweenTime[1]}')`
}
let s = await this.dao.statGroupBy(params, null)
return s
}
/**
* 公司id,平台公司ID为1
* @param {*} companyId
* @param {*} opath
* @param {*} username
* @param {*} userid
*/
async statBizChance(companyId, opath, username, userid, betweenTime) {
// 时间 筛选
let andWhere = [];
if (betweenTime.length > 0) {
andWhere.push({
"created_at": { [this.db.Op.between]: betweenTime }
})
}
//如果当前登录人是平台,返回所有商机
let waittoHandledCount = 0
let handlingCount = 0
let finishedCount = 0
let closedCount = 0
if (companyId == 1) {
waittoHandledCount = await this.dao.findCount({ where: { business_status: 'beforeSubmission', [this.db.Op.and]: andWhere } })
handlingCount = await this.dao.findCount({ where: { business_status: 'beforeConfirmation', [this.db.Op.and]: andWhere } })
finishedCount = await this.dao.findCount({ where: { business_status: 'isFinished', [this.db.Op.and]: andWhere } })
closedCount = await this.dao.findCount({ where: { business_status: 'isClosed', [this.db.Op.and]: andWhere } })
} else {
let opathstr = ''
if (opath) {
opathstr = opath
waittoHandledCount = await this.dao.findCount({ where: { business_status: 'beforeSubmission', salesman_opcode: { [this.db.Op.like]: `%${opathstr}%` }, 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
handlingCount = await this.dao.findCount({ where: { business_status: 'beforeConfirmation', salesman_opcode: { [this.db.Op.like]: `%${opathstr}%` }, 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
finishedCount = await this.dao.findCount({ where: { business_status: 'isFinished', salesman_opcode: { [this.db.Op.like]: `%${opathstr}%` }, 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
closedCount = await this.dao.findCount({ where: { business_status: 'isClosed', salesman_opcode: { [this.db.Op.like]: `%${opathstr}%` }, 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
} else {
waittoHandledCount = await this.dao.findCount({ where: { business_status: 'beforeSubmission', 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
handlingCount = await this.dao.findCount({ where: { business_status: 'beforeConfirmation', 'facilitator_id': companyId, [this.db.Op.and]: andWhere } })
finishedCount = await this.dao.findCount({ where: { business_status: 'isFinished', 'facilitator_id': companyId }, [this.db.Op.and]: andWhere })
closedCount = await this.dao.findCount({ where: { business_status: 'isClosed', 'facilitator_id': companyId }, [this.db.Op.and]: andWhere })
}
}
//成单率
let allChance = waittoHandledCount + handlingCount + finishedCount + closedCount
let successRadio = Math.ceil((finishedCount / allChance) * 100)
//如果当前登录人不是平台,那么需要按照opath查询
return { waittoHandledCount: waittoHandledCount, handlingCount: handlingCount, finishedCount: finishedCount, closedCount: closedCount, successRadio: successRadio }
}
async findAndCountAll(obj) {
var self = this;
const apps = await this.dao.findAndCountAll(obj);
return apps;
}
/*根据商机编号获取商机详情*/
async findInfoByDemandCode(qobj) {
return await this.dao.findInfoByDemandCode(qobj);
}
/* 根据商机编号更新商机状态 */
async updateStatusByDemandCode(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateStatusByDemandCode(qobj, t);
});
}
/*更新业务员信息*/
async updateSalesmanInfoByDemandCode(qobj){
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateSalesmanInfoByDemandCode(qobj, t);
});
}
/*插入商机信息*/
async insertInfo(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj, t);
});
}
}
module.exports = BizOptService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class CacheInfoService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(CacheInfoService));
}
// async findAndCountAll(obj) {
// var self = this;
// const apps = await this.dao.findAndCountAll(obj);
// return apps;
// }
/*根据交付单id获取缓存详情*/
async findInfoByDeliverId(qobj){
return await this.dao.findInfoByDeliverId(qobj);
}
/* 根据交付单id更新缓存信息 */
async updateInfoByDeliverId(qobj){
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.updateInfoByDeliverId(qobj,t);
});
}
/*插入缓存信息*/
async insertInfo(qobj){
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
}
module.exports = CacheInfoService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class MaterialService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(MaterialService));
}
// async findAndCountAll(obj) {
// var self = this;
// const apps = await this.dao.findAndCountAll(obj);
// return apps;
// }
/*根据交付单编号获取注册材料信息详情*/
async findInfoByDeliverNumber(qobj) {
return await this.dao.findInfoByDeliverNumber(qobj);
}
/* 根据交付单编号更新交付单编号信息 */
async updateInfoByDeliverNumber(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateInfoByDeliverNumber(qobj, t);
});
}
/* 根据id更新zip信息 */
async updateZipById(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateZipById(qobj, t);
});
}
/*获取没有压缩文件的信息*/
async findnoUrlInfo() {
var sql = "select id,file_info from material_information where is_download = 0 and file_info is not null";
var d = await this.dao.customQuery(sql);
if (d && d.length > 0) {
var rtndata = [];
d.forEach(item => {
if (item.file_info.uploadList && item.file_info.uploadList != 'undefined') {
rtndata.push({ "id": item.id, "uploadList": item.file_info.uploadList });
}
});
return rtndata;
}
else {
return [];
}
}
/*插入信息*/
async insertInfo(qobj) {
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj, t);
});
}
}
module.exports = MaterialService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class SalesmanhisService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(SalesmanhisService));
}
/*插入状态信息*/
async insertInfo(qobj){
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
}
module.exports = SalesmanhisService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class SchemeService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(SchemeService));
}
async findById(qobj){//根据id获取方案信息
var oid = qobj.id;
return await this.dao.findById(oid);
}
async findInfoByDemandCode(qobj){//根据方案编号获取方案详情
return await this.dao.findInfoByDemandCode(qobj);
}
async updateStatusByDemandCode(qobj){//根据商机编号号更新方案状态及原因
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.updateStatusByDemandCode(qobj,t);
});
}
async updateInfoByDemandCode(qobj){//根据商机编号更新方案详情
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateInfoByDemandCode(qobj,t);
});
}
async updateSchemeNumberByDemandCode(qobj){//根据商机编号更新方案编号
var self = this;
return self.db.transaction(async function (t) {
return await self.dao.updateSchemeNumberByDemandCode(qobj,t);
});
}
async insertInfo(qobj){//插入方案信息
var self = this;
return await self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
}
module.exports = SchemeService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class SettleBillService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(SettleBillService));
this.deliverbillDao=system.getObject("db.bizchance.deliverybillDao")
}
async advice(id,msg,userId,userName){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(id,{transaction:t})
st.auditor_id=userId
st.auditor=userName
st.memo=msg
await st.save({transaction:t})
return st
});
}
async auditPass(settleId,userId,userName){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(settleId,{transaction:t})
st.auditedStatus=true
st.auditor_id=userId
st.auditor=userName
await st.save({transaction:t})
return st
});
}
async pay(settleId,userId,userName){
var self=this
return this.db.transaction(async function (t){
//先按照ids查询出交付单的合计服务成本
let st=await self.dao.findById(settleId,{transaction:t})
st.isPayedStatus=true
st.payer_id=userId
st.payer=userName
await st.save({transaction:t})
//改变所有交付单的结算settle_status settled ,
await self.deliverbillDao.updateByWhere({settle_status:'settled'}, { settlebill_id: st.id }, t);
return st
});
}
async delete(p){
var self=this
return this.db.transaction(async function(t){
let dobj=await self.dao.delete(p,t)
//更新交付单上结算状态为waittosettle--待结算,清空settlebill_id
//waittosettle
await self.deliverbillDao.updateByWhere({settle_status:'waittosettle',settlebill_id:null}, { settlebill_id: dobj.id }, t);
return dobj
})
}
}
module.exports = SettleBillService;
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const appconfig = system.getSysConfig();
class StatusLogService extends ServiceBase {
constructor() {
super("bizchance", ServiceBase.getDaoName(StatusLogService));
}
/*插入状态信息*/
async insertInfo(qobj){
var self=this;
return self.db.transaction(async function (t) {
return await self.dao.insertInfo(qobj,t);
});
}
}
module.exports = StatusLogService;
\ No newline at end of file
const system=require("../../../system");
const ServiceBase=require("../../sve.base");
class ArticleService extends ServiceBase{
constructor(){
super(ServiceBase.getDaoName(ArticleService));
this.newschannelDao=system.getObject("db.newschannelDao");
}
//获取频道列表
async findChannel(obj){
// const apps=await super.findAndCountAll(obj);
var usageType = obj.usageType;
if(usageType==null||usageType==""||usageType=="undefined"){
return {code:-101,msg:"参数有误",data:null};
}
try {
var sqlwhere = {
where: {usageType:usageType},
attributes: ["id", "code", "title", "bgimg", "isPubed", "usageType", "app_id"],
order: [["orderNo", 'ASC']],
raw: true
};
var list = await this.newschannelDao.model.findAll(sqlwhere);
if (list == null || list.length == 0) {
return {code:0,msg:"没有信息",data:null};
}else {
return {code:1,msg:"操作成功",data:list};
}
}catch (e) {
return {code:-1,msg:"操作失败",data:null};
}
}
//获取该频道所有列表
async findAndCountAll2(obj){
// const apps=await super.findAndCountAll(obj);
var newschannel = obj.newschannel_id;
var pageSize=obj.page_size;
var currentPage=obj.current_page;
if(newschannel==null||newschannel==""||newschannel=="undefined"){
return {code:-101,msg:"参数有误",data:null};
}
if(pageSize==null||pageSize==""||pageSize=="undefined"){
pageSize="";
}
if(currentPage==null||currentPage==""||currentPage=="undefined"){
currentPage="";
}
try {
var sqlwhere = {
where: {newschannel_id:newschannel},
attributes: ["id","code", "title", "listimg", "videourl", "desc", "mediaType", "usageType",
"test","newschannel_id", "app_id"],
order: [["orderNo", 'ASC']],
raw: true
};
if(pageSize!=""&&currentPage!=""){
var tPageSize=Number(pageSize);
var tCurrentPage=Number(currentPage);
if(tCurrentPage<1){
tCurrentPage=1;
}
if(tPageSize>50){
tPageSize=50;
}
if(tPageSize<1){
tPageSize=1;
}
sqlwhere.limit=tPageSize;
sqlwhere.offset= (tCurrentPage - 1) * tPageSize;
}
var list = await this.dao.model.findAll(sqlwhere);
if (list == null || list.length == 0) {
return {code:0,msg:"没有信息",data:null};
}else {
return {code:1,msg:"操作成功",data:list};
}
}catch (e) {
return {code:-1,msg:"操作失败",data:null};
}
// apps.forEach(a=>{
// if(a.content && a.content!=""){
// a.content=decodeURIComponent(a.content);
// }
// });
// console.log("xxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyxxxxxxxxxxxxxxxxx");
// for(var arch of apps.rows){
// var c=arch.content.toString("utf-8") ;
// console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
// console.log(c);
// if(c && c!=""){
// arch.content=c;
// }
// }
// return apps;
}
//获取详细信息
async findArticle(obj){
// const apps=await super.findAndCountAll(obj);
var id = obj.id;
if(id==null||id==""||id=="undefined"){
return {code:-101,msg:"参数有误",data:null};
}
try {
var sqlwhere = {
where: {id:id},
attributes: ["id","code", "title", "listimg", "videourl", "desc", "content", "mediaType", "usageType",
"test", "app_id"],
order: [["created_at", 'desc']],
raw: true
};
var list = await this.dao.model.findOne(sqlwhere);
if (list == null || list.length == 0) {
return {code:0,msg:"没有信息",data:null};
}else {
return {code:1,msg:"操作成功",data:list};
}
}catch (e) {
return {code:-1,msg:"操作失败",data:null};
}
}
}
module.exports=ArticleService;
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