|
@@ -6,6 +6,8 @@ const redis_help = require('../src/use_redis');
|
|
|
const config = require('../etc/config.json');
|
|
|
const other_book_controllers = require('../src/data_manager/Controllers/other_book_controllers');
|
|
|
const tools = require('../tools');
|
|
|
+const helper = require('../src/helper');
|
|
|
+const { default: axios } = require('axios');
|
|
|
const time_count = 1000;
|
|
|
const task_queue = []
|
|
|
|
|
@@ -382,8 +384,9 @@ CMD.update_filter_data = async function(FilterConfig,data) {
|
|
|
|
|
|
if(main_info.pay_type==0){
|
|
|
table_data.book_platform = config.platform_heiyanmf
|
|
|
- table_data.product_parent_id = data.product_parent_id
|
|
|
+ table_data.product_parent_id = await CMD.get_product_parent_id(data.book_id)
|
|
|
}
|
|
|
+ console.log("table_data:",table_data)
|
|
|
//没有找到 可以创建
|
|
|
await video_applet_product_controllers.createAppletProductData(table_data)
|
|
|
}
|
|
@@ -400,6 +403,43 @@ CMD.update_filter_data = async function(FilterConfig,data) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+CMD.get_product_parent_id = async function(product_id) {
|
|
|
+ try{
|
|
|
+ let bookIds = []
|
|
|
+ bookIds.push(product_id)
|
|
|
+ if(bookIds.length>0){
|
|
|
+ let timestamp = helper.getCurrentUnixTimestamp()
|
|
|
+ let sign = helper.generateSign({
|
|
|
+ "pid":config.heiyan_config.pid,
|
|
|
+ "timestamp":timestamp,
|
|
|
+ "sign":"",
|
|
|
+ "bookIds":bookIds.join(',')
|
|
|
+ },config.heiyan_config.key)
|
|
|
+ var url = config.heiyan_config.copyBooks
|
|
|
+ var base_params = `/?sign=${sign}&pid=${config.heiyan_config.pid}×tamp=${timestamp}`
|
|
|
+ var other_params = `&bookIds=${bookIds.join(',')}`
|
|
|
+ url = `${url}${base_params}${other_params}`
|
|
|
+ // console.log("url:",url)
|
|
|
+ let response = await axios.get(url)
|
|
|
+ let data = response.data
|
|
|
+ if(data.code==1){
|
|
|
+ let list = data.data
|
|
|
+ console.log("get_hy_origin_books:",list)
|
|
|
+ for (let index = 0; index < list.length; index++) {
|
|
|
+ const element = list[index];
|
|
|
+ let parent_id = element.bookId
|
|
|
+ return parent_id
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }catch(e){
|
|
|
+ console.error("get_product_parent_id err::",e)
|
|
|
+ return ""
|
|
|
+ }
|
|
|
+ return ""
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
CMD.insert_product = async function(data){
|
|
|
return await video_product_controllers.createProductData({
|
|
|
book_platform:data.tg_platform_id,
|