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


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

  /**
   * 打印
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public print(orderId: number, printType: number, callBack) {
    this.http.get(environment.baseUrl + 'highOrder/print?orderId=' + orderId + '&printType=' + printType).subscribe(data => {
      callBack(data);
    });
  }


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

    /**
     * 查询油站订单
     *
     * @param  paramsObject   对象
     * @param  callBack   回调
     */
    public getGasOrderListByOil(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'highGas/getGasOrderList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

  /**
   * 统计油站订单
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public countGasOrder(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highGas/countGasOrder?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName getDiscountPackageList
   * @Description // 查询优惠券包订单列表
   * @Date 5:24 下午 2021/12/9
   * @Param [paramsObject: object, callBack]
   */
  public getDiscountPackageList(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrder/getDiscountPackageList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询代理商订单列表
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getOrderListByIdCode(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrder/getOrderListByIdCode?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询团游订单列表
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getGasOrderList(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrder/getGasOrderList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

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

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


  public getMobileOrderList(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrder/getMobileOrderList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

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

  /**
   * @Author Sum1Dream
   * @methodName exportDiscountPackageList
   * @Description // 到处优惠券包订单列表
   * @Date 5:25 下午 2021/12/9
   * @Param [paramsObject: object, callBack]
   */
  public exportDiscountPackageList(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrder/exportDiscountPackageList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName exportListPreOrder
   * @Description // 导出预约订单
   * @Date 6:33 下午 2021/11/21
   * @Param [paramsObject , callBack]
   */
  public exportListPreOrder(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrderPre/exportListPreOrder?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }



  /**
   * @Author Sum1Dream
   * @methodName exportOrderListByIdCode
   * @Description // 导出预约订单
   * @Date 9:58 上午 2021/11/22
   * @Param [paramsObject , callBack]
   */
  public exportOrderListByIdCode(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrder/exportOrderListByIdCode?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 退款
   *
   * @param params 上传对象
   * @param  callBack   回调
   * @return data 返回结果
   */
  public refuelingOrderRefund(params: object, callBack) {
    this.http.post(environment.baseUrl + 'highGas/refuelingOrderRefund', params).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName preOrderSuccess
   * @Description //TODO
   * @Date 5:50 下午 2021/11/21
   * @Param [params , callBack]
   */
  public preOrderSuccess(params: object, callBack) {
    this.http.post(environment.baseUrl + 'highOrderPre/preOrderSuccess', params).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName preOrderFail
   * @Description // 预约失败
   * @Date 9:59 上午 2021/11/22
   * @Param [params , callBack]
   */
  public preOrderFail(params: object, callBack) {
    this.http.post(environment.baseUrl + 'highOrderPre/preOrderFail', params).subscribe(data => {
      callBack(data);
    });
  }



  /**
   * @Author Sum1Dream
   * @methodName getListPreOrder
   * @Description // 查询预约订单
   * @Date 2:35 下午 2021/11/19
   * @Param [params , callBack]
   */
  public getListPreOrder(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highOrderPre/getListPreOrder?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName getOrderById
   * @Description //TODO
   * @Date 5:17 下午 2021/11/19
   * @Param [orderId , callBack]
   */
  public getOrderById(orderId: number , callBack) {
    this.http.get(environment.baseUrl + 'highOrder/getOrderById?orderId=' + orderId).subscribe( data => {
      callBack(data);
    });
  }

  public getPreOrderById(id: number , callBack) {
    this.http.get(environment.baseUrl + 'highOrderPre/getPreOrderById?id=' + id).subscribe( data => {
      callBack(data);
    });
  }

  /**
   * 请求团油统计
   *
   * @param params 上传对象
   * @param  callBack   回调
   * @return data 返回结果
   */
  public TyOrderStatistics(params: object, callBack) {
    this.http.post(environment.baseUrl + 'highOrder/TyOrderStatistics', params).subscribe(data => {
      callBack(data);
    });
  }

  public exportGasOrder(params: object , callBack) {
    this.http.get(environment.baseUrl + 'highGas/exportGasOrder?' + this.common.getWhereCondition(params)).subscribe( data => {
      callBack(data);
    });
  }

    public getGasOrderDetail(orderNo: string , callBack) {
        this.http.get(environment.baseUrl + 'highGas/getGasOrderDetail?orderNo=' + orderNo).subscribe( data => {
            callBack(data);
        });
    }
}
