dz_create_link.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //执行一个创建点众链接任务
  2. const axios = require('axios');
  3. const helper = require('../src/helper');
  4. const config = require('../etc/config.json')
  5. const HttpClient = require('../src/HttpClient')
  6. const CMD = {}
  7. CMD.runTask = async function(data,main_info,PlatformInfo,call_back){
  8. let tg_link_config = JSON.parse(main_info.tg_link_config)
  9. let chongzhi_id = tg_link_config['chongzhi_id']
  10. let chongzhi_list = JSON.parse(PlatformInfo.chongzhi)
  11. let chongzhi_name = null
  12. let recharge_template_id = ""
  13. for (let index = 0; index < chongzhi_list.length; index++) {
  14. const cz_obj = chongzhi_list[index];
  15. if(cz_obj.id==chongzhi_id){
  16. chongzhi_name = cz_obj.name
  17. recharge_template_id = cz_obj.value
  18. break
  19. }
  20. }
  21. try {
  22. let client = new HttpClient()
  23. let clientId= config.dianzhong_config.clientId;
  24. let timestamp = new Date().getTime();
  25. let bookId = data.product_id;
  26. let chapterIdx = 1;
  27. let name = data.product_name;
  28. let mediaSource = "dy";
  29. let channelId = main_info.channelId;
  30. let batchId = "";
  31. let CallbackConfigId = "";
  32. let fromDrId = "zywzfromDrId";
  33. let chapterChargeStart = 1;
  34. let chapterKandian = 0;
  35. let response = await client.post(config.dianzhong_config.create_link_host,{
  36. clientId:clientId,
  37. timestamp:timestamp,
  38. bookId:bookId,
  39. chapterIdx:chapterIdx,
  40. name:name,
  41. mediaSource:mediaSource,
  42. channelId:channelId,
  43. batchId:batchId,
  44. CallbackConfigId:CallbackConfigId,
  45. fromDrId:fromDrId,
  46. chapterChargeStart:chapterChargeStart,
  47. chapterKandian:chapterKandian
  48. })
  49. } catch (error) {
  50. console.error('fq_create_link :Error:', error);
  51. // 处理错误
  52. }
  53. }
  54. module.exports = CMD;