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

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

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

  /**
   * 生成二维码
   * @param paramObject 参数
   * @param callBack
   */
  generatePayQrCode(param: object, callBack) {
    this.http.post(environment.baseUrl + 'payQrCode/generatePayQrCode', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 分配公司
   * @param paramObject 参数
   * @param callBack
   */
  assignCompany(param: object, callBack) {
    this.http.post(environment.baseUrl + 'payQrCode/assignCompany', param).subscribe(data => {
      callBack(data);
    });
  }

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

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

  /**
   * 解绑二维码
   * @param paramObject 参数
   * @param callBack
   */
  unbindStore(param: object, callBack) {
    this.http.post(environment.baseUrl + 'payQrCode/unbindStore', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 解绑二维码
   * @param paramObject 参数
   * @param callBack
   */
  disabled(param: object, callBack) {
    this.http.post(environment.baseUrl + 'payQrCode/disabled', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 解绑二维码
   * @param paramObject 参数
   * @param callBack
   */
  enable(param: object, callBack) {
    this.http.post(environment.baseUrl + 'payQrCode/enable', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询二维码列表
   * @param paramObject 参数
   * @param callBack
   */
  getQrCodeList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'payQrCode/getQrCodeList?' + this.commonsService.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询二维码列表
   * @param paramObject 参数
   * @param callBack
   */
  exportQrCodeList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'payQrCode/exportQrCodeList?' + this.commonsService.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }
}
