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

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

    /**
     * @Author Sum1Dream
     * @methodName getDistributionAgent
     * @Description // 查询分销代理商
     * @Date 11:06 2022/8/19
     * @Param callBack
     */
    public getDistributionAgent(callBack) {
        this.http.get(environment.baseUrl + 'bsDistributionUserRel/getDistributionAgent').subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getDistributionFirst
     * @Description // 查询一级分销
     * @Date 11:07 2022/8/19
     * @Param param: object , callBack
     */
    public getDistributionFirst(param: object , callBack) {
        this.http.get(environment.baseUrl + 'bsDistributionUserRel/getDistributionFirst?'  + this.common.getWhereCondition(param)).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getDistributionSecond
     * @Description // 查询二级分销
     * @Date 11:08 2022/8/19
     * @Param param: object , callBack
     */
    public getDistributionSecond(param: object , callBack) {
        this.http.get(environment.baseUrl + 'bsDistributionUserRel/getDistributionSecond?'  + this.common.getWhereCondition(param)).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getDistributionIntegralList
     * @Description // 查询分销积分列表
     * @Date 11:09 2022/8/19
     * @Param param: object , callBack
     */
    public getDistributionIntegralList(param: object , callBack) {
        this.http.get(environment.baseUrl + 'bsDistributionUserRel/getDistributionIntegralList?'  + this.common.getWhereCondition(param)).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getDistributionAgent
     * @Description // 查询推广代理商
     * @Date 11:06 2022/8/19
     * @Param callBack
     */
    public agentUserList(callBack) {
        this.http.get(environment.baseUrl + 'bsDistributionUserRel/agentUserList').subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getDistributionIntegralList
     * @Description // 查询推广订单列表
     * @Date 11:09 2022/8/19
     * @Param param: object , callBack
     */
    public orderListByAgentId(param: object , callBack) {
        this.http.get(environment.baseUrl + 'bsDistributionUserRel/orderListByAgentId?'  + this.common.getWhereCondition(param)).subscribe(data => {
            callBack(data);
        });
    }

}
