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

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

  /**
   * @params  paramsObject
   * @params  callBack
   * @return ArrayList
   * @author sum1dream
   * @description  查询活动列表
   * @date 2021/9/27 5:53 下午
   * @version:    1.0.0
   */
  public getList(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'activity/getList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @params  params
   * @author sum1dream
   * @description 编辑活动基本信息
   * @date 2021/9/28 2:37 下午
   * @version:    1.0.0
   */
  public editActivityInfo(params: object, callBack) {
    this.http.post(environment.baseUrl + 'activity/editActivityInfo', params).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @params  id
   * @author sum1dream
   * @description 根据id查询活动基本信息详情
   * @date 2021/9/28 2:39 下午
   * @version:    1.0.0
   */
  public getDetailById(id: number, callBack) {
    this.http.get(environment.baseUrl + 'activity/getDetailById?activityId=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @params  id
   * @author sum1dream
   * @description 根据id查询活动活动配置奖品
   * @date 2021/9/28 2:39 下午
   * @version:    1.0.0
   */
  public getListByActivityId(id: number, callBack) {
    this.http.get(environment.baseUrl + 'activityAward/getListByActivityId?activityId=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName getWinLotteryList
   * @Description //查询活动中奖记录
   * @Date 17:54 2021/9/30
   * @Param mod
   **/
  public getWinLotteryList(param: object, callBack) {
    this.http.get(environment.baseUrl + 'activityAward/getWinLotteryList?' + this.common.getWhereCondition(param)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 活动开始
   * @param param 参数
   * @param callBack
   */
  public startActivity(param: object, callBack) {
    this.http.post(environment.baseUrl + 'activity/startActivity', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 活动结束
   * @param param 参数
   * @param callBack
   */
  public endActivity(param: object, callBack) {
    this.http.post(environment.baseUrl + 'activity/endActivity', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName editActivityInfo
   * @Description //新增中奖名次
   * @Date 15:43 2021/9/30
   * @Param mod
   **/
  public editActivityAward(params: object, callBack) {
    this.http.post(environment.baseUrl + 'activityAward/editActivityAward', params).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @params  id
   * @author sum1dream
   * @description 删除
   * @date 2021/9/28 2:39 下午
   * @version:    1.0.0
   */
  public deleteActivateAward(id: number, callBack) {
    this.http.get(environment.baseUrl + 'activityAward/deleteActivateAward?activityId=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @params  id
   * @author sum1dream
   * @description 查询剩余数量
   * @date 2021/9/28 2:39 下午
   * @version:    1.0.0
   */
  public checkNumberPrizes(id: number, callBack) {
    this.http.get(environment.baseUrl + 'activityAward/checkNumberPrizes?activityId=' + id).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @params  params
   * @author sum1dream
   * @description 根据奖励id新增奖励数量
   * @date 2021/9/28 2:37 下午
   * @version:    1.0.0
   */
  public numberOfNewRewards(params: object, callBack) {
    this.http.post(environment.baseUrl + 'activityAward/numberOfNewRewards', params).subscribe(data => {
      callBack(data);
    });
  }


}
