123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- // const video_product_controllers = require('./src/data_manager/Controllers/video_product_controllers');
- const config = require("./etc/config.json")
- const redis_help = require('./src/use_redis');
- const mysql = require('mysql2/promise');
- const tools = require('./tools');
- const TaskdbConfig = config.isDebug?config.debug_task_mysql:config.release_task_mysql
- const dbConfig = config.isDebug?config.debug_mysql:config.release_mysql
- const CMD = {}
- async function processTask(){
- let connection = null
- let connection2 = null
- try{
- connection = await mysql.createConnection({
- ...TaskdbConfig,
- multipleStatements: true
- });
- connection2 = await mysql.createConnection({
- ...dbConfig,
- multipleStatements: true
- });
- let [rows] = await connection.execute('SELECT * FROM video_product WHERE publish_time IS NULL LIMIT 100')
- if(rows.length>0){
- for (let index = 0; index < rows.length; index++) {
- const element = rows[index];
- let [info] = await connection2.execute(`SELECT * FROM fq_dj_lib WHERE book_id = ${element.product_id} LIMIT 1`)
- let start_chapter = await require("./5_CREATE_LINK_FACTORY/fq_create_link").get_tui_jian_start_chapter(element.product_id)
- await new Promise(resolve => setTimeout(resolve,500));
- if(info.length>0&&start_chapter!=-1){
- start_chapter = start_chapter==null?10:start_chapter
- console.log("info[0].publish_time:",info[0].publish_time,start_chapter,element.product_id)
- await connection.execute(
- `UPDATE video_product
- SET publish_time = ?, start_chapter = ?
- WHERE id = ?`,
- [
- new Date(info[0].publish_time), // 自动转换为 MySQL 支持的日期格式
- start_chapter,
- element.id
- ]
- );
- }else{
- if(start_chapter==-1){
- await connection.execute(
- `DELETE from video_product
- WHERE id = ?`,
- [
- element.id
- ]
- );
- }
- if(info.length<=0){
- let book_info = await require("./src/api/fq/fq_search_book").new_search_id(element.product_id)
- if(book_info.code ==0 ){
- if(book_info.data.total>0){
- let item = book_info.data.data[0]
- const values = [
- [
- item.book_id,
- item.series_name,
- item.amount_limit_status,
- item.book_pool,
- item.category,
- item.category_text,
- item.creation_status,
- item.delivery_status,
- item.episode_amount,
- item.episode_price,
- item.free_episode_count,
- item.latest_update_time,
- item.need_show_publish_tag,
- item.on_shelf_time,
- item.original_thumb_url,
- item.permission_status,
- item.price_changed,
- item.publish_time,
- item.thumb_uri,
- item.thumb_url,
- item.wx_audit_status,
- item.wx_is_reject
- ]
- ];
- let table_name = "fq_dj_lib"
- const insertSQL = `
- INSERT INTO ${table_name}
- (book_id, series_name, amount_limit_status, book_pool, category,
- category_text, creation_status, delivery_status, episode_amount,
- episode_price, free_episode_count, latest_update_time, need_show_publish_tag,
- on_shelf_time, original_thumb_url, permission_status, price_changed,
- publish_time, thumb_uri,thumb_url,wx_audit_status,wx_is_reject)
- VALUES ?
- ON DUPLICATE KEY UPDATE
- book_id = VALUES(book_id)
- `;
- await connection2.query(insertSQL, [values]);
- console.log("info:",book_info.data.data)
- }
- }
-
- console.log("短剧库没有:",element.product_id)
- }
- }
- }
- }
- }catch(e){
- console.error("processTask error:",e)
- } finally{
- if(connection!=null){
- connection.end()
- }
- if(connection2!=null){
- connection2.end()
- }
- global.setTimeout(processTask, 1000);
- }
- }
- CMD.init = async function(){
- redis_help.connect((results)=>{
- if(results){
- processTask();
- }
- })
- }
- CMD.init()
|