Commit ed73b6ee by 宋毅

tj

parent a2be4ade
......@@ -51,146 +51,6 @@ class APIBase {
}
return system.getResultSuccess();
}
/**
* 白名单验证
* @param {*} gname 组名
* @param {*} methodname 方法名
*/
async isCheckWhiteList(gname, methodname) {
var fullname = gname + "." + methodname;
var lst = [
"test.test",
"action.info",
"action.error",
"auth.getToken",
"auth.getJdSign"
];
var x = lst.indexOf(fullname);
return x >= 0;
}
async checkAcck(gname, methodname, pobj, query, req) {
var uAppInfo = null;
var selfAppInfo = null;
var ispass = await this.isCheckWhiteList(gname, methodname);
if (ispass) {
return system.getResultSuccess();
}//在白名单里面
var token = req.headers["token"];
if (!token) {
return system.getResult(null, "token不能为空");
}
uAppInfo = await this.cacheManager["ApiAccessKeyCheckCache"].cache(token, { status: true }, this.exTime);
if (!uAppInfo || (uAppInfo.status && uAppInfo.status != 0)) {
return uAppInfo;
}
var selfAppInfo = await this.cacheManager["ApiAppKeyCheckCache"].cache(uAppInfo.data.app.appkey, null, this.exTime);
if (!selfAppInfo || (selfAppInfo.status && selfAppInfo.status != 0)) {
return selfAppInfo;
}
// if (!appInfo) {
// return system.getResult(null, "通过token获取sign的密钥信息失败,请重新获取");
// }
// var signResult = await this.verifySign(pobj.action_body, appInfo.appSecret);
// if (signResult.status != 0) {
// return system.getResultFail(system.signFail, signResult.msg);
// }
if (pobj.isUser && pobj.isUser == "yes") {
var channelUserId = pobj.channelUserId ? pobj.channelUserId : pobj.actionBody.channelUserId || "";
if (!channelUserId && pobj.actionBody.channelUser) {
channelUserId = pobj.actionBody.channelUser.channelUserId;
}
if (!channelUserId) {
return system.getResult(null, "base verify channelUserId is empty");
}
var userCacheKey = selfAppInfo.data.uappKey + "_" + channelUserId;
var userInfo = await this.cacheManager["ApiUserCache"].cache(userCacheKey, channelUserId,
this.exTime, pobj.actionBody, selfAppInfo, uAppInfo.data.app.id);
if (!userInfo || (userInfo.status && userInfo.status != 0)) {
return userInfo;
}
if (userInfo.data && userInfo.data.isEnabled && userInfo.data.isEnabled != 1) {
return system.getResultFail(system.getUserInfoFail, "用户处于待审核等待启用状态");
}
req.user = userInfo.data;
pobj.actionBody.channelUserId = channelUserId;
}
req.app = selfAppInfo.data;
return system.getResultSuccess();
}
async doexec(gname, methodname, pobj, query, req) {
var requestid = req.headers["request-id"] || this.getUUID();
if (!req.headers["request-id"]) {
req.headers["request-id"] = requestid;
}
try {
if (pobj.actionType == "createChannelUser") {
if (!pobj.isUser) {
system.getResult(null, "isUser is empty");
}
if (pobj.isUser != "yes") {
system.getResult(null, "isUser value must yes");
}
}
//验证accesskey或验签
var isPassResult = await this.checkAcck(gname, methodname, pobj, query, req);
if (isPassResult.status != 0) {
isPassResult.requestId = "";
return isPassResult;
}
if (pobj.actionType == "createChannelUser") {
var encryptResult = await this.toolSve.encryptStr(req.app, req.user.channelUserId);
if (encryptResult.status != 0) {
system.getResult(null, "encrypt channelUserId is error");
}
req.user.encryptChannelUserId = encryptResult.data;
return system.getResultSuccess(req.user);
}//创建用户
req.requestId = requestid;
var rtn = await this[methodname](pobj, query, req);
if (rtn && !rtn.requestId) {
rtn.requestId = requestid;
}
this.logCtl.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: requestid,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api服务提供方appKey:" + settings.appKey,
});
return rtn;
} catch (e) {
console.log(e.stack, "api调用出现异常,请联系管理员..........")
this.logCtl.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: requestid,
op: req.classname + "/" + methodname,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(e.stack),
clientIp: req.clientIp,
agent: req.uagent,
opTitle: "api调用出现异常,请联系管理员error,appKey:" + settings.appKey,
});
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: requestid,
op: pobj.classname + "/" + methodname,
content: e.stack,
clientIp: pobj.clientIp,
agent: req.uagent,
optitle: "api调用出现异常,请联系管理员",
});
var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
rtnerror.requestId = requestid;
return rtnerror;
}
}
//-----------------------新的模式------------------开始
async doexecMethod(gname, methodname, pobj, query, req) {
......
var APIBase = require("../../api.base");
var system = require("../../../system");
class NeedOrderAPI extends APIBase {
constructor() {
super();
this.needinfoSve = system.getObject("service.dbneed.needinfoSve");
}
/**
* 接口跳转-POST请求
* action_process 执行的流程
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionProcess) {
return system.getResult(null, "actionProcess参数不能为空");
}
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = null;
pobj.actionBody["user"] = req.user;
pobj.actionBody["app"] = req.app;
switch (pobj.actionProcess) {
case "jd"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
case "1688"://京东
result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
break;
default:
result = system.getResult(null, "actionProcess参数错误");
break;
}
return result;
}
async opActionProcess(action_process, action_type, action_body) {
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "subNeed"://提交需求
opResult = await this.needinfoSve.subNeed(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = NeedOrderAPI;
\ No newline at end of file
......@@ -7,7 +7,6 @@ var settings = require("../../../../config/settings");
class ReceiveDataAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
this.customerinfoSve = system.getObject("service.dborder.customerinfoSve");
this.customercontactsSve = system.getObject("service.dborder.customercontactsSve");
......@@ -30,56 +29,20 @@ class ReceiveDataAPI extends APIBase {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
// var result = null;
// switch (pobj.actionProcess) {
// case "jd"://京东
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
// break;
// case "1688"://1688
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
// break;
// case "gsbhome"://gsb_homepage
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
// break;
// default:
// result = system.getResult(null, "actionProcess参数错误");
// break;
// }
return result;
}
async opActionProcess(action_process, action_type, action_body, pobj, req) {
// action_body.app = req.app;
// action_body.user = req.user;
// action_body.app = { id: 1, appPayType: "00", appDataOpType: "00" };
// action_body.user = { id: 1, app_id: 1, nickname: "测试用户",channelUserId:"channelUserIdtest01" };
var logParam = {
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/api/impl/action/receiveData.js/opActionProcess",
content: "参数信息:" + JSON.stringify(action_body),
clientIp: pobj.clientIp,
optitle: "接收推送过来的数据处理=>action_type=" + action_type,
};
// var logParam = {
// appid: req.app.id,
// appkey: req.app.uappKey,
// requestId: req.requestId || "",
// op: "/igirl-channel/zhichan/igirl-channel/app/base/api/impl/action/receiveData.js/opActionProcess",
// content: "参数信息:" + JSON.stringify(action_body),
// clientIp: pobj.clientIp,
// optitle: "接收推送过来的数据处理=>action_type=" + action_type,
// };
var opResult = null;
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "receiveTmOfficialData"://接收回执文件
opResult = await this.trademarkSve.receiveTmOfficialData(action_body);
break;
case "updateAssistTmStatus"://接收商标状态信息
opResult = await this.trademarkSve.updateAssistTmStatus(action_body);
break;
case "assistRegTmData"://接收辅助注册商标数据
opResult = await this.ordertmproductSve.addAssistTm(action_body);
break;
case "assistEditTmData"://接收辅助注册修改商标数据
// opResult = system.getResultSuccess(null, "测试成功");
opResult = await this.ordertmproductSve.editAssistTm(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -22,22 +22,6 @@ class TmQueryAPI extends APIBase {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// var result = null;
// switch (pobj.actionProcess) {
// case "jd"://京东
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// break;
// case "1688":
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// break;
// case "gsbhome":
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// break;
// default:
// result = system.getResult(null, "actionProcess参数错误");
// break;
// }
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
......
......@@ -19,22 +19,6 @@ class TmToolsAPI extends APIBase {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// var result = null;
// switch (pobj.actionProcess) {
// case "jd"://京东
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// break;
// case "1688":
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// break;
// case "gsbhome":
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// break;
// default:
// result = system.getResult(null, "actionProcess参数错误");
// break;
// }
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
......
......@@ -19,18 +19,6 @@ class TmTransactionAPI extends APIBase {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// var result = null;
// switch (pobj.actionProcess) {
// case "jd"://京东
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
// break;
// case "1688":
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody);
// break;
// default:
// result = system.getResult(null, "actionProcess参数错误");
// break;
// }
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
......
......@@ -3,7 +3,6 @@ var system = require("../../../system");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
}
/**
......@@ -19,63 +18,47 @@ class AccessAuthAPI extends APIBase {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, req);
// var result = null;
// switch (pobj.actionProcess) {
// case "jd"://京东
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
// break;
// case "1688"://1688
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
// break;
// case "gsbhome"://gsb_homepage
// result = await this.opActionProcess(pobj.actionProcess, pobj.actionType, pobj.actionBody, pobj, req);
// break;
// default:
// result = system.getResult(null, "actionProcess参数错误");
// break;
// }
var result = await this.opActionProcess(pobj, pobj.actionType, req);
return result;
}
async opActionProcess(action_process, action_type, action_body, req) {
async opActionProcess(pobj, action_type, req) {
var opResult = system.getResult(null, "req Failure");
var userpin = this.getUUID();
action_body.appInfo = req.appInfo;
pobj.actionBody.userpin = this.getUUID();
switch (action_type) {
// sy
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getVerifyCode":
opResult = await this.opPlatformUtils.getVerifyCodeByMoblie(action_body, action_process, req);
opResult = await this.utilsAuthSve.getVerifyCodeByMoblie(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess()
}
break;
case "loginUserByChannelUserId":
opResult = await this.utilsAuthSve.loginUserByChannelUserId(action_body, action_process, userpin, req);
opResult = await this.utilsAuthSve.loginUserByChannelUserId(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByLgoin":
opResult = await this.utilsAuthSve.getReqUserPinByLgoin(action_body, action_process, userpin, req);
opResult = await this.utilsAuthSve.getReqUserPinByLgoin(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByLgoinVcode":
action_body.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(action_body, action_process, userpin, req);
pobj.actionBody.reqType = "login";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
case "userPinByRegister":
action_body.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(action_body, action_process, userpin, req);
pobj.actionBody.reqType = "reg";
opResult = await this.utilsAuthSve.getReqUserPinByLgoinVcode(pobj, pobj.actionBody);
if (opResult.status == 0) {
return system.getResultSuccess({ userpin: userpin })
return system.getResultSuccess({ userpin: pobj.actionBody.userpin })
}
break;
default:
......@@ -92,38 +75,11 @@ class AccessAuthAPI extends APIBase {
*/
async getAppTokenByHosts(pobj, qobj, req) {
var token = this.getUUID();
var opResult = await this.opPlatformUtils.getReqTokenByHosts(pobj.actionBody.app_hosts, token);
var opResult = await this.utilsAuthSve.getReqTokenByHosts(pobj.actionBody.app_hosts, token);
if (opResult.status != 0) {
return opResult;
}
return system.getResultSuccess({ token: token })
}
async getToken(pobj, qobj, req) {
var appkey = pobj.appkey;
var secret = pobj.secret;
if (!appkey) {
return system.getResult(null, "appkey参数不能为空");
}
if (!secret) {
return system.getResult(null, "secret参数不能为空");
}
var result = await this.opPlatformUtils.getReqApiAccessKey(appkey, secret);
if (result && result.status && result.status != 0) {
return result;
}
var resultData = {
token: result && result.data ? result.data.accessKey : ""
};
return system.getResultSuccess(resultData);
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(pobj, qobj, req) {
return await this.opPlatformUtils.authByCode(qobj.code);
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
var APIBase = require("../../api.base");
var system = require("../../../system");
class jdAuthAPI extends APIBase {
constructor() {
super();
}
async getUser(pobj, qobj, req) {
console.log("pobj......getUser..........:\n", pobj);
console.log("qobj......getUser..........:\n", qobj);
return { getUser: "ok" };
}
async payOrderInfo(pobj, qobj, req) {
console.log("pobj......payOrderInfo..........:\n", pobj);
console.log("qobj......payOrderInfo..........:\n", qobj);
return { payOrderInfo: "ok" };
}
}
module.exports = jdAuthAPI;
\ No newline at end of file
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAccessKeyCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中缓存访问token";
}
prefix() {
return settings.cacheprefix + "_accesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var appkey = inputkey || settings.appKey;
var secret = items && items.length > 0 ? items[0] : settings.secret;
var acckapp = await this.restS.execPost({ appkey: appkey, secret: secret }, settings.paasUrl() + "api/auth/accessAuth/getAccessKey");
var s = acckapp.stdout;
console.log(acckapp.stdout, "ApiAccessKeyCache............. acckapp.stdout..........")
if (s) {
var tmp = JSON.parse(s);
return tmp;
// if (tmp.status == 0) {
// return JSON.stringify(tmp.data);
// }
}
return system.getResult(null, "返回数据为空!");
}
}
module.exports = ApiAccessKeyCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiAccessKeyCheckCache extends CacheBase {
constructor() {
super();
this.restS = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_verify_reqaccesskey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var cacheManager = system.getObject("db.common.cacheManager");
//当来访key缓存不存在时,需要去开放平台检查是否存在来访key缓存
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
if (acckapp.status != 0) {
return system.getResult(null, "获取本应用accessKey错误");
}
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.data.accessKey);
if (checkresult.status == 0) {
return checkresult;
// var s = checkresult.data;
// return JSON.stringify(s);
} else {
await cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
var acckapp = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, ex);//先获取本应用accessKey
var checkresult = await this.restS.execPostWithAK({ checkAccessKey: inputkey }, settings.paasUrl() + "api/auth/accessAuth/authAccessKey", acckapp.data.accessKey);
return checkresult;
// var s = checkresult.data;
// return JSON.stringify(s);
}
}
}
module.exports = ApiAccessKeyCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
class ApiAppKeyCheckCache extends CacheBase {
constructor() {
super();
this.appDao = system.getObject("db.dbapp.appDao");
}
desc() {
return "应用中来访访问appid缓存";
}
prefix() {
return settings.cacheprefix + "_verify_appKey:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var item = await this.appDao.getItemByAppKey(inputkey);
if (!item) {
return system.getResult(null, "返回数据为空!");
}
if (item.status != 1) {
return system.getResultFail(system.waitAuditSelfApp, "渠道应用处于待审核等待启用状态");
}
return system.getResultSuccess(item);
}
}
module.exports = ApiAppKeyCheckCache;
const CacheBase = require("../cache.base");
const system = require("../../system");
const settings = require("../../../config/settings");
//缓存首次登录的赠送的宝币数量
class ApiUserCache extends CacheBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appDao = system.getObject("db.dbapp.appDao");
this.appuserDao = system.getObject("db.dbapp.appuserDao");
this.restClient = system.getObject("util.restClient");
}
desc() {
return "应用中来访访问token缓存";
}
prefix() {
return settings.cacheprefix + "_userdata:";
}
async buildCacheVal(cachekey, inputkey, val, ex, ...items) {
var actionBody = items[0];
var selfAppInfo = items[1];
var uAppId = items[2];
var channelUserId = val || "";
var uUserName = channelUserId + "$" + selfAppInfo.data.uappKey;//uUserName
var createUserPwd = inputkey;//(格式:selfAppInfo.data.uappKey+”_“+channelUserId)
var userInfo = await this.appuserDao.getItemByUUserId(uUserName, selfAppInfo.data.id);
if (userInfo) {
var loginNum = Number(userInfo.loginNum || 0) + 1;
this.appuserDao.updateByWhere({ lastLoginTime: new Date(), loginNum: loginNum }, { where: { id: userInfo.id } });
return system.getResultSuccess(userInfo);
}
var uUserInfo = await this.opPlatformUtils.createUserInfo(uUserName, actionBody.channelUserMoblie || "15010888888",
createUserPwd, selfAppInfo.data.uappKey, selfAppInfo.data.appSecret);
if (uUserInfo.status != 2000 && uUserInfo.status != 0) {
return uUserInfo;
}//已经存在此用户 或 注册失败
if (uUserInfo.status == 0) {
var params = {
app_id: selfAppInfo.data.id,
channelUserId: channelUserId,
channelUserName: actionBody.channelUserName || channelUserId,
userMoblie: actionBody.channelUserMoblie || "88888888888",
nickname: actionBody.nickname || "",
orgName: actionBody.orgName || "",
orgPath: actionBody.orgPath || "",
uUserName: uUserName,
uAppId: uAppId,
isEnabled: 1,
lastLoginTime: new Date()
};
userInfo = await this.appuserDao.create(params);
}
else {
return uUserInfo;
}
return system.getResultSuccess(userInfo);
}
}
module.exports = ApiUserCache;
......@@ -4,8 +4,6 @@ const settings = require("../../../config/settings");
class AppUserPinByLoginPwdCache extends CacheBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appuserDao = system.getObject("db.dbapp.appuserDao");
this.restClient = system.getObject("util.restClient");
}
desc() {
......
......@@ -4,8 +4,6 @@ const settings = require("../../../config/settings");
class AppUserPinByLoginVcodeCache extends CacheBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.appuserDao = system.getObject("db.dbapp.appuserDao");
this.restClient = system.getObject("util.restClient");
}
desc() {
......
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppDao extends Dao {
constructor() {
super(Dao.getModelName(AppDao));
}
async getItemByAppKey(appKey) {
return this.model.findOne({
where: {
uappKey: appKey
},
attributes: ["id",
"name", // 应用名称
"appDataOpType", // 应用数据操作类型:00独立,10全委托,20部分委托
"appPayType", // 支付类型:00第三方应用自己支付,10平台代收款
"contactName", // 联系人姓名
"contactMobile", // 联系人手机
"contactEmail", // 联系人邮箱
"uappKey", // 平台应用key
"appSecret", // 密钥信息,用于进行签名请求接口
"status", // 状态 0禁用 1启用
"uAppId",
"channelAppId", // 渠道appID
"channelAppKey", // 渠道appKey
"pushOrderUrl", //获取渠道推送订单的url
"appSourceCode", //app来源code
"notes"],
raw: true
});
}
}
module.exports = AppDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppProductDao extends Dao {
constructor() {
super(Dao.getModelName(AppProductDao));
}
async findOneByServiceItemCode(itemCode, appId) {
return this.model.findOne({
where: {
serviceItemCode: itemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"serviceItemCode",
"pushServiceItemCode",
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
async findOneByCode(itemCode, appId) {
return this.model.findOne({
where: {
itemCode: itemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"serviceItemCode",
"pushServiceItemCode",
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
async findOneByChannelItemCode(channelItemCode, appId) {
return this.model.findOne({
where: {
channelItemCode: channelItemCode,
app_id: appId
},
attributes: ["id",
"app_id", // 应用id
"itemCode", // 产品编码
"itemName", // 产品名称
"picUrl", // 产品图片地址
"channelItemCode", // 渠道产品编码
"channelItemName", // 渠道产品名称
"serviceItemCode",
"pushServiceItemCode",
"deliveryUrl",
"status", // 状态 0禁用 1启用
"verifyPrice", // 是否验证价格 0不验证 1验证
"proPrice", // 产品价格
"serviceCharge", // 服务费
"publicExpense", // 官费
"rateConfig", // 税率
"discountsRateConfig",// 优惠税率
"channelProfitRate",// 渠道利润分成比率(只分订单中毛利润总额的分成)
"sort",
"productType_id",
"productOneType_id"],
raw: true
});
}
}
module.exports = AppProductDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class AppUserDao extends Dao {
constructor() {
super(Dao.getModelName(AppUserDao));
}
async getItemByUUserId(uUserName, appId) {
return this.model.findOne({
where: {
uUserName: uUserName,
app_id: appId
},
attributes: ["id",
"app_id",
"channelUserId",
"channelUserName",
"uUserName",
"uAppId",
"userMoblie",
"nickname",
"orgName",
"orgPath",
"isEnabled",
"loginNum",
"lastLoginTime"],
raw: true
});
}
}
module.exports = AppUserDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class MoneyAccountDao extends Dao {
constructor() {
super(Dao.getModelName(MoneyAccountDao));
}
}
module.exports = MoneyAccountDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class NeedInfoDao extends Dao{
constructor(){
super(Dao.getModelName(NeedInfoDao));
}
}
module.exports=NeedInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CustomerContactsDao extends Dao {
constructor() {
super(Dao.getModelName(CustomerContactsDao));
}
async findOneByMobile(mobile, customerinfoId) {
return this.model.findOne({
where: {
mobile: mobile,
customerinfo_id: customerinfoId
},
attributes: ["id",
"deliveryOrderNo",
"mobile",
"email",
"tel",
"fax",
"name",
"code",
"app_id"],
raw: true
});
}
async findOneByCustomerinfoId(customerinfoId) {
return this.model.findOne({
where: {
customerinfo_id: customerinfoId
},
attributes: ["id",
"deliveryOrderNo",
"mobile",
"email",
"tel",
"fax",
"name",
"code",
"app_id"],
raw: true
});
}
}
module.exports = CustomerContactsDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class CustomerInfoDao extends Dao {
constructor() {
super(Dao.getModelName(CustomerInfoDao));
}
async findOneByCodeAndUserId(code, userId) {
return this.model.findOne({
where: {
code: code,
createuser_id: userId
},
attributes: ["id",
"customerType",// ent:企业,person:个人
"customerTypeName",
"identityCardPic",//身份证图片
"businessLicensePic",//营业执照图片
"name",//公司名称或个人名称
"code",//公司统一社会代码
"app_id",
"deliveryOrderNo",
"applyAddr",//申请地址
"applyArea",//存储省市编码
"province",//省
"city",//市
"identityCardNo",//身份证号
"notes",//备注
"zipCode",
"identityCardPdf",
"businessLicensePdf",
"createuser_id",
"updateuser_id",
"owner_id"],
raw: true
});
}
async findOneByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findOne({
where: {
deliveryOrderNo: deliveryOrderNo
},
attributes: ["id",
"customerType",// ent:企业,person:个人
"customerTypeName",
"identityCardPic",//身份证图片
"businessLicensePic",//营业执照图片
"name",//公司名称或个人名称
"code",//公司统一社会代码
"app_id",
"deliveryOrderNo",
"applyAddr",//申请地址
"applyArea",//存储省市编码
"province",//省
"city",//市
"identityCardNo",//身份证号
"notes",//备注
"zipCode",
"identityCardPdf",
"businessLicensePdf",
"createuser_id",
"updateuser_id",
"owner_id"],
raw: true
});
}
}
module.exports = CustomerInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderFlowDao extends Dao {
constructor() {
super(Dao.getModelName(OrderFlowDao));
}
async getListBySourceOrderNo(sourceOrderNo) {
return this.model.findAll({
where: {
sourceOrderNo: sourceOrderNo,
isShow: 1
},
order:[["created_at", 'desc']],
raw: true
});
}
}
module.exports = OrderFlowDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OrderTmProductDao extends Dao {
constructor() {
super(Dao.getModelName(OrderTmProductDao));
}
async getTmListByChannelServiceNo(channelServiceNo, appId) {
return this.model.findAll({
where: {
channelServiceNo: channelServiceNo,
app_id: appId
},
raw: true
});
}
async getTmItemByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findOne({
where: {
deliveryOrderNo: deliveryOrderNo
},
raw: true
});
}
async getItemByNeedNoOrderNo(needNoOrderNo, appId, t) {
var sqlWhere = {
where: {
needNoOrderNo: needNoOrderNo,
app_id: appId
},
raw: true
};
if (t) {
sqlWhere.transaction = t;
}
sqlWhere.attributes = ["id",
"deliveryOrderNo",
"payStatus",
"needNo",
"sourceOrderNo",
"tmName",
"tmType",
"tmFormType",
"nclOneCodes",
"deliveryStatus",
"picUrl",
"colorizedPicUrl",
"sywjUrl",
"gzwtsUrl",
"nclCount",
"smwjUrl",
"updateuser_id",
"updateuser",
"notes",
"nclOneCount"
];
return this.model.findOne(sqlWhere);
}
async getItemByChannelServiceNo(channelServiceNo, appId, t) {
var sqlWhere = {
where: {
channelServiceNo: channelServiceNo,
app_id: appId
},
raw: true
};
if (t) {
sqlWhere.transaction = t;
}
sqlWhere.attributes = ["id",
"deliveryOrderNo",
"needNo",
"sourceOrderNo",
"tmName",
"tmType",
"tmFormType",
"nclOneCodes",
"deliveryStatus",
"picUrl",
"colorizedPicUrl",
"sywjUrl",
"gzwtsUrl",
"nclCount",
"smwjUrl",
"updateuser_id",
"updateuser",
"notes",
"nclOneCount"
];
return this.model.findOne(sqlWhere);
}
}
module.exports = OrderTmProductDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class ReceiptVoucherDao extends Dao {
constructor() {
super(Dao.getModelName(ReceiptVoucherDao));
}
async getItemSourceOrderNo(sourceOrderNo) {
return this.model.findAll({
where: {
sourceOrderNo: sourceOrderNo
},
raw: true
});
}
async addReceiptvoucher(orderParams, req, t) {
var param = {
app_id: orderParams.app_id,//
totalSum: orderParams.totalSum || 0,// 订单总额(产品价格×优惠费率×订单件数)
channelServiceNo: orderParams.channelServiceNo,// 渠道服务单号
auditStatus: "tg",
sourceType: "order",
sourceOrderNo: orderParams.orderNo,// 来源订单号
payDate: orderParams.payTime,//
createuser_id: orderParams.createuser_id,
creator: orderParams.creator || "",
accountType: "other",
};
return this.create(param, t);//创建订单
}
}
module.exports = ReceiptVoucherDao;
const system=require("../../../system");
const Dao=require("../../dao.base");
class TmOfficialDao extends Dao{
constructor(){
super(Dao.getModelName(TmOfficialDao));
}
async getListByTmRegistNum(tmRegistNum) {
return this.model.findAll({
where: {
tmRegistNum: tmRegistNum
},
raw: true
});
}
}
module.exports=TmOfficialDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class TradeMarkDao extends Dao {
constructor() {
super(Dao.getModelName(TradeMarkDao));
}
async getListByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findAll({
where: {
deliveryOrderNo: deliveryOrderNo
},
raw: true
});
}
}
module.exports = TradeMarkDao;
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("app", {
name: DataTypes.STRING(100), // 应用名称
appDataOpType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type),
}, // 应用数据操作类型:00独立,10全委托,20部分委托
appPayType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_pay_type),
}, // 支付类型:00第三方支付,10平台代收款
contactName : DataTypes.STRING(30), // 联系人姓名
contactMobile: DataTypes.STRING(30), // 联系人手机
contactEmail : DataTypes.STRING(30), // 联系人邮箱
uappKey : DataTypes.STRING(64), // 平台应用key
uAppId : DataTypes.INTEGER, //
appSecret : DataTypes.STRING(64), // 密钥信息,用于进行签名请求接口
status : DataTypes.INTEGER, // 状态 0禁用 1启用
channelAppId : DataTypes.STRING(64), // 渠道appID
channelAppKey: DataTypes.STRING(64), // 渠道appKey
pushOrderUrl : DataTypes.STRING(500), // 获取渠道推送订单的url
appSourceCode : DataTypes.STRING(50), // app来源code
notes : DataTypes.STRING, // 备注
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("appproduct", {
app_id :DataTypes.STRING(50),// 应用id
itemCode :DataTypes.STRING(100),// 产品编码
itemName :DataTypes.STRING(100),// 产品名称
picUrl :DataTypes.STRING(500),// 产品图片地址
channelItemCode :DataTypes.STRING(100),// 渠道产品编码
channelItemName :DataTypes.STRING(100),// 渠道产品名称
serviceItemCode :DataTypes.STRING(100),// 服务商产品编码
pushServiceItemCode :DataTypes.STRING(100),// 推送到服务商的产品编码
status :DataTypes.BOOLEAN,// 状态 0禁用 1启用
verifyPrice :DataTypes.BOOLEAN,// 是否验证价格 0不验证 1验证
proPrice :DataTypes.DOUBLE,// 产品价格
serviceCharge :DataTypes.DOUBLE,// 服务费
publicExpense :DataTypes.DOUBLE,// 官费
rateConfig :DataTypes.DECIMAL(12, 2),// 税率
discountsRateConfig :DataTypes.DECIMAL(12, 2),// 优惠税率
channelProfitRate :DataTypes.DECIMAL(12, 2),// 渠道利润分成比率(只分订单中毛利润总额的分成)
sort :DataTypes.INTEGER,// 排序
productType_id :DataTypes.INTEGER,// 产品类型Id
productOneType_id :DataTypes.INTEGER,// 产品大类Id
deliveryUrl:DataTypes.STRING(500),// 交付地址
productLogo:DataTypes.STRING(500),// 产品logo
productDesc:DataTypes.STRING(1024),// 产品描述
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app_product',
validate: {
},
indexes: [
// Create a unique index on email
// {
// unique: true,
// fields: ['email']
// },
//
// // Creates a gin index on data with the jsonb_path_ops operator
// {
// fields: ['data'],
// using: 'gin',
// operator: 'jsonb_path_ops'
// },
//
// // By default index name will be [table]_[fields]
// // Creates a multi column partial index
// {
// name: 'public_by_author',
// fields: ['author', 'status'],
// where: {
// status: 'public'
// }
// },
//
// // A BTREE index with a ordered field
// {
// name: 'title_index',
// method: 'BTREE',
// fields: ['author', {attribute: 'title', collate: 'en_US', order: 'DESC', length: 5}]
// }
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("appuser", {
app_id : DataTypes.INTEGER, // 应用id
channelUserId : DataTypes.STRING(64), // 渠道用户ID
channelUserName : DataTypes.STRING(64), // 渠道用户登录名
uUserName : DataTypes.STRING(64), //
uAppId : DataTypes.INTEGER, //
userMoblie : DataTypes.STRING(20), // 用户手机号
nickname : DataTypes.STRING(50), // 昵称
orgName : DataTypes.STRING(255), // 组织结构名称
orgPath : DataTypes.STRING(255), // 组织结构路径
isEnabled : DataTypes.INTEGER, // 是否启用
loginNum : DataTypes.INTEGER, // 登录次数
lastLoginTime : DataTypes.DATE, // 上次登录时间
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'c_app_user',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("moneyaccount", {
app_id: DataTypes.INTEGER, // 是否显示
balance: {//余额
type: DataTypes.DECIMAL(12, 3),
defaultValue: 0.00,
},
accountType: {
//帐户类型:"cash": "现金", "bank": "银行" ,"wx":"微信","alipay":"支付宝","other":"其它"
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.pay_account_type),
set: function (val) {
this.setDataValue("accountType", val);
this.setDataValue("accountTypeName", uiconfig.config.pdict.pay_account_type[val]);
},
defaultValue: "other",
},
accountTypeName: {//帐户类型名称
type: DataTypes.STRING(50),
defaultValue: "其它",
},
payeeName: {
type: DataTypes.STRING(100),
},//收款人姓名
certificateNo: DataTypes.STRING(100),//帐号
bankAddr: DataTypes.STRING(500), //银行地址
description: DataTypes.STRING,//描述
isOfflinePay: {//是否支持线下支付,0否,1是
type: DataTypes.BOOLEAN,
defaultValue: false,
},
transferRate: {//商户收款费率,千分率,如:值为5,计算时除以1000(第三方公司收款账户有此值)
type: DataTypes.DECIMAL(12, 2),
defaultValue: 5.00,
},
bankToPtTransferRate: {//银行收平台费率,千分率,如:值为2.6,计算时除以1000(平台公司收款账户有此值)
type: DataTypes.DECIMAL(12, 2),
defaultValue: 0,
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_moneyaccount',
validate: {
},
indexes: [
]
});
}
\ No newline at end of file
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("needinfo", {
app_id :DataTypes.INTEGER, //
needNo :DataTypes.STRING(64), //需求单号
needDesc :DataTypes.STRING(255), //
needUserMoblie :DataTypes.STRING(20), //
notes :DataTypes.STRING(255), //
opNotes :DataTypes.STRING(500), //
channelUserName :DataTypes.STRING(50), // 渠道用户登录名
auditStatus :DataTypes.STRING(10), //确认状态:00待确认,10确认通过,20确认不通过
createuser_id :DataTypes.INTEGER, //
updateuser_id :DataTypes.INTEGER, //
owner_id :DataTypes.INTEGER, //
creator :DataTypes.STRING(50), //
updator :DataTypes.STRING(50), //
owner :DataTypes.STRING(50), //
ownerMoblie :DataTypes.STRING(20), //
itemCode :DataTypes.STRING(80), //产品码
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_needinfo',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("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 moment = require('moment')
const settings = require("../../config/settings");
const md5 = require("MD5");
class AppServiceBase {
constructor() {
this.restClient = system.getObject("util.restClient");
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 execPostUrl(pobj, url) {
var rtn = await this.restClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
}
}
module.exports = AppServiceBase;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AapService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AapService));
}
async getItemByAppKey(appKey) {
return this.dao.getItemByAppKey(appKey);
}
}
module.exports = AapService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AppProductService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AppProductService));
}
//根据渠道产品码获取产品详情
async findByChannelItemCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var channelItemCode = obj.channelItemCode;
if(!channelItemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var product = await this.dao.model.findOne({
where:{channelItemCode:channelItemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig"],
raw:true
});
if(!product){
return system.getResultFail(-104, "未知产品");
}
return system.getResultSuccess(product);
}
//获取产品列表(根据父类产品编码获取)
async findByProductTypeCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productType_id:pProduct.id,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig",
"productLogo","productDesc"
],
raw:true
});
return system.getResultSuccess(pList);
}
//获取产品列表(根据产品一类编码获取)
async findByProductOneTypeCode(obj){
// var user = obj.user;
var app = obj.app;
// if(!user){
// return system.getResultFail(-101, "未知用户");
// }
if(!app){
return system.getResultFail(-102, "未知渠道");
}
var itemCode = obj.itemCode;
if(!itemCode){
return system.getResultFail(-103, "渠道产品编码不能为空");
}
var pProduct = await this.dao.model.findOne({
where:{itemCode:itemCode,app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName"],
raw:true
});
if(!pProduct || !pProduct.id){
return system.getResultFail(-104, "未知产品");
}
var pList = await this.dao.model.findAll({
where:{productOneType_id:pProduct.id,productType_id:{ [this.db.Op.ne]: 0 },app_id:app.id,status:1},
attributes:["id","app_id","itemCode","itemName","picUrl","channelItemCode","channelItemName",
"serviceItemCode","proPrice","serviceCharge","publicExpense","rateConfig","discountsRateConfig",
"productLogo","productDesc"
],
raw:true
});
return system.getResultSuccess(pList);
}
//--------------------------------应用中心获取产品信息-start-----------------------------------------------------
/**
* 根据产品类型码获取产品列表
* @param {*} obj
*/
async findByTypeCode(obj){
var app = obj.app;
if(!app || !app.uapp_id){
return system.getResultFail(-100, "渠道信息有误");
}
obj["uapp_id"]=app.uapp_id;
obj["actionType"]="findByTypeCode";
// var typeCode = obj.typeCode;
// if(!typeCode){
// return system.getResultFail(-101, "产品类型编码有误");
// }
var rc = system.getObject("util.restClient");
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
var rtn= await rc.execPost(obj, url);
var result = JSON.parse(rtn.stdout);
return result;
}
/**
* 根据产品类型码获取产品列表
* @param {*} obj
*/
async findByTypeOneCode(obj){
var app = obj.app;
if(!app || !app.uapp_id){
return system.getResultFail(-100, "渠道信息有误");
}
obj["uapp_id"]=app.uapp_id;
obj["actionType"]="findByTypeOneCode";
// var typeCode = obj.typeCode;
// if(!typeCode){
// return system.getResultFail(-101, "产品类型编码有误");
// }
var rc = system.getObject("util.restClient");
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
var rtn= await rc.execPost(obj, url);
var result = JSON.parse(rtn.stdout);
return result;
}
/**
* 获取产品详情
* @param {*} obj
*/
async getProductDetailByCode(obj){
var app = obj.app;
if(!app || !app.uapp_id){
return system.getResultFail(-100, "渠道信息有误");
}
obj["uapp_id"]=app.uapp_id;
obj["actionType"]="getProductDetailByCode";
var rc = system.getObject("util.restClient");
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
var rtn= await rc.execPost(obj, url);
var result = JSON.parse(rtn.stdout);
return result;
}
//--------------------------------应用中心获取产品信息--end----------------------------------------------------
}
module.exports = AppProductService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class AapUserService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(AapUserService));
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async loginUser(channelUserId, channelUserName, userMoblie, nickname, orgName, orgPath) {
if (!channelUserId) {
return system.getResult(null, "channelUserId不能为空");
}
var params = {
channelUserId: channelUserId,
channelUserName: channelUserName,
userMoblie: userMoblie,
nickname: nickname,
orgName: orgName,
orgPath: orgPath
}
var userItem = await this.cacheManager["ApiUserCache"].cache(channelUserId, { status: true }, 3000, params);
if (!userItem) {
return system.getResult(null, "用户注册失败");
}
return system.getResultSuccess(userItem);
}
}
module.exports = AapUserService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class MoneyAccountService extends ServiceBase {
constructor() {
super("dbapp", ServiceBase.getDaoName(MoneyAccountService));
}
}
module.exports=MoneyAccountService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class NeedInfoService extends ServiceBase {
constructor() {
super("dbneed", ServiceBase.getDaoName(NeedInfoService));
}
async subNeed(obj){
var user = obj.user;
var app = obj.app;
if(!user){
return system.getResultFail(-100, "未知用户");
}
if(!app){
return system.getResultFail(-101, "未知渠道");
}
var needNo=await this.getBusUid("ni");
var needObj={
app_id :app.id,
needNo :needNo,
needDesc :obj.needDesc,
needUserMoblie :obj.needUserMoblie,
notes :obj.notes,
channelUserName :user.channelUserName,
auditStatus :"00",
createuser_id :user.id,
itemCode:obj.itemCode
};
var need = await this.dao.create(needObj);
return system.getResultSuccess(need);
}
}
module.exports=NeedInfoService;
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");
this.orderflowDao = system.getObject("db.dborder.orderflowDao");
}
/**
* 修改商标交付单联系人(订单详情页面)
* @param {*} obj
* obj.deliveryOrderNo 交付订单号,
* obj.name 联系人,obj.mobile 联系电话,obj.email 电子邮箱,obj.tel 座机电话
* obj.user 用户数据
*/
async updateContacts(obj){
var user = obj.user;
var app = obj.app;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
if (!app || !app.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,app_id:app.id},
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,app_id: app.id }, transaction: t });
var logMsg = { sourceOrderNo: deliveryOrderNo, opContent: "修改订单信息", app_id: app.id, isShow: 1 };
await self.orderflowDao.create(logMsg, 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");
this.trademarkDao = system.getObject("db.dbtrademark.trademarkDao");
this.orderflowDao = system.getObject("db.dborder.orderflowDao");
}
/**
* 修改申请人信息(订单详情页面使用)
* @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;
var app = obj.app;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
if (!app || !app.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,app_id:app.id},
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,app_id:app.id
},
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.identityCardNo){
ciObj["identityCardNo"]=obj.identityCardNo;
}
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);//修改申请人信息
var customerinfo2 = await self.dao.model.findOne({
where:{
id:customerinfo.id
},
raw:true
});
if(ordertmproduct.gzwtsUrl && customerinfo2.businessLicensePdf && (customerinfo2.customerType=="ent" || customerinfo2.identityCardPdf)){
// otpObj["deliveryStatus"]="dsh";
if(ordertmproduct.deliveryStatus=="dsccl"){
await self.ordertmproductSve.update({id:ordertmproduct.id,deliveryStatus:"dsh"},t);
}
await self.trademarkDao.model.update({officialType:"dsh"},{where:{deliveryOrderNo:deliveryOrderNo,app_id:app.id},transaction:t});
}
var logMsg = { sourceOrderNo: deliveryOrderNo, opContent: "修改订单信息", app_id: app.id , isShow: 1};
await self.orderflowDao.create(logMsg, 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;
var app = obj.app;
if(!user || !user.id){
return system.getResultFail(-100, "未知用户");
}
if (!app || !app.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,app_id:app.id},
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,app_id:app.id
},
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 customerinfo2 = await self.dao.model.findOne({
where:{
id:customerinfo.id
},
raw:true
});
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;
}
if((ordertmproduct.gzwtsUrl || otpObj["gzwtsUrl"]) && customerinfo2.businessLicensePdf && (customerinfo2.customerType=="ent" || customerinfo2.identityCardPdf)){
if(ordertmproduct.deliveryStatus=="dsccl"){
otpObj["deliveryStatus"]="dsh";
}
await self.trademarkDao.model.update({officialType:"dsh"},{where:{deliveryOrderNo:deliveryOrderNo},transaction:t});
}
await self.ordertmproductSve.update(otpObj,t);//商标交付单 修改盖章委托书、说明文件
var logMsg = { sourceOrderNo: deliveryOrderNo, opContent: "修改订单信息", app_id: app.id, isShow: 1 };
await self.orderflowDao.create(logMsg, t);
return system.getResultSuccess();
})
}
}
module.exports=CustomerInfoService;
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 ReceiptVoucherService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(ReceiptVoucherService));
}
}
module.exports=ReceiptVoucherService;
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;
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
const logCtl = system.getObject("service.common.oplogSve");
//商标查询操作
class UtilsAuthSve {
class UtilsAuthSve extends AppServiceBase {
constructor() {
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
super();
}
async loginUserByChannelUserId(action_body, action_process, userpin, req) {
async loginUserByChannelUserId(pobj, actionBody) {
var opResult = null;
switch (action_process) {
switch (pobj.actionProcess) {
case "gsbhome":
opResult = await this.getDefaultUserInfo(action_body, userpin);
opResult = await this.getDefaultUserInfo(pobj, actionBody);
break;
default:
opResult = system.getResult(null, "action_process参数错误");
......@@ -18,19 +19,59 @@ class UtilsAuthSve {
}
return opResult;
}
async getDefaultUserInfo(action_body, userpin) {
var userinfo = await this.opPlatformUtils.getReqUserPinByChannelUserId(action_body, userpin);
return userinfo;
async getDefaultUserInfo(pobj, actionBody) {
if (!actionBody.channelUserId) {
return system.getResult(null, "actionBody.channelUserId can not be empty");
}
var result = await this.cacheManager["AppUserPinByChannelUserId"].cache(actionBody.userpin, pobj, system.exTime);
return result;
}
//---------------登录-----------------------------------------------------
async getReqUserPinByLgoin(action_body, action_process, userpin, req) {
var userinfo = await this.opPlatformUtils.getReqUserPinByLgoin(action_body, userpin);
return userinfo;
async getReqTokenByHosts(appHosts, tokenValue) { //获取token
if (!appHosts) {
return system.getResult(null, "appHosts can not be empty");
}
var result = await this.cacheManager["AppTokenByHostsCache"].cache(tokenValue, appHosts, system.exTime);
return result;
}
async getVerifyCodeByMoblie(pobj, actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty !");
}
var acckapp = await this.restClient.execPost(pobj, settings.centerAppUrl() + "auth/accessAuth/getVerifyCodeByMoblie");
var result = acckapp.stdout;
if (result) {
var tmp = JSON.parse(result);
return tmp;
}
return system.getResult(null, "data is empty");
}
async getReqUserPinByLgoinVcode(action_body, action_process, userpin, req) {
var userinfo = await this.opPlatformUtils.getReqUserPinByLgoinVcode(action_body, userpin, action_body.reqType);
return userinfo;
async getReqUserPinByLgoin(pobj, actionBody) {
if (!actionBody.userName) {
return system.getResult(null, "actionBody.userName can not be empty");
}
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
var result = await this.cacheManager["AppUserPinByLoginPwdCache"].cache(actionBody.userpin, pobj, system.exTime);
return result;
}
async getReqUserPinByLgoinVcode(pobj, actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty");
}
if (!actionBody.vcode) {
return system.getResult(null, "actionBody.vcode can not be empty");
}
if (actionBody.reqType == "reg") {
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
}
var result = await this.cacheManager["AppUserPinByLoginVcodeCache"].cache(actionBody.userpin, pobj, system.exTime);
return result;
}
}
......
var system = require("../../../system");
var settings = require("../../../../config/settings");
const AppServiceBase = require("../../app.base");
//商标查询操作
class UtilsProductSve extends AppServiceBase {
constructor() {
super();
}
//--------------------------------应用中心获取产品信息-start-----------------------------------------------------
/**
* 根据产品类型码获取产品列表
* @param {*} actionBody
*/
async findByTypeCode(pobj, actionBody) {
if (!actionBody.typeCode) {
return system.getResult(null, "actionBody.typeCode can not be empty");
}
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.execPostUrl(pobj, url);
}
/**
* 根据产品类型码获取产品列表
* @param {*} actionBody
*/
async findByTypeOneCode(pobj, actionBody) {
if (!actionBody.typeOneCode) {
return system.getResult(null, "actionBody.typeOneCode can not be empty");
}
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.execPostUrl(pobj, url);
}
/**
* 获取产品详情
* @param {*} obj
*/
async getProductDetailByCode(pobj, actionBody) {
if (!actionBody.channelItemCode) {
return system.getResult(null, "actionBody.channelItemCode can not be empty");
}
var url = settings.centerAppUrl() + "action/opProduct/springBoard";
return await this.execPostUrl(pobj, url);
}
//--------------------------------应用中心获取产品信息--end----------------------------------------------------
}
module.exports = UtilsProductSve;
......@@ -5,7 +5,7 @@ const md5 = require("MD5");
class ServiceBase {
constructor(gname, daoName) {
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.dao = system.getObject("db." + gname + "." + daoName);
this.restS = system.getObject("util.restClient");
......
const system = require("../../system");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
var settings = require("../../../config/settings");
class OpPlatformUtils {
constructor() {
this.restClient = system.getObject("util.restClient");
this.createUserUrl = settings.paasUrl() + "api/auth/accessAuth/register";
this.fetchDefaultVCodeUrl = settings.paasUrl() + "api/auth/accessAuth/fetchDefaultVCode";
this.loginUrl = settings.paasUrl() + "api/auth/accessAuth/loginByMd5Password";
this.authByCodeUrl = settings.paasUrl() + "api/auth/accessAuth/authByCode";
this.exTime = 2 * 3600;//缓存过期时间,2小时
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
async getReqApiAccessKey(appKey, secret) {
var cacheManager = system.getObject("db.common.cacheManager");
var reqApiAccessKey = null;
if (appKey && secret) {
reqApiAccessKey = await cacheManager["ApiAccessKeyCache"].cache(appKey, null, this.exTime, secret);
} else {
reqApiAccessKey = await cacheManager["ApiAccessKeyCache"].cache(settings.appKey, null, this.exTime);
}
if (!reqApiAccessKey || !reqApiAccessKey.data) {
return system.getResult(null, "获取请求token失败");
}
return reqApiAccessKey;
}
/**
* 创建用户信息
* @param {*} userName 用户名
* @param {*} mobile 手机号
* @param {*} password 密码,不传为使用默认密码
*
* 返回值:
* {
"status": 0,---值为2000为已经存在此用户,注册失败
"msg": "success",
"data": {
"auth_url": "http://sj.app.com:3002/auth?opencode=1e4949d1c39444a8b32f023143625b1d",---回调url,通过回调地址获取平台用户信息
"opencode": "1e4949d1c39444a8b32f023143625b1d",---平台用户code随机生成会变,平台是30s有效期,通过其可以向获取用户信息
"open_user_id": 12---平台用户id
},
"requestid": "5362bf6f941e4f92961a61068f05cd7f"
}
*/
async createUserInfo(userName, mobile, password, appKey, secret) {
var reqApiAccessKey = await this.getReqApiAccessKey(appKey, secret);
if (reqApiAccessKey.status != 0) {
return reqApiAccessKey;
}
var param = {
userName: userName,
mobile: mobile,
password: password || settings.defaultPassWord,
}
//按照访问token
var restResult = await this.restClient.execPostWithAK(
param,
this.createUserUrl, reqApiAccessKey.data.accessKey);
if (restResult.status != 0 || !restResult.data) {
return system.getResult(restResult.status, restResult.msg);
}
return system.getResultSuccess(restResult.data);
}
async fetchVCode(mobile) {
var reqApiAccessKey = await this.getReqApiAccessKey(null, null);
if (reqApiAccessKey.status != 0) {
return reqApiAccessKey;
}
var param = { mobile: mobile }
//按照访问token
var restResult = await this.restClient.execPostWithAK(
param,
this.fetchDefaultVCodeUrl, reqApiAccessKey.data.accessKey);
if (restResult.status != 0 || !restResult.data) {
return system.getResult(null, restResult.msg);
}
return system.getResultSuccess();
}
/**
* 用户登录
* @param {*} userName 用户名
* @param {*} password 密码,不传为使用默认密码
*
* 返回值:
* {
"status": 0,---值为2010为用户名或密码错误
"msg": "success",
"data": {
"auth_url": "http://sj.app.com:3002/auth?opencode=1e4949d1c39444a8b32f023143625b1d",---回调url,通过回调地址获取平台用户信息
"opencode": "1e4949d1c39444a8b32f023143625b1d"---平台用户code随机生成会变,平台是30s有效期,通过其可以向获取用户信息
},
"requestid": "5362bf6f941e4f92961a61068f05cd7f"
}
*/
async login(userName, password, appKey, secret) {
var reqApiAccessKey = await this.getReqApiAccessKey(appKey, secret);
if (reqApiAccessKey.status != 0) {
return reqApiAccessKey;
}
var param = {
userName: userName,
password: password || settings.defaultPassWord,
}
//按照访问token
var restResult = await this.restClient.execPostWithAK(
param,
this.loginUrl, reqApiAccessKey.data.accessKey);
if (restResult.status != 0 || !restResult.data) {
return system.getResult(restResult.status, restResult.msg);
}
return system.getResultSuccess(restResult.data);
}
/**
* 通过opencode获取用户登录信息
* @param {*} opencode 用户登录或注册opencode
*
* 返回值:
* {
"status": 0,---值为2010为用户名或密码错误
"msg": "success",
"data": {},---平台用户信息
"requestid": "5362bf6f941e4f92961a61068f05cd7f"
}
*/
async authByCode(opencode, appKey, secret) {
var reqApiAccessKey = await this.getReqApiAccessKey(appKey, secret);
if (reqApiAccessKey.status != 0) {
return reqApiAccessKey;
}
var param = {
opencode: opencode
}
//按照访问token
var restResult = await this.restClient.execPostWithAK(
param,
this.authByCodeUrl, reqApiAccessKey.data.accessKey);
if (restResult.status != 0 || !restResult.data) {
return system.getResult(restResult.status, restResult.msg);
}
return system.getResultSuccess(restResult.data);
}
//------------------------新的方式------------------------------------------------------------------------------------
async getReqTokenByHosts(appHosts, tokenValue) {
if (!appHosts) {
return system.getResult(null, "appHosts can not be empty");
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppTokenByHostsCache"].cache(tokenValue, appHosts, system.exTime);
return result;
}
async getReqUserPinByChannelUserId(actionBody, userPinValue) {
if (!actionBody.channelUserId) {
return system.getResult(null, "actionBody.channelUserId can not be empty");
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppUserPinByChannelUserId"].cache(userPinValue, actionBody, system.exTime);
return result;
}
async getReqUserPinByLgoin(actionBody, userPinValue) {
if (!actionBody.userName) {
return system.getResult(null, "actionBody.userName can not be empty");
}
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppUserPinByLoginPwdCache"].cache(userPinValue, actionBody, system.exTime);
return result;
}
async getReqUserPinByLgoinVcode(actionBody, userPinValue, reqType) {
if (!actionBody.mobile) {
return system.getResult(null, "actionBody.mobile can not be empty");
}
if (!actionBody.vcode) {
return system.getResult(null, "actionBody.vcode can not be empty");
}
if (reqType == "reg") {
if (!actionBody.password) {
return system.getResult(null, "actionBody.password can not be empty");
}
}
var cacheManager = system.getObject("db.common.cacheManager");
var result = await cacheManager["AppUserPinByLoginVcodeCache"].cache(userPinValue, actionBody, system.exTime);
return result;
}
async getVerifyCodeByMoblie(actionBody) {
if (!actionBody.mobile) {
return system.getResult(null, "pobj.mobile can not be empty !");
}
var acckapp = await this.restClient.execPost(actionBody, settings.centerAppUrl() + "auth/accessAuth/getVerifyCodeByMoblie");
var result = acckapp.stdout;
if (result) {
var tmp = JSON.parse(result);
return tmp;
}
return system.getResult(null, "data is empty");
}
}
module.exports = OpPlatformUtils;
var url = require("url");
var system = require("../../base/system");
module.exports = function (app) {
app.get('/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
classPath = gname + "." + classPath;
var tClientIp = system.get_client_ip(req);
req.clientIp = tClientIp;
req.uagent = req.headers["user-agent"];
req.classname = classPath;
var params = [];
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
app.post('/:gname/:qname/:method', function (req, res) {
var classPath = req.params["qname"];
var methodName = req.params["method"];
var gname = req.params["gname"];
var params = [];
classPath = gname + "." + classPath;
var tClientIp = system.get_client_ip(req);
req.clientIp = tClientIp;
req.uagent = req.headers["user-agent"];
req.classname = classPath;
params.push(gname);
params.push(methodName);
params.push(req.body);
params.push(req.query);
params.push(req);
var p = null;
var invokeObj = system.getObject("api." + classPath);
if (invokeObj["doexec"]) {
p = invokeObj["doexec"].apply(invokeObj, params);
}
p.then(r => {
res.end(JSON.stringify(r));
});
});
//-----------------------新的模式------------------开始
app.all("/web/*", async function (req, res, next) {
......@@ -84,8 +31,8 @@ module.exports = function (app) {
res.end(JSON.stringify(result));
return result;
}
req.appInfo = result.data;
req.body.actionProcess = req.appInfo.app_code;
req.body.appInfo = result.data;
req.body.actionProcess = result.data.app_code;
var lst = [
"subTmOrder", "getTmOrderList",
"getTmOrderInfo", "getTmApplyInfo",
......@@ -107,7 +54,7 @@ module.exports = function (app) {
res.end(JSON.stringify(result));
return result;
}
req.userInfo = result.data;
req.body.userInfo = result.data;
}
}//需要用户登录
next();
......
var path = require('path');
var ENVINPUT={
DB_HOST:process.env.DB_HOST,
DB_PORT:process.env.DB_PORT,
DB_USER:process.env.DB_USER,
DB_PWD:process.env.DB_PWD,
DB_NAME:process.env.ZC_CHANNEL_DB_NAME,
REDIS_HOST:process.env.REDIS_HOST,
REDIS_PORT:process.env.REDIS_PORT,
REDIS_PWD:process.env.REDIS_PWD,
REDIS_DB:process.env.ZC_CHANNEL_REDIS_DB,
APP_ENV:process.env.APP_ENV?process.env.APP_ENV:"dev"
var ENVINPUT = {
DB_HOST: process.env.DB_HOST,
DB_PORT: process.env.DB_PORT,
DB_USER: process.env.DB_USER,
DB_PWD: process.env.DB_PWD,
DB_NAME: process.env.ZC_CHANNEL_DB_NAME,
REDIS_HOST: process.env.REDIS_HOST,
REDIS_PORT: process.env.REDIS_PORT,
REDIS_PWD: process.env.REDIS_PWD,
REDIS_DB: process.env.ZC_CHANNEL_REDIS_DB,
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "dev"
};
var settings = {
env:ENVINPUT.APP_ENV,
env: ENVINPUT.APP_ENV,
appKey: "201911061250",
secret: "f99d413b767f09b5dff0b3610366cc46",
salt: "%iatpD1gcxz7iF#B",
cacheprefix: "centerChannel",
usertimeout: 3600,//单位秒
basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 4003,
port: process.env.NODE_PORT || 4011,
paasUrl: function () {
if (this.env == "dev") {
return "http://p.apps.com:4001/";
......@@ -33,7 +33,7 @@ var settings = {
} else {
return "https://centerapp/";
}
},
},
reqTransferurl: function () {
if (this.env == "dev") {
return "http://192.168.18.61:3003/";
......@@ -86,10 +86,10 @@ var settings = {
return localsettings.redis;
} else {
return {
host:ENVINPUT.REDIS_HOST,
port:ENVINPUT.REDIS_PORT,
password:ENVINPUT.REDIS_PWD,
db:ENVINPUT.REDIS_DB,
host: ENVINPUT.REDIS_HOST,
port: ENVINPUT.REDIS_PORT,
password: ENVINPUT.REDIS_PWD,
db: ENVINPUT.REDIS_DB,
};
}
},
......@@ -99,24 +99,24 @@ var settings = {
return localsettings.database;
} else {
return {
dbname : ENVINPUT.DB_NAME,
user : ENVINPUT.DB_USER,
password : ENVINPUT.DB_PWD,
config : {
host: ENVINPUT.DB_HOST,
dialect: 'mysql',
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 90000000,
idle: 1000000
},
debug:false,
dialectOptions:{
requestTimeout: 999999,
// instanceName:'DEV'
} //设置MSSQL超时时间
dbname: ENVINPUT.DB_NAME,
user: ENVINPUT.DB_USER,
password: ENVINPUT.DB_PWD,
config: {
host: ENVINPUT.DB_HOST,
dialect: 'mysql',
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 90000000,
idle: 1000000
},
debug: false,
dialectOptions: {
requestTimeout: 999999,
// instanceName:'DEV'
} //设置MSSQL超时时间
},
};
}
......
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