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

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

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

  /**
   * 查询门店列表
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getStoreListByMerchant(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highMerchantStore/getStoreListByMerchant?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

    /**
     * 查询门店油品列表
     *
     * @param  paramsObject   对象
     * @param  callBack   回调
     */
    public getOilPriceListByStore(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'gasOilPrice/getOilPriceListByStore?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

  /**
   * 超级管理员查询门店列表
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getStoreListByCompany(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highMerchantStore/getStoreListByCompany?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 新增商户
   *
   * @param params 上传对象
   * @param  callBack   回调
   * @return data 返回结果
   */
  public insertMerchantStore(params: object, callBack) {
    this.http.post(environment.baseUrl + 'highMerchantStore/insertMerchantStore', params).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 修改商户
   *
   * @param params 上传对象
   * @param  callBack   回调
   * @return data 返回结果
   */
  public updateMerchantStore(params: object, callBack) {
    this.http.post(environment.baseUrl + 'highMerchantStore/updateMerchantStore', params).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 根据id查询详情
   *
   * @param  merchantId   职位id
   * @param  callBack   回调
   */
  public getMerchantStoreById(merchantId: number, callBack) {
    this.http.get(environment.baseUrl + 'highMerchantStore/getMerchantStoreById?id=' + merchantId).subscribe(data => {
      callBack(data);
    });
  }


  /**
   * 禁用商户
   *
   * @param id  用户id
   * @param callBack 返回参数
   */
  public deleteMerchantStore(id: number, callBack) {
    this.http.get(environment.baseUrl + 'highMerchantStore/deleteMerchantStore?id=' + id).subscribe(data => {
      callBack(data);
    });
  }

    /**
     * 查询油站油品详情
     *
     * @param  paramsObject   对象
     * @param  callBack   回调
     */
    public getOilPriceDetail(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'gasOilPrice/getOilPriceDetail?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 编辑油品
     *
     * @param params 上传对象
     * @param  callBack   回调
     * @return data 返回结果
     */
    public editGasOilPrice(params: object, callBack) {
        this.http.post(environment.baseUrl + 'gasOilPrice/editGasOilPrice', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 删除油品
     *
     * @param params 上传对象
     * @param  callBack   回调
     * @return data 返回结果
     */
    public delOilPrice(params: object, callBack) {
        console.log(params);
        this.http.post(environment.baseUrl + 'gasOilPrice/delOilPrice', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 删除油枪
     *
     * @param params 上传对象
     * @param  callBack   回调
     * @return data 返回结果
     */
    public delGunNo(params: object, callBack) {
        this.http.post(environment.baseUrl + 'gasOilGunNo/delGunNo', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 查询油站油品油枪
     *
     * @param  oilPriceId   对象
     * @param  callBack   回调
     */
    public getGunNoListByOilPrice(oilPriceId: number, callBack) {
        this.http.get(environment.baseUrl + 'gasOilGunNo/getGunNoListByOilPrice?oilPriceId=' + oilPriceId).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 配置油枪号
     *
     * @param params 上传对象
     * @param  callBack   回调
     * @return data 返回结果
     */
    public addGasOilPrice(params: object, callBack) {
        this.http.post(environment.baseUrl + 'gasOilGunNo/addGasOilPrice', params).subscribe(data => {
            callBack(data);
        });
    }
}
