Commit 34b3787d by 王勇飞

pp

parent 52fed0ca
const ApiBase = require("../api.base");
const System = require("../../system");
const request = require('request');
const aliyunClient = require('../../utils/aliyunClient.js');
const OplogSve = require('../../service/impl/oplogSve.js');
// let fqReqUrl = "https://yunfuapi.gongsibao.com";//线上域名
let fqReqUrl = "https://yunfuapi-dev.gongsibao.com";//dev域名
//推送联系地址等信息到阿里(每次需要推送50条)
class CustomerInfoPusherApi {
constructor() {
this.trademarkS = System.getObject("service.trademarkSve");
this.tmapplierinfoDao = System.getObject("db.tmapplierinfoDao");
this.aliyunClient = new aliyunClient();
this.oplogSve = new OplogSve();
};
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
let url = fqReqUrl + '/cloudapi/iduty/igirl/pushFollowUp';
let body = {
'order_no': order_no,
'json': oneItem
};
let res = await this.aliyunClient.postig(url, body);
console.log('推送完成--' + i, res);
//将成功结果写入到日志
await this.oplogSve.create({
logLevel: "info",
optitle: "推送商标数据至蜂擎---",
op: "app/base/api/impl/tmInfoPusherApi.js/collectInfo",
content: "参数:" + JSON.stringify(body) + "返回结果:" + JSON.stringify(res),
clientIp: ""
});
//更新isPushed字段为1
await this.trademarkS.updateIsPushed(d.id);
console.log('更新isPushed字段完成--', i);
}
return { code: 200, message: "调用推送接口成功" };
} catch (e) {
console.log('collectInfo error: ', e);
//将错误写入到日志
await this.oplogSve.create({
logLevel: "error",
optitle: "推送商标数据至蜂擎---异常",
op: "app/base/api/impl/tmInfoPusherApi.js/collectInfo",
content: JSON.stringify(e.stack),
clientIp: ""
});
return e;
}
}
}
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 CustomerInfoPusherCtl {
constructor(){
// super(CtlBase.getServiceName(TmkCtl));
// this.service=System.getObject("service.tmkSve");
this.CustomerInfoPusherApi=System.getObject("api.customerInfoPusherApi");
}
async pushInfo(obj, req){
console.log('接收到请求');
let result = await this.CustomerInfoPusherApi.collectInfo();
console.log('接口返回数据', result);
return result;
}
}
module.exports = CustomerInfoPusherCtl;
......@@ -1984,7 +1984,7 @@ class OrderService extends ServiceBase {
//将联系地址同步到该公司的其他订单数据中
async contactAddressSyncUpdate(contactAddress, mobile, applyName) {
let sql = "UPDATE h_tmcustomer_info SET contactAddress = '" + contactAddress + "' WHERE id IN (SELECT id FROM (SELECT cu.id FROM h_tmapplier_info AS ap LEFT JOIN h_tmcustomer_info AS cu ON ap.orderNum = cu.orderNum WHERE cu.mobile = '" + mobile + "' AND ap.applyName = '" + applyName + "') AS a)";
let sql = "UPDATE h_tmcustomer_info SET contactAddress = '" + contactAddress + "' , addressIsPushed = '0' WHERE id IN (SELECT id FROM (SELECT cu.id FROM h_tmapplier_info AS ap LEFT JOIN h_tmcustomer_info AS cu ON ap.orderNum = cu.orderNum WHERE cu.mobile = '" + mobile + "' AND ap.applyName = '" + applyName + "') AS a)";
let updateRes = await this.dao.customUpdate(sql);
return updateRes;
}
......
......@@ -1590,63 +1590,76 @@ class TrademarkService extends ServiceBase {
}
async queryTmInfoForPush() {
try{
try {
let sql = "SELECT id,orderNum,tmFormType,tmName,picUrl,nclOneCodes,nclSmallCodes,principal,tmRegistNum,tmStatus,tmStatusName,tmSourceTypeName,channelOrderListInfo, businessId,`updated_at`,lastUp 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) {
} catch (e) {
console.log('queryTmInfoForPush查询失败');
return e;
}
}
//联系人信息查询-tm信息推送接口
async queryTmCustomerInfoForPush(orderNum) {
try{
try {
let sql = "SELECT * FROM `h_tmcustomer_info` WHERE orderNum='" + orderNum + "';";
let customerResult = await this.dao.customQuery(sql);
return customerResult;
}catch(e) {
} catch (e) {
console.log('queryTmCustomerInfoForPush查询失败');
return e;
}
}
//联系人信息查询-联系人地址信息推送接口
async queryTmCustomerInfo(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 +"';";
try {
let sql = "SELECT * FROM `h_tm_flow` WHERE tmRegistNum='" + tmRegistNum + "';";
let tmFlowResult = await this.dao.customQuery(sql);
return tmFlowResult;
}catch(e) {
} catch (e) {
console.log('queryTmFlowInfoForPush查询失败');
return e;
}
}
async updateIsPushed(id) {
try{
let setObj = {isPushed: '1'};
let whereObj = {where: {id: id}};
try {
let setObj = { isPushed: '1' };
let whereObj = { where: { id: id } };
let tmResult = await this.dao.updateByWhere(setObj, whereObj);
return tmResult;
}catch(e) {
} catch (e) {
console.log('updateIsPushed更新失败', e);
}
}
//----------------------------------1688商标状态修改 结束----------------------------------------------------------------
async getApplyNameByChannelOrderNo(pobj){
if(!pobj || !pobj.channelOrderNo){
return {code:-100,msg:"channelOrderNo is empty!"}
async getApplyNameByChannelOrderNo(pobj) {
if (!pobj || !pobj.channelOrderNo) {
return { code: -100, msg: "channelOrderNo is empty!" }
}
var tm = await this.dao.model.findOne({
where: {channelOrderListInfo:{[this.db.Op.like]:"%" + pobj.channelOrderNo + "%" }},
attributes:["applyName"],
raw:true
where: { channelOrderListInfo: { [this.db.Op.like]: "%" + pobj.channelOrderNo + "%" } },
attributes: ["applyName"],
raw: true
});
if(tm && tm.applyName){
return {code:1,data:tm.applyName}
if (tm && tm.applyName) {
return { code: 1, data: tm.applyName }
}
return {code:-101,msg:"未知申请人"};
return { code: -101, msg: "未知申请人" };
}
}
module.exports = TrademarkService;
......
......@@ -51,6 +51,7 @@
historyOrderNum: "",
showSelectedNclList: false,
fkey: 0,
tmStatus: "",
saveDraft: false,
viewDrafts: false,
inputDraftName: '',
......@@ -370,7 +371,7 @@
} else if (!this.apply.principal) {
that.$message.warning("请选择提报类型");
return;
}
}
that.$root.showMask();
var params = this.apply.type + ";" + this.apply.applyName + ";" + this.apply.identityCard + ";" + this.form.tmFormType
+ ";" + this.form.colorizedPicUrl + ";" + this.form.picUrl + ";" + this.apply.applyAddr;
......@@ -413,6 +414,8 @@
remark: d_order.remark
};
this.tmStatus = d_tm.tmStatus;
console.log('商标状态: ', this.tmStatus);
console.log('前端打印接收后端的数据: ', JSON.stringify(d_apply));
var apply = {
......@@ -442,7 +445,7 @@
var nclOne = [];
for (var i = 0; i < d.data.tms.length; i++) {
var t = d.data.tms[i];
var nclThree = null;
var nclThree = null;
if (t.nclSmallCodes.indexOf("nclthree") < 0) {
nclThree = JSON.parse(t.nclSmallCodes);
} else {
......@@ -823,64 +826,64 @@
},
checkChannelUsableOrder(){
var order = this.order;
if(order){
if(!order.created_at || !order.orderSourceType || order.orderSourceType=='8'){
return {code:1};
if (order) {
if (!order.created_at || !order.orderSourceType || order.orderSourceType == '8') {
return { code: 1 };
}
console.log(order.created_at);
var create_date = new Date(order.created_at);
if(create_date){
if (create_date) {
var time = create_date.getTime();
console.log(time);
if(time<1576666800000){/**2019-12-18 19:00:00 之前创建的订单,不做校验 */
return {code:1};
if (time < 1576666800000) {/**2019-12-18 19:00:00 之前创建的订单,不做校验 */
return { code: 1 };
}
}
}
var usable_order_no_class_count = this.channelOrder.usable_order_no_class_count;
var usableOrderList = null;
if(usable_order_no_class_count){
usableOrderList=usable_order_no_class_count.slice(0);
if (usable_order_no_class_count) {
usableOrderList = usable_order_no_class_count.slice(0);
}
this.channelOrder.usable_order_no_class_count;
var nclOnes = this.nclOne;
if(!usableOrderList || usableOrderList.length<1){
return {code:-1,msg:"有效渠道订单为空"};
if (!usableOrderList || usableOrderList.length < 1) {
return { code: -1, msg: "有效渠道订单为空" };
}
if(!nclOnes || nclOnes.length<1){
return {code:-2,msg:"尼斯信息不能为空"};
if (!nclOnes || nclOnes.length < 1) {
return { code: -2, msg: "尼斯信息不能为空" };
}
for(var a=0;a<nclOnes.length;a++){
for (var a = 0; a < nclOnes.length; a++) {
var nclOne = nclOnes[a];
nclOne["channelOrderListInfo"]=null;
nclOne["channelOrderListInfo"] = null;
}
for(var i=0;i<nclOnes.length;i++){
for (var i = 0; i < nclOnes.length; i++) {
var nclOne = nclOnes[i];
var nclThree = nclOne.nclThree;
if(nclThree.length>10){
for(var j=0;j<usableOrderList.length;j++){
if (nclThree.length > 10) {
for (var j = 0; j < usableOrderList.length; j++) {
var usableOrder = usableOrderList[j];
if(usableOrder && usableOrder.class_count && usableOrder.class_count==nclThree.length){
if (usableOrder && usableOrder.class_count && usableOrder.class_count == nclThree.length) {
nclOne["channelOrderListInfo"] = usableOrder.order_no;
usableOrderList[j]=null;
usableOrderList[j] = null;
break;
}
}
}else{
for(var k=0;k<usableOrderList.length;k++){
} else {
for (var k = 0; k < usableOrderList.length; k++) {
var usableOrder = usableOrderList[k];
if(usableOrder && (!usableOrder.class_count || usableOrder.class_count<=10)){
if (usableOrder && (!usableOrder.class_count || usableOrder.class_count <= 10)) {
nclOne["channelOrderListInfo"] = usableOrder.order_no;
usableOrderList[k]=null;
usableOrderList[k] = null;
break;
}
}
}
if(!nclOne["channelOrderListInfo"]){
return {code:-3,msg:"建案内容与订单条件不匹配,请仔细核对!"};
if (!nclOne["channelOrderListInfo"]) {
return { code: -3, msg: "建案内容与订单条件不匹配,请仔细核对!" };
}
}
return {code:1};
return { code: 1 };
},
submitForm(formName) {
var that = this;
......@@ -892,8 +895,11 @@
return false;
}
if (!that.channelOrder.remainder || that.channelOrder.remainder < 0) {
that.$message.warning(`渠道订单产品数量异常`);
return false;
if (this.tmStatus != '12' || this.tmStatus != '13') {
that.$message.warning(`渠道订单产品数量异常`);
return false;
}
}
if (formName == "form" && that.nclOne.length < 1) {
that.$message.warning(`请选择商标分类`);
......@@ -905,7 +911,7 @@
}
if (formName == "form") {
var checkRes = that.checkChannelUsableOrder();
if(checkRes.code!=1){
if (checkRes.code != 1) {
that.$message.warning(checkRes.msg);
return false;
}
......@@ -1003,7 +1009,7 @@
},
reuseDraft: function(row) {
console.log('=========row', row.draftId, row.draftName);
this.$root.getReq("web/drafthistoryCtl/findOneDraft", {id: row.draftId}).then(d => {
this.$root.getReq("web/drafthistoryCtl/findOneDraft", { id: row.draftId }).then(d => {
console.log("findOneDraft return :", d);
var data = d.data.draftData;
if (data.checkedNcl) {
......@@ -1041,7 +1047,7 @@
});
},
updateDraft: function() {
var data = {obj: {id: '2'}, newData: {draftData: {"name": "更新测试数据"}}};
var data = { obj: { id: '2' }, newData: { draftData: { "name": "更新测试数据" } } };
this.$root.postReq("/web/drafthistoryCtl/updateDraft", data).then(d => {
console.log("updateDraft return:", d);
}).catch(e => {
......@@ -1050,12 +1056,12 @@
},
deleteDraft: function(row) {
console.log('----------', row.draftId);
var data = {id: row.draftId};
var data = { id: row.draftId };
this.$root.getReq("/web/drafthistoryCtl/deleteDraft", data).then(d => {
console.log("deleteDraft return:", d);
this.$message.success("删除成功");
this.viewDraftData.forEach((rowData, idx) => {
if(row === rowData) {
if (row === rowData) {
this.viewDraftData.splice(idx, 1);
}
});
......@@ -1064,11 +1070,11 @@
});
},
createDraft: function() {
if(!this.inputDraftName) {
if (!this.inputDraftName) {
this.$message.warning("草稿名称不能为空");
return;
};
var data = {draftName: this.inputDraftName, draftData: { checkedNcl: this.checkedNcl, form: this.form, nclOne: this.nclOne, apply: this.apply }};
var data = { draftName: this.inputDraftName, draftData: { checkedNcl: this.checkedNcl, form: this.form, nclOne: this.nclOne, apply: this.apply } };
this.$root.postReq("/web/drafthistoryCtl/createDraft", data).then(d => {
console.log("createDraft return:", d);
this.$message.success("保存草稿成功");
......
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