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

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

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

  /**
   * 根据id查询审核详情
   *
   * @param  approveId   审核id
   * @param  callBack   回调
   */
  public getApproveDetail(approveId: number, callBack) {
    this.http.get(environment.baseUrl + 'audit/getApproveDetail?approveId=' + approveId).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 拒绝退款
   *
   * @param  id  id
   * @param  callBack   回调
   */
  public getRefundReject(id: number, callBack) {
    this.http.get(environment.baseUrl + 'highRefundAudit/getRefundReject?id=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询退款审核列表列表
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getOrderList(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highRefundAudit/getOrderList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }


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

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

}
