using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.AspNetCore.Authorization;

using System.Web;
using MySystem.MainModels;
using LitJson;
using Library;

namespace MySystem.Areas.Api.Controllers.v1
{
    [Area("Api")]
    [Route("Api/[controller]/[action]")]
    public class KdbController : BaseController
    {
        public KdbController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
        {
        }



        #region 获取押金政策
        public string GetDepositList(string value)
        {
            string content = "";
            try
            {
                JsonData data = JsonMapper.ToObject(value);
                string depositId = data["depositId"].ToString();
                content = PublicImportDataService.Instance.GetDepositAmount(depositId);
            }
            catch(Exception ex)
            {
                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "获取开店宝政策异常");
            }
            return content;
        }
        #endregion


        #region 设置押金
        public string SetDeposit(string value)
        {
            string content = "";
            try
            {
                JsonData data = JsonMapper.ToObject(value);
                string sn = data["sn"].ToString();
                string depositId = data["depositId"].ToString();
                content = PublicImportDataService.Instance.ModifyDeposit(sn, depositId);
            }
            catch(Exception ex)
            {
                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "设置开店宝押金异常");
            }
            return content;
        }
        #endregion


        #region 设置费率
        public string SetFee(string value)
        {
            string content = "";
            try
            {
                JsonData data = JsonMapper.ToObject(value);
                string sn = data["sn"].ToString();
                string fee = data["fee"].ToString();
                content = PublicImportDataService.Instance.ModifyFee(sn, fee);
            }
            catch(Exception ex)
            {
                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "设置开店宝费率异常");
            }
            return content;
        }
        #endregion

    }
}

