const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings");
class TaxService extends ServiceBase {
  constructor() {
    super();
  }
  /**
   * 月账期
   * @param {*} params 
   */
  async getReportData(params) {
    try {
      let data ={
        "accountPeriod": 202003,
        "companyId": 102,
        "customerId": 498779,
        "desc": "string",
        "reportType": 2,
        "signWithoutKey": "string"
      }
      let url = settings.ntapi().getReportData
      return await this.callApi(url, data, "月账期");
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   * 季度账期
   * @param {*} params 
   */
  async getReportDataQuarter(params) {
    try {
      let data ={
        "companyId": 102,
        "customerId": 498779,
        "desc": "string",
        "endPeriod": 202003,
        "reportType": 2,
        "signWithoutKey": "string",
        "startPeriod": 202001
      };

      let url = settings.ntapi().getReportDataQuarter
      return await this.callApi(url, data, "季度账期");
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   * 获取用户账簿信息
   * @param {*} params 
   * id  个体工商户ID
   */
  async getCustomerById(params) {
    try {
      let businessmen = await this.callms("order", "queryObusinessmen", {
        id: params.id
      });
      if (!businessmen || !businessmen.data) {
        return system.getResult(null, `个体工商户不存在`);
      }
      let url = settings.ntapi().getCustomerById;
      let res = await this.callApi(url, {
        id: businessmen.customer_id
      }, "获取用户账簿信息");
      return res;
    } catch (error) {
      console.log(error);
      return system.getResult(null, `系统错误`);
    }
  }
}
module.exports = TaxService;