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;
......
......@@ -4,18 +4,7 @@ var settings = require("../../../../config/settings");
class TmOrderAPI extends APIBase {
constructor() {
super();
this.opPlatformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.orderSve = system.getObject("service.dborder.orderSve");
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
this.customerinfoSve = system.getObject("service.dborder.customerinfoSve");
this.customercontactsSve = system.getObject("service.dborder.customercontactsSve");
this.trademarkSve = system.getObject("service.dbtrademark.trademarkSve");
this.zcApiUrl = settings.reqZcApi();
this.pushFqbossDataUrl = settings.pushFqbossDataUrl();
this.pushlogSve = system.getObject("service.common.pushlogSve");
this.toolSve = system.getObject("service.trademark.toolSve");
this.appProductSve = system.getObject("service.dbapp.appproductSve");
this.orderinfoSve = system.getObject("service.dbcorder.orderinfoSve");
this.utilsProductSve = system.getObject("service.utilsSve.utilsProductSve");
}
/**
* 接口跳转-POST请求
......@@ -30,223 +19,20 @@ class TmOrderAPI extends APIBase {
if (!pobj.actionType) {
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;
// }
var result = await this.opActionProcess(pobj, pobj.actionType, req);
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: 2,uAppId:18};
// action_body.user = { id: 6, app_id: 2, nickname: "测试用户",channelUserId:"testUserId01" };
async opActionProcess(pobj, action_type, req) {
var opResult = null;
if (["subTmOrder", "getTmOrderList", "getTmOrderInfo", "getTmApplyInfo", "getTmNclList", "getNeedInfo",
"tmConfirm", "updateTmInfo", "updateNclInfo", "updateContacts",
"updateCustomerInfo", "addOrderAndDelivery", "updateOrderPayStatus"].indexOf(action_type) >= 0) {
if (!action_body.channelUserId) {
return system.getResult(null, "verify channelUserId is empty");
}
}
switch (action_type) {
// sy
case "againPushFqBusiness"://再次推送商机
opResult = await this.orderSve.againPushFqBusiness(pobj, req);
break;
case "updateOrderStatus"://更新订单状态
opResult = await this.orderSve.updateOrderStatus(action_body, pobj, req);
break;
case "updateOrderPayStatus"://更新订单付款状态
opResult = await this.orderSve.updateOrderPayStatus(action_body, pobj, req);
if (opResult.status == 0) {
pobj.actionBody["deliveryOrderNo"] = opResult.data.deliveryOrderNo;
var url = this.pushFqbossDataUrl + "api/channelaccessApi/updateChannelPayStatus";
this.pushData2(opResult, req, pobj, url);
}
break;
case "addOrderAndDelivery"://创建订单和交付单
opResult = await this.orderSve.addOrderAndDelivery(action_body, pobj, req);
break;
case "clearAllCache":
await this.cacheManager["MagCache"].clearAll();
opResult = system.getResultSuccess(null, "清理缓存成功");
break;
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "getOrderList"://获取订单列表(分页)
opResult = await this.orderinfoSve.findAndCountAll(action_body, req);
break;
case "getOrderDetailByOrderNo"://获取订单详情
opResult = await this.orderinfoSve.getOrderDetailByOrderNo(action_body, req);
break;
case "decryptStr"://
opResult = await this.toolSve.decryptStr(req.app, action_body.opStr);
break;
case "op1688ChannelPushOrder"://处理渠道订单信息
opResult = await this.orderSve.op1688ChannelPushOrder(action_body, pobj, req);
if (opResult.status == 0) {
opResult.data = null;
var encryptResult = await this.toolSve.encryptStr(req.app, action_body.channelUserId);
if (encryptResult.status == 0 && encryptResult.data && encryptResult.data != "undefined") {
opResult.data = encryptResult.data;
}
}
break;
case "get1688ChannelOrderInfo"://获取渠道订单信息
opResult = await this.ordertmproductSve.get1688ChannelOrder(action_body);
break;
case "subTmOrder"://商标提报
opResult = await this.ordertmproductSve.addTmOrder(action_body, pobj, req);
if (opResult && opResult.status == 0 && opResult.data) {
var returnTms = opResult.data.tm;
for (var i = 0; i < pobj.actionBody.nclones.length; i++) {
var nclone = pobj.actionBody.nclones[i];
for (var j = 0; j < returnTms.length; j++) {
var returnTm = returnTms[j];
if (returnTm.nclOne && nclone.code && returnTm.nclOne == nclone.code) {
pobj.actionBody.nclones[i]["tbCode"] = returnTm.tbCode;
}
}
}
pobj.actionBody["deliveryOrderNo"] = opResult.data.deliveryOrderNo;
pobj.actionBody["itemCode"] = opResult.data.channelItemCode;
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/createChannelOrder"
this.pushData2(opResult, req, pobj, url);
}
break;
case "subExistTmOrder"://提交存在商标提报
opResult = await this.ordertmproductSve.addExistTmOrder(action_body);
if (opResult && opResult.status == 0 && opResult.data) {
var returnTms = opResult.data.tm;
for (var i = 0; i < pobj.actionBody.nclones.length; i++) {
var nclone = pobj.actionBody.nclones[i];
for (var j = 0; j < returnTms.length; j++) {
var returnTm = returnTms[j];
if (returnTm.nclOne && nclone.code && returnTm.nclOne == nclone.code) {
pobj.actionBody.nclones[i]["tbCode"] = returnTm.tbCode;
}
}
}
pobj.actionBody["deliveryOrderNo"] = opResult.data.deliveryOrderNo;
pobj.actionBody["itemCode"] = opResult.data.channelItemCode;
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/createChannelOrder"
this.pushData2(opResult, req, pobj, url);
}
break;
case "getTmOrderList"://商标交付列表
opResult = await this.ordertmproductSve.getTmOrderList(action_body, pobj, req);
break;
case "getOrderDetails"://
opResult = await this.ordertmproductSve.getOrderDetails(action_body, pobj, req);
break;
case "getTmOrderListAdmin"://商标交付列表
action_body.getListType = "getTmOrderListAdmin";
opResult = await this.ordertmproductSve.getTmOrderList(action_body, pobj, req);
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);
if (opResult && opResult.status == 0) {
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/updateChannelTmInfo"
this.pushData2(opResult, req, pobj, url);
}
break;
case "updateNclInfo"://修改商标订单-商标尼斯信息修改
opResult = await this.trademarkSve.updateNclInfo(action_body);
if (opResult && opResult.status == 0) {
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/updateChannelNclInfo"
this.pushData2(opResult, req, pobj, url);
}
break;
case "updateContacts"://修改商标订单-修改商标交付单联系人
opResult = await this.customercontactsSve.updateContacts(action_body);
if (opResult && opResult.status == 0) {
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/updateChannelContacts"
this.pushData2(opResult, req, pobj, url);
}
break;
case "updateCustomerInfo"://修改商标订单-修改申请人信息
opResult = await this.customerinfoSve.updateCustomerInfo(action_body);
if (opResult && opResult.status == 0) {
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/updateChannelCustomerInfo"
this.pushData2(opResult, req, pobj, url);
}
break;
case "updateOfficial"://修改商标订单-修改交官文件
opResult = await this.customerinfoSve.updateOfficial(action_body);
if (opResult && opResult.status == 0) {
// await this.pushData(opResult, req, pobj);
var url = this.pushFqbossDataUrl + "api/channelaccessApi/updateChannelOfficial"
this.pushData2(opResult, req, pobj, url);
}
break;
case "tmConfirm"://商标方案确认
opResult = await this.ordertmproductSve.tmConfirm(action_body);
if (opResult && opResult.status == 0) {
var url = this.pushFqbossDataUrl + "api/channelaccessApi/channelTmConfirm"
this.pushData2(opResult, req, pobj, url);
}
break;
case "pushFqBusiness"://推送商机到峰擎
opResult = await this.orderSve.push1688FqBusiness(action_body, pobj, req);
break;
case "getProductDetail"://根据渠道产品码获取产品详情
opResult = await this.appProductSve.findByChannelItemCode(action_body);
break;
case "getProductListByTypeOneCode"://获取产品列表(根据产品一类编码获取)
opResult = await this.appProductSve.findByProductOneTypeCode(action_body);
break;
case "getProductListByTypeCode"://获取产品列表(根据父类产品编码获取)
opResult = await this.appProductSve.findByProductTypeCode(action_body);
break;
case "getCAProductDetail"://根据渠道产品码获取产品详情 ---应用中心
// opResult = await this.appProductSve.findByChannelItemCode(action_body);
pobj["app"] = req.appInfo;
pobj["appInfo"] = req.appInfo;
opResult = await this.appProductSve.getProductDetailByCode(pobj);
opResult = await this.utilsProductSve.getProductDetailByCode(pobj, pobj.actionBody);
break;
case "getCAProductListByTypeOneCode"://获取产品列表(根据产品一类编码获取) ---应用中心
// opResult = await this.appProductSve.findByProductOneTypeCode(action_body);
pobj["app"] = req.appInfo;
pobj["appInfo"] = req.appInfo;
opResult = await this.appProductSve.findByTypeOneCode(pobj);
opResult = await this.utilsProductSve.findByTypeOneCode(pobj, pobj.actionBody);
break;
case "getCAProductListByTypeCode"://获取产品列表(根据父类产品编码获取) ---应用中心
// opResult = await this.appProductSve.findByProductTypeCode(action_body);
pobj["app"] = req.appInfo;
pobj["appInfo"] = req.appInfo;
opResult = await this.appProductSve.findByTypeCode(pobj);
break;
case "subGsbOrderInfo"://提交公司宝订单信息
opResult = await this.orderSve.gsbOrderInfo(pobj, req);
opResult = await this.utilsProductSve.findByTypeCode(pobj, pobj.actionBody);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
......@@ -254,88 +40,6 @@ class TmOrderAPI extends APIBase {
}
return opResult;
}
//数据推送
async pushData(opResult, req, pobj) {
var url = this.zcApiUrl + "action/tmOrder/springBoard";
var rc = system.getObject("util.execClient");
var rtn = null;
var requestId = opResult.requestId || req.requestId;
if (requestId) {
rtn = await rc.execPushDataPost(pobj, url, req.headers["token"], req.headers["request-id"]);
} else {
rtn = await rc.execPost(pobj, url);
}
var returnType = "0";
if (rtn && rtn.code == 1) {
returnType = "1";
}
this.pushlogSve.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: opResult.requestId || req.requestId,
op: url,
content: JSON.stringify(pobj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
returnType: returnType,
agent: req.uagent,
opTitle: "数据推送",
});
}
//数据推送fqboss
async pushData2(opResult, req, pobj, url) {
var rc = system.getObject("util.execClient");
var obj = pobj.actionBody;
var user = obj.user;
if (obj.app) {
obj.app = null;
}
obj["channelUserId"] = obj.channelUserId;
obj["channelCode"] = pobj.actionProcess;
obj["appid"] = "2e787bbaacda4c6488b9fae58fff30ba";
var rtn = null;
try {
var requestId = opResult.requestId || req.requestId;
if (requestId) {
rtn = await rc.execPushDataPost(obj, url, req.headers["token"], req.headers["request-id"]);
} else {
rtn = await rc.execPost(obj, url);
}
var returnType = "0";
if (rtn.stdout) {
var j = JSON.parse(rtn.stdout);
if (j && j.code == 1) {
returnType = "1";
}
}
this.pushlogSve.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: opResult.requestId || req.requestId,
op: url,
content: JSON.stringify(obj),
resultInfo: JSON.stringify(rtn),
clientIp: req.clientIp,
returnType: returnType,
agent: req.uagent,
opTitle: "数据推送",
});
} catch (e) {
this.pushlogSve.createDb({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: opResult.requestId || req.requestId,
op: url,
content: JSON.stringify(obj),
resultInfo: JSON.stringify(e.stack),
clientIp: req.clientIp,
returnType: '0',
agent: req.uagent,
opTitle: "数据推送",
});
}
}
}
module.exports = TmOrderAPI;
\ No newline at end of file
......@@ -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 OrderDao extends Dao {
constructor() {
super(Dao.getModelName(OrderDao));
}
/**
* 创建订单
* @param {*} ordercode
* @param {*} orderType
* @param {*} user
* @param {*} app
* @param {*} productItem
* @param {*} channelOrder
* @param {*} channelUser
* @param {*} apply 订单联系人信息
* @param {*} orderAmount 订单金额信息
* @param {*} t
*/
async addOrder(ordercode, orderType, user, app, productItem, channelOrder, channelUser, apply, orderAmount, t) {
var sqlWhere = { channelServiceNo: channelOrder.channelServiceNo, app_id: user.app_id };
var order = await this.findOne(sqlWhere, t);
if (order) {
var salesDiliverNum = Number(order.salesNum) - Number(order.salesDiliverNum) - orderAmount.salesNum;
if (salesDiliverNum < 0) {
return system.getResult(null, "服务单交付数量有误,数量为:" + order.salesNum + ",已交付数量为:" + order.salesDiliverNum);
}
var minitermDiliverNum = Number(order.minitermNum) - Number(order.minitermDiliverNum) - orderAmount.minitermNum;
if (minitermDiliverNum < 0) {
return system.getResult(null, "服务单交付小项数量有误,小项数量为:" + order.minitermNum + ",已交付小项数量为:" + order.minitermDiliverNum);
}
order.salesDiliverNum = Number(order.salesDiliverNum || "0") + orderAmount.salesNum;
order.minitermDiliverNum = Number(order.minitermDiliverNum || "0") + orderAmount.minitermNum;
var sWhere = { where: sqlWhere };
await this.updateByWhere({ salesDiliverNum: order.salesDiliverNum, minitermDiliverNum: order.minitermDiliverNum }, sWhere, t);
return system.getResultSuccess(order);
}
var myDate = new Date();
if (app.appPayType == "00") {
channelOrder.payStatus = channelOrder.payStatus || "yfk";
channelOrder.payTime = channelOrder.payTime || myDate.toLocaleString();//myDate.toLocaleString()获取日期与时间==="2018-11-5 17:40:21"
}
var orderObj = {
app_id: user.app_id,//
orderNo: ordercode,// 订单号
channelServiceNo: channelOrder.channelServiceNo || "",// 渠道服务单号
channelOrderNo: channelOrder.channelOrderNo || "",//渠道订单号列表,多个以,隔开
payTime: channelOrder.payTime || null,
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
channelItemCode: productItem.channelItemCode,// 渠道产品编码
channelItemName: productItem.channelItemName,// 渠道产品名称
salesNum: channelOrder.quantity || 1,//项目订单数量(即服务项目的倍数,默认值为1)
salesDiliverNum: channelOrder.salesDiliverNum || 0,//项目订单交付数量(即与项目订单数量相对应)
minitermNum: channelOrder.nclCount || 10 * channelOrder.quantity,//订单小项数量
minitermDiliverNum: channelOrder.minitermDiliverNum || 0,//订单小项交付数量
orderType: orderType || "dkxd",// 订单类型,zzdd: 自主订单,dkxd: 代客下单
orderPayStatus: channelOrder.payStatus || "dfk",// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalServiceCharge: orderAmount.totalServiceCharge || 0,// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense: orderAmount.totalPublicExpense || 0,// 官费总额(产品配置的官费*订单件数)
totalDiscounts: orderAmount.totalDiscounts,// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
totalTaxes: orderAmount.totalTaxes || 0,// 税费总额(订单总额-(订单总额/(1+产品费率)))
totalSum: orderAmount.totalSum || 0,// 订单总额(产品价格×优惠费率×订单件数)
refundSum: 0,// 退款金额
totalProfitSum: orderAmount.totalProfitSum,// 订单毛利润总额(订单总额-官费总额)
pfProfitSum: orderAmount.pfProfitSum,// 订单平台毛利润总额(订单毛利润总额-订单渠道分成毛利润总额)
channelProfitSum: orderAmount.channelProfitSum || 0,// 订单渠道分成毛利润总额((订单总额-官费总额)*渠道利润分成比率)
pfSettleProfit: 0,// 平台结算渠道利润,0否,1是
notes: apply.notes, //备注
appPayType: app.appPayType,// 支付类型:00第三方支付,10平台代收款
createuser_id: user.id,
owner_id: user.id,//
creator: user.nickname,
owner: user.nickname,//
ownerMoblie: user.userMoblie,//
invoiceApplyStatus: "00",// 发票状态:00: 未申请, 10: 已申请,20:已开票
channelUserId: channelUser.channelUserId,// 渠道用户id
needNo: channelOrder.needNo || null,//需求单号
picUrl: productItem.picUrl,//
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
serviceItemSnapshot: JSON.stringify(productItem),//产品快照
};
var order = await this.create(orderObj, t);
var tmpResult = system.getResultSuccess(order);
tmpResult.addOrder = true;
return tmpResult;
}
async putOrder(setObj, whereObj, t) {
return this.updateByWhere(setObj, whereObj, t)
}
async getItemByChannelServiceNo(channelServiceNo, appId) {//通过订单号查询订单
return this.model.findOne({
where: {
channelServiceNo: channelServiceNo,
app_id: appId
},
attributes: ["id",
"orderNo",
"channelUserId",
"channelServiceNo",
"channelOrderNo",
"needNo",
"invoiceApplyStatus",
"orderType",
"salesNum",
"salesDiliverNum",
"minitermNum",
"minitermDiliverNum",
"orderPayStatus",
"notes",
"totalServiceCharge",
"totalPublicExpense",
"totalTaxes",
"totalSum",
"appPayType",
"payTime",
"itemCode",
"itemName",
"buyerMoblie"
],
raw: true
});
}
}
module.exports = OrderDao;
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 settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
module.exports = (db, DataTypes) => {
return db.define("trademark", {
tbCode :DataTypes.STRING(50), //提报号(自动生成)
nclOneCodes :DataTypes.STRING(10), //尼斯大类
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, //
deliveryOrderNo :DataTypes.STRING(64), //交付订单号
bizNo :DataTypes.STRING(64), //业务单号,用于对接第三方业务单号
app_id :DataTypes.INTEGER, //
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), //
opNotes :DataTypes.STRING(500), //
subErrorMsg :DataTypes.STRING(4000), // 提报错误信息
payPublicExpense :DataTypes.INTEGER, // 支付官费,0否,1是
nclCount :DataTypes.INTEGER, // 尼斯数量
nclPublicExpense :DataTypes.DECIMAL(12, 2), // 尼斯官费总额
}, {
paranoid: true,//假的删除
underscored: true,
version: true,
freezeTableName: true,
timestamps: true,
updatedAt: false,
//freezeTableName: true,
// define the table's name
tableName: 'b_trademark',
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 OrderService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(OrderService));
this.logCtl = system.getObject("service.common.oplogSve");
this.orderflowDao = system.getObject("db.dborder.orderflowDao");
this.appproductDao = system.getObject("db.dbapp.appproductDao");
this.ordertmproductDao = system.getObject("db.dborder.ordertmproductDao");
this.receiptvoucherDao = system.getObject("db.dborder.receiptvoucherDao");
this.customercontactsDao = system.getObject("db.dborder.customercontactsDao");
this.execClient = system.getObject("util.execClient");
this.fqReqUrl = "https://yunfuapi.gongsibao.com";//线上域名
// this.fqReqUrl = "https://yunfuapi-dev.gongsibao.com";//dev域名
}
async addOrderAndDelivery(action_body, pobj, req) {
if (!action_body.needNo) {
return system.getResult(null, "needNo is empty");
}
if (!action_body.channelItemCode) {
return system.getResult(null, "channelItemCode is empty");
}
var productItem = await this.appproductDao.findOneByChannelItemCode(action_body.channelItemCode, req.app.id);//获取产品
if (!productItem) {
return system.getResult(null, action_body.channelItemCode + " productItem is empty");;
}
var orderCount = await this.dao.findCount({ where: { needNo: action_body.needNo } });
if (orderCount > 0) {
return system.getResultFail(system.existData, "order is exist");
}
var self = this;
return await self.db.transaction(async function (t) {
//创建订单
var ordercode = await self.getBusUid("tm");
var orderParams = {
app_id: req.app.id,//
orderNo: ordercode,// 订单号
payTime: new Date(),//
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
channelItemCode: productItem.channelItemCode,// 渠道产品编码
channelItemName: productItem.channelItemName,// 渠道产品名称
salesNum: 1,//项目订单数量(即服务项目的倍数,默认值为1)
salesDiliverNum: 0,//项目订单交付数量(即与项目订单数量相对应)
minitermNum: 10,//订单小项数量
minitermDiliverNum: 0,//订单小项交付数量
orderType: "dkxd",// 订单类型,zzdd: 自主订单,dkxd: 代客下单
orderPayStatus: "yfk",// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalServiceCharge: productItem.totalServiceCharge || 0,// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense: productItem.totalPublicExpense || 0,// 官费总额(产品配置的官费*订单件数)
totalSum: productItem.proPrice || 0,// 订单总额(产品价格×优惠费率×订单件数)
refundSum: 0,// 退款金额
buyerMoblie: action_body.buyerMoblie || "",
// notes: apply.notes, //备注
appPayType: "00",// 支付类型:00第三方支付,10平台代收款
payAccountType: "other",// 帐户类型( 支付类型):cash: 现金, bank: 银行,wx:微信,alipay:支付,other:其它
createuser_id: req.user.id,
owner_id: req.user.id,//
creator: req.user.nickname || "",
owner: req.user.nickname || "",//
ownerMoblie: req.user.userMoblie || "",//
invoiceApplyStatus: "00",// 发票状态:00: 未申请, 10: 已申请,20:已开票
channelUserId: req.user.channelUserId || "",// 渠道用户id
needNo: action_body.needNo || null,//需求单号
needNoOrderNo: action_body.needNoOrderNo || null,//需求单号
picUrl: productItem.picUrl,//
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
serviceItemSnapshot: JSON.stringify(productItem),//产品快照
};
var orderItem = await self.dao.create(orderParams, t);//创建订单
var receiptvoucherItem = await self.receiptvoucherDao.addReceiptvoucher(orderParams, req, t);//创建订单支付信息
var pushType = "ic_";
var orderProductObj = {};
if (["fzsbzc", "dbsbzc"].indexOf(productItem.itemCode) >= 0) {
var tmDeliveryOrderNo = await self.getBusUid("jf")
orderProductObj = {
app_id: req.app.id,//
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
orderServicePayStatus: "yfk",//支付状态:dfk: 待付款, yfk: 已支付
deliveryStatus: "dfwsfw",
deliveryStatusName: "待服务",
appDataOpType: req.app.appDataOpType,// 应用数据操作类型:00独立,10全委托,20部分委托
sourceOrderNo: ordercode,//来源单号
deliveryOrderNo: tmDeliveryOrderNo,
needNo: action_body.needNo || null,//需求单号
needNoOrderNo: action_body.needNoOrderNo || null,//需求单号
sourceType: "00",
channelUserId: req.user.channelUserId || "",// 渠道用户id
createuser_id: req.user.id,//
createuser: req.user.nickname,//
};
var orderTm = await self.ordertmproductDao.create(orderProductObj, t);//创建订单交付流程
pushType = "tm_";
}//创建服务单
//推送商机到峰擎
if (productItem.pushServiceItemCode && orderParams.buyerMoblie) {
self.pushFqBusiness(pushType, orderParams, productItem.pushServiceItemCode, pobj, req);
} else {
self.logCtl.info({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/service/impl/dborder/orderSve/addOrderAndDelivery",
content: "pushServiceItemCode=" + productItem.pushServiceItemCode + ",buyerMoblie=" + action_body.buyerMoblie,
clientIp: pobj.clientIp,
optitle: "未能推送订单商机到FQ信息,pushServiceItemCode 或 buyerMoblie 为空",
});
}
return system.getResultSuccess({
orderNo: ordercode,
deliveryOrderNo: orderProductObj.deliveryOrderNo || ordercode,
needNo: action_body.needNo
});
});
}
//关联订单对应的需求ID和需求订单号--渠道web用
async updateOrderStatus(action_body, pobj, req) {
// var setObj = { channelServiceNo: action_body.channelServiceNo, needNo: action_body.needNo, needNoOrderNo: action_body.needNoOrderNo };
var setObj = { needNo: action_body.needNo, needNoOrderNo: action_body.needNoOrderNo };
var self = this;
return await this.db.transaction(async function (t) {
await self.dao.updateByWhere(setObj, { where: { orderNo: action_body.orderNo } }, t);
await self.ordertmproductDao.updateByWhere(setObj, { where: { sourceOrderNo: action_body.orderNo } }, t);
return system.getResultSuccess();
});
}
//更新付款状态--渠道web用
async updateOrderPayStatus(action_body, pobj, req) {
var payStatus = action_body.payStatus || "dfk";
var self = this;
var result = await self.ordertmproductDao.getItemByNeedNoOrderNo(action_body.needNoOrderNo, req.app.id);
if (!result) {
return system.getResult(null, "data is empty");
}
return await this.db.transaction(async function (t) {
await self.dao.updateByWhere({ orderPayStatus: payStatus, buyerMoblie: action_body.buyerMoblie || "" }, { where: { needNoOrderNo: action_body.needNoOrderNo, app_id: req.app.id } }, t);
await self.ordertmproductDao.updateByWhere({ payStatus: payStatus }, { where: { needNoOrderNo: action_body.needNoOrderNo, app_id: req.app.id } }, t);
var logMsg = { sourceOrderNo: result.deliveryOrderNo, opContent: "订单已成功支付", app_id: req.app.id, isShow: 1 };
await self.orderflowDao.create(logMsg, t);
return system.getResultSuccess({ deliveryOrderNo: result.deliveryOrderNo });
});
}
async op1688ChannelPushOrder(action_body, pobj, req) {
try {
//var reqUrl = "https://inte-mcp.chanjet.com/gsb/getOrder?token=" + action_body.token; //测试环境
var reqUrl = "https://mcp.chanjet.com/gsb/getOrder?token=" + action_body.token; //线上环境
var rtn = await this.execClient.execGet("", reqUrl);
var logParam = {
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/service/impl/dborder/orderSve/opChannelCallbackData",
content: "请求地址:" + reqUrl,
clientIp: pobj.clientIp,
optitle: "渠道回调信息返回结果:" + rtn.stdout,
};
this.logCtl.info(logParam);
var result = JSON.parse(rtn.stdout);
// var result = { "returnValue": [{ "bizStatusExt": "audit_pass", "memberId": "b2b-1624961198", "productName": "【商标注册】自助注册申请", "gmtCreate": "20191119162048000+0800", "gmtServiceEnd": null, "bizStatus": "B", "paymentAmount": 0.0, "executePrice": 0, "orderItemNum": "W19111938409910_1", "gmtServiceBegin": null, "gmtConfirm": "20191119162051000+0800", "settleItemDtos": [], "payCustomerUid": "1875826463", "signCustomerUid": "1875826463" }, { "bizStatusExt": "audit_pass", "memberId": "b2b-1624961198", "productName": "【商标注册】自助注册申请", "gmtCreate": "20191119161008000+0800", "gmtServiceEnd": null, "bizStatus": "B", "paymentAmount": 0.0, "executePrice": 0, "orderItemNum": "W19111938409527_1", "gmtServiceBegin": null, "gmtConfirm": "20191119161011000+0800", "settleItemDtos": [], "payCustomerUid": "1875826463", "signCustomerUid": "1875826463" }, { "bizStatusExt": "audit_pass", "memberId": "b2b-1624961198", "productName": "【商标注册】自助注册申请", "gmtCreate": "20191119130813000+0800", "gmtServiceEnd": null, "bizStatus": "B", "paymentAmount": 0.0, "executePrice": 0, "orderItemNum": "W19111938403044_1", "gmtServiceBegin": null, "gmtConfirm": "20191119130816000+0800", "settleItemDtos": [], "payCustomerUid": "1875826463", "signCustomerUid": "1875826463" }, { "bizStatusExt": "audit_pass", "memberId": "b2b-1624961198", "productName": "【商标注册】自助注册申请", "gmtCreate": "20191119125011000+0800", "gmtServiceEnd": null, "bizStatus": "B", "paymentAmount": 0.0, "executePrice": 0, "orderItemNum": "W19111938402638_1", "gmtServiceBegin": null, "gmtConfirm": "20191119125017000+0800", "settleItemDtos": [], "payCustomerUid": "1875826463", "signCustomerUid": "1875826463" }, { "bizStatusExt": "audit_pass", "memberId": "b2b-1624961198", "productName": "【商标注册】自助注册申请", "gmtCreate": "20191119110329000+0800", "gmtServiceEnd": null, "bizStatus": "B", "paymentAmount": 0.0, "executePrice": 0, "orderItemNum": "W19111938399256_1", "gmtServiceBegin": null, "gmtConfirm": "20191119110332000+0800", "settleItemDtos": [], "payCustomerUid": "1875826463", "signCustomerUid": "1875826463" }, { "bizStatusExt": "audit_pass", "memberId": "b2b-1624961198", "productName": "【商标注册】自助注册申请", "gmtCreate": "20191119104737000+0800", "gmtServiceEnd": null, "bizStatus": "B", "paymentAmount": 0.0, "executePrice": 0, "orderItemNum": "W19111938398567_1", "gmtServiceBegin": null, "gmtConfirm": "20191119104740000+0800", "settleItemDtos": [], "payCustomerUid": "1875826463", "signCustomerUid": "1875826463" }, { "bizStatusExt": "audit_pass", "memberId": "b2b-1624961198", "productName": "【商标注册】自助注册申请", "gmtCreate": "20191118191753000+0800", "gmtServiceEnd": null, "bizStatus": "B", "paymentAmount": 0.0, "executePrice": 0, "orderItemNum": "W19111838384729_1", "gmtServiceBegin": null, "gmtConfirm": "20191118191755000+0800", "settleItemDtos": [], "payCustomerUid": "1875826463", "signCustomerUid": "1875826463" }], "successed": true, "errorMsg": null };
if (result && result.successed && result.successed == true && result.returnValue && result.returnValue.length) {
await this.addOrderNeed(action_body, req, result.returnValue);
}//操作需求
return system.getResultSuccess();
} catch (e) {
console.log(e.stack, "渠道回调信息返回结果:error......1.....");
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/service/impl/dborder/orderSve/opChannelCallbackData",
content: "error:" + e.stack,
clientIp: pobj.clientIp,
optitle: "渠道回调信息返回结果:" + rtn.stdout,
});
}
}
async op1688ChannelPushOrderTest(action_body, pobj, req) {
try {
var returnValue = [
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_01",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_02",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_03",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_04",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_05",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_06",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_07",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_08",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_09",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_10",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_11",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_12",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_13",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_14",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_15",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_16",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_17",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_18",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_19",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
},
{
"bizStatusExt": "service",
"memberId": "b2b-****02",
"productName": "商机**",
"gmtCreate": "20171231200252000+0800",
"gmtServiceEnd": "20190101000000000+0800",
"bizStatus": "S",
"paymentAmount": 420,
"executePrice": 420,
"orderItemNum": "eeeee3120025200_20",
"gmtServiceBegin": "20171231000000000+0800",
"gmtConfirm": "20171231200329000+0800",
"settleItemDtos": [],
"payCustomerUid": "12345678990000",
"signCustomerUid": "12345678990000"
}
];
await this.addOrderNeed(action_body, req, returnValue);
return system.getResultSuccess();
} catch (e) {
console.log(e.stack, "渠道回调信息返回结果:error...........");
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "/igirl-channel/zhichan/igirl-channel/app/base/service/impl/dborder/orderSve/opChannelCallbackData",
content: "请求地址:" + reqUrl + ",error:" + e.stack,
clientIp: pobj.clientIp,
optitle: "渠道回调信息返回结果:" + rtn.stdout,
});
}
}
async addOrderNeed(action_body, req, returnValue) {
var productItem = await this.appproductDao.findOneByChannelItemCode(action_body.channelItemCode, req.app.id);//获取产品
if (!productItem) {
return;
}
var self = this;
//创建订单
var ordercode = await this.getBusUid("ts");
for (let index = 0; index < returnValue.length; index++) {
const element = returnValue[index];
if (element) {
if (element.bizStatusExt == "service" || element.bizStatusExt == "audit_pass") {
var orderCount = await self.findCount({ where: { needNo: element.orderItemNum } });
if (orderCount > 0) {
continue;
}
var payTime = null;
if (element.gmtCreate && element.gmtCreate.length > 14) {
payTime = element.gmtCreate.substr(0, 4) + "-" + element.gmtCreate.substr(4, 2) +
"-" + element.gmtCreate.substr(6, 2) + " " + element.gmtCreate.substr(8, 2) + ":" +
element.gmtCreate.substr(10, 2) + ":" + element.gmtCreate.substr(12, 2);
}
await self.db.transaction(async function (t) {
//创建订单
var ordercode = await self.getBusUid("tm");
var orderParams = {
app_id: req.app.id,//
orderNo: ordercode,// 订单号
channelServiceNo: element.orderItemNum,// 渠道服务单号
payTime: payTime,//
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
channelItemCode: productItem.channelItemCode,// 渠道产品编码
channelItemName: productItem.channelItemName,// 渠道产品名称
salesNum: 1,//项目订单数量(即服务项目的倍数,默认值为1)
salesDiliverNum: 0,//项目订单交付数量(即与项目订单数量相对应)
minitermNum: 10,//订单小项数量
minitermDiliverNum: 0,//订单小项交付数量
orderType: "dkxd",// 订单类型,zzdd: 自主订单,dkxd: 代客下单
orderPayStatus: "yfk",// 订单付款状态dfk: 待付款, zfpz: 已上传支付凭证, yfk: 已付款, ddqx: 订单取消, tkclz: 退款处理中, bfytk: 部分已退款, ytk: 已退款,zfshbtg:支付审核不通过
totalServiceCharge: productItem.totalServiceCharge || 0,// 服务费总额(产品配置的服务费*订单件数)
totalPublicExpense: productItem.totalPublicExpense || 0,// 官费总额(产品配置的官费*订单件数)
totalSum: element.executePrice || 0,// 订单总额(产品价格×优惠费率×订单件数)
refundSum: 0,// 退款金额
// notes: apply.notes, //备注
appPayType: "00",// 支付类型:00第三方支付,10平台代收款
payAccountType: "other",// 帐户类型( 支付类型):cash: 现金, bank: 银行,wx:微信,alipay:支付,other:其它
createuser_id: req.user.id,
owner_id: req.user.id,//
creator: req.user.nickname || "",
owner: req.user.nickname || "",//
ownerMoblie: req.user.userMoblie || "",//
invoiceApplyStatus: "00",// 发票状态:00: 未申请, 10: 已申请,20:已开票
channelUserId: req.user.channelUserId || "",// 渠道用户id
needNo: element.orderItemNum || null,//需求单号
picUrl: productItem.picUrl,//
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
serviceItemSnapshot: JSON.stringify(productItem),//产品快照
};
var orderItem = await self.dao.create(orderParams, t);//创建订单
var receiptvoucherItem = await self.receiptvoucherDao.addReceiptvoucher(orderParams, req, t);//创建订单支付信息
var orderProductObj = {
app_id: req.app.id,//
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
payStatus: "yfk",//支付状态:dfk: 待付款, yfk: 已支付
appDataOpType: req.app.appDataOpType,// 应用数据操作类型:00独立,10全委托,20部分委托
sourceOrderNo: ordercode,//来源单号
deliveryOrderNo: await self.getBusUid("jf"),
channelServiceNo: element.orderItemNum || null,// 渠道服务单号
needNo: element.orderItemNum || null,//需求单号
sourceType: "00",
channelUserId: req.user.channelUserId || "",// 渠道用户id
createuser_id: req.user.id,//
createuser: req.user.nickname,//
};
//创建服务单
var orderTm = await self.ordertmproductDao.create(orderProductObj, t);//创建订单交付流程
});
}
}
}
}
async push1688FqBusiness(action_body, pobj, req) {
var item = await this.dao.getItemByChannelServiceNo(action_body.channelServiceNo, req.app.id);
if (!item) {
return system.getResult(null, "没有找到相关订单信息");
}
if (item.itemCode != "fzsbzc") {
return system.getResult(null, "订单类型有误,请推送商标注册-专家辅助申请的订单");
}
if (item.buyerMoblie) {
return system.getResult(null, "订单已经推送过,请勿重覆推送");
}
item.buyerMoblie = action_body.buyerMoblie;
var result = await this.pushFqBusiness("tm_", item, "5dd513db4f3b08000a6fc082", pobj, req);
if (result.status != 0) {
return result;
}
await this.updateByWhere({ buyerMoblie: action_body.buyerMoblie }, { where: { channelServiceNo: action_body.channelServiceNo } });
return result;
}
/**
*
* @param {*} pushType 推送的类型 tm_ ic_ icp_
* @param {*} item 订单信息 包含buyerMoblie
* @param {*} pushServiceItemCode 推送的产品id
* @param {*} pobj
* @param {*} req
*/
async pushFqBusiness(pushType, item, pushServiceItemCode, pobj, req) {//推送商机
var rc = system.getObject("util.aliyunClient");
var rtn = null;
var reqUrl = this.fqReqUrl + "/crm/order/submit";
try {
var body = {
idempotentId: item.needNo,// 是 业务 ID
idempotentSource: req.app.appSourceCode ? pushType + req.app.appSourceCode : "tm_1688",// 是 业务来源(ali、jd)
idempotentSourceName: req.app.name || "1688应用",// 是 阿里,京东
city: "",// 否 所属城市
phone: item.buyerMoblie,// 是 手机号
userId: item.channelUserId,// 否 用户 ID
companyName: "",// 否 公司名称
orderPrice: item.totalSum,// 是 订单金额
productId: pushServiceItemCode,// 是 产品 ID
productQuantity: item.salesNum,// 是 产品数量
};
rtn = await rc.post(reqUrl, body);
this.logCtl.info({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "igirl-channel/app/base/service/impl/dborder/orderSve/pushFqBusiness",
content: "请求地址:" + reqUrl + ",参数:" + JSON.stringify(body) + ",返回结果:" + JSON.stringify(rtn),
clientIp: pobj.clientIp,
optitle: "推送订单商机到FQ信息",
});
if (rtn.code != 200 && rtn.success != true) {
return system.getResult(null, "推送失败,失败原因:" + rtn.errorMsg + ",selfrequestId=" + req.requestId + ",requestId=" + rtn.requestId);
}
return system.getResultSuccess(null, "推送成功");
} catch (e) {
//日志记录
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "igirl-channel/app/base/service/impl/dborder/orderSve/pushFqBusiness",
content: "error:" + e.stack,
clientIp: pobj.clientIp,
optitle: "推送订单商机到FQ出错",
});
}
}
async againPushFqBusiness(pobj, req) {//再次推送商机
var rc = system.getObject("util.aliyunClient");
var rtn = null;
var reqUrl = this.fqReqUrl + "/crm/order/submit";
var body = pobj.actionBody;
try {
rtn = await rc.post(reqUrl, body);
this.logCtl.info({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "igirl-channel/app/base/service/impl/dborder/orderSve/againPushFqBusiness",
content: "请求地址:" + reqUrl + ",参数:" + JSON.stringify(body) + ",返回结果:" + JSON.stringify(rtn),
clientIp: pobj.clientIp,
optitle: "推送订单商机到FQ信息--again",
});
if (rtn.code != 200 && rtn.success != true) {
return system.getResult(null, "推送失败,失败原因:" + rtn.errorMsg + ",selfrequestId=" + req.requestId + ",requestId=" + rtn.requestId);
}
return system.getResultSuccess(null, "推送成功");
} catch (e) {
//日志记录
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "igirl-channel/app/base/service/impl/dborder/orderSve/againPushFqBusiness",
content: "error:" + e.stack,
clientIp: pobj.clientIp,
optitle: "推送订单商机到FQ出错--again",
});
}
}
async gsbOrderInfo(pobj, req) {//公司宝官网订单
var rc = system.getObject("util.aliyunClient");
var rtn = null;
var reqUrl = this.fqReqUrl + "/dsc/order/add";
var body = pobj.actionBody.order_param || "";
if (!body) {
return system.getResult(null, "order_param is empty");
}
try {
rtn = await rc.post(reqUrl, body);
this.logCtl.info({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "igirl-channel/app/base/service/impl/dborder/orderSve/gsbOrderInfo",
content: "请求地址:" + reqUrl + ",参数:" + JSON.stringify(body) + ",返回结果:" + JSON.stringify(rtn),
clientIp: pobj.clientIp,
optitle: "公司宝官网订单--gsbOrderInfo",
});
if (rtn.code != 200 && rtn.success != true) {
return system.getResult(null, "公司宝官网订单失败,失败原因:" + rtn.errorMsg + ",selfrequestId=" + req.requestId + ",requestId=" + rtn.requestId);
}
return system.getResultSuccess(rtn.data, "订单下单成功");
} catch (e) {
//日志记录
this.logCtl.error({
appid: req.app.id,
appkey: req.app.uappKey,
requestId: req.requestId || "",
op: "igirl-channel/app/base/service/impl/dborder/orderSve/againPushFqBusiness",
content: "error:" + e.stack,
clientIp: pobj.clientIp,
optitle: "公司宝官网订单出错--gsbOrderInfo",
});
}
}
}
module.exports = OrderService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class OrderFlowService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(OrderFlowService));
}
}
module.exports=OrderFlowService;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class OrderTmProductService extends ServiceBase {
constructor() {
super("dborder", ServiceBase.getDaoName(OrderTmProductService));
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 = system.getObject("db.dborder.receiptvoucherDao");
this.tmofficialDao = system.getObject("db.dbtrademark.tmofficialDao");
this.userDao = system.getObject("db.dbapp.appuserDao");
this.appDao = system.getObject("db.dbapp.appDao");
}
//------------------------------------------创建订单-------------------开始-------------------------
async addExistTmOrder(params) {//创建商标订单信息
var self = this;
var itemCode = params.itemCode;//产品编码
var tm = params.tm;//增加sourceType || "00";//来源类型:00订单,10需求,20服务商
var apply = params.apply;
var app = params.app;
var user = params.user;
var nclones = params.nclones || null;
var channelUser = params.channelUser || null;
var channelOrder = params.channelOrder || null;
var orderType = params.orderType || "dkxd";//订单类型,zzdd: 自主订单,dkxd: 代客下单
if (!nclones || nclones.length < 1) {
return system.getResult(null, "尼斯大类不能为空");
}
if (nclones.length > 1) {
return system.getResult(null, "尼斯大类不能大于1个大类");
}
//判断尼斯小项的数量
var selectNclThreeCount = 0;
for (let index = 0; index < nclones.length; index++) {
const element = nclones[index];
var nclList = null;
if (typeof (element) == "string") {
nclList = JSON.parse(element);
} else {
nclList = element;
}
selectNclThreeCount = selectNclThreeCount + nclList.nclThree.length;
}
if (selectNclThreeCount > 10) {
return system.getResult(null, "尼斯小项数量不能大于10个小项数量,目前选择的小项数量为" + selectNclThreeCount);
}
if (!itemCode) {
return system.getResult(null, "itemCode参数错误");
}
var productItem = await this.appproductDao.findOneByCode(itemCode, user.app_id);//通过ChannelItemCode获取产品
if (!productItem) {
return system.getResult(null, "未知的产品");
}
if (productItem.status != 1) {
return system.getResult(null, "产品已禁用");
}
var verifyResult = await self.isOrderVerify(user, 1, tm, productItem, nclones, null);
if (verifyResult) {
return verifyResult;
}
// if (productItem && productItem.verifyPrice == 1) {
// var verifyResult = await self.isOrderVerify(user, 1, tm, productItem, nclones, null);
// if (verifyResult) {
// return verifyResult;
// }
// } else {
// tm.nclOneCodes = [];
// tm.nclCount = 0;
// for (var i = 0; i < nclones.length; i++) {
// var tbcode = await self.getBusUid("tb");
// var nclone = nclones[i];
// var nclthreeobj = nclone.nclThree;
// if (nclone) {
// tm.nclOneCodes.push(nclone.code);
// tm.nclCount = tm.nclCount + nclthreeobj.length;
// }
// }
// }
if (tm.tmFormType == "4") {//图形商标
tm["name"] = "图形";
}
return await self.db.transaction(async function (t) {
var orderTm = await self.dao.getItemByChannelServiceNo(channelOrder.channelServiceNo, app.id, t);
if (!orderTm) {
return system.getResult(null, "交付单数据不存在");
}
var orderAmount = tm;
orderAmount.salesNum = tm.nclOneCodes.length;
orderAmount.minitermNum = tm.nclCount;
var orderResult = await self.orderDao.addOrder(orderTm.sourceOrderNo, orderType, user, app, productItem, channelOrder, channelUser, apply, orderAmount, t);
if (orderResult.status != 0) {
return orderResult;
}
var order = orderResult.data;
var orderProductObj = {
tmName: tm.tmName,//商标名称
tmType: "p",//"p": "普通商标", "j": "集体商标", "z": "证明商标", "t": "特殊商标"
tmFormType: tm.tmFormType,//商标类型形式:"1": "立体", "3": "字", "4": "图", "5": "字图", "6": "颜色", "7": "彩色"
nclOneCodes: tm.nclOneCodes ? tm.nclOneCodes.join(",") : null,//尼斯大类列表:格式以,隔开
deliveryStatus: "dsccl",//商标交付状态:dsccl: 待上传材料, dsh: 待审核, ddj: 待递交, ywc: 已完成
picUrl: tm.picUrl || null,//商标图样
colorizedPicUrl: tm.colorizedPicUrl || null,//商标彩色图样
sywjUrl: apply.sywjUrl || null,//声音文件
gzwtsUrl: apply.gzwtsUrl || null,//盖章委托书
smwjUrl: apply.smwjUrl || null,//说明文件
updateuser_id: user.id,//
updateuser: user.nickname,//
notes: tm.notes || "", // 备注信息
nclOneCount: tm.nclOneCodes.length,
nclCount: tm.nclCount,
deliveryOrderNo: orderTm.deliveryOrderNo
};
var flowContent = "";
if (apply.customerType == "person") {
if (!apply.businessLicensePic || !apply.identityCardPic || !apply.gzwtsUrl) {
orderProductObj["deliveryStatus"] = "dsccl";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待上传材料" : "订单已创建待付款";
} else {
orderProductObj["deliveryStatus"] = "dsh";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待专家服务" : "订单已创建待付款";
}
}
if (apply.customerType == "ent") {
if (!apply.businessLicensePic || !apply.gzwtsUrl) {
orderProductObj["deliveryStatus"] = "dsccl";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待上传材料" : "订单已创建待付款";
} else {
orderProductObj["deliveryStatus"] = "dsh";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待专家服务" : "订单已创建待付款";
}
}
//订单客户档案添加和修改
await self.opCustomerInfo(user, apply, orderProductObj, t);
//创建服务单
var putWhere = { where: { channelServiceNo: channelOrder.channelServiceNo } };
await self.dao.updateByWhere(orderProductObj, putWhere, t);//创建商标订单--------put
var flowObj = {
app_id: user.app_id,
createuser_id: user.id,
sourceOrderNo: orderTm.sourceOrderNo,
opContent: flowContent
};
if (channelOrder.payStatus == "yfk") {
flowObj.isShow = 1;
}
await self.orderflowDao.create(flowObj, t);//创建订单流程
flowObj.sourceOrderNo = orderProductObj.deliveryOrderNo;
await self.orderflowDao.create(flowObj, t);//创建交付流程
var returnTm = await self.opTmInfo(user, tm, apply, nclones, orderTm, JSON.stringify(productItem), t);
return system.getResultSuccess({
deliveryOrderNo: orderProductObj.deliveryOrderNo,
channelServiceNo: channelOrder.channelServiceNo,
channelItemCode: productItem.serviceItemCode,
channelParams: params.channelParams,
tm: returnTm
});
})
}
async addTmOrder(params, pobj, req) {//创建商标订单信息
var self = this;
var itemCode = params.itemCode;//产品编码
var tm = params.tm;//增加sourceType || "00";//来源类型:00订单,10需求,20服务商
var apply = params.apply;
var app = params.app;
var user = params.user;
var nclones = params.nclones || null;
var channelUser = params.channelUser || null;
var channelOrder = params.channelOrder || {};
var orderType = params.orderType || "dkxd";//订单类型,zzdd: 自主订单,dkxd: 代客下单
if (!nclones || nclones.length < 1) {
return system.getResult(null, "尼斯大类不能为空");
}
if (!itemCode) {
return system.getResult(null, "itemCode参数错误");
}
var productItem = await this.appproductDao.findOneByChannelItemCode(itemCode, user.app_id);//通过ChannelItemCode获取产品//this.appproductDao.findOneByChannelItemCode(itemCode, user.app_id);//通过ChannelItemCode获取产品
if (!productItem) {
return system.getResult(null, "未知的产品");
}
if (productItem.status != 1) {
return system.getResult(null, "产品已禁用");
}
var verifyResult = await self.isOrderVerify(user, 1, tm, productItem, nclones, null);
if (verifyResult) {
return verifyResult;
}
var orderAmount = tm;
orderAmount.salesNum = tm.nclOneCodes ? tm.nclOneCodes.length : 0;
orderAmount.minitermNum = tm.nclCount ? tm.nclCount : 0;
if (pobj.actionProcess == "jd") {
if (orderAmount.salesNum > 1 || orderAmount.minitermNum > 10) {
return system.getResult(null, "选择的尼斯数据有误,目前只支持1大类10小项");
}
}
if (tm.tmFormType == "4") {//图形商标
tm["name"] = "图形";
}
return await self.db.transaction(async function (t) {
//创建订单
var ordercode = await self.getBusUid("tm");
channelOrder.payStatus = "dfk";
var orderResult = await self.orderDao.addOrder(ordercode, orderType, user, app, productItem, channelOrder, channelUser, apply, orderAmount, t);
if (orderResult.status != 0) {
return orderResult;
}
var order = orderResult.data;
if (orderResult.addOrder && orderResult.addOrder == true) {
await self.receiptvoucherDao.addReceiptvoucher(order, null, t);//创建订单支付信息
}
var orderProductObj = {
app_id: user.app_id,//
productType_id: productItem.productType_id,//产品类型Id
productOneType_id: productItem.productOneType_id,//产品大类Id
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
tmName: tm.tmName,//商标名称
tmType: "p",//"p": "普通商标", "j": "集体商标", "z": "证明商标", "t": "特殊商标"
tmFormType: tm.tmFormType,//商标类型形式:"1": "立体", "3": "字", "4": "图", "5": "字图", "6": "颜色", "7": "彩色"
nclOneCodes: tm.nclOneCodes ? tm.nclOneCodes.join(",") : null,//尼斯大类列表:格式以,隔开
orderServicePayStatus: channelOrder.payStatus,//支付状态:dfk: 待付款, yfk: 已支付
deliveryStatus: "dsccl",//商标交付状态:dsccl: 待上传材料, dsh: 待审核, ddj: 待递交, ywc: 已完成
appDataOpType: app.appDataOpType,// 应用数据操作类型:00独立,10全委托,20部分委托
sourceOrderNo: ordercode,//来源单号
deliveryOrderNo: await self.getBusUid("jf"),
channelServiceNo: channelOrder.channelServiceNo || "",// 渠道服务单号
channelOrderNo: channelOrder.channelOrderNo || "",//渠道订单号列表,多个以,隔开
needNo: channelOrder.needNo || null,//需求单号
sourceType: tm.sourceType || "00",
picUrl: tm.picUrl || null,//商标图样
colorizedPicUrl: tm.colorizedPicUrl || null,//商标彩色图样
sywjUrl: tm.sywjUrl || null,//声音文件
gzwtsUrl: tm.gzwtsUrl || null,//盖章委托书
smwjUrl: tm.smwjUrl || null,//说明文件
channelUserId: channelUser.channelUserId,// 渠道用户id
createuser_id: user.id,//
createuser: user.nickname,//
notes: tm.notes || "", // 备注信息
nclOneCount: tm.nclOneCodes.length,
nclCount: tm.nclCount,
};
var flowContent = "";
if (apply.customerType == "person") {
if (!apply.businessLicensePic || !apply.identityCardPic || !tm.gzwtsUrl) {
orderProductObj["deliveryStatus"] = "dsccl";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待上传材料" : "订单已创建待付款";
} else {
orderProductObj["deliveryStatus"] = "dsh";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款" : "订单已创建待付款";
}
}
if (apply.customerType == "ent") {
if (!apply.businessLicensePic || !tm.gzwtsUrl) {
orderProductObj["deliveryStatus"] = "dsccl";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待上传材料" : "订单已创建待付款";
} else {
orderProductObj["deliveryStatus"] = "dsh";
flowContent = channelOrder.payStatus == "yfk" ? "订单已付款" : "订单已创建待付款";
}
}
//订单客户档案添加和修改
await self.opCustomerInfo(user, apply, orderProductObj, t);
//创建服务单
var orderTm = await self.dao.create(orderProductObj, t);//创建商标订单
var flowObj = {
app_id: user.app_id,
createuser_id: user.id,
sourceOrderNo: ordercode,
opContent: flowContent
};
await self.orderflowDao.create(flowObj, t);//创建订单流程
flowObj.sourceOrderNo = orderProductObj.deliveryOrderNo;
if (channelOrder.payStatus == "yfk") {
flowObj.isShow = 1;
}
await self.orderflowDao.create(flowObj, t);//创建交付流程
orderTm.needNo = channelOrder.needNo || null;//需求单号
var returnTm = await self.opTmInfo(user, tm, apply, nclones, orderTm, JSON.stringify(productItem), t);
return system.getResultSuccess({
deliveryOrderNo: orderProductObj.deliveryOrderNo,
orderNo: ordercode,
channelParams: params.channelParams,
channelItemCode: productItem.serviceItemCode,
tm: returnTm
});
})
}
async isOrderVerify(user, verifyType, tm, serviceitem, nclones, buyProductCount) { //订单验证
/*
verifyType==1为商标注册验证,2为其他订单验证
*/
var sveItemRateConfig = serviceitem.rateConfig ? Number(serviceitem.rateConfig) : 0;//产品费率
var fwf = serviceitem.serviceCharge ? Number(serviceitem.serviceCharge) : 0;//服务费
var yhfl = serviceitem.discountsRateConfig ? Number(serviceitem.discountsRateConfig) : 0;//最大优惠费率
var gf = serviceitem.publicExpense ? Number(serviceitem.publicExpense) : 0;//产品官费
var nclSmallPrice = gf / 10;//单个小类官费
nclSmallPrice = Number(nclSmallPrice.toFixed(2));
var productCount = 1;//产品数量
var gfze = 0;//官费总额--------------------------------------------------------------------------------------------
if (verifyType == 1) {
tm.nclOneCodes = [];
tm.nclCount = 0;
productCount = nclones.length;
for (var a = 0; a < nclones.length; a++) {
var nclone = nclones[a];
if (nclone.code) {
tm.nclOneCodes.push(nclone.code);
tm.nclCount = tm.nclCount + nclone.nclThree.length;
var nclthreeobj = nclone.nclThree;
gfze = gfze + gf;
if (nclthreeobj.length > 10) {
gfze = gfze + (nclthreeobj.length - 10) * nclSmallPrice;
}
}
}
}
else if (verifyType == 2) {
productCount = buyProductCount;
gfze = gf * Number(productCount);
}
var fwfze = Number(fwf) * Number(productCount);//服务费总额--------------------------------------------------------------------------------------------
var sfze = Number(tm.totalSum) / (sveItemRateConfig + 100) * sveItemRateConfig; //totalTaxes 税费总额
sfze = sfze.toFixed(2);
sfze = Number(sfze);//--------------------------------------------------------------------------------------------
var zdyhe = (gfze + fwfze) * yhfl / 100;//最大优惠额-------------------------------------------------------------------------------------------
zdyhe = zdyhe.toFixed(2);
zdyhe = Number(zdyhe);
//毛利总额=应付总额-官费总额
var mlze = Number(tm.totalSum) - gfze;//totalProfitSum 毛利总额--------------------------------------------------------------------------------------------
mlze = mlze.toFixed(2);
mlze = Number(mlze);
var ddze = Number(fwfze) + Number(gfze);//订单总额---------------------------------------------------
if (parseFloat(tm.totalSum) < Number(ddze)) {
return { code: -201, msg: "订单总额有误" };
}
tm.totalServiceCharge = fwfze;// 服务费总额(产品配置的服务费*订单件数)
tm.totalPublicExpense = gfze;// 官费总额(产品配置的官费*订单件数)
tm.totalDiscounts = zdyhe;// 优惠总额((服务费总额+官费总额)-订单总额(产品价格×优惠费率×订单件数)>0则有优惠额度)
tm.totalTaxes = sfze;// 税费总额(订单总额-(订单总额/(1+产品费率)))
return "";
// //优惠金额=服务费+官费总额-应付总额(服务费、官费之和小于等于应付总额时,优惠金额为零)
// var yhje = fwfze + gfze - Number(tm.totalSum);
// if (yhje < 0) {
// yhje = 0;
// }
// yhje = yhje.toFixed(2);
// yhje = Number(yhje);
// if (fwfze != Number(tm.totalServiceCharge)) {
// return { code: -201, msg: "服务费总额有误" };
// }
// if (gfze != Number(tm.totalPublicExpense)) {
// return { code: -202, msg: "官费总额有误" };
// }
// if (sfze != Number(tm.totalTaxes)) {
// return { code: -203, msg: "税费总额有误" };
// }
// if (mlze != Number(tm.totalProfitSum)) {
// return { code: -204, msg: "毛利总额有误" };
// }
// if (yhje != Number(tm.totalDiscounts) || yhje > zdyhe) {
// return { code: -205, msg: "优惠总额有误" };
// }
// var channelProfitSum = 0;//订单渠道分成毛利润总额
// var pfProfitSum = 0;//订单平台毛利润总额
// var totalProfitSum = Number(tm.totalProfitSum);//订单毛利润总额
// if (totalProfitSum > 0) {
// var tmpChannelProfitRate = Number(serviceitem.channelProfitRate);
// if (tmpChannelProfitRate > 0) {
// var channelProfitRate = tmpChannelProfitRate / 100;
// channelProfitSum = totalProfitSum * channelProfitRate;
// pfProfitSum = totalProfitSum - channelProfitSum;
// channelProfitSum = channelProfitSum.toFixed(2);
// pfProfitSum = pfProfitSum.toFixed(2);
// if (channelProfitSum < 0 || pfProfitSum < 0) {
// return { code: -206, msg: "利润计算有误" };
// }
// tm["channelProfitSum"] = channelProfitSum;
// tm["pfProfitSum"] = pfProfitSum;
// } else if (tmpChannelProfitRate == 0) {
// pfProfitSum = mlze;//毛利总额
// }
// }//渠道利润分成比率(只分订单中毛利润总额的分成)
// return "";
}
async opCustomerInfo(user, apply, orderObj, t) {//订单客户档案添加和修改
var customerInfoObj = {
deliveryOrderNo: orderObj.deliveryOrderNo,//交付订单号
app_id: user.app_id,
code: apply.code,
name: apply.name,
applyAddr: apply.applyAddr,//申请地址
applyArea: apply.applyArea,//申请区域
customerType: apply.customerType,//申请人类型 ent person
businessLicensePic: apply.businessLicensePic || "", //营业执照图片
businessLicensePdf: apply.businessLicensePdf || "", //营业执pdf
identityCardPic: apply.identityCardPic || "", //身份证图片
identityCardPdf: apply.identityCardPdf || "", //身份证pdf
owner_id: user.id,
createuser_id: user.id,
zipCode: apply.zipCode,//邮政编码
};
if (apply.customerType == "person") {
customerInfoObj["identityCardNo"] = apply.identityCardNo;
customerInfoObj["identityCardPic"] = apply.identityCardPic || "";
customerInfoObj["identityCardPdf"] = apply.identityCardPdf || "";
//身份证号、身份证图片
if (!apply.identityCardNo || !apply.identityCardPic) {
orderObj.deliveryStatus = "dsccl";
}
else {
if (!orderObj.deliveryStatus) {
orderObj.deliveryStatus = "dsh";
}
}
}
// var customer = await this.customerinfoDao.findOneByCodeAndUserId(apply.code, user.id);//查询客户档案
var customer = await this.customerinfoDao.model.findOne({
where: { deliveryOrderNo: orderObj.deliveryOrderNo },
raw: true
});
if (customer && customer.id) {//客户已存在 则更新
customerInfoObj["id"] = customer.id;
await this.customerinfoDao.update(customerInfoObj, t);
} else {//客户不存在 则创建
customer = await this.customerinfoDao.create(customerInfoObj, t);
}
var customerContactObj = {
deliveryOrderNo: orderObj.deliveryOrderNo,//交付订单号
app_id: user.app_id,
customerinfo_id: customer.id,
name: apply.contacts,//联系人
mobile: apply.mobile,//手机号
email: apply.email,//邮箱
tel: apply.tel,//座机
fax: apply.fax//传真
};
// var customercontacts = await this.customercontactsDao.findOneByMobile(apply.mobile, customer.id);
var customercontacts = await this.customercontactsDao.model.findOne({
where: { deliveryOrderNo: orderObj.deliveryOrderNo },
raw: true
});
if (!customercontacts) {//客户联系人不存在 则创建
customercontacts = await this.customercontactsDao.create(customerContactObj, t);//创建订单联系人
}
}
async opTmInfo(user, tm, apply, nclones, orderTm, serviceItemSnapshot, t, ) {//商标(商标注册)添加操作
//获取产品快照
var productItem = serviceItemSnapshot;
if (productItem) {
productItem = JSON.parse(productItem);
}
var gf = productItem.publicExpense ? Number(productItem.publicExpense) : 0;//产品官费
var nclSmallPrice = gf / 10;//单个小类官费
nclSmallPrice = Number(nclSmallPrice.toFixed(2));
var self = this;
var returnTm = [];
await this.trademarkDao.bulkDeleteByWhere({ where: { deliveryOrderNo: orderTm.deliveryOrderNo, nclOneCodes: { [self.db.Op.in]: tm.nclOneCodes } } }, t);
for (var i = 0; i < nclones.length; i++) {
var tbcode = await self.getBusUid("tb");
var nclone = nclones[i];
if (nclone.tbCode) {//用于辅助注册推送数据
tbcode = nclone.tbCode;
}
var nclthreeobj = nclone.nclThree;
var nclthreeobjCount = nclone.nclThree.length;
//计算尼斯小类官方总额
var nclgfze = 300;
if (nclthreeobj.length > 10) {
nclgfze = nclgfze + (nclthreeobj.length - 10) * nclSmallPrice;
}
nclthreeobj = JSON.stringify(nclthreeobj);
var trademarkobj = {
tbCode: tbcode,//提报号(自动生成)
deliveryOrderNo: orderTm.deliveryOrderNo,
needNo: orderTm.needNo,//需求单号
officialType: orderTm.deliveryStatus,//"dsccl": "待上传材料", "dsh": "待审核"
app_id: user.app_id,
createuser_id: user.id,
owner_id: user.id,
owner: user.nickname,
ownerMoblie: user.userMoblie,
creator: user.nickname,
nclOneCodes: nclone.code,//尼斯大类
nclSmallCodes: nclthreeobj,//尼斯小类
nclCount: nclthreeobjCount,//尼斯数量
nclPublicExpense: nclgfze,
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
channelUserId: user.channelUserId
};
var trademark = await self.trademarkDao.create(trademarkobj, t);//创建商标
var returnObj = {
nclOne: nclone.code, tbCode: tbcode
};
returnTm.push(returnObj);
}
return returnTm;
}
//------------------------------------------创建订单--------------------结束------------------------
async op1688ChannelPushOrder(action_body) {
return system.getResultSuccess();
}
async get1688ChannelOrder(action_body) {
var orderItem = await this.orderDao.getItemByChannelServiceNo(action_body.channelOrderNo, action_body.app.id);
if (!orderItem) {
return system.getResult(null, "暂无订单信息");
}
var salesDiliverNum = Number(orderItem.salesNum) - Number(orderItem.salesDiliverNum);
if (salesDiliverNum <= 0) {
return system.getResult(null, "服务单交付数量有误,数量为:" + orderItem.salesNum + ",已交付数量为:" + orderItem.salesDiliverNum);
}
var minitermDiliverNum = Number(orderItem.minitermNum) - Number(orderItem.minitermDiliverNum);
if (minitermDiliverNum <= 0) {
return system.getResult(null, "服务单交付小项数量有误,小项数量为:" + orderItem.minitermNum + ",已交付小项数量为:" + orderItem.minitermDiliverNum);
}
var param = {
itemCode: orderItem.itemCode,
channelParams: "",
channelUser: {
channelUserId: orderItem.channelUserId || "",
channelUserName: "",
channelUserMoblie: "",
nickname: "",
orgName: "",
orgPath: "",
},
channelOrder: {
channelServiceNo: orderItem.channelServiceNo || "",
channelOrderNo: orderItem.channelOrderNo || "",
needNo: orderItem.needNo || "",
quantity: salesDiliverNum,
nclCount: minitermDiliverNum,
payStatus: orderItem.orderPayStatus || "",
payTime: orderItem.payTime || "",
}
};
return system.getResultSuccess(param);
}
/**
* 订单详情
* @param {*} params 格式:{channelUserId:XX, needNoOrderNo:XX}
*/
async getOrderDetails(params, pobj, req) {
var item = await this.dao.getItemByNeedNoOrderNo(params.needNoOrderNo, req.app.id);
if (!item) {
return system.getResult(null, "item data is empty");
}
if (item.payStatus == "dfk") {
item.deliveryStatus = item.payStatus;
}
return system.getResultSuccess({ deliveryOrderNo: item.deliveryOrderNo, deliveryStatus: item.deliveryStatus });
}
/**
* 商标交付列表
* @param {*} params 格式:{channelServiceNo:XX, app:{ appId:XX}}
*/
async getTmOrderList(params, pobj, req) {//商标交付列表
var pageSize = Number(params.pageSize || 20);
var pageIndex = Number(params.pageIndex || 1);
var from = pageIndex == 1 ? 0 : Number((pageIndex - 1) * pageSize);
if (pageSize > 50) {
pageSize = 50;
}
var sql = "SELECT tm.`needNo`,tm.`channelServiceNo`,tm.`deliveryOrderNo`,tm.`tmName`,tm.`nclOneCount`,tm.`nclOneCodes`,tm.itemCode,tm.itemName," +
" o.`totalSum`,c.`name`,tm.`deliveryStatus`,tm.`deliveryStatusName`,tm.payStatus,tm.payStatusName,o.payTime AS CreateDate,tm.submitTime," +
" c.`customerType`,c.`businessLicensePic`,c.`identityCardPic`,tm.`gzwtsUrl`,tm.`smwjUrl`" +
" FROM `b_order_tm_product` AS tm LEFT JOIN `b_order` AS o ON tm.`sourceOrderNo`=o.`orderNo` LEFT JOIN" +
" `b_customerinfo` AS c ON tm.`deliveryOrderNo`=c.`deliveryOrderNo` where tm.deleted_at is null ";
var sqlCount = "SELECT count(1) as dataCount FROM `b_order_tm_product` AS tm LEFT JOIN `b_order` AS o ON tm.`sourceOrderNo`=o.`orderNo` LEFT JOIN" +
" `b_customerinfo` AS c ON tm.`deliveryOrderNo`=c.`deliveryOrderNo` where tm.deleted_at is null ";
var paramWhere = {};
if (["1688", "jd", "gsbhome"].indexOf(pobj.actionProcess) >= 0) {
sql += " and o.orderPayStatus=:orderPayStatus";
sqlCount += " and o.orderPayStatus=:orderPayStatus";;
paramWhere.orderPayStatus = "yfk";
}
if (req.user) {
if (params.getListType && params.getListType == "getTmOrderListAdmin") {
if (["syaify", "jd_613f2fd04340f"].indexOf(req.user.channelUserId) < 0) {
sql += " and tm.createuser_id=:createuser_id";
sqlCount += " and tm.createuser_id=:createuser_id";
paramWhere.createuser_id = req.user.id;
}
} else {
sql += " and tm.createuser_id=:createuser_id";
sqlCount += " and tm.createuser_id=:createuser_id";
paramWhere.createuser_id = req.user.id;
}
}
if (params.channelServiceNo) {
sql += " and tm.channelServiceNo like :channelServiceNo";
sqlCount += " and tm.channelServiceNo like :channelServiceNo";
paramWhere.channelServiceNo = "%" + params.channelServiceNo.trim() + "%";
}
if (params.deliveryOrderNo) {
sql += " and tm.deliveryOrderNo like :deliveryOrderNo";
sqlCount += " and tm.deliveryOrderNo like :deliveryOrderNo";
paramWhere.deliveryOrderNo = "%" + params.deliveryOrderNo.trim() + "%";
}
if (params.itemCode) {
sql += " and tm.itemCode=:itemCode";
sqlCount += " and tm.itemCode=:itemCode";
paramWhere.itemCode = params.itemCode;
}
if (params.deliveryStatus) {
sql += " and tm.deliveryStatus=:deliveryStatus";
sqlCount += " and tm.deliveryStatus=:deliveryStatus";
paramWhere.deliveryStatus = params.deliveryStatus;
}
if (params.payStatus) {
sql += " and tm.payStatus=:payStatus";
sqlCount += " and tm.payStatus=:payStatus";
paramWhere.payStatus = params.payStatus;
}
if (params.tmName) {
sql += " and tm.tmName like :tmName";
sqlCount += " and tm.tmName like :tmName";
paramWhere.tmName = +"%" + params.tmName.trim() + "%";
}
if (params.name) {
sql += " and c.name like :name";
sqlCount += " and c.name like :name";
paramWhere.name = "%" + params.name.trim() + "%";
}
if (params.startTime && params.entTime) {
var startTime = params.startTime.trim() + " 00:00:00";
var entTime = params.entTime + " 23:59:59";
sql += " and o.created_at >=:startTime and o.created_at<=:entTime";
sqlCount += " and o.created_at >=:startTime and o.created_at<=:entTime";
paramWhere.startTime = startTime;
paramWhere.entTime = entTime;
}
sql += " order by tm.id desc LIMIT " + pageSize + " OFFSET " + from + "";
var tmpResult = await this.customQuery(sql, paramWhere);
var tmpResultCount = await this.customQuery(sqlCount, paramWhere);
if (!tmpResult || tmpResult.length == 0) {
return system.getResultSuccess(null, "暂无数据");
}
var result = system.getResultSuccess(tmpResult);
result.dataCount = tmpResultCount && tmpResultCount.length > 0 ? tmpResultCount[0].dataCount : 0;
return result;
}
/**
* 商标交付信息
* @param {*} params 格式:{deliveryOrderNo:XX}
*/
async getTmOrder(params) {//商标交付信息
var deliveryOrderNo = params.deliveryOrderNo;
var item = await this.ordertmproductDao.getTmItemByDeliveryOrderNo(deliveryOrderNo);
if (!item) {
return system.getResultSuccess(null, "暂无数据");
}
if (item.payStatus == "dfk") {
item.deliveryStatus = item.payStatus;
}
var resultData = {
tm: {
itemCode: item.itemCode,
itemName: item.itemName,
tmName: item.tmName,
picUrl: item.picUrl,
colorizedPicUrl: item.colorizedPicUrl,
tmType: item.tmType,
tmFormType: item.tmFormType,
nclOneCodes: item.nclOneCodes,
gzwtsUrl: item.gzwtsUrl,
smwjUrl: item.smwjUrl,
deliveryStatus: item.deliveryStatus,
totalSum: item.totalSum,
notes: item.notes
}, orderFlow: [], receiptVoucher: []
};
var flowList = await this.orderflowDao.getListBySourceOrderNo(deliveryOrderNo);
if (flowList && flowList.length > 0) {
for (let index = 0; index < flowList.length; index++) {
const element = flowList[index];
if (element) {
resultData.orderFlow.push({
opContent: element.opContent,
createDate: element.created_at
});
}
}
}
var rItemList = await this.receiptvoucherDao.getItemSourceOrderNo(item.sourceOrderNo);
if (rItemList && rItemList.length > 0) {
for (let j = 0; j < rItemList.length; j++) {
const rItem = rItemList[j];
if (rItem) {
resultData.receiptVoucher.push({
payAccountType: rItem.payAccountType,
payDate: rItem.payDate,
wxPayOrderCode: rItem.wxPayOrderCode,
aliPayOrderCode: rItem.aliPayOrderCode,
busPayOrderCode: rItem.busPayOrderCode,
certifyFileUrl: rItem.certifyFileUrl,
totalSum: rItem.totalSum
});
}
}
}
return system.getResultSuccess(resultData);
}
/**
* 商标订单-申请信息
* @param {*} params 格式:{deliveryOrderNo:XX}
*/
async getTmApply(params) {//商标订单-申请信息
var deliveryOrderNo = params.deliveryOrderNo;
var item = await this.customerinfoDao.findOneByDeliveryOrderNo(deliveryOrderNo);
if (!item) {
return system.getResultSuccess(null, "暂无数据");
}
var resultData = {
applyAddr: item.applyAddr,
applyArea: item.applyArea,
businessLicensePic: item.businessLicensePic,
businessLicensePdf: item.businessLicensePdf,
code: item.code,
customerType: item.customerType,
identityCardNo: item.identityCardNo,
identityCardPic: item.identityCardPic,
identityCardPdf: item.identityCardPdf,
name: item.name,
zipCode: item.zipCode,
notes: item.notes
};
var contactsItem = await this.customercontactsDao.findOneByCustomerinfoId(item.id);
if (contactsItem) {
resultData.contacts = contactsItem.name;
resultData.mobile = contactsItem.mobile;
resultData.email = contactsItem.email;
resultData.fax = contactsItem.fax;
}
return system.getResultSuccess(resultData);
}
/**
* 商标订单-商标尼斯信息
* @param {*} params 格式:{deliveryOrderNo:XX}
*/
async getTmNclList(params) {//商标订单-商标尼斯信息
var deliveryOrderNo = params.deliveryOrderNo;
var self = this;
var tmList = await this.trademarkDao.getListByDeliveryOrderNo(deliveryOrderNo);
if (!tmList || tmList.length == 0) {
return system.getResultSuccess(null, "暂无数据");
}
var resultData = [];
for (let index = 0; index < tmList.length; index++) {
const item = tmList[index];
if (item) {
var tm = {
tbCode: item.tbCode,
nclOneCodes: item.nclOneCodes,
nclOneCodesName: item.nclOneCodesName,
nclSmallCodes: item.nclSmallCodes,
officialType: item.officialType,
officialTypeName: item.officialTypeName,
tmRegistNum: item.tmRegistNum,
submitTime: item.submitTime,
tmOfficials: []
};
if (item.tmRegistNum) {
var tmOfficialsList = await self.tmofficialDao.getListByTmRegistNum(item.tmRegistNum);
if (tmOfficialsList && tmOfficialsList.length > 0) {
for (let i = 0; i < tmOfficialsList.length; i++) {
const element = tmOfficialsList[i];
if (element) {
tm.push({
officialType: element.officialType,
officialTypeName: element.officialTypeName,
officialFileUrl: element.officialFileUrl,
createDate: element.created_at
});
}
}
}
}
resultData.push(tm);
}
}
return system.getResultSuccess(resultData);
}
//-------------------------接收辅助注册商标数据-------start--------------------------------------------------------
/**
* 接收辅助注册商标数据
*/
async addAssistTm(params) {
// return system.getResultSuccess(null, "接口开发中");
var self = this;
var itemCode = params.itemCode;//产品编码
var tm = params.tm;//增加sourceType || "00";//来源类型:00订单,10需求,20服务商
var apply = params.apply;
var nclones = params.nclones || null;
var channelOrder = params.channelOrder || null;
var orderType = params.orderType || "dkxd";//订单类型,zzdd: 自主订单,dkxd: 代客下单
var needNo = channelOrder.needNo;
if (!needNo) {
return system.getResult(null, "需求编号不能为空");
}
var order = await this.orderDao.model.findOne({
where: { needNo: needNo },
raw: true
});
if (!order || !order.id) {
return system.getResult(null, "未知订单");
}
//获取渠道用户数据
var user = await this.userDao.model.findOne({
where: { channelUserId: order.channelUserId, app_id: order.app_id },
raw: true
});
var app = await this.appDao.model.findOne({
where: { id: order.app_id },
raw: true
});
// channelOrder["channelServiceNo"]=order.channelServiceNo;
channelOrder["payTime"] = order.payTime;
if (!nclones || nclones.length < 1) {
return system.getResult(null, "尼斯大类不能为空");
}
if (!itemCode) {
return system.getResult(null, "itemCode参数错误");
}
// itemCode="zzsbzc";//测试
var productItem = await this.appproductDao.findOneByServiceItemCode(itemCode, user.app_id);//获取产品
if (!productItem) {
return system.getResult(null, "未知的产品");
}
if (productItem.status != 1) {
return system.getResult(null, "产品已禁用");
}
if (productItem && productItem.verifyPrice == 1) {
var verifyResult = await self.isOrderVerify(user, 1, tm, productItem, nclones, null);
if (verifyResult) {
return verifyResult;
}
} else {
tm.nclOneCodes = [];
tm.nclCount = 0;
for (var i = 0; i < nclones.length; i++) {
var nclone = nclones[i];
var nclthreeobj = nclone.nclThree;
if (nclone) {
tm.nclOneCodes.push(nclone.code);
tm.nclCount = tm.nclCount + nclthreeobj.length;
}
}
}
if (tm.tmFormType == "4") {//图形商标
tm["name"] = "图形";
}
return await self.db.transaction(async function (t) {
//创建订单
var ordercode = await self.getBusUid("tm");
if (order.orderNo) {
ordercode = order.orderNo;
}
var orderAmount = tm;
orderAmount.salesNum = tm.nclOneCodes.length;
orderAmount.minitermNum = tm.nclCount;
var jfcode = await self.getBusUid("jf");
var orderProductObj = {
app_id: user.app_id,//
productType_id: productItem.picUrl,//产品类型Id
productOneType_id: productItem.picUrl,//产品大类Id
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
tmName: tm.tmName,//商标名称
tmType: "p",//"p": "普通商标", "j": "集体商标", "z": "证明商标", "t": "特殊商标"
tmFormType: tm.tmFormType,//商标类型形式:"1": "立体", "3": "字", "4": "图", "5": "字图", "6": "颜色", "7": "彩色"
nclOneCodes: tm.nclOneCodes ? tm.nclOneCodes.join(",") : null,//尼斯大类列表:格式以,隔开
orderServicePayStatus: channelOrder.payStatus,//支付状态:dfk: 待付款, yfk: 已支付
deliveryStatus: "dqrfa",//商标交付状态:dsccl: 待上传材料, dsh: 待审核, ddj: 待递交, ywc: 已完成
appDataOpType: app.appDataOpType,// 应用数据操作类型:00独立,10全委托,20部分委托
sourceOrderNo: ordercode,//来源单号
deliveryOrderNo: channelOrder.deliveryOrderNo || jfcode,
channelServiceNo: channelOrder.channelServiceNo,// 渠道服务单号
channelOrderNo: channelOrder.channelOrderNo,//渠道订单号列表,多个以,隔开
needNo: channelOrder.needNo || null,//需求单号
sourceType: order.sourceType || "00",
picUrl: tm.picUrl || null,//商标图样
colorizedPicUrl: tm.colorizedPicUrl || null,//商标彩色图样
sywjUrl: tm.sywjUrl || null,//声音文件
gzwtsUrl: tm.gzwtsUrl || null,//盖章委托书
smwjUrl: tm.smwjUrl || null,//说明文件
channelUserId: user.channelUserId,// 渠道用户id
createuser_id: user.id,//
createuser: user.nickname,//
notes: tm.notes || "", // 备注信息
nclOneCount: tm.nclOneCodes.length,
nclCount: tm.nclCount,
};
var flowContent = "";
flowContent = "专家服务已提供服务,方案待确认";
// if (apply.customerType == "person") {
// if (!apply.businessLicensePic || !apply.identityCardPic || !tm.gzwtsUrl) {
// orderProductObj["deliveryStatus"] = "dsccl";
// flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待上传材料" : "订单已创建待付款";
// } else {
// orderProductObj["deliveryStatus"] = "dsh";
// if (tm.tmStatus && tm.tmStatus == "SUBALITMOK") {
// orderProductObj["deliveryStatus"] = "dqrfa";
// }
// flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待审核" : "订单已创建待付款";
// }
// }
// if (apply.customerType == "ent") {
// if (!apply.businessLicensePic || !tm.gzwtsUrl) {
// orderProductObj["deliveryStatus"] = "dsccl";
// flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待上传材料" : "订单已创建待付款";
// } else {
// orderProductObj["deliveryStatus"] = "dsh";
// if (tm.tmStatus && tm.tmStatus == "SUBALITMOK") {
// orderProductObj["deliveryStatus"] = "dqrfa";
// }
// flowContent = channelOrder.payStatus == "yfk" ? "订单已付款待审核" : "订单已创建待付款";
// }
// }
//订单客户档案添加和修改
await self.opCustomerInfo(user, apply, orderProductObj, t);
//获取历史交付单信息
var beforeOtp = await self.ordertmproductDao.model.findOne({
// where: { deliveryOrderNo: channelOrder.deliveryOrderNo },
where: { [self.db.Op.or]: [{ deliveryOrderNo: channelOrder.deliveryOrderNo }, { sourceOrderNo: order.orderNo }] },
raw: true
});
var orderTm = null;
if (beforeOtp && beforeOtp.id) {//更新交付单
orderProductObj["id"] = beforeOtp.id;
await self.dao.update(orderProductObj, t);
// orderTm = await self.ordertmproductDao.model.findOne({
// where: { id: beforeOtp.id },
// raw: true
// });
orderTm = orderProductObj;
} else {//创建服务单
orderTm = await self.dao.create(orderProductObj, t);//创建商标订单
}
var flowObj = {
app_id: user.app_id,
createuser_id: user.id,
sourceOrderNo: ordercode,
opContent: flowContent,
isShow: 1
};
await self.orderflowDao.create(flowObj, t);//创建订单流程
flowObj.sourceOrderNo = orderProductObj.deliveryOrderNo;
await self.orderflowDao.create(flowObj, t);//创建交付流程
orderTm.needNo = channelOrder.needNo || null;//需求单号
var returnTm = await self.opAssistTmInfo(user, tm, apply, nclones, orderTm, JSON.stringify(productItem), t);
var orderObj = {
id: order.id
};
if (channelOrder.channelServiceNo) {
orderObj["channelServiceNo"] = channelOrder.channelServiceNo;
}
if (channelOrder.channelOrderNo) {
orderObj["channelOrderNo"] = channelOrder.channelOrderNo;
}
await self.orderDao.update(orderObj, t);
return system.getResultSuccess({
deliveryOrderNo: orderProductObj.deliveryOrderNo,
channelServiceNo: channelOrder.channelServiceNo,
channelParams: params.channelParams,
tm: returnTm
});
})
}
async opAssistTmInfo(user, tm, apply, nclones, orderTm, serviceItemSnapshot, t, ) {//商标(商标注册)添加操作
//获取产品快照
var productItem = serviceItemSnapshot;
if (productItem) {
productItem = JSON.parse(productItem);
}
var gf = productItem.publicExpense ? Number(productItem.publicExpense) : 0;//产品官费
var nclSmallPrice = gf / 10;//单个小类官费
nclSmallPrice = Number(nclSmallPrice.toFixed(2));
var self = this;
var returnTm = [];
await this.trademarkDao.bulkDeleteByWhere({ where: { deliveryOrderNo: orderTm.deliveryOrderNo } }, t);
for (var i = 0; i < nclones.length; i++) {
var tbcode = await self.getBusUid("tb");
var nclone = nclones[i];
if (nclone.tbCode) {//用于辅助注册推送数据
tbcode = nclone.tbCode;
}
var nclthreeobj = nclone.nclThree;
var nclthreeobjCount = nclone.nclThree.length;
//计算尼斯小类官方总额
var nclgfze = 300;
if (nclthreeobj.length > 10) {
nclgfze = nclgfze + (nclthreeobj.length - 10) * nclSmallPrice;
}
nclthreeobj = JSON.stringify(nclthreeobj);
var trademarkobj = {
tbCode: tbcode,//提报号(自动生成)
deliveryOrderNo: orderTm.deliveryOrderNo,
needNo: orderTm.needNo,//需求单号
officialType: orderTm.deliveryStatus,//"dsccl": "待上传材料", "dsh": "待审核"
app_id: user.app_id,
createuser_id: user.id,
owner_id: user.id,
owner: user.nickname,
ownerMoblie: user.userMoblie,
creator: user.nickname,
nclOneCodes: nclone.code,//尼斯大类
nclSmallCodes: nclthreeobj,//尼斯小类
nclCount: nclthreeobjCount,//尼斯数量
nclPublicExpense: nclgfze,
itemCode: productItem.itemCode,//
itemName: productItem.itemName,//
channelUserId: user.channelUserId
};
var trademark = await self.trademarkDao.create(trademarkobj, t);//创建商标
var returnObj = {
nclOne: nclone.code, tbCode: tbcode
};
returnTm.push(returnObj);
}
return returnTm;
}
/**
* 接收辅助注册商标修改数据
*/
async editAssistTm(obj) {
// return system.getResultSuccess(null, "接口开发中");
var self = this;
var needNo = obj.needId;
if (!needNo) {
return system.getResultFail(-101, "needNo参数错误");
}
//获取交付单信息
var ordertmproduct = await this.ordertmproductDao.model.findOne({
where: { needNo: needNo },
raw: true
});
if (!ordertmproduct || !ordertmproduct.id) {
return system.getResultFail(-102, "商标交付单不存在");
}
var deliveryOrderNo = ordertmproduct.deliveryOrderNo;
//获取交付单状态,判断是否可修改
if (ordertmproduct.deliveryStatus == 'ddj' || ordertmproduct.deliveryStatus == 'ywc') {
var deliveryStatusName = "待递交";
if (ordertmproduct.deliveryStatus == 'ywc') {
deliveryStatusName = "已完成";
}
return system.getResultFail(-103, "该商标交付单状态为" + deliveryStatusName + ",不能进行修改");
}
//获取渠道用户数据
var user = await this.userDao.model.findOne({
where: { id: ordertmproduct.createuser_id },
raw: true
});
if (!user) {
return system.getResultFail(-104, "未知的用户");
}
//获取渠道数据
var app = await this.appDao.model.findOne({
where: { id: ordertmproduct.app_id },
raw: true
});
if (!app) {
return system.getResultFail(-105, "未知的渠道");
}
var itemCode = obj.itemCode;//产品编码
if (!itemCode) {
return system.getResultFail(-106, "产品编码参数错误");
}
var productItem = await this.appproductDao.findOneByServiceItemCode(itemCode, app.id);//获取产品
if (!productItem) {
return system.getResultFail(-107, "未知的产品");
}
return await self.db.transaction(async function (t) {
var whereObj = { where: { deliveryOrderNo: deliveryOrderNo, app_id: app.id }, transaction: t };
//申请人
var applyObj = obj.apply;
applyObj["updated_at"] = new Date();
await self.customerinfoDao.model.update(applyObj, whereObj);
//联系人
var contactObj = obj.contacts;
contactObj["updated_at"] = new Date();
await self.customercontactsDao.model.update(contactObj, whereObj);
//商标信息
var tmsList = obj.tms;
await self.trademarkDao.bulkDeleteByWhere(whereObj, t);
for (var i = 0; i < tmsList.length; i++) {
var tm = tmsList[i];
tm["needNo"] = needNo;
tm["deliveryOrderNo"] = deliveryOrderNo;
tm["app_id"] = app.id;
tm["createuser_id"] = user.id;
tm["owner_id"] = user.id;
tm["owner"] = user.nickname;
tm["ownerMoblie"] = user.ownerMoblie;
tm["creator"] = user.nickname;
tm["itemCode"] = itemCode;
tm["itemName"] = productItem.itemName;
tm["channelUserId"] = user.channelUserId;
tm["updated_at"] = new Date();
tm.officialType = "dsh"
// if (tm.officialType == "WAITARTIFICIALEXAMINE") {
// tm.officialType = "dsh"
// }
// else if (tm.officialType == "FILLEXCEPTION") {
// tm.officialType = "shbtg"
// }
// else if (tm.officialType == "WAITCOMMIT") {
// tm.officialType = "ddj"
// }
// else if (tm.officialType == "ROBOT") {
// tm.officialType = "ydj"
// } else {
// tm.officialType = "dsccl";
// }
await self.trademarkDao.create(tm, t);
}
//交付单
var otp = obj.order;
// if (otp.tmStatus && otp.tmStatus == "SUBALITMOK") {
// otp["deliveryStatus"] = "dqrfa";
// }
otp["deliveryStatus"] = "dqrfa";
otp["updated_at"] = new Date();
await self.dao.model.update(otp, whereObj);
return system.getResultSuccess();
})
}
async tmConfirm(obj) {
var self = this;
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 channelUserId = obj.channelUserId;
var deliveryOrderNo = obj.deliveryOrderNo;
var isConfirm = obj.isConfirm;
if (!channelUserId) {
return system.getResultFail(-101, "渠道用户id不能为空");
}
if (!deliveryOrderNo) {
return system.getResultFail(-102, "交付单号不能为空");
}
if (!isConfirm) {
return system.getResultFail(-103, "确认码不能为空");
}
//获取交付单信息
var ordertmproduct = await this.ordertmproductDao.model.findOne({
where: { deliveryOrderNo: deliveryOrderNo },
raw: true
});
if (!ordertmproduct || !ordertmproduct.id) {
return system.getResultFail(-104, "未知支付单");
}
if (ordertmproduct.deliveryStatus != "dqrfa") {
return system.getResultFail(-105, "方案确认失败,该方案交付状态为" + ordertmproduct.deliveryStatusName);
}
// if(ordertmproduct.channelUserId!=channelUserId){
// return system.getResultFail(-105, "方案确认失败,只能确认自己的商标方案");
// }
return await self.db.transaction(async function (t) {
var otpObj = { id: ordertmproduct.id };
var tmObj = { officialType: "dsh" };
var logMsg = { sourceOrderNo: deliveryOrderNo, opContent: "商标方案确认", app_id: app.id, isShow: 1 };
if (isConfirm == "0") {
if (!obj.notes) {
return system.getResultFail(-106, "方案确认失败,不通过原因不能为空");
}
otpObj["deliveryStatus"] = "fabtg";
otpObj["notes"] = obj.notes;
tmObj.officialType = "fabtg";
logMsg["opContent"] = "商标方案不通过";
}
if (isConfirm == "1") {
otpObj["deliveryStatus"] = "dsh";
otpObj["notes"] = obj.notes || "";
logMsg["opContent"] = "商标方案确认通过";
}
await self.trademarkDao.updateByWhere(tmObj, { where: { deliveryOrderNo: deliveryOrderNo } }, t);
await self.dao.update(otpObj, t);
await self.orderflowDao.create(logMsg, t);
return system.getResultSuccess();
})
}
//------------------------接收辅助注册商标数据--------end---------------------------------------------------------
}
module.exports = OrderTmProductService;
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;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
const uiconfig = system.getUiConfig2(settings.appKey);
class TradeMarkService extends ServiceBase {
constructor() {
super("dbtrademark", ServiceBase.getDaoName(TradeMarkService));
this.ordertmproductSve = system.getObject("service.dborder.ordertmproductSve");
this.tmofficialDao = system.getObject("db.dbtrademark.tmofficialDao");
this.orderflowDao = system.getObject("db.dborder.orderflowDao");
this.statusConvertJSON = {
"WAITARTIFICIALEXAMINE": "dsh",
"1": "1",
"2": "2",
"3": "3",
"4": "4",
"5": "5",
"6": "6",
"7": "7",
"8": "8",
"9": "9",
"10": "10",
"11": "11",
"12": "12",
"13": "13",
"READY": "dsccl",
"DOCFINISH": "dsh",
"AWAITCHECK": "dsh",
"WAITCOMMIT": "ddj",
"COMMITED": "ydj",
"ROBOT": "ydj",
"ROBOTPAY": "ydj",
"RECVCOMMIT": "ydj",
"FILLEXCEPTION": "shbtg",
//1688
"WAITCONFIRM": "dqrfa",
"CONFIRMFAIL": "dqrfa"
}
}
/**
* 修改商标信息 (订单详情页面使用)
* @param {*} obj
* obj.deliveryOrderNo 交付订单号,
* obj.tmName 商标名称,
* obj.tmFormType 商标类型,
* obj.notes 商标说明,
* obj.picUrl 商标图样,
* obj.colorizedPicUrl 商标彩色图样,
* obj.user 用户数据
*/
async updateTmInfo(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 otpObj = {
id: ordertmproduct.id,
deliveryOrderNo: deliveryOrderNo,
updateuser_id: user.id,
updateuser: user.nickname
};
if (obj.picUrl) {//商标图样 黑白
otpObj["picUrl"] = obj.picUrl;
}
if (obj.colorizedPicUrl) {//彩色商标图样
otpObj["colorizedPicUrl"] = obj.colorizedPicUrl;
}
if (obj.tmName) {//商标名称
otpObj["tmName"] = obj.tmName;
}
if (obj.tmFormType) {//商标类型
otpObj["tmFormType"] = obj.tmFormType;
}
if (obj.notes) {//商标说明
otpObj["notes"] = obj.notes;
}
await self.ordertmproductSve.dao.update(otpObj, t);//商标交付单 修改商标图样
var logMsg = { sourceOrderNo: deliveryOrderNo, opContent: "修改订单信息", app_id: app.id, isShow: 1 };
await self.orderflowDao.create(logMsg, t);
return system.getResultSuccess();
})
}
/**
* 修改商标尼斯信息 (订单详情页面使用)
* @param {*} obj
* obj.tbCode 商标提报号,
* obj.deliveryOrderNo 交付订单号,
* obj.nclOneCodes 商标尼斯大类,
* obj.nclSmallCodes 商标尼斯小类数组
* obj.user 用户数据
*/
async updateNclInfo(obj) {
var user = obj.user;
var app = obj.app;
var self = this;
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 tbCode = obj.tbCode;
if (!tbCode) {
return system.getResultFail(-104, "tbCode参数错误");
}
//获取商标尼斯信息
var tm = await this.dao.model.findOne({
where: { tbCode: tbCode },
raw: true
});
if (!tm || !tm.id) {
return system.getResultFail(-105, "尼斯信息不存在");
}
//获取交付单下其它商标尼斯信息
var othertm = await this.dao.model.findAll({
where: {
deliveryOrderNo: deliveryOrderNo,
tbCode: { [self.db.Op.ne]: tbCode }
},
raw: true
});
if (!obj.nclOneCodes) {
return system.getResultFail(-106, "nclOneCodes参数错误");
}
if (!obj.nclSmallCodes || obj.nclSmallCodes.length < 1) {
return system.getResultFail(-107, "nclSmallCodes参数错误");
}
if (obj.nclSmallCodes.length > 10) {
return system.getResultFail(-108, "尼斯小类不能超过10项");
}
var nclOneCodes2 = obj.nclOneCodes;
for (var i = 0; i < othertm.length; i++) {//判断重复大类
var other = othertm[i];
if (other.nclOneCodes == obj.nclOneCodes) {
return system.getResultFail(-109, "该商标存在重复的尼斯大类");
} else {
nclOneCodes2 = nclOneCodes2 + "," + other.nclOneCodes;
}
}
return await self.db.transaction(async function (t) {
var tmObj = {
id: tm.id,
nclOneCodes: obj.nclOneCodes,
nclSmallCodes: JSON.stringify(obj.nclSmallCodes),
updateuser_id: user.id,
updateuser: user.nickname
};
await self.dao.update(tmObj, t);//修改商标尼斯信息
var otpObj = {
id: ordertmproduct.id,
nclOneCodes: nclOneCodes2,
updateuser_id: user.id,
updateuser: user.nickname
};
await self.ordertmproductSve.dao.update(otpObj, t);//商标交付单 修改大类列表
var logMsg = { sourceOrderNo: deliveryOrderNo, opContent: "修改订单信息", app_id: app.id, isShow: 1 };
await self.orderflowDao.create(logMsg, t);
return system.getResultSuccess();
})
}
/**
* 接收商标回执数据
* @param {*} obj
* obj.tbCode 商标提报号,
* obj.deliveryOrderNo 交付订单号,
* obj.officialType 商标状态类型officialType,
* 1: 商标注册申请书, 2: 商标注册申请补正通知书, 3: 商标注册申请受理通知书, 4: 商标注册申请不予受理通知书,
5: 商标注册同日申请补送使用证据通知书,6: 商标注册同日申请协商通知书商标注册同日申请抽签通知书,
7: 商标驳回通知书, 8: 商标部分驳回通知书, 9: 商标注册申请初步审定公告通知书,
10: 商标异议答辩通知书, 11: 异议裁定书, 12: 纸质版商标注册证, 13: 电子版商标注册证
"dsccl": "待上传材料", "dsh": "待审核", "shbtg": "审核不通过", "ddj": "待递交",
"ydj": "已递交", "djyc": "递交异常" ,
* obj.tmRegistNum 商标注册号,
* obj.officialFileName 官文文件名称 ,
* obj.officialFileUrl 官文文件地址 ,
*/
async receiveTmOfficialData(obj) {
// return system.getResultFail(-100, "接口开发中");
// var user = obj.user;
// var app = obj.app;
var self = this;
// if(!user || !user.id){
// return system.getResultFail(-100, "未知用户");
// }
var deliveryOrderNo = obj.deliveryOrderNo;
if (!deliveryOrderNo) {
return system.getResultFail(-101, "deliveryOrderNo参数错误");
}
// 1.获取交付单信息
var ordertmproduct = await this.ordertmproductSve.dao.model.findOne({
where: { deliveryOrderNo: deliveryOrderNo },
raw: true
});
if (!ordertmproduct || !ordertmproduct.id) {
return system.getResultFail(-102, "商标交付单不存在");
}
// if(!app){
// return system.getResultFail(-103, "未知应用");
// }
var tbCode = obj.tbCode;
if (!tbCode) {
return system.getResultFail(-104, "tbCode参数错误");
}
//获取商标尼斯信息
var tm = await this.dao.model.findOne({
where: { tbCode: tbCode, deliveryOrderNo: deliveryOrderNo },
raw: true
});
if (!tm || !tm.id) {
return system.getResultFail(-105, "尼斯信息不存在");
}
return await self.db.transaction(async function (t) {
var tmObj = {
id: tm.id
};
var officialObj = {
app_id: ordertmproduct.app_id
};
if (obj.officialType) {
if (self.statusConvertJSON[obj.officialType]) {
tmObj["officialType"] = self.statusConvertJSON[obj.officialType];
officialObj["officialType"] = self.statusConvertJSON[obj.officialType];
}
}
if (obj.tmRegistNum) {
officialObj["tmRegistNum"] = obj.tmRegistNum;
tmObj["tmRegistNum"] = obj.tmRegistNum;
}
await self.dao.update(tmObj, t);//修改商标状态信息
if (officialObj["tmRegistNum"] && officialObj["officialType"]) {
if (obj.officialFileName) {
officialObj["officialFileName"] = obj.officialFileName;
}
if (obj.officialFileUrl) {
officialObj["officialFileUrl"] = obj.officialFileUrl;
}
var code = await self.getBusUid("tmoff");
officialObj["code"] = code;
await self.tmofficialDao.create(officialObj, t);
}
return system.getResultSuccess();
})
}
/**
* 辅助商标状态修改
* @param {*} obj
*/
async updateAssistTmStatus(obj) {
var self = this;
var deliveryOrderNo = obj.channelOrderNum;
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, "商标交付单不存在");
}
var tbCode = obj.proxyCode;
if (!tbCode) {
return system.getResultFail(-104, "tbCode参数错误");
}
//获取商标尼斯信息
var tm = await this.dao.model.findOne({
where: { tbCode: tbCode, deliveryOrderNo: deliveryOrderNo },
raw: true
});
if (!tm || !tm.id) {
return system.getResultFail(-105, "商标信息不存在");
}
return await self.db.transaction(async function (t) {
var tmObj = { id: tm.id };
var otp = { id: ordertmproduct.id };
if (obj.tmStatus) {
if (self.statusConvertJSON[obj.tmStatus]) {
tmObj["officialType"] = self.statusConvertJSON[obj.tmStatus];
}
if (tmObj.officialType && ",dqrfa,dsccl,dsh,ddj,ydj,ywc,".indexOf(tmObj.officialType) >= 0) {
otp["deliveryStatus"] = tmObj.officialType;
await self.ordertmproductSve.update(otp, t);
}
// {"dqrfa":"待确认方案", "dsccl": "待上传材料", "dsh": "待审核", "ddj": "待递交", "ydj": "已递交", "ywc": "已完成" },
}
if (obj.opNotes) {
tmObj["opNotes"] = obj.opNotes;
}
if (obj.submitTime) {
tmObj["submitTime"] = obj.submitTime;
}
if(obj.tmRegistNum){
tmObj["tmRegistNum"]=obj.tmRegistNum;
}
await self.dao.update(tmObj,t);//修改商标状态信息
var deliveryStatusName = uiconfig.config.pdict.official_type[tmObj.officialType];
var flowObj = {
isShow: 1,
app_id: ordertmproduct.app_id,
createuser_id: ordertmproduct.createuser_id,
sourceOrderNo: deliveryOrderNo,
opContent: "第" + tm.nclOneCodes + "类商标状态更新为【" + deliveryStatusName + "】" + obj.opNotes
};
await self.orderflowDao.create(flowObj, t);//创建交付流程
await self.dao.update(tmObj, t);//修改商标状态信息
return system.getResultSuccess();
})
}
}
module.exports = TradeMarkService;
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