904118851 1 개월 전
부모
커밋
451d749527

+ 60 - 0
match_book.json

@@ -0,0 +1,60 @@
+{
+    "apps": [
+        {
+            "name": "run_fq_iaa_match_7day",
+            "script": "./task_script/run_fq_iaa_match_7day.js",
+            "node_args": "--max-old-space-size=8192 --expose-gc",
+            "max_memory_restart": "4G",
+            "args": ["--type=data"],
+            "cwd": "/home/tg_factory",
+            "log_date_format": "YYYY-MM-DD HH:mm:ss",
+            "error_file": "./logs/MATCH_BOOK/run_fq_iaa_match_7day_error.log",
+            "out_file": "./logs/MATCH_BOOK/run_fq_iaa_match_7day_out.log",
+            "merge_logs": true,
+            "exec_mode": "fork",
+            "autorestart": true
+        },
+        {
+            "name": "run_fq_iap_match_7day",
+            "script": "./task_script/run_fq_iap_match_7day.js",
+            "node_args": "--max-old-space-size=8192 --expose-gc",
+            "max_memory_restart": "4G",
+            "args": ["--type=data"],
+            "cwd": "/home/tg_factory",
+            "log_date_format": "YYYY-MM-DD HH:mm:ss",
+            "error_file": "./logs/MATCH_BOOK/run_fq_iap_match_7day_error.log",
+            "out_file": "./logs/MATCH_BOOK/run_fq_iap_match_7day_out.log",
+            "merge_logs": true,
+            "exec_mode": "fork",
+            "autorestart": true
+        },
+        {
+            "name": "run_qm_iaa_match_7day",
+            "script": "./task_script/run_qm_iaa_match_7day.js",
+            "node_args": "--max-old-space-size=8192 --expose-gc",
+            "max_memory_restart": "4G",
+            "args": ["--type=data"],
+            "cwd": "/home/tg_factory",
+            "log_date_format": "YYYY-MM-DD HH:mm:ss",
+            "error_file": "./logs/MATCH_BOOK/run_qm_iaa_match_7day_error.log",
+            "out_file": "./logs/MATCH_BOOK/run_qm_iaa_match_7day_out.log",
+            "merge_logs": true,
+            "exec_mode": "fork",
+            "autorestart": true
+        },
+        {
+            "name": "run_qm_iap_match_7day",
+            "script": "./task_script/run_qm_iap_match_7day.js",
+            "node_args": "--max-old-space-size=8192 --expose-gc",
+            "max_memory_restart": "4G",
+            "args": ["--type=data"],
+            "cwd": "/home/tg_factory",
+            "log_date_format": "YYYY-MM-DD HH:mm:ss",
+            "error_file": "./logs/MATCH_BOOK/run_qm_iap_match_7day_error.log",
+            "out_file": "./logs/MATCH_BOOK/run_qm_iap_match_7day_out.log",
+            "merge_logs": true,
+            "exec_mode": "fork",
+            "autorestart": true
+        }
+    ]
+}

+ 10 - 0
run_match_book.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+cd /home/tg_factory
+mkdir -p logs
+chmod 755 logs
+
+sleep 1
+/home/node/node-v20.17.0-linux-x64/lib/node_modules/pm2/bin/pm2 start match_book.json
+
+# sleep 1
+# bash /home/tg_factory/MESSAGE_DISPATCH/run_py.sh

+ 0 - 1
task_script/run_all_qmmf_book_find_match_book.js

@@ -23,7 +23,6 @@ async function processTask(){
         const pageSize = 100;
         const totalPages = Math.ceil(total / pageSize);
         
-
         // 循环分页查询
         for (let page = 0; page < totalPages; page++) {
             const offset = page * pageSize;

+ 88 - 0
task_script/run_fq_iaa_match_7day.js

@@ -0,0 +1,88 @@
+//同步番茄免费的匹配书籍
+const config = require("../etc/config.json");
+const mysql = require('mysql2/promise');
+const taskdbConfig = config.isDebug?config.debug_task_mysql:config.release_task_mysql
+const redis_help = require('../src/use_redis');
+const video_product_controllers = require('../src/data_manager/Controllers/video_product_controllers');
+const helper = require("../src/helper");
+const schedule = require('node-schedule');
+const CMD = {}
+async function processTask(){
+    let right_status = true
+    let connection  = null
+    try{
+        connection = await mysql.createConnection({
+            ...taskdbConfig,
+            multipleStatements: true
+        });
+
+        const [records] = await connection.execute(
+            `SELECT * FROM video_product WHERE publish_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND publish_time <= CURDATE()
+             AND book_platform = ${config.platform_fanqiemf} AND match_book = "NONE" LIMIT 1000 ;`
+         );
+
+         if(records.length<=0){
+             console.log("完成所有番茄免费的匹配")
+             throw 0
+         }
+         for (let index = 0; index < records.length; index++) {
+            const element = records[index];
+            let iap_book_info = await require('../src/api/fq/fq_search_book').根据番茄免费ID查询付费书籍(element.product_id)
+            if(iap_book_info!=null){
+                let book_info = await video_product_controllers.getProductData({book_id:iap_book_info.book_id})
+                if(!book_info.success){
+                    //创建一个付费书籍
+                    await video_product_controllers.createProductData({
+                        book_platform:config.platform_fanqie,
+                        product_name:iap_book_info.book_name,
+                        genre:iap_book_info.genre,
+                        product_id:iap_book_info.book_id,
+                        words:iap_book_info.words,
+                        match_book:element.product_id
+                    })
+                }else{
+                    await video_product_controllers.updateData({id:book_info.data.id},{
+                        match_book:element.product_id
+                    })
+                }
+
+                await connection.execute(
+                    `UPDATE video_product 
+                    SET match_book = ?, 
+                        product_parent_id = ? 
+                    WHERE id = ?`,
+                    [iap_book_info.book_id, iap_book_info.book_id, element.id]
+                );
+            }
+        }
+
+
+    }catch(e){
+        if(e==0){
+            right_status = false
+        }
+        console.error("processTask error:",e)
+    } finally{
+        if(connection!=null){
+            connection.end()
+        }
+        if(right_status){
+            global.setTimeout(processTask, 2000);
+        }
+    }
+
+}
+
+
+CMD.init = async function(){
+    redis_help.connect((results)=>{
+        if(results){
+            const job = schedule.scheduleJob('0 08,20 * * *', async function() {
+                await  processTask();
+            });
+        }
+    })
+
+}
+
+CMD.init()

+ 88 - 0
task_script/run_fq_iap_match_7day.js

@@ -0,0 +1,88 @@
+//同步番茄付费的匹配书籍
+const config = require("../etc/config.json");
+const mysql = require('mysql2/promise');
+const taskdbConfig = config.isDebug?config.debug_task_mysql:config.release_task_mysql
+const redis_help = require('../src/use_redis');
+const video_product_controllers = require('../src/data_manager/Controllers/video_product_controllers');
+const helper = require("../src/helper");
+const schedule = require('node-schedule');
+const CMD = {}
+async function processTask(){
+    let right_status = true
+    let connection  = null
+    try{
+        connection = await mysql.createConnection({
+            ...taskdbConfig,
+            multipleStatements: true
+        });
+
+        const [records] = await connection.execute(
+            `SELECT * FROM video_product WHERE publish_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND publish_time <= CURDATE()
+             AND book_platform = ${config.platform_fanqie} AND match_book = "NONE" LIMIT 1000 ;`
+         );
+
+         if(records.length<=0){
+             console.log("完成所有番茄付费的匹配")
+             throw 0
+         }
+         for (let index = 0; index < records.length; index++) {
+            const element = records[index];
+            let iaa_book_info = await require('../src/api/fq/fq_search_book').根据番茄付费ID查询免费书籍(element.product_id)
+            if(iaa_book_info!=null){
+                let book_info = await video_product_controllers.getProductData({book_id:iaa_book_info.book_id})
+                if(!book_info.success){
+                    //创建一个免费书籍
+                    await video_product_controllers.createProductData({
+                        book_platform:config.platform_fanqiemf,
+                        product_name:iaa_book_info.book_name,
+                        genre:iaa_book_info.genre,
+                        product_id:iaa_book_info.book_id,
+                        words:iaa_book_info.words,
+                        match_book:element.product_id,
+                        product_parent_id:element.product_id
+                    })
+                }else{
+                    await video_product_controllers.updateData({id:book_info.data.id},{
+                        match_book:element.product_id
+                    })
+                }
+
+                await connection.execute(
+                    `UPDATE video_product 
+                    SET match_book = ?, 
+                    WHERE id = ?`,
+                    [iaa_book_info.book_id, element.id]
+                );
+            }
+        }
+
+
+    }catch(e){
+        if(e==0){
+            right_status = false
+        }
+        console.error("processTask error:",e)
+    } finally{
+        if(connection!=null){
+            connection.end()
+        }
+        if(right_status){
+            global.setTimeout(processTask, 2000);
+        }
+    }
+
+}
+
+
+CMD.init = async function(){
+    redis_help.connect((results)=>{
+        if(results){
+            const job = schedule.scheduleJob('0 07,19 * * *', async function() {
+                await  processTask();
+            });
+        }
+    })
+
+}
+
+CMD.init()

+ 88 - 0
task_script/run_qm_iaa_match_7day.js

@@ -0,0 +1,88 @@
+//同步七猫免费的匹配书籍
+const config = require("../etc/config.json");
+const mysql = require('mysql2/promise');
+const taskdbConfig = config.isDebug?config.debug_task_mysql:config.release_task_mysql
+const redis_help = require('../src/use_redis');
+const video_product_controllers = require('../src/data_manager/Controllers/video_product_controllers');
+const helper = require("../src/helper");
+const schedule = require('node-schedule');
+const CMD = {}
+async function processTask(){
+    let right_status = true
+    let connection  = null
+    try{
+        connection = await mysql.createConnection({
+            ...taskdbConfig,
+            multipleStatements: true
+        });
+
+        const [records] = await connection.execute(
+            `SELECT * FROM video_product WHERE publish_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND publish_time <= CURDATE()
+             AND book_platform = ${config.platform_qmmf} AND match_book = "NONE" LIMIT 1000 ;`
+         );
+
+         if(records.length<=0){
+             console.log("完成所有七猫免费的匹配")
+             throw 0
+         }
+         for (let index = 0; index < records.length; index++) {
+            const element = records[index];
+            let iap_book_info = await require('../src/api/qm/qm_search_book').根据七猫免费D查询付费书籍(element.product_id)
+            if(iap_book_info!=null){
+                let book_info = await video_product_controllers.getProductData({book_id:iap_book_info.book_id})
+                if(!book_info.success){
+                    //创建一个付费书籍
+                    await video_product_controllers.createProductData({
+                        book_platform:config.platform_qimao,
+                        product_name:iap_book_info.book_name,
+                        genre:iap_book_info.genre,
+                        product_id:iap_book_info.book_id,
+                        words:iap_book_info.words,
+                        match_book:element.product_id
+                    })
+                }else{
+                    await video_product_controllers.updateData({id:book_info.data.id},{
+                        match_book:element.product_id
+                    })
+                }
+
+                await connection.execute(
+                    `UPDATE video_product 
+                    SET match_book = ?, 
+                        product_parent_id = ? 
+                    WHERE id = ?`,
+                    [iap_book_info.book_id, iap_book_info.book_id, element.id]
+                );
+            }
+        }
+
+
+    }catch(e){
+        if(e==0){
+            right_status = false
+        }
+        console.error("processTask error:",e)
+    } finally{
+        if(connection!=null){
+            connection.end()
+        }
+        if(right_status){
+            global.setTimeout(processTask, 2000);
+        }
+    }
+
+}
+
+
+CMD.init = async function(){
+    redis_help.connect((results)=>{
+        if(results){
+            const job = schedule.scheduleJob('0 06,18 * * *', async function() {
+                await  processTask();
+            });
+        }
+    })
+
+}
+
+CMD.init()

+ 88 - 0
task_script/run_qm_iap_match_7day.js

@@ -0,0 +1,88 @@
+//同步七猫付费的匹配书籍
+const config = require("../etc/config.json");
+const mysql = require('mysql2/promise');
+const taskdbConfig = config.isDebug?config.debug_task_mysql:config.release_task_mysql
+const redis_help = require('../src/use_redis');
+const video_product_controllers = require('../src/data_manager/Controllers/video_product_controllers');
+const helper = require("../src/helper");
+const schedule = require('node-schedule');
+const CMD = {}
+async function processTask(){
+    let right_status = true
+    let connection  = null
+    try{
+        connection = await mysql.createConnection({
+            ...taskdbConfig,
+            multipleStatements: true
+        });
+
+        const [records] = await connection.execute(
+            `SELECT * FROM video_product WHERE publish_time >= DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND publish_time <= CURDATE()
+             AND book_platform = ${config.platform_qimao} AND match_book = "NONE" LIMIT 1000 ;`
+         );
+
+         if(records.length<=0){
+             console.log("完成所有七猫付费的匹配")
+             throw 0
+         }
+         for (let index = 0; index < records.length; index++) {
+            const element = records[index];
+            let iaa_book_info = await require('../src/api/qm_mf/qm_mf_search_book').根据七猫付费ID查询免费书籍(element.product_id)
+            if(iaa_book_info!=null){
+                let book_info = await video_product_controllers.getProductData({book_id:iaa_book_info.book_id})
+                if(!book_info.success){
+                    //创建一个免费书籍
+                    await video_product_controllers.createProductData({
+                        book_platform:config.platform_qmmf,
+                        product_name:iaa_book_info.book_name,
+                        genre:iaa_book_info.genre,
+                        product_id:iaa_book_info.book_id,
+                        words:iaa_book_info.words,
+                        match_book:element.product_id,
+                        product_parent_id:element.product_id
+                    })
+                }else{
+                    await video_product_controllers.updateData({id:book_info.data.id},{
+                        match_book:element.product_id
+                    })
+                }
+
+                await connection.execute(
+                    `UPDATE video_product 
+                    SET match_book = ?, 
+                    WHERE id = ?`,
+                    [iaa_book_info.book_id, element.id]
+                );
+            }
+        }
+
+
+    }catch(e){
+        if(e==0){
+            right_status = false
+        }
+        console.error("processTask error:",e)
+    } finally{
+        if(connection!=null){
+            connection.end()
+        }
+        if(right_status){
+            global.setTimeout(processTask, 2000);
+        }
+    }
+
+}
+
+
+CMD.init = async function(){
+    redis_help.connect((results)=>{
+        if(results){
+            const job = schedule.scheduleJob('0 04,16 * * *', async function() {
+                await  processTask();
+            });
+        }
+    })
+
+}
+
+CMD.init()