import { Injectable } from '@angular/core';
import {HttpClient} from  '@angular/common/http';
import {CommonsService} from './commons.service';
import {environment} from '../../environments/environment';

@Injectable({
  providedIn: 'root'
})
export class OilCardService {

  constructor(
      private http: HttpClient,
      private common: CommonsService
  ) { }

  /**
   * 油卡充值
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public recharge(param: object, callBack) {
    this.http.post(environment.baseUrl + 'oilCard/recharge', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 油卡回收余额
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public recycleAmount(param: object, callBack) {
    this.http.post(environment.baseUrl + 'oilCard/recycleAmount', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 生成油卡
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public generateCard(param: object, callBack) {
    this.http.post(environment.baseUrl + 'oilCard/generateCard', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 设置联系人
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public setContact(param: object, callBack) {
    this.http.post(environment.baseUrl + 'oilCard/setContact', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 禁用
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public disabled(param: object, callBack) {
    this.http.post(environment.baseUrl + 'oilCard/disabled', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 启用
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public enable(param: object, callBack) {
    this.http.post(environment.baseUrl + 'oilCard/enable', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 油卡列表
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public getCardList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'oilCard/getCardList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 油卡记录列表
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public getOilCardRecordList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'oilCardRecord/getOilCardRecordList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 油卡操作记录列表
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public getOilCardContactRecordList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'oilCardContactRecord/getOilCardContactRecordList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 导出油卡
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public exportCard(param: object, callBack) {
    this.http.get(environment.baseUrl + 'oilCard/exportCard?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 油卡订单列表
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public getCardOrderList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'oilCard/getCardOrderList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 导出油卡订单
   *
   * @param  param   参数对象
   * @param  callBack   回调
   */
  public exportCardOrder(param: object, callBack) {
    this.http.get(environment.baseUrl + 'oilCard/exportCardOrder?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

}
