Commit 2ca780fc by 宋毅

tj

parent aaa35c5e
> 1%
last 2 versions
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
}
const system = require("../system");
const settings = require("../../config/settings");
const DocBase = require("./doc.base");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase {
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("web.common.oplogCtl");
this.oplogSve = system.getObject("service.common.oplogSve");
this.toolSve = system.getObject("service.trademark.toolSve");
this.exTime = 2 * 3600;//缓存过期时间,2小时
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
if (!params.timestamp) {
return system.getResult(null, "请求参数timestamp为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "签名验证失败");
}
return system.getResultSuccess();
}
/**
* 白名单验证
* @param {*} gname 组名
* @param {*} methodname 方法名
*/
async isCheckWhiteList(gname, methodname) {
var fullname = gname + "." + methodname;
var lst = [
"test.test",
"action.info",
"action.error",
"auth.getToken",
"auth.getJdSign"
];
var x = lst.indexOf(fullname);
return x >= 0;
}
async checkAcck(gname, methodname, pobj, query, req) {
var uAppInfo = null;
var selfAppInfo = null;
var ispass = await this.isCheckWhiteList(gname, methodname);
if (ispass) {
return system.getResultSuccess();
}//在白名单里面
var token = req.headers["token"];
if (!token) {
return system.getResult(null, "token不能为空");
}
uAppInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(token, { status: true }, this.exTime);
if (!uAppInfo || (uAppInfo.status && uAppInfo.status != 0)) {
return uAppInfo;
}
var selfAppInfo = await this.cacheManager["ApiAppKeyCheckCache"].cache(uAppInfo.data.app.appkey, null, this.exTime);
if (!selfAppInfo || (selfAppInfo.status && selfAppInfo.status != 0)) {
return selfAppInfo;
}
// if (!appInfo) {
// return system.getResult(null, "通过token获取sign的密钥信息失败,请重新获取");
// }
// var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
// if (signResult.status != 0) {
// return system.getResultFail(system.signFail, signResult.msg);
// }
if (pobj.isUser && pobj.isUser == "yes") {
var channelUserId = pobj.channelUserId ? pobj.channelUserId : pobj.actionBody.channelUserId || "";
if (!channelUserId && pobj.actionBody.channelUser) {
channelUserId = pobj.actionBody.channelUser.channelUserId;
}
if (!channelUserId) {
return system.getResult(null, "base verify channelUserId is empty");
}
var userCacheKey = selfAppInfo.data.uappKey + "_" + channelUserId;
var userInfo = await this.cacheManager["ApiUserCache"].cache(userCacheKey, channelUserId,
this.exTime, pobj.actionBody, selfAppInfo, uAppInfo.data.app.id);
if (!userInfo || (userInfo.status && userInfo.status != 0)) {
return userInfo;
}
if (userInfo.data && userInfo.data.isEnabled && userInfo.data.isEnabled != 1) {
return system.getResultFail(system.getUserInfoFail, "用户处于待审核等待启用状态");
}
req.user = userInfo.data;
pobj.actionBody.channelUserId = channelUserId;
}
req.app = selfAppInfo.data;
return system.getResultSuccess();
}
async doexec(gname, methodname, pobj, query, req) {
var requestid = req.headers["request-id"] || this.getUUID();
if (!req.headers["request-id"]) {
req.headers["request-id"] = requestid;
}
try {
if (pobj.actionType == "createChannelUser") {
if (!pobj.isUser) {
system.getResult(null, "isUser is empty");
}
if (pobj.isUser != "yes") {
system.getResult(null, "isUser value must yes");
}
}
//验证accesskey或验签
var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
if (isPassResult.status != 0) {
isPassResult.requestId = "";
return isPassResult;
}
if (pobj.actionType == "createChannelUser") {
var encryptResult = await this.toolSve.encryptStr(req.app, req.user.channelUserId);
if (encryptResult.status != 0) {
system.getResult(null, "encrypt channelUserId is error");
}
req.user.encryptChannelUserId = encryptResult.data;
return system.getResultSuccess(req.user);
}//创建用户
req.requestId = requestid;
var rtn = await this[methodname](pobj, query, req);
if (rtn && !rtn.requestId) {
rtn.requestId = requestid;
}
this.oplogSve.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: requestid,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.oplogSve.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: requestid,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(e.stack),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api调用出现异常,请联系管理员error,appKey:" + settings.appKey,
});
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: requestid,
op: pobj.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
rtnerror.requestId = requestid;
return rtnerror;
}
}
}
module.exports = APIBase;
const system = require("../system");
const settings = require("../../config/settings");
const DocBase = require("./doc.base");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase extends DocBase {
constructor() {
super();
this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("web.common.oplogCtl");
this.oplogSve = system.getObject("service.common.oplogSve");
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
if (!params.times_tamp) {
return system.getResult(null, "请求参数times_tamp为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "签名验证失败");
}
return system.getResultSuccess();
}
/**
* 白名单验证
* @param {*} gname 组名
* @param {*} methodname 方法名
*/
async isCheckWhiteList(gname, methodname) {
var fullname = gname + "." + methodname;
var lst = [
"test.testApi"
];
var x = lst.indexOf(fullname);
return x >= 0;
}
async checkAcck(gname, methodname, pobj, query, req) {
var appInfo = null;
var result = system.getResultSuccess();
var ispass = await this.isCheckWhiteList(gname, methodname);
var appkey = req.headers["accesskey"];
if (ispass) {
return result;
}//在百名单里面
if (appkey) {
appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000);
if (!appInfo || !appInfo.app) {
result.status = system.tokenFail;
result.msg = "请求头accesskey失效,请重新获取";
}
}//验证accesskey
else {
result.status = -1;
result.msg = "请求头没有相关访问参数,请验证后在进行请求";
}
return result;
}
async doexec(gname, methodname, pobj, query, req) {
var requestid = this.getUUID();
try {
//验证accesskey或验签
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (isPassResult.status != 0) {
// isPassResult.requestid = "";
// return isPassResult;
// }
var rtn = await this[methodname](pobj, query, req);
rtn.requestid = requestid;
this.oplogSve.createDb({
appid: req.headers["app_id"] || "",
appkey: req.headers["accesskey"] || "",
requestId: requestid,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.error({
appid: req.headers["app_id"] || "",
appkey: req.headers["accesskey"] || "",
requestId: requestid,
op: pobj.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员");
rtnerror.requestid = requestid;
return rtnerror;
}
}
}
module.exports = APIBase;
const system=require("../system");
const uuidv4 = require('uuid/v4');
class DocBase{
constructor(){
this.apiDoc={
group:"逻辑分组",
groupDesc:"",
name:"",
desc:"请对当前类进行描述",
exam:"概要示例",
methods:[]
};
this.initClassDoc();
}
initClassDoc(){
// this.descClass();
// this.descMethods();
}
descClass(){
var classDesc= this.classDesc();
this.apiDoc.group=classDesc.groupName;
this.apiDoc.groupDesc=classDesc.groupDesc;
this.apiDoc.name=classDesc.name;
this.apiDoc.desc=classDesc.desc;
this.apiDoc.exam=this.examHtml();
}
examHtml(){
var exam= this.exam();
exam=exam.replace(/\\/g,"<br/>");
return exam;
}
exam(){
throw new Error("请在子类中定义类操作示例");
}
classDesc(){
throw new Error(`
请重写classDesc对当前的类进行描述,返回如下数据结构
{
groupName:"auth",
groupDesc:"认证相关的包"
desc:"关于认证的类",
exam:"",
}
`);
}
descMethods(){
var methoddescs=this.methodDescs();
for(var methoddesc of methoddescs){
for(var paramdesc of methoddesc.paramdescs){
this.descMethod(methoddesc.methodDesc,methoddesc.methodName
,paramdesc.paramDesc,paramdesc.paramName,paramdesc.paramType,
paramdesc.defaultValue,methoddesc.rtnTypeDesc,methoddesc.rtnType);
}
}
}
methodDescs(){
throw new Error(`
请重写methodDescs对当前的类的所有方法进行描述,返回如下数据结构
[
{
methodDesc:"生成访问token",
methodName:"getAccessKey",
paramdescs:[
{
paramDesc:"访问appkey",
paramName:"appkey",
paramType:"string",
defaultValue:"x",
},
{
paramDesc:"访问secret",
paramName:"secret",
paramType:"string",
defaultValue:null,
}
],
rtnTypeDesc:"xxxx",
rtnType:"xxx"
}
]
`);
}
descMethod(methodDesc,methodName,paramDesc,paramName,paramType,defaultValue,rtnTypeDesc,rtnType){
var mobj=this.apiDoc.methods.filter((m)=>{
if(m.name==methodName){
return true;
}else{
return false;
}
})[0];
var param={
pname:paramName,
ptype:paramType,
pdesc:paramDesc,
pdefaultValue:defaultValue,
};
if(mobj!=null){
mobj.params.push(param);
}else{
this.apiDoc.methods.push(
{
methodDesc:methodDesc?methodDesc:"",
name:methodName,
params:[param],
rtnTypeDesc:rtnTypeDesc,
rtnType:rtnType
}
);
}
}
}
module.exports=DocBase;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class NeedOrderAPI extends APIBase {
constructor() {
super();
this.needinfoSve = system.getObject("service.dbneed.needinfoSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
pobj.actionBody["user"] = req.user;
pobj.actionBody["app"] = req.app;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
case "1688"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "subNeed"://提交需求
opResult = await this.needinfoSve.subNeed(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = NeedOrderAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
const logCtl = system.getObject("web.common.oplogCtl");
class opLog extends APIBase {
constructor() {
super();
}
async info(pobj, qobj, req) {
this.logCtl.info(pobj);
}
async error(pobj, qobj, req) {
this.logCtl.error(pobj);
}
}
module.exports = opLog;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
/**
* 接收远程推送的商标数据api
*/
class ReceiveDataAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
this.customerinfoSve = system.getObject("service.dborder.customerinfoSve");
this.customercontactsSve = system.getObject("service.dborder.customercontactsSve");
this.trademarkSve = system.getObject("service.dbtrademark.trademarkSve");
this.zcApiUrl = settings.reqZcApi();
this.pushFqbossDataUrl = settings.pushFqbossDataUrl();
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
break;
case "1688"://1688
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
break;
case "gsbhome"://gsb_homepage
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(action_process, action_type, action_body, pobj, req) {
// action_body.app = req.app;
// action_body.user = req.user;
// action_body.app = { id: 1, appPayType: "00", appDataOpType: "00" };
// action_body.user = { id: 1, app_id: 1, nickname: "测试用户",channelUserId:"channelUserIdtest01" };
var logParam = {
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/api/impl/action/receiveData.js/opActionProcess",
content: "参数信息:" + JSON.stringify(action_body),
clientIp: pobj.clientIp,
optitle: "接收推送过来的数据处理=>action_type=" + action_type,
};
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "receiveTmOfficialData"://接收回执文件
opResult = await this.trademarkSve.receiveTmOfficialData(action_body);
break;
case "updateAssistTmStatus"://接收商标状态信息
opResult = await this.trademarkSve.updateAssistTmStatus(action_body);
break;
case "assistRegTmData"://接收辅助注册商标数据
opResult = await this.ordertmproductSve.addAssistTm(action_body);
break;
case "assistEditTmData"://接收辅助注册修改商标数据
// opResult = system.getResultSuccess(null, "测试成功");
opResult = await this.ordertmproductSve.editAssistTm(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
logParam.resultInfo = JSON.stringify(opResult);
this.logCtl.info(logParam);
return opResult;
}
}
module.exports = ReceiveDataAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmQueryAPI extends APIBase {
constructor() {
super();
// this.tmqueryApi = system.getObject("api.trademark.tmqueryApi");
this.tmquerySve = system.getObject("service.trademark.tmquerySve");
// this.toolApi = system.getObject("api.tool.toolApi");
this.toolSve = system.getObject("service.trademark.toolSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
break;
case "1688":
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
break;
case "gsbhome":
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "findTrademarkNameAccurate"://商标精确检索(相同商标检索)
opResult = await this.tmquerySve.findTrademarkNameAccurate(action_body, req);
break;
case "findTrademarkName"://近似商标检索
opResult = await this.tmquerySve.findTrademarkName(action_body, req);
break;
case "findTrademarkzchAccurate"://商标申请号检索
opResult = await this.tmquerySve.findTrademarkzchAccurate(action_body, req);
break;
case "findTrademarkzcr"://申请人查询
opResult = await this.tmquerySve.findTrademarkzcr(action_body, req);
break;
case "getCropperPic"://获取检索图片url
opResult = await this.toolSve.getCropperPic(action_body, req);
break;
case "imagequery"://图形检索
opResult = await this.tmquerySve.imagequery(action_body, req);
break;
case "findImageSearch"://图形检索查询
opResult = await this.tmquerySve.findImageSearch(action_body, req);
break;
case "tradeMarkDetail"://商标详情查询
opResult = await this.tmquerySve.tradeMarkDetail(action_body, req);
break;
case "sbzuixinsearch"://最新商标查询
opResult = await this.tmquerySve.sbzuixinsearch(action_body, req);
break;
case "noticequeryTMZCSQ"://近12期初审公告查询接口
opResult = await this.tmquerySve.noticequeryTMZCSQ(action_body, req);
break;
case "noticequery"://公告列表检索接口
opResult = await this.tmquerySve.noticequery(action_body, req);
break;
case "noticezcggsearch"://注册公告详情查询
opResult = await this.tmquerySve.noticezcggsearch(action_body, req);
break;
case "noticesearch"://初审公告详情查询
opResult = await this.tmquerySve.noticesearch(action_body, req);
break;
case "getCompanyInfoNoUser"://企业查询
opResult = await this.tmquerySve.getCompanyInfoNoUser(action_body, req);
break;
case "getNclDetail"://尼斯详情
opResult = await this.tmquerySve.getNclDetail(action_body, req);
break;
case "gettwoNcl"://获取尼斯群组
opResult = await this.tmquerySve.gettwoNcl(action_body, req);
break;
case "nclFuwuSearch"://尼斯分类检索
opResult = await this.tmquerySve.nclFuwuSearch(action_body, req);
break;
case "bycznfx"://商标智能分析 -----
opResult = await this.toolSve.bycznfx(action_body, req);
break;
case "tmConfirm"://商标方案确认
// opResult = await this.toolApi.bycznfx(action_body);
opResult = system.getResultSuccess(null, "商标方案确认成功");
break;
case "icheming"://商标智能分析 -----
opResult = await this.toolSve.icheming(action_body, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmQueryAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmToolsAPI extends APIBase {
constructor() {
super();
this.toolSve = system.getObject("service.trademark.toolSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
break;
case "1688":
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
break;
case "gsbhome":
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "encryptStr"://
opResult = await this.toolSve.encryptStr(req.app, action_body.opStr);
break;
case "decryptStr"://
opResult = await this.toolSve.decryptStr(req.app, action_body.opStr);
break;
case "getOssConfig"://
opResult = await this.toolSve.getOssConfig();
break;
case "getNcl"://尼斯查询(一)
opResult = await this.toolSve.getNcl(action_body, req);
break;
case "getNclByLikeNameAndNcl"://尼斯查询(二)
opResult = await this.toolSve.getNclByLikeNameAndNcl(action_body, req);
break;
case "word2pic"://文字转图片
opResult = await this.toolSve.word2pic(action_body, req);
break;
case "uploadStandardTm"://商标样式转换
opResult = await this.toolSve.uploadStandardTm(action_body, req);
break;
case "pic2pdf"://图片转pdf
opResult = await this.toolSve.pic2pdf(action_body, req);
break;
case "getCompanyInfoByLikeName"://企业近似查询
opResult = await this.toolSve.getCompanyInfoByLikeName(action_body, req);
break;
case "getEntregistryByCompanyName"://企业精确查询
opResult = await this.toolSve.getEntregistryByCompanyName(action_body, req);
break;
case "adjustWTSSize"://调整委托书
opResult = await this.toolSve.adjustWTSSize(action_body, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmToolsAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmTransactionAPI extends APIBase {
constructor() {
super();
this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.action_type) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
case "1688":
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "addOrder"://添加订单
opResult = await this.orderinfoSve.createOrder(action_body, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmTransactionAPI;
\ No newline at end of file
const system = require("../../../system");
var APIBase = require("../../api.base");
var settings = require("../../../../config/settings");
var moment = require('moment')
class TradetransferAPI extends APIBase {
constructor() {
super();
this.aliclient = system.getObject("util.aliyunClient");
this.execlient = system.getObject("util.execClient");
this.transferurl = settings.reqTransferurl();
this.corderSve = system.getObject("service.dbcorder.orderinfoSve");
}
//订单创建
async createtransfer(p, obj, req) {
console.log(p.actionBody, "actionBody...............................");
var orderinfo = await this.corderSve.createOrder(p.actionBody, req);
console.log(orderinfo, "orderinfo............................");
if (orderinfo) {
if (orderinfo.status == "0") {
var result = {
"errorCode": "OK",
"errorMsg": "成功",
"module": { "orderId": orderinfo.data.orderNo },
"requestId": req.requestId,
"success": true
}
return result;
} else if (orderinfo.status == "2") {
var result = {
"errorCode": "OK",
"errorMsg": "订单已存在",
"module": { "orderId": orderinfo.data },
"requestId": req.requestId,
"success": true
}
return result;
} else {
var result = {
"errorCode": "error",
"errorMsg": orderinfo.msg,
"module": { "orderId": "" },
"requestId": req.requestId,
"success": false
}
return result;
}
} else {
var result = {
"errorCode": "error",
"errorMsg": "",
"module": { "orderId": "" },
"requestId": req.requestId,
"success": false
}
return result;
}
}
//订单查询
async ordersel(p, obj) {
var url = this.transferurl + "api/transfer/tradeApi/queryOrderState";
var transferinfo = await this.execlient.execPost(p.actionBody, url);
var a = JSON.parse(transferinfo.stdout)
return a;
}
//订单关闭
async orderclose(p,obj) {
var url = this.transferurl + "api/transfer/tradeApi/closeOrder";
var transferinfo = await this.execlient.execPost(p.actionBody, url);
var a = JSON.parse(transferinfo.stdout)
return a;
}
//业务员分配
async fenpeiowner(obj) {
if (!obj.BizId) {
return {
"errorCode": "error",
"errorMsg": "订单号不能为空",
"requestId": obj.requestId,
"success": false
}
}
var transferinfo = await this.findOne({ ali_bizid: obj.BizId });
}
//阿里网关
async aliclienttransfer(p, obj) {
console.log("----------------sssssssssssssssssss-------------------------------------------")
console.log(p.actionBody)
if (p.actionBody) {
console.log(p.actionBody)
var rtn = await this.aliclient.reqbyget(p.actionBody)
return rtn;
}
}
}
module.exports = TradetransferAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async getToken(pobj, qobj, req) {
var appkey = pobj.appkey;
var secret = pobj.secret;
if (!appkey) {
return system.getResult(null, "appkey参数不能为空");
}
if (!secret) {
return system.getResult(null, "secret参数不能为空");
}
var result = await this.opPlatformUtils.getReqApiAccessKey(appkey, secret);
if (result && result.status && result.status != 0) {
return result;
}
var resultData = {
token: result && result.data ? result.data.accessKey : ""
};
return system.getResultSuccess(resultData);
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(pobj, qobj, req) {
return await this.opPlatformUtils.authByCode(qobj.code);
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class jdAuthAPI extends APIBase {
constructor() {
super();
}
async getUser(pobj, qobj, req) {
console.log("pobj......getUser..........:\n", pobj);
console.log("qobj......getUser..........:\n", qobj);
return { getUser: "ok" };
}
async payOrderInfo(pobj, qobj, req) {
console.log("pobj......payOrderInfo..........:\n", pobj);
console.log("qobj......payOrderInfo..........:\n", qobj);
return { payOrderInfo: "ok" };
}
}
module.exports = jdAuthAPI;
\ No newline at end of file
mongoose = require('mongoose');
var Schema = mongoose.Schema({
company_name: { type: String},
})
const ad = mongoose.model('taierphones', Schema);
//导出模型
module.exports =ad;
const system = require("../system");
const settings = require("../../config/settings");
class CtlBase {
constructor(gname, sname) {
this.serviceName = sname;
this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager");
this.md5 = require("MD5");
}
encryptPasswd(passwd) {
if (!passwd) {
throw new Error("请输入密码");
}
var md5 = this.md5(passwd + "_" + settings.salt);
return md5.toString().toLowerCase();
}
notify(req, msg) {
if (req.session) {
req.session.bizmsg = msg;
}
}
async findOne(queryobj, qobj) {
var rd = await this.service.findOne(qobj);
return system.getResult(rd, null);
}
async findAndCountAll(queryobj, obj, req) {
obj.codepath = req.codepath;
if (req.session.user) {
obj.uid = req.session.user.id;
obj.appid = req.session.user.app_id;
obj.onlyCode = req.session.user.unionId;
obj.account_id = req.session.user.account_id;
obj.ukstr = req.session.user.app_id + "¥" + req.session.user.id + "¥" + req.session.user.nickName + "¥" + req.session.user.headUrl;
}
var apps = await this.service.findAndCountAll(obj);
return system.getResult(apps, null);
}
async refQuery(queryobj, qobj) {
var rd = await this.service.refQuery(qobj);
return system.getResult(rd, null);
}
async bulkDelete(queryobj, ids) {
var rd = await this.service.bulkDelete(ids);
return system.getResult(rd, null);
}
async delete(queryobj, qobj) {
var rd = await this.service.delete(qobj);
return system.getResult(rd, null);
}
async create(queryobj, qobj, req) {
if (req && req.session && req.session.app) {
qobj.app_id = req.session.app.id;
qobj.onlyCode = req.session.user.unionId;
if (req.codepath) {
qobj.codepath = req.codepath;
}
}
var rd = await this.service.create(qobj);
return system.getResult(rd, null);
}
async createLog(queryobj, qobj, req) {
if (req && req.session && req.session.app) {
qobj.app_id = req.session.app.id;
qobj.onlyCode = req.session.user.unionId;
if (req.codepath) {
qobj.codepath = req.codepath;
}
}
var tmpParam = qobj || queryobj;
var rd = await this.service.create(tmpParam);
return system.getResult(rd, null);
}
async update(queryobj, qobj, req) {
if (req && req.session && req.session.user) {
qobj.onlyCode = req.session.user.unionId;
}
if (req.codepath) {
qobj.codepath = req.codepath;
}
var rd = await this.service.update(qobj);
return system.getResult(rd, null);
}
static getServiceName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve";
}
async initNewInstance(queryobj, req) {
return system.getResult({}, null);
}
async findById(oid) {
var rd = await this.service.findById(oid);
return system.getResult(rd, null);
}
async timestampConvertDate(time) {
if (time == null) {
return "";
}
var date = new Date(Number(time * 1000));
var y = 1900 + date.getYear();
var m = "0" + (date.getMonth() + 1);
var d = "0" + date.getDate();
return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
}
async universalTimeConvertLongDate(time) {
if (time == null) {
return "";
}
var d = new Date(time);
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
}
async universalTimeConvertShortDate(time) {
if (time == null) {
return "";
}
var d = new Date(time);
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
}
async doexec(methodname, pobj, query, req) {
try {
var rtn = await this[methodname](pobj, query, req);
return rtn;
} catch (e) {
console.log(e.stack);
// this.logCtl.error({
// optitle: "Ctl调用出错",
// op: pobj.classname + "/" + methodname,
// content: e.stack,
// clientIp: pobj.clientIp
// });
return system.getResultFail(-200, "Ctl出现异常,请联系管理员");
}
}
}
module.exports = CtlBase;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
var cacheBaseComp = null;
class UserCtl extends CtlBase {
constructor() {
super("auth", CtlBase.getServiceName(UserCtl));
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(req) {
var opencode = req.query.code;
var user = await this.service.authByCode(opencode);
if (user) {
req.session.user = user;
} else {
req.session.user = null;
}
//缓存opencode,方便本应用跳转到其它应用
// /auth?code=xxxxx,缓存没有意义,如果需要跳转到其它应用,需要调用
//平台开放的登录方法,返回 <待跳转的目标地址>/auth?code=xxxxx
//this.cacheManager["OpenCodeCache"].cacheOpenCode(user.id,opencode);
return user;
}
async navSysSetting(pobj, qobj, req) {
//开始远程登录,返回code
var jumpobj = await this.service.navSysSetting(req.session.user);
if (jumpobj) {
return system.getResultSuccess(jumpobj);
}
return system.getResultFail();
}
async loginUser(qobj, pobj, req) {
return super.findById(req.session.user.id);
}
async initNewInstance(queryobj, req) {
var rtn = {};
rtn.roles = [];
if (rtn) {
return system.getResultSuccess(rtn);
}
return system.getResultFail();
}
async checkLogin(gobj, qobj, req) {
//当前如果缓存中存在user,还是要检查当前user所在的域名,如果不和来访一致,则退出重新登录
if (req.session.user) {
var x = null;
if (req.session.user.Roles) {
x = req.session.user.Roles.map(r => { return r.code });
}
var tmp = {
id: req.session.user.id,
userName: req.session.user.userName,
nickName: req.session.user.nickName,
mobile: req.session.user.mobile,
isAdmin: req.session.user.isAdmin,
created_at: req.session.user.created_at,
email: req.session.user.email,
headUrl: req.session.user.headUrl,
roles: x ? x.join(",") : ""
}
return system.getResult(tmp, "用户登录", req);
} else {
req.session.user = null;
//req.session.destroy();
return system.getResult(null, "用户未登录", req);
}
}
async exit(pobj, qobj, req) {
req.session.user = null;
req.session.destroy();
return system.getResultSuccess({ "env": settings.env });
}
}
module.exports = UserCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
class OplogCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(OplogCtl));
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(qobj) {
var u = uuidv4();
var aid = u.replace(/\-/g, "");
var rd = { name: "", appid: aid }
return system.getResultSuccess(rd, null);
}
async debug(obj) {
obj.logLevel = "debug";
return this.createLog(obj);
}
async info(obj) {
obj.logLevel = "info";
return this.createLog(obj);
}
async warn(obj) {
obj.logLevel = "warn";
return this.createLog(obj);
}
async error(obj) {
obj.logLevel = "error";
return this.createLog(obj);
}
async fatal(obj) {
obj.logLevel = "fatal";
return this.createLog(obj);
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid_Ctl(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo_Ctl(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
module.exports = OplogCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
class PushlogCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(PushlogCtl));
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(qobj) {
var u = uuidv4();
var aid = u.replace(/\-/g, "");
var rd = { name: "", appid: aid }
return system.getResultSuccess(rd, null);
}
async debug(obj) {
obj.logLevel = "debug";
return this.create(obj);
}
async info(obj) {
obj.logLevel = "info";
return this.create(obj);
}
async warn(obj) {
obj.logLevel = "warn";
return this.create(obj);
}
async error(obj) {
obj.logLevel = "error";
return this.create(obj);
}
async fatal(obj) {
obj.logLevel = "fatal";
return this.create(obj);
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid_Ctl(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo_Ctl(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
module.exports = PushlogCtl;
const system = require("../../system");
const settings = require("../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
function exp(db, DataTypes) {
var base = {
code: DataTypes.STRING(100),
app_id: DataTypes.INTEGER,//
createuser_id: DataTypes.INTEGER,//
updateuser_id: DataTypes.INTEGER,//
auditoruser_id: DataTypes.INTEGER,//
moneyaccount_id: DataTypes.INTEGER,//
creator: DataTypes.STRING(100),//创建者
updator: DataTypes.STRING(100),//更新者
auditor: DataTypes.STRING(100),//审核者
opNotes: DataTypes.STRING(500),//操作备注
auditStatusName: {
type: DataTypes.STRING(50),
defaultValue: "待审核",
},
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.audit_status),
set: function (val) {
this.setDataValue("auditStatus", val);
this.setDataValue("auditStatusName", uiconfig.config.pdict.audit_status[val]);
},
defaultValue: "dsh",
},
sourceTypeName: DataTypes.STRING(50),
sourceType: {//来源类型 "order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单", "trademark": "商标单"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.source_type),
set: function (val) {
this.setDataValue("sourceType", val);
this.setDataValue("sourceTypeName", uiconfig.config.pdict.source_type[val]);
}
},
sourceOrderNo: DataTypes.STRING(100),//来源单号
channelServiceNo: DataTypes.STRING(100),//渠道服务单号
};
return base;
}
module.exports = exp;
const system = require("../system")
const settings = require("../../config/settings.js");
class CacheBase {
constructor() {
this.redisClient = system.getObject("util.redisClient");
this.desc = this.desc();
this.prefix = this.prefix();
this.cacheCacheKeyPrefix = "s_sadd_appkeys:" + settings.appKey + "_cachekey";
this.isdebug = this.isdebug();
}
isdebug() {
return false;
}
desc() {
throw new Error("子类需要定义desc方法,返回缓存描述");
}
prefix() {
throw new Error("子类需要定义prefix方法,返回本缓存的前缀");
}
async cache(inputkey, val, ex, ...items) {
const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null" || this.isdebug) {
var objval = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items);
if (!objval || (objval.status && objval.status != 0)) {
return objval;
}
if (ex) {
await this.redisClient.setWithEx(cachekey, JSON.stringify(objval), ex);
} else {
await this.redisClient.set(cachekey, JSON.stringify(objval));
}
//缓存当前应用所有的缓存key及其描述
this.redisClient.sadd(this.cacheCacheKeyPrefix, [cachekey + "|" + this.desc]);
return objval;
} else {
return JSON.parse(cacheValue);
}
}
async invalidate(inputkey) {
const cachekey = this.prefix + inputkey;
this.redisClient.delete(cachekey);
return 0;
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
throw new Error("子类中实现构建缓存值的方法,返回字符串");
}
}
module.exports = CacheBase;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAccessKeyCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_accesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var appkey = inputkey || settings.appKey;
var secret = items && items.length > 0 ? items[0] : settings.secret;
var acckapp = await this.restS.execPost({ appkey: appkey, secret: secret }, settings.paasUrl() + "api/auth/accessAuth/getAccessKey");
var s = acckapp.stdout;
console.log(acckapp.stdout, "ApiAccessKeyCache............. acckapp.stdout..........")
if (s) {
var tmp = JSON.parse(s);
return tmp;
// if (tmp.status == 0) {
// return JSON.stringify(tmp.data);
// }
}
return system.getResult(null, "返回数据为空!");
}
}
module.exports = ApiAccessKeyCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiAccessKeyCheckCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_verify_reqaccesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var cacheManager = system.getObject("db.common.cacheManager");
//当来访key缓存不存在时,需要去开放平台检查是否存在来访key缓存
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
if (acckapp.status != 0) {
return system.getResult(null, "获取本应用accessKey错误");
}
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.data.accessKey);
if (checkresult.status == 0) {
return checkresult;
// var s = checkresult.data;
// return JSON.stringify(s);
} else {
await cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.data.accessKey);
return checkresult;
// var s = checkresult.data;
// return JSON.stringify(s);
}
}
}
module.exports = ApiAccessKeyCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAppKeyCheckCache extends CacheBase {
constructor() {
super();
this.appDao = system.getObject("db.dbapp.appDao");
}
desc() {
return "应用中来访访问appid缓存";
}
prefix() {
return settings.cacheprefix + "_verify_appKey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var item = await this.appDao.getItemByAppKey(inputkey);
if (!item) {
return system.getResult(null, "返回数据为空!");
}
if (item.status != 1) {
return system.getResultFail(system.waitAuditSelfApp, "渠道应用处于待审核等待启用状态");
}
return system.getResultSuccess(item);
}
}
module.exports = ApiAppKeyCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiUserCache extends CacheBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appDao = system.getObject("db.dbapp.appDao");
this.appuserDao = system.getObject("db.dbapp.appuserDao");
this.restClient = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_userdata:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var actionBody = items[0];
var selfAppInfo = items[1];
var uAppId = items[2];
var channelUserId = val || "";
var uUserName = channelUserId + "$" + selfAppInfo.data.uappKey;//uUserName
var createUserPwd = inputkey;//(格式:selfAppInfo.data.uappKey+”_“+channelUserId)
var userInfo = await this.appuserDao.getItemByUUserId(uUserName, selfAppInfo.data.id);
if (userInfo) {
var loginNum = Number(userInfo.loginNum || 0) + 1;
this.appuserDao.updateByWhere({ lastLoginTime: new Date(), loginNum: loginNum }, { where: { id: userInfo.id } });
return system.getResultSuccess(userInfo);
}
var uUserInfo = await this.opPlatformUtils.createUserInfo(uUserName, actionBody.channelUserMoblie || "15010888888",
createUserPwd, selfAppInfo.data.uappKey, selfAppInfo.data.appSecret);
if (uUserInfo.status != 2000 && uUserInfo.status != 0) {
return uUserInfo;
}//已经存在此用户 或 注册失败
if (uUserInfo.status == 0) {
var params = {
app_id: selfAppInfo.data.id,
channelUserId: channelUserId,
channelUserName: actionBody.channelUserName || channelUserId,
userMoblie: actionBody.channelUserMoblie || "88888888888",
nickname: actionBody.nickname || "",
orgName: actionBody.orgName || "",
orgPath: actionBody.orgPath || "",
uUserName: uUserName,
uAppId: uAppId,
isEnabled: 1,
lastLoginTime: new Date()
};
userInfo = await this.appuserDao.create(params);
}
else {
return uUserInfo;
}
return system.getResultSuccess(userInfo);
}
}
module.exports = ApiUserCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class MagCache extends CacheBase {
constructor() {
super();
this.prefix = "magCache";
}
desc() {
return "应用UI配置缓存";
}
//暂时没有用到,只是使用其帮助的方法
prefix() {
return settings.cacheprefix + "_uiconfig:";
}
async getCacheSmembersByKey(key) {
return this.redisClient.smembers(key);
}
async delCacheBySrem(key, value) {
return this.redisClient.srem(key, value)
}
async keys(p) {
return this.redisClient.keys(p);
}
async get(k) {
return this.redisClient.get(k);
}
async del(k) {
return this.redisClient.delete(k);
}
async clearAll() {
console.log("xxxxxxxxxxxxxxxxxxxclearAll............");
return this.redisClient.flushall();
}
}
module.exports = MagCache;
const system = require("../system");
class Dao {
constructor(modelName) {
this.modelName = modelName;
var db = system.getObject("db.common.connection").getCon();
this.db = db;
this.model = db.models[this.modelName];
}
preCreate(u) {
return u;
}
/**
*
* @param {*} u 对象
* @param {*} t 事务对象t
*/
async create(u, t) {
var u2 = this.preCreate(u);
if (t) {
return this.model.create(u2, { transaction: t }).then(u => {
return u;
});
} else {
return this.model.create(u2, { transaction: t }).then(u => {
return u;
});
}
}
static getModelName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Dao")).toLowerCase()
}
async refQuery(qobj) {
var w = {};
if (qobj.likestr) {
w[qobj.fields[0]] = { [this.db.Op.like]: "%" + qobj.likestr + "%" };
return this.model.findAll({ where: w, attributes: qobj.fields });
} else {
return this.model.findAll({ attributes: qobj.fields });
}
}
async bulkDeleteByWhere(whereParam, t) {
var en = null;
if (t != null && t != 'undefined') {
whereParam.transaction = t;
return await this.model.destroy(whereParam);
} else {
return await this.model.destroy(whereParam);
}
}
async bulkDelete(ids) {
var en = await this.model.destroy({ where: { id: { [this.db.Op.in]: ids } } });
return en;
}
async delete(qobj) {
var en = await this.model.findOne({ where: qobj });
if (en != null) {
return en.destroy();
}
return null;
}
extraModelFilter() {
//return {"key":"include","value":{model:this.db.models.app}};
return null;
}
extraWhere(obj, where) {
return where;
}
orderBy() {
//return {"key":"include","value":{model:this.db.models.app}};
return [["created_at", "DESC"]];
}
buildAttributes() {
return [];
}
buildQuery(qobj) {
var linkAttrs = [];
const pageNo = qobj.pageInfo.pageNo;
const pageSize = qobj.pageInfo.pageSize;
const search = qobj.search;
const orderInfo = qobj.orderInfo;//格式:[["created_at", 'desc']]
var qc = {};
//设置分页查询条件
qc.limit = pageSize;
qc.offset = (pageNo - 1) * pageSize;
//默认的查询排序
if (orderInfo) {
qc.order = orderInfo;
} else {
qc.order = this.orderBy();
}
//构造where条件
qc.where = {};
if (search) {
Object.keys(search).forEach(k => {
console.log(search[k], ":search[k]search[k]search[k]");
if (search[k] && search[k] != 'undefined' && search[k] != "") {
if ((k.indexOf("Date") >= 0 || k.indexOf("_at") >= 0)) {
if (search[k] != "" && search[k]) {
var stdate = new Date(search[k][0]);
var enddate = new Date(search[k][1]);
qc.where[k] = { [this.db.Op.between]: [stdate, enddate] };
}
}
else if (k.indexOf("id") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("channelCode") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("Type") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("Status") >= 0) {
qc.where[k] = search[k];
}
else if (k.indexOf("status") >= 0) {
qc.where[k] = search[k];
}
else {
if (k.indexOf("~") >= 0) {
linkAttrs.push(k);
} else {
qc.where[k] = { [this.db.Op.like]: "%" + search[k] + "%" };
}
}
}
});
}
this.extraWhere(qobj, qc.where, qc, linkAttrs);
var extraFilter = this.extraModelFilter();
if (extraFilter) {
qc[extraFilter.key] = extraFilter.value;
}
var attributesObj = this.buildAttributes();
if (attributesObj && attributesObj.length > 0) {
qc.attributes = attributesObj;
}
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
console.log(qc);
return qc;
}
async findAndCountAll(qobj, t) {
var qc = this.buildQuery(qobj);
var apps = await this.model.findAndCountAll(qc);
return apps;
}
preUpdate(obj) {
return obj;
}
async update(obj, tm) {
var obj2 = this.preUpdate(obj);
if (tm != null && tm != 'undefined') {
return this.model.update(obj2, { where: { id: obj2.id }, transaction: tm });
} else {
return this.model.update(obj2, { where: { id: obj2.id } });
}
}
async updateByWhere(setObj, whereObj, t) {
if (t && t != 'undefined') {
if (whereObj && whereObj != 'undefined') {
whereObj.transaction = t;
} else {
whereObj = { transaction: t };
}
}
return this.model.update(setObj, whereObj);
}
async customExecAddOrPutSql(sql, paras = null) {
return this.db.query(sql, paras);
}
async customQuery(sql, paras, t) {
var tmpParas = null;//||paras=='undefined'?{type: this.db.QueryTypes.SELECT }:{ replacements: paras, type: this.db.QueryTypes.SELECT };
if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.SELECT };
tmpParas.transaction = t;
} else {
tmpParas = { replacements: paras, type: this.db.QueryTypes.SELECT };
tmpParas.transaction = t;
}
} else {
tmpParas = paras == null || paras == 'undefined' || paras.keys == 0 ? { type: this.db.QueryTypes.SELECT } : { replacements: paras, type: this.db.QueryTypes.SELECT };
}
var result = this.db.query(sql, tmpParas);
return result;
}
async customUpdate(sql, paras, t) {
var tmpParas = null;
if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.UPDATE };
tmpParas.transaction = t;
} else {
tmpParas = { replacements: paras, type: this.db.QueryTypes.UPDATE };
tmpParas.transaction = t;
}
} else {
tmpParas = paras == null || paras == 'undefined' ? { type: this.db.QueryTypes.UPDATE } : { replacements: paras, type: this.db.QueryTypes.UPDATE };
}
return this.db.query(sql, tmpParas);
}
async findCount(whereObj = null) {
return this.model.count(whereObj, { logging: false }).then(c => {
return c;
});
}
async findSum(fieldName, whereObj = null) {
return this.model.sum(fieldName, whereObj);
}
async getPageList(pageIndex, pageSize, whereObj = null, orderObj = null, attributesObj = null, includeObj = null) {
var tmpWhere = {};
tmpWhere.limit = pageSize;
tmpWhere.offset = (pageIndex - 1) * pageSize;
if (whereObj != null) {
tmpWhere.where = whereObj;
}
if (orderObj != null && orderObj.length > 0) {
tmpWhere.order = orderObj;
}
if (attributesObj != null && attributesObj.length > 0) {
tmpWhere.attributes = attributesObj;
}
if (includeObj != null && includeObj.length > 0) {
tmpWhere.include = includeObj;
tmpWhere.distinct = true;
}
tmpWhere.raw = true;
return await this.model.findAndCountAll(tmpWhere);
}
async findOne(obj, t) {
var params = { "where": obj };
if (t) {
params.transaction = t;
}
return this.model.findOne(params);
}
async findById(oid) {
return this.model.findById(oid);
}
}
module.exports = Dao;
const system=require("../../../system");
const fs=require("fs");
const settings=require("../../../../config/settings");
var glob = require("glob");
class APIDocManager{
constructor(){
this.doc={};
this.buildAPIDocMap();
}
async buildAPIDocMap(){
var self=this;
//订阅任务频道
var apiPath=settings.basepath+"/app/base/api/impl";
var rs = glob.sync(apiPath + "/**/*.js");
if(rs){
for(let r of rs){
// var ps=r.split("/");
// var nl=ps.length;
// var pkname=ps[nl-2];
// var fname=ps[nl-1].split(".")[0];
// var obj=system.getObject("api."+pkname+"."+fname);
var ClassObj=require(r);
var obj=new ClassObj();
var gk=obj.apiDoc.group+"|"+obj.apiDoc.groupDesc
if(!this.doc[gk]){
this.doc[gk]=[];
this.doc[gk].push(obj.apiDoc);
}else{
this.doc[gk].push(obj.apiDoc);
}
}
}
}
}
module.exports=APIDocManager;
const fs = require("fs");
const settings = require("../../../../config/settings");
class CacheManager {
constructor() {
//await this.buildCacheMap();
this.buildCacheMap();
}
buildCacheMap() {
try {
var self = this;
self.doc = {};
var cachePath = settings.basepath + "/app/base/db/cache/";
const files = fs.readdirSync(cachePath);
if (files) {
files.forEach(function (r) {
var classObj = require(cachePath + "/" + r);
self[classObj.name] = new classObj();
var refTmp = self[classObj.name];
if (refTmp.prefix) {
self.doc[refTmp.prefix] = refTmp.desc;
}
else {
console.log("请在" + classObj.name + "缓存中定义prefix");
}
});
}
} catch (e) {
console.log(e.stack, "CacheManager................error")
}
}
}
module.exports = CacheManager;
// var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{
// console.log(x);
// });
// });
const Sequelize = require('sequelize');
const settings = require("../../../../config/settings")
const fs = require("fs")
const path = require("path");
var glob = require("glob");
class DbFactory {
constructor() {
const dbConfig = settings.database();
this.db = new Sequelize(dbConfig.dbname,
dbConfig.user,
dbConfig.password,
dbConfig.config);
this.db.Sequelize = Sequelize;
this.db.Op = Sequelize.Op;
this.initModels();
this.initRelations();
}
async initModels() {
var self = this;
var modelpath = path.normalize(path.join(__dirname, '../..')) + "/models/";
console.log("modelpath=====================================================");
console.log(modelpath);
var models = glob.sync(modelpath + "/**/*.js");
console.log(models.length);
models.forEach(function (m) {
console.log(m);
self.db.import(m);
});
console.log("init models....");
}
async initRelations() {
/**
一个账户对应多个登陆用户
一个账户对应一个commany
一个APP对应多个登陆用户
一个APP有多个角色
登陆用户和角色多对多
**/
/*建立账户和用户之间的关系*/
//account--不属于任何一个app,是统一用户
//用户登录时首先按照用户名和密码检查account是否存在,如果不存在则提示账号或密码不对,如果
//存在则按照按照accountid和应用key,查看user,后台实现对应user登录
}
//async getCon(){,用于使用替换table模型内字段数据使用
getCon() {
//同步模型
if (settings.env == "dev") {
}
return this.db;
}
getConhb() {
var that = this;
if (settings.env == "dev") {
}
return this.dbhb;
}
}
module.exports = DbFactory;
const mongoose = require('mongoose')
class MgDbFactory {
constructor() {
const reqUrl = "mongodb://wdy1:123456@43.247.184.94:27017/phones";
this.mgdb = mongoose.connect(reqUrl, { useNewUrlParser: true });
}
getModel(tabName) {
// let schema = require("./model/" + tabName.replace(/_/g, "."));
let model = mongoose.models[tabName];
if (!model) {
model = mongoose.model(tabName, new mongoose.Schema({
company_name: { type: String }
}), tabName);
}
return model
}
}
module.exports = MgDbFactory;
\ No newline at end of file
const system=require("../../../system");
const Dao=require("../../dao.base");
class OplogDao extends Dao{
constructor(){
super(Dao.getModelName(OplogDao));
}
}
module.exports=OplogDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class PushlogDao extends Dao{
constructor(){
super(Dao.getModelName(PushlogDao));
}
}
module.exports=PushlogDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppDao extends Dao {
constructor() {
super(Dao.getModelName(AppDao));
}
async getItemByAppKey(appKey) {
return this.model.findOne({
where: {
uappKey: appKey
},
attributes: ["id",
"name", // 应用名称
"appDataOpType", // 应用数据操作类型:00独立,10全委托,20部分委托
"appPayType", // 支付类型:00第三方应用自己支付,10平台代收款
"contactName", // 联系人姓名
"contactMobile", // 联系人手机
"contactEmail", // 联系人邮箱
"uappKey", // 平台应用key
"appSecret", // 密钥信息,用于进行签名请求接口
"status", // 状态 0禁用 1启用
"uAppId",
"channelAppId", // 渠道appID
"channelAppKey", // 渠道appKey
"pushOrderUrl", //获取渠道推送订单的url
"appSourceCode", //app来源code
"notes"],
raw: true
});
}
}
module.exports = AppDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppProductDao extends Dao {
constructor() {
super(Dao.getModelName(AppProductDao));
}
async findOneByServiceItemCode(itemCode, appId) {
return this.model.findOne({
where: {
serviceItemCode: itemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"serviceItemCode",
"pushServiceItemCode",
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
async findOneByCode(itemCode, appId) {
return this.model.findOne({
where: {
itemCode: itemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"serviceItemCode",
"pushServiceItemCode",
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
async findOneByChannelItemCode(channelItemCode, appId) {
return this.model.findOne({
where: {
channelItemCode: channelItemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"serviceItemCode",
"pushServiceItemCode",
"deliveryUrl",
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
}
module.exports = AppProductDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppUserDao extends Dao {
constructor() {
super(Dao.getModelName(AppUserDao));
}
async getItemByUUserId(uUserName, appId) {
return this.model.findOne({
where: {
uUserName: uUserName,
app_id: appId
},
attributes: ["id",
"app_id",
"channelUserId",
"channelUserName",
"uUserName",
"uAppId",
"userMoblie",
"nickname",
"orgName",
"orgPath",
"isEnabled",
"loginNum",
"lastLoginTime"],
raw: true
});
}
}
module.exports = AppUserDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class MoneyAccountDao extends Dao {
constructor() {
super(Dao.getModelName(MoneyAccountDao));
}
}
module.exports = MoneyAccountDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class FlowLogDao extends Dao {
constructor() {
super(Dao.getModelName(FlowLogDao));
}
}
module.exports = FlowLogDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderContactsDao extends Dao {
constructor() {
super(Dao.getModelName(OrderContactsDao));
}
}
module.exports = OrderContactsDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderInfoDao extends Dao {
constructor() {
super(Dao.getModelName(OrderInfoDao));
}
buildAttributes(){
return [
"orderNo",
"channelServiceNo",
"needNo",
"payTime",
"channelUserId",
"quantity",
"serviceQuantity",
"orderPayStatusName",
"orderPayStatus",
"totalSum",
"payTotalSum",
"refundSum",
"channelProfitSum",
"pfSettleProfit",
"notes",
"opNotes"
];
}
}
module.exports = OrderInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderProductDao extends Dao {
constructor() {
super(Dao.getModelName(OrderProductDao));
}
}
module.exports = OrderProductDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class ExpenseVoucherDao extends Dao{
constructor(){
super(Dao.getModelName(ExpenseVoucherDao));
}
}
module.exports=ExpenseVoucherDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class MoneyJourneyDao extends Dao{
constructor(){
super(Dao.getModelName(MoneyJourneyDao));
}
}
module.exports=MoneyJourneyDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderReceiptVoucherDao extends Dao {
constructor() {
super(Dao.getModelName(OrderReceiptVoucherDao));
}
}
module.exports = OrderReceiptVoucherDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderRefundVoucherDao extends Dao {
constructor() {
super(Dao.getModelName(OrderRefundVoucherDao));
}
}
module.exports = OrderRefundVoucherDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class NeedInfoDao extends Dao{
constructor(){
super(Dao.getModelName(NeedInfoDao));
}
}
module.exports=NeedInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CustomerContactsDao extends Dao {
constructor() {
super(Dao.getModelName(CustomerContactsDao));
}
async findOneByMobile(mobile, customerinfoId) {
return this.model.findOne({
where: {
mobile: mobile,
customerinfo_id: customerinfoId
},
attributes: ["id",
"deliveryOrderNo",
"mobile",
"email",
"tel",
"fax",
"name",
"code",
"app_id"],
raw: true
});
}
async findOneByCustomerinfoId(customerinfoId) {
return this.model.findOne({
where: {
customerinfo_id: customerinfoId
},
attributes: ["id",
"deliveryOrderNo",
"mobile",
"email",
"tel",
"fax",
"name",
"code",
"app_id"],
raw: true
});
}
}
module.exports = CustomerContactsDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CustomerInfoDao extends Dao {
constructor() {
super(Dao.getModelName(CustomerInfoDao));
}
async findOneByCodeAndUserId(code, userId) {
return this.model.findOne({
where: {
code: code,
createuser_id: userId
},
attributes: ["id",
"customerType",// ent:企业,person:个人
"customerTypeName",
"identityCardPic",//身份证图片
"businessLicensePic",//营业执照图片
"name",//公司名称或个人名称
"code",//公司统一社会代码
"app_id",
"deliveryOrderNo",
"applyAddr",//申请地址
"applyArea",//存储省市编码
"province",//省
"city",//市
"identityCardNo",//身份证号
"notes",//备注
"zipCode",
"identityCardPdf",
"businessLicensePdf",
"createuser_id",
"updateuser_id",
"owner_id"],
raw: true
});
}
async findOneByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findOne({
where: {
deliveryOrderNo: deliveryOrderNo
},
attributes: ["id",
"customerType",// ent:企业,person:个人
"customerTypeName",
"identityCardPic",//身份证图片
"businessLicensePic",//营业执照图片
"name",//公司名称或个人名称
"code",//公司统一社会代码
"app_id",
"deliveryOrderNo",
"applyAddr",//申请地址
"applyArea",//存储省市编码
"province",//省
"city",//市
"identityCardNo",//身份证号
"notes",//备注
"zipCode",
"identityCardPdf",
"businessLicensePdf",
"createuser_id",
"updateuser_id",
"owner_id"],
raw: true
});
}
}
module.exports = CustomerInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderFlowDao extends Dao {
constructor() {
super(Dao.getModelName(OrderFlowDao));
}
async getListBySourceOrderNo(sourceOrderNo) {
return this.model.findAll({
where: {
sourceOrderNo: sourceOrderNo,
isShow: 1
},
order:[["created_at", 'desc']],
raw: true
});
}
}
module.exports = OrderFlowDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderTmProductDao extends Dao {
constructor() {
super(Dao.getModelName(OrderTmProductDao));
}
async getTmListByChannelServiceNo(channelServiceNo, appId) {
return this.model.findAll({
where: {
channelServiceNo: channelServiceNo,
app_id: appId
},
raw: true
});
}
async getTmItemByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findOne({
where: {
deliveryOrderNo: deliveryOrderNo
},
raw: true
});
}
async getItemByNeedNoOrderNo(needNoOrderNo, appId, t) {
var sqlWhere = {
where: {
needNoOrderNo: needNoOrderNo,
app_id: appId
},
raw: true
};
if (t) {
sqlWhere.transaction = t;
}
sqlWhere.attributes = ["id",
"deliveryOrderNo",
"payStatus",
"needNo",
"sourceOrderNo",
"tmName",
"tmType",
"tmFormType",
"nclOneCodes",
"deliveryStatus",
"picUrl",
"colorizedPicUrl",
"sywjUrl",
"gzwtsUrl",
"nclCount",
"smwjUrl",
"updateuser_id",
"updateuser",
"notes",
"nclOneCount"
];
return this.model.findOne(sqlWhere);
}
async getItemByChannelServiceNo(channelServiceNo, appId, t) {
var sqlWhere = {
where: {
channelServiceNo: channelServiceNo,
app_id: appId
},
raw: true
};
if (t) {
sqlWhere.transaction = t;
}
sqlWhere.attributes = ["id",
"deliveryOrderNo",
"needNo",
"sourceOrderNo",
"tmName",
"tmType",
"tmFormType",
"nclOneCodes",
"deliveryStatus",
"picUrl",
"colorizedPicUrl",
"sywjUrl",
"gzwtsUrl",
"nclCount",
"smwjUrl",
"updateuser_id",
"updateuser",
"notes",
"nclOneCount"
];
return this.model.findOne(sqlWhere);
}
}
module.exports = OrderTmProductDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class ReceiptVoucherDao extends Dao {
constructor() {
super(Dao.getModelName(ReceiptVoucherDao));
}
async getItemSourceOrderNo(sourceOrderNo) {
return this.model.findAll({
where: {
sourceOrderNo: sourceOrderNo
},
raw: true
});
}
async addReceiptvoucher(orderParams, req, t) {
var param = {
app_id: orderParams.app_id,//
totalSum: orderParams.totalSum || 0,// 订单总额(产品价格×优惠费率×订单件数)
channelServiceNo: orderParams.channelServiceNo,// 渠道服务单号
auditStatus: "tg",
sourceType: "order",
sourceOrderNo: orderParams.orderNo,// 来源订单号
payDate: orderParams.payTime,//
createuser_id: orderParams.createuser_id,
creator: orderParams.creator || "",
accountType: "other",
};
return this.create(param, t);//创建订单
}
}
module.exports = ReceiptVoucherDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class TmOfficialDao extends Dao{
constructor(){
super(Dao.getModelName(TmOfficialDao));
}
async getListByTmRegistNum(tmRegistNum) {
return this.model.findAll({
where: {
tmRegistNum: tmRegistNum
},
raw: true
});
}
}
module.exports=TmOfficialDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class TradeMarkDao extends Dao {
constructor() {
super(Dao.getModelName(TradeMarkDao));
}
async getListByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findAll({
where: {
deliveryOrderNo: deliveryOrderNo
},
raw: true
});
}
}
module.exports = TradeMarkDao;
module.exports = {
"appid": "201911061250",
"label": "知产渠道api应用",
"config": {
"rstree": {
"code": "paasroot",
"label": "paas",
"children": [
// {
// "code": "register",
// "icon": "fa fa-power-off",
// "path": "register",
// "isMenu": false,
// "label": "注册",
// "isctl": "no"
// },
],
},
"bizs": {
},
"pdict": {
"logLevel": { "debug": 0, "info": 1, "warn": 2, "error": 3, "fatal": 4 },
//应用数据操作类型
"app_data_op_type": { "00": "独立", "10": "全委托", "20": "部分委托" },
//支付类型
"app_pay_type": { "00": "第三方支付", "10": "平台代收款" },
//订单类型
"order_type": { "zzdd": "自主订单", "dkxd": "代客下单" },
//订单付款状态
"order_pay_status": { "dfk": "待付款", "zfpz": "已上传支付凭证", "yfk": "已付款", "bfyfk": "部分已付款", "ddqx": "订单取消", "tkclz": "退款处理中", "bfytk": "部分已退款", "ytk": "已退款", "zfshbtg": "支付审核不通过" },
//帐户类型( 支付类型)
"pay_account_type": { "cash": "现金", "bank": "银行", "wx": "微信", "alipay": "支付宝", "other": "其它" },
//订单服务付款状态
"order_service_pay_status": { "dfk": "待付款", "yfk": "已付款" },
//商标交付状态
"delivery_status": { "dqrfa": "待确认方案", "fabtg": "方案不通过", "dfwsfw": "待服务", "dsccl": "待上传材料", "dsh": "待审核", "ddj": "待递交", "ydj": "已递交", "ywc": "已完成" },
//商标类型
"tm_type": { "p": "普通商标", "j": "集体商标", "z": "证明商标", "t": "特殊商标" },
//商标类型形式
"tm_form_type": { "1": "立体", "3": "字", "4": "图", "5": "字图", "6": "颜色", "7": "彩色" },
//商标官文回执类型
"official_receipt_type": {
"1": "商标注册申请书", "2": "商标注册申请补正通知书", "3": "商标注册申请受理通知书", "4": "商标注册申请不予受理通知书", "5": "商标注册同日申请补送使用证据通知书",
"6": "商标注册同日申请协商通知书商标注册同日申请抽签通知书", "7": "商标驳回通知书", "8": "商标部分驳回通知书", "9": "商标注册申请初步审定公告通知书",
"10": "商标异议答辩通知书", "11": "异议裁定书", "12": "纸质版商标注册证", "13": "电子版商标注册证"
},
//商标状态
"official_type": {
"1": "商标注册申请书", "2": "商标注册申请补正通知书", "3": "商标注册申请受理通知书", "4": "商标注册申请不予受理通知书", "5": "商标注册同日申请补送使用证据通知书",
"6": "商标注册同日申请协商通知书商标注册同日申请抽签通知书", "7": "商标驳回通知书", "8": "商标部分驳回通知书", "9": "商标注册申请初步审定公告通知书",
"10": "商标异议答辩通知书", "11": "异议裁定书", "12": "纸质版商标注册证", "13": "电子版商标注册证",
"dsccl": "待上传材料", "dqrfa": "待确认方案", "fabtg": "方案不通过", "dsh": "待审核", "shbtg": "审核不通过", "ddj": "待递交", "ydj": "已递交", "djyc": "递交异常"
},
//申请企业类型
"customer_type": { "ent": "企业", "person": "个人" },
//附件类型
"stuff_type": { "csty": "彩色图样", "wts": "委托书", "gzwts": "盖章委托书", "ty": "图样", "sywj": "声音文件", "smwj": "说明文件" },
//来源类型
"source_type": { "childorders": "子订单", "expensevoucher": "费用单" },
//审核状态
"audit_status": { "dsh": "待审核", "btg": "不通过", "tg": "通过" },
//收款类型
"receipt_type": { "sk": "收款", "csrz": "初始入账", "ptdsk": "平台代收款" },
//退款类型
"refund_type": { "tk": "退款", "ptdtk": "平台代退款" },
//费用类型
"expense_type": { "gf": "官费", "tax": "税金", "channelSettleProfit": "订单渠道分润结算" },
//凭单类型
"direction_type": { "sr": "收", "zc": "支" },
"push_return_type": { "0": "推送失败", "1": "推送成功" },
},
}
}
\ No newline at end of file
module.exports={
"bizName":"oplogs",
"list":{
columnMetaData:[
{"width":"200","label":"应用","prop":"appname","isShowTip":true,"isTmpl":false},
{"width":"200","label":"时间","prop":"created_at","isShowTip":true,"isTmpl":false},
{"width":"100","label":"用户名","prop":"username","isShowTip":true,"isTmpl":false},
{"width":"100","label":"性别","prop":"sex","isShowTip":true,"isTmpl":false},
{"width":"200","label":"行为","prop":"op","isShowTip":true,"isTmpl":false},
{"width":"200","label":"内容","prop":"content","isShowTip":true,"isTmpl":false},
{"width":"200","label":"客户端IP","prop":"clientIp","isShowTip":true,"isTmpl":false},
{"width":"200","label":"客户端环境","prop":"agent","isShowTip":true,"isTmpl":false},
]
},
"form":[
{
"title":"应用名称",
"validProp":"name",
"rule": [
{ "required": true, "message": '请输入应用名称', "trigger": 'blur' },
],
ctls:[
{"type":"input","label":"应用名称","prop":"name","placeHolder":"应用名称","style":""},
]
},
{
"title":"应用ID",
"ctls":[
{"type":"input","label":"应用ID","prop":"appid","disabled":true,"placeHolder":"","style":""},
]
},
],
"search":[
{
"title":"应用名称",
ctls:[
{"type":"input","label":"操作用户","prop":"username","placeHolder":"请模糊输入应用名称","style":""},
]
},
{
"title":"客户环境",
ctls:[
{"type":"input","label":"客户环境","prop":"agent","placeHolder":"请模糊输入客户环境","style":""},
]
},
// {
// "title":"",
// "min":1,
// "max":1,
// ctls:[
// {"type":"check","dicKey":"sex","label":"客户环境","prop":"sex","style":""},
// ]
// },
// <gsb-select v-model="formModel[item.prop]"
// :dicKey="item.dicKey"
// :autoComplete="item.autoComplete"
// :isMulti="item.isMulti"
// :modelName="item.modelName"
// :isFilter="item.isFilter"
// :labelField="item.labelField"
// :valueField="item.valueField"></gsb-select>
{
"title":"性别",
ctls:[
{"type":"select","dicKey":"sex","label":"性别","prop":"sex","labelField":"label","valueField":"value","style":""},
]
},
],
"auth":{
"add":[
],
"edit":[
],
"delete":[
{"icon":"el-icon-remove","title":"删除","type":"default","key":"delete","isOnGrid":true},
],
"common":[
],
}
}
const fs=require("fs");
const path=require("path");
const appsPath=path.normalize(__dirname+"/apps");
const bizsPath=path.normalize(__dirname+"/bizs");
var appJsons={
}
function getBizFilePath(appJson,bizCode){
const filePath=bizsPath+"/"+"bizjs"+"/"+bizCode+".js";
return filePath;
}
//异常日志处理todo
function initAppBizs(appJson){
for(var bizCode in appJson.config.bizs)
{
const bizfilePath=getBizFilePath(appJson,bizCode);
try{
delete require.cache[bizfilePath];
const bizConfig=require(bizfilePath);
appJson.config.bizs[bizCode].config=bizConfig;
}catch(e){
console.log("bizconfig meta file not exist........");
}
}
return appJson;
}
//初始化资源树--objJson是rstree
function initRsTree(appjson,appidfolder,objJson,parentCodePath){
if(!parentCodePath){//说明当前是根结点
objJson.codePath=objJson.code;
}else{
objJson.codePath=parentCodePath+"/"+objJson.code;
}
if(objJson["bizCode"]){//表示叶子节点
objJson.auths=[];
if(appjson.config.bizs[objJson["bizCode"]]){
objJson.bizConfig=appjson.config.bizs[objJson["bizCode"]].config;
objJson.path=appjson.config.bizs[objJson["bizCode"]].path;
appjson.config.bizs[objJson["bizCode"]].codepath=objJson.codePath;
}
}else{
if(objJson.children){
objJson.children.forEach(obj=>{
initRsTree(appjson,appidfolder,obj,objJson.codePath);
});
}
}
}
fs.readdirSync(appsPath).forEach(f=>{
const ff=path.join(appsPath,f);
delete require.cache[ff];
var appJson=require(ff);
appJson= initAppBizs(appJson);
initRsTree(appJson,appJson.appid,appJson.config.rstree,null);
appJsons[appJson.appid]=appJson;
});
module.exports=appJsons;
module.exports={
"appid":"wx76a324c5d201d1a4",
"label":"企业服务工具箱",
"config":{
"rstree":{
"code":"toolroot",
"label":"工具箱",
"children":[
{
"code":"toggleHeader",
"icon":"el-icon-sort",
"isMenu":true,
"label":"折叠",
},
{
"code":"personCenter",
"label":"个人信息",
"src":"/imgs/logo.png",
"isSubmenu":true,
"children":[
{"code":"wallet","isGroup":true,"label":"账户","children":[
{"code":"mytraderecord","label":"交易记录","isMenu":true,"bizCode":"trades","bizConfig":null,"path":""},
{"code":"smallmoney","label":"钱包","isMenu":true,"bizCode":"oplogs","bizConfig":null,"path":""},
{"code":"fillmoney","label":"充值","isMenu":true,},
]},
{"code":"tool","isGroup":true,"label":"工具","children":[
{"code":"entconfirm","label":"企业用户认证","isMenu":true,"bizCode":"apps","bizConfig":null,"path":""},
{"code":"fav","label":"收藏夹","isMenu":true,"bizCode":"fav","bizConfig":null,"path":""},
{"code":"filebox","label":"文件柜","isMenu":true,"bizCode":"filebox","bizConfig":null,"path":""},
]},
],
},
{
"code":"fillmoney",
"icon":"fa fa-money",
"isMenu":true,
"label":"充值",
},
{
"code":"platformop",
"label":"平台运营",
"icon":"fa fa-cubes",
"isSubmenu":true,
"children":[
{"code":"papp","isGroup":true,"label":"平台数据","children":[
{"code":"papparch","label":"应用档案","isMenu":true,"bizCode":"apps","bizConfig":null,"path":""},
{"code":"userarch","label":"用户档案","isMenu":true,"bizCode":"pusers","bizConfig":null,"path":""},
{"code":"traderecord","label":"交易记录","isMenu":true,"bizCode":"trades","bizConfig":null,"qp":"my","path":""},
{"code":"pconfigs","label":"平台配置","isMenu":true,"bizCode":"pconfigs","bizConfig":null,"qp":"my","path":""},
]},
{"code":"pop","isGroup":true,"label":"平台运维","children":[
{"code":"cachearch","label":"缓存档案","isMenu":true,"bizCode":"cachearches","bizConfig":null,"path":""},
{"code":"oplogmag","label":"行为日志","isMenu":true,"bizCode":"oplogs","bizConfig":null,"path":""},
{"code":"machinearch","label":"机器档案","isMenu":true,"bizCode":"machines","bizConfig":null,"path":""},
{"code":"codezrch","label":"代码档案","isMenu":true,"bizCode":"codezrch","bizConfig":null,"path":""},
{"code":"imagearch","label":"镜像档案","isMenu":true},
{"code":"containerarch","label":"容器档案","isMenu":true},
]},
],
},
{
"code":"sysmag",
"label":"系统管理",
"icon":"fa fa-cube",
"isSubmenu":true,
"children":[
{"code":"usermag","isGroup":true,"label":"用户管理","children":[
{"code":"rolearch","label":"角色档案","isMenu":true,"bizCode":"roles","bizConfig":null},
{"code":"appuserarch","label":"用户档案","isMenu":true,"bizCode":"appusers","bizConfig":null},
]},
{"code":"productmag","isGroup":true,"label":"产品管理","children":[
{"code":"productarch","label":"产品档案","bizCode":"mgproducts","isMenu":true,"bizConfig":null},
{"code":"products","label":"首页产品档案","bizCode":"products","isMenu":false,"bizConfig":null},
]},
],
},
{
"code":"exit",
"icon":"fa fa-power-off",
"isMenu":true,
"label":"退出",
},
{
"code":"toolCenter",
"label":"工具集",
"src":"/imgs/logo.png",
"isSubmenu":false,
"isMenu":false,
"children":[
{"code":"tools","isGroup":true,"label":"查询工具","children":[
{"code":"xzquery","label":"续展查询","bizCode":"xzsearch","bizConfig":null,"path":""},
{"code":"xzgqquery","label":"续展过期查询","bizCode":"xzgqsearch","bizConfig":null,"path":""},
]},
],
},
],
},
"bizs":{
"cachearches":{"title":"首页产品档案","config":null,"path":"/platform/cachearches","comname":"cachearches"},
"products":{"title":"首页产品档案","config":null,"path":"/","comname":"products"},
"mgproducts":{"title":"产品档案","config":null,"path":"/platform/mgproducts","comname":"mgproducts"},
"codezrch":{"title":"代码档案","config":null,"path":"/platform/codezrch","comname":"codezrch"},
"machines":{"title":"机器档案","config":null,"path":"/platform/machines","comname":"machines"},
"pconfigs":{"title":"平台配置","config":null,"path":"/platform/pconfigs","comname":"pconfigs"},
"apps":{"title":"应用档案","config":null,"path":"/platform/apps","comname":"apps"},
"roles":{"title":"角色档案","config":null,"path":"/platform/roles","comname":"roles"},
"pusers":{"title":"平台用户档案","config":null,"path":"/platform/pusers","comname":"users"},
"appusers":{"title":"某应用用户档案","config":null,"path":"/platform/appusers","comname":"users"},
"oplogs":{"title":"行为日志","config":null,"path":"/platform/op/oplogs","comname":"oplogs"},
"trades":{"title":"交易记录","config":null,"path":"/platform/uc/trades","comname":"trades"},
"xzsearch":{"title":"续展查询","config":null,"isDynamicRoute":true,"path":"/products/xzsearch","comname":"xzsearch"},
"xzgqsearch":{"title":"续展过期查询","config":null,"isDynamicRoute":true,"path":"/products/xzgqsearch","comname":"xzgqsearch"},
},
"pauths":[
"add","edit","delete","export","show"
],
"pdict":{
"sex":{"male":"男","female":"女"},
"configType":{"price":"宝币兑换率","initGift":"初次赠送"},
"productCata":{"ip":"知产","ic":"工商","tax":"财税","hr":"人力","common":"常用"},
"logLevel":{"debug":0,"info":1,"warn":2,"error":3,"fatal":4},
"tradeType":{"fill":"充值","consume":"消费","gift":"赠送","giftMoney":"红包","refund":"退款"},
"tradeStatus":{"unSettle":"未结算","settled":"已结算"}
}
}
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("oplog", {
appid: DataTypes.STRING,
appkey: DataTypes.STRING,
requestId: DataTypes.STRING,
logLevel: {
type: DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.logLevel),
defaultValue: "info",
},
op: DataTypes.STRING,
content: DataTypes.STRING(5000),
resultInfo: DataTypes.TEXT('long'),
clientIp: DataTypes.STRING,
agent: {
type: DataTypes.STRING,
allowNull: true,
},
opTitle: DataTypes.TEXT,
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_op_log',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("pushlog", {
appid: DataTypes.STRING,
appkey: DataTypes.STRING,
requestId: DataTypes.STRING,
logLevel: {
type: DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.logLevel),
defaultValue: "info",
},
op: DataTypes.STRING,
content: DataTypes.TEXT,
resultInfo: DataTypes.TEXT('long'),
returnTypeName:DataTypes.STRING,
returnType : {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.push_return_type),
set: function (val) {
this.setDataValue("returnType", val);
this.setDataValue("returnTypeName", uiconfig.config.pdict.push_return_type[val]);
},
defaultValue: "0",
}, //数据推送返回结果类型 push_return_type:{"0":"失败","1":"成功"}
clientIp: DataTypes.STRING,
agent: {
type: DataTypes.STRING,
allowNull: true,
},
opTitle: DataTypes.STRING(500),
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_push_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}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("app", {
name: DataTypes.STRING(100), // 应用名称
appDataOpType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type),
}, // 应用数据操作类型:00独立,10全委托,20部分委托
appPayType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_pay_type),
}, // 支付类型:00第三方支付,10平台代收款
contactName : DataTypes.STRING(30), // 联系人姓名
contactMobile: DataTypes.STRING(30), // 联系人手机
contactEmail : DataTypes.STRING(30), // 联系人邮箱
uappKey : DataTypes.STRING(64), // 平台应用key
uAppId : DataTypes.INTEGER, //
appSecret : DataTypes.STRING(64), // 密钥信息,用于进行签名请求接口
status : DataTypes.INTEGER, // 状态 0禁用 1启用
channelAppId : DataTypes.STRING(64), // 渠道appID
channelAppKey: DataTypes.STRING(64), // 渠道appKey
pushOrderUrl : DataTypes.STRING(500), // 获取渠道推送订单的url
appSourceCode : DataTypes.STRING(50), // app来源code
notes : DataTypes.STRING, // 备注
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_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 uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("appproduct", {
app_id :DataTypes.STRING(50),// 应用id
itemCode :DataTypes.STRING(100),// 产品编码
itemName :DataTypes.STRING(100),// 产品名称
picUrl :DataTypes.STRING(500),// 产品图片地址
channelItemCode :DataTypes.STRING(100),// 渠道产品编码
channelItemName :DataTypes.STRING(100),// 渠道产品名称
serviceItemCode :DataTypes.STRING(100),// 服务商产品编码
pushServiceItemCode :DataTypes.STRING(100),// 推送到服务商的产品编码
status :DataTypes.BOOLEAN,// 状态 0禁用 1启用
verifyPrice :DataTypes.BOOLEAN,// 是否验证价格 0不验证 1验证
proPrice :DataTypes.DOUBLE,// 产品价格
serviceCharge :DataTypes.DOUBLE,// 服务费
publicExpense :DataTypes.DOUBLE,// 官费
rateConfig :DataTypes.DECIMAL(12, 2),// 税率
discountsRateConfig :DataTypes.DECIMAL(12, 2),// 优惠税率
channelProfitRate :DataTypes.DECIMAL(12, 2),// 渠道利润分成比率(只分订单中毛利润总额的分成)
sort :DataTypes.INTEGER,// 排序
productType_id :DataTypes.INTEGER,// 产品类型Id
productOneType_id :DataTypes.INTEGER,// 产品大类Id
deliveryUrl:DataTypes.STRING(500),// 交付地址
productLogo:DataTypes.STRING(500),// 产品logo
productDesc:DataTypes.STRING(1024),// 产品描述
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app_product',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("appuser", {
app_id : DataTypes.INTEGER, // 应用id
channelUserId : DataTypes.STRING(64), // 渠道用户ID
channelUserName : DataTypes.STRING(64), // 渠道用户登录名
uUserName : DataTypes.STRING(64), //
uAppId : DataTypes.INTEGER, //
userMoblie : DataTypes.STRING(20), // 用户手机号
nickname : DataTypes.STRING(50), // 昵称
orgName : DataTypes.STRING(255), // 组织结构名称
orgPath : DataTypes.STRING(255), // 组织结构路径
isEnabled : DataTypes.INTEGER, // 是否启用
loginNum : DataTypes.INTEGER, // 登录次数
lastLoginTime : DataTypes.DATE, // 上次登录时间
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app_user',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("moneyaccount", {
app_id: DataTypes.INTEGER, // 是否显示
balance: {//余额
type: DataTypes.DECIMAL(12, 3),
defaultValue: 0.00,
},
accountType: {
//帐户类型:"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.pay_account_type),
set: function (val) {
this.setDataValue("accountType", val);
this.setDataValue("accountTypeName", uiconfig.config.pdict.pay_account_type[val]);
},
defaultValue: "other",
},
accountTypeName: {//帐户类型名称
type: DataTypes.STRING(50),
defaultValue: "其它",
},
payeeName: {
type: DataTypes.STRING(100),
},//收款人姓名
certificateNo: DataTypes.STRING(100),//帐号
bankAddr: DataTypes.STRING(500), //银行地址
description: DataTypes.STRING,//描述
isOfflinePay: {//是否支持线下支付,0否,1是
type: DataTypes.BOOLEAN,
defaultValue: false,
},
transferRate: {//商户收款费率,千分率,如:值为5,计算时除以1000(第三方公司收款账户有此值)
type: DataTypes.DECIMAL(12, 2),
defaultValue: 5.00,
},
bankToPtTransferRate: {//银行收平台费率,千分率,如:值为2.6,计算时除以1000(平台公司收款账户有此值)
type: DataTypes.DECIMAL(12, 2),
defaultValue: 0,
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_moneyaccount',
validate: {
},
indexes: [
]
});
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("flowlog", {
uapp_id: DataTypes.INTEGER, //
sourceOrderNo: DataTypes.STRING(64), // 来源单号
opContent: DataTypes.STRING(1024), // 操作描述
notes: DataTypes.STRING, // 备注
isShow: {//是否显示
type: DataTypes.BOOLEAN,
defaultValue: false,
},
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_flow_log',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("ordercontacts", {
uapp_id :DataTypes.INTEGER, //
sourceOrderNo :DataTypes.STRING(64),//来源单号
contactName :DataTypes.STRING(1000), // 联系人
mobile :DataTypes.STRING(20), //
email :DataTypes.STRING(50), //
tel :DataTypes.STRING(20), //
fax :DataTypes.STRING(50), //
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_order_contacts',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("orderinfo", {
uapp_id :DataTypes.INTEGER,//
orderNo :DataTypes.STRING(64),// 订单号
channelServiceNo :DataTypes.STRING(64),// 渠道服务单号
channelOrderNo :DataTypes.STRING(1024),// 渠道订单号列表,多个以,隔开
channelUserId :DataTypes.STRING(64), // 渠道用户ID
ownerUserId :DataTypes.STRING(20),// 拥有渠道用户ID
needNo :DataTypes.STRING(64), // 需求单号
needNoOrderNo :DataTypes.STRING(64), // 需求订单号
payTime :DataTypes.DATE,// 渠道有支付时间则用渠道的支付时间
quantity :DataTypes.INTEGER,// 订单数量(即产品的倍数,默认值为1)
serviceQuantity :DataTypes.INTEGER,// 订单服务数量(即与订单数量相对应)
orderPayStatusName :DataTypes.STRING(50),//
orderPayStatus :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_pay_status),
set: function (val) {
this.setDataValue("orderPayStatus", val);
this.setDataValue("orderPayStatusName", uiconfig.config.pdict.order_pay_status[val]);
}
},// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, bfyfk: 部分已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalSum :DataTypes.DECIMAL(12, 2),// 订单总额(产品价格×优惠费率×订单件数)
payTotalSum :DataTypes.DECIMAL(12, 2),// 订单付款总额
refundSum :DataTypes.DECIMAL(12, 2),// 退款金额
totalServiceCharge :DataTypes.DECIMAL(12, 2),// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense :DataTypes.DECIMAL(12, 2),// 官费总额(产品配置的官费*订单件数)
totalProfitSum :DataTypes.DECIMAL(12, 2),// 订单毛利润总额(订单总额-官费总额)
totalDiscounts :DataTypes.DECIMAL(12, 2),// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
pfProfitSum :DataTypes.DECIMAL(12, 2),// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum :DataTypes.DECIMAL(12, 2),// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
pfSettleProfit :DataTypes.INTEGER,// 平台结算渠道利润,0否,1是
invoiceApplyStatus :DataTypes.STRING(10),// 发票状态:00: 未申请, 10: 已申请,20:已开票
opNotes :DataTypes.STRING,// 备注
notes :DataTypes.STRING,// 备注
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_order_info',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("orderproduct", {
uapp_id: DataTypes.INTEGER,//
sourceOrderNo :DataTypes.STRING(64),//来源单号
productType_id :DataTypes.INTEGER,//产品类型Id
productOneType_id :DataTypes.INTEGER,//产品大类Id
itemCode :DataTypes.STRING(64),//产品编码
itemName :DataTypes.STRING(100),//产品名称
channelItemCode :DataTypes.STRING(100),// 渠道产品编码
channelItemName :DataTypes.STRING(100),// 渠道产品名称
serviceItemCode :DataTypes.STRING(100),// 服务商产品编码
picUrl :DataTypes.STRING(500),// 产品图片地址
proPrice :DataTypes.DOUBLE, // 产品价格
quantity :DataTypes.INTEGER,// 订单数量(即产品的倍数,默认值为1)
opPayType :DataTypes.STRING(10),// 操作付款类型:00: 创建订单, 10: 补单
serviceItemSnapshot :DataTypes.TEXT('long'), //产品快照
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_order_product',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {//费用单:
return db.define("expensevoucher", {
uapp_id: DataTypes.INTEGER, //
sourceOrderNo: DataTypes.STRING(64), // 来源单号
expenseTypeName: DataTypes.STRING,
expenseType: {//收款类型,gf: 官费, tax: 税金, channelSettleProfit: 订单渠道分润结算
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.expense_type),
set: function (val) {
this.setDataValue("expenseType", val);
this.setDataValue("expenseTypeName", uiconfig.config.pdict.expense_type[val]);
}
},
totalSum: DataTypes.DECIMAL(12, 3),//总额
notes: DataTypes.STRING,//备注
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_expensevoucher',
validate: {
}
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("moneyjourney", {
uapp_id: DataTypes.INTEGER, //
sourceOrderNo: DataTypes.STRING(64), // 来源单号
channelUserId: DataTypes.STRING(64), // 渠道用户ID
ownerUserId: DataTypes.STRING(20),// 拥有渠道用户ID
accountType: {
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.pay_account_type),
set: function (val) {
this.setDataValue("accountType", val);
this.setDataValue("accountTypeName", uiconfig.config.pdict.pay_account_type[val]);
}
},
accountTypeName: {//帐户类型名称
type: DataTypes.STRING,
},
directionTypeName: DataTypes.STRING,
directionType: {//凭单类型,"sr": "收","zc": "支"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.direction_type),
set: function (val) {
this.setDataValue("directionType", val);
this.setDataValue("directionTypeName", uiconfig.config.pdict.direction_type[val]);
}
},
voucherDate: DataTypes.DATE,//凭单时间
recvAmount: DataTypes.DECIMAL(12, 3),//收总额
payAmount: DataTypes.DECIMAL(12, 3),//支总额
sourceTypeName: DataTypes.STRING,
sourceType: {//来源类型 "orderinfo": "订单","expensevoucher": "费用单"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.source_type),
set: function (val) {
this.setDataValue("sourceType", val);
this.setDataValue("sourceTypeName", uiconfig.config.pdict.source_type[val]);
}
},
auditStatusName: {
type: DataTypes.STRING(50),
defaultValue: "待审核",
},
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.audit_status),
set: function (val) {
this.setDataValue("auditStatus", val);
this.setDataValue("auditStatusName", uiconfig.config.pdict.audit_status[val]);
},
defaultValue: "dsh",
},
notes: DataTypes.STRING,//备注
opNotes: DataTypes.STRING,//操作备注
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_moneyjourney',
validate: {
}
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("orderreceiptvoucher", {//收款单:
uapp_id: DataTypes.INTEGER, //
sourceOrderNo: DataTypes.STRING(64), // 来源单号
accountType: {
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.pay_account_type),
set: function (val) {
this.setDataValue("accountType", val);
this.setDataValue("accountTypeName", uiconfig.config.pdict.pay_account_type[val]);
}
},
accountTypeName: {//帐户类型名称
type: DataTypes.STRING,
},
payDate: DataTypes.DATE,//支付时间
totalSum: DataTypes.DECIMAL(12, 3),//订单总额
payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
buyerOpenId: DataTypes.STRING,//用户在支付商户appid下的唯一标识或买家在支付宝的用户id
passTradeNo: DataTypes.STRING,//通道的统一订单号
buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
certifyFileUrl: DataTypes.STRING(500), //支付证明文件Url
wxPayOrderCode: DataTypes.STRING(64),//业务微信支付订单号
aliPayOrderCode: DataTypes.STRING(50),//业务支付宝支付订单号
busPayOrderCode: DataTypes.STRING(50),//业务支付订单号
auditStatusName: {
type: DataTypes.STRING(50),
defaultValue: "待审核",
},
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.audit_status),
set: function (val) {
this.setDataValue("auditStatus", val);
this.setDataValue("auditStatusName", uiconfig.config.pdict.audit_status[val]);
},
defaultValue: "dsh",
},
notes: DataTypes.STRING,//备注
opNotes: DataTypes.STRING,//操作备注
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_order_receiptvoucher',
validate: {
}
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("orderrefundvoucher", {//退款单:
uapp_id: DataTypes.INTEGER, //
sourceOrderNo: DataTypes.STRING(64), // 来源单号
busPayOrderCode: DataTypes.STRING(100),//业务支付订单号
accountType: {
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.pay_account_type),
set: function (val) {
this.setDataValue("accountType", val);
this.setDataValue("accountTypeName", uiconfig.config.pdict.pay_account_type[val]);
}
},
accountTypeName: {//帐户类型名称
type: DataTypes.STRING,
},
payDate: DataTypes.DATE,//支付时间
totalSum: DataTypes.DECIMAL(12, 3),//总额
certifyFileUrl: DataTypes.STRING(500), //证明文件Url
payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
buyerOpenId: DataTypes.STRING,//用户在支付商户appid下的唯一标识或买家在支付宝的用户id
passTradeNo: DataTypes.STRING,//通道的统一订单号
buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
auditStatusName: {
type: DataTypes.STRING(50),
defaultValue: "待审核",
},
auditStatus: {//审核状态"dsh": "待审核", "btg": "不通过", "tg": "通过"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.audit_status),
set: function (val) {
this.setDataValue("auditStatus", val);
this.setDataValue("auditStatusName", uiconfig.config.pdict.audit_status[val]);
},
defaultValue: "dsh",
},
notes: DataTypes.STRING,//备注
opNotes: DataTypes.STRING,//操作备注
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'c_order_refundvoucher',
validate: {
}
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("needinfo", {
app_id :DataTypes.INTEGER, //
needNo :DataTypes.STRING(64), //需求单号
needDesc :DataTypes.STRING(255), //
needUserMoblie :DataTypes.STRING(20), //
notes :DataTypes.STRING(255), //
opNotes :DataTypes.STRING(500), //
channelUserName :DataTypes.STRING(50), // 渠道用户登录名
auditStatus :DataTypes.STRING(10), //确认状态:00待确认,10确认通过,20确认不通过
createuser_id :DataTypes.INTEGER, //
updateuser_id :DataTypes.INTEGER, //
owner_id :DataTypes.INTEGER, //
creator :DataTypes.STRING(50), //
updator :DataTypes.STRING(50), //
owner :DataTypes.STRING(50), //
ownerMoblie :DataTypes.STRING(20), //
itemCode :DataTypes.STRING(80), //产品码
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_needinfo',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("customercontacts", {
app_id :DataTypes.INTEGER, //
customerinfo_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号
mobile :DataTypes.STRING(20), //
email :DataTypes.STRING(50), //
tel :DataTypes.STRING(20), //
fax :DataTypes.STRING(50), //
name :DataTypes.STRING(1000), // 联系人
code :DataTypes.STRING(100), // 暂时没有用
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_customercontacts',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("customerinfo", {
customerTypeName :DataTypes.STRING(50), //
customerType : {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.customer_type),
set: function (val) {
this.setDataValue("customerType", val);
this.setDataValue("customerTypeName", uiconfig.config.pdict.customer_type[val]);
},
defaultValue: "0",
}, //申请企业类型: ent:企业,person:个人
identityCardPic :DataTypes.STRING(500), // 身份证图片
identityCardPdf :DataTypes.STRING(500), // 身份证pdf
businessLicensePic :DataTypes.STRING(500), // 营业执照图片
businessLicensePdf :DataTypes.STRING(500), // 营业执照pdf
name :DataTypes.STRING(1000), // 公司名称或个人名称
code :DataTypes.STRING(100), // 公司统一社会代码
app_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号
applyAddr :DataTypes.STRING, // 申请地址
applyArea :DataTypes.STRING(50), // 存储省市编码
province :DataTypes.STRING(50), // 省
city :DataTypes.STRING(50), // 市
identityCardNo :DataTypes.STRING(50), // 身份证号
notes :DataTypes.STRING, // 备注
createuser_id :DataTypes.INTEGER, //
updateuser_id :DataTypes.INTEGER, //
owner_id :DataTypes.INTEGER, // 拥有者
zipCode :DataTypes.STRING(20), //
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_customerinfo',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("order", {
app_id :DataTypes.INTEGER,//
orderNo :DataTypes.STRING(64),// 订单号
channelServiceNo :DataTypes.STRING(64),// 渠道服务单号
channelOrderNo :DataTypes.STRING(1024),// 渠道订单号列表,多个以,隔开
itemCode :DataTypes.STRING(64),//
itemName :DataTypes.STRING(100),//
channelItemCode :DataTypes.STRING(64),// 渠道产品编码
channelItemName :DataTypes.STRING,// 渠道产品名称
payTime :DataTypes.DATE,// 渠道有支付时间则用渠道的支付时间
salesNum :DataTypes.INTEGER,// 项目订单数量(即服务项目的倍数,默认值为1)
salesDiliverNum :DataTypes.INTEGER,// 项目订单交付数量(即与项目订单数量相对应)
minitermNum :DataTypes.INTEGER,// 订单小项数量
minitermDiliverNum :DataTypes.INTEGER,// 订单小项交付数量
orderType :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_type),
},// 订单类型,zzdd: 自主订单,dkxd: 代客下单
orderPayStatusName: DataTypes.STRING(50),//
orderPayStatus :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_pay_status),
set: function (val) {
this.setDataValue("orderPayStatus", val);
this.setDataValue("orderPayStatusName", uiconfig.config.pdict.order_pay_status[val]);
}
},// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalServiceCharge :DataTypes.DECIMAL(12, 2),// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense :DataTypes.DECIMAL(12, 2),// 官费总额(产品配置的官费*订单件数)
totalDiscounts :DataTypes.DECIMAL(12, 2),// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
totalTaxes :DataTypes.DECIMAL(12, 2),// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalSum :DataTypes.DECIMAL(12, 2),// 订单总额(产品价格×优惠费率×订单件数)
refundSum :DataTypes.DECIMAL(12, 2),// 退款金额
totalProfitSum :DataTypes.DECIMAL(12, 2),// 订单毛利润总额(订单总额-官费总额)
pfProfitSum :DataTypes.DECIMAL(12, 2),// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum :DataTypes.DECIMAL(12, 2),// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
pfSettleProfit :DataTypes.DECIMAL(12, 2),// 平台结算渠道利润,0否,1是
opNotes :DataTypes.STRING,// 备注
notes :DataTypes.STRING,// 备注
appPayType :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_pay_type),
},// 支付类型:00第三方支付,10平台代收款
createuser_id :DataTypes.INTEGER,//
updateuser_id :DataTypes.INTEGER,//
owner_id :DataTypes.INTEGER,//
creator :DataTypes.STRING(100),//
updator :DataTypes.STRING(100),//
owner :DataTypes.STRING(100),//
ownerMoblie :DataTypes.STRING(20),//
invoiceApplyStatus :DataTypes.STRING(10),// 发票状态:00: 未申请, 10: 已申请,20:已开票
channelUserId :DataTypes.STRING(64), // 渠道用户ID
needNo :DataTypes.STRING(64), // 需求单号
needNoOrderNo :DataTypes.STRING(64), // 需求订单号
sourceType: DataTypes.STRING(10),//来源类型:00订单,10需求需要用户确认方案
picUrl :DataTypes.STRING(500),// 产品图片地址
productType_id :DataTypes.INTEGER, //产品类型Id
productOneType_id :DataTypes.INTEGER, //产品大类Id
serviceItemSnapshot :DataTypes.TEXT, //产品快照
buyerMoblie :DataTypes.STRING(64), // 买家手机号
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_order',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("orderflow", {
sourceOrderNo: DataTypes.STRING(64), // 来源单号
opContent: DataTypes.STRING(1024), // 操作描述
app_id: DataTypes.INTEGER, //
notes: DataTypes.STRING, // 备注
createuser_id: DataTypes.INTEGER, //
isShow: {//是否显示
type: DataTypes.BOOLEAN,
defaultValue: false,
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_orderflow',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("ordertmproduct", {
app_id: DataTypes.INTEGER,//
productType_id: DataTypes.INTEGER,//产品类型Id
productOneType_id: DataTypes.INTEGER,//产品大类Id
itemCode: DataTypes.STRING(64),//产品编码
itemName: DataTypes.STRING(100),//产品名称
tmName: DataTypes.STRING(1000),//商标名称
tmType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.tm_type),
},//p:普通商标,j:集体商标,z:证明商标,t:特殊商标
tmFormTypeName: DataTypes.STRING(50),//
tmFormType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.tm_form_type),
set: function (val) {
this.setDataValue("tmFormType", val);
this.setDataValue("tmFormTypeName", uiconfig.config.pdict.tm_form_type[val]);
}
},//商标类型形式:1:立体,3:字,4:图,5:字图,6:颜色,7:彩色
nclOneCodes: DataTypes.STRING,//尼斯大类列表:格式以,隔开
payStatusName: DataTypes.STRING(50),//
payStatus: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_service_pay_status),
set: function (val) {
this.setDataValue("payStatus", val);
this.setDataValue("payStatusName", uiconfig.config.pdict.order_service_pay_status[val]);
}
},//支付状态:dfk:待付款,yzf:已支付
deliveryStatusName: DataTypes.STRING(50),//
deliveryStatus: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.delivery_status),
set: function (val) {
this.setDataValue("deliveryStatus", val);
this.setDataValue("deliveryStatusName", uiconfig.config.pdict.delivery_status[val]);
}
},//商标交付状态:dsccl:待上传材料,dsh:待审核,ddj:待递交, ydj: 已递交,ywc:已完成
appDataOpType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type),
},//应用数据操作类型:00独立,10全委托,20部分委托
sourceOrderNo: DataTypes.STRING(64),//来源单号
deliveryOrderNo: DataTypes.STRING(64),//交付订单号
channelServiceNo: DataTypes.STRING(64),//渠道服务单号
channelOrderNo: DataTypes.STRING(1024),//渠道订单号列表,多个以,隔开
needNo: DataTypes.STRING(64),//需求单号
needNoOrderNo :DataTypes.STRING(64), // 需求订单号
sourceType: DataTypes.STRING(10),//来源类型:00订单,10需求需要用户确认方案
picUrl: DataTypes.STRING(500), //商标图样
colorizedPicUrl: DataTypes.STRING(500),//商标彩色图样
gzwtsUrl: DataTypes.STRING(500), //盖章委托书
sywjUrl: DataTypes.STRING(500), //声音文件
smwjUrl: DataTypes.STRING(500), //说明文件
channelUserId: DataTypes.STRING(64),//渠道用户ID
notes: DataTypes.STRING(255),//备注
createuser_id: DataTypes.INTEGER,//
updateuser_id: DataTypes.INTEGER,//
auditor_id: DataTypes.INTEGER,//
createuser: DataTypes.STRING(100),//
updateuser: DataTypes.STRING(100),//
auditor: DataTypes.STRING(100),//
nclOneCount: DataTypes.INTEGER, // 尼斯大类数量
nclCount: DataTypes.INTEGER, // 尼斯数量
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_order_tm_product',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
var base = require("../../basemodel/voucherbase")(db, DataTypes);
return db.define("receiptvoucher", Object.assign({//收款单:
//基类 code: 收款单号(自动生成)
//基类 creator: 创建者
//基类 updator:/更新者
//基类 auditor: 审核者
//基类 opNotes: 操作备注
//基类 auditStatusName: //审核状态名称
//基类 auditStatus: //审核状态:ENUM=audit_status,"dsh": "待审核", "btg": "不通过", "tg": "通过"
//基类 sourceTypeName: //来源类型名称
//基类 sourceType: //来源类型:ENUM=source_type,"order": "订单","expensevoucher": "费用单","receiptvoucher": "收款单","refundvoucher": "退款单", "trademark": "商标单"
//基类 sourceOrderNo: DataTypes.STRING,//来源单号(如:订单号等)
//基类 channelServiceNo //渠道服务单号
createapp_id: DataTypes.INTEGER,//
payuser_id: DataTypes.INTEGER,//
busPayOrderCode: DataTypes.STRING(100),//业务支付订单号
payOrderNo: DataTypes.STRING, //支付凭证流水单号,如:微信支付凭证单号
receiptTypeName: DataTypes.STRING,
receiptType: {//收款类型,"sk": "收款","csrz": "初始入账" ,"ptdsk": "平台代收款"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.receipt_type),
set: function (val) {
this.setDataValue("receiptType", val);
this.setDataValue("receiptTypeName", uiconfig.config.pdict.receipt_type[val]);
}
},
accountType: {
//帐户类型( 支付类型):"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.pay_account_type),
set: function (val) {
this.setDataValue("accountType", val);
this.setDataValue("accountTypeName", uiconfig.config.pdict.pay_account_type[val]);
},
defaultValue: "other",
},
accountTypeName: {//帐户类型名称
type: DataTypes.STRING,
defaultValue: "其它",
},
payDate: DataTypes.DATE,//支付时间
totalSum: DataTypes.DECIMAL(12, 3),//订单总额(平台费用+服务费+官费+发票税费+个人利润+平台利润)
certifyFileUrl: DataTypes.STRING(500), //证明文件Url
notes: DataTypes.STRING,//备注
itemCode: DataTypes.STRING(100),//项目操作码
itemName: DataTypes.STRING(100),//项目名称
buyerOpenId: DataTypes.STRING,//用户在商户appid下的唯一标识或买家在支付宝的用户id
passTradeNo: DataTypes.STRING,//通道的统一订单号
buyerAliLogonId: DataTypes.STRING,//买家支付宝账号
}, base), {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
//freezeTableName: true,
// define the table's name
tableName: 'b_receiptvoucher',
validate: {
}
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("tmofficial", {
tmRegistNum :DataTypes.STRING(50), //注册号
officialTypeName :DataTypes.STRING(50), //
officialType : {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.official_type),
set: function (val) {
this.setDataValue("officialType", val);
this.setDataValue("officialTypeName", uiconfig.config.pdict.official_type[val]);
}
}, //商标官文类型:1: 商标注册申请书, 2: 商标注册申请补正通知书, 3: 商标注册申请受理通知书, 4: 商标注册申请不予受理通知书,
//5: 商标注册同日申请补送使用证据通知书,6: 商标注册同日申请协商通知书商标注册同日申请抽签通知书,
//7: 商标驳回通知书, 8: 商标部分驳回通知书, 9: 商标注册申请初步审定公告通知书,
//10: 商标异议答辩通知书, 11: 异议裁定书, 12: 纸质版商标注册证, 13: 电子版商标注册证
officialFileName :DataTypes.STRING(200), // 官文文件名称
officialFileUrl :DataTypes.STRING(255), // 官文文件地址
notes :DataTypes.STRING , //
name :DataTypes.STRING(1000), //暂时没有用
code :DataTypes.STRING(64), //官文单号(自动生成)
app_id :DataTypes.INTEGER, //
createuser_id :DataTypes.INTEGER, //
updateuser_id :DataTypes.INTEGER, //
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_tmofficial',
validate: {
},
indexes: [
]
});
}
const system=require("../system")
const logCtl=system.getObject("web.common.oplogCtl");
class TaskBase{
constructor(className){
this.redisClient=system.getObject("util.redisClient");
this.serviceName=className;
}
async doTask(){
try {
await this.subDoTask();
//日志记录
logCtl.info({
optitle:this.serviceName+",任务成功执行完成",
op:"base/db/task.base.js",
content:"",
clientIp:""
});
} catch (e) {
//日志记录
logCtl.error({
optitle:this.serviceName+"任务执行异常",
op:"base/db/task.base.js",
content:e.stack,
clientIp:""
});
}
}
async subDoTask(){
console.log("请在子类中重写此方法进行操作业务逻辑............................!");
}
static getServiceName(ClassObj){
return ClassObj["name"];
}
}
module.exports=TaskBase;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
class CacheService {
constructor() {
this.cacheManager = system.getObject("db.common.cacheManager");
}
async buildCacheRtn(pageValues) {
var ps = pageValues.map(k => {
var tmpList = k.split("|");
if (tmpList.length == 2) {
return { name: tmpList[0], val: tmpList[1], key: k };
}
});
return ps;
}
async findAndCountAll(obj) {
const pageNo = obj.pageInfo.pageNo;
const pageSize = obj.pageInfo.pageSize;
const limit = pageSize;
const offset = (pageNo - 1) * pageSize;
var search_name = obj.search && obj.search.name ? obj.search.name : "";
var cacheCacheKeyPrefix = "sadd_children_appkeys:" + settings.appKey + "_cachekey";
var cacheList = await this.cacheManager["MagCache"].getCacheSmembersByKey(cacheCacheKeyPrefix);
if (search_name) {
cacheList = cacheList.filter(f => f.indexOf(search_name) >= 0);
}
var pageValues = cacheList.slice(offset, offset + limit);
var kobjs = await this.buildCacheRtn(pageValues);
var tmpList = { results: { rows: kobjs, count: cacheList.length } };
return system.getResultSuccess(tmpList);
}
async delCache(obj) {
var keyList = obj.del_cachekey.split("|");
if (keyList.length == 2) {
var cacheCacheKeyPrefix = "sadd_children_appkeys:" + settings.appKey + "_cachekey";
await this.cacheManager["MagCache"].delCacheBySrem(cacheCacheKeyPrefix, obj.del_cachekey);
await this.cacheManager["MagCache"].del(keyList[0]);
return { status: 0 };
}
}
async clearAllCache(obj) {
await this.cacheManager["MagCache"].clearAll();
return { status: 0 };
}
}
module.exports = CacheService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
class OplogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(OplogService));
//this.appDao=system.getObject("db.appDao");
this.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
}
async create(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("oplogCtl") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
var rc = system.getObject("util.execClient");
var rtn = null;
try {
// var myDate = new Date();
// var tmpTitle=myDate.toLocaleString()+":"+qobj.optitle;
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
if (this.opLogEsIsAdd == 1) {
qobj.content = qobj.content.replace("field list", "字段列表")
qobj.created_at = (new Date()).getTime();
//往Es中写入日志
var addEsData = JSON.stringify(qobj);
rc.execPost(qobj, this.opLogUrl);
} else {
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
}
async createDb(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("oplogCtl") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
}
}
module.exports = OplogService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
class PushlogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(PushlogService));
//this.appDao=system.getObject("db.appDao");
this.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
}
async create(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("oplogCtl") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
var rc = system.getObject("util.execClient");
var rtn = null;
try {
// var myDate = new Date();
// var tmpTitle=myDate.toLocaleString()+":"+qobj.optitle;
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
if (this.opLogEsIsAdd == 1) {
qobj.content = qobj.content.replace("field list", "字段列表")
qobj.created_at = (new Date()).getTime();
//往Es中写入日志
var addEsData = JSON.stringify(qobj);
rc.execPost(qobj, this.opLogUrl);
} else {
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
}
async createDb(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("oplogCtl") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
}
}
module.exports = PushlogService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AapService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AapService));
}
async getItemByAppKey(appKey) {
return this.dao.getItemByAppKey(appKey);
}
}
module.exports = AapService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AppProductService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AppProductService));
}
//根据渠道产品码获取产品详情
async findByChannelItemCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var channelItemCode = obj.channelItemCode;
if(!channelItemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var product = await this.dao.model.findOne({
where:{channelItemCode:channelItemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig"],
raw:true
});
if(!product){
return system.getResultFail(-104, "未知产品");
}
return system.getResultSuccess(product);
}
//获取产品列表(根据父类产品编码获取)
async findByProductTypeCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productType_id:pProduct.id,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig",
"productLogo","productDesc"
],
raw:true
});
return system.getResultSuccess(pList);
}
//获取产品列表(根据产品一类编码获取)
async findByProductOneTypeCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productOneType_id:pProduct.id,productType_id:{ [this.db.Op.ne]: 0 },app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig",
"productLogo","productDesc"
],
raw:true
});
return system.getResultSuccess(pList);
}
}
module.exports = AppProductService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AapUserService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AapUserService));
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async loginUser(channelUserId, channelUserName, userMoblie, nickname, orgName, orgPath) {
if (!channelUserId) {
return system.getResult(null, "channelUserId不能为空");
}
var params = {
channelUserId: channelUserId,
channelUserName: channelUserName,
userMoblie: userMoblie,
nickname: nickname,
orgName: orgName,
orgPath: orgPath
}
var userItem = await this.cacheManager["ApiUserCache"].cache(channelUserId, { status: true }, 3000, params);
if (!userItem) {
return system.getResult(null, "用户注册失败");
}
return system.getResultSuccess(userItem);
}
}
module.exports = AapUserService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class MoneyAccountService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(MoneyAccountService));
}
}
module.exports=MoneyAccountService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class FlowLogService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(FlowLogService));
}
}
module.exports = FlowLogService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderContactsService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderContactsService));
}
}
module.exports = OrderContactsService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderProductService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderProductService));
}
}
module.exports = OrderProductService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class ExpenseVoucherService extends ServiceBase {
constructor() {
super("dbcpay", ServiceBase.getDaoName(ExpenseVoucherService));
}
}
module.exports = ExpenseVoucherService;
const system=require("../../../system");
const Dao=require("../../dao.base");
class MoneyJourneyService extends ServiceBase {
constructor() {
super("dbcpay", ServiceBase.getDaoName(MoneyJourneyService));
}
}
module.exports=MoneyJourneyService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderReceiptVoucherService extends ServiceBase {
constructor() {
super("dbcpay", ServiceBase.getDaoName(OrderReceiptVoucherService));
}
}
module.exports = OrderReceiptVoucherService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderRefundVoucherService extends ServiceBase {
constructor() {
super("dbcpay", ServiceBase.getDaoName(OrderRefundVoucherService));
}
}
module.exports = OrderRefundVoucherService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class NeedInfoService extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(NeedInfoService));
}
async subNeed(obj){
var user = obj.user;
var app = obj.app;
if(!user){
return system.getResultFail(-100, "未知用户");
}
if(!app){
return system.getResultFail(-101, "未知渠道");
}
var needNo=await this.getBusUid("ni");
var needObj={
app_id :app.id,
needNo :needNo,
needDesc :obj.needDesc,
needUserMoblie :obj.needUserMoblie,
notes :obj.notes,
channelUserName :user.channelUserName,
auditStatus :"00",
createuser_id :user.id,
itemCode:obj.itemCode
};
var need = await this.dao.create(needObj);
return system.getResultSuccess(need);
}
}
module.exports=NeedInfoService;
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