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

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


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

    /**
     * @Author Sum1Dream
     * @methodName editPriceStatus
     * @Description // 修改价格状态
     * @Date 15:03 2021/8/12
     * @Param mod
     **/
    public updateMerchant(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiMerchants/updateMerchant', params).subscribe(data => {
            callBack(data);
        });
    }

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

    /**
     * @Author Sum1Dream
     * @methodName editPriceStatus
     * @Description // 修改价格状态
     * @Date 15:03 2021/8/12
     * @Param mod
     **/
    public editMerchantsStatus(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiMerchants/editMerchantsStatus', params).subscribe(data => {
            callBack(data);
        });
    }

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


    /**
     * @Author Sum1Dream
     * @methodName getListApiMerchantByAll
     * @Description // 查询所有正常商户
     * @Date 15:03 2021/8/12
     * @Param mod
     **/
    public getListApiMerchantByAll(callBack) {
        this.http.get(environment.baseUrl + 'apiMerchants/getListApiMerchantByAll').subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName
     * @Description // 商户充值
     * @Date 14:28 2022/6/8
     * @Param
     */
    public recharge(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiMerchants/recharge', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getMerchRechargeData
     * @Description // 查询商户充值数据
     * @Date 15:19 2022/6/8
     * @Param id
     */
    public getMerchRechargeData(id: number, callBack) {
        this.http.get(environment.baseUrl + 'apiMerchants/getMerchRechargeData?merchantId=' + id).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName configApiProduct
     * @Description // 提交配置产品
     * @Date 18:00 2022/6/8
     * @Param 
     */
    public configApiProduct(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiProduct/configApiProduct', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName editPriceStatus
     * @Description // 修改价格状态
     * @Date 15:03 2021/8/12
     * @Param mod
     **/
    public editConfigApiProductByStatus(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiProduct/editConfigApiProductByStatus', params).subscribe(data => {
            callBack(data);
        });
    }

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

    /**
     * @Author Sum1Dream
     * @methodName editPriceStatus
     * @Description // 修改价格状态
     * @Date 15:03 2021/8/12
     * @Param mod
     **/
    public updateConfigApiProduct(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiProduct/updateConfigApiProduct', params).subscribe(data => {
            callBack(data);
        });
    }
}
