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

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

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

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

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

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

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

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

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


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

    /**
     * 根据id完成订单
     *
     * @param  id   id
     * @param  callBack   回调
     */
    public getMobileRechargeByOrderId(id: number, callBack) {
        this.http.get(environment.baseUrl + 'outRechargeOrder/getMobileRechargeByOrderId?orderId=' + id).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 根据id完成退款
     *
     * @param  id   id
     * @param  callBack   回调
     */
    public orderToRefund(id: number, callBack) {
        this.http.get(environment.baseUrl + 'outRechargeOrder/orderToRefund?orderId=' + id).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName orderToRefundPre
     * @Description // 预约订单退款
     * @Date 11:17 上午 2021/11/23
     * @Param [id: number, callBack]
     */
    public orderToRefundPre(id: number, callBack) {
        this.http.get(environment.baseUrl + 'highOrderPre/orderToRefund?orderId=' + id).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 申请退款
     *
     * @param  id   id
     * @param  callBack   回调
     */
    public postRefund(params: object, callBack) {
        this.http.post(environment.baseUrl + 'highRefundAudit/insertRefundAudit', params).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 查询充值订单数量
     *
     * @param  id   id
     * @param  callBack   回调
     */
    public countOrder(callBack) {
        this.http.get(environment.baseUrl + 'outRechargeOrder/countOrder').subscribe(data => {
            callBack(data);
        });
    }

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

    /**
     * 到处订单统计
     *
     * @param  paramsObject   对象
     * @param  callBack   回调
     */
    public exportOrderListCount(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'outRechargeOrder/exportOrderListCount?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 到处订单统计
     *
     * @param  paramsObject   对象
     * @param  callBack   回调
     */
    public exportOrderList(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'outRechargeOrder/exportOrderList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

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


    /**
     * 到处订单统计
     *
     * @param  paramsObject   对象
     * @param  callBack   回调
     */
    public exportUserOrderListCount(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'outRechargeOrder/exportUserOrderListCount?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 获取渠道商获取关联商品
     *
     * @param  callBack   回调
     */
    public getMemberGoods(callBack) {
        this.http.get(environment.baseUrl + 'telApi/getMemberGoods').subscribe(data => {
            callBack(data);
        });
    }

    /**
     * @Author Sum1Dream
     * @methodName orderToRefundPre
     * @Description // 预约订单退款
     * @Date 11:17 上午 2021/11/23
     * @Param [id: number, callBack]
     */
    public getChildOrder(id: number, callBack) {
        this.http.get(environment.baseUrl + 'outRechargeOrder/getChildOrder?orderId=' + id).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 获取充值产品编码列表
     *
     * @param  paramsObject   对象
     * @param  callBack   回调
     */
    public getRechargeCodeList(paramsObject: object, callBack) {
        this.http.get(environment.baseUrl + 'outRechargePrice/getRechargeCodeList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
            callBack(data);
        });
    }

    /**
     * 编辑产品编码
     *
     * @param params 上传对象
     * @param  callBack   回调
     * @return data 返回结果
     */
    public editRechargeCode(params: object, callBack) {
        this.http.post(environment.baseUrl + 'outRechargePrice/editRechargeCode', params).subscribe(data => {
            callBack(data);
        });
    }

}
