using BBWY.Client.Models;
using BBWY.Common.Http;
using BBWY.Common.Models;
using System;
using System.Collections.Generic;
using System.Net.Http;

namespace BBWY.Client.APIServices
{
    public class StatisticsService : BaseApiService, IDenpendency
    {
        public StatisticsService(RestApiService restApiService, GlobalContext globalContext) : base(restApiService, globalContext)
        {

        }

        /// <summary>
        /// 今日业绩统计
        /// </summary>
        /// <returns></returns>
        public ApiResponse<ToDayOrderAchievementResponse> GetTodayAchievementStatistics(DateTime startTime, DateTime endTime, long shopId)
        {
            return SendRequest<ToDayOrderAchievementResponse>(globalContext.BBYWApiHost, "Api/Statistics/GetOrderAchievementStatistics", new
            {
                shopId,
                startTime,
                endTime
            },
            null, HttpMethod.Post);
        }

        public ApiResponse<OrderCountStatisticsResponse> GetOrderCountStatistics(long shopId)
        {
            return SendRequest<OrderCountStatisticsResponse>(globalContext.BBYWApiHost, "Api/Statistics/GetOrderCountStatistics", $"shopId={shopId}", null, HttpMethod.Get);
        }

        /// <summary>
        /// 刷单组个人统计
        /// </summary>
        /// <param name="sdOperator"></param>
        /// <returns></returns>
        public ApiResponse<SDGroupPersonStatisticsResponse> GetSDGroupPersonStatistics(string sdOperator, DateTime startDate, DateTime endDate)
        {
            return SendRequest<SDGroupPersonStatisticsResponse>(globalContext.BBYWApiHost, "/Api/Statistics/GetSDGroupPersonStatistics", $"sdOperator={sdOperator}&startDate={startDate}&endDate={endDate}", null, HttpMethod.Get);
        }

        /// <summary>
        /// 获取Sku近30天件数销量
        /// </summary>
        /// <param name="skuIds"></param>
        /// <returns></returns>
        public ApiResponse<IList<SkuRecentSaleResponse>> GetSkuRecentSales(List<string> skuIds)
        {
            return SendRequest<IList<SkuRecentSaleResponse>>(globalContext.BBYWApiHost, "/Api/Statistics/GetSkuRecentSales", new
            {
                skuIds
            }, null, HttpMethod.Post);
        }
    }
}