Commit 2593f63e by 宋毅

tj

parent f37530a5
var WEBBase = require("../../web.base");
var APIBase = require("../../api.base");
var system = require("../../../system");
class AccessAuthAPI extends WEBBase {
class AccessAuthAPI extends APIBase {
constructor() {
super();
this.utilsAuthSve = system.getObject("service.utilsSve.utilsAuthSve");
this.gatewaypushlogSve = system.getObject("service.common.gatewaypushlogSve");
this.utilsPushSve = system.getObject("service.utilsSve.utilsPushSve");
this.pushlogSve = system.getObject("service.common.pushlogSve");
this.aliclient = system.getObject("util.aliyunClient");
}
async taskAliIcapi() {
......@@ -14,6 +15,9 @@ class AccessAuthAPI extends WEBBase {
}
async taskAgainPushOneNewBusInfo(pobj, qobj, req) {//再次推送新rpc业务数据
var rtn = await this.utilsPushSve.againPushBusInfo(pobj);
if (rtn.status == 0) {
this.pushlogSve.delDbPushfaillogById(Number(pobj.id || 0));
}
return rtn;
}
async taskAgainPushOneOldBusInfo(pobj, qobj, req) {//再次推送老rpc业务数据
......
......@@ -34,6 +34,13 @@ class ProductAPI extends WEBBase {
this.utilsPushSve.pushBusInfo(pobj, "closeAliTmApply", 1);
}
break;
case "checkTmNameByAli"://检测商标名称是否合规
var pushInterfaceResult = await this.utilsOpOrderSve.getProductInterface(pobj, pobj.actionBody.product_id);
if (pushInterfaceResult.status != 0) {
pobj.actionBody.product_info.interface_info = pushInterfaceResult.data;
this.utilsPushSve.pushBusInfo(pobj, "closeAliTmApply", 1);
}
break;
case "updateContacts"://修改订单联系人
opResult = await this.utilsOpOrderSve.updateContacts(pobj, pobj.actionBody);
break;
......
......@@ -10,7 +10,7 @@ module.exports = (db, DataTypes) => {
resultInfo: DataTypes.TEXT('long'),
clientIp: DataTypes.STRING,
opTitle: DataTypes.STRING(500),
failType: DataTypes.INTEGER,//错误类型,1为old-rpc推送失败日志,2为new-rpc推送失败日志
failType: DataTypes.INTEGER,//错误类型,1为old-rpc推送失败日志,2为new-rpc推送失败日志,业务处理失败日志
pushNumber: DataTypes.INTEGER,//推送次数
}, {
paranoid: false,//假的删除
......
......@@ -44,20 +44,50 @@ class AppServiceBase {
return system.getResultSuccess();
}
async restPostUrl(pobj, url) {
var rtn = await this.restClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty");
try {
var rtn = await this.restClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "restPost data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
} catch (e) {
var errorMsg = "error:" + e.stack;
//日志记录
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "service/app.base.js/restPostUrl",
content: errorMsg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->restPostUrl",
});
return system.getResult(null, errorMsg);
}
var result = JSON.parse(rtn.stdout);
return result;
}
async execPostUrl(pobj, url) {
var rtn = await this.execClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty");
try {
var rtn = await this.execClient.execPost(pobj, url);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPost data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
} catch (e) {
var errorMsg = "error:" + e.stack;
//日志记录
this.logCtl.error({
appid: pobj.appInfo ? pobj.appInfo.uapp_id || "" : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key || "" : "",
requestId: pobj.requestId || "",
op: "service/app.base.js/restPostUrl",
content: errorMsg,
// clientIp: pobj.clientIp,
optitle: pobj.opType + "推送操作异常->restPostUrl",
});
return system.getResult(null, errorMsg);
}
var result = JSON.parse(rtn.stdout);
return result;
}
async opAliyunRpcVerifyParam(pobj) {//参数信息验证
var verify = system.getResultSuccess();
......@@ -128,6 +158,7 @@ class AppServiceBase {
}
}
async disposePushResult(pobj, result, opTitleDesc) {//处理结果信息--内部使用
var opType = pobj.opType || "";
if (result.status != 0) {
this.pushlogSve.createFailLogDb({
appid: pobj.appInfo.uapp_id,
......@@ -137,7 +168,7 @@ class AppServiceBase {
resultInfo: JSON.stringify(result),
clientIp: pobj.clientIp || "",
failType: 2,
opTitle: pobj.opType + "推送操作失败->" + opTitleDesc,
opTitle: opType + "推送操作失败->" + opTitleDesc,
pushNumber: pobj.pushNumber || 1
});
result.data = null;
......@@ -147,16 +178,24 @@ class AppServiceBase {
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
requestId: pobj.requestId || "",
op: JSON.stringify(pobj.interface_info),//推送的接口信息
op: "推送业务类型:" + opType,
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(result),
returnType: '1',
opTitle: pobj.opType + "数据推送成功->" + opTitleDesc
opTitle: opType + "数据推送成功->" + opTitleDesc
});
result.data = null;
return result;
}
async disposePushResultFail(pobj, result, opTitleDesc) {//处理失败的结果信息--内部使用
/**
* 处理失败的结果信息--内部使用
* @param {*} pobj
* @param {*} result
* @param {*} opTitleDesc
* @param {*} failType 错误类型,1为old-rpc推送失败日志,2为new-rpc推送失败日志,业务处理失败日志
*/
async disposePushResultFail(pobj, result, opTitleDesc, failType) {//处理失败的结果信息--内部使用
var opType = pobj.opType || "";
this.pushlogSve.createFailLogDb({
appid: pobj.appInfo.uapp_id,
appkey: pobj.appInfo.uapp_key,
......@@ -164,8 +203,8 @@ class AppServiceBase {
content: JSON.stringify(pobj),//推送的参数信息
resultInfo: JSON.stringify(result),
clientIp: pobj.clientIp || "",
failType: 2,
opTitle: pobj.opType + "推送操作失败->" + opTitleDesc,
failType: failType || 2,
opTitle: opType + "推送操作失败->" + opTitleDesc,
pushNumber: pobj.pushNumber || 1
});
result.data = null;
......
......@@ -41,10 +41,8 @@ class PushlogService extends ServiceBase {
});
}
}
async delDbById(id) {
var sql = "DELETE FROM `c?enter_channel_pushlog` WHERE id=:id";
// var paramWhere = { id: id ??};
this.bulkDeleteByWhere({ where: { id: id } });//customQuery(sql, paramWhere);
async delDbPushfaillogById(id) {
this.pushfaillogDao.bulkDeleteByWhere({ where: { id: id } });
}
}
module.exports = PushlogService;
......@@ -25,7 +25,13 @@ class UtilsOpOrderService extends AppServiceBase {
}
var reqUrl = this.centerOrderUrl + "opaction/opOrder/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
this.opUpdatePushInfo(result, pobj, actionBody, "pushUpdateOrderContacts");
if (result.status != 0) {
result.data = null;
return result;
}
if (result.data.orderStatus == 2) {
this.opUpdatePushInfo(result, pobj, actionBody, "pushUpdateOrderContacts");
}//状态为付款的订单进行推送
result.data = null;
return result;
}
......@@ -35,7 +41,14 @@ class UtilsOpOrderService extends AppServiceBase {
}
var reqUrl = this.centerOrderUrl + "opaction/opOrder/springBoard";
var result = await this.restPostUrl(pobj, reqUrl);
this.opUpdatePushInfo(result, pobj, "pushUpdateOrder");
if (result.status != 0) {
result.data = null;
return result;
}
if (result.data.orderStatus == 2) {
this.opUpdatePushInfo(result, pobj, "pushUpdateOrder");
this.opUpdatePushInfo(result, pobj, "updateAliTmApplicant");
}//状态为付款的订单进行推送
result.data = null;
return result;
}
......@@ -56,7 +69,6 @@ class UtilsOpOrderService extends AppServiceBase {
appInfo: pobj.appInfo,
actionBody: result.data
}
delete result.data["orderStatus"];
this.utilsPushSve.pushBusInfo(tmpPobj, opType, 1);
}
}
......
......@@ -525,6 +525,7 @@ class UtilsOrderService extends AppServiceBase {
channel_username: opOrderResult.data.order_info.channelUserId,
channel_nickname: opOrderResult.data.order_info.channelUserId
};
opOrderResult.data.orderNo = opResult.data.orderNo;
var pobj = {
appInfo: opOrderResult.data.appInfo,
actionBody: opOrderResult.data
......
......@@ -39,11 +39,9 @@ class UtilsPushService extends AppServiceBase {
if (result.status != 0) {
return result;
}
await this.pushlogSve.delDbById(Number(pobj.id || 0));
return system.getResultSuccess();
}
async reflexAction(interface_info, opType, pobj, isDelProductInfo) {
var refResult = null;
pobj.interface_info = interface_info;
......
......@@ -104,93 +104,86 @@ class UtilsTmAliyunService extends AppServiceBase {
return await this.disposePushResultFail(pobj, classificationsResult, "ali->tmCreateApplicant->classificationsResult");
}
var tmCreateResult = await this.tmCreate(pobj, tmInfo, rpcParam, picUrl, authorizationOssKey, classificationsResult, 323661);//applicantResult.data.ApplicantId);
return await this.disposePushResult(pobj, tmCreateResult, "ali->tmCreateApplicant->tmCreateResult");
}
async bindAliTmApplicantGzwtsUrl(pobj) {//绑定商标申请人信息-(绑定授权书Oss文件)
var verifyResult = await this.opAliyunRpcVerifyParam(pobj);
if (!pobj.actionBody.applicantId) {
verifyResult = system.getResult(null, "applicantId param is empty,100500");
if (tmCreateResult.status == 0) {
//保存渠道申请人数据
actionBody.ApplicantId = 323661;//applicantResult.data.ApplicantId;
actionBody.AuthorizationOssKey = authorizationOssKey;
this.addAliChannelTmApplicant(pobj, actionBody, tmCreateResult.data.orderId);
}
if (!pobj.actionBody.gzwtsUrl) {
verifyResult = system.getResult(null, "gzwtsUrl param is empty,100503");
}
var authorizationOssKey = "";
if (pobj.actionBody.gzwtsUrl) {
authorizationOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.ATTORNEY, pobj.actionBody.gzwtsUrl, rpcParam);
if (!authorizationOssKey) {
verifyResult = system.getResult(null, "gzwtsUrl ali oss upload is error,100505");
}
}
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "ali->bindAliTmApplicantGzwtsUrl->verifyResult");
}
var params = {
action: rpcParam.action,
reqbody: { ApplicantId: pobj.actionBody.applicantId, AuthorizationOssKey: authorizationOssKey },
rpcParam: rpcParam
}
var result = await this.opAliyunRpcReq(pobj, params);
return await this.disposePushResult(pobj, result, "ali->bindAliTmApplicantGzwtsUrl->result");
return await this.disposePushResult(pobj, tmCreateResult, "ali->tmCreateApplicant->tmCreateResult");
}
async updateAliTmApplicant(pobj) {//更新商标申请人信息
var verifyResult = await this.opAliyunRpcVerifyParam(pobj);
var apply = pobj.actionBody.delivery_content.apply;
var orderContact = pobj.actionBody.delivery_content.orderContact;
var apply = pobj.actionBody.apply;
if (!apply) {
verifyResult = system.getResult(null, "apply data is empty,100510");
}
var dbApplyResult = await this.getAliChannelTmDelivery(pobj);
if (dbApplyResult.status != 0) {
verifyResult = dbApplyResult;
}
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "ali->updateAliTmApplicant->verifyResult");
}
var rpcParam = verifyResult.data;
var dbApply = dbApplyResult.data.apply;
var idCardOssKey = "";
var businessLicenceOssKey = "";
var legalNoticeOssKey = "";
if (apply.customerType != "ent" && apply.identityCardPic) {
idCardOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.CARD, apply.identityCardPic, rpcParam);
if (!idCardOssKey) {
verifyResult = system.getResult(null, "identityCardPic ali oss upload is error,100512");
var authorizationOssKey = "";//授权委托书
if (verifyResult.status == 0) {
if (apply.customerType != "ent" && apply.identityCardPic) {
idCardOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.CARD, apply.identityCardPic, rpcParam);
if (idCardOssKey && idCardOssKey != dbApply.IdCardOssKey) {
dbApply.IdCardOssKey = idCardOssKey;
}
}
}
if (apply.customerType == "ent" && apply.businessLicensePic) {
businessLicenceOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.BUSINESS_LICENSE, apply.businessLicensePic, rpcParam);
if (!businessLicenceOssKey) {
verifyResult = system.getResult(null, "businessLicensePic ali oss upload is error,100514");
if (apply.customerType == "ent" && apply.businessLicensePic) {
businessLicenceOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.BUSINESS_LICENSE, apply.businessLicensePic, rpcParam);
if (businessLicenceOssKey && businessLicenceOssKey != dbApply.BusinessLicenceOssKey) {
dbApply.BusinessLicenceOssKey = businessLicenceOssKey;
}
}
}
if (apply.smwjUrl) {
legalNoticeOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.LEGAL_NOTICE, apply.smwjUrl, rpcParam);
if (!legalNoticeOssKey) {
verifyResult = system.getResult(null, "smwjUrl ali oss upload is error,100516");
if (apply.smwjUrl) {
legalNoticeOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.LEGAL_NOTICE, apply.smwjUrl, rpcParam);
if (legalNoticeOssKey && legalNoticeOssKey != dbApply.LegalNoticeOssKey) {
dbApply.LegalNoticeOssKey = legalNoticeOssKey;
}
}
if (apply.gzwtsUrl) {
authorizationOssKey = await this.getAliOssFileUrl("trade-mark-user-upload", pobj, this.aliOssFileType.ATTORNEY, apply.gzwtsUrl, rpcParam);
if (authorizationOssKey && authorizationOssKey != dbApply.AuthorizationOssKey) {
dbApply.AuthorizationOssKey = authorizationOssKey;
//绑定商标申请人信息(绑定授权书Oss文件)
var bindAliTmApplicantGzwtsUrlResult = await this.bindAliTmApplicantGzwtsUrl(pobj, rpcParam, dbApply.ApplicantId, authorizationOssKey);
if (bindAliTmApplicantGzwtsUrlResult.status != 0) {
return await this.disposePushResultFail(pobj, bindAliTmApplicantGzwtsUrlResult, "ali->bindAliTmApplicantGzwtsUrl->bindAliTmApplicantGzwtsUrlResult");
}
}
}
}
if (verifyResult.status != 0) {
return await this.disposePushResultFail(pobj, verifyResult, "ali->updateAliTmApplicant->verifyResult");
if (apply.zipCode && apply.zipCode != dbApply.ContactZipcode) {
dbApply.ContactZipcode = apply.zipCode;
}
var rpcParam = verify.data;
var actionBody = {
ApplicantId: pobj.actionBody.applicantId,//Long 是 123456 申请人ID
ContactName: orderContact.contactName || "",//String 否 张三 联系人姓名
ContactNumber: orderContact.mobile || "",//String 否 18611112222 联系人电话
ContactEmail: orderContact.email || "",//String 否 test@alibaba.com 联系人邮箱
ContactZipcode: apply.zipCode || "",//String 否 100000 联系人邮编
ContactAddress: apply.applyAddr,//String 否 北京市朝阳区绿地中心A座 联系人地址
ApplicantType: apply.customerType && apply.customerType == "ent" ? 2 : 1,//Integer 否 1 申请人类型 1, "个人";2, "企业"
ApplicantRegion: 1,//Integer 否 1 阿拉伯数字 1, "中国大陆";2, "中国香港";3, "中国澳门";4, "中国台湾";5, "国外"
ApplicantName: apply.name,//String 否 张三 申请人名称
CardNumber: apply.customerType && apply.customerType == "ent" ? apply.code : apply.identityCardNo,//String 否 123456 证件号码
Address: apply.applyAddr,//String 否 北京市朝阳区绿地中心A座 申请人地址
IdCardOssKey: idCardOssKey,//String 否 1219541161213057/card/ujd8hthwfdk.png 身份证ossKey
BusinessLicenceOssKey: businessLicenceOssKey,//String 否 1219541161213057/business_license/gmzl6cvbk48.png 营业执照ossKey
LegalNoticeOssKey: legalNoticeOssKey//String 否 1219541161213057/legal_notice/mlnpsjmaed.jpg 法律声明ossKey
if (apply.applyAddr && apply.applyAddr != dbApply.ContactAddress) {
dbApply.ContactAddress = apply.applyAddr;
}
if (apply.name && apply.name != dbApply.ApplicantName) {
dbApply.ApplicantName = apply.name;
}
if (apply.applyAddr && apply.applyAddr != dbApply.Address) {
dbApply.Address = apply.applyAddr;
}
dbApply.CardNumber = apply.customerType && apply.customerType == "ent" ? apply.code : apply.identityCardNo;//String 否 123456 证件号码
dbApply.ApplicantType = apply.customerType && apply.customerType == "ent" ? 2 : 1;//Integer 否 1 申请人类型 1, "个人";2, "企业"
// Province: apply.,//String 否 安徽省 省份
// EName: apply.,//String 否 zhang san 英文名称
// EAddress: apply.,//String 否 bei jing shi 英文地址
// Country: apply.,//String 否 2096 国家
// PassportOssKey: apply.,//String 否 1219541161213057/pass_port/gmzl16cvbk48.png 护照ossKey
// AuthorizationOssKey: apply.,//String 否 1219541161213057/attorney/gy378w6btam.jpg 授权书ossKey--联系了开发,创建申请人时不用填写,在创建商标时填写
};
// ContactName: orderContact.contactName || "",//String 否 张三 联系人姓名
// ContactNumber: orderContact.mobile || "",//String 否 18611112222 联系人电话
// ContactEmail: orderContact.email || "",//String 否 test@alibaba.com 联系人邮箱
var params = {
action: rpcParam.action,
reqbody: actionBody,
reqbody: dbApply,
rpcParam: rpcParam
}
var result = await this.opAliyunRpcReq(pobj, params);
......@@ -245,9 +238,23 @@ class UtilsTmAliyunService extends AppServiceBase {
reqbody: actionBody,
rpcParam: rpcParam
}
// var tmCreateReslut = await this.opAliyunRpcReqByPost(pobj, params);
var tmCreateReslut = await this.opAliyunRpcReq(pobj, params);
return tmCreateReslut;
// var tmCreateReslut = await this.opAliyunRpcReq(pobj, params);
// return tmCreateReslut;
return system.getResultSuccess({ "orderId": "204426185080629" });
}
async bindAliTmApplicantGzwtsUrl(pobj, rpcParam, applicantId, authorizationOssKey) {//绑定商标申请人信息-(绑定授权书Oss文件)---内部使用
if (!authorizationOssKey) {
return system.getResult(null, "gzwtsUrl param is empty,100503");
}
var params = {
action: "BindApplicant",
reqbody: { ApplicantId: applicantId, AuthorizationOssKey: authorizationOssKey },
rpcParam: rpcParam
}
//TODO:BizId-----报 BizId is mandatory for this action--BizId是此操作的强制命令
var result = await this.opAliyunRpcReq(pobj, params);
return result;
}
async getAliOssFileUrl(bucketName, pobj, fileType, selfFileUrl, rpcParam) {
var fileUrl = "";
......@@ -336,6 +343,39 @@ class UtilsTmAliyunService extends AppServiceBase {
return system.getResultSuccess(nclInfoResult.data.Classifications.Classification);
}
//-------------------------操作渠道商标信息
async addAliChannelTmApplicant(pobj, applyInfo, channelOrderNo) {//新增ali渠道商标交付信息
var tmpPobj = {
actionType: "addAliChannelTmApplicant",
appInfo: pobj.appInfo,
actionBody: { deliveryData: { apply: applyInfo }, orderNo: pobj.actionBody.orderNo, channelOrderNo: channelOrderNo }
}
var reqUrl = settings.centerOrderUrl() + "opaction/opOrder/springBoard";
var result = await this.restPostUrl(tmpPobj, reqUrl);
if (result.status != 0) {
return await this.disposePushResultFail(tmpPobj, result, "ali->tmCreateApplicant->addChannelTmApplicantResult->新增ali渠道商标交付信息失败", 3);
}
return result;
}
async getAliChannelTmDelivery(pobj) {//查询ali渠道商标交付信息
var tmpPobj = {
actionType: "getAliChannelTmDelivery",
appInfo: pobj.appInfo,
actionBody: { orderNo: pobj.actionBody.orderNo }
}
var reqUrl = settings.centerOrderUrl() + "opaction/opOrder/springBoard";
var result = await this.restPostUrl(tmpPobj, reqUrl);
if (result.status != 0) {
return await this.disposePushResultFail(tmpPobj, result, "ali->tmCreateApplicant->addChannelTmApplicantResult->查询ali渠道商标交付失败", 3);
}
return result;
}
async updateAliChannelTm(pobj) {//修改ali渠道商标信息
}
//--------------------------------------------------内部辅助方法-------------------end-----------------
}
module.exports = UtilsTmAliyunService;
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