Commit 87144ef2 by 蒋勇

alionlines

parents 769cbc17 b600eb45
...@@ -25,6 +25,9 @@ class ProductAPI extends APIBase { ...@@ -25,6 +25,9 @@ class ProductAPI extends APIBase {
case "tmBatchUpload": // 2020 0901 lin 新增 标源批传 case "tmBatchUpload": // 2020 0901 lin 新增 标源批传
opResult = await this.trademarkTransactionSve.tmBatchUpload(pobj, pobj.actionBody); opResult = await this.trademarkTransactionSve.tmBatchUpload(pobj, pobj.actionBody);
break; break;
case "tmAddUpload": // 2020 0901 lin 新增 标源批传
opResult = await this.trademarkTransactionSve.tmAddUpload(pobj, pobj.actionBody);
break;
case "tmInfo": // 2020 0903 lin 新增 标原管理 case "tmInfo": // 2020 0903 lin 新增 标原管理
opResult = await this.trademarkTransactionSve.tmInfo(pobj, pobj.actionBody); opResult = await this.trademarkTransactionSve.tmInfo(pobj, pobj.actionBody);
break; break;
...@@ -34,6 +37,9 @@ class ProductAPI extends APIBase { ...@@ -34,6 +37,9 @@ class ProductAPI extends APIBase {
case "forceUpdate": case "forceUpdate":
opResult = await this.trademarkTransactionSve.forceUpdate(pobj, pobj.actionBody); opResult = await this.trademarkTransactionSve.forceUpdate(pobj, pobj.actionBody);
break; break;
case "allOnSale":
opResult = await this.trademarkTransactionSve.allOnSale(pobj, pobj.actionBody);
break;
case "tmListInfo": // 2020 0903 lin 新增 标原管理 case "tmListInfo": // 2020 0903 lin 新增 标原管理
opResult = await this.trademarkTransactionSve.tmListInfo(pobj, pobj.actionBody); opResult = await this.trademarkTransactionSve.tmListInfo(pobj, pobj.actionBody);
break; break;
......
...@@ -73,6 +73,8 @@ module.exports = (db, DataTypes) => { ...@@ -73,6 +73,8 @@ module.exports = (db, DataTypes) => {
type: DataTypes.STRING, //转让类型 type: DataTypes.STRING, //转让类型
reason: DataTypes.STRING, //转让原因 reason: DataTypes.STRING, //转让原因
fail_reason: DataTypes.STRING, //失败原因 fail_reason: DataTypes.STRING, //失败原因
TradeTmDetailJson: DataTypes.JSON,
TmType: DataTypes.STRING, // 商标标签: NORMAL: 普通标 (不传默认普通) STORY:故事商标 BARGAIN:特价 SELECTED:甄选
}, { }, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
......
...@@ -2,7 +2,7 @@ const system = require("../system"); ...@@ -2,7 +2,7 @@ const system = require("../system");
const moment = require('moment') const moment = require('moment')
const axios = require('axios'); const axios = require('axios');
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const md5 = require("MD5"); const md5 = require("md5");
class AppServiceBase { class AppServiceBase {
constructor() { constructor() {
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
......
...@@ -4,11 +4,33 @@ const ServiceBase = require("../../sve.base"); ...@@ -4,11 +4,33 @@ const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings"); var settings = require("../../../../config/settings");
var {reqbyget,buildobj} = require("../../../utils/aliClient"); var {reqbyget,buildobj} = require("../../../utils/aliClient");
var fs = require('fs'); var fs = require('fs');
const amqp = require('amqplib');
const queName = 'tm-audit-onsale'
let Channel
const mq_url = 'amqp://zhichan:gsbMQ2020@123.57.217.203:30672/'
class TrademarktransactionService extends ServiceBase { class TrademarktransactionService extends ServiceBase {
constructor() { constructor() {
super("tm", ServiceBase.getDaoName(TrademarktransactionService)); super("tm", ServiceBase.getDaoName(TrademarktransactionService));
this.ossClient = system.getObject("util.ossClient"); this.ossClient = system.getObject("util.ossClient");
} }
async consume() {
if (!Channel) {
const conn = await amqp.connect(mq_url);
Channel = await conn.createChannel()
Channel.assertQueue(queName, {durable: true});
Channel.prefetch(1);
console.log("开始接收队列消息");
Channel.consume(queName, async (msg) => {
const data = JSON.parse(msg.content.toString())
try {
await this.updateAlistatus(data,"ON_SALE")
Channel.ack(msg)
}catch (e){
Channel.nack(msg)
}
}, {noAck: false});
}
}
/** /**
* 用户获取业务申请实体列表 * 用户获取业务申请实体列表
* @param {*} pobj * @param {*} pobj
...@@ -282,7 +304,7 @@ class TrademarktransactionService extends ServiceBase { ...@@ -282,7 +304,7 @@ class TrademarktransactionService extends ServiceBase {
} }
} }
// 2020 0910 lin 新增 platform_quoted_price = business_quoted_price * 1.2 + 1000 // 2020 0910 lin 新增 platform_quoted_price = business_quoted_price * 1.2 + 1000
objlist[i].platform_quoted_price = Number(objlist[i].business_quoted_price) * 1.2 + 1000; objlist[i].platform_quoted_price = objlist[i].platform_quoted_price || (Number(objlist[i].business_quoted_price) * 1.2 + 1000);
var boo = isNaN(objlist[i].platform_quoted_price); var boo = isNaN(objlist[i].platform_quoted_price);
if(boo) { if(boo) {
failCount++; failCount++;
...@@ -299,7 +321,33 @@ class TrademarktransactionService extends ServiceBase { ...@@ -299,7 +321,33 @@ class TrademarktransactionService extends ServiceBase {
} }
return system.getResultSuccess(data); return system.getResultSuccess(data);
} }
//甄选特价品牌商标的上传
async tmAddUpload(pobj, actionbody) {
if (!pobj || !actionbody) {
return system.getResultFail(-101, "actionBody is empty");
}
let objlist = await this.addbaseinfo([actionbody]);
let res
let err
for (var i = 0; i < objlist.length; i++) {
// 2020 0910 lin 新增 platform_quoted_price = business_quoted_price * 1.2 + 1000
objlist[i].platform_quoted_price = Number(objlist[i].business_quoted_price) * 1.2 + 1000;
delete objlist[i].publish_status
delete objlist[i].publish_status_name
if (objlist[i].id)
await this.dao.updateByWhere(objlist[i], {where: {id: objlist[i].id}})
else{
let alires = await this.queryAlistatus(objlist[i].code)
if (alires.status === 1 && alires.trademarks[0].TmType === "NORMAL") {
res = await this.dao.findOne({code: objlist[i].code, publish_status: "uppershelf"})
await res.update(objlist[i])
}else
res = await this.dao.create(objlist[i]);
}
err = await this.updateAlistatus([objlist[i].id||res.id],"ON_SALE")
}
return system.getResult(!err,err);
}
/** /**
* @api {post} /tmtransaction/action/trademarktransaction/springBoard 标原列表 * @api {post} /tmtransaction/action/trademarktransaction/springBoard 标原列表
* @apiGroup 标源管理 * @apiGroup 标源管理
...@@ -386,8 +434,8 @@ class TrademarktransactionService extends ServiceBase { ...@@ -386,8 +434,8 @@ class TrademarktransactionService extends ServiceBase {
var countObj = { }; var countObj = { };
var whereObj = { }; var whereObj = { };
if (ab.excelName) {// 商标名称 if (ab.excelName) {// 商标名称
whereObj["excelName"] = { [this.db.Op.like]: "%" + ab.name + "%" }; whereObj["excelName"] = { [this.db.Op.like]: "%" + ab.excelName + "%" };
countObj["excelName"] = { [this.db.Op.like]: "%" + ab.name + "%" }; countObj["excelName"] = { [this.db.Op.like]: "%" + ab.excelName + "%" };
} }
if (ab.code) {// 申请号 if (ab.code) {// 申请号
whereObj["code"] = { [this.db.Op.like]: "%" + ab.code + "%" }; whereObj["code"] = { [this.db.Op.like]: "%" + ab.code + "%" };
...@@ -407,8 +455,16 @@ class TrademarktransactionService extends ServiceBase { ...@@ -407,8 +455,16 @@ class TrademarktransactionService extends ServiceBase {
countObj["id"] = { [this.db.Op.in]: ab.tmList }; countObj["id"] = { [this.db.Op.in]: ab.tmList };
} }
if (ab.publish_status) {// publish_status if (ab.publish_status) {// publish_status
whereObj["publish_status"] = ab.publish_status; whereObj["publish_status"] = {$in:ab.publish_status};
countObj["publish_status"] = ab.publish_status; countObj["publish_status"] = {$in:ab.publish_status};
}
if (ab.TmType) {// publish_status
whereObj["TmType"] = {$in:ab.TmType};
countObj["TmType"] = {$in:ab.TmType};
}
if (ab.ncl_one_code) {
whereObj["ncl_one_code"] = {$in: ab.ncl_one_code};
countObj["ncl_one_code"] = {$in: ab.ncl_one_code};
} }
var count = await this.dao.findCount({ where: countObj }); var count = await this.dao.findCount({ where: countObj });
var list = await this.dao.model.findAll({ var list = await this.dao.model.findAll({
...@@ -424,7 +480,8 @@ class TrademarktransactionService extends ServiceBase { ...@@ -424,7 +480,8 @@ class TrademarktransactionService extends ServiceBase {
"contacts",//联系人 "contacts",//联系人
"mobile",//联系电话 "mobile",//联系电话
"name",//商标名称 "name",//商标名称
"trademark_type_name", "TmType",
"TradeTmDetailJson",
"ncl_one_code", "ncl_one_code",
"channel_name", "channel_name",
"tm_applier", "tm_applier",
...@@ -441,6 +498,21 @@ class TrademarktransactionService extends ServiceBase { ...@@ -441,6 +498,21 @@ class TrademarktransactionService extends ServiceBase {
}); });
console.log(list); console.log(list);
var result = system.getResultSuccess(list); var result = system.getResultSuccess(list);
for (let i = 0; i < list.length; i++) {
if (list[i].TmType!=="NORMAL"){
let data = await this.queryAlistatus(list[i].code)
if (data.status===1){
list[i].publish_status="ON_SALE"
list[i].publish_status_name="在售"
this.dao.updateByWhere(list[i], {where: {id: list[i].id}})
}else if (data.status===0){
list[i].fail_reason = data.fail_reason
list[i].publish_status = "failali"
list[i].publish_status_name = "阿里审核失败"
this.dao.updateByWhere(list[i], {where: {id: list[i].id}})
}
}
}
result.totalCount = count; result.totalCount = count;
return result; return result;
} }
...@@ -715,11 +787,19 @@ class TrademarktransactionService extends ServiceBase { ...@@ -715,11 +787,19 @@ class TrademarktransactionService extends ServiceBase {
async updateAlistatus(ids, status) { async updateAlistatus(ids, status) {
let res = await this.dao.model.findAll({where: {id: {$in: ids}}}) let res = await this.dao.model.findAll({where: {id: {$in: ids}}})
let err
for (const item of res) { for (const item of res) {
let obj = buildobj(item,status) let obj = buildobj(item,status)
if (obj) { if (obj) {
let err = await reqbyget({ let action = "UpdateTrademarkOnsale"
action:item.publish_status==="audit"?"UploadTrademarkOnSale":"UpdateTrademarkOnsale", if (["audit","fail"].includes(item.publish_status))
action = "UploadTrademarkOnSale"
if (item.fail_reason === "商标属于当前用户,不需要发起强制操作")
action = "UpdateTrademarkOnsale"
/*if (item.TmType !== "NORMAL"&&item.publish_status==="fail")
action = "UpdateTrademarkOnsale"*/
err = await reqbyget({
action,
reqbody: obj reqbody: obj
}) })
await this.sleep() await this.sleep()
...@@ -728,12 +808,30 @@ class TrademarktransactionService extends ServiceBase { ...@@ -728,12 +808,30 @@ class TrademarktransactionService extends ServiceBase {
item.publish_status = "fail" item.publish_status = "fail"
item.publish_status_name = "发布失败" item.publish_status_name = "发布失败"
}else { }else {
item.publish_status = status ==="ON_SALE"?"uppershelf":"lowershelf" if (item.TmType === "NORMAL") {
item.publish_status_name = status ==="ON_SALE"?"在售":"下架" item.publish_status = status === "ON_SALE" ? "uppershelf" : "lowershelf"
item.publish_status_name = status === "ON_SALE" ? "在售" : "下架"
}else {
item.publish_status = status === "ON_SALE" ? "auditali" : "lowershelf"
item.publish_status_name = status === "ON_SALE" ? "待阿里审核" : "下架"
}
} }
item.save() item.save()
} }
} }
return err
}
async allOnSale(pobj, status) {
let ok = await Channel.assertQueue(queName, {durable: true})
if (ok.messageCount === 0) {
let res = await this.dao.model.findAll({where: {publish_status: "audit"}})
while (res.length > 0) {
let push_data = res.splice(0, 100)
let ids = push_data.map(ite => ite.id)
Channel.sendToQueue(queName, Buffer.from(JSON.stringify(ids)), {persistent: true});
}
}
return system.getResultSuccess()
} }
async forceUpdate(pobj, status) { async forceUpdate(pobj, status) {
let item = await this.dao.findOne({id:pobj.actionBody.id}) let item = await this.dao.findOne({id:pobj.actionBody.id})
...@@ -809,8 +907,11 @@ class TrademarktransactionService extends ServiceBase { ...@@ -809,8 +907,11 @@ class TrademarktransactionService extends ServiceBase {
if (!pobj || !pobj.actionBody) { if (!pobj || !pobj.actionBody) {
return system.getResultFail(-106, "actionBody is empty"); return system.getResultFail(-106, "actionBody is empty");
} }
var res = await this.dao.update(actionBody) await this.dao.update(actionBody)
return system.getResultSuccess(res); let err
// if (actionBody.publish_status === "uppershelf")
err = await this.updateAlistatus([actionBody.id],"ON_SALE")
return system.getResult(!err,err);
} }
/** /**
...@@ -1088,7 +1189,12 @@ module.exports = TrademarktransactionService; ...@@ -1088,7 +1189,12 @@ module.exports = TrademarktransactionService;
// a.addbaseinfo([{ "code": "22426244" }, { "code": "31566397" }, { "code": "37222371" }]); // a.addbaseinfo([{ "code": "22426244" }, { "code": "31566397" }, { "code": "37222371" }]);
// a.createjsonfile(); // a.createjsonfile();
<<<<<<< HEAD
// (async ()=>{ // (async ()=>{
// })() // })()
=======
const tc = new TrademarktransactionService()
tc.consume()
>>>>>>> b600eb4509e728617354a1af84158ca0507498d4
...@@ -2,7 +2,7 @@ const system = require("../system"); ...@@ -2,7 +2,7 @@ const system = require("../system");
const moment = require('moment') const moment = require('moment')
const settings = require("../../config/settings"); const settings = require("../../config/settings");
const axios = require('axios'); const axios = require('axios');
const md5 = require("MD5"); const md5 = require("md5");
class ServiceBase { class ServiceBase {
constructor(gname, daoName) { constructor(gname, daoName) {
this.execClient = system.getObject("util.execClient"); this.execClient = system.getObject("util.execClient");
......
...@@ -11,7 +11,11 @@ getAliTMClient = () => { ...@@ -11,7 +11,11 @@ getAliTMClient = () => {
} }
//阿里接口 //阿里接口
<<<<<<< HEAD
exports.reqbyget = async (obj,method='GET') => { exports.reqbyget = async (obj,method='GET') => {
=======
exports.reqbyget = async (obj,rt) => {
>>>>>>> b600eb4509e728617354a1af84158ca0507498d4
var action = obj.action; var action = obj.action;
var reqbody = obj.reqbody; var reqbody = obj.reqbody;
try { try {
...@@ -26,11 +30,17 @@ exports.reqbyget = async (obj,method='GET') => { ...@@ -26,11 +30,17 @@ exports.reqbyget = async (obj,method='GET') => {
method: method, // set the http method, default is GET method: method, // set the http method, default is GET
headers: {}, // set the http request headers headers: {}, // set the http request headers
}); });
<<<<<<< HEAD
console.log(JSON.stringify(res)) console.log(JSON.stringify(res))
return res return res
// console.log(obj.reqbody.tmNumber,"---",obj.reqbody.tmName,"---","成功"); // console.log(obj.reqbody.tmNumber,"---",obj.reqbody.tmName,"---","成功");
=======
console.log(res);
if (rt)
return res
>>>>>>> b600eb4509e728617354a1af84158ca0507498d4
} catch (e) { } catch (e) {
// console.log(obj.reqbody.tmNumber,"---",obj.reqbody.tmName,"---",e.data.Message); console.log(e);
return e.data.Message return e.data.Message
} }
} }
...@@ -43,7 +53,7 @@ exports.buildobj=(sqlobj,status)=>{ ...@@ -43,7 +53,7 @@ exports.buildobj=(sqlobj,status)=>{
return null return null
if (sqlobj.ncl_one_code.length===1) if (sqlobj.ncl_one_code.length===1)
nclcode = "0"+nclcode nclcode = "0"+nclcode
return { let data = {
"beginTime": 1574388139000, "beginTime": 1574388139000,
"classificationCode":nclcode, "classificationCode":nclcode,
"description": JSON.parse(sqlobj.tm_ncl_third).join(","), "description": JSON.parse(sqlobj.tm_ncl_third).join(","),
...@@ -61,6 +71,11 @@ exports.buildobj=(sqlobj,status)=>{ ...@@ -61,6 +71,11 @@ exports.buildobj=(sqlobj,status)=>{
"tmName": sqlobj.name, "tmName": sqlobj.name,
"tmNumber": sqlobj.code "tmNumber": sqlobj.code
} }
if (sqlobj.TmType !== "NORMAL"){
data.TmType = sqlobj.TmType
data.TradeTmDetailJson = JSON.stringify(sqlobj.TradeTmDetailJson)
}
return data
}catch (e){ }catch (e){
return null return null
} }
......
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@alicloud/pop-core": "^1.7.7", "@alicloud/pop-core": "^1.7.7",
"MD5": "^1.3.0",
"after": "^0.8.2", "after": "^0.8.2",
"ali-oss": "^4.12.2", "ali-oss": "^4.12.2",
"aliyun-api-gateway": "^1.1.6", "aliyun-api-gateway": "^1.1.6",
"amqplib": "^0.8.0",
"axios": "^0.19.2", "axios": "^0.19.2",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"base64id": "^1.0.0", "base64id": "^1.0.0",
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
"express-session": "^1.15.6", "express-session": "^1.15.6",
"gm": "^1.23.1", "gm": "^1.23.1",
"marked": "^0.7.0", "marked": "^0.7.0",
"md5": "^2.3.0",
"method-override": "^2.3.10", "method-override": "^2.3.10",
"morgan": "^1.9.0", "morgan": "^1.9.0",
"multer": "^1.3.0", "multer": "^1.3.0",
......
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