Commit d1f3bd7b by 王勇飞

pp

parent 26d28db6
const ApiBase = require("../api.base");
const System = require("../../system");
const request = require('request');
const fs = require('fs');
// this.fqReqUrl = "https://yunfuapi.gongsibao.com";//线上域名
let fqReqUrl = "https://yunfuapi-dev.gongsibao.com";//dev域名
//推送tm等信息到指定接口(每回需要推送200条)
class TmInfoPusherApi {
constructor() {
this.trademarkS = System.getObject("service.trademarkSve");
this.tmapplierinfoDao = System.getObject("db.tmapplierinfoDao");
};
async collectInfo() {
try{
//根据状态判断获取商标数据、根据商标数据获取申请人信息、联系人信息、官文信息
//获取商标数据
let resultTm = await this.trademarkS.queryTmInfoForPush();
console.log('请求推送的数据成功:', resultTm.length);
let oneItem = {};
for(let i=0;i<resultTm.length;i++) {
let d = resultTm[i];
let orderNum = d.orderNum;
let tmRegistNum = d.tmRegistNum;
let order_no = d.channelOrderListInfo;
oneItem.tm = d;
//商标状态
oneItem.tmStatusName = d.tmStatusName;
//获取商标申请人信息
let tmapplierSql = "SELECT * FROM `h_tmapplier_info` WHERE orderNum='" + orderNum + "';";
let resultApplier = await this.tmapplierinfoDao.customQuery(tmapplierSql);
oneItem.tmApplier = resultApplier[0];
//获取联系人信息
let resultTmCustomer = await this.trademarkS.queryTmCustomerInfoForPush(orderNum);
oneItem.tmCustomer = resultTmCustomer[0];
//获取官文信息, 一对多的关系,所以传入list
let resultTmFlow = await this.trademarkS.queryTmFlowInfoForPush(tmRegistNum);
oneItem.tmFlow = resultTmFlow;
console.log('收集商标信息完成--', i);
//调用推送接口推送oneItem
var options = {
'method': 'POST',
'url': fqReqUrl + ':/cloudapi/iduty/igirl/pushFollowUp',
'headers': {
},
body: JSON.stringify({
'order_no': order_no,
'json': oneItem
})
};
let res = await this.reqPost(options);
console.log('推送完成--' + i, res);
//更新isPushed字段为1
await this.trademarkS.updateIsPushed(d.id);
console.log('更新isPushed字段完成--', i);
}
return {code: 200, message: "调用推送接口成功"};
}catch(e) {
console.log('collectInfo error: ', e);
return e;
}
}
async reqPost(options) {
return new Promise((resolve, reject)=>{
request(options, (e, response, body) => {
if(e) {
console.log('请求igirl接口错误:', e);
reject(e);
}
return resolve(body);
});
})
}
}
module.exports = TmInfoPusherApi;
\ No newline at end of file
var System=require("../../system");
var settings=require("../../../config/settings");
const CtlBase = require("../ctl.base");
const uuidv4 = require('uuid/v4');
class TmInfoPusherCtl {
constructor(){
// super(CtlBase.getServiceName(TmkCtl));
// this.service=System.getObject("service.tmkSve");
this.TmInfoPusherApi=System.getObject("api.tmInfoPusherApi");
}
async pushInfo(obj, req){
console.log('接收到请求');
let result = await this.TmInfoPusherApi.collectInfo();
console.log('接口返回数据', result);
return result;
}
}
module.exports = TmInfoPusherCtl;
...@@ -119,6 +119,7 @@ module.exports = (db, DataTypes) => { ...@@ -119,6 +119,7 @@ module.exports = (db, DataTypes) => {
nclCount: DataTypes.INTEGER, nclCount: DataTypes.INTEGER,
nclPublicExpense: DataTypes.DECIMAL(12, 2), nclPublicExpense: DataTypes.DECIMAL(12, 2),
principal: DataTypes.STRING(100),//提报主体 principal: DataTypes.STRING(100),//提报主体
isPushed: DataTypes.INTEGER,//是否推送(0:未推送,1:已推送)
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
...@@ -1589,6 +1589,50 @@ class TrademarkService extends ServiceBase { ...@@ -1589,6 +1589,50 @@ class TrademarkService extends ServiceBase {
} }
} }
async queryTmInfoForPush() {
try{
let sql = "SELECT id,orderNum,tmFormType,tmName,picUrl,nclOneCodes,nclSmallCodes,principal,tmRegistNum,tmStatus,tmStatusName,tmSourceTypeName,channelOrderListInfo,`updated_at` FROM `h_trade_mark` WHERE channelOrderListInfo NOT LIKE '%,%' AND channelOrderListInfo NOT LIKE '%,%' AND channelOrderListInfo IS NOT NULL AND channelOrderListInfo !='' AND isPushed!=1 LIMIT 200;";
let tmResult = await this.dao.customQuery(sql);
return tmResult;
}catch(e) {
console.log('queryTmInfoForPush查询失败');
return e;
}
}
async queryTmCustomerInfoForPush(orderNum) {
try{
let sql = "SELECT * FROM `h_tmcustomer_info` WHERE orderNum='" + orderNum + "';";
let customerResult = await this.dao.customQuery(sql);
return customerResult;
}catch(e) {
console.log('queryTmCustomerInfoForPush查询失败');
return e;
}
}
async queryTmFlowInfoForPush(tmRegistNum) {
try{
let sql = "SELECT * FROM `h_tm_flow` WHERE tmRegistNum='" + tmRegistNum +"';";
let tmFlowResult = await this.dao.customQuery(sql);
return tmFlowResult;
}catch(e) {
console.log('queryTmFlowInfoForPush查询失败');
return e;
}
}
async updateIsPushed(id) {
try{
let setObj = {isPushed: '1'};
let whereObj = {where: {id: id}};
let tmResult = await this.dao.updateByWhere(setObj, whereObj);
return tmResult;
}catch(e) {
console.log('updateIsPushed更新失败', e);
}
}
//----------------------------------1688商标状态修改 结束---------------------------------------------------------------- //----------------------------------1688商标状态修改 结束----------------------------------------------------------------
} }
......
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