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

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

        public ApiResponse<long> SaveShopSetting(long shopId,
                                                string managerPwd,
                                                decimal platformCommissionRatio,
                                                PurchaseAccount purchaseAccount,
                                                string dingDingWebHook,
                                                string dingDingKey,
                                                int skuSafeTurnoverDays,
                                                string siNanDingDingWebHook,
                                                string siNanDingDingKey,
                                                int siNanPolicyLevel,
                                                string qiKuDingDingWebHook,
                                                string qiKuDingDingKey
                                                )
        {
            return SendRequest<long>(globalContext.BBYWApiHost, "api/vender/SaveShopSetting", new
            {
                shopId,
                managerPwd,
                platformCommissionRatio,
                PurchaseAccountId = purchaseAccount.Id,
                purchaseAccount.AccountName,
                purchaseAccount.AppKey,
                purchaseAccount.AppSecret,
                purchaseAccount.AppToken,
                purchaseAccount.PurchasePlatformId,
                dingDingWebHook,
                dingDingKey,
                skuSafeTurnoverDays,
                siNanDingDingWebHook,
                siNanDingDingKey,
                siNanPolicyLevel,
                qiKuDingDingWebHook,
                qiKuDingDingKey
            }, null, HttpMethod.Post);
        }

        /// <summary>
        /// 根据订单Id查询归属店铺
        /// </summary>
        /// <param name="orderIdList"></param>
        /// <returns></returns>
        public ApiResponse<IList<OrderBelongShopResponse>> GetOrderBelongShop(IList<string> orderIdList)
        {
            return SendRequest<IList<OrderBelongShopResponse>>(globalContext.BBYWApiHost, "api/order/GetOrderBelongShop", orderIdList, null, HttpMethod.Post);
        }

        /// <summary>
        /// 获取部门及下属店铺
        /// </summary>
        /// <returns></returns>
        public ApiResponse<IList<DepartmentResponse>> GetDepartmentList()
        {
            return SendRequest<IList<DepartmentResponse>>(globalContext.BBYWApiHost, "api/vender/GetDeparmentList", null,
                new Dictionary<string, string>()
                {
                    { "bbwyTempKey", "21jfhayu27q" }
                }, HttpMethod.Get);
        }

        public ApiResponse<IList<ShopResponse>> GetShopListByIds(IList<string> shopIds)
        {
            return SendRequest<IList<ShopResponse>>(globalContext.BBYWApiHost, "api/vender/GetShopListByShopIds", new
            {
                shopIds
            }, new Dictionary<string, string>()
                {
                    { "bbwyTempKey", "21jfhayu27q" }
                }, HttpMethod.Post);
        }

        public ApiResponse<IList<WaiterResponse>> GetServiceGroupList()
        {
            return SendRequest<IList<WaiterResponse>>(globalContext.BBYWApiHost, "api/vender/GetServiceGroupList", new
            {
                globalContext.User.Shop.Platform,
                globalContext.User.Shop.AppKey,
                globalContext.User.Shop.AppSecret,
                globalContext.User.Shop.AppToken,
            }, null, HttpMethod.Post);
        }
    }
}