check_hy_info.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const video_product_controllers = require('./src/data_manager/Controllers/video_product_controllers');
  2. const config = require("./etc/config.json")
  3. const redis_help = require('./src/use_redis');
  4. const CMD = {}
  5. async function processTask(){
  6. try{
  7. const result = await video_product_controllers.getDataByBookPlatform({book_platform:config.platform_heiyan})
  8. console.log("result:",result)
  9. if(result.success){
  10. for (let index = 0; index < result.data.length; index++) {
  11. const product_item = result.data[index];
  12. let hy_book_data = await require('./src/api/hy/hy_search_book').search_id(product_item.product_id)
  13. if(hy_book_data!=null){
  14. let genre = 1
  15. if(hy_book_data==undefined||hy_book_data==null){
  16. return null
  17. }
  18. if(hy_book_data.rows==null||hy_book_data.rows==undefined){
  19. return null
  20. }
  21. if(hy_book_data.rows.lenght<=0){
  22. return null
  23. }
  24. let typeDesc = hy_book_data.rows[0].typeDesc; //'中篇',
  25. if(typeDesc=="长篇"){
  26. genre = 1;
  27. }else{
  28. genre = 3;
  29. }
  30. await video_product_controllers.updateData({id:product_item.id},{
  31. genre:genre
  32. })
  33. }
  34. await new Promise(resolve => setTimeout(resolve,100));
  35. }
  36. }
  37. }catch(e){
  38. console.error("processTask error:",e)
  39. } finally{
  40. console.log("finish all!!!!!")
  41. }
  42. }
  43. CMD.init = async function(){
  44. redis_help.connect((results)=>{
  45. if(results){
  46. processTask();
  47. }
  48. })
  49. }
  50. CMD.init()