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

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


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

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

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

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

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

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

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

    /**
     * @Author Sum1Dream
     * @methodName getStarbucksProducts
     * @Description // 查询星巴克产品
     * @Date 13:53 2022/6/30
     * @Param callBack
     */
    public getStarbucksProducts(callBack) {
        this.http.get(environment.baseUrl + 'apiProduct/getStarbucksProducts').subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName insertProductConfig
     * @Description // 新增第三方产品配置
     * @Date 14:22 2022/6/30
     * @Param params: object, callBack
     */
    public productConfig(params: object, callBack) {
        this.http.post(environment.baseUrl + 'bsProductConfig/productConfig', params).subscribe(data => {
            callBack(data);
        });
    }
    /**
     * @Author Sum1Dream
     * @methodName insertProductConfig
     * @Description // 新增第三方产品配置
     * @Date 14:22 2022/6/30
     * @Param params: object, callBack
     */
    public updateProductConfig(params: object, callBack) {
        this.http.post(environment.baseUrl + 'bsProductConfig/updateProductConfig', params).subscribe(data => {
            callBack(data);
        });
    }

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

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

    /**
     * @Author Sum1Dream
     * @methodName findStarbucksProducts
     * @Description // 查询产品详情
     * @Date 10:29 2022/7/1
     * @Param id: number, callBack
     */
    public findStarbucksProducts(id: number, callBack) {
        this.http.get(environment.baseUrl + 'bsProductConfig/findStarbucksProducts?id=' + id).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getListApiMemberProduct
     * @Description // 查询会员产品列表
     * @Date 10:38 2022/7/12
     * @Param paramsObject: object, callBack
     */
    public getListApiMemberProduct(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'apiMemberProduct/getListApiMemberProduct?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

   /**
    * @Author Sum1Dream
    * @methodName insertMemberProduct
    * @Description // 新增会员产品
    * @Date 10:39 2022/7/12
    * @Param params: object, callBack
    */
    public insertMemberProduct(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiMemberProduct/insertMemberProduct', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName updateMemberProduct
     * @Description // 修改会员产品
     * @Date 10:40 2022/7/12
     * @Param params: object, callBack
     */
    public updateMemberProduct(params: object, callBack) {
        this.http.post(environment.baseUrl + 'apiMemberProduct/updateMemberProduct', params).subscribe(data => {
            callBack(data);
        });
    }

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

    /**
     * @Author Sum1Dream
     * @methodName insertMemberProduct
     * @Description // 新增积分返利配置
     * @Date 10:39 2022/7/12
     * @Param params: object, callBack
     */
    public insertIntegralRebate(params: object, callBack) {
        this.http.post(environment.baseUrl + 'bsIntegralRebate/insertIntegralRebate', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName updateMemberProduct
     * @Description // 修改积分返利配置
     * @Date 10:40 2022/7/12
     * @Param params: object, callBack
     */
    public updateIntegralRebate(params: object, callBack) {
        this.http.post(environment.baseUrl + 'bsIntegralRebate/updateIntegralRebate', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName getListApiMemberProduct
     * @Description // 查询列表
     * @Date 10:38 2022/7/12
     * @Param paramsObject: object, callBack
     */
    public getIntegralRebateByList(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'bsIntegralRebate/getIntegralRebateByList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

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

    /**
     * 删除
     *
     * @param  id   id
     * @param  callBack   回调
     */
    public deleteIntegralRebate(id: number, callBack) {
        this.http.get(environment.baseUrl + 'bsIntegralRebate/deleteIntegralRebate?id=' + id).subscribe(data => {
            callBack(data);
        });
    }

}
