Commit 6565a7e3 by linboxuan

ucommune rename

parent ad410254
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/main.js"
}
]
}
\ No newline at end of file
const system = require("../system");
const settings = require("../../config/settings");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase {
constructor() {
this.restClient = system.getObject("util.restClient");
this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("service.common.oplogSve");
this.toolSve = system.getObject("service.trademark.toolSve");
this.exTime = 6 * 3600;//缓存过期时间,6小时
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
//-----------------------新的模式------------------开始
async doexecMethod(gname, methodname, pobj, query, req) {
req.requestId = this.getUUID();
try {
var rtn = await this[methodname](pobj, query, req);
this.logCtl.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
rtn.requestId = req.requestId;
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.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: req.requestId,
op: req.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
rtnerror.requestId = req.requestId;
return rtnerror;
}
}
//-----------------------新的模式------------------结束
async restPostUrl(pobj, url) {
var rtn = await this.restClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
}
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("service.common.oplogSve");
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
/**
* 白名单验证
* @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.logCtl.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 WEBBase = require("../../web.base");
var system = require("../../../system");
const askForSve = system.getObject("service.common.askForSve");
class askFor extends WEBBase {
constructor() {
super();
}
/**
* @description 商标 尼斯查询 收藏 注册申请
* @author liangwk
* @param {*} pobj
* @param {*} qobj
* @param {*} req
* @returns
* @memberof askFor
*/
async tradeMark (pobj, qobj, req) {
switch (pobj.actionType) {
case 'niceQuery':
const param = pobj.actionBody
const adddic = ['首位', '中位', '末位', '随机']
if (param.word_site) {
if (adddic.indexOf(param.word_site) === -1) {
return system.getResult(null, '请选择正确的位置')
}
}
if (isNaN(parseInt(param.name_size)) || parseInt(param.name_size) <= 0) {
return system.getResult(null, '字数不正确')
} else {
param.name_size = parseInt(param.name_size)
}
if (!Array.isArray(param.ncl_one_list) || param.ncl_one_list.length === 0) {
return system.getResult(null, '分类不能为空')
} else {
for (let i in param.ncl_one_list) {
if (isNaN(parseInt(param.ncl_one_list[i])) || (parseInt(param.ncl_one_list[i]) <= 0 || parseInt(param.ncl_one_list[i]) > 45)) {
return system.getResult(null, '分类选择不正确')
} else {
param.ncl_one_list[i] = parseInt(param.ncl_one_list[i])
}
}
}
let result = await askForSve.niceQuery(pobj.actionBody)
if (result.code === 200) {
return system.getResult2(result.data)
} else {
return system.getResult(null, result.message)
}
case 'collect':
if (!pobj.actionBody.type) {
let result = await askForSve.getCollect(pobj)
if (result.status === 0) {
return system.getResult2(result.data)
} else {
return system.getResult(null, result.msg)
}
} else {
let result = await askForSve.collect(pobj)
if (result.status === 0) {
return system.getResult2(result)
} else {
return system.getResult(null, result.msg)
}
}
case 'reg':
if (!pobj.actionBody.type) {
let result = await askForSve.getAskFor(pobj)
if (result.status === 0) {
return system.getResult2(result.data)
} else {
return system.getResult(null, result.msg)
}
} else {
let result = await askForSve.askFor(pobj)
if (result.status === 0) {
return system.getResult2(result.data)
} else {
return system.getResult(null, result.msg)
}
}
}
}
}
module.exports = askFor;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
class EnterpriseQueryAPI extends WEBBase {
constructor() {
super();
this.enterSve = system.getObject("service.enterprise.enterpriseSve");
}
/**
* 接口跳转-POST请求
* 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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "gxCountByAuthor"://获取企业高薪信息数量
case "gxListByAuthor"://获取企业高薪信息列表
case "gameCountByAuthor"://获取企业游戏出版及运营数量
case "gameListByAuthor"://获取企业游戏出版及运营信息列表
case "licenseCountByAuthor"://获取企业证照信息数量
case "licenseListByAuthor"://获取企业证照信息列表
case "ipCountByAuthor"://获取企业域名信息数量
case "ipListByAuthor"://获取企业域名信息列表
case "getQccBranches"://获取企业的分支机构(从企查查获取)
case "getcountAll"://获取企业所有证照数量
opResult = await this.enterSve.opReqResult(pobj, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = EnterpriseQueryAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class IcAPI extends WEBBase {
constructor() {
super();
// this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
this.centerorderSve = system.getObject("service.common.centerorderSve");
// this.utilsFqAliyunSve = system.getObject("service.utilsSve.utilsFqAliyunSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if(pobj.actionType=='getPolicyNeedList' || pobj.actionType=='submitPolicyNeedNotes' ){
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
// case "testPushBusinessOrder":
// opResult=await this.utilsFqAliyunSve.testPushBusinessOrder();
// break;
case "submitProgramme"://提交公司注册方案
opResult = await this.centerorderSve.submitProgramme(pobj);
break;
case "getProgrammeListByUser"://获取方案列表(获取用户所有方案)
opResult = await this.centerorderSve.reqCenterOrderApi(pobj);
break;
case "getProgrammeInfoByNeedNo"://根据需求查看方案列表
opResult = await this.centerorderSve.reqCenterOrderApi(pobj);
break;
case "receiveFeedback"://接收方案反馈信息(即方案作废)
opResult = await this.centerorderSve.reqCenterOrderApi(pobj);
break;
case "abolishProgramme"://服务商方案作废
opResult = await this.centerorderSve.abolishProgramme(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class IcpAPI extends APIBase {
constructor() {
super();
// this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
this.centerorderSve = system.getObject("service.common.centerorderSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if (pobj.actionType == 'getPolicyNeedList' || pobj.actionType == 'submitPolicyNeedNotes') {
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getNeedSolutionDetailByUser"://获取方案详情
opResult = await this.centerorderSve.reqCenterOrderApi(pobj,"action/icpapi/springBoard");
break;
case "submitIcpProgramme"://icp方案提交
opResult = await this.centerorderSve.submitIcpProgramme(pobj);
break;
case "submitIcpMaterial"://icp材料提交
opResult = await this.centerorderSve.submitIcpMaterial(pobj);
break;
case "acceptIcpPartnerNotification"://icp通知状态变更
opResult = await this.centerorderSve.acceptIcpPartnerNotification(pobj);
break;
case "abolishIcpProgramme"://服务商icp方案关闭
opResult = await this.centerorderSve.abolishIcpProgramme(pobj);
break;
case "getProgrammeInfoByChannelNeedNo"://获取需求方案列表
opResult = await this.centerorderSve.reqCenterOrderApi(pobj,"action/icpapi/springBoard");
break;
// case "updateStausByRefundOrder"://修改退款方案状态
// opResult = await this.needsolutionSve.updateStausByRefundOrder(pobj);
// break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcpAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
class LicenseQueryAPI extends WEBBase {
constructor() {
super();
this.liecseSve = system.getObject("service.licenses.licenseSve");
}
/**
* 接口跳转-POST请求
* 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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getLicenses"://根据公司得到推荐要办的证书
//opResult = await this.liecseSve.getLicenses(action_body);
opResult = await this.liecseSve.opReqResult(pobj, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = LicenseQueryAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class LogoOrderAPI extends APIBase {
constructor() {
super();
this.centerorderSve = system.getObject("service.common.centerorderSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
if (pobj.actionType == 'getPolicyNeedList' || pobj.actionType == 'submitPolicyNeedNotes') {
if (!pobj.userInfo) {
return system.getResult(system.noLogin, "user no login!");
}
if (!pobj.appInfo) {
return system.getResult(system.noLogin, "app is null!");
}
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "singlelogo"://生成logo
opResult = await this.centerorderSve.singlelogo(pobj);
break;
case "changelogo"://换一批logo
opResult = await this.centerorderSve.changelogo(pobj);
break;
case "downloadlogoscene"://下载logo场景
opResult = await this.centerorderSve.downloadlogoscene(pobj);
break;
case "getPaidLogoListByUser"://获取已购买的logo
opResult = await this.centerorderSve.reqCenterOrderApi(pobj,"action/logoOrderApi/springBoard");
break;
case "getLogoMaterial"://下载logo素材
opResult = await this.centerorderSve.reqCenterOrderApi(pobj,"action/logoOrderApi/springBoard");
break;
case "getCollectibleLogoListByUser"://获取收藏的logo
opResult = await this.centerorderSve.reqCenterOrderApi(pobj,"action/logoOrderApi/springBoard");
break;
case "collectLogo"://收藏logo
opResult = await this.centerorderSve.reqCenterOrderApi(pobj,"action/logoOrderApi/springBoard");
break;
case "cancelCollectLogo"://取消收藏
opResult = await this.centerorderSve.reqCenterOrderApi(pobj,"action/logoOrderApi/springBoard");
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = LogoOrderAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ProductAPI extends WEBBase {
constructor() {
super();
this.utilsUcommuneSve = system.getObject("service.utilsSve.utilsUcommuneSve");
}
/**
* 优客工厂
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getIndustryInfo":// 获取行业信息
opResult = await this.utilsUcommuneSve.getUserInfo(pobj, pobj.actionBody);
break;
case "placeOrder":// 提交订单
opResult = await this.utilsUcommuneSve.getOrderList(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ProductAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
const logCtl = system.getObject("service.common.oplogSve");
class opLog extends WEBBase {
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 WEBBase = require("../../web.base");
var system = require("../../../system");
class PatentQueryAPI extends WEBBase {
constructor() {
super();
this.patentSve = system.getObject("service.patent.patentycSve");
}
/**
* 接口跳转-POST请求
* 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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "CommomSearchbyApplicant"://根据申请人查询聚合
case "paCountByApplicantName"://根据申请人获取专利量
case "paShortListByApplicantName"://根据申请人获取专利详情列表
case "paDetailsBypubNo"://根据公开或授权号获取专利详情列表
case "paDetailsByfilingNo"://根据申请号获取专利详情列表
case "softwareCountByAuthor"://根据公司名称得到软著量
case "softwareListByAuthor"://根据公司名称得到软著详情
case "softwareDetailsByregNum"://根据登记号获取软著详情
case "worksCountByAuthor"://根据公司名称得到著作权量
case "worksListByAuthor"://根据公司名称得到著作权详情
case "worksDetailsByregNum"://根据登记号获取著作权详情
opResult = await this.patentSve.opReqResult(pobj, req);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = PatentQueryAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
class PolicyAPI extends WEBBase {
constructor() {
super();
this.policySve = system.getObject("service.policy.policySve");
this.wxTokenSve = system.getObject("service.common.wxTokenSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj,pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj,action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "policyQuery"://政策检索
opResult = await this.policySve.policyQuery(pobj);
break;
case "policyTypeQuery"://政策检索(根据政策类型检索)
opResult = this.policySve.reqPolicyApi(pobj);
break;
case "submitPolicyNeed"://政策申请提报
opResult = this.policySve.submitPolicyNeed(pobj);
break;
case "getPolicyNeedList"://政策需求列表
opResult = this.policySve.getPolicyNeedList(pobj);
break;
case "submitPolicyNeedNotes"://申请信息备注提交
opResult = this.policySve.submitPolicyNeedNotes(pobj);
break;
case "getWxSign"://获取微信签名信息
opResult = this.policySve.getWxSign(action_body.url);
break;
case "getTokenAndOpenid"://通过code换取网页授权access_token,用于政策H5 oauth授权登录
opResult = this.wxTokenSve.getTokenAndOpenid(action_body);
break;
case "submitPolicysubscribe"://提交政策订阅
opResult = this.policySve.reqPolicyApi(pobj);
break;
case "delPolicysubscribe"://取消政策订阅
opResult = this.policySve.reqPolicyApi(pobj);
break;
case "getPolicysubscribeList"://获取政策订阅列表
opResult = this.policySve.reqPolicyApi(pobj);
break;
case "policyTypeCount"://政策类型统计计数
opResult = this.policySve.reqPolicyApi(pobj);
break;
case "policySubscribeQuery"://政策订阅检索列表(通过订阅信息查询订阅的政策信息)
opResult = this.policySve.reqPolicyApi(pobj);
break;
case "getPolicyBusinessFq"://政策商机(蜂擎)
opResult = this.policySve.reqPolicyApi(pobj);
break;
case "getPolicyNeedInfo"://政策需求信息(icompany)
opResult = this.policySve.reqPolicyApi(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = PolicyAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ProductAPI extends WEBBase {
constructor() {
super();
this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getProductList"://通过产品类别编码路径获取产品列表
opResult = await this.utilsProductSve.getProductList(pobj, pobj.actionBody);
break;
case "getProductListH5"://通过产品类别编码路径获取产品列表
opResult = await this.utilsProductSve.getProductListH5(pobj, pobj.actionBody);
break;
case "getProductDetail"://根据渠道产品编码获取产品详情
opResult = await this.utilsProductSve.getProductDetail(pobj, pobj.actionBody);
break;
case "getProductPrice":
opResult = await this.utilsProductSve.getProductPrice(pobj,pobj.actionBody)
break;
default:
opResult = system.getResult(null, "action_type参数错误");
}
return opResult;
}
}
module.exports = ProductAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
class TmQueryAPI extends WEBBase {
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 = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req, pobj);
return result;
}
async opActionProcess(action_process, action_type, action_body, req, pobj) {
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;
case "tmreport"://商标报告
var rtn = await this.tmquerySve.tmreport(action_body, pobj, req);
if (rtn.code > 0) {
opResult = system.getResultSuccess();
} else {
opResult = system.getResult(null, rtn.msg);
}
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmQueryAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
class TmToolsAPI extends WEBBase {
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 = await this.opActionProcess(pobj, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, 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"://获取oss信息
opResult = await this.toolSve.getOssConfig(pobj);
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 WEBBase = require("../../web.base");
var system = require("../../../system");
class TmTransactionAPI extends WEBBase {
constructor() {
super();
this.pushlogSve = system.getObject("service.common.pushlogSve");
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "addPushContent"://添加推送信息
opResult = await this.pushlogSve.addPublicServiceLog(pobj, 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 WEBBase = require("../../web.base");
var settings = require("../../../../config/settings");
var moment = require('moment')
class TradetransferAPI extends WEBBase {
constructor() {
super();
this.aliclient = system.getObject("util.aliyunClient");
this.execlient = system.getObject("util.execClient");
this.transferurl = settings.reqTransferurl();
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
}
//订单创建
async createtransfer(p, obj, req) {
console.log(p.actionBody, "actionBody...............................");
var orderinfo = await this.utilsOrderSve.addOrder(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 WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ProductAPI extends WEBBase {
constructor() {
super();
this.utilsUcommuneSve = system.getObject("service.utilsSve.utilsUcommuneSve");
}
/**
* 优客工厂
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
switch (action_type) {
case "getUserInfo":// 根据优客token获取用户信息,生成userPin返回前端 actionBody
opResult = await this.utilsUcommuneSve.getUserInfo(pobj, pobj.actionBody);
break;
case "orderTotalSum":// addOrder后进入支付页面获取支付金额
opResult = await this.utilsUcommuneSve.orderTotalSum(pobj, pobj.actionBody);
break;
case "orderConfirm":// 点击确认支付后返回拼接字符串
opResult = await this.utilsUcommuneSve.orderConfirm(pobj, pobj.actionBody);
break;
case "orderCheck":// 调起支付框后获取支付结果
opResult = await this.utilsUcommuneSve.orderCheck(pobj, pobj.actionBody);
break;
case "ucommuneGetOrderList":// 优客调取订单列表用
opResult = await this.utilsUcommuneSve.ucommuneGetOrderList(pobj, pobj.actionBody);
break;
case "ucommuneGetOrderDetail":// 优客调取订单详情 目前未使用
opResult = await this.utilsUcommuneSve.ucommuneGetOrderDetail(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ProductAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class PaymentAPI extends WEBBase {
constructor() {
super();
this.execlient = system.getObject("util.execClient");
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_type, action_body, req) {
var opResult = null;
var url = "";
switch (action_type) {
// sy
case "needinfo2fq"://pc端订单支付二维码生成
url = settings.centerOrderUrl() + "action/zcbusinesschanceApi/springBoard";
break;
// case "flowinfo"://pc端订单支付二维码生成
// opResult = await this.needinfoSve.flowinfo(needinfo);
// break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
// var url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.restPostUrl(pobj, url);
// return opResult;
}
}
module.exports = PaymentAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
class AccessAuthAPI extends WEBBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
this.utilsTmAliyunSve = system.getObject("service.utilsSve.utilsTmAliyunSve");//测试用
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = system.getResult(null, "req Failure");
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();
switch (action_type) {
// sy
case "test"://测试
var rpcParam = {
accessKeyId: "LTAI4Fgz1uoUpfHpa79iq3XV",
accessKeySecret: "up8vlX0wzwCVtRAjKRXsCrFta6CHOY",
endpoint: "https://trademark.aliyuncs.com",
apiVersion: "2019-09-02"
};
opResult = await this.utilsTmAliyunSve.getAliOssInfo(null, "ATTORNEY", rpcParam);
// opResult = system.getResultSuccess(null, "测试成功");
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getTokenInfo"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
opResult = system.getResultSuccess({
app_code: pobj.appInfo.app_code,
app_hosts: pobj.appInfo.app_hosts,
uapp_id: pobj.appInfo.uapp_id,
uapp_key: pobj.appInfo.uapp_key,
id: pobj.appInfo.id
})
break;
case "getNeedUserPinByChannelUserId"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
//获取需求信息
pobj.actionType = "getItemByChannelNeedNo";
var needResult = await this.utilsNeedSve.getItemByChannelNeedNo(pobj, pobj.actionBody);
if (needResult.status != 0) {
return needResult;
}
opResult.data.channelTypeCode = needResult.data.channelTypeCode;
opResult.data.typeCode = needResult.data.typeCode
break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break;
case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess()
}
break;
case "userPinByLgoin"://通过账户和密码登录
opResult = await this.utilsAuthSve.getReqUserPinByLgoin(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByLgoinVcode"://通过短信登录信息
pobj.actionBody.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByRegister"://通过短信注册信息
pobj.actionBody.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "putUserPwdByMobile"://通过手机验证码修改用户密码
opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody);
break;
case "getLoginInfo"://通过userpin获取用户登录信息
opResult = await this.utilsAuthSve.getLoginInfo(pobj, pobj.actionBody);
break;
case "logout"://用户退出
opResult = await this.utilsAuthSve.userLogout(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByHosts(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "hosts";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByAppKey(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "appkey";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
class ChannelAccessAuthAPI extends WEBBase {
constructor() {
super();
this.utilsChannelAuthSve = system.getObject("service.utilsSve.utilsChannelAuthSve");
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.utilsTmAliyunSve = system.getObject("service.utilsSve.utilsTmAliyunSve");//测试用
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = system.getResult(null, "req Failure");
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();
switch (action_type) {
// sy
case "test"://测试
console.log(pobj, "...test....pobj.actionBody....");
opResult = system.getResultSuccess(null, "测试成功");
opResult.status = 1;
break;
case "getUserPinByAliCode"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var aliUserResult = await this.utilsChannelAuthSve.getH5AliDingUserByCode(pobj, pobj.actionBody);
if (aliUserResult.status != 0) {
return aliUserResult;
}
pobj.actionType = "getLoginByUserName";
pobj.actionBody.channelUserId = aliUserResult.data.channelUserId;
pobj.actionBody.isAdmin = aliUserResult.data.isAdmin;
pobj.actionBody.isSuper = aliUserResult.data.isSuper;
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break;
case "getDingJsApiAuthInfo"://获取钉钉鉴权信息
opResult = await this.utilsChannelAuthSve.getDingJsApiAuthInfo(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ChannelAccessAuthAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.gatewaypushlogSve = system.getObject("service.common.gatewaypushlogSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
this.pushlogSve = system.getObject("service.common.pushlogSve");
this.aliclient = system.getObject("util.aliyunClient");
this.utilsTmAliyunSve = system.getObject("service.utilsSve.utilsTmAliyunSve");
}
async taskAliIcapi() {
var rtn = await this.gatewaypushlogSve.taskAliIcapi();
return rtn;
}
async taskAgainFqPushInfo(pobj, qobj, req) {//再次推送蜂擎业务数据
var rtn = await this.utilsPushSve.aliBusiness2Fq(pobj, pobj.opType);
this.pushlogSve.delDbPushfaillogById(Number(pobj.id || 0));
return rtn;
}
async taskAgainPushOneNewBusInfo(pobj, qobj, req) {//再次推送新rpc业务数据
var rtn = await this.utilsPushSve.againPushBusInfo(pobj);
this.pushlogSve.delDbPushfaillogById(Number(pobj.id || 0));
return rtn;
}
async taskAgainPushOneOldBusInfo(pobj, qobj, req) {//再次推送老rpc业务数据
var rtn = await this.aliclient.reqbyget(pobj)
this.pushlogSve.delDbPushfaillogById(Number(pobj.id || 0));
return rtn;
}
async taskAliTmUpdate(pobj, qobj, req) {//操作阿里商标更新
var rtn = await this.utilsTmAliyunSve.taskAliTmUpdate();
return rtn;
}
async taskAliRpcAgainPush(pobj, qobj, req) {
var result = await this.pushlogSve.getFailLogList();
if (result.status != 0 || !result.data || result.data.length == 0) {
return system.getResult(null, "push data is empty");
}
var self = this;
for (let index = 0; index < result.data.length; index++) {
const element = result.data[index];
if (element) {
var contentData = JSON.parse(element.content);
contentData.id = element.id;
contentData.pushNumber = element.pushNumber + 1;
if (element.failType == 1) {
self.taskAgainPushOneOldBusInfo(contentData);
}
else if (element.failType == 2) {
self.taskAgainPushOneNewBusInfo(contentData);
} else if (element.failType == 4) {
self.taskAgainFqPushInfo(contentData);
}//FQ
}
}
return system.getResultSuccess();
}
async taskPushPublicService(pobj, qobj, req) {
var result = await this.pushlogSve.getPublicServiceLogList();
if (result.status != 0 || !result.data || result.data.length == 0) {
return system.getResult(null, "PushPublicService data is empty");
}
var self = this;
for (let index = 0; index < result.data.length; index++) {
const element = result.data[index];
if (element && element.pushUrl) {
var contentData = JSON.parse(element.pushContent);
var opResult = await self.restPostUrl(contentData, element.pushUrl);
if ((!opResult && opResult.status != 0) || opResult.code != 1) {
var tmpPobj = {
actionBody: {
uapp_key: element.appkey,
pushUrl: element.pushUrl,
pushContent: contentData,
pushNumber: element.pushNumber + 1,
resultInfo: opResult
}
}
self.pushlogSve.addPublicServiceLog(tmpPobj, { clientIp: element.clientIp });
} else {
self.logCtl.info({
appid: "",
appkey: element.appkey,
requestId: req.requestId || "",
op: req.classname,
content: contentData,
clientIp: element.clientIp,
agent: req.uagent,
optitle: "推送公共服务:PushPublicService Success",
});
}
self.pushlogSve.delPublicServiceLog(element.id);
}
}
return system.getResultSuccess();
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class NameAPI extends WEBBase{
constructor() {
super();
this.redisClient = system.getObject("util.redisClient");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
this.centerOrderUrl = settings.centerOrderUrl();
this.centerCacheUrl = settings.centerCacheUrl();
}
/**
* 接口跳转-POST请求
* action_type 执行的类型
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = null;
pobj.requestId = req.requestId;
switch (action_type) {
case "getCache"://行业类别
opResult = await this.getCache();
break;
case "getPreference"://偏好
opResult=await this.getPreference();
break;
case "createName"://起名
opResult =await this.addOrderDelivery(pobj,pobj.actionBody);
break;
case "getNameDetail"://详情
opResult = await this.getNameDetail(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
/**
* 获取行业类别数据 後期可提出為一個service文件
* @returns {Promise<{}>}
*/
async getCache(){
let cacheResult = {};
cacheResult.cache = cacheJson
return system.getResult(cacheResult);
}
/**
* 获取偏好信息 後期可提出為一個service文件
* @returns {Promise<{}>}
*/
async getPreference(){
let preResult = {};
const key = 'qmbpreference';
let result = await this.redisClient.get(key)
if(result){
preResult.preference = JSON.parse(result);
return system.getResult(preResult);
}else{
const data = await this.restPostUrl({},this.centerCacheUrl+"preference_select");
if(data.code == 200){
await this.redisClient.set(key,JSON.stringify(data.data),2*3600)
preResult.preference = data.data
return system.getResult(preResult);
}
}
}
/**
* 获取起名数据并添加到c_order_delivery 后期可提取为一個service文件
* @param pobj
* @param actionBody
* @returns {Promise<{msg: string, data: (*|null), bizmsg: *, status: number}|{msg: *, data: *, status: *}|{msg: *, data: (*|null), status: number}>}
*/
async addOrderDelivery(pobj,actionBody){
if (!actionBody.orderId) {
return system.getResult(null, "orderId参数不能为空");
}
if (!actionBody.province) {
return system.getResult(null, "province参数不能为空");
}
if (!actionBody.city) {
return system.getResult(null, "city:参数不能为空");
}
if (!actionBody.county) {
return system.getResult(null, "county参数不能为空");
}
if (!actionBody.pcate) {
return system.getResult(null, "pcate参数不能为空");
}
if (!actionBody.cate) {
return system.getResult(null, "cate参数不能为空");
}
if (!actionBody.preference) {
return system.getResult(null, "preference参数不能为空");
}
await this.redisClient.set("ch"+JSON.stringify(actionBody.orderId),JSON.stringify(actionBody));
return system.getResultSuccess();
}
//获取取名结果,并保存到数据库
async getNameDetail(pobj){
pobj.actionType = 'getOrderDeliveryInfo';
const opResult = await this.utilsOrderSve.getOrderDeliveryInfo(pobj, pobj.actionBody);
if(opResult.status == 0){
if(!opResult.data.hasOwnProperty('result_name')){
const actionBody =await this.redisClient.get('ch'+ JSON.stringify(pobj.actionBody.orderNo));
if(actionBody != null){
const nameResult = await this.restPostUrl(JSON.parse(actionBody),this.centerCacheUrl+"treasure_name");
if(nameResult.code == 200){
pobj.actionType = 'addOrderDelivery'
pobj.actionBody = nameResult.data;
//取名结果存储
await this.restPostUrl(pobj,this.centerOrderUrl + "action/nameOrder/springBoard");
return system.getResult(nameResult.data,"操作成功")
}
}else{
return system.getResult()
}
}else{
return system.getResult(opResult.data,'操作成功')
}
}else {
return system.getResultFail('',opResult.msg);
}
}
}
const cacheJson = {
"科技类": ["网络科技", "电子商务", "信息技术", "游戏", "电子", "软件", "新材料", "生物科技", "教育科技", "环保科技", "信息科技"],
"许可类": ["投资管理", "金融", "资产", "商业保理", "融资租赁", "医疗器械", "人力资源", "食品", "劳务派遣"],
"服务类": ["广告", "文化传媒", "建筑装潢", "设计", "美容美发", "房地产中介", "物业管理", "商务咨询", "企业管理"],
"其他": ["贸易","实业","制造","服饰","化妆品","工程","农业","餐饮管理","物流"],
}
module.exports = NameAPI;
var WEBBase = require("../../web.base");
var system = require("../../../system");
class FgbusinesschanceAPI extends WEBBase {
constructor() {
super();
this.utilsFgbusinesschancSve = system.getObject("service.utilsSve.utilsFgbusinesschanceSve");
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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "create"://创建复购商机
opResult = await this.utilsFgbusinesschancSve.create(pobj, pobj.actionBody);
break;
case "createOrderRefundFq":
opResult = await this.utilsFgbusinesschancSve.createOrderRefundFq(pobj, pobj.actionBody);
break;
case "createOnlineProductClassificiationFq":
opResult = await this.utilsFgbusinesschancSve.createOnlineProductClassificiationFq(pobj, pobj.actionBody);
break;
case "createOrderInfoAndPayFq":
opResult = await this.utilsFgbusinesschancSve.createOrderInfoAndPayFq(pobj, pobj.actionBody);
break;
// ------ 对蜂擎页面 -------
case "getCompanyInfo": // 获取工商信息
opResult = await this.toolSve.getEntregistryByCompanyName(pobj.actionBody, req);
break;
case "getCompanyLabel":// 三十秒认知客户
opResult = await this.utilsFgbusinesschancSve.getCompanyLabel(pobj, pobj.actionBody);
break
case "getRecommendProducts": // 获取推荐产品列表
opResult = await this.utilsFgbusinesschancSve.getRecommendProducts(pobj, pobj.actionBody);
break;
case "getTalkContent": // 获取营销话术
opResult = await this.utilsFgbusinesschancSve.getTalkContent(pobj, pobj.actionBody);
break;
case "getOldOrder": // 获取已购产品
opResult = await this.utilsFgbusinesschancSve.getOldOrder(pobj, pobj.actionBody);
break;
case "updateStatus"://更新商机跟进状态
opResult = await this.utilsFgbusinesschancSve.updateStatus(pobj, pobj.actionBody);
break;
case "getMoreInfoUrl":// 更多客户信息链接地址
opResult = await this.utilsFgbusinesschancSve.getMoreInfoUrl(pobj, pobj.actionBody);
break
case "getConsultingRecord":// 根据咨询公司名称获取咨询记录
opResult = await this.utilsFgbusinesschancSve.getConsultingRecord(pobj, pobj.actionBody);
break
case "addStatusRemarks": // 产品跟进状态备注
opResult = await this.utilsFgbusinesschancSve.addStatusRemarks(pobj, pobj.actionBody);
break
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = FgbusinesschanceAPI;
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class IcbcOrderNotify extends WEBBase {
constructor() {
super();
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
this.logCtl.info({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: req.requestId,
op: pobj.actionType,
content: JSON.stringify(pobj),
clientIp: req.clientIp,
agent: req.uagent,
optitle: "icbcOrderNotify信息通知记录",
});
switch (action_type) {
case "icOrderStatusNotify"://工商状态通知
opResult = await this.utilsOrderSve.icOrderStatusNotify(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = IcbcOrderNotify;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ProductAPI extends WEBBase {
constructor() {
super();
this.utilsOpOrderSve = system.getObject("service.utilsSve.utilsOpOrderSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
this.utilsTmAliyunSve = system.getObject("service.utilsSve.utilsTmAliyunSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "opAliDingInterfaceManage"://操作阿里钉钉接口管理---actionBody:{为阿里需要的参数}
var pushInterfaceResult = await this.utilsOpOrderSve.getOpInterfaceByProductId(pobj.appInfo, pobj.product_id);
if (pushInterfaceResult.status != 0) {
return pushInterfaceResult;
}
var interface_list_temp = pushInterfaceResult.data.filter(f => f.op_type == "createAliTmApply")
if (!interface_list_temp || interface_list_temp.length == 0) {
return system.getResult(null, "暂无【createAliTmApply】的推送配置,100520");
}
pobj.interface_params = interface_list_temp[0].params;
opResult = await this.utilsTmAliyunSve.opAliDingInterfaceManage(pobj);
break;
// case "checkTmNameByAli"://检测商标名称是否合规
// var pushInterfaceResult = await this.utilsOpOrderSve.getOpInterfaceByProductId(pobj, pobj.actionBody.product_id);
// if (pushInterfaceResult.status != 0) {
// pobj.actionBody.product_info.interface_info = pushInterfaceResult.data;
// this.utilsPushSve.pushBusInfo(pobj, "closeAliTmApply", 1);
// }
// break;
case "updateContacts"://修改订单联系人
opResult = await this.utilsOpOrderSve.updateContacts(pobj, pobj.actionBody);
break;
case "updateTmOrder"://修改商标订单信息
opResult = await this.utilsOpOrderSve.updateTmOrder(pobj, pobj.actionBody);
break;
case "tmConfirm"://商标方案确认
opResult = await this.utilsOpOrderSve.tmConfirm(pobj, pobj.actionBody);
break;
case "sendAliWtsEmail"://推送委托书模板邮件(阿里云)
opResult = await this.utilsTmAliyunSve.sendAliWtsEmail(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ProductAPI;
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class ProductAPI extends WEBBase {
constructor() {
super();
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
pobj.requestId = req.requestId;
var opResult = null;
switch (action_type) {
case "addOrder"://创建订单
opResult = await this.utilsOrderSve.addOrder(pobj, pobj.actionBody);
break;
case "getOrderInfo"://获取订单列表信息
opResult = await this.utilsOrderSve.getOrderInfo(pobj, pobj.actionBody);
break;
case "getOrderDetails"://获取订单详情信息
opResult = await this.utilsOrderSve.getOrderDetails(pobj, pobj.actionBody);
break;
case "getOrderDeliveryInfo"://获取订单交付信息
opResult = await this.utilsOrderSve.getOrderDeliveryInfo(pobj, pobj.actionBody);
break;
case "getOrderDeliveryFlowInfo"://获取订单交付流程信息
opResult = await this.utilsOrderSve.getOrderDeliveryFlowInfo(pobj, pobj.actionBody);
break;
case "getOrderDeliveryFlowList"://获取订单交付流程列表信息
opResult = await this.utilsOrderSve.getOrderDeliveryFlowList(pobj, pobj.actionBody);
break;
case "getOrderLogInfo"://获取订单日志信息
opResult = await this.utilsOrderSve.getOrderLogInfo(pobj, pobj.actionBody);
break;
case "delOrder"://删除订单
opResult = await this.utilsOrderSve.delOrder(pobj, pobj.actionBody);
break;
// case "getIcbcOrderDetails"://获取工商详情
// opResult = await this.utilsOrderSve.addOrder(pobj, pobj.actionBody);
// break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = ProductAPI;
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(pobj, action_type, req) {
var opResult = system.getResult(null, "req Failure");
pobj.actionBody.userpin = pobj.actionBody.userpin || this.getUUID();
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getLoginByUserName"://渠道通过账户进行登录,有则返回用户信息,没有则创建用户
var tmpOpResult = await this.utilsAuthSve.getLoginByUserName(pobj, pobj.actionBody);
if (tmpOpResult.status != 0 && tmpOpResult.status != 2060) {
return tmpOpResult;
}
opResult = system.getResultSuccess({ userpin: pobj.actionBody.userpin })
if (tmpOpResult.status == 2060) {
opResult.msg = tmpOpResult.msg;
opResult.data.userpin = tmpOpResult.data.userpin;
}
break;
case "getVerifyCode"://获取默认模板的手机验证码
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess()
}
break;
case "userPinByLgoin"://通过账户和密码登录
opResult = await this.utilsAuthSve.getReqUserPinByLgoin(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByLgoinVcode"://通过短信登录信息
pobj.actionBody.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByRegister"://通过短信注册信息
pobj.actionBody.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "putUserPwdByMobile"://通过手机验证码修改用户密码
opResult = await this.utilsAuthSve.putUserPwdByMobile(pobj, pobj.actionBody);
break;
case "getLoginInfo"://通过userpin获取用户登录信息
opResult = await this.utilsAuthSve.getLoginInfo(pobj, pobj.actionBody);
break;
case "logout"://用户退出
opResult = await this.utilsAuthSve.userLogout(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByHosts(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "hosts";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
*/
async getAppTokenByAppKey(pobj, qobj, req) {
var token = this.getUUID();
pobj.actionBody.reqType = "appkey";
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class Ic extends APIBase {
constructor() {
super();
this.centerorderSve = system.getObject("service.common.centerorderSve");
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_process, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
case "deliveryInfo"://办理公司表单数据
break;
case "deliveryStatus"://办理公司状态
break;
case "reqCenterOrderApi"://办理公司状态
break;
case "paySuccess"://支付回调
opResult = await this.centerorderSve.paySuccess(pobj);
break;
case "orderClose"://阿里退款
opResult = await this.utilsOrderSve.orderClose(pobj);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = Ic;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class Need extends APIBase {
constructor() {
super();
this.utilsNeedSve = system.getObject("service.utilsSve.utilsNeedSve");
this.centerorderSve = system.getObject("service.common.centerorderSve");
}
/**
* 接口跳转-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 = await this.opActionProcess(pobj, pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_process, action_type, action_body, req) {
pobj.requestId = req.requestId;
var self = this;
var opResult = null;
switch (action_type) {
case "submitNeed"://提交需求
opResult = await this.utilsNeedSve.submitNeed(pobj, pobj.actionBody);
break;
case "submitNeedH5"://提交需求
opResult = await this.utilsNeedSve.submitNeedH5(pobj, pobj.actionBody);
break;
case "needClose"://关闭需求
opResult = await this.utilsNeedSve.needClose(pobj, pobj.actionBody);
break;
case "needCloseIcp"://关闭需求
opResult = await this.utilsNeedSve.needCloseIcp(pobj, pobj.actionBody);
break;
case "needDetailByChannelNo":
opResult = await this.utilsNeedSve.needDetailByChannelNo(pobj, pobj.actionBody);
break;
case "getItemByChannelNeedNo":
opResult = await this.utilsNeedSve.getItemByChannelNeedNo(pobj, pobj.actionBody);
break;
case "getItemByNeedNo":
opResult = await this.utilsNeedSve.getItemByNeedNo(pobj, pobj.actionBody);
break;
case "receiveFeedback"://接收方案反馈信息
opResult = await this.centerorderSve.reqCenterOrderApi(pobj);
break;
case "icpFeedbackSubmit"://icp接收方案反馈信息
pobj.actionType = "receiveIcpFeedback";
opResult = await this.utilsNeedSve.reqCenterOrderApi(pobj);
break;
case "icpNotify"://icp方案更新
var rtn = await this.utilsNeedSve.icpNotify(pobj, pobj.actionBody);
if (pobj.actionBody.status == 4 && rtn.status == 0) {
opResult = await self.centerorderSve.icppaysuccess(pobj, pobj.actionBody);
} else {
opResult = rtn;
}
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = Need;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class ChannelPayment extends APIBase {
constructor() {
super();
this.utilsAlibankSve = system.getObject("service.utilsSve.utilsAlibankSve");
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
// sy
case "getAliPayInfo"://唤起钉钉h5支付信息---只供简单应用
opResult = await this.utilsAlibankSve.getH5AliDingPayInfo(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
//支付成功后通知
async receiveCallBackNotify(pobj, query, req) {
// var rtn = await this.utilstlbankSve.receiveCallBackNotify(pobj.actionBody.parmas, pobj.client_ip);
// return rtn;
}
}
module.exports = ChannelPayment;
\ No newline at end of file
var WEBBase = require("../../web.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class PaymentAPI extends WEBBase {
constructor() {
super();
// this.execlient = system.getObject("util.execClient");
// this.centerAppUrl = settings.centerAppUrl();
this.utilsOrderSve = system.getObject("service.utilsSve.utilsOrderSve");
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj, pobj.actionType, pobj.actionBody, req);
return result;
}
async opActionProcess(pobj, action_type, action_body, req) {
var opResult = null;
switch (action_type) {
// sy
case "getH5PayUrl"://H5端订单支付二维码生成
opResult = await this.utilsOrderSve.getH5PayUrl(pobj, pobj.actionBody);
break;
case "getOrderQrCode"://pc端订单支付二维码生成
opResult = await this.utilsOrderSve.getQrCodeInfo(pobj, pobj.actionBody);
break;
case "queryOrderStatus"://通联支付查询
opResult = await this.utilsOrderSve.queryOrderStatus(pobj, pobj.actionBody);
break;
case "getQrCode"://获取pc端支付二维码--不跟订单关联
opResult = await this.utilsOrderSve.getQrCode(pobj, pobj.actionBody);
break;
case "queryOrder"://通联支付查询
opResult = await this.utilsOrderSve.queryOrder(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = PaymentAPI;
\ 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");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class WEBBase {
constructor() {
this.restClient = system.getObject("util.restClient");
this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("service.common.oplogSve");
this.toolSve = system.getObject("service.trademark.toolSve");
this.exTime = 6 * 3600;//缓存过期时间,6小时
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
//-----------------------新的模式------------------开始
async doexecMethod(gname, methodname, pobj, query, req) {
req.requestId = this.getUUID();
try {
var rtn = await this[methodname](pobj, query, req);
this.logCtl.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
rtn.requestId = req.requestId;
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.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: req.requestId,
op: req.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
rtnerror.requestId = req.requestId;
return rtnerror;
}
}
//-----------------------新的模式------------------结束
async restPostUrl(pobj, url) {
var rtn = await this.restClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
}
module.exports = WEBBase;
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 {
this.redisClient.set(cachekey, cacheValue, ex);
return JSON.parse(cacheValue);
}
}
async getCache(inputkey, ex) {
const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null") {
return system.getResultFail(system.cacheInvalidation, "cache is invalidation")
} else {
if (ex) {
this.redisClient.set(cachekey, cacheValue, ex);
}
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 AppTokenByHostsCache extends CacheBase {
constructor() {
super();
this.restClient = system.getObject("util.restClient");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_accesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var actionBody = val;
var acckapp = await this.restClient.execPost(actionBody, settings.centerAppUrl() + "auth/accessAuth/getTokenByHosts");
var result = acckapp.stdout;
console.log(acckapp.stdout, "AppTokenByHostsCache............. acckapp.stdout..........");
if (result) {
var tmp = JSON.parse(result);
return tmp;
}
return system.getResult(null, "data is empty");
}
}
module.exports = AppTokenByHostsCache;
const CacheBase=require("../cache.base");
const system=require("../../system");
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 飞书小程序--AppAccessToken缓存--有效时间7100s
*/
class feishuAppAccessTokenCache extends CacheBase{
constructor(){
super();
this.restClient = system.getObject("util.restClient");
this.prefix="feishu_appAccessToken_9e28dcb1d637100d";
}
desc() {
return "应用UI配置缓存";
}
prefix() {
return "feishu_appAccessToken_9e28dcb1d637100d";
}
async get(){
var key = this.prefix;
var result = await this.redisClient.get(key);
return result;
}
async set(accessToken,expire){
if(!expire){
expire=7100;
}
var key = this.prefix;
if(accessToken){
await this.redisClient.setWithEx(key,accessToken,expire);
}
return accessToken;
}
}
module.exports=feishuAppAccessTokenCache;
\ No newline at end of file
const CacheBase=require("../cache.base");
const system=require("../../system");
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 飞书小程序--AppTicket缓存--有效时间3600s
*/
class feishuAppTicketCache extends CacheBase{
constructor(){
super();
this.restClient = system.getObject("util.restClient");
this.prefix="feishu_appTicket_cli_9e28dcb1d637100d";
}
desc() {
return "应用UI配置缓存";
}
prefix() {
return "feishu_appTicket_cli_9e28dcb1d637100d";
}
async get(){
var key = this.prefix;
var result = await this.redisClient.get(key);
return result
}
async set(appTicket){
var key = this.prefix;
if(appTicket){
await this.redisClient.setWithEx(key,appTicket,3600);
}
return appTicket;
}
}
module.exports=feishuAppTicketCache;
\ No newline at end of file
const CacheBase=require("../cache.base");
const system=require("../../system");
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 飞书小程序--UserAccessTokenCache缓存--有效时间7100s
*/
class feishuUserAccessTokenCache extends CacheBase{
constructor(){
super();
this.restClient = system.getObject("util.restClient");
this.prefix="feishu_userAccessToken_9e28dcb1d637100d";
}
desc() {
return "应用UI配置缓存";
}
prefix() {
return "feishu_userAccessToken_9e28dcb1d637100d";
}
async get(openid){
var key = this.prefix+"_"+openid;
var result = await this.redisClient.get(key);
var obj = null;
if(result){
obj = JSON.parse(result);
}
if(obj && obj.access_token){
return obj;
}
return null;
}
async set(obj,openid){
var expire = 7100;
if(obj.expires_in){
var time = obj.expires_in;
var now = Date.parse(new Date())/1000;
if(now<time){
expire = time - now;
}else{
return null;
}
}
var key = this.prefix+"_"+openid;
if(obj && obj.access_token){
var stringobj = JSON.stringify(obj);
await this.redisClient.setWithEx(key,stringobj,expire);
return obj;
}
return null;
}
}
module.exports=feishuUserAccessTokenCache;
\ No newline at end of file
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class MagCache extends CacheBase {
constructor() {
super();
this.prefix = "magCache";
}
desc() {
return "应用UI配置缓存";
}
//暂时没有用到,只是使用其帮助的方法
prefix() {
return settings.cacheprefix + "_uiconfig:";
}
async getCacheSmembersByKey(key) {
return this.redisClient.smembers(key);
}
async delCacheBySrem(key, value) {
return this.redisClient.srem(key, value)
}
async keys(p) {
return this.redisClient.keys(p);
}
async get(k) {
return this.redisClient.get(k);
}
async del(k) {
return this.redisClient.delete(k);
}
async clearAll() {
console.log("xxxxxxxxxxxxxxxxxxxclearAll............");
return this.redisClient.flushall();
}
}
module.exports = MagCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class TlPayLocker extends CacheBase {
constructor() {
super();
this.prefix = settings.cacheprefix + "_tlPayLocker:";
}
desc() {
return "支付业务锁";
}
prefix() {
return settings.cacheprefix + "_uiconfig:";
}
async init(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key, "1", 1800);
}
async enter(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpop(key);
}
async release(tradekey) {
const key = this.prefix + tradekey;
return this.redisClient.rpushWithEx(key, "1", 1800);
}
}
module.exports = TlPayLocker;
const CacheBase=require("../cache.base");
const system=require("../../system");
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 微信开放平台 公众号或小程序的接口调用凭据(授权方令牌)缓存(2小时后失效)
*/
class WxJsapiTicketCache extends CacheBase{
constructor(){
super();
this.prefix="wx_ticket_wx4c91e81bbb6039cd";
this.restClient = system.getObject("util.restClient");
this.wxTokenSve = system.getObject("service.common.wxTokenSve");
}
desc() {
return "应用UI配置缓存";
}
prefix() {
return "wx_ticket_wx4c91e81bbb6039cd";
}
async get(access_token){//公众号appid
var key = this.prefix;
var result = await this.redisClient.get(key);
var obj = null;
if(result){
console.log(result,"缓存中获取token+++++++++++++++++++++++");
obj=JSON.parse(result);
}
if(!obj){//无缓存
var newobj = await this.wxTokenSve.getJsapiTicket(access_token);
console.log(newobj);
if(newobj){
var newobjstring=JSON.stringify(newobj);
await this.redisClient.setWithEx(key,newobjstring,7000);
return newobj;
}else{
return null;
}
}
return obj;
}
}
module.exports=WxJsapiTicketCache;
\ No newline at end of file
const CacheBase=require("../cache.base");
const system=require("../../system");
// const OpenplatformWxop = require("../../wxop/impl/openplatformWxop");
/**
* 微信开放平台 公众号或小程序的接口调用凭据(授权方令牌)缓存(2小时后失效)
*/
class WxTokenCache extends CacheBase{
constructor(){
super();
this.prefix="wx_toekn_wx4c91e81bbb6039cd";
this.restClient = system.getObject("util.restClient");
this.wxTokenSve = system.getObject("service.common.wxTokenSve");
}
desc() {
return "应用UI配置缓存";
}
prefix() {
return "wx_toekn_wx4c91e81bbb6039cd";
}
async get(){//公众号appid
var key = this.prefix;
var result = await this.redisClient.get(key);
var obj = null;
if(result){
console.log(result,"缓存中获取token+++++++++++++++++++++++");
obj=JSON.parse(result);
}
if(!obj){//无缓存
var newobj = await this.wxTokenSve.getToken();
console.log(newobj);
if(newobj && newobj.access_token){
var newobjstring=JSON.stringify(newobj);
// await this.redisClient.set(key,newobjstring);
// this.redisClient.client.expire(key, 7000);
await this.redisClient.setWithEx(key,newobjstring,7000);
return newobj;
}else{
return null;
}
}
return obj;
}
}
module.exports=WxTokenCache;
\ No newline at end of file
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 customInsert(sql, paras, t) {
var tmpParas = null;
if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.INSERT };
tmpParas.transaction = t;
} else {
tmpParas = { replacements: paras, type: this.db.QueryTypes.INSERT };
tmpParas.transaction = t;
}
} else {
tmpParas = paras == null || paras == 'undefined' || paras.keys == 0 ? { type: this.db.QueryTypes.INSERT } : { replacements: paras, type: this.db.QueryTypes.INSERT };
}
var result = this.db.query(sql, tmpParas);
return result;
}
async customDelete(sql, paras, t) {
var tmpParas = null;
if (t && t != 'undefined') {
if (paras == null || paras == 'undefined') {
tmpParas = { type: this.db.QueryTypes.DELETE };
tmpParas.transaction = t;
} else {
tmpParas = { replacements: paras, type: this.db.QueryTypes.DELETE };
tmpParas.transaction = t;
}
} else {
tmpParas = paras == null || paras == 'undefined' || paras.keys == 0 ? { type: this.db.QueryTypes.DELETE } : { replacements: paras, type: this.db.QueryTypes.DELETE };
}
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 system=require("../../../system");
const Dao=require("../../dao.base");
class GatewaypushlogDao extends Dao{
constructor(){
super(Dao.getModelName(GatewaypushlogDao));
}
}
module.exports=GatewaypushlogDao;
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 PushFailLogDao extends Dao{
constructor(){
super(Dao.getModelName(PushFailLogDao));
}
}
module.exports=PushFailLogDao;
\ No newline at end of file
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
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 },
"push_return_type": { "0": "推送失败", "1": "推送成功" },
},
}
}
\ No newline at end of file
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("gatewaypushlog", {
requestId: DataTypes.STRING,
requestUrl: DataTypes.STRING, //请求地址
requestjson: DataTypes.STRING,//请求地址
pushUrl: DataTypes.STRING,//调用地址
pushActionType: DataTypes.STRING,//调用参数
pushtimes:DataTypes.INTEGER,//推送次数
pushStatus:DataTypes.STRING,//推送状态
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'gateway_pushlog',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("oplog", {
appid: DataTypes.STRING,
appkey: DataTypes.STRING,
requestId: DataTypes.STRING,
logLevel: {
type: DataTypes.ENUM,
allowNull: false,
values: Object.keys(uiconfig.config.pdict.logLevel),
defaultValue: "info",
},
op: DataTypes.STRING(4000),
content: DataTypes.TEXT('long'),
resultInfo: DataTypes.TEXT('long'),
clientIp: DataTypes.STRING,
agent: DataTypes.STRING(500),
opTitle: DataTypes.TEXT,
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'center_channel_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("pushfaillog", {
appid: DataTypes.STRING,
appkey: DataTypes.STRING,
requestId: DataTypes.STRING,
content: DataTypes.TEXT('long'),
resultInfo: DataTypes.TEXT('long'),
clientIp: DataTypes.STRING,
opTitle: DataTypes.STRING(500),
failType: DataTypes.INTEGER,//错误类型,1为old-rpc推送失败日志,2为new-rpc推送失败日志,业务处理失败日志
pushNumber: DataTypes.INTEGER,//推送次数
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'center_channel_pushfaillog',
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(4000),
content: DataTypes.TEXT('long'),
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: DataTypes.STRING(500),
opTitle: DataTypes.STRING(500),
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'center_channel_pushlog',
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 logCtl=system.getObject("service.common.oplogSve");
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 AppServiceBase = require("../../app.base")
const settings = require("../../../../config/settings")
class AskForService extends AppServiceBase {
constructor() {
super();
this.restClient = system.getObject("util.restClient")
this.centerOrderUrl = settings.centerOrderUrl()
this.centerCacheUrl = settings.centerCacheUrl()
}
/**
* @description 商标尼斯查询
* @author liangwk
* @param {*} param
* @returns
* @memberof AskForService
*/
async niceQuery (param) {
let url = `${this.centerCacheUrl}tm_treasure_name`
let result = await this.restClient.execPost(param, url)
result = result.stdout
result = JSON.parse(result)
return result;
}
/**
* @description 获取收藏列表
* @author liangwk
* @param {*} pobj
* @returns
* @memberof AskForService
*/
async getCollect (pobj) {
if (pobj.actionBody.collections) {
pobj.actionType = 'getByUidAndCollections'
} else {
pobj.actionType = 'getByUid'
}
let url = `${this.centerOrderUrl}askfor/collect/tradeMark`
let result = await this.restClient.execPost(pobj, url)
result = result.stdout
result = JSON.parse(result)
return result
}
/**
* @description
* @author liangwk
* @param {*} pobj
* @returns
* @memberof AskForService
*/
async collect (pobj) {
pobj.actionType = pobj.actionBody.id ? 'delete' : 'create'
let url = `${this.centerOrderUrl}askfor/collect/tradeMark`
let result = await this.restClient.execPost(pobj, url)
result = result.stdout
result = JSON.parse(result)
return result
}
async getAskFor (pobj) {
pobj.actionType = 'getByUid'
let url = `${this.centerOrderUrl}askfor/askfor/tradeMark`
let result = await this.restClient.execPost(pobj, url)
result = result.stdout
result = JSON.parse(result)
return result
}
async askFor (pobj) {
pobj.actionType = pobj.actionBody.id ? 'delete' : 'create'
let url = `${this.centerOrderUrl}askfor/askfor/tradeMark`
let result = await this.restClient.execPost(pobj, url)
result = result.stdout
result = JSON.parse(result)
return result
}
}
module.exports = AskForService;
\ No newline at end of file
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");
const uuidv4 = require('uuid/v4');
const getRawBody = require('raw-body');
class GatewaypushlogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(GatewaypushlogService));
this.execClient = system.getObject("util.execClient");
}
async taskAliIcapi() {
try {
var sql = "select * from gateway_pushlog where pushStatus='wts' and pushtimes<4"
var icloginfos = await this.customQuery(sql);
if (icloginfos.length > 0) {
var count = 10;
if (icloginfos.length < count) {
count = icloginfos.length;
}
var self = this;
for (var i = 0; i < count; i++) {
var icloginfo = icloginfos[i];
var requestdata = null;
if (icloginfo && icloginfo.requestjson) {
requestdata = JSON.parse(icloginfo.requestjson);
}
var url = settings.gatewayUrl() + "action/intentionapi/springBoard";
var rtn = await self.execClient.execPost(requestdata, url);
var data = JSON.parse(rtn.stdout);
if (data.success) {
icloginfo.pushStatus = "yts";
} else {
icloginfo.pushtimes += 1;
}
await this.update(icloginfo);
}
}
return system.getResultSuccess();
} catch (error) {
return system.getResultFail(-1,error);
}
}
}
module.exports = GatewaypushlogService;
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.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
}
async error(qobj) {
this.create(qobj);
}
async info(qobj) {
this.create(qobj);
}
async create(qobj) {
var rc = system.getObject("util.execClient");
try {
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中写入日志
rc.execPost(qobj, this.opLogUrl);
} else {
this.dao.create(qobj);
}
} catch (e) {
qobj.content = e.stack;
this.dao.create(qobj);
}
}
async createDb(qobj) {
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
this.dao.create(qobj);
} catch (e) {
//日志记录
this.create({
appid: qobj.appid || "",
appkey: qobj.appkey || "",
requestId: qobj.requestId || "",
op: qobj.op || "",
content: qobj.content + "-->error:" + e.stack,
clientIp: qobj.clientIp || "",
optitle: qobj.optitle || "" + "-->添加日志失败center_channel_log->createDb",
});
}
}
}
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.logCtl = system.getObject("service.common.oplogSve");
this.pushfaillogDao = system.getObject("db.common.pushfaillogDao");
}
async createDb(qobj) {
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
this.dao.create(qobj);
} catch (e) {
//日志记录
this.logCtl.error({
appid: qobj.appid || "",
appkey: qobj.appkey || "",
requestId: qobj.requestId || "",
op: qobj.op || "",
content: qobj.content + "-->error:" + e.stack,
clientIp: qobj.clientIp || "",
optitle: qobj.optitle || "" + "-->添加日志失败center_channel_pushlog->createDb",
});
}
}
async createFailLogDb(qobj) {
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
this.pushfaillogDao.create(qobj);
} catch (e) {
//日志记录
this.logCtl.error({
appid: qobj.appid || "",
appkey: qobj.appkey || "",
requestId: qobj.requestId || "",
op: qobj.op || "",
content: qobj.content + "-->error:" + e.stack,
clientIp: qobj.clientIp || "",
optitle: qobj.optitle || "" + "-->添加日志失败center_channel_pushfaillog->createFailLogDb",
});
}
}
async delDbPushfaillogById(id) {
this.pushfaillogDao.bulkDeleteByWhere({ where: { id: id } });
}
async getFailLogList() {
var sql = "SELECT id,`content`,failType,pushNumber,opTitle FROM `center_channel_pushfaillog` WHERE failType IN(1,2,4) AND pushNumber<10 LIMIT 200";
var list = await this.pushfaillogDao.customQuery(sql);
var result = system.getResultSuccess(list);
return result;
}
async addPublicServiceLog(pobj, req) {
var sql = "INSERT INTO `igirl_api`.`center_channel_public_servicelog` (`appkey`,`pushUrl`,`pushContent`,`resultInfo`,`pushNumber`,`clientIp`,created_at)" +
"VALUES(:appkey,:pushUrl,:pushContent,:resultInfo,:pushNumber,:clientIp,:created_at)";
var params = {
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
pushUrl: pobj.actionBody.pushUrl,
pushContent: pobj.actionBody.pushContent ? JSON.stringify(pobj.actionBody.pushContent) : "",
resultInfo: pobj.actionBody.resultInfo ? JSON.stringify(pobj.actionBody.resultInfo) : "",
pushNumber: pobj.actionBody.pushNumber || 0,
clientIp: req.clientIp || "",
created_at: new Date()
}
await this.pushfaillogDao.customInsert(sql, params);
return system.getResultSuccess();
}
async delPublicServiceLog(id) {
var sql = "DELETE FROM `center_channel_public_servicelog` WHERE id=:id";
var params = {
id: id
}
await this.pushfaillogDao.customDelete(sql, params);
return system.getResultSuccess();
}
async getPublicServiceLogList() {
var sql = "SELECT id,appkey,`pushUrl`,pushContent,pushNumber,clientIp FROM `center_channel_public_servicelog` WHERE pushNumber<10 LIMIT 200";
var list = await this.pushfaillogDao.customQuery(sql);
var result = system.getResultSuccess(list);
return result;
}
}
module.exports = PushlogService;
const system = require("../../../system");
var settings = require("../../../../config/settings");
/**
* 微信token
* zhuangbing
* 2020.02.17
*/
class WxTokenService{
constructor(){
this.rc=system.getObject("util.execClient");
this.logDao = system.getObject("db.common.oplogDao");
}
/**
* 获取微信access_token,用于微信H5链接分享
* 返回结果:
* component_access_token 第三方平台access_token
* expires_in 有效期
*/
async getToken(){
try{
var wxconfig = {
AppID : "wx4c91e81bbb6039cd",
Secret : "12048e66dba64f2581e02b306680b232",
Token:"bosstoken",
AccessTokenUrl : "https://api.weixin.qq.com/cgi-bin/token",
};
// var url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx8aa8a8d4ff3da8bd&secret=5b64d43832cfd08327e9369aa455f799";
var url="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx4c91e81bbb6039cd&secret=12048e66dba64f2581e02b306680b232";
var rtn=await this.rc.execGet({},url);
console.log(rtn);
this.logDao.create({
op: "WxTokenService/getToken",
content: JSON.stringify(rtn),
optitle: "获取政策微信access_token",
});
var result=JSON.parse(rtn.stdout);
return result;
}catch(e){
return null;
}
}
/**
* 获取微信getJsapiTicket,用于微信H5链接分享
*/
async getJsapiTicket(access_token){
try{
var url="https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + access_token + "&type=jsapi";
var rtn=await this.rc.execGet({},url);
console.log(rtn);
this.logDao.create({
op: "WxTokenService/getJsapiTicket",
content: JSON.stringify(rtn),
optitle: "获取政策微信getJsapiTicket",
});
var result=JSON.parse(rtn.stdout);
return result;
}catch(e){
return null;
}
}
/**
* 通过code换取网页授权access_token,用于政策H5 oauth授权登录
* 注意:
* 里通过code换取的是一个特殊的网页授权access_token,
* 与基础支持中的access_token(该access_token用于调用其他接口)不同。
* 公众号可通过下述接口来获取网页授权access_token。
* 如果网页授权的作用域为snsapi_base,则本步骤中获取到网页授权access_token的同时,也获取到了openid,
* snsapi_base式的网页授权流程即到此为止。
*
*/
async getTokenAndOpenid(obj){
try {
if(!obj || !obj.code){
return system.getResultFail(-1,"code参数不能为空");
}
var url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx6f3ebe44defe336a&secret=82e8e32421647f0a86bbad14f041959b&code="+
obj.code+"&grant_type=authorization_code";
var rtn=await this.rc.execGet({},url);
console.log(rtn);
this.logDao.create({
op: "WxTokenService/getToken2",
content: JSON.stringify(rtn),
optitle: "获取政策微信getToken2",
});
var result=JSON.parse(rtn.stdout);
return system.getResultSuccess(result);
} catch (e) {
var err = JSON.stringify(e.stack);
return system.getResultFail(-200,err);
}
}
}
module.exports=WxTokenService;
\ No newline at end of file
const System = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
const AppServiceBase = require("../../app.base");
class EnterpriseService extends AppServiceBase {
constructor() {
super();
this.zcApiUrl = settings.reqZcApi();
};
async opReqResult(pobj, req) {
var url = this.zcApiUrl + "action/enterpriseQuery/springBoard";
var result = await this.restPostUrl(pobj, url);
return result;
};
}
module.exports = EnterpriseService;
\ No newline at end of file
const System = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
const AppServiceBase = require("../../app.base");
class LicenseService extends AppServiceBase {
constructor() {
super();
this.zcApiUrl = settings.reqZcApi();
};
async opReqResult(pobj, req) {
var url = this.zcApiUrl + "action/licenseQuery/springBoard";
var result = await this.restPostUrl(pobj, url);
return result;
};
}
module.exports = LicenseService;
\ No newline at end of file
const System = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
const AppServiceBase = require("../../app.base");
class PatentycService extends AppServiceBase {
constructor() {
super();
this.zcApiUrl = settings.reqZcApi();
};
async opReqResult(pobj, req) {
var url = this.zcApiUrl + "action/patentQuery/springBoard";
var result = await this.restPostUrl(pobj, url);
return result;
}
}
module.exports = PatentycService;
const system = require("../../../system");
const crypto = require('crypto');
var settings = require("../../../../config/settings");
class PolicyService{
constructor() {
this.centerOrderUrl = settings.centerOrderUrl();
this.execClient = system.getObject("util.execClient");
this.cacheManager = system.getObject("db.common.cacheManager");
};
// sha1加密
sha1(str) {
let shasum = crypto.createHash("sha1")
shasum.update(str)
str = shasum.digest("hex")
return str
}
/**
* 生成签名的时间戳
* @return {字符串}
*/
createTimestamp() {
return parseInt(new Date().getTime() / 1000) + ''
}
/**
* 生成签名的随机串
* @return {字符串}
*/
createNonceStr() {
return Math.random().toString(36).substr(2, 15)
}
/**
* 对参数对象进行字典排序
* @param {对象} args 签名所需参数对象
* @return {字符串} 排序后生成字符串
*/
raw(args) {
var keys = Object.keys(args)
keys = keys.sort()
var newArgs = {}
keys.forEach(function (key) {
newArgs[key.toLowerCase()] = args[key]
})
var string = ''
for (var k in newArgs) {
string += '&' + k + '=' + newArgs[k]
}
string = string.substr(1)
return string
}
async getWxSign(url){
try {
if(!url){
return system.getResult("url不能为空");
}
var tokenRes = await this.cacheManager["WxTokenCache"].get();
if(tokenRes){
if(tokenRes.access_token){
var ticketRes = await this.cacheManager["WxJsapiTicketCache"].get(tokenRes.access_token);
if(ticketRes){
if(ticketRes.ticket){
var ret = {
jsapi_ticket: ticketRes.ticket,
nonceStr: "zhengcepolicy",
timestamp: parseInt(new Date().getTime() / 1000),
url: url
};
var string = this.raw(ret)
ret.signature = this.sha1(string)
ret.appId = "wx4c91e81bbb6039cd";
console.log('ret', ret)
return system.getResultSuccess(ret);
}else{
return system.getResultFail(-2,"获取微信配置参数失败",ticketRes);
}
}
}else{
return system.getResultFail(-1,"获取微信配置参数失败",tokenRes);
}
}
return system.getResult("获取微信配置参数失败");
} catch (e) {
return system.getResult(e.stack);
}
}
async reqPolicyApi(pobj){
var url = this.centerOrderUrl + "action/policy/springBoard";
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
return data;
}
async policyQuery(pobj) {
var url = this.centerOrderUrl + "action/policy/springBoard";
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
return data;
}
async submitPolicyNeed(pobj) {
var url = this.centerOrderUrl + "action/policy/springBoard";
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
return data;
}
async getPolicyNeedList(pobj){
var url = this.centerOrderUrl + "action/policy/springBoard";
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
return data;
}
async submitPolicyNeedNotes(pobj){
var url = this.centerOrderUrl + "action/policy/springBoard";
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
return data;
}
async submitPolicysubscribe(pobj){
var url = this.centerOrderUrl + "action/policy/springBoard";
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
return data;
}
}
module.exports = PolicyService;
const system=require("../../../system");
var settings=require("../../../../config/settings");
class bigtmService {
constructor(){
this.GsbByTmSearchApi=system.getObject("api.tmquery.bytmsearch");
}
}
module.exports=bigtmService;
// var test = new TmqueryService();
// test.bigtmcompanyjuhe({status:3,tmreg_year:2018,seltype:1,apply_addr_province:""}).then(function(d){
// console.log("#################################");
// console.log(d);
// })
const system=require("../../../system");
var settings=require("../../../../config/settings");
class BytmmonitService {
constructor(){
}
}
module.exports=BytmmonitService;
// var test = new TmqueryService();
// test.bigtmcount({tmreg_year:2018,apply_addr_province:""}).then(function(d){
// console.log("#################################");
// console.log(d);
// })
const system = require("../../../system");
var settings = require("../../../../config/settings");
const crypto = require('crypto');
const cryptoJS = require("crypto-js");
var fs = require("fs");
// var AWS = require('aws-sdk');
var ak = "D0784B08541791E175B544D5317281B0";
var sk = "93AB12B3BFADB1356EC078D52B064A33";
var ossurl = "https://hangtang.s3.cn-north-1.jdcloud-oss.com";
class JdossService {
constructor() {
this.execClient = system.getObject("util.execClient");
}
async getJdOssConfig(app, opStr) {
var date = new Date();
var month = date.getMonth()+1;
month=month.toString();
if(month<10){
month="0"+month;
}
var day = date.getDate().toString();
if(day<10){
day="0"+day;
}
var time = date.getFullYear().toString()+month+day;
let timestamp = date.getTime();//当前的时间戳
timestamp = timestamp + 6 * 60 * 60 * 1000;
//格式化时间获取年月日
var dateAfter = new Date(timestamp);
var policyText = {
"expiration": dateAfter,
"conditions": [
{"bucket": "hangtang"},
["starts-with", "$key", "zc"],
{"Content-Type": "image/jpeg"},
{"X-Amz-Credential": ak+"/"+time+"/cn-north-1/s3/aws4_request"},
{"X-Amz-Algorithm": "AWS4-HMAC-SHA256"},
{"X-Amz-Date": date}
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature = crypto.createHmac('sha256', sk).update(policyBase64).digest("hex");
var data = {
"OSSAccessKeyId":ak,
"Bucket":"hangtang",
"Signature":signature,
"policy": policyBase64,
"success_action_status": 201,
"x-amz-algorithm":"AWS4-HMAC-SHA256",
"x-amz-credential":ak+"/"+time+"/cn-north-1/s3/aws4_request",
"x-amz-date":date,
"x-amz-signature":signature,
"url": ossurl
};
return system.getResultSuccess(data);
}
}
module.exports = JdossService;
const system = require("../../../system");
var settings = require("../../../../config/settings");
class TmqueryService {
constructor() {
this.zcApiUrl = settings.reqZcApi();
this.execClient = system.getObject("util.execClient");
}
async findTrademarkNameAccurate(queryobj, req) {//通过商标名来进行精准查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkNameAccurate";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkNameIndex(queryobj, req) {//根据商标名称模糊查询,首次查询,
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkNameIndex";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkName(queryobj, req) {//根据商标名称模糊查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkName";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkzchAccurate(queryobj, req) {//通过商标号来进行精准查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkzchAccurate";
return await this.opReqResult(url, queryobj, req);
}
async findTrademarkzcr(queryobj, req) {//通过注册人模糊查询
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findTrademarkzcr";
return await this.opReqResult(url, queryobj, req);
}
async imagequery(queryobj, req) {//图像检索
var url = this.zcApiUrl + "api/trademark/tmqueryApi/imagequery";
return await this.opReqResult(url, queryobj, req);
}
async findImageSearch(queryobj, req) { //图像检索查询,
var url = this.zcApiUrl + "api/trademark/tmqueryApi/findImageSearch";
return await this.opReqResult(url, queryobj, req);
}
async tradeMarkDetail(queryobj, req) {//商标详情
var url = this.zcApiUrl + "api/trademark/tmqueryApi/tradeMarkDetail";
return await this.opReqResult(url, queryobj, req);
}
async sbzuixinsearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/sbzuixinsearch";
return await this.opReqResult(url, queryobj, req);
}
async noticequeryTMZCSQ(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticequeryTMZCSQ";
return await this.opReqResult(url, queryobj, req);
}
async noticequery(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticequery";
return await this.opReqResult(url, queryobj, req);
}
async noticezcggsearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticezcggsearch";
return await this.opReqResult(url, queryobj, req);
}
async noticesearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/noticesearch";
return await this.opReqResult(url, queryobj, req);
}
async getCompanyInfoNoUser(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/getCompanyInfoNoUser";
return await this.opReqResult(url, queryobj, req);
}
async getNclDetail(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/getNclDetail";
return await this.opReqResult(url, queryobj, req);
}
async gettwoNcl(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/gettwoNcl";
return await this.opReqResult(url, queryobj, req);
}
async nclFuwuSearch(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/nclFuwuSearch";
return await this.opReqResult(url, queryobj, req);
}
async tmreport(queryobj, pobj,req) {
if (!queryobj.type) {
return { code: -102, msg: "参数错误" }
}
if (!queryobj.receiverId) {
return { code: -102, msg: "参数错误" }
}
if (queryobj.push_type == 1 && !queryobj.email) {
return { code: -102, msg: "参数错误" }
}
if (queryobj.push_type == 2 && !queryobj.notifyUrl) {
return { code: -102, msg: "参数错误" }
}
if(queryobj.type!=1){
return { code: -101, msg: "功能开发中......" }
}
queryobj.wxuser_id = queryobj.receiverId;
queryobj.appid =pobj.appInfo.id;
var url = settings.igirlWeburl() + "web/toolCtl/createMonitoringReportH5p";
return await this.opReqResult(url, queryobj, req);
}
async opReqResult(reqUrl, queryobj, req) {
var rtn = await this.execClient.execPushDataPost(queryobj, reqUrl, req.headers["token"], req.headers["request-id"]);
var data = JSON.parse(rtn.stdout);
return data;
}
}
module.exports = TmqueryService;
const system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const crypto = require('crypto');
const cryptoJS = require("crypto-js");
class ToolService extends AppServiceBase {
constructor() {
super();
this.zcApiUrl = settings.reqZcApi();
// this.execClient = system.getObject("util.execClient");
}
async getCropperPic(obj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getCropperPic";
return await this.opReqResult(url, obj, req);
}
//智能分析 bycquerytm.html
async bycznfx(obj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/bycznfx";
return await this.opReqResult(url, queryobj, req);
}
//根据尼斯编号获取尼斯子类,尼斯树节点点击时触发调用
async getNcl(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getNcl";
return await this.opReqResult(url, queryobj, req);
}
//根据大类、名称查询尼斯信息
async getNclByLikeNameAndNcl(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getNclByLikeNameAndNcl";
return await this.opReqResult(url, queryobj, req);
}
//文字转图片
async word2pic(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/word2pic";
return await this.opReqResult(url, queryobj, req);
}
//商标样式转换 彩色商标图样转黑白,调整图样宽高,生成符合商标局规范的标准商标图样
async uploadStandardTm(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/uploadStandardTm";
return await this.opReqResult(url, queryobj, req);
}
//营业执照(身份证明)图片文件转为符合商标局要求的pdf文件
async pic2pdf(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/pic2pdf";
return await this.opReqResult(url, queryobj, req);
}
//企业近似查询
async getCompanyInfoByLikeName(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getCompanyInfoByLikeName";
var result = await this.opReqResult(url, queryobj, req);
if (result.data.length > 0) {
return system.getResultSuccess(result.data);
}
return system.getResult(null, "data is empty,100565");
}
//企业注册信息精确查询
async getEntregistryByCompanyName(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/getEntregistryByCompanyName";
var result = await this.opReqResult(url, queryobj, req);
if (Object.keys(result).length > 3) {
return system.getResultSuccess(result);
}
return system.getResult(null, "data is empty,100560");
}
//调整委托书 调整委托书大小使其符合商标局规范
async adjustWTSSize(queryobj, req) {
var url = this.zcApiUrl + "api/tool/toolApi/adjustWTSSize";
return await this.opReqResult(url, queryobj, req);
}
//工商核名
async icheming(queryobj, req) {
var url = this.zcApiUrl + "api/trademark/tmqueryApi/icheming";
return await this.opReqResult(url, queryobj, req);
}
async opReqResult(reqUrl, queryobj, req) {
var rtn = await this.execClient.execPushDataPost(queryobj, reqUrl, req.headers["token"], req.headers["request-id"]);
var data = JSON.parse(rtn.stdout);
return data;
}
async getOssConfig(pobj, req) {//获取oss信息
var reqUrl = settings.centerAppUrl() + "auth/accessAuth/getOssInfo";
var result = await this.restPostUrl(pobj, reqUrl);
return result;
}
//加密信息
async encryptStr(app, opStr) {
if (!opStr) {
return system.getResult(null, "opStr is empty");
}
let keyHex = cryptoJS.enc.Utf8.parse(app.uappKey);
let ivHex = cryptoJS.enc.Utf8.parse(app.appSecret.substring(0, 8));
var cipherStr = cryptoJS.TripleDES.encrypt(opStr, keyHex, { iv: ivHex }).toString();
return system.getResultSuccess(cipherStr);
}
//解密信息
async decryptStr(app, opStr) {
if (!opStr) {
return system.getResult(null, "opStr is empty");
}
let keyHex = cryptoJS.enc.Utf8.parse(app.uappKey);
let ivHex = cryptoJS.enc.Utf8.parse(app.appSecret.substring(0, 8));
var bytes = cryptoJS.TripleDES.decrypt(opStr, keyHex, {
iv: ivHex
});
var plaintext = bytes.toString(cryptoJS.enc.Utf8);
return system.getResultSuccess(plaintext);
}
}
module.exports = ToolService;
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