Commit f80340bb by 宋毅

tj

parent bf89eecf
const system = require("../system"); const system = require("../system");
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const DocBase = require("./doc.base"); // const DocBase = require("./doc.base");
const uuidv4 = require('uuid/v4'); const uuidv4 = require('uuid/v4');
const md5 = require("MD5"); const md5 = require("MD5");
class APIBase extends DocBase { class APIBase {
constructor() { constructor() {
super(); this.logCtl = system.getObject("service.common.oplogSve");
this.cacheManager = system.getObject("db.common.cacheManager"); this.exTime = 2 * 3600;//缓存过期时间,2小时
this.logCtl = system.getObject("web.common.oplogCtl");
this.oplogSve = system.getObject("service.common.oplogSve");
} }
getUUID() { getUUID() {
var uuid = uuidv4(); var uuid = uuidv4();
var u = uuid.replace(/\-/g, ""); var u = uuid.replace(/\-/g, "");
return u; return u;
} }
/** async checkAcck(gname, methodname, pobj, query, req) {
* 验证签名 if (methodname.length > 4) {
* @param {*} params 要验证的参数 var prefixStr = methodname.substr(0, 4);
* @param {*} app_key 应用的校验key if (prefixStr == "task" || prefixStr == "nbtz") {
*/ return system.getResultSuccess();
async verifySign(params, app_key) { }
if (!params) { }//为任务或内部通知的放行
return system.getResult(null, "请求参数为空"); var method = pobj.actionType;
} if (method && method.length > 4) {
if (!params.sign) { var prefixStr = method.substr(0, 4);
return system.getResult(null, "请求参数sign为空"); if (prefixStr == "task" || prefixStr == "nbtz") {
} return system.getResultSuccess();
if (!params.times_tamp) {
return system.getResult(null, "请求参数times_tamp为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
} }
} }
if (signArr.length == 0) { if (["updateTmStatus"].indexOf(methodname) >= 0) {
return system.getResult(null, "请求参数组装签名参数信息为空"); return system.getResultSuccess();
} }
var resultSignStr = signArr.join("&") + "&key=" + app_key; if (!pobj.appInfo) {
var resultTmpSign = md5(resultSignStr).toUpperCase(); return system.getResult(null, "pobj.appInfo can not be empty !!");
if (params.sign != resultTmpSign) {
return system.getResult(null, "签名验证失败");
} }
return system.getResultSuccess(); return system.getResultSuccess();
} }
/**
* 白名单验证
* @param {*} gname 组名
* @param {*} methodname 方法名
*/
async isCheckWhiteList(gname, methodname) {
var fullname = gname + "." + methodname;
var lst = [
"test.testApi"
];
var x = lst.indexOf(fullname);
return x >= 0;
}
async checkAcck(gname, methodname, pobj, query, req) {
var appInfo = null;
var result = system.getResultSuccess();
var ispass = await this.isCheckWhiteList(gname, methodname);
var appkey = req.headers["accesskey"];
var app_id = req.headers["app_id"];
if (ispass) {
return result;
}//在百名单里面
if (app_id) {
appInfo = await this.cacheManager["ApiAppIdCheckCache"].cache(app_id, null, 3000);
if (!appInfo) {
result.status = system.appidFail;
result.msg = "请求头app_id值失效,请重新获取";
}
// var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
// if (signResult.status != 0) {
// result.status = system.signFail;
// result.msg = signResult.msg;
// }
}//验签
else if (appkey) {
appInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(appkey, { status: true }, 3000);
if (!appInfo || !appInfo.app) {
result.status = system.tokenFail;
result.msg = "请求头accesskey失效,请重新获取";
}
}//验证accesskey
else {
result.status = -1;
result.msg = "请求头没有相关访问参数,请验证后在进行请求";
}
return result;
}
async doexec(gname, methodname, pobj, query, req) { async doexec(gname, methodname, pobj, query, req) {
// var requestid = this.getUUID(); req.requestId = this.getUUID();
var requestid = req.headers["request-id"] || this.getUUID();
try { try {
//验证accesskey或验签 //验证accesskey或验签
// var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req); var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
// if (isPassResult.status != 0) { if (isPassResult.status != 0) {
// isPassResult.requestid = ""; isPassResult.requestId = "";
// return isPassResult; return isPassResult;
// }
if (pobj && pobj.action_body) {
pobj.action_body.merchant_id = pobj.action_body.merchant_id || req.headers["app_id"];
}
if (query) {
query.merchant_id = req.headers["app_id"];
} }
var rtn = await this[methodname](pobj, query, req); var rtn = await this[methodname](pobj, query, req);
rtn.requestId = requestid; this.logCtl.createDb({
appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
this.oplogSve.createDb({ appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
appid: req.headers["app_id"] || "", requestId: req.requestId,
appkey: req.headers["accesskey"] || "",
requestId: requestid,
op: req.classname + "/" + methodname, op: req.classname + "/" + methodname,
content: JSON.stringify(pobj), content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn), resultInfo: JSON.stringify(rtn),
...@@ -128,24 +56,35 @@ class APIBase extends DocBase { ...@@ -128,24 +56,35 @@ class APIBase extends DocBase {
agent: req.uagent, agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey, opTitle: "api服务提供方appKey:" + settings.appKey,
}); });
rtn.requestId = req.requestId;
return rtn; return rtn;
} catch (e) { } catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........") console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.createDb({
appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
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({ this.logCtl.error({
appid: req.headers["app_id"] || "", appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
appkey: req.headers["accesskey"] || "", appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
requestId: requestid, requestId: req.requestId,
op: pobj.classname + "/" + methodname, op: req.classname + "/" + methodname,
content: e.stack, content: e.stack,
clientIp: pobj.clientIp, clientIp: pobj.clientIp,
agent: req.uagent, agent: req.uagent,
optitle: "api调用出现异常,请联系管理员_zcapi", optitle: "api调用出现异常,请联系管理员",
}); });
var rtnerror = system.getResultFail(-200, "出现异常,请联系管理员"); var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
rtnerror.requestid = requestid; rtnerror.requestId = req.requestId;
return rtnerror; return rtnerror;
} }
} }
} }
module.exports = APIBase; module.exports = APIBase;
const system=require("../system");
const uuidv4 = require('uuid/v4');
class DocBase{
constructor(){
this.apiDoc={
group:"逻辑分组",
groupDesc:"",
name:"",
desc:"请对当前类进行描述",
exam:"概要示例",
methods:[]
};
this.initClassDoc();
}
initClassDoc(){
// this.descClass();
// this.descMethods();
}
descClass(){
var classDesc= this.classDesc();
this.apiDoc.group=classDesc.groupName;
this.apiDoc.groupDesc=classDesc.groupDesc;
this.apiDoc.name=classDesc.name;
this.apiDoc.desc=classDesc.desc;
this.apiDoc.exam=this.examHtml();
}
examHtml(){
var exam= this.exam();
exam=exam.replace(/\\/g,"<br/>");
return exam;
}
exam(){
throw new Error("请在子类中定义类操作示例");
}
classDesc(){
throw new Error(`
请重写classDesc对当前的类进行描述,返回如下数据结构
{
groupName:"auth",
groupDesc:"认证相关的包"
desc:"关于认证的类",
exam:"",
}
`);
}
descMethods(){
var methoddescs=this.methodDescs();
for(var methoddesc of methoddescs){
for(var paramdesc of methoddesc.paramdescs){
this.descMethod(methoddesc.methodDesc,methoddesc.methodName
,paramdesc.paramDesc,paramdesc.paramName,paramdesc.paramType,
paramdesc.defaultValue,methoddesc.rtnTypeDesc,methoddesc.rtnType);
}
}
}
methodDescs(){
throw new Error(`
请重写methodDescs对当前的类的所有方法进行描述,返回如下数据结构
[
{
methodDesc:"生成访问token",
methodName:"getAccessKey",
paramdescs:[
{
paramDesc:"访问appkey",
paramName:"appkey",
paramType:"string",
defaultValue:"x",
},
{
paramDesc:"访问secret",
paramName:"secret",
paramType:"string",
defaultValue:null,
}
],
rtnTypeDesc:"xxxx",
rtnType:"xxx"
}
]
`);
}
descMethod(methodDesc,methodName,paramDesc,paramName,paramType,defaultValue,rtnTypeDesc,rtnType){
var mobj=this.apiDoc.methods.filter((m)=>{
if(m.name==methodName){
return true;
}else{
return false;
}
})[0];
var param={
pname:paramName,
ptype:paramType,
pdesc:paramDesc,
pdefaultValue:defaultValue,
};
if(mobj!=null){
mobj.params.push(param);
}else{
this.apiDoc.methods.push(
{
methodDesc:methodDesc?methodDesc:"",
name:methodName,
params:[param],
rtnTypeDesc:rtnTypeDesc,
rtnType:rtnType
}
);
}
}
}
module.exports=DocBase;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class PushBusinessAPI extends APIBase {
constructor() {
super();
this.toolSve = system.getObject("service.trademark.toolSve");
this.toolApi = system.getObject("api.tool.toolApi");
this.appSourceList = {
"tm_ali": "阿里云应用", "ic_ali": "阿里云应用", "icp_ali": "阿里云应用",
"tm_jdyun": "京东云应用", "ic_jdyun": "京东云应用", "icp_jdyun": "京东云应用",
"tm_1688": "1688应用", "ic_1688": "1688应用", "icp_1688": "1688应用",
};
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
var self = this;
if (!req.app) {
return system.getResult(null, "app is not empty");
}
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "tm_1688":
opResult = await self.opActionProcess(pobj.actionProcess);
break;
case "ic_1688":
opResult = await this.toolSve.getNclByLikeNameAndNcl(action_body);
break;
case "icp_1688":
opResult = await this.toolSve.word2pic(action_body);
break;
case "tm_ali":
opResult = await this.toolSve.getNcl(action_body);
break;
case "ic_ali":
opResult = await this.toolSve.getNclByLikeNameAndNcl(action_body);
break;
case "icp_ali":
opResult = await this.toolSve.word2pic(action_body);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(pushBusinessSource, action_type, action_body) {
if (!pobj.actionBody.idempotentId) {
return system.getResult(null, "idempotentId is not empty");
}//接入方业务产品 ID
if (!pobj.actionBody.idempotentSource) {
return system.getResult(null, "idempotentSource is not empty");
}//业务来源(ali、jdyun、1688)
if (!pobj.actionBody.idempotentSourceName) {
return system.getResult(null, "idempotentSourceName is not empty");
}//业务来源名称 京东云应用、阿里云应用、1688应用
if (!pobj.actionBody.phone) {
return system.getResult(null, "phone is not empty");
}//手机号
if (!pobj.actionBody.orderPrice) {
return system.getResult(null, "orderPrice is not empty");
}//订单金额 double
if (!pobj.actionBody.productId) {
return system.getResult(null, "productId is not empty");
}//订单金额 string
if (!pobj.actionBody.productQuantity) {
return system.getResult(null, "productQuantity is not empty");
}//产品数量 int
// city、companyName
var opResult = null;
switch (action_type) {
case "fqdev"://dev
result = await this.opActionProcess(pushBusinessSource, reqEnv, action_body);
break;
case "fqProd"://prod
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = PushBusinessAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmOrderAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
this.customerinfoSve = system.getObject("service.dborder.customerinfoSve");
this.customercontactsSve = system.getObject("service.dborder.customercontactsSve");
this.trademarkSve = system.getObject("service.dbtrademark.trademarkSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.jdOpActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async jdOpActionProcess(action_process, action_type, action_body) {
action_body.app = { id: 1, appPayType: "00", appDataOpType: "00" };
action_body.user = { id: 1, app_id: 1, nickname: "测试用户" };
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "addOrder"://商标提报
opResult = await this.ordertmproductSve.addTmOrder(action_body);
break;
case "getTmOrderList"://商标交付列表
opResult = await this.ordertmproductSve.getTmOrderList(action_body);
break;
case "getTmOrderInfo"://商标交付信息
opResult = await this.ordertmproductSve.getTmOrder(action_body);
break;
case "getTmApplyInfo"://商标订单-申请信息
opResult = await this.ordertmproductSve.getTmApply(action_body);
break;
case "getTmNclList"://商标订单-商标尼斯信息
opResult = await this.ordertmproductSve.getTmNclList(action_body);
break;
case "updateTmInfo"://修改商标订单-商标信息修改
opResult = await this.trademarkSve.updateTmInfo(action_body);
break;
case "updateNclInfo"://修改商标订单-商标尼斯信息修改
opResult = await this.trademarkSve.updateNclInfo(action_body);
break;
case "updateContacts"://修改商标订单-修改商标交付单联系人
opResult = await this.customercontactsSve.updateContacts(action_body);
break;
case "updateCustomerInfo"://修改商标订单-修改申请人信息
opResult = await this.customerinfoSve.updateCustomerInfo(action_body);
break;
case "updateOfficial"://修改商标订单-修改交官文件
opResult = await this.customerinfoSve.updateOfficial(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmOrderAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmQueryAPI extends APIBase {
constructor() {
super();
this.tmqueryApi = system.getObject("api.trademark.tmqueryApi");
this.tmquerySve = system.getObject("service.trademark.tmquerySve");
this.toolApi = system.getObject("api.tool.toolApi");
this.toolSve = system.getObject("service.trademark.toolSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.jdOpActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async jdOpActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "findTrademarkNameAccurate"://商标精确检索(相同商标检索)
opResult = await this.tmquerySve.findTrademarkNameAccurate(action_body);
break;
case "findTrademarkName"://近似商标检索
opResult = await this.tmquerySve.findTrademarkName(action_body);
break;
case "findTrademarkzchAccurate"://商标申请号检索
opResult = await this.tmquerySve.findTrademarkzchAccurate(action_body);
break;
case "findTrademarkzcr"://申请人查询
opResult = await this.tmquerySve.findTrademarkzcr(action_body);
break;
case "getCropperPic"://获取检索图片url
opResult = await this.toolSve.getCropperPic(action_body);
break;
case "imagequery"://图形检索
opResult = await this.tmquerySve.imagequery(action_body);
break;
case "findImageSearch"://图形检索查询
opResult = await this.tmquerySve.findImageSearch(action_body);
break;
case "tradeMarkDetail"://商标详情查询
opResult = await this.tmquerySve.tradeMarkDetail(action_body);
break;
case "sbzuixinsearch"://最新商标查询
opResult = await this.tmquerySve.sbzuixinsearch(action_body);
break;
case "noticequeryTMZCSQ"://近12期初审公告查询接口
opResult = await this.tmquerySve.noticequeryTMZCSQ(action_body);
break;
case "noticequery"://公告列表检索接口
opResult = await this.tmquerySve.noticequery(action_body);
break;
case "noticezcggsearch"://注册公告详情查询
opResult = await this.tmquerySve.noticezcggsearch(action_body);
break;
case "noticesearch"://初审公告详情查询
opResult = await this.tmquerySve.noticesearch(action_body);
break;
case "getCompanyInfoNoUser"://企业查询
opResult = await this.tmquerySve.getCompanyInfoNoUser(action_body);
break;
case "getNclDetail"://尼斯详情
opResult = await this.tmquerySve.getNclDetail(action_body);
break;
case "gettwoNcl"://获取尼斯群组
opResult = await this.tmquerySve.gettwoNcl(action_body);
break;
case "nclFuwuSearch"://尼斯分类检索
opResult = await this.tmquerySve.nclFuwuSearch(action_body);
break;
case "bycznfx"://商标智能分析 -----
opResult = await this.toolSve.bycznfx(action_body);
break;
case "tmConfirm"://商标方案确认
// opResult = await this.toolApi.bycznfx(action_body);
opResult = system.getResultSuccess(null, "商标方案确认成功");
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmQueryAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmToolsAPI extends APIBase {
constructor() {
super();
this.toolSve = system.getObject("service.trademark.toolSve");
this.toolApi = system.getObject("api.tool.toolApi");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.jdOpActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async jdOpActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getNcl"://尼斯查询(一)
opResult = await this.toolSve.getNcl(action_body);
break;
case "getNclByLikeNameAndNcl"://尼斯查询(二)
opResult = await this.toolSve.getNclByLikeNameAndNcl(action_body);
break;
case "word2pic"://文字转图片
opResult = await this.toolSve.word2pic(action_body);
break;
case "uploadStandardTm"://商标样式转换
opResult = await this.toolSve.uploadStandardTm(action_body);
break;
case "pic2pdf"://图片转pdf
opResult = await this.toolSve.pic2pdf(action_body);
break;
case "getCompanyInfoByLikeName"://企业近似查询
opResult = await this.toolSve.getCompanyInfoByLikeName(action_body);
break;
case "getEntregistryByCompanyName"://企业精确查询
opResult = await this.toolSve.getEntregistryByCompanyName(action_body);
break;
case "adjustWTSSize"://调整委托书
opResult = await this.toolSve.adjustWTSSize(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmToolsAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TmTransactionAPI extends APIBase {
constructor() {
super();
}
/**
* 接口跳转-POST请求
* actionProcess 执行的流程
* actionType 执行的类型
* actionBody 执行的参数
*/
async springboard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.action_type) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.jdOpActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async jdOpActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "addOrder"://添加订单
// opResult = await this.orderSve.addOrder(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = TmTransactionAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async getTokenInfo(pobj, qobj, req) {
var result = await this.opPlatformUtils.getReqApiAccessKeyInfo();
var resultData = {
token: result ? result.accessKey : ""
};
return system.getResultSuccess(resultData);
}
async getToken(pobj, qobj, req) {
var appkey = pobj.appkey;
var secret = pobj.secret;
if (!appkey) {
return system.getResult(null, "appkey参数不能为空");
}
if (!secret) {
return system.getResult(null, "secret参数不能为空");
}
var result = await this.opPlatformUtils.getReqApiAccessKey(appkey, secret);
var resultData = {
token: result ? result.accessKey : ""
};
return system.getResultSuccess(resultData);
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(pobj, qobj, req) {
return await this.opPlatformUtils.authByCode(qobj.code);
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
class jdAuthAPI extends APIBase { var settings = require("../../../../config/settings");
class InternalCallsNotify extends APIBase {
//内部通知调用
constructor() { constructor() {
super(); super();
// this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
} }
async getUser(pobj, qobj, req) { async updateTmStatus(pobj, qobj, req) {
console.log(pobj, "pobj...................................jd............"); // return await this.orderinfoSve.updateTmStatus(pobj);
console.log(qobj, "qobj...................................jd............");
return {tm:"ok"};
} }
} }
module.exports = jdAuthAPI; module.exports = InternalCallsNotify;
\ No newline at end of file \ No newline at end of file
var APIBase = require("../../api.base"); var APIBase = require("../../api.base");
var system = require("../../../system"); var system = require("../../../system");
class NeedOrderAPI extends APIBase { var settings = require("../../../../config/settings");
class OrderAPI extends APIBase {
constructor() { constructor() {
super(); super();
this.needinfoSve = system.getObject("service.dbneed.needinfoSve"); // this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
...@@ -12,34 +13,17 @@ class NeedOrderAPI extends APIBase { ...@@ -12,34 +13,17 @@ class NeedOrderAPI extends APIBase {
* action_body 执行的参数 * action_body 执行的参数
*/ */
async springBoard(pobj, qobj, req) { async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) { if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空"); return system.getResult(null, "actionType参数不能为空");
} }
var result = null; var result = await this.opActionProcess(pobj, pobj.actionType, req);
pobj.actionBody["user"]=req.user;
pobj.actionBody["app"]=req.app;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.jdOpActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result; return result;
} }
async jdOpActionProcess(action_process, action_type, action_body) { async opActionProcess(pobj, action_type, req) {
var opResult = null; var opResult = null;
switch (action_type) { switch (action_type) {
// sy case "icOrderStatusNotify"://操作工商流程通知信息
case "test"://测试 // opResult = await this.orderinfoSve.icOrderStatusNotify(pobj, pobj.actionBody);
opResult = system.getResultSuccess(null, "测试成功");
break;
case "subNeed"://提交需求
opResult = await this.needinfoSve.subNeed(action_body);
break; break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
...@@ -49,4 +33,4 @@ class NeedOrderAPI extends APIBase { ...@@ -49,4 +33,4 @@ class NeedOrderAPI extends APIBase {
} }
} }
module.exports = NeedOrderAPI; module.exports = OrderAPI;
\ No newline at end of file \ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
var settings = require("../../../../config/settings");
class OpPayOrder extends APIBase {
constructor() {
super();
// this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
}
async receivePayCallBackNotify(pobj, qobj, req) {
// var result = await this.orderinfoSve.opOrderPayCallBackTl(pobj, pobj.appInfo);
// return result;
}
}
module.exports = OpPayOrder;
\ No newline at end of file
var System=require("../../../system");
var settings=require("../../../../config/settings");
const querystring = require('querystring');
const ApiBase =require("../../api.base");
class ChinaAffairSearchApi extends ApiBase{
constructor(){
super();
this.affairUrl = settings.reqEsAddrIc()+"bigdata_patent_affair_op/_search";
};
buildDate(date){
var date = new Date(date);
var time = Date.parse(date);
time=time / 1000;
return time;
};
async SearchbyFilingno(obj){//根据申请号查询并根据法律状态日期排序
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
}
var filingno = obj.filingno==null?"":obj.filingno;
if(filingno==""){
return {status:-1,msg:"传入申请号信息为空",data:null,buckets:null};
}
var params= {
"query": {
"bool": {
"must": [
]
}
},
"sort": [
{
"aff_date": "asc"
}
]
};
var param = {
"term": {
"filing_no": filingno
}
}
params.query.bool.must.push(param);
var rc=System.getObject("util.execClient");
var rtn=null;
var requrl = this.affairUrl;
try{
rtn=await rc.execPost(params,requrl);
var j=JSON.parse(rtn.stdout);
return System.getResult2(j.hits,null);
}catch(e){
return rtn=System.getResult2(null,null);
}
};
}
module.exports = ChinaAffairSearchApi;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class TestAPI extends APIBase {
constructor() {
super();
this.orderSve = system.getObject("service.order.orderSve");
}
async test(pobj, query, req) {
// var tmp = await this.orderSve.createLicense(pobj.action_body);
return system.getResultSuccess({req:"ok"});
}
exam() {
return "";
}
classDesc() {
return {
groupName: "",
groupDesc: "",
name: "",
desc: "",
exam: "",
};
}
methodDescs() {
return [
{
methodDesc: "",
methodName: "",
paramdescs: [
{
paramDesc: "",
paramName: "",
paramType: "",
defaultValue: "",
}
],
rtnTypeDesc: "",
rtnType: ""
}
];
}
}
module.exports = TestAPI;
\ No newline at end of file
var System=require("../../../system")
const crypto = require('crypto');
var fs=require("fs");
var accesskey='DHmRtFlw2Zr3KaRwUFeiu7FWATnmla';
var accessKeyId='LTAIyAUK8AD04P5S';
var url="https://gsb-zc.oss-cn-beijing.aliyuncs.com";
class UploadApi{
constructor(){
this.cmdPdf2HtmlPattern = "docker run -i --rm -v /tmp/:/pdf 0c pdf2htmlEX --zoom 1.3 '{fileName}'";
this.restS=System.getObject("util.execClient");
this.cmdInsertToFilePattern = "sed -i 's/id=\"page-container\"/id=\"page-container\" contenteditable=\"true\"/'";
//sed -i 's/1111/&BBB/' /tmp/input.txt
//sed 's/{position}/{content}/g' {path}
}
async getOssConfig(){
var policyText = {
"expiration":"2119-12-31T16:00:00.000Z",
"conditions":[
["content-length-range",0,1048576000],
["starts-with","$key","zc"]
]
};
var b = new Buffer(JSON.stringify(policyText));
var policyBase64 = b.toString('base64');
var signature= crypto.createHmac('sha1',accesskey).update(policyBase64).digest().toString('base64'); //base64
var data={
OSSAccessKeyId:accessKeyId,
policy:policyBase64,
Signature:signature,
Bucket:'gsb-zc',
success_action_status:201,
url:url
};
return data;
};
async upfile(srckey,dest){
var oss=System.getObject("util.ossClient");
var result=await oss.upfile(srckey,"/tmp/"+dest);
return result;
};
async downfile(srckey){
var oss=System.getObject("util.ossClient");
var downfile=await oss.downfile(srckey).then(function(){
downfile="/tmp/"+srckey;
return downfile;
});
return downfile;
};
async pdf2html(obj){
var srckey=obj.key;
var downfile=await this.downfile(srckey);
var cmd=this.cmdPdf2HtmlPattern.replace(/\{fileName\}/g, srckey);
var rtn=await this.restS.exec(cmd);
var path="/tmp/"+srckey.split(".pdf")[0]+".html";
var a=await this.insertToFile(path);
fs.unlink("/tmp/"+srckey);
var result=await this.upfile(srckey.split(".pdf")[0]+".html",srckey.split(".pdf")[0]+".html");
return result.url;
};
async insertToFile(path){
var cmd=this.cmdInsertToFilePattern+" "+path;
return await this.restS.exec(cmd);
};
}
module.exports=UploadApi;
var System = require("../../../system");
var settings = require("../../../../config/settings");
const ApiBase = require("../../api.base");
var ad = require('../../mongo');
const logCtl = System.getObject("web.common.oplogCtl");
class GsbMgSearchApi extends ApiBase {
constructor() {
super();
this.mgdbModel = System.getObject("db.common.mgconnection").getModel("taierphones");
};
buildDate(date) {
var date = new Date(date);
var time = Date.parse(date);
time = time / 1000;
return time;
};
async phoneNameSearch(obj) {
var companyName = obj.companyName == null ? "" : obj.companyName;
companyName = await this.getConvertSemiangleStr(companyName);
var pageSize = obj.pageSize == null ? 15 : obj.pageSize;
if (obj.currentPage == null) {
var from = 0;
} else {
var from = Number((obj.currentPage - 1) * obj.pageSize);
}
var skipnum = (obj.currentPage - 1) * pageSize;
var params = {
"company_name": companyName
}
var opt = { "_id": 0 };
var rtn = null;
var list = {}
var phone = []
list.company_name = companyName
try {
rtn = await this.mgdbModel.find(params, opt).skip(skipnum).limit(pageSize).exec()
var data = {
"result": 1,
"totalSize": rtn.length,
"pageSize": pageSize,
"currentPage": obj.currentPage - 1, "list": rtn
};
var a = { status: 0, msg: "操作成功", data: data };
return a;
} catch (e) {
//日志记录
logCtl.error({
optitle: "mg操作失败,通过公司名称查电话-error",
op: "base/api/impl/phonesearch/phoneNameSearch",
content: e.stack,
clientIp: ""
});
// console.log(e.stack, "mg操作失败");
return { status: -1, msg: "操作失败", data: null };
}
}
async phoneAdressSearch(obj) {
var adress = obj.adress == null ? "" : obj.adress;
adress = await this.getConvertSemiangleStr(adress);
var pageSize = obj.pageSize == null ? 15 : obj.pageSize;
if (obj.currentPage == null) {
var from = 0;
} else {
var from = Number((obj.currentPage - 1) * obj.pageSize);
}
var skipnum = (obj.currentPage - 1) * pageSize;
var params = {
"postal_address": adress
}
var opt = { "_id": 0 };
var rtn = null;
try {
rtn = await this.mgdbModel.find(params, opt).skip(skipnum).limit(pageSize).exec()
var data = {
"result": 1,
"totalSize": rtn.length,
"pageSize": pageSize,
"currentPage": obj.currentPage, "list": rtn
};
var a = { status: 0, msg: "操作成功", data: data };
return a;
} catch (e) {
//日志记录
logCtl.error({
optitle: "mg操作失败,通过公司地址查电话-error",
op: "base/api/impl/phonesearch/phoneAdressSearch",
content: e.stack,
clientIp: ""
});
return { status: -1, msg: "操作失败", data: null };
}
}
async phoneNumSearch(obj) {
var phoneNum = obj.phoneNum == null ? "" : obj.phoneNum;
var pageSize = obj.pageSize == null ? 15 : obj.pageSize;
// if (obj.currentPage == null) {
// var from = 0;
// } else {
// var from = Number((obj.currentPage - 1) * obj.pageSize);
// }
// var skipnum = (obj.currentPage - 1) * pageSize;
var params = {
"phone_number": phoneNum
}
var opt = { "_id": 0 };
var rtn = null;
var list = {}
list.phoneNum = phoneNum
try {
rtn = await this.mgdbModel.find(params, opt).limit(20).exec()
var sources = []
if (rtn.length > 0) {
for (var i = 0; i < rtn.length; i++) {
if (sources.indexOf(rtn[i]["company_name"])<0) {
sources.push(rtn[i]["company_name"])
}
}
}
var data = {
"result": 1,
"totalSize": sources.length,
"list": sources
};
var a = { status: 0, msg: "操作成功", data: data };
return a;
} catch (e) {
//日志记录
logCtl.error({
optitle: "mg操作失败,通过电话查公司名称-error",
op: "base/api/impl/phonesearch/phoneNumSearch",
content: e.stack,
clientIp: ""
});
// console.log(e.stack, "mg操作失败>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
return { status: -1, msg: "操作失败", data: null };
}
}
async getConvertSemiangleStr(str) {
var result = "";
str = str.replace(/\s+/g, "");
var len = str.length;
for (var i = 0; i < len; i++) {
var cCode = str.charCodeAt(i);
//全角与半角相差(除空格外):65248(十进制)
cCode = (cCode >= 0xFF01 && cCode <= 0xFF5E) ? (cCode - 65248) : cCode;
//处理空格
cCode = (cCode == 0x03000) ? 0x0020 : cCode;
result += String.fromCharCode(cCode);
}
return result;
};
}
module.exports = GsbMgSearchApi;
This source diff could not be displayed because it is too large. You can view the blob instead.
var System=require("../../../system");
var settings=require("../../../../config/settings");
const ApiBase = require("../../api.base");
var pinyin = require("pinyin");
class tmtransactionApi extends ApiBase{
constructor(){
super();
this.GsbByTmSearchApi=System.getObject("api.trademark.tmsearch");
this.utilstmSve=System.getObject("service.trademark.utilstmSve");
this.utilstmTransactionSve = System.getObject("service.trademark.utilstmTransactionSve");
this.tm_status={1:"申请中",2:"已初审",3:"已注册",4:"已无效",5:"其他"};
this.tm_gjfl={1:"01类 化学原料",2:"02类 颜料油漆",3:"03类 日化用品",4:"04类 燃料油脂",5:"05类 医药",6:"06类 金属材料",7:"07类 机械设备",8:"08类 手工器械",9:"09类 科学仪器",
10:"10类 医疗器械",11:"11类 灯具空调",12:"12类 运输工具",13:"13类 军火烟火",14:"14类 珠宝钟表",15:"15类 乐器",16:"16类 办公用品",17:"17类 橡胶制品",18:"18类 皮革皮具",19:"19类 建筑材料",20:"20类 家具",21:"21类 厨房洁具",22:"22类 绳网袋蓬",23:"23类 纱线丝",24:"24类 布料床单",
25:"25类 服装鞋帽",26:"26类 钮扣拉链",27:"27类 地毯席垫",28:"28类 健身器材",29:"29类 食品",30:"30类 方便食品",31:"31类 农林生鲜",32:"32类 啤酒饮料",33:"33类 酒",34:"34类 烟草烟具",35:"35类 广告销售",36:"36类 金融物管",37:"37类 建筑修理",38:"38类 通讯服务",
39:"39类 运输贮藏",40:"40类 材料加工",41:"41类 教育娱乐",42:"42类 科技服务",43:"43类 餐饮住宿",44:"44类 医疗园艺",45:"45类 社会服务"};
}
convertDate(time){
if(time==null){
return "";
}
var date = new Date(Number(time*1000));
var y = 1900+date.getYear();
var m = "0"+(date.getMonth()+1);
var d = "0"+date.getDate();
return y+"-"+m.substring(m.length-2,m.length)+"-"+d.substring(d.length-2,d.length);
}
//商标交易检索
async tmTransactionSearch(query,obj){
console.log("----------------------");
console.log(obj);
var result={rows:[],total:""};
var sources=[];
var codes=[];
var keyword=obj.keyword;
var tm_nclcode=obj.tm_nclcode;
var price_min = obj.min;
var price_max = obj.max;
var tm_structure=obj.tm_structure;
if(obj.tm_word == '1-2个字'){
var tm_word = 2;
}else if(obj.tm_word == '3个字'){
var tm_word = 3;
}else if(obj.tm_word == '4个字'){
var tm_word = 4;
}else if(obj.tm_word == '5个字'){
var tm_word = 5;
}else if(obj.tm_word == '5个字以上'){
var tm_word = 6;
}else{
var tm_word ='';
}
var order_field='';
if(obj.order == "价格"){
order_field= "platform_quoted_price";
}else if(obj.order == "时间"){
order_field= "created_at";
}
var sort = obj.sort;
var pagesize=obj.pagesize;
var currentpage=obj.currentpage;
var data={
keyword:keyword,
tm_nclcode:tm_nclcode,
price_min:price_min,
price_max:price_max,
tm_structure:tm_structure,
tm_word:tm_word,
order_field:order_field,
sort:sort,
pagesize:pagesize,
currentpage:currentpage
};
console.log("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzjjjjjjjjjjjjjjjjjj");
console.log(data);
var that = this;
var tms =await this.utilstmTransactionSve.tmTransactionSearch(data);//获取查询结果
// console.log(tms);
if(tms.status==0){
result.total=tms.total;
tms.data.forEach(function(tm){
var source={
tm_name:tm.tm_name,//商标名称
platform_quoted_price:tm.platform_quoted_price,//平台售价
ncl_one_codes:tm.ncl_one_codes,//尼斯大类
ncl_one_codes_name:that.tm_gjfl[tm.ncl_one_codes],//国际分类名称
tm_regist_num:tm.tm_regist_num,//注册号
pic_url:tm.pic_url, //图片url
pic_url_user:tm.pic_url_user //用户自己上传的图片url
}
sources.push(source)
});
result.rows=sources;
}
console.log("=====================+++++++++++++++++++++++++");
// console.log(result);
return System.getResult2(result,null);
}
async tmTransactionDetail(query,obj){//商标交易详情接口
console.log(obj);
var result={detail:{}};
var sbzch=obj.sbzch;
var gjfl=obj.gjfl;
var data={
sbzch:sbzch,
gjfl:gjfl,
};
var that = this;
var detailtms= await this.GsbByTmSearchApi.tradeMarkDetailapi(data);
var ts= await this.utilstmTransactionSve.tmTransactionDetailsve(data);//获取查询结果
var data2={
reg_num:sbzch,
nclone_code:gjfl
}
var qunzutms=await this.utilstmSve.getGroupNclInfo(data2);
var spfwxmlist=[];
var codelist=[];
if(qunzutms.status==0){
qunzutms.data.exist.forEach(function(c){
if(spfwxmlist.findIndex(f => f == c.small_name) < 0){
spfwxmlist.push(c.small_name)
}
if(codelist.findIndex(f => f ==c.code)<0){
codelist.push(c.code)
}
});
}
var spfwxm=spfwxmlist.join(",");
var codes=codelist.join(",");
var sbmc="";
var gjfl="";
var gjflname="";
var sbzch="";
var sbzt="";
var sqrq="";
var csrq="";
var zcrq="";
var zcr="";
var jzrq="";
var yzcr="";
var zcdz="";
var dljg="";
var logo="";
var pic_url_user="";
var platform_quoted_price="";
var tm_introduction="";
if(detailtms.status == 0 && detailtms.data.length>0){
var tm=detailtms.data[0];
sbmc=tm.tm_name;//商标名称
gjfl=tm.ncl_one_codes;//国际分类
gjflname=that.tm_gjfl[tm.ncl_one_codes];//国际分类名称
sbzch=tm.tm_regist_num;//商标注册号
sbzt=that.tm_status[tm.status];//商标状态
sqrq=that.convertDate(tm.apply_day);//申请日期
csrq=that.convertDate(tm.first_notice_day);//初审日期
zcrq=that.convertDate(tm.original_regist_notice_day);//注册日期
zcr=tm.applicant_cn;//申请人
jzrq=that.convertDate(tm.tm_end_day) ;//截止日期
yzcr=tm.original_applicant_cn;//原申请人
zcdz=tm.applicant_cn_addr;//申请地址
dljg=tm.tm_agency;//代理机构
logo=tm.pic_url;//商标图样
}
if(ts.status == 0 && ts.data.length>0){
var tm=ts.data[0];
platform_quoted_price=tm.platform_quoted_price;//平台售价
tm_introduction=tm.tm_introduction;//商标简介
pic_url_user=tm.pic_url_user; //用户自己上传的图片url
}
result.detail={
sbmc:sbmc,//商标名称
gjfl:gjfl,//国际分类
gjflname:gjflname,//国际分类名称
sbzch:sbzch,//商标注册号
sbzt:sbzt,//商标状态
sqrq:sqrq,//申请日期
csrq:csrq,//初审日期
zcrq:zcrq,//注册日期
zcr:zcr,//申请人
jzrq:jzrq,//截止日期
yzcr:yzcr,//原申请人
zcdz:zcdz,//申请地址
dljg:dljg,//代理机构
logo:logo,//商标图样
spfwxm:spfwxm,//商品/服务项
codes:codes,//群组
pic_url_user:pic_url_user, //用户自己上传的图片url
platform_quoted_price:platform_quoted_price,//平台售价
tm_introduction:tm_introduction//商标简介
}
console.log(result);
return System.getResult2(result,null);
}
}
module.exports=tmtransactionApi;
const system = require("../system");
const settings = require("../../config/settings");
class CtlBase {
constructor(gname, sname) {
this.serviceName = sname;
this.service = system.getObject("service." + gname + "." + sname);
this.cacheManager = system.getObject("db.common.cacheManager");
this.md5 = require("MD5");
}
encryptPasswd(passwd) {
if (!passwd) {
throw new Error("请输入密码");
}
var md5 = this.md5(passwd + "_" + settings.salt);
return md5.toString().toLowerCase();
}
notify(req, msg) {
if (req.session) {
req.session.bizmsg = msg;
}
}
async findOne(queryobj, qobj) {
var rd = await this.service.findOne(qobj);
return system.getResult(rd, null);
}
async findAndCountAll(queryobj, obj, req) {
obj.codepath = req.codepath;
if (req.session.user) {
obj.uid = req.session.user.id;
obj.appid = req.session.user.app_id;
obj.onlyCode = req.session.user.unionId;
obj.account_id = req.session.user.account_id;
obj.ukstr = req.session.user.app_id + "¥" + req.session.user.id + "¥" + req.session.user.nickName + "¥" + req.session.user.headUrl;
}
var apps = await this.service.findAndCountAll(obj);
return system.getResult(apps, null);
}
async refQuery(queryobj, qobj) {
var rd = await this.service.refQuery(qobj);
return system.getResult(rd, null);
}
async bulkDelete(queryobj, ids) {
var rd = await this.service.bulkDelete(ids);
return system.getResult(rd, null);
}
async delete(queryobj, qobj) {
var rd = await this.service.delete(qobj);
return system.getResult(rd, null);
}
async create(queryobj, qobj, req) {
if (req && req.session && req.session.app) {
qobj.app_id = req.session.app.id;
qobj.onlyCode = req.session.user.unionId;
if (req.codepath) {
qobj.codepath = req.codepath;
}
}
var rd = await this.service.create(qobj);
return system.getResult(rd, null);
}
async update(queryobj, qobj, req) {
if (req && req.session && req.session.user) {
qobj.onlyCode = req.session.user.unionId;
}
if (req.codepath) {
qobj.codepath = req.codepath;
}
var rd = await this.service.update(qobj);
return system.getResult(rd, null);
}
static getServiceName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Ctl")).toLowerCase() + "Sve";
}
async initNewInstance(queryobj, req) {
return system.getResult({}, null);
}
async findById(oid) {
var rd = await this.service.findById(oid);
return system.getResult(rd, null);
}
async timestampConvertDate(time) {
if (time == null) {
return "";
}
var date = new Date(Number(time * 1000));
var y = 1900 + date.getYear();
var m = "0" + (date.getMonth() + 1);
var d = "0" + date.getDate();
return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
}
async universalTimeConvertLongDate(time) {
if (time == null) {
return "";
}
var d = new Date(time);
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
}
async universalTimeConvertShortDate(time) {
if (time == null) {
return "";
}
var d = new Date(time);
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
}
async doexec(methodname, pobj, query, req) {
try {
var rtn = await this[methodname](pobj, query, req);
return rtn;
} catch (e) {
console.log(e.stack);
// this.logCtl.error({
// optitle: "Ctl调用出错",
// op: pobj.classname + "/" + methodname,
// content: e.stack,
// clientIp: pobj.clientIp
// });
return system.getResultFail(-200, "Ctl出现异常,请联系管理员");
}
}
}
module.exports = CtlBase;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const logCtl = system.getObject("web.common.oplogCtl");
var cacheBaseComp = null;
class UserCtl extends CtlBase {
constructor() {
super("auth", CtlBase.getServiceName(UserCtl));
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(req) {
var opencode = req.query.code;
var user = await this.service.authByCode(opencode);
if (user) {
req.session.user = user;
} else {
req.session.user = null;
}
//缓存opencode,方便本应用跳转到其它应用
// /auth?code=xxxxx,缓存没有意义,如果需要跳转到其它应用,需要调用
//平台开放的登录方法,返回 <待跳转的目标地址>/auth?code=xxxxx
//this.cacheManager["OpenCodeCache"].cacheOpenCode(user.id,opencode);
return user;
}
async navSysSetting(pobj, qobj, req) {
//开始远程登录,返回code
var jumpobj = await this.service.navSysSetting(req.session.user);
if (jumpobj) {
return system.getResultSuccess(jumpobj);
}
return system.getResultFail();
}
async loginUser(qobj, pobj, req) {
return super.findById(req.session.user.id);
}
async initNewInstance(queryobj, req) {
var rtn = {};
rtn.roles = [];
if (rtn) {
return system.getResultSuccess(rtn);
}
return system.getResultFail();
}
async checkLogin(gobj, qobj, req) {
//当前如果缓存中存在user,还是要检查当前user所在的域名,如果不和来访一致,则退出重新登录
if (req.session.user) {
var x = null;
if (req.session.user.Roles) {
x = req.session.user.Roles.map(r => { return r.code });
}
var tmp = {
id: req.session.user.id,
userName: req.session.user.userName,
nickName: req.session.user.nickName,
mobile: req.session.user.mobile,
isAdmin: req.session.user.isAdmin,
created_at: req.session.user.created_at,
email: req.session.user.email,
headUrl: req.session.user.headUrl,
roles: x ? x.join(",") : ""
}
return system.getResult(tmp, "用户登录", req);
} else {
req.session.user = null;
//req.session.destroy();
return system.getResult(null, "用户未登录", req);
}
}
async exit(pobj, qobj, req) {
req.session.user = null;
req.session.destroy();
return system.getResultSuccess({ "env": settings.env });
}
}
module.exports = UserCtl;
var system = require("../../../system")
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
const uuidv4 = require('uuid/v4');
var moment = require("moment");
class OplogCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(OplogCtl));
//this.appS=system.getObject("service.appSve");
}
async initNewInstance(qobj) {
var u = uuidv4();
var aid = u.replace(/\-/g, "");
var rd = { name: "", appid: aid }
return system.getResultSuccess(rd, null);
}
async debug(obj) {
obj.logLevel = "debug";
return this.create(obj);
}
async info(obj) {
obj.logLevel = "info";
return this.create(obj);
}
async warn(obj) {
obj.logLevel = "warn";
return this.create(obj);
}
async error(obj) {
obj.logLevel = "error";
return this.create(obj);
}
async fatal(obj) {
obj.logLevel = "fatal";
return this.create(obj);
}
/*
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid_Ctl(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
}
var prefixlength = prefix.length;
var subLen = 8 - prefixlength;
var uidStr = "";
if (subLen > 0) {
uidStr = await this.getUidInfo_Ctl(subLen, 60);
}
var timStr = moment().format("YYYYMMDDHHmm");
return prefix + timStr + uidStr;
}
/*
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo_Ctl(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
if (len) {
for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];
} else {
var r;
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
uuid[14] = '4';
for (i = 0; i < 36; i++) {
if (!uuid[i]) {
r = 0 | Math.random() * 16;
uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r];
}
}
}
return uuid.join('');
}
}
module.exports = OplogCtl;
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;
...@@ -21,19 +21,32 @@ class CacheBase { ...@@ -21,19 +21,32 @@ class CacheBase {
const cachekey = this.prefix + inputkey; const cachekey = this.prefix + inputkey;
var cacheValue = await this.redisClient.get(cachekey); var cacheValue = await this.redisClient.get(cachekey);
if (!cacheValue || cacheValue == "undefined" || cacheValue == "null" || this.isdebug) { if (!cacheValue || cacheValue == "undefined" || cacheValue == "null" || this.isdebug) {
var objvalstr = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items); var objval = await this.buildCacheVal(cachekey, inputkey, val, ex, ...items);
if (!objvalstr) { if (!objval || (objval.status && objval.status != 0)) {
return null; return objval;
} }
if (ex) { if (ex) {
await this.redisClient.setWithEx(cachekey, objvalstr, ex); await this.redisClient.setWithEx(cachekey, JSON.stringify(objval), ex);
} else { } else {
await this.redisClient.set(cachekey, objvalstr); await this.redisClient.set(cachekey, JSON.stringify(objval));
} }
//缓存当前应用所有的缓存key及其描述 //缓存当前应用所有的缓存key及其描述
this.redisClient.sadd(this.cacheCacheKeyPrefix, [cachekey + "|" + this.desc]); this.redisClient.sadd(this.cacheCacheKeyPrefix, [cachekey + "|" + this.desc]);
return JSON.parse(objvalstr); return objval;
} else { } 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); return JSON.parse(cacheValue);
} }
} }
......
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAccessKeyCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_accesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var acckapp = await this.restS.execPost({ appkey: settings.appKey, secret: settings.secret }, settings.paasUrl() + "api/auth/accessAuth/getAccessKey");
var s = acckapp.stdout;
if (s) {
var tmp = JSON.parse(s);
if (tmp.status == 0) {
return JSON.stringify(tmp.data);
}
}
return null;
}
}
module.exports = ApiAccessKeyCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiAccessKeyCheckCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_verify_reqaccesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var cacheManager = system.getObject("db.common.cacheManager");
//当来访key缓存不存在时,需要去开放平台检查是否存在来访key缓存
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
if (checkresult.status == 0) {
var s = checkresult.data;
return JSON.stringify(s);
} else {
await cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
var s = checkresult.data;
return JSON.stringify(s);
}
}
}
module.exports = ApiAccessKeyCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAppIdCheckCache extends CacheBase {
constructor() {
super();
// this.merchantDao = system.getObject("db.merchant.merchantDao");
}
desc() {
return "应用中来访访问appid缓存";
}
prefix() {
return settings.cacheprefix + "_verify_appid:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
// var item = await this.merchantDao.getItemByAppId(inputkey);
// if (!item) {
// return null;
// }
// return JSON.stringify(item);
return null;//TODO:接口验证appid有效性
}
}
module.exports = ApiAppIdCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiUserCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_userdata:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var cacheManager = system.getObject("db.common.cacheManager");
//当来访key缓存不存在时,需要去开放平台检查是否存在来访key缓存
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
if (checkresult.status == 0) {
var s = checkresult.data;
return JSON.stringify(s);
} else {
await cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.accessKey);
var s = checkresult.data;
return JSON.stringify(s);
}
}
}
module.exports = ApiUserCache;
...@@ -3,13 +3,17 @@ class Dao { ...@@ -3,13 +3,17 @@ class Dao {
constructor(modelName) { constructor(modelName) {
this.modelName = modelName; this.modelName = modelName;
var db = system.getObject("db.common.connection").getCon(); var db = system.getObject("db.common.connection").getCon();
// this.db = db; this.db = db;
console.log("........set dao model..........");
this.model = db.models[this.modelName]; this.model = db.models[this.modelName];
} }
preCreate(u) { preCreate(u) {
return u; return u;
} }
/**
*
* @param {*} u 对象
* @param {*} t 事务对象t
*/
async create(u, t) { async create(u, t) {
var u2 = this.preCreate(u); var u2 = this.preCreate(u);
if (t) { if (t) {
...@@ -65,6 +69,9 @@ class Dao { ...@@ -65,6 +69,9 @@ class Dao {
//return {"key":"include","value":{model:this.db.models.app}}; //return {"key":"include","value":{model:this.db.models.app}};
return [["created_at", "DESC"]]; return [["created_at", "DESC"]];
} }
buildAttributes() {
return [];
}
buildQuery(qobj) { buildQuery(qobj) {
var linkAttrs = []; var linkAttrs = [];
const pageNo = qobj.pageInfo.pageNo; const pageNo = qobj.pageInfo.pageNo;
...@@ -124,6 +131,10 @@ class Dao { ...@@ -124,6 +131,10 @@ class Dao {
if (extraFilter) { if (extraFilter) {
qc[extraFilter.key] = extraFilter.value; qc[extraFilter.key] = extraFilter.value;
} }
var attributesObj = this.buildAttributes();
if (attributesObj && attributesObj.length > 0) {
qc.attributes = attributesObj;
}
console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm"); console.log("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm");
console.log(qc); console.log(qc);
return qc; return qc;
...@@ -168,9 +179,10 @@ class Dao { ...@@ -168,9 +179,10 @@ class Dao {
tmpParas.transaction = t; tmpParas.transaction = t;
} }
} else { } else {
tmpParas = paras == null || paras == 'undefined' ? { type: this.db.QueryTypes.SELECT } : { replacements: paras, type: this.db.QueryTypes.SELECT }; tmpParas = paras == null || paras == 'undefined' || paras.keys == 0 ? { type: this.db.QueryTypes.SELECT } : { replacements: paras, type: this.db.QueryTypes.SELECT };
} }
return this.db.query(sql, tmpParas); var result = this.db.query(sql, tmpParas);
return result;
} }
async customUpdate(sql, paras, t) { async customUpdate(sql, paras, t) {
...@@ -218,8 +230,8 @@ class Dao { ...@@ -218,8 +230,8 @@ class Dao {
return await this.model.findAndCountAll(tmpWhere); return await this.model.findAndCountAll(tmpWhere);
} }
async findOne(obj, t) { async findOne(obj, t) {
var params = {"where": obj}; var params = { "where": obj };
if(t) { if (t) {
params.transaction = t; params.transaction = t;
} }
return this.model.findOne(params); return this.model.findOne(params);
......
const fs=require("fs"); const fs = require("fs");
const settings=require("../../../../config/settings"); const settings = require("../../../../config/settings");
class CacheManager{ class CacheManager {
constructor(){ constructor() {
//await this.buildCacheMap(); //await this.buildCacheMap();
this.buildCacheMap(); this.buildCacheMap();
} }
buildCacheMap(){ buildCacheMap() {
var self=this; try {
self.doc={}; var self = this;
var cachePath=settings.basepath+"/app/base/db/cache/"; self.doc = {};
const files=fs.readdirSync(cachePath); var cachePath = settings.basepath + "/app/base/db/cache/";
if(files){ const files = fs.readdirSync(cachePath);
files.forEach(function(r){ if (files) {
var classObj=require(cachePath+"/"+r); files.forEach(function (r) {
self[classObj.name]=new classObj(); var classObj = require(cachePath + "/" + r);
var refTmp=self[classObj.name]; self[classObj.name] = new classObj();
if(refTmp.prefix){ var refTmp = self[classObj.name];
self.doc[refTmp.prefix]=refTmp.desc; if (refTmp.prefix) {
} self.doc[refTmp.prefix] = refTmp.desc;
else{
console.log("请在"+classObj.name+"缓存中定义prefix");
} }
}); else {
} console.log("请在" + classObj.name + "缓存中定义prefix");
}
});
}
} catch (e) {
console.log(e.stack, "CacheManager................error")
}
} }
} }
module.exports=CacheManager; module.exports = CacheManager;
// var cm= new CacheManager(); // var cm= new CacheManager();
// cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){ // cm["InitGiftCache"].cacheGlobalVal("hello").then(function(){
// cm["InitGiftCache"].cacheGlobalVal().then(x=>{ // cm["InitGiftCache"].cacheGlobalVal().then(x=>{
......
const system=require("../../../system");
const Dao=require("../../dao.base");
class PushlogDao extends Dao{
constructor(){
super(Dao.getModelName(PushlogDao));
}
}
module.exports=PushlogDao;
\ No newline at end of file
const system = require("../../../system");
const Dao = require("../../dao.base");
class AapDao extends Dao {
constructor() {
super(Dao.getModelName(AapDao));
}
async getItemByAppKey(appKey) {
return this.model.findOne({
where: {
uappKey: appKey
},
attributes: ["id",
"name", // 应用名称
"appDataOpType", // 应用数据操作类型:00独立,10全委托,20部分委托
"appPayType", // 支付类型:00第三方应用自己支付,10平台代收款
"contactName", // 联系人姓名
"contactMobile", // 联系人手机
"contactEmail", // 联系人邮箱
"uappKey", // 平台应用key
"appSecret", // 密钥信息,用于进行签名请求接口
"status", // 状态 0禁用 1启用
"channelAppId", // 渠道appID
"channelAppKey", // 渠道appKey
"notes"],
raw: true
});
}
}
module.exports = AapDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppProductDao extends Dao {
constructor() {
super(Dao.getModelName(AppProductDao));
}
async findOneByCode(itemCode, appId) {
return this.model.findOne({
where: {
itemCode: itemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
}
module.exports = AppProductDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppUserDao extends Dao {
constructor() {
super(Dao.getModelName(AppUserDao));
}
async getItemByChannelUserId(appKey) {
return this.model.findOne({
where: {
uappKey: appKey
},
attributes: ["id",
"app_id", // 应用id
"channelUserId", // 渠道用户ID
"channelUserName", // 渠道用户登录名
"uUserId", // 平台用户Id
"userMoblie", // 用户手机号
"nickname", // 昵称
"orgName", // 组织结构名称
"orgPath", // 组织结构路径
"isEnabled"],
raw: true
});
}
}
module.exports = AppUserDao;
const system = require("../../../system"); const system = require("../../../system");
const Dao = require("../../dao.base"); const Dao = require("../../dao.base");
class OrderFlowDao extends Dao { class FlowLogDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(OrderFlowDao)); super(Dao.getModelName(FlowLogDao));
} }
async getListBySourceOrderNo(sourceOrderNo) { async getlogListBySourceOrderNo(sourceOrderNo) {
return this.model.findAll({ return await this.model.findAll({
where: { where: {
sourceOrderNo: sourceOrderNo, sourceOrderNo: sourceOrderNo,
isShow: 1 isShow: 1
}, },
order: [["id", 'desc']],
attributes: [
"opContent",
"created_at"],
raw: true raw: true
}); });
} }
} }
module.exports = OrderFlowDao; module.exports = FlowLogDao;
const system = require("../../../system"); const system = require("../../../system");
const Dao = require("../../dao.base"); const Dao = require("../../dao.base");
class TradeMarkDao extends Dao { class OrderContactsDao extends Dao {
constructor() { constructor() {
super(Dao.getModelName(TradeMarkDao)); super(Dao.getModelName(OrderContactsDao));
} }
async getListByDeliveryOrderNo(deliveryOrderNo) { async getItemByOrderNo(orderNo, uapp_id) {
return this.model.findAll({ return await this.model.findOne({
where: { where: {
deliveryOrderNo: deliveryOrderNo sourceOrderNo: orderNo
}, },
attributes: [
"id",
"contactName",
"mobile",
"tel",
"email",
"fax"],
raw: true raw: true
}); });
} }
} }
module.exports = TradeMarkDao; module.exports = OrderContactsDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderInfoDao extends Dao {
constructor() {
super(Dao.getModelName(OrderInfoDao));
}
async getItemStatusByOrderNo(orderNo, uapp_id) {
var sqlWhere = {
where: {
orderNo: orderNo
},
attributes: [
"id",
"uapp_id",
"orderNo",
"channelServiceNo",
"channelOrderNo",
"channelUserId",
"ownerUserId",
"payTime",
"quantity",
"serviceQuantity",
"orderStatusName",
"orderStatus",
"totalSum",
"payTotalSum",
"refundSum",
"invoiceApplyStatus",
"created_at"],
raw: true
};
if (uapp_id) {
sqlWhere.where.uapp_id = uapp_id;
}
return await this.model.findOne(sqlWhere);
}
async delOrderByOrderNo(orderNo, uapp_id, channelUserId) {
var sqlWhere = {
orderNo: orderNo,
uapp_id: uapp_id,
channelUserId: channelUserId
};
return await this.delete(sqlWhere);
}
}
module.exports = OrderInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderProductDao extends Dao {
constructor() {
super(Dao.getModelName(OrderProductDao));
}
async getItemByOrderNo(orderNo, uapp_id) {
return await this.model.findOne({
where: {
sourceOrderNo: orderNo, uapp_id: uapp_id
},
attributes: [
"sourceOrderNo",
"productType_id",
"pathCode",
"itemCode",
"itemName",
"channelItemCode",
"channelItemName",
"serviceItemCode",
"payAfterJumpH5Url",
"payAfterJumpPcUrl",
"picUrl",
"price",
"quantity"],
raw: true
});
}
async getItemInfoByOrderNo(orderNo) {
return await this.model.findOne({
where: {
sourceOrderNo: orderNo
},
raw: true
});
}
}
module.exports = OrderProductDao;
const system=require("../../../system"); const system=require("../../../system");
const Dao=require("../../dao.base"); const Dao=require("../../dao.base");
class NeedInfoDao extends Dao{ class NeedinfoDao extends Dao{
constructor(){ constructor(){
super(Dao.getModelName(NeedInfoDao)); super(Dao.getModelName(NeedinfoDao));
}
extraWhere(obj,w){
if(obj.codepath && obj.codepath!=""){
if(obj.codepath.indexOf("calculateprice")>0){
w["user_id"]=obj.uid;
}
}
return w;
} }
} }
module.exports=NeedInfoDao; module.exports=NeedinfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CustomerContactsDao extends Dao {
constructor() {
super(Dao.getModelName(CustomerContactsDao));
}
async findOneByMobile(mobile, customerinfoId) {
return this.model.findOne({
where: {
mobile: mobile,
customerinfo_id: customerinfoId
},
attributes: ["id",
"deliveryOrderNo",
"mobile",
"email",
"tel",
"fax",
"name",
"code",
"app_id"],
raw: true
});
}
async findOneByCustomerinfoId(customerinfoId) {
return this.model.findOne({
where: {
customerinfo_id: customerinfoId
},
attributes: ["id",
"deliveryOrderNo",
"mobile",
"email",
"tel",
"fax",
"name",
"code",
"app_id"],
raw: true
});
}
}
module.exports = CustomerContactsDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CustomerInfoDao extends Dao {
constructor() {
super(Dao.getModelName(CustomerInfoDao));
}
async findOneByCodeAndUserId(code, userId) {
return this.model.findOne({
where: {
code: code,
createuser_id: userId
},
attributes: ["id",
"customerType",// ent:企业,person:个人
"customerTypeName",
"identityCardPic",//身份证图片
"businessLicensePic",//营业执照图片
"name",//公司名称或个人名称
"code",//公司统一社会代码
"app_id",
"deliveryOrderNo",
"applyAddr",//申请地址
"applyArea",//存储省市编码
"province",//省
"city",//市
"identityCardNo",//身份证号
"notes",//备注
"zipCode",
"identityCardPdf",
"businessLicensePdf",
"createuser_id",
"updateuser_id",
"owner_id"],
raw: true
});
}
async findOneByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findOne({
where: {
deliveryOrderNo: deliveryOrderNo
},
attributes: ["id",
"customerType",// ent:企业,person:个人
"customerTypeName",
"identityCardPic",//身份证图片
"businessLicensePic",//营业执照图片
"name",//公司名称或个人名称
"code",//公司统一社会代码
"app_id",
"deliveryOrderNo",
"applyAddr",//申请地址
"applyArea",//存储省市编码
"province",//省
"city",//市
"identityCardNo",//身份证号
"notes",//备注
"zipCode",
"identityCardPdf",
"businessLicensePdf",
"createuser_id",
"updateuser_id",
"owner_id"],
raw: true
});
}
}
module.exports = CustomerInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderTmProductDao extends Dao {
constructor() {
super(Dao.getModelName(OrderTmProductDao));
}
async getTmListByChannelServiceNo(channelServiceNo, appId) {
return this.model.findAll({
where: {
channelServiceNo: channelServiceNo,
app_id: appId
},
raw: true
});
}
async getTmItemByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findOne({
where: {
deliveryOrderNo: deliveryOrderNo
},
raw: true
});
}
}
module.exports = OrderTmProductDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class PushBusinessDao extends Dao {
constructor() {
super(Dao.getModelName(PushBusinessDao));
}
async getItemByUappKey(uappKey, reqEnv) {
return this.model.findOne({
where: {
uappKey: uappKey,
reqEnv: reqEnv
},
attributes: ["id",
"sourceCode",
"sourceName",
"uappKey",
"aliAppkey",
"aliSecret",
"status",
"pushSveUrl",
"pushProductId",
"sveProductId",
"reqEnv",
"notes"],
raw: true
});
}
}
module.exports = PushBusinessDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class TmOfficialDao extends Dao{
constructor(){
super(Dao.getModelName(TmOfficialDao));
}
async getListByTmRegistNum(tmRegistNum) {
return this.model.findAll({
where: {
tmRegistNum: tmRegistNum
},
raw: true
});
}
}
module.exports=TmOfficialDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class TmStuffDao extends Dao{
constructor(){
super(Dao.getModelName(TmStuffDao));
}
async getListBySourceOrderNo(sourceOrderNo){
return this.model.findAll({
where: {
sourceOrderNo: sourceOrderNo
},
raw: true
});
}
}
module.exports=TmStuffDao;
module.exports = { module.exports = {
"appid": "201911051030", "appid": "201911061250",
"label": "知产api应用", "label": "知产渠道api应用",
"config": { "config": {
"rstree": { "rstree": {
"code": "paasroot", "code": "paasroot",
...@@ -28,13 +28,13 @@ module.exports = { ...@@ -28,13 +28,13 @@ module.exports = {
//订单类型 //订单类型
"order_type": { "zzdd": "自主订单", "dkxd": "代客下单" }, "order_type": { "zzdd": "自主订单", "dkxd": "代客下单" },
//订单付款状态 //订单付款状态
"order_pay_status": { "dfk": "待付款", "zfpz": "已上传支付凭证", "yfk": "已付款", "ddqx": "订单取消", "tkclz": "退款处理中", "bfytk": "部分已退款", "ytk": "已退款", "zfshbtg": "支付审核不通过" }, "order_status": { 1: "待付款", 2: "已付款", 4: "服务中", 8: "已完成" },
//帐户类型( 支付类型) //帐户类型( 支付类型)
"pay_account_type": { "cash": "现金", "bank": "银行", "wx": "微信", "alipay": "支付宝", "other": "其它" }, "pay_account_type": { "cash": "现金", "bank": "银行", "wx": "微信", "alipay": "支付宝", "other": "其它" },
//订单服务付款状态 //订单服务付款状态
"order_service_pay_status": { "dfk": "待付款", "yfk": "已付款" }, "order_service_pay_status": { "dfk": "待付款", "yfk": "已付款" },
//商标交付状态 //商标交付状态
"delivery_status": { "dsccl": "待上传材料", "dsh": "待审核", "ddj": "待递交", "ydj": "已递交", "ywc": "已完成" }, "delivery_status": { "dqrfa": "待确认方案", "fabtg": "方案不通过", "dfwsfw": "待服务", "dsccl": "待上传材料", "dsh": "待审核", "ddj": "待递交", "ydj": "已递交", "ywc": "已完成" },
//商标类型 //商标类型
"tm_type": { "p": "普通商标", "j": "集体商标", "z": "证明商标", "t": "特殊商标" }, "tm_type": { "p": "普通商标", "j": "集体商标", "z": "证明商标", "t": "特殊商标" },
//商标类型形式 //商标类型形式
...@@ -50,14 +50,14 @@ module.exports = { ...@@ -50,14 +50,14 @@ module.exports = {
"1": "商标注册申请书", "2": "商标注册申请补正通知书", "3": "商标注册申请受理通知书", "4": "商标注册申请不予受理通知书", "5": "商标注册同日申请补送使用证据通知书", "1": "商标注册申请书", "2": "商标注册申请补正通知书", "3": "商标注册申请受理通知书", "4": "商标注册申请不予受理通知书", "5": "商标注册同日申请补送使用证据通知书",
"6": "商标注册同日申请协商通知书商标注册同日申请抽签通知书", "7": "商标驳回通知书", "8": "商标部分驳回通知书", "9": "商标注册申请初步审定公告通知书", "6": "商标注册同日申请协商通知书商标注册同日申请抽签通知书", "7": "商标驳回通知书", "8": "商标部分驳回通知书", "9": "商标注册申请初步审定公告通知书",
"10": "商标异议答辩通知书", "11": "异议裁定书", "12": "纸质版商标注册证", "13": "电子版商标注册证", "10": "商标异议答辩通知书", "11": "异议裁定书", "12": "纸质版商标注册证", "13": "电子版商标注册证",
"dsccl": "待上传材料", "dsh": "待审核", "shbtg": "审核不通过", "ddj": "待递交", "ydj": "已递交", "djyc": "递交异常" "dsccl": "待上传材料", "dqrfa": "待确认方案", "fabtg": "方案不通过", "dsh": "待审核", "shbtg": "审核不通过", "ddj": "待递交", "ydj": "已递交", "djyc": "递交异常"
}, },
//申请企业类型 //申请企业类型
"customer_type": { "ent": "企业", "person": "个人" }, "customer_type": { "ent": "企业", "person": "个人" },
//附件类型 //附件类型
"stuff_type": { "csty": "彩色图样", "wts": "委托书", "gzwts": "盖章委托书", "ty": "图样", "sywj": "声音文件", "smwj": "说明文件" }, "stuff_type": { "csty": "彩色图样", "wts": "委托书", "gzwts": "盖章委托书", "ty": "图样", "sywj": "声音文件", "smwj": "说明文件" },
//来源类型 //来源类型
"source_type": { "order": "订单", "expensevoucher": "费用单", "receiptvoucher": "收款单", "refundvoucher": "退款单", "trademark": "商标单" }, "source_type": { "childorders": "子订单", "expensevoucher": "费用单" },
//审核状态 //审核状态
"audit_status": { "dsh": "待审核", "btg": "不通过", "tg": "通过" }, "audit_status": { "dsh": "待审核", "btg": "不通过", "tg": "通过" },
//收款类型 //收款类型
...@@ -65,9 +65,13 @@ module.exports = { ...@@ -65,9 +65,13 @@ module.exports = {
//退款类型 //退款类型
"refund_type": { "tk": "退款", "ptdtk": "平台代退款" }, "refund_type": { "tk": "退款", "ptdtk": "平台代退款" },
//费用类型 //费用类型
"expense_type": { "gf": "官费", "sxf": "手续费", "tax": "税金", "salary": "薪酬", "sale": "销售费用", "mag": "管理费用", "channelSettleProfit": "订单渠道分润结算" }, "expense_type": { "gf": "官费", "tax": "税金", "channelSettleProfit": "订单渠道分润结算" },
//凭单类型 //凭单类型
"direction_type": { "sr": "收", "zc": "支" }, "direction_type": { "sr": "收", "zc": "支" },
} "push_return_type": { "0": "推送失败", "1": "推送成功" },
"push_chance_type": { "wts": "未推送", "yts": "已推送", "ygj": "已跟进", "ycd": "已成单" },
"policy_type":{'fzbt':'租金减免','jrdk':'金融贷款','zdfc':'行政措施','ssjm':'税收优惠','rlzy':'人力资源'},
"customer_intention":{"dgj":"待跟进","yyx":"有意向","wyx":"无意向"},
},
} }
} }
\ No newline at end of file
...@@ -14,13 +14,13 @@ module.exports = (db, DataTypes) => { ...@@ -14,13 +14,13 @@ module.exports = (db, DataTypes) => {
}, },
op: DataTypes.STRING, op: DataTypes.STRING,
content: DataTypes.STRING(5000), content: DataTypes.STRING(5000),
resultInfo: DataTypes.TEXT, resultInfo: DataTypes.TEXT('long'),
clientIp: DataTypes.STRING, clientIp: DataTypes.STRING,
agent: { agent: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
}, },
opTitle: DataTypes.STRING(500), opTitle: DataTypes.TEXT,
}, { }, {
paranoid: false,//假的删除 paranoid: false,//假的删除
underscored: true, underscored: true,
...@@ -30,7 +30,7 @@ module.exports = (db, DataTypes) => { ...@@ -30,7 +30,7 @@ module.exports = (db, DataTypes) => {
updatedAt: false, updatedAt: false,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'zcapi_op_log', tableName: 'd_op_log',
validate: { validate: {
}, },
......
...@@ -2,25 +2,35 @@ const system = require("../../../system"); ...@@ -2,25 +2,35 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("app", { return db.define("pushlog", {
name: DataTypes.STRING(100), // 应用名称 appid: DataTypes.STRING,
appDataOpType: { appkey: DataTypes.STRING,
requestId: DataTypes.STRING,
logLevel: {
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type), allowNull: false,
}, // 应用数据操作类型:00独立,10全委托,20部分委托 values: Object.keys(uiconfig.config.pdict.logLevel),
appPayType: { defaultValue: "info",
},
op: DataTypes.STRING,
content: DataTypes.TEXT,
resultInfo: DataTypes.TEXT('long'),
returnTypeName:DataTypes.STRING,
returnType : {
type: DataTypes.ENUM, type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_pay_type), values: Object.keys(uiconfig.config.pdict.push_return_type),
}, // 支付类型:00第三方支付,10平台代收款 set: function (val) {
contactName : DataTypes.STRING(30), // 联系人姓名 this.setDataValue("returnType", val);
contactMobile: DataTypes.STRING(30), // 联系人手机 this.setDataValue("returnTypeName", uiconfig.config.pdict.push_return_type[val]);
contactEmail : DataTypes.STRING(30), // 联系人邮箱 },
uappKey : DataTypes.STRING(64), // 平台应用key defaultValue: "0",
appSecret : DataTypes.STRING(64), // 密钥信息,用于进行签名请求接口 }, //数据推送返回结果类型 push_return_type:{"0":"失败","1":"成功"}
status : DataTypes.INTEGER, // 状态 0禁用 1启用 clientIp: DataTypes.STRING,
channelAppId : DataTypes.STRING(64), // 渠道appID agent: {
channelAppKey: DataTypes.STRING(64), // 渠道appKey type: DataTypes.STRING,
notes : DataTypes.STRING, // 备注 allowNull: true,
},
opTitle: DataTypes.STRING(500),
}, { }, {
paranoid: false,//假的删除 paranoid: false,//假的删除
underscored: true, underscored: true,
...@@ -30,7 +40,7 @@ module.exports = (db, DataTypes) => { ...@@ -30,7 +40,7 @@ module.exports = (db, DataTypes) => {
updatedAt: false, updatedAt: false,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'c_app', tableName: 'd_push_log',
validate: { validate: {
}, },
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("appproduct", {
app_id :DataTypes.STRING(50),// 应用id
itemCode :DataTypes.STRING(100),// 产品编码
itemName :DataTypes.STRING(100),// 产品名称
picUrl :DataTypes.STRING(500),// 产品图片地址
channelItemCode :DataTypes.STRING(100),// 渠道产品编码
channelItemName :DataTypes.STRING(100),// 渠道产品名称
status :DataTypes.BOOLEAN,// 状态 0禁用 1启用
verifyPrice :DataTypes.BOOLEAN,// 是否验证价格 0不验证 1验证
proPrice :DataTypes.DOUBLE,// 产品价格
serviceCharge :DataTypes.DOUBLE,// 服务费
publicExpense :DataTypes.DOUBLE,// 官费
rateConfig :DataTypes.DECIMAL(12, 2),// 税率
discountsRateConfig :DataTypes.DECIMAL(12, 2),// 优惠税率
channelProfitRate :DataTypes.DECIMAL(12, 2),// 渠道利润分成比率(只分订单中毛利润总额的分成)
sort :DataTypes.INTEGER,// 排序
productType_id :DataTypes.INTEGER,// 产品类型Id
productOneType_id :DataTypes.INTEGER,// 产品大类Id
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app_product',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("appuser", {
app_id : DataTypes.INTEGER, // 应用id
channelUserId : DataTypes.STRING(64), // 渠道用户ID
channelUserName : DataTypes.STRING(64), // 渠道用户登录名
userMoblie : DataTypes.STRING(20), // 用户手机号
nickname : DataTypes.STRING(50), // 昵称
orgName : DataTypes.STRING(255), // 组织结构名称
orgPath : DataTypes.STRING(255), // 组织结构路径
isEnabled : DataTypes.INTEGER, // 是否启用
lastLoginTime : DataTypes.DATE, // 上次登录时间
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app_user',
validate: {
},
indexes: [
]
});
}
...@@ -2,18 +2,17 @@ const system = require("../../../system"); ...@@ -2,18 +2,17 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("orderflow", { return db.define("flowlog", {
sourceOrderNo: DataTypes.STRING(64), // 来源单号 uapp_id: DataTypes.INTEGER, //
opContent: DataTypes.STRING(1024), // 操作描述 sourceOrderNo: DataTypes.STRING(128), // 来源单号
app_id: DataTypes.INTEGER, // opContent: DataTypes.STRING(1024), // 操作描述
notes: DataTypes.STRING, // 备注 notes: DataTypes.STRING, // 备注
createuser_id: DataTypes.INTEGER, //
isShow: {//是否显示 isShow: {//是否显示
type: DataTypes.BOOLEAN, type: DataTypes.BOOLEAN,
defaultValue: false, defaultValue: false,
}, },
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
...@@ -21,7 +20,7 @@ module.exports = (db, DataTypes) => { ...@@ -21,7 +20,7 @@ module.exports = (db, DataTypes) => {
updatedAt: false, updatedAt: false,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'b_orderflow', tableName: 'd_flow_log',
validate: { validate: {
}, },
......
...@@ -2,18 +2,17 @@ const system = require("../../../system"); ...@@ -2,18 +2,17 @@ const system = require("../../../system");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("customercontacts", { return db.define("ordercontacts", {
app_id :DataTypes.INTEGER, // uapp_id :DataTypes.INTEGER, //
customerinfo_id :DataTypes.INTEGER, // sourceOrderNo :DataTypes.STRING(128),//来源单号
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号 contactName :DataTypes.STRING(1000), // 联系人
mobile :DataTypes.STRING(20), // mobile :DataTypes.STRING(20), //
email :DataTypes.STRING(50), // email :DataTypes.STRING(50), //
tel :DataTypes.STRING(20), // tel :DataTypes.STRING(20), //
fax :DataTypes.STRING(50), // fax :DataTypes.STRING(50), //
name :DataTypes.STRING(1000), // 联系人
code :DataTypes.STRING(100), // 暂时没有用
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
...@@ -21,7 +20,7 @@ module.exports = (db, DataTypes) => { ...@@ -21,7 +20,7 @@ module.exports = (db, DataTypes) => {
updatedAt: false, updatedAt: false,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'b_customercontacts', tableName: 'd_order_contacts',
validate: { validate: {
}, },
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("orderproduct", {
uapp_id: DataTypes.INTEGER,//
sourceOrderNo :DataTypes.STRING(128),//来源单号(启服通订单号)
channelServiceNo :DataTypes.STRING(128),// 渠道服务单号
channelOrderNo :DataTypes.STRING(128),// 渠道订单号(页面中列表中显示该单号)
productType_id :DataTypes.INTEGER,//产品类型Id
pathCode :DataTypes.STRING(512), //产品类型编码路径,如:1/2
itemCode :DataTypes.STRING(64),//产品编码
itemName :DataTypes.STRING(100),//产品名称
channelItemCode :DataTypes.STRING(100),// 渠道产品编码
channelItemName :DataTypes.STRING(100),// 渠道产品名称
channelItemAppendName :DataTypes.STRING(500),// 渠道产品附加名称 --如商标名称
serviceItemCode :DataTypes.STRING(100),// 服务商产品编码
payAfterJumpH5Url :DataTypes.STRING(500),
payAfterJumpPcUrl :DataTypes.STRING(500),
picUrl :DataTypes.STRING(500),// 产品图片地址
price :DataTypes.DOUBLE, // 产品价格
priceDesc :DataTypes.STRING, //定价描述
priceTypeName :DataTypes.STRING(10), //定价类型名称
quantity :DataTypes.INTEGER,// 订单数量(即产品的倍数,默认值为1)
opPayType :DataTypes.STRING(10),// 操作付款类型:00: 创建订单, 10: 补单
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'd_order_product',
validate: {
},
indexes: [
]
});
}
\ No newline at end of file
...@@ -3,37 +3,47 @@ const settings = require("../../../../config/settings"); ...@@ -3,37 +3,47 @@ const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey); const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => { module.exports = (db, DataTypes) => {
return db.define("needinfo", { return db.define("needinfo", {
app_id :DataTypes.INTEGER, // uapp_id: DataTypes.INTEGER,
needNo :DataTypes.STRING(64), //需求单号 channelNeedNo: DataTypes.STRING(128), //渠道需求号(页面中列表中显示该需求号)
needDesc :DataTypes.STRING(255), // needNo: DataTypes.STRING(128), //需求号(启服通需求号)
needUserMoblie :DataTypes.STRING(20), // channelUserId: DataTypes.INTEGER,//发布者id
notes :DataTypes.STRING(255), // publisherName: DataTypes.STRING,//发布者姓名
opNotes :DataTypes.STRING(500), // publisherOnlyCode: DataTypes.STRING(50),//发布者唯一码
channelUserName :DataTypes.STRING(50), // 渠道用户登录名 publishContent: DataTypes.STRING,//发布内容
auditStatus :DataTypes.STRING(10), //确认状态:00待确认,10确认通过,20确认不通过 publishMobile: DataTypes.STRING,//发布者手机号
createuser_id :DataTypes.INTEGER, // followManUserId: DataTypes.INTEGER,//跟进人id
updateuser_id :DataTypes.INTEGER, // followManName: DataTypes.STRING,//跟进人姓名
owner_id :DataTypes.INTEGER, // followManMobile: DataTypes.STRING,//跟进人手机号(合伙人)
creator :DataTypes.STRING(50), // followManOnlyCode: DataTypes.STRING(50),//跟进者唯一码
updator :DataTypes.STRING(50), // followContent: DataTypes.STRING,//跟进内容
owner :DataTypes.STRING(50), // productOneType_id: DataTypes.STRING,//产品大类Id
ownerMoblie :DataTypes.STRING(20), // productType_id: DataTypes.STRING,//产品类型Id
itemCode :DataTypes.STRING(80), //产品码 notes: DataTypes.STRING,//备注
disposeNotes: DataTypes.STRING,//处理的备注
status: {
//wts未推送,yts已推送,ygj已跟进,ycd已成单
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.push_chance_type),
set: function (val) {
this.setDataValue("chanceType", val);
this.setDataValue("chanceTypeName", uiconfig.config.pdict.push_chance_type[val]);
}
},
city: DataTypes.STRING(50), // 城市
province: DataTypes.STRING(50), // 省份
}, { }, {
paranoid: false,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
freezeTableName: true, freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'b_needinfo', tableName: 'n_need_info',
validate: { validate: {
}, },
indexes: [ indexes: [
] ]
}); });
} }
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("customerinfo", {
customerTypeName :DataTypes.STRING(50), //
customerType : {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.customer_type),
set: function (val) {
this.setDataValue("customerType", val);
this.setDataValue("customerTypeName", uiconfig.config.pdict.customer_type[val]);
},
defaultValue: "0",
}, //申请企业类型: ent:企业,person:个人
identityCardPic :DataTypes.STRING(500), // 身份证图片
identityCardPdf :DataTypes.STRING(500), // 身份证pdf
businessLicensePic :DataTypes.STRING(500), // 营业执照图片
businessLicensePdf :DataTypes.STRING(500), // 营业执照pdf
name :DataTypes.STRING(1000), // 公司名称或个人名称
code :DataTypes.STRING(100), // 公司统一社会代码
app_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号
applyAddr :DataTypes.STRING, // 申请地址
applyArea :DataTypes.STRING(50), // 存储省市编码
province :DataTypes.STRING(50), // 省
city :DataTypes.STRING(50), // 市
identityCardNo :DataTypes.STRING(50), // 身份证号
notes :DataTypes.STRING, // 备注
createuser_id :DataTypes.INTEGER, //
updateuser_id :DataTypes.INTEGER, //
owner_id :DataTypes.INTEGER, // 拥有者
zipCode :DataTypes.STRING(20), //
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_customerinfo',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("order", {
app_id :DataTypes.INTEGER,//
orderNo :DataTypes.STRING(64),// 订单号
channelServiceNo :DataTypes.STRING(64),// 渠道服务单号
channelOrderNo :DataTypes.STRING(1024),// 渠道订单号列表,多个以,隔开
itemCode :DataTypes.STRING(64),//
itemName :DataTypes.STRING(100),//
channelItemCode :DataTypes.STRING(64),// 渠道产品编码
channelItemName :DataTypes.STRING,// 渠道产品名称
payTime :DataTypes.DATE,// 渠道有支付时间则用渠道的支付时间
salesNum :DataTypes.INTEGER,// 项目订单数量(即服务项目的倍数,默认值为1)
salesDiliverNum :DataTypes.INTEGER,// 项目订单交付数量(即与项目订单数量相对应)
minitermNum :DataTypes.INTEGER,// 订单小项数量
minitermDiliverNum :DataTypes.INTEGER,// 订单小项交付数量
orderType :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_type),
},// 订单类型,zzdd: 自主订单,dkxd: 代客下单
orderPayStatusName: DataTypes.STRING(50),//
orderPayStatus :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_pay_status),
set: function (val) {
this.setDataValue("orderPayStatus", val);
this.setDataValue("orderPayStatusName", uiconfig.config.pdict.order_pay_status[val]);
}
},// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalServiceCharge :DataTypes.DECIMAL(12, 2),// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense :DataTypes.DECIMAL(12, 2),// 官费总额(产品配置的官费*订单件数)
totalDiscounts :DataTypes.DECIMAL(12, 2),// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
totalTaxes :DataTypes.DECIMAL(12, 2),// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalSum :DataTypes.DECIMAL(12, 2),// 订单总额(产品价格×优惠费率×订单件数)
refundSum :DataTypes.DECIMAL(12, 2),// 退款金额
totalProfitSum :DataTypes.DECIMAL(12, 2),// 订单毛利润总额(订单总额-官费总额)
pfProfitSum :DataTypes.DECIMAL(12, 2),// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum :DataTypes.DECIMAL(12, 2),// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
pfSettleProfit :DataTypes.DECIMAL(12, 2),// 平台结算渠道利润,0否,1是
opNotes :DataTypes.STRING,// 备注
appPayType :{
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_pay_type),
},// 支付类型:00第三方支付,10平台代收款
createuser_id :DataTypes.INTEGER,//
updateuser_id :DataTypes.INTEGER,//
owner_id :DataTypes.INTEGER,//
creator :DataTypes.STRING(100),//
updator :DataTypes.STRING(100),//
owner :DataTypes.STRING(100),//
ownerMoblie :DataTypes.STRING(20),//
invoiceApplyStatus :DataTypes.STRING(10),// 发票状态:00: 未申请, 10: 已申请,20:已开票
channelUserId :DataTypes.STRING(64), // 渠道用户ID
needNo :DataTypes.STRING(64), // 需求单号
picUrl :DataTypes.STRING(500),// 产品图片地址
productType_id :DataTypes.INTEGER, //产品类型Id
productOneType_id :DataTypes.INTEGER, //产品大类Id
serviceItemSnapshot :DataTypes.TEXT, //产品快照
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_order',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("ordertmproduct", {
app_id: DataTypes.INTEGER,//
productType_id: DataTypes.INTEGER,//产品类型Id
productOneType_id: DataTypes.INTEGER,//产品大类Id
itemCode: DataTypes.STRING(64),//产品编码
itemName: DataTypes.STRING(100),//产品名称
tmName: DataTypes.STRING(1000),//商标名称
tmType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.tm_type),
},//p:普通商标,j:集体商标,z:证明商标,t:特殊商标
tmFormTypeName: DataTypes.STRING(50),//
tmFormType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.tm_form_type),
set: function (val) {
this.setDataValue("tmFormType", val);
this.setDataValue("tmFormTypeName", uiconfig.config.pdict.tm_form_type[val]);
}
},//商标类型形式:1:立体,3:字,4:图,5:字图,6:颜色,7:彩色
nclOneCodes: DataTypes.STRING,//尼斯大类列表:格式以,隔开
payStatusName: DataTypes.STRING(50),//
payStatus: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.order_service_pay_status),
set: function (val) {
this.setDataValue("payStatus", val);
this.setDataValue("payStatusName", uiconfig.config.pdict.order_service_pay_status[val]);
}
},//支付状态:dfk:待付款,yzf:已支付
deliveryStatusName: DataTypes.STRING(50),//
deliveryStatus: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.delivery_status),
set: function (val) {
this.setDataValue("deliveryStatus", val);
this.setDataValue("deliveryStatusName", uiconfig.config.pdict.delivery_status[val]);
}
},//商标交付状态:dsccl:待上传材料,dsh:待审核,ddj:待递交, ydj: 已递交,ywc:已完成
appDataOpType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type),
},//应用数据操作类型:00独立,10全委托,20部分委托
deliveryOrderNo: DataTypes.STRING(64),//交付订单号
channelServiceNo: DataTypes.STRING(64),//渠道服务单号
channelOrderNo: DataTypes.STRING(1024),//渠道订单号列表,多个以,隔开
needNo: DataTypes.STRING(64),//需求单号
sourceType: DataTypes.STRING(10),//来源类型:00订单,10需求,20服务商
picUrl: DataTypes.STRING(500), //商标图样
colorizedPicUrl: DataTypes.STRING(500),//商标彩色图样
gzwtsUrl: DataTypes.STRING(500), //盖章委托书
sywjUrl: DataTypes.STRING(500), //声音文件
smwjUrl: DataTypes.STRING(500), //说明文件
channelUserId: DataTypes.STRING(64),//渠道用户ID
notes: DataTypes.STRING(255),//备注
createuser_id: DataTypes.INTEGER,//
updateuser_id: DataTypes.INTEGER,//
auditor_id: DataTypes.INTEGER,//
createuser: DataTypes.STRING(100),//
updateuser: DataTypes.STRING(100),//
auditor: DataTypes.STRING(100),//
nclOneCount: DataTypes.INTEGER, // 尼斯大类数量
nclCount: DataTypes.INTEGER, // 尼斯数量
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_order_tm_product',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("pushbusiness", {
sourceCode: DataTypes.STRING(100), // 业务来源
sourceName: DataTypes.STRING(100), // 业务来源名称
uappKey: DataTypes.STRING(64), // 平台应用key
aliAppkey: DataTypes.STRING(64), // 阿里网关appkey
aliSecret: DataTypes.STRING(255), // 阿里网关密钥
status: DataTypes.INTEGER, // 状态 0禁用 1启用
pushSveUrl: DataTypes.STRING(500), // 推送服务url
pushProductId: DataTypes.STRING(255), // 推送方产品ID
sveProductId: DataTypes.STRING(255), // 服务方产品ID
notes: DataTypes.STRING(255), // 备注
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_push_business',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("tmofficial", {
tmRegistNum :DataTypes.STRING(50), //注册号
officialTypeName :DataTypes.STRING(50), //
officialType : {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.official_type),
set: function (val) {
this.setDataValue("officialType", val);
this.setDataValue("officialTypeName", uiconfig.config.pdict.official_type[val]);
}
}, //商标官文类型:1: 商标注册申请书, 2: 商标注册申请补正通知书, 3: 商标注册申请受理通知书, 4: 商标注册申请不予受理通知书,
//5: 商标注册同日申请补送使用证据通知书,6: 商标注册同日申请协商通知书商标注册同日申请抽签通知书,
//7: 商标驳回通知书, 8: 商标部分驳回通知书, 9: 商标注册申请初步审定公告通知书,
//10: 商标异议答辩通知书, 11: 异议裁定书, 12: 纸质版商标注册证, 13: 电子版商标注册证
officialFileName :DataTypes.STRING(200), // 官文文件名称
officialFileUrl :DataTypes.STRING(255), // 官文文件地址
notes :DataTypes.STRING , //
name :DataTypes.STRING(1000), //暂时没有用
code :DataTypes.STRING(64), //官文单号(自动生成)
app_id :DataTypes.INTEGER, //
createuser_id :DataTypes.INTEGER, //
updateuser_id :DataTypes.INTEGER, //
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_tmofficial',
validate: {
},
indexes: [
]
});
}
const system=require("../system") const system=require("../system")
const logCtl=system.getObject("web.common.oplogCtl"); const logCtl=system.getObject("service.common.oplogSve");
class TaskBase{ class TaskBase{
constructor(className){ constructor(className){
this.redisClient=system.getObject("util.redisClient"); this.redisClient=system.getObject("util.redisClient");
......
const system = require("../system");
const moment = require('moment')
const settings = require("../../config/settings");
const md5 = require("MD5");
class AppServiceBase {
constructor() {
this.restClient = system.getObject("util.restClient");
this.execClient = system.getObject("util.execClient");
this.cacheManager = system.getObject("db.common.cacheManager");
}
/**
* 验证签名
* @param {*} params 要验证的参数
* @param {*} app_key 应用的校验key
*/
async verifySign(params, app_key) {
if (!params) {
return system.getResult(null, "请求参数为空");
}
if (!params.sign) {
return system.getResult(null, "请求参数sign为空");
}
var signArr = [];
var keys = Object.keys(params).sort();
if (keys.length == 0) {
return system.getResult(null, "请求参数信息为空");
}
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey] && !(params[tKey] instanceof Array)) {
signArr.push(tKey + "=" + params[tKey]);
}
}
if (signArr.length == 0) {
return system.getResult(null, "请求参数组装签名参数信息为空");
}
var resultSignStr = signArr.join("&") + "&key=" + app_key;
var resultTmpSign = md5(resultSignStr).toUpperCase();
if (params.sign != resultTmpSign) {
return system.getResult(null, "返回值签名验证失败");
}
return system.getResultSuccess();
}
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;
}
async execPostUrl(pobj, url) {
var rtn = await this.execClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
}
module.exports = AppServiceBase;
...@@ -8,10 +8,15 @@ class OplogService extends ServiceBase { ...@@ -8,10 +8,15 @@ class OplogService extends ServiceBase {
this.opLogUrl = settings.apiconfig.opLogUrl(); this.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd(); this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
} }
async error(qobj) {
this.create(qobj);
}
async info(qobj) {
this.create(qobj);
}
async create(qobj) { async create(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 || if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 || qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("oplogCtl") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 || qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 || qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) { qobj.op.indexOf("getRsConfig") >= 0) {
...@@ -49,7 +54,6 @@ class OplogService extends ServiceBase { ...@@ -49,7 +54,6 @@ class OplogService extends ServiceBase {
async createDb(qobj) { async createDb(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 || if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 || qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("oplogCtl") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 || qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 || qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) { qobj.op.indexOf("getRsConfig") >= 0) {
...@@ -59,7 +63,7 @@ class OplogService extends ServiceBase { ...@@ -59,7 +63,7 @@ class OplogService extends ServiceBase {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle; qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
//解决日志大于4000写入的问题 //解决日志大于4000写入的问题
if (qobj.content.length > 4980) { if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980); qobj.content = qobj.content.substring(0, 4980);
} }
this.dao.create(qobj); this.dao.create(qobj);
} catch (e) { } catch (e) {
......
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
class PushlogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(PushlogService));
//this.appDao=system.getObject("db.appDao");
this.opLogUrl = settings.apiconfig.opLogUrl();
this.opLogEsIsAdd = settings.apiconfig.opLogEsIsAdd();
}
async create(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
var rc = system.getObject("util.execClient");
var rtn = null;
try {
// var myDate = new Date();
// var tmpTitle=myDate.toLocaleString()+":"+qobj.optitle;
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
if (this.opLogEsIsAdd == 1) {
qobj.content = qobj.content.replace("field list", "字段列表")
qobj.created_at = (new Date()).getTime();
//往Es中写入日志
var addEsData = JSON.stringify(qobj);
rc.execPost(qobj, this.opLogUrl);
} else {
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
}
async createDb(qobj) {
if (!qobj || !qobj.op || qobj.op.indexOf("metaCtl/getUiConfig") >= 0 ||
qobj.op.indexOf("userCtl/checkLogin") >= 0 ||
qobj.op.indexOf("getDicConfig") >= 0 ||
qobj.op.indexOf("getRouteConfig") >= 0 ||
qobj.op.indexOf("getRsConfig") >= 0) {
return null;
}
try {
qobj.optitle = (new Date()).Format("yyyy-MM-dd hh:mm:ss") + ":" + qobj.optitle;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
} catch (e) {
console.log(e.stack, "addLog------error-----------------------*****************");
qobj.content = e.stack;
//解决日志大于4000写入的问题
if (qobj.content.length > 4980) {
qobj.content = qobj.content.substring(0, 4980);
}
this.dao.create(qobj);
}
}
}
module.exports = PushlogService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AapService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AapService));
}
}
module.exports=AapService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AppProductService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AppProductService));
}
}
module.exports = AppProductService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AapUserService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AapUserService));
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async loginUser(channelUserId, channelUserName, userMoblie, nickname, orgName, orgPath) {
if (!channelUserId) {
return system.getResult(null, "channelUserId不能为空");
}
var params = {
channelUserId: channelUserId,
channelUserName: channelUserName,
userMoblie: userMoblie,
nickname: nickname,
orgName: orgName,
orgPath: orgPath
}
var userItem = await this.cacheManager["ApiUserCache"].cache(channelUserId, { status: true }, 3000, params);
if (!userItem) {
return system.getResult(null, "用户注册失败");
}
return system.getResultSuccess(userItem);
}
}
module.exports = AapUserService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class FlowLogService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(FlowLogService));
}
}
module.exports = FlowLogService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderContactsService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderContactsService));
}
}
module.exports = OrderContactsService;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderProductService extends ServiceBase {
constructor() {
super("dbcorder", ServiceBase.getDaoName(OrderProductService));
}
}
module.exports = OrderProductService;
const uuidv4 = require('uuid/v4');
const system = require("../../../system"); const system = require("../../../system");
const ServiceBase = require("../../sve.base"); const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings"); const settings = require("../../../../config/settings");
class NeedinfoService extends ServiceBase {
class NeedInfoService extends ServiceBase {
constructor() { constructor() {
super("dbneed", ServiceBase.getDaoName(NeedInfoService)); super("dbneed", ServiceBase.getDaoName(NeedinfoService));
this.execlient = system.getObject("util.execClient");
} }
async subNeed(obj){ async needinfo2fq(pobj) {
var user = obj.user; pobj.actionBody.needNo=await this.getBusUid("n");
var app = obj.app; pobj.actionBody.uapp_id=pobj.appInfo.id;
if(!user){ var needinfo = await this.dao.create(pobj.actionBody);
return system.getResultFail(-100, "未知用户"); var pobj = {
} "idempotentId": needinfo.needNo,
if(!app){ "idempotentSource": needinfo.chanceType_code,
return system.getResultFail(-101, "未知渠道"); "idempotentSourceName": pobj.appInfo.app_name+"_"+pobj.actionBody.chanceTypeName,
} "phone": needinfo.publishMobile,
var needNo=await this.getBusUid("ni"); "remark": needinfo.notes,
var needObj={ "customerName": needinfo.publishName
app_id :app.id,
needNo :needNo,
needDesc :obj.needDesc,
needUserMoblie :obj.needUserMoblie,
notes :obj.notes,
channelUserName :user.channelUserName,
auditStatus :"00",
createuser_id :user.id,
itemCode:obj.itemCode
}; };
var need = await this.dao.create(needObj);
return system.getResultSuccess(need); var rc = system.getObject("util.aliyunClient");
var rtn = await rc.post("https://yunfuapi.gongsibao.com/crm/opportunity/submit", pobj);
console.log(rtn)
return system.getResultSuccess();
// var opResultstr = await this.execlient.execPost(pobj, "https://yunfuapi-dev.gongsibao.com/crm/opportunity/submit");
// opResult = JSON.parse(opResultstr.stdout)
// if (opResultstr) {
// return system.getResultSuccess();
// }
} }
async flowinfo(obj) {
}
} }
module.exports=NeedInfoService; module.exports = NeedinfoService;
// var a=new NeedinfoService();
// a.needinfo2fq();
\ No newline at end of file
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class CustomerContactsService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(CustomerContactsService));
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
}
/**
* 修改商标交付单联系人(订单详情页面)
* @param {*} obj
* obj.deliveryOrderNo 交付订单号,
* obj.name 联系人,obj.mobile 联系电话,obj.email 电子邮箱,obj.tel 座机电话
* obj.user 用户数据
*/
async updateContacts(obj){
var user = obj.user;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
var deliveryOrderNo = obj.deliveryOrderNo;
if(!deliveryOrderNo){
return system.getResultFail(-101, "deliveryOrderNo参数错误");
}
// 1.获取交付单信息
var ordertmproduct = await this.ordertmproductSve.dao.model.findOne({
where:{deliveryOrderNo:deliveryOrderNo},
raw:true
});
if(!ordertmproduct || !ordertmproduct.id){
return system.getResultFail(-102, "商标交付单不存在");
}
// 2.获取交付单状态,判断是否可修改
if(ordertmproduct.deliveryStatus=='ddj' || ordertmproduct.deliveryStatus=='ywc'){
var deliveryStatusName = "待递交";
if(ordertmproduct.deliveryStatus=='ywc'){
deliveryStatusName="已完成";
}
return system.getResultFail(-103, "该商标交付单状态为"+deliveryStatusName+",不能进行修改");
}
var self = this;
return await self.db.transaction(async function (t) {
var contactsObj={deliveryOrderNo:deliveryOrderNo};
if(obj.name){
contactsObj["name"]=obj.name;
}
if(obj.mobile){
contactsObj["mobile"]=obj.mobile;
}
if(obj.email){
contactsObj["email"]=obj.email;
}
if(obj.tel){
contactsObj["tel"]=obj.tel;
}
//修改联系人信息
await self.dao.model.update(contactsObj, { where: { deliveryOrderNo:deliveryOrderNo }, transaction: t });
return system.getResultSuccess();
})
}
}
module.exports=CustomerContactsService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class CustomerInfoService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(CustomerInfoService));
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
}
/**
* 修改申请人信息(订单详情页面使用)
* @param {*} obj
* obj.deliveryOrderNo 交付订单号,
* obj.customerType 申请人类型,
* obj.name 公司名称或个人名称,
* obj.code 社会统一信用代码,
* obj.applyAddr 公司地址,
* obj.zipCode 邮编
* obj.identityCardPic 身份证图片,
* obj.businessLicensePic 营业执照图片,
* obj.identityCardPdf 身份证pdf,
* obj.businessLicensePdf 营业执照pdf,
* obj.user 用户数据
*/
async updateCustomerInfo(obj){
var user = obj.user;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
var deliveryOrderNo = obj.deliveryOrderNo;
if(!deliveryOrderNo){
return system.getResultFail(-101, "deliveryOrderNo参数错误");
}
// 1.获取交付单信息
var ordertmproduct = await this.ordertmproductSve.dao.model.findOne({
where:{deliveryOrderNo:deliveryOrderNo},
raw:true
});
if(!ordertmproduct || !ordertmproduct.id){
return system.getResultFail(-102, "商标交付单不存在");
}
// 2.获取交付单状态,判断是否可修改
if(ordertmproduct.deliveryStatus=='ddj' || ordertmproduct.deliveryStatus=='ywc'){
var deliveryStatusName = "待递交";
if(ordertmproduct.deliveryStatus=='ywc'){
deliveryStatusName="已完成";
}
return system.getResultFail(-103, "该商标交付单状态为"+deliveryStatusName+",不能进行修改");
}
var customerinfo = await this.dao.model.findOne({
where:{
deliveryOrderNo:deliveryOrderNo
},
raw:true
});
if(!customerinfo || !customerinfo.id){
return system.getResultFail(-104, "未知申请人");
}
var self = this;
return await self.db.transaction(async function (t) {
var ciObj={ id:customerinfo.id,updateuser_id:user.id };
if(obj.customerType){
ciObj["customerType"]=obj.customerType;
}
if(obj.name){
ciObj["name"]=obj.name;
}
if(obj.code){
ciObj["code"]=obj.code;
}
if(obj.applyAddr){
ciObj["applyAddr"]=obj.applyAddr;
}
if(obj.zipCode){
ciObj["zipCode"]=obj.zipCode;
}
if(obj.businessLicensePic){
ciObj["businessLicensePic"]=obj.businessLicensePic;
}
if(obj.identityCardPic){
ciObj["identityCardPic"]=obj.identityCardPic;
}
if(obj.businessLicensePdf){
ciObj["businessLicensePdf"]=obj.businessLicensePdf;
}
if(obj.identityCardPdf){
ciObj["identityCardPdf"]=obj.identityCardPdf;
}
await self.dao.update(ciObj,t);//修改申请人信息
return system.getResultSuccess();
})
}
/**
* 修改交官文件
* @param {*} obj
* obj.deliveryOrderNo 交付单号,
* obj.gzwtsUrl 盖章委托书,
* obj.smwjUrl 说明文件,
* obj.identityCardPic 身份证图片,
* obj.businessLicensePic 营业执照图片,
* obj.identityCardPdf 身份证pdf,
* obj.businessLicensePdf 营业执照pdf,
* obj.user 用户数据
*/
async updateOfficial(obj){
var user = obj.user;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
var deliveryOrderNo = obj.deliveryOrderNo;
if(!deliveryOrderNo){
return system.getResultFail(-101, "deliveryOrderNo参数错误");
}
// 1.获取交付单信息
var ordertmproduct = await this.ordertmproductSve.dao.model.findOne({
where:{deliveryOrderNo:deliveryOrderNo},
raw:true
});
if(!ordertmproduct || !ordertmproduct.id){
return system.getResultFail(-102, "商标交付单不存在");
}
// 2.获取交付单状态,判断是否可修改
if(ordertmproduct.deliveryStatus=='ddj' || ordertmproduct.deliveryStatus=='ywc'){
var deliveryStatusName = "待递交";
if(ordertmproduct.deliveryStatus=='ywc'){
deliveryStatusName="已完成";
}
return system.getResultFail(-103, "该商标交付单状态为"+deliveryStatusName+",不能进行修改");
}
var customerinfo = await this.dao.model.findOne({
where:{
deliveryOrderNo:deliveryOrderNo
},
raw:true
});
if(!customerinfo || !customerinfo.id){
return system.getResultFail(-104, "未知申请人");
}
var self = this;
return await self.db.transaction(async function (t) {
var ciObj={ id:customerinfo.id,updateuser_id:user.id };
if(obj.businessLicensePic){
ciObj["businessLicensePic"]=obj.businessLicensePic;
}
if(obj.identityCardPic){
ciObj["identityCardPic"]=obj.identityCardPic;
}
if(obj.businessLicensePdf){
ciObj["businessLicensePdf"]=obj.businessLicensePdf;
}
if(obj.identityCardPdf){
ciObj["identityCardPdf"]=obj.identityCardPdf;
}
await self.dao.update(ciObj,t);//申请人信息 修改营业执照、身份证文件
var otpObj={
id:ordertmproduct.id,
updateuser_id:user.id,
updateuser:user.nickname
};
if(obj.gzwtsUrl){
otpObj["gzwtsUrl"]=obj.gzwtsUrl;
}
if(obj.smwjUrl){
otpObj["smwjUrl"]=obj.smwjUrl;
}
await self.ordertmproductSve.update(otpObj,t);//商标交付单 修改盖章委托书、说明文件
return system.getResultSuccess();
})
}
}
module.exports=CustomerInfoService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class OrderService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(OrderService));
}
}
module.exports = OrderService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class OrderFlowService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(OrderFlowService));
}
}
module.exports=OrderFlowService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class PushBusinessService extends ServiceBase {
constructor() {
super("dbpush", ServiceBase.getDaoName(PushBusinessService));
this.pushbusinessDao = system.getObject("db.dbpush.pushbusinessDao");
}
async opFqPushBusiness(pushBusinessSource, reqEnv, action_body) {
var item = await this.pushbusinessDao.getItemByUappKey(action_body.app.uappKey, reqEnv);
if (!item) {
return system.getResult(null, "push_business item is not empty");
}
var body = {
idempotentId: item.pushProductId,// 是 接入方业务产品 ID
productId: item.sveProductId,// 是 产品 ID
idempotentSource: item.sourceCode || "tm_1688",// 是 业务来源(ali、jd)
idempotentSourceName: item.sourceName || "1688应用",// 是 阿里,京东
city: action_body.city || "",// 否 所属城市
phone: action_body.phone || "15010929366",// 是 手机号
userId: action_body.userId || "channelUserIdtest01",// 否 用户 ID
companyName: action_body.companyName || "",// 否 公司名称
orderPrice: action_body.phoneaction_body.orderPrice || 899,// 是 订单金额
productQuantity: action_body.productQuantity || 1,// 是 产品数量
};
if (!body.idempotentId) {
return system.getResult(null, "idempotentId is not empty");
}//接入方业务产品 ID
if (!body.idempotentSource) {
return system.getResult(null, "idempotentSource is not empty");
}//业务来源(ali、jdyun、1688)
if (!body.idempotentSourceName) {
return system.getResult(null, "idempotentSourceName is not empty");
}//业务来源名称 京东云应用、阿里云应用、1688应用
if (!body.phone) {
return system.getResult(null, "phone is not empty");
}//手机号
if (!body.orderPrice) {
return system.getResult(null, "orderPrice is not empty");
}//订单金额 double
if (!body.productId) {
return system.getResult(null, "productId is not empty");
}//订单金额 string
if (!body.productQuantity) {
return system.getResult(null, "productQuantity is not empty");
}//产品数量 int
// city、companyName
var aliGateway = system.getObject("util.aliyunClient");
var result = await aliGateway.post(item.aliAppkey, item.aliSecret, item.pushSveUrl, body);
return result;
// if (reqEnv == "fqdev") {
// aliGateway=system.getObject("util.aliyunFqDevClient");
// }
// else if (reqEnv == "fqProd") {
// aliGateway=system.getObject("util.aliyunFqProdClient");
// }
}
}
module.exports = PushBusinessService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class TmOfficialService extends ServiceBase {
constructor() {
super("dbtrademark", ServiceBase.getDaoName(TmOfficialService));
}
}
module.exports=TmOfficialService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class TmStuffService extends ServiceBase {
constructor() {
super("dbtrademark", ServiceBase.getDaoName(TmStuffService));
}
}
module.exports=TmStuffService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class TradeMarkService extends ServiceBase {
constructor() {
super("dbtrademark", ServiceBase.getDaoName(TradeMarkService));
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
}
/**
* 修改商标信息 (订单详情页面使用)
* @param {*} obj
* obj.deliveryOrderNo 交付订单号,
* obj.tmName 商标名称,
* obj.tmFormType 商标类型,
* obj.notes 商标说明,
* obj.picUrl 商标图样,
* obj.colorizedPicUrl 商标彩色图样,
* obj.user 用户数据
*/
async updateTmInfo(obj){
var user = obj.user;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
var deliveryOrderNo = obj.deliveryOrderNo;
if(!deliveryOrderNo){
return system.getResultFail(-101, "deliveryOrderNo参数错误");
}
// 1.获取交付单信息
var ordertmproduct = await this.ordertmproductSve.dao.model.findOne({
where:{deliveryOrderNo:deliveryOrderNo},
raw:true
});
if(!ordertmproduct || !ordertmproduct.id){
return system.getResultFail(-102, "商标交付单不存在");
}
// 2.获取交付单状态,判断是否可修改
if(ordertmproduct.deliveryStatus=='ddj' || ordertmproduct.deliveryStatus=='ywc'){
var deliveryStatusName = "待递交";
if(ordertmproduct.deliveryStatus=='ywc'){
deliveryStatusName="已完成";
}
return system.getResultFail(-103, "该商标交付单状态为"+deliveryStatusName+",不能进行修改");
}
var self = this;
return await self.db.transaction(async function (t) {
var otpObj={
id:ordertmproduct.id,
deliveryOrderNo:deliveryOrderNo,
updateuser_id:user.id,
updateuser:user.nickname
};
if(obj.picUrl){//商标图样 黑白
otpObj["picUrl"]=obj.picUrl;
}
if(obj.colorizedPicUrl){//彩色商标图样
otpObj["colorizedPicUrl"]=obj.colorizedPicUrl;
}
if(obj.tmName){//商标名称
otpObj["tmName"]=obj.tmName;
}
if(obj.tmFormType){//商标类型
otpObj["tmFormType"]=obj.tmFormType;
}
if(obj.notes){//商标说明
otpObj["notes"]=obj.notes;
}
await self.ordertmproductSve.dao.update(otpObj,t);//商标交付单 修改商标图样
return system.getResultSuccess();
})
}
/**
* 修改商标尼斯信息 (订单详情页面使用)
* @param {*} obj
* obj.tbCode 商标提报号,
* obj.deliveryOrderNo 交付订单号,
* obj.nclOneCodes 商标尼斯大类,
* obj.nclSmallCodes 商标尼斯小类数组
* obj.user 用户数据
*/
async updateNclInfo(obj){
var user = obj.user;
var self = this;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
var deliveryOrderNo = obj.deliveryOrderNo;
if(!deliveryOrderNo){
return system.getResultFail(-101, "deliveryOrderNo参数错误");
}
// 1.获取交付单信息
var ordertmproduct = await this.ordertmproductSve.dao.model.findOne({
where:{deliveryOrderNo:deliveryOrderNo},
raw:true
});
if(!ordertmproduct || !ordertmproduct.id){
return system.getResultFail(-102, "商标交付单不存在");
}
// 2.获取交付单状态,判断是否可修改
if(ordertmproduct.deliveryStatus=='ddj' || ordertmproduct.deliveryStatus=='ywc'){
var deliveryStatusName = "待递交";
if(ordertmproduct.deliveryStatus=='ywc'){
deliveryStatusName="已完成";
}
return system.getResultFail(-103, "该商标交付单状态为"+deliveryStatusName+",不能进行修改");
}
var tbCode = obj.tbCode;
if(!tbCode){
return system.getResultFail(-104, "tbCode参数错误");
}
//获取商标尼斯信息
var tm = await this.dao.model.findOne({
where:{tbCode:tbCode},
raw:true
});
if(!tm || !tm.id){
return system.getResultFail(-105, "尼斯信息不存在");
}
//获取交付单下其它商标尼斯信息
var othertm = await this.dao.model.findAll({
where:{
deliveryOrderNo:deliveryOrderNo,
tbCode: { [self.db.Op.ne]: tbCode }
},
raw:true
});
if(!obj.nclOneCodes){
return system.getResultFail(-106, "nclOneCodes参数错误");
}
if(!obj.nclSmallCodes || obj.nclSmallCodes.length<1){
return system.getResultFail(-107, "nclSmallCodes参数错误");
}
if(obj.nclSmallCodes.length>10){
return system.getResultFail(-108, "尼斯小类不能超过10项");
}
var nclOneCodes2 = obj.nclOneCodes;
for(var i=0;i<othertm.length;i++){//判断重复大类
var other = othertm[i];
if(other.nclOneCodes==obj.nclOneCodes){
return system.getResultFail(-109, "该商标存在重复的尼斯大类");
}else{
nclOneCodes2=nclOneCodes2+","+other.nclOneCodes;
}
}
return await self.db.transaction(async function (t) {
var tmObj={
id:tm.id,
nclOneCodes:obj.nclOneCodes,
nclSmallCodes: JSON.stringify(obj.nclSmallCodes),
updateuser_id:user.id,
updateuser:user.nickname
};
await self.dao.update(tmObj,t);//修改商标尼斯信息
var otpObj={
id:ordertmproduct.id,
nclOneCodes:nclOneCodes2,
updateuser_id:user.id,
updateuser:user.nickname
};
await self.ordertmproductSve.dao.update(otpObj,t);//商标交付单 修改大类列表
return system.getResultSuccess();
})
}
}
module.exports=TradeMarkService;
This source diff could not be displayed because it is too large. You can view the blob instead.
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");
class ToolService {
constructor() {
}
async pushFqBusiness(pushBusinessSource, reqEnv, action_body) {
}
}
module.exports = ToolService;
// var test = new TmqueryService();
// test.bigtmcount({tmreg_year:2018,apply_addr_province:""}).then(function(d){
// console.log("#################################");
// console.log(d);
// })
var System=require("../../../system");
var settings=require("../../../../config/settings");
const logCtl=System.getObject("web.common.oplogCtl");
//内容过滤查询
class UtilsTmService{
constructor(){
this.reqEsAddr=settings.reqEsAddr();
}
async getSynonymsList(obj,opName){
var result={
code: 1,
message: "success",
data: []
};
var name=obj.name==null||obj.name==""||obj.name=="undefined"?"":obj.name;
if(name==""){
result.code=-101;
result.message="name参数有误";
return result;
}
var reqUrl=this.reqEsAddr+"bigdata_synonyms_filter/_search";
var params ={
"query" : {
"term" : { "name" : name }
},
"from": 0,
"size": 200,
"_source": [
"name"
]
};
var tResult=await this.returnResult(params,reqUrl,opName,"getSynonymsList");
if(tResult.status!=0){
result.code=-200;
result.message="查询错误";
return result;
}
var tArry=[name];
if(tResult.data.length>0){
for (var i = 0; i < tResult.data.length; i++) {
var tmp=tResult.data[i];
if(tmp!=null && tmp!="" && tmp.name!=null && tmp.name!=""){
for (var j = 0; j < tmp.name.length; j++) {
var tmpName=tmp.name[j];
var indexLength=tArry.findIndex(v => v ===tmpName);
if(indexLength<0){
tArry.push(tmpName);
}
}
}
}
}
result.data=tArry;
return result;
}
async getSimilarList(obj,opName){
var result={
code: 1,
message: "success",
data: []
};
var name=obj.name==null||obj.name==""||obj.name=="undefined"?"":obj.name;
if(name==""){
result.code=-101;
result.message="name参数有误";
return result;
}
var reqUrl=this.reqEsAddr+"bigdata_similar_filter/_search";
var params ={
"query" : {
"term" : { "name" : name }
},
"from": 0,
"size": 200,
"_source": [
"name"
]
};
var tResult=await this.returnResult(params,reqUrl,opName,"getSimilarList");
if(tResult.status!=0){
result.code=-200;
result.message="查询错误";
return result;
}
var tArry=[name];
if(tResult.data.length>0){
for (var i = 0; i < tResult.data.length; i++) {
var tmp=tResult.data[i];
if(tmp!=null && tmp!="" && tmp.name!=null && tmp.name!=""){
for (var j = 0; j < tmp.name.length; j++) {
var tmpName=tmp.name[j];
var indexLength=tArry.findIndex(v => v ===tmpName);
if(indexLength<0){
tArry.push(tmpName);
}
}
}
}
}
result.data=tArry;
return result;
}
async returnResult(params,reqUrl,opClassName,opMethod){
var rc=System.getObject("util.execClient");
var rtn=null;
try{
rtn=await rc.execPost(params,reqUrl);
var j=JSON.parse(rtn.stdout);
if(j.status!=undefined){
//执行查询有错
//日志记录
logCtl.error({
optitle:"ES内容过滤查询opClassName="+opClassName+",opMethod="+opMethod+"ES执行异常error",
op:"base/service/impl/tmutilsSve.js",
content:rtn.stdout,
clientIp:""
});
return System.getResult2(null,null,null,"查询出错");
}
return System.getResult3(j.hits,null);
}catch(e){
//日志记录
logCtl.error({
optitle:"ES内容过滤查询opClassName="+opClassName+",opMethod="+opMethod+"操作异常异常error",
op:"base/service/impl/tmutilsSve.js",
content:e.stack,
clientIp:""
});
return System.getResult2(null,null,null,"查询异常");
}
}
}
module.exports=UtilsTmService;
var System = require("../../../system");
var settings = require("../../../../config/settings");
const logCtl = System.getObject("web.common.oplogCtl");
//商标查询操作
class UtilsTmTaskTradeService {
constructor() {
// this.tmFlowUrl = settings.apiconfig.tmFlowUrl();
// this.tmNclUrl = settings.apiconfig.tmNclUrl();
// this.nclUrl = settings.apiconfig.nclUrl();
this.tmSearchUrl = settings.apiconfig.tmSearchUrl();
this.opTmTransactionUrl = settings.apiconfig.opTmTransactionUrl();
this.tmTransactionUrl = settings.apiconfig.tmTransactionUrl();
this.trademarktransactionDao = System.getObject("db.trademarktransactionDao");
this.orderSve = System.getObject("service.orderSve");
}
async getAuditList(pageIndex, pageSize) {
//publish_status===:tm_transaction_publish_status": { "audit": "审核中", "fail": "审核不通过", "success": "审核通过", "uppershelf": "上架", "lowershelf": "下架" }
var whereObj = { publish_status: "audit" };
return this.trademarktransactionDao.getPageList(pageIndex, pageSize, whereObj, [["created_at", 'desc']], null);
}
buildDate(date) {
var date = new Date(date);
var time = Date.parse(date);
time = time / 1000;
return time;
}
convertDate(time) {//es时间戳转换时间
if (time == null) {
return "";
}
var date = new Date(Number(time * 1000));
var y = 1900 + date.getYear();
var m = "0" + (date.getMonth() + 1);
var d = "0" + date.getDate();
return y + "-" + m.substring(m.length - 2, m.length) + "-" + d.substring(d.length - 2, d.length);
}
async opAuditData() {
var self = this;
var rc = System.getObject("util.execClient");
var list = await self.getAuditList(1, 1000);
if (!list || list.rows.length == 0) {
return "no";
}
var codeList = [];
for (let i = 0; i < list.rows.length; i++) {
const codeItem = list.rows[i];
if (codeItem) {
codeList.push(codeItem.code);
}
if (codeList.length == 200) {
await self.opEsQuery(list.rows, codeList, self, rc);
codeList = [];
}
}
if (codeList.length > 0) {
await self.opEsQuery(list.rows, codeList, self, rc);
}
}
//订单付款提醒任务(针对未付款订单)
async orderPaymentReminder(){
return this.orderSve.orderPaymentReminder();
}
async opEsQuery(auditData, codeList, self, rc) {
var params = {
"query": {
"terms": {
"tm_regist_num": codeList
}
},
"from": 0,
"size": 500,
"_source": [
"pic_url",
"tm_name",
"tm_name_en",
"tm_regist_num",
"ncl_one_codes",
"applicant_cn",
"original_regist_notice_day",
"tm_end_day",
"ncl_two_codes",
"cn_count",
"en_name_count"
]
};
var esData = await self.returnResult(params, this.tmSearchUrl, "UtilsTmTaskTradeService", "opEsQuery");
if (esData.status == 0 && esData.data.length > 0) {
await self.addEsData(auditData, esData.data, self, rc);
}
}
async addEsData(auditData, esTmList, self, rc) {
var addDbList = [];
var rtn = null;
for (let b = 0; b < esTmList.length; b++) {
const esItem = esTmList[b];
var auditList = auditData.filter(a => a.code == esItem.tm_regist_num);
if (!auditList || auditList.length == 0) {
continue;
}
var params = {
created_at: self.buildDate(auditList[0].created_at),
tm_regist_num: esItem.tm_regist_num,
en_name: esItem.tm_name_en,
en_name_count: esItem.en_name_count,
en_name_standard: esItem.tm_name_en,
tm_name: esItem.tm_name,
tm_name_standard: esItem.tm_name,
tm_name_count: Number(esItem.cn_count || "0") + Number(esItem.en_name_count || "0"),
cn_count: esItem.cn_count,
pic_url: esItem.pic_url,
pic_url_user: auditList[0].pic_url || "",
is_transaction: 1,//--------------------db----是否可以交易
ncl_one_codes: esItem.ncl_one_codes,
platform_quoted_price: auditList[0].platform_quoted_price,
tm_heat: 0,
tm_introduction: auditList[0].tm_introduction,
};
try {
await self.putDbData(esItem, auditData, addDbList, self);
var esParams = {
"query": {
"bool": {
"must": [
{
"term": {
"ncl_one_codes": esItem.ncl_one_codes
}
},
{
"term": {
"tm_regist_num": esItem.tm_regist_num
}
}
]
}
},
"from": 0,
"size": 1,
"_source": [
"tm_name"
]
};
var queryEs = await self.returnResult(esParams, this.tmTransactionUrl, "UtilsTmTaskTradeService", "addEsData");
if (queryEs.status == 0 && queryEs.data && queryEs.data.length == 0) {
await rc.execPost(params, self.opTmTransactionUrl);
}
} catch (e) {
logCtl.error({
optitle: "往ES中插入数据或更新商标交易中的商标异常error",
op: "/igirl-web/app/base/service/impl/utilstmtasktradeSve.js/addEsData.js",
content: e.stack,
clientIp: ""
});
}
}
if (addDbList.length > 0) {
await this.trademarktransactionDao.model.bulkCreate(addDbList);
}
}
async putDbData(esItem, auditData, addDbList, self) {//更新数据库
var putIndex = auditData.findIndex(f => f.code === esItem.tm_regist_num);
if (putIndex < 0) {
return;
}
var filterTmList = auditData.filter(f => f.code === esItem.tm_regist_num && f.ncl_one_code === esItem.ncl_one_codes);
if (filterTmList && filterTmList.length > 0) {
var addParams = {
code: esItem.tm_regist_num,
ncl_one_code: esItem.ncl_one_codes,
name: esItem.tm_name,
excelName: esItem.tm_name,
tm_applier: esItem.applicant_cn,
tm_group: JSON.stringify(esItem.ncl_two_codes),
pic_url: auditData[putIndex].pic_url || esItem.pic_url,
business_quoted_price: auditData[putIndex].business_quoted_price,
platform_quoted_price: auditData[putIndex].platform_quoted_price,
tm_structure_name: auditData[putIndex].tm_structure_name,
tm_introduction: auditData[putIndex].tm_introduction,
publish_status: "uppershelf",
createcompany_id: auditList[0].createcompany_id,
createuser_id: auditList[0].createuser_id,
notes: "add_new",
};
if (esItem.original_regist_notice_day && esItem.original_regist_notice_day != null) {
addParams.tm_start_day = self.convertDate(esItem.original_regist_notice_day);
}
if (esItem.tm_end_day && esItem.tm_end_day != null) {
addParams.tm_end_day = self.convertDate(esItem.tm_end_day);
}
addDbList.push(addParams);
return;
}//大类是有值,则新增数据到db
auditData[putIndex].ncl_one_code = esItem.ncl_one_codes;
var setField = {
ncl_one_code: esItem.ncl_one_codes,
name: esItem.tm_name,
tm_applier: esItem.applicant_cn,
tm_group: JSON.stringify(esItem.ncl_two_codes),
pic_url: auditData[putIndex].pic_url || esItem.pic_url,
publish_status: "uppershelf"
};
if (esItem.original_regist_notice_day && esItem.original_regist_notice_day != null) {
setField.tm_start_day = self.convertDate(esItem.original_regist_notice_day);
}
if (esItem.tm_end_day && esItem.tm_end_day != null) {
setField.tm_end_day = self.convertDate(esItem.tm_end_day);
}
var sqlWhere = { where: { id: auditData[putIndex].id } };
var tmpR = await self.trademarktransactionDao.updateByWhere(setField, sqlWhere);
return;
}
async returnResult(params, reqUrl, opClassName, opMethod) {
var rc = System.getObject("util.execClient");
var rtn = null;
try {
rtn = await rc.execPost(params, reqUrl);
var j = JSON.parse(rtn.stdout);
if (j.status != undefined) {
//执行查询有错
//日志记录
logCtl.error({
optitle: "商标交易ES查询商标信息opClassName=" + opClassName + ",opMethod=" + opMethod + "ES执行异常error",
op: "base/service/impl/tmutilsSve.js",
content: rtn.stdout,
clientIp: ""
});
return System.getResult2(null, null, null, "查询出错");
}
return System.getResult3(j.hits, null);
} catch (e) {
//日志记录
logCtl.error({
optitle: "ES查询商标信息opClassName=" + opClassName + ",opMethod=" + opMethod + "操作异常异常error",
op: "base/service/impl/tmutilsSve.js",
content: e.stack,
clientIp: ""
});
return System.getResult2(null, null, null, "查询异常");
}
}
}
module.exports = UtilsTmTaskTradeService;
...@@ -5,9 +5,9 @@ const md5 = require("MD5"); ...@@ -5,9 +5,9 @@ const md5 = require("MD5");
class ServiceBase { class ServiceBase {
constructor(gname, daoName) { constructor(gname, daoName) {
this.db = system.getObject("db.common.connection").getCon(); this.db = system.getObject("db.common.connection").getCon();
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.daoName = daoName; this.daoName = daoName;
this.dao =system.getObject("db." + gname + "." + daoName); this.dao = system.getObject("db." + gname + "." + daoName);
this.restS = system.getObject("util.restClient"); this.restS = system.getObject("util.restClient");
} }
/** /**
...@@ -224,6 +224,6 @@ class ServiceBase { ...@@ -224,6 +224,6 @@ class ServiceBase {
} }
} }
return uuid.join(''); return uuid.join('');
} }
} }
module.exports = ServiceBase; module.exports = ServiceBase;
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