using BBWY.Client.Models.APIModel.Response.PackTask;
using BBWY.Client.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BBWY.Client.Models.PackTask
{
    public class ShopTotal : NotifyObject
    {

        private FeesItemResponse feesItemResponse;

        public FeesItemResponse FeesItemResponse { get => feesItemResponse; set { Set(ref feesItemResponse, value); } }


        private long id;
        public long Id { get => id; set { Set(ref id, value); } }

        private bool taskChecked;
        public bool TaskChecked { get => taskChecked; set { Set(ref taskChecked, value); } }


        public string TaskIdRemark { get; set; }
        /// <summary>
        /// 任务id
        /// </summary>
        public long TaskId { get; set; }
        /// <summary>
        /// 完成打包时间日期
        /// </summary>
        public DateTime? CreateTime { get; set; }
        /// <summary>
        /// 是否结清
        /// </summary>
        public Settle IsSettle { get; set; }
        /// <summary>
        /// 部门
        /// </summary>
        public string DepartmentName { get; set; }
        /// <summary>
        /// 店铺
        /// </summary>
        public string ShopName { get; set; }
        /// <summary>
        /// 对接人
        /// </summary>
        public string AcceptUserName { get; set; }
        /// <summary>
        /// sku标题
        /// </summary>
        public string SkuName { get; set; }
        /// <summary>
        /// sku数量(任务数量)
        /// </summary>
        public int SkuCount { get; set; }
        /// <summary>
        /// 耗材费
        /// </summary>
        public decimal ConsumableFees { get; set; }
        /// <summary>
        /// 到货数量
        /// </summary>
        public int? ArrivalQuantity { get; set; }
        /// <summary>
        /// 打包费(原价)
        /// </summary>
        public decimal PackFees { get; set; }
        /// <summary>
        /// 折扣系数
        /// </summary>
        public decimal? DiscountFactor { get; set; }
        /// <summary>
        /// 打包费用折扣价
        /// </summary>
        public decimal? PackDisCountFees { get; set; }


        /// <summary>
        /// 赔付费用
        /// </summary>
        public decimal? CompensateFees { get; set; }

        /// <summary>
        /// 实际打包费用
        /// </summary>
        public decimal? ActualPackFees { get; set; }
        ///// <summary>
        ///// 折扣类型
        ///// </summary>
        //public FeesMode? FeesMode { get; set; }
        /// <summary>
        /// 总费用
        /// </summary>
        public decimal? AllFees { get; set; }
        /// <summary>
        /// 工序类型名称
        /// </summary>
        public string ProcessTypeName { get; set; }
        /// <summary>
        /// 工序套餐名称
        /// </summary>
        public string ProcessComboName { get; set; }
        /// <summary>
        /// 工序套餐单价
        /// </summary>
        public decimal ProcessComboPrice { get; set; }
        /// <summary>
        /// 工序套餐任务量
        /// </summary>
        public int ProcessComboTaskCount { get; set; }

        /// <summary>
        /// 耗材服务数据
        /// </summary>
        public List<ServiceItemResponse> ConsumableList { get; set; }
        // string title = "任务ID,日期,是否结清,所属部门,所属店铺,包装数量,收货数量,耗材总价,工序类型,工序套餐,工序单价,打包原价,打包折扣系数,打包折扣价,总收费";
        public override string ToString()
        {
            string ConsumableStr = string.Empty;
            if (ConsumableList != null && ConsumableList.Count > 0)
                ConsumableStr = string.Join(",", ConsumableList.Select(x => $"{x.ItemName} {x.ItemPrice}*{x.ItemCount}"));

            return $"{TaskId},{CreateTime?.ToString("MM-dd")},{IsSettle},{DepartmentName},{ShopName}" +
                $",{SkuCount},{ArrivalQuantity},\"{ConsumableStr}\" ,{ConsumableFees},{ProcessTypeName},{ProcessComboName},{ProcessComboPrice},{PackFees},{DiscountFactor},{PackDisCountFees},{CompensateFees},{ActualPackFees},{AllFees}";
        }
    }

    public class ShopTotalResponse
    {
        /// <summary>
        ///
        /// </summary>
        public int TotalCount { get; set; }

        public ShopTotal[] ShopTotals { get; set; }

        /// <summary>
        /// 总打包费用
        /// </summary>
        public decimal TotalPackDiscountFees { get; set; }

        /// <summary>
        /// 总耗材费
        /// </summary>
        public decimal TotalConsumableFees { get; set; }
    }
}