|
@@ -5,7 +5,12 @@ const origin_data_controllers = require('../src/data_manager/Controllers/origin_
|
|
|
const filter_data_controllers = require('../src/data_manager/Controllers/filter_data_controllers');
|
|
|
const helper = require('../src/helper');
|
|
|
async function createFilterData(result,FilterConfig) {
|
|
|
- let filter_data = filter_and_insert(result.data,FilterConfig)
|
|
|
+
|
|
|
+ let PlatformConfig = await redis_help.getKeyValue("PlatformConfig")
|
|
|
+
|
|
|
+ PlatformConfig = JSON.parse(PlatformConfig)
|
|
|
+
|
|
|
+ let filter_data = filter_and_insert(result.data,FilterConfig,PlatformConfig)
|
|
|
if(filter_data!=null){
|
|
|
filter_data.status = 0; //设置筛选的这个状态未定义
|
|
|
let res = await filter_data_controllers.createFilterData({
|
|
@@ -91,18 +96,18 @@ CMD.init = function(){
|
|
|
}
|
|
|
|
|
|
|
|
|
-function filter_and_insert(origin_data,tg_config){
|
|
|
-
|
|
|
+function filter_and_insert(origin_data,tg_config,PlatformConfig){
|
|
|
if(origin_data.guajian_link.length<=0){
|
|
|
return null
|
|
|
}
|
|
|
|
|
|
- let obj = parsePromotion(origin_data.guajian_link,tg_config.source_filter,tg_config.platform_select)
|
|
|
+ let obj = parsePromotion(origin_data.guajian_link,tg_config.source_filter,tg_config.platform_select,PlatformConfig)
|
|
|
// console.log("obj::",obj)
|
|
|
if(obj==null){
|
|
|
console.log("xml[挂件地址] error 2:",obj)
|
|
|
return null
|
|
|
}
|
|
|
+ console.log(JSON.stringify(obj))
|
|
|
// console.log("挂件地址正确")
|
|
|
if(origin_data.like_num < tg_config.like_num){
|
|
|
return null
|
|
@@ -120,15 +125,15 @@ function filter_and_insert(origin_data,tg_config){
|
|
|
return null
|
|
|
}
|
|
|
let tg_platform_id = 0
|
|
|
- if(obj.channel=="番茄"){
|
|
|
+ if(obj.channel==2){ //"番茄"
|
|
|
tg_platform_id = 2
|
|
|
obj.book_id = obj.key
|
|
|
- }else if(obj.channel=="黑岩"){
|
|
|
+ }else if(obj.channel==1){ //"黑岩"
|
|
|
tg_platform_id = 1
|
|
|
- }else if(obj.channel=="七猫"){
|
|
|
+ }else if(obj.channel==3){ //"七猫"
|
|
|
tg_platform_id = 3
|
|
|
obj.book_id = obj.id
|
|
|
- }else if(obj.channel=="点众"){
|
|
|
+ }else if(obj.channel==4){ //"点众"
|
|
|
tg_platform_id = 4
|
|
|
obj.book_id = obj.book_id
|
|
|
}
|
|
@@ -137,42 +142,62 @@ function filter_and_insert(origin_data,tg_config){
|
|
|
like_num:origin_data.like_num,kepp_num:origin_data.kepp_num ,shared_num:origin_data.shared_num,comment_num:origin_data.comment_num,tg_platform_id:tg_platform_id}
|
|
|
}
|
|
|
|
|
|
-function getChannel(start_page,platform_select,promotion){
|
|
|
+function getChannel(start_page,platform_select,promotion,PlatformConfig){
|
|
|
let isOpenHeiYan = false
|
|
|
let isOpenFanQie = false
|
|
|
let isOpenQiMao = false
|
|
|
let isOpenDianZhong = false
|
|
|
+ let kv = new Map()
|
|
|
+
|
|
|
+
|
|
|
+ for (let index = 0; index < PlatformConfig.length; index++) {
|
|
|
+ const platform_info = PlatformConfig[index];
|
|
|
+ kv.set(platform_info.tg_platform_id,false)
|
|
|
+ }
|
|
|
+
|
|
|
for (let index = 0; index < platform_select.length; index++) {
|
|
|
const element = platform_select[index];
|
|
|
if(element==1){
|
|
|
isOpenHeiYan = true
|
|
|
+ kv.set(element,true)
|
|
|
}
|
|
|
if(element==2){
|
|
|
isOpenFanQie = true
|
|
|
+ kv.set(element,true)
|
|
|
}
|
|
|
if(element==3){
|
|
|
isOpenQiMao = true
|
|
|
+ kv.set(element,true)
|
|
|
}
|
|
|
if(element==4){
|
|
|
isOpenDianZhong = true
|
|
|
+ kv.set(element,true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // console.log("PlatformConfig:",PlatformConfig,kv)
|
|
|
+ for (let index = 0; index < PlatformConfig.length; index++) {
|
|
|
+ const platform_info = PlatformConfig[index];
|
|
|
+ if(helper.checkChannel(promotion,platform_info.filter_guajian_logic)&&kv.get(platform_info.tg_platform_id)){
|
|
|
+ return platform_info.tg_platform_id
|
|
|
}
|
|
|
}
|
|
|
+ return null
|
|
|
// console.log("start_page:",isOpenHeiYan,isOpenFanQie,start_page)
|
|
|
- if(start_page=="pages/readPage/chapter?bookId"&&isOpenHeiYan){
|
|
|
+ if(helper.checkChannel(promotion,'pages/readPage/chapter')&&isOpenHeiYan){ //start_page=="pages/readPage/chapter?bookId"
|
|
|
return "黑岩"
|
|
|
- }else if(start_page=="pages/bookstore/index?aid"&&isOpenFanQie){
|
|
|
+ }else if(helper.checkChannel(promotion,'pages/bookstore/index')&&isOpenFanQie){ //start_page=="pages/bookstore/index?aid"
|
|
|
return "番茄"
|
|
|
- }
|
|
|
- else if(start_page=="pages/reader/index?bookId"&&isOpenDianZhong){ //点众
|
|
|
+ }else if(helper.checkChannel(promotion,'pages/reader/index?bookId=')&&isOpenDianZhong){ //点众 //start_page=="pages/reader/index?bookId"
|
|
|
return "点众"
|
|
|
- }else if(helper.checkChannel(promotion,'&channel=rd')&&isOpenQiMao){ //七猫
|
|
|
+ }else if(helper.checkChannel(promotion,'channel=rd')&&isOpenQiMao){ //七猫
|
|
|
return "七猫"
|
|
|
}
|
|
|
return null
|
|
|
}
|
|
|
|
|
|
//解析挂件
|
|
|
-function parsePromotion(promotion,source_list,platform_select){
|
|
|
+function parsePromotion(promotion,source_list,platform_select,PlatformConfig){
|
|
|
let list = promotion.split('&')
|
|
|
if(list.length!=undefined){
|
|
|
if(list.length>2){
|
|
@@ -187,7 +212,7 @@ function parsePromotion(promotion,source_list,platform_select){
|
|
|
params[obj.key] = obj.value
|
|
|
}
|
|
|
}
|
|
|
- let channel = getChannel(params['start_page'],platform_select,promotion)
|
|
|
+ let channel = getChannel(params['start_page'],platform_select,promotion,PlatformConfig)
|
|
|
// console.log("source_list:",source_list,platform_select,channel,params['start_page'])
|
|
|
if(channel!=null){
|
|
|
let item_info = {}
|