Commit e242a828 by 王栋源

wdy

parent 61220171
const system = require("../system");
const settings = require("../../config/settings");
const DocBase = require("./doc.base");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class APIBase {
......
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
......@@ -8,7 +8,7 @@ class TradetransferAPI extends APIBase {
this.execlient = system.getObject("util.execClient");
this.channelApiUrl = settings.channelApiUrl();
this.appInfo = {
aliyuntmtransfer: { appkey: "201912031344", secret: "7cbb846246874167b5c7e01cd0016c88" }
aliyuntmtransfer: { appkey: settings.appKey, secret: settings.secret }
};
}
......
var APIBase = require("../../api.base");
var system = require("../../../system");
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
}
async getToken(pobj, qobj, req) {
var appkey = pobj.appkey;
var secret = pobj.secret;
if (!appkey) {
return system.getResult(null, "appkey参数不能为空");
}
if (!secret) {
return system.getResult(null, "secret参数不能为空");
}
var result = await this.opPlatformUtils.getReqApiAccessKey(appkey, secret);
if (result && result.status && result.status != 0) {
return result;
}
var resultData = {
token: result && result.data ? result.data.accessKey : ""
};
return system.getResultSuccess(resultData);
}
async getPlatformAppItem(pobj, qobj, req) {
return req.uApp;
}
async getLongAppItem(pobj, qobj, req) {
return req.app;
}
async getUserItem(pobj, qobj, req) {
return req.user;
}
/**
* 开放平台回调处理
* @param {*} req
*/
async authByCode(pobj, qobj, req) {
return await this.opPlatformUtils.authByCode(qobj.code);
}
}
module.exports = AccessAuthAPI;
\ No newline at end of file
......@@ -9,35 +9,5 @@ class TestAPI extends APIBase {
// 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
......@@ -59,6 +59,18 @@ class CtlBase {
var rd = await this.service.create(qobj);
return system.getResult(rd, null);
}
async createLog(queryobj, qobj, req) {
if (req && req.session && req.session.app) {
qobj.app_id = req.session.app.id;
qobj.onlyCode = req.session.user.unionId;
if (req.codepath) {
qobj.codepath = req.codepath;
}
}
var tmpParam = qobj || queryobj;
var rd = await this.service.create(tmpParam);
return system.getResult(rd, null);
}
async update(queryobj, qobj, req) {
if (req && req.session && req.session.user) {
qobj.onlyCode = req.session.user.unionId;
......
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;
......@@ -17,23 +17,23 @@ class OplogCtl extends CtlBase {
}
async debug(obj) {
obj.logLevel = "debug";
return this.create(obj);
return this.createLog(obj);
}
async info(obj) {
obj.logLevel = "info";
return this.create(obj);
return this.createLog(obj);
}
async warn(obj) {
obj.logLevel = "warn";
return this.create(obj);
return this.createLog(obj);
}
async error(obj) {
obj.logLevel = "error";
return this.create(obj);
return this.createLog(obj);
}
async fatal(obj) {
obj.logLevel = "fatal";
return this.create(obj);
return this.createLog(obj);
}
/*
......
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..........")
console.log("------------------------------------------cuowu--------------------------------------")
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 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 || "15088888888",
// 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 || "15088888888",
// nickname: actionBody.nickname || "",
// orgName: actionBody.orgName || "",
// orgPath: actionBody.orgPath || "",
// uUserName: uUserName,
// uAppId: selfAppInfo.uAppId,
// isEnabled: 1,
// lastLoginTime: new Date()
// };
// userInfo = await this.appuserDao.create(params);
// }
// else {
// return uUserInfo;
// }
// return system.getResultSuccess(userInfo);
return system.getResultSuccess(null);
}
}
module.exports = ApiUserCache;
const system=require("../../../system");
const fs=require("fs");
const settings=require("../../../../config/settings");
var glob = require("glob");
class APIDocManager{
constructor(){
this.doc={};
this.buildAPIDocMap();
}
async buildAPIDocMap(){
var self=this;
//订阅任务频道
var apiPath=settings.basepath+"/app/base/api/impl";
var rs = glob.sync(apiPath + "/**/*.js");
if(rs){
for(let r of rs){
// var ps=r.split("/");
// var nl=ps.length;
// var pkname=ps[nl-2];
// var fname=ps[nl-1].split(".")[0];
// var obj=system.getObject("api."+pkname+"."+fname);
var ClassObj=require(r);
var obj=new ClassObj();
var gk=obj.apiDoc.group+"|"+obj.apiDoc.groupDesc
if(!this.doc[gk]){
this.doc[gk]=[];
this.doc[gk].push(obj.apiDoc);
}else{
this.doc[gk].push(obj.apiDoc);
}
}
}
}
}
module.exports=APIDocManager;
const 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 DeliveryProductDao extends Dao {
constructor() {
super(Dao.getModelName(DeliveryProductDao));
}
}
module.exports = DeliveryProductDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class FlowLogDao extends Dao {
constructor() {
super(Dao.getModelName(FlowLogDao));
}
async getListBySourceOrderNo(sourceOrderNo) {
return this.model.findAll({
where: {
sourceOrderNo: sourceOrderNo,
isShow: 1
},
raw: true
});
}
}
module.exports = FlowLogDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class OfficialInfoDao extends Dao {
constructor() {
super(Dao.getModelName(OfficialInfoDao));
}
async getListByTmRegistNum(tmRegistNum) {
return this.model.findAll({
where: {
tmRegistNum: tmRegistNum
},
raw: true
});
}
}
module.exports = OfficialInfoDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class TmDeliveryDao extends Dao {
constructor() {
super(Dao.getModelName(TmDeliveryDao));
}
async getListByTmRegistNum(tmRegistNum) {
return this.model.findAll({
where: {
tmRegistNum: tmRegistNum
},
raw: true
});
}
}
module.exports = TmDeliveryDao;
const system = require("../../../system");
const Dao = require("../../dao.base");
class TradeMarkDao extends Dao {
constructor() {
super(Dao.getModelName(TradeMarkDao));
}
async getListByDeliveryOrderNo(deliveryOrderNo) {
return this.model.findAll({
where: {
deliveryOrderNo: deliveryOrderNo
},
raw: true
});
}
}
module.exports = TradeMarkDao;
module.exports = {
"appid": "201911051030",
"appid": "201912031344",
"label": "知产api应用",
"config": {
"rstree": {
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("customercontacts", {
uapp_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号
contactName :DataTypes.STRING(1000), // 联系人
mobile :DataTypes.STRING(20), //
email :DataTypes.STRING(50), //
tel :DataTypes.STRING(20), //
fax :DataTypes.STRING(50), //
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'd_customercontacts',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("customerinfo", {
uapp_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), // 交付订单号
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
applyname :DataTypes.STRING(1000), // 公司名称或个人名称
applycode :DataTypes.STRING(100), // 公司统一社会代码
identityCardNo :DataTypes.STRING(50), // 身份证号
applyAddr :DataTypes.STRING, // 申请地址
applyArea :DataTypes.STRING(50), // 存储省市编码
province :DataTypes.STRING(50), // 省
city :DataTypes.STRING(50), // 市
notes :DataTypes.STRING, // 备注
createuser_id :DataTypes.INTEGER, //
updateuser_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: 'd_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("deliveryproduct", {
uapp_id: DataTypes.INTEGER,//
deliveryOrderNo: DataTypes.STRING(64),//交付订单号
needNo: DataTypes.STRING(64),//需求单号(渠道过来的订单号,如阿里、1688过来的单号)
itemCode: DataTypes.STRING(64),//
itemName: DataTypes.STRING(100),//
channelItemCode: DataTypes.STRING(64),// 渠道产品编码
channelItemName: DataTypes.STRING,// 渠道产品名称
proPrice: DataTypes.DOUBLE,// 产品价格
picUrl: DataTypes.STRING(500),// 产品图片地址
productType_id: DataTypes.INTEGER, //产品类型Id
productOneType_id: DataTypes.INTEGER, //产品大类Id
serviceItemSnapshot: DataTypes.TEXT, //产品快照
createuser_id: DataTypes.INTEGER,//
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'd_delivery_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("flowlog", {
uapp_id: DataTypes.INTEGER, //
deliveryOrderNo: DataTypes.STRING(64),//交付订单号
opContent: DataTypes.STRING(208), // 操作描述
notes: DataTypes.STRING, // 备注
createuser_id: DataTypes.INTEGER, //
isShow: {//是否显示
type: DataTypes.BOOLEAN,
defaultValue: false,
},
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'd_flow_log',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("tmofficialinfo", {
uapp_id :DataTypes.INTEGER, //
officialCode :DataTypes.STRING(50), //官文号(如:商标注册号)
officialTypeName :DataTypes.STRING(100), //
officialType :DataTypes.STRING(50),
//商标官文类型:1: 商标注册申请书, 2: 商标注册申请补正通知书, 3: 商标注册申请受理通知书, 4: 商标注册申请不予受理通知书,
//5: 商标注册同日申请补送使用证据通知书,6: 商标注册同日申请协商通知书商标注册同日申请抽签通知书,
//7: 商标驳回通知书, 8: 商标部分驳回通知书, 9: 商标注册申请初步审定公告通知书,
//10: 商标异议答辩通知书, 11: 异议裁定书, 12: 纸质版商标注册证, 13: 电子版商标注册证
officialFileName :DataTypes.STRING(200), // 官文文件名称
officialFileUrl :DataTypes.STRING(500), // 官文文件地址
notes :DataTypes.STRING , //
officialMailType :DataTypes.STRING(10), //官文邮寄类型:1: 待申请, 2: 待邮寄, 3: 已邮寄
officialMailTypeName :DataTypes.STRING(50), //官文邮寄类型名称
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: 'd_tmofficial',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("tmdelivery", {
uapp_id: DataTypes.INTEGER,//
deliveryOrderNo: DataTypes.STRING(64),//交付订单号
channelUserId: DataTypes.STRING(64),//渠道用户ID
channelServiceNo: DataTypes.STRING(64),//渠道服务单号
channelOrderNo: DataTypes.STRING(1024),//渠道订单号列表,多个以,隔开
needNo: DataTypes.STRING(64),//需求单号(渠道过来的订单号,如阿里、1688过来的单号)
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:已支付
payTime :DataTypes.DATE,// 渠道有支付时间则用渠道的支付时间
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: 待上传材料,dqrfa:待确认方案,fabtg:方案不通过, dsh: 待审核, ddj: 待递交, ydj: 已递交, ywc: 已完成
submitTime :DataTypes.DATE,// 递交时间
appDataOpType: {
type: DataTypes.ENUM,
values: Object.keys(uiconfig.config.pdict.app_data_op_type),
},//应用数据操作类型:00独立,10全委托,20部分委托
picUrl: DataTypes.STRING(500), //商标图样
colorizedPicUrl: DataTypes.STRING(500),//商标彩色图样
gzwtsUrl: DataTypes.STRING(500), //盖章委托书
sywjUrl: DataTypes.STRING(500), //声音文件
smwjUrl: DataTypes.STRING(500), //说明文件
notes: DataTypes.STRING(255),//备注
createuser_id: DataTypes.INTEGER,//
updateuser_id: DataTypes.INTEGER,//
auditor_id: DataTypes.INTEGER,//
createuser: DataTypes.STRING(100),//
updateuser: DataTypes.STRING(100),//
auditoruser: DataTypes.STRING(100),//
nclOneCount: DataTypes.INTEGER, // 尼斯大类数量
nclCount: DataTypes.INTEGER, // 尼斯数量
nclPublicExpense :DataTypes.DECIMAL(12, 2), // 尼斯官费总额
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'tm_delivery',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("trademark", {
uapp_id :DataTypes.INTEGER, //
deliveryOrderNo :DataTypes.STRING(64), //交付订单号
channelServiceNo: DataTypes.STRING(64),//渠道服务单号
channelOrderNo :DataTypes.STRING(1024), //渠道订单号,单个
needNo: DataTypes.STRING(64),//需求单号(渠道过来的订单号,如阿里、1688过来的单号)
bizNo :DataTypes.STRING(64), //业务单号,用于对接第三方业务单号(如:阿里的商标单号)
channelUserId :DataTypes.STRING(64), //渠道用户ID
tbCode :DataTypes.STRING(50), //提报号(自动生成)
nclOneCodes :DataTypes.STRING(10), //尼斯大类
nclOneCodesName :DataTypes.STRING(100), //尼斯大类
nclSmallCodes :DataTypes.TEXT('long'), //尼斯小类
submitTime :DataTypes.DATE, //提报时间
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: 电子版商标注册证
// "dsccl": "待上传材料", "dsh": "待审核", "shbtg": "审核不通过", "ddj": "待递交", "ydj": "已递交", "djyc": "递交异常" //
tbKey :DataTypes.STRING(50), //
tbErrorCount :DataTypes.INTEGER, //
opNotes :DataTypes.STRING(500), //
subErrorMsg :DataTypes.STRING(4000), // 提报错误信息
payPublicExpense :DataTypes.INTEGER, // 支付官费,0否,1是
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), //
nclCount :DataTypes.INTEGER, // 尼斯数量
nclPublicExpense :DataTypes.DECIMAL(12, 2), // 尼斯官费总额
}, {
paranoid: false,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'tm_trademark',
validate: {
},
indexes: [
]
});
}
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class CustomerContactsService extends ServiceBase {
constructor() {
super("dbdelivery", 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("dbdelivery", 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 DeliveryProductSve extends ServiceBase {
constructor() {
super("dbdelivery", ServiceBase.getDaoName(DeliveryProductSve));
// this.appproductDao = system.getObject("db.dbapp.appproductDao");
// this.ordertmproductDao = system.getObject("db.dborder.ordertmproductDao");
// // this.orderDao = system.getObject("db.dborder.orderDao");
// this.customerinfoDao = system.getObject("db.dborder.customerinfoDao");
// this.customercontactsDao = system.getObject("db.dborder.customercontactsDao");
// this.orderflowDao = system.getObject("db.dborder.orderflowDao");
// this.trademarkDao = system.getObject("db.dbtrademark.trademarkDao");
// this.receiptvoucherDao = null;
// this.tmofficialDao = system.getObject("db.dbtrademark.tmofficialDao");
}
}
module.exports = DeliveryProductSve;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class FlowLogService extends ServiceBase {
constructor() {
super("dbdelivery", ServiceBase.getDaoName(FlowLogService));
}
}
module.exports = FlowLogService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class OfficialInfoService extends ServiceBase {
constructor() {
super("dbdelivery", ServiceBase.getDaoName(OfficialInfoService));
}
}
module.exports = OfficialInfoService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class TmDeliverySve extends ServiceBase {
constructor() {
super("dbtrademark", ServiceBase.getDaoName(TmDeliverySve));
// this.appproductDao = system.getObject("db.dbapp.appproductDao");
// this.ordertmproductDao = system.getObject("db.dborder.ordertmproductDao");
// // this.orderDao = system.getObject("db.dborder.orderDao");
// this.customerinfoDao = system.getObject("db.dborder.customerinfoDao");
// this.customercontactsDao = system.getObject("db.dborder.customercontactsDao");
// this.orderflowDao = system.getObject("db.dborder.orderflowDao");
// this.trademarkDao = system.getObject("db.dbtrademark.trademarkDao");
// this.receiptvoucherDao = null;
// this.tmofficialDao = system.getObject("db.dbtrademark.tmofficialDao");
}
}
module.exports = TmDeliverySve;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class TradeMarkService extends ServiceBase {
constructor() {
super("dbtrademark", ServiceBase.getDaoName(TradeMarkService));
}
}
module.exports = TradeMarkService;
......@@ -102,38 +102,6 @@ class ServiceBase {
}
return tResult;
}
async apiCallWithAk(url, params) {
var acckapp = await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey);
var acck = acckapp.accessKey;
//按照访问token
var restResult = await this.restS.execPostWithAK(params, url, acck);
if (restResult) {
if (restResult.status == 0) {
var resultRtn = restResult.data;
return resultRtn;
} else {
await this.cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
return null;
}
}
return null;
}
// async apiCallWithAkNoWait(url,params){
// var acckapp=await this.cacheManager["ApiAccessKeyCache"].cache(settings.appKey);
// var acck=acckapp.accessKey;
// //按照访问token
// var restResult=await this.restS.execPostWithAK(params,url,acck);
// if(restResult){
// if(restResult.status==0){
// var resultRtn=restResult.data;
// return resultRtn;
// }else{
// await this.cacheManager["ApiAccessKeyCache"].invalidate(settings.appKey);
// return null;
// }
// }
// return null;
// }
static getDaoName(ClassObj) {
return ClassObj["name"].substring(0, ClassObj["name"].lastIndexOf("Service")).toLowerCase() + "Dao";
}
......
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.status != 0) {
return reqApiAccessKey;
}
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);
}
}
module.exports = OpPlatformUtils;
const system = require("../../system");
const uuidv4 = require('uuid/v4');
const md5 = require("MD5");
class PushUtils {
constructor() {
this.logCtl = system.getObject("web.common.oplogCtl");
this.cacheManager = system.getObject("db.common.cacheManager");
this.merchantpushlogSve = system.getObject("service.merchant.merchantpushlogSve");
this.execClient = system.getObject("util.execClient");
this.merchantpushSve = system.getObject("service.merchant.merchantpushSve");
}
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
async getCachePushItemUrl(merchant_id) {
return await this.cacheManager["MerchantPushUrlCache"].cache(merchant_id, null, 3600);
}
/**
* 推送到第三方数据
* @param {*} reqUrl 请求推送的url
* @param {*} params 推送的参数
*/
async push(merchantId, field, params) {
try {
var pushConfig = await this.getCachePushItemUrl(merchantId) || {};
var reqUrl = pushConfig[field];
if(!reqUrl) {
this.logCtl.error({
optitle: "推送到第三方数据异常error",
op: "merchantId = " + merchantId + "; reqUrl is empty, field = " + field,
content: "reqUrl is empty",
clientIp: "pushUtils中没有ip"
});
return;
}
// 签名
params.sign = await this.createSign(params, merchantId);
params.requestid = this.getUUID();
var rtn = await this.execClient.execPost(params, reqUrl);
var returnValue = 0;
if (rtn.stdout) {
var result = JSON.parse(rtn.stdout);
if (result.code == "success") {
returnValue = 1;
}
}
//记录推送结果
this.merchantpushlogSve.create({
merchant_id: merchantId,//商户id
api: reqUrl,//接口地址
params: JSON.stringify(params),//推送数据信息
rs: rtn.stdout,//推送返回结果
success: returnValue//是否推送成功
});
} catch (e) {
console.log(e.stack);
this.logCtl.error({
optitle: "推送到第三方数据异常error",
op: reqUrl + ";params=" + JSON.stringify(params) + ";reqid=" + params.requestid,
content: e.stack,
clientIp: "pushUtils中没有ip"
});
}
}
/**
* 多次推送到第三方数据
* @param {*} reqUrl 请求推送的url
* @param {*} params 推送的参数
*/
async pushMany(reqUrl, params) {
try {
params.requestid = this.getUUID();
var rtn = this.execClient.execPost(params, reqUrl);
//TODO:可以做多次推送,规则待定
// var result = JSON.parse(rtn.stdout);
// if (result && result.code == 200) {
// var resultdata = result.data;
// return { code: 1, msg: "success" };
// } else {
// return { code: -1, msg: "err" };
// }
} catch (e) {
this.logCtl.error({
optitle: "多次推送到第三方数据异常error",
op: url + ";params=" + JSON.stringify(params) + ";reqid=" + params.requestid,
content: e.stack,
clientIp: pobj.clientIp
});
}
}
async createSign(params, appId) {
var appInfo = await this.cacheManager["ApiAppIdCheckCache"].cache(appId, null, 3000);
var signArr = [];
var keys = Object.keys(params).sort();
for (let k = 0; k < keys.length; k++) {
const tKey = keys[k];
if (tKey != "sign" && params[tKey]) {
signArr.push(tKey + "=" + params[tKey]);
}
}
var resultSignStr = signArr.join("&") + "&key=" + appInfo.appSecret;
return md5(resultSignStr).toUpperCase();
}
}
module.exports = PushUtils;
......@@ -15,21 +15,14 @@ var ENVINPUT = {
};
var settings = {
env: ENVINPUT.APP_ENV,
appKey: "201911051030",
appKey: "201912031344",
paasKey: "wx76a324c5d201d1a4",
secret: "aeea89de9e8049b09233ec146173de4a",
secret: "7cbb846246874167b5c7e01cd0016c88",
salt: "%iatpD1gcxz7iF#B",
cacheprefix: "sjb",
cacheprefix: "channelgateway",
usertimeout: 3600,//单位秒
basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 4005,
paasUrl: function () {
if (this.env == "dev") {
return "http://p.apps.com:4001/";
} else {
return "https://open.gongsibao.com/";
}
},
reqEsAddr: function () {
if (this.env == "dev") {
var localsettings = require("./localsettings");
......
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