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 TyAgentOilStationService {

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

  /**
   * 分配机构
   * @param paramObject 参数
   * @param callBack
   */
  assignOrg(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'tyAgentOilStation/assignOrg', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 解绑机构
   * @param paramObject 参数
   * @param callBack
   */
  unbindOrg(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'tyAgentOilStation/unbindOrg', paramObject).subscribe(data => {
      callBack(data);
    });
  }
  /**
   * 分配代理商
   * @param paramObject 参数
   * @param callBack
   */
  assignAgent(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'tyAgentOilStation/assignAgent', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 分配代理商
   * @param paramObject 参数
   * @param callBack
   */
  unbindAgent(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'tyAgentOilStation/unbindAgent', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 分配业务员
   * @param paramObject 参数
   * @param callBack
   */
  assignSalesman(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'tyAgentOilStation/assignSalesman', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 分配业务员
   * @param paramObject 参数
   * @param callBack
   */
  unbindSalesman(paramObject: object, callBack) {
    this.http.post(environment.baseUrl + 'tyAgentOilStation/unbindSalesman', paramObject).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询加油站列表
   * @param paramObject 参数
   * @param callBack
   */
  getOilStationList(paramObject: object, callBack) {
    this.http.get(environment.baseUrl + 'tyAgentOilStation/getOilStationList?' + this.common.getWhereCondition(paramObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询订单列表
   * @param paramObject 参数
   * @param callBack
   */
  getOrderList(paramObject: object, callBack) {
    this.http.get(environment.baseUrl + 'tyAgentOilStation/getOrderList?' + this.common.getWhereCondition(paramObject)).subscribe(data => {
      callBack(data);
    });
  }


  /**
   * 查询订单列表
   * @param paramObject 参数
   * @param callBack
   */
  excelOrder(paramObject: object, callBack) {
    this.http.get(environment.baseUrl + 'tyAgentOilStation/excelOrder?' + this.common.getWhereCondition(paramObject)).subscribe(data => {
      callBack(data);
    });
  }

}
