|
@@ -0,0 +1,68 @@
|
|
|
+//同步19的男女频道
|
|
|
+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 CMD = {}
|
|
|
+async function processTask(){
|
|
|
+ let right_status = true
|
|
|
+ let connection = null
|
|
|
+ try{
|
|
|
+ connection = await mysql.createConnection({
|
|
|
+ ...taskdbConfig,
|
|
|
+ multipleStatements: true
|
|
|
+ });
|
|
|
+ let sql = `SELECT * FROM video_product WHERE book_platform = ${config.platform_qmmf} AND gender = 0 LIMIT 500`
|
|
|
+ console.log("sql:",sql)
|
|
|
+ const [rows] = await connection.execute(
|
|
|
+ sql
|
|
|
+ );
|
|
|
+
|
|
|
+ if(rows.length<=0){
|
|
|
+ throw 0
|
|
|
+ }
|
|
|
+
|
|
|
+ for (let index = 0; index < rows.length; index++) {
|
|
|
+ let video_product_info = rows[index]
|
|
|
+ let data = await require('../src/api/qm_mf/qm_mf_search_book').search_id_new(video_product_info.product_id)
|
|
|
+ if(data!=null&&data!=""){
|
|
|
+ let gender = data.gender
|
|
|
+ await connection.execute(
|
|
|
+ ` UPDATE video_product SET gender = ${gender} WHERE id = ${video_product_info.id} `
|
|
|
+ );
|
|
|
+ }else{
|
|
|
+ await connection.execute(
|
|
|
+ ` UPDATE video_product SET gender = 3 WHERE id = ${video_product_info.id} `
|
|
|
+ );
|
|
|
+ console.error("查无此书:",video_product_info)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }catch(e){
|
|
|
+ if(e==0){
|
|
|
+ right_status = false
|
|
|
+ }
|
|
|
+ console.error("processTask error:",e)
|
|
|
+ } finally{
|
|
|
+ if(connection!=null){
|
|
|
+ connection.end()
|
|
|
+ }
|
|
|
+ global.setTimeout(processTask, 1000);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+CMD.init = async function(){
|
|
|
+ redis_help.connect((results)=>{
|
|
|
+ if(results){
|
|
|
+ processTask();
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+CMD.init()
|