/*
 * @Author: YKH
 * @Date: 2021-12-08 10:26:27
 * @LastEditTime: 2022-09-20 22:21:35
 * @Description:
 * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\task\service\demo.ts
 */
import { Inject, Logger, Provide } from '@midwayjs/decorator';
import { BaseService } from 'midwayjs-cool-core';
import { ILogger } from '@midwayjs/logger';
import { Utils } from '../../../comm/utils';

/**
 * 描述
 */
@Provide()
export class TaskDemoService extends BaseService {
  @Logger()
  logger: ILogger;
  @Inject()
  utils: Utils;
  /**
   * 描述
   */
  async test() {
    this.logger.info('我被调用了');
    return '任务执行成功';
  }
  /**
   *
   * 测试访问小绵羊接口
   * @return {*}
   * @memberof TaskDemoService
   */
  // async testXMY() {
  //   let new_date = this.utils.formatDate(new Date())
  //   this.logger.info('testXMY>>>' + new_date);
  //   let xmyData = await queryXMY(new_date, new_date)
  //   console.log(xmyData)
  //   return '任务执行成功>>>testXMY>>>' + new_date;
  // }
}

// 获取小绵羊后台数据
// let queryXMY = function (new_date1, new_date2) {
//   var url = 'http://api.sheepsdk.17xmy.com/foreign/api/get_youhua_data.php?start_day=' + new_date1 + '&end_day=' + new_date2
//   var http = require('http');
//   var pm = new Promise(function (resolve, reject) {
//     http.get(url, function (res) {
//       var html = '';
//       res.on('data', function (d) {
//         html += d.toString()
//       });
//       res.on('end', function () {
//         resolve(html);
//       });
//     }).on('error', function (e) {
//       reject(e)
//     });
//   });
//   return pm;
// }
