Commit 8e374d7d by 王悦

待审全部上架

parent 8592016f
...@@ -34,6 +34,9 @@ class ProductAPI extends APIBase { ...@@ -34,6 +34,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;
......
...@@ -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
...@@ -793,6 +815,15 @@ class TrademarktransactionService extends ServiceBase { ...@@ -793,6 +815,15 @@ class TrademarktransactionService extends ServiceBase {
} }
return err return err
} }
async allOnSale(pobj, status) {
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})
let price = item.platform_quoted_price let price = item.platform_quoted_price
...@@ -1148,3 +1179,6 @@ module.exports = TrademarktransactionService; ...@@ -1148,3 +1179,6 @@ module.exports = TrademarktransactionService;
// var a = new TrademarktransactionService(); // var a = new TrademarktransactionService();
// a.addbaseinfo([{ "code": "22426244" }, { "code": "31566397" }, { "code": "37222371" }]); // a.addbaseinfo([{ "code": "22426244" }, { "code": "31566397" }, { "code": "37222371" }]);
// a.createjsonfile(); // a.createjsonfile();
const tc = new TrademarktransactionService()
tc.consume()
\ No newline at end of file
...@@ -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": "^2.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