public void SetValue(string curDate, StoreDailyInfo value)
    {
        data                  = value;
        curDateTime           = curDate;
        Text_StoreID.text     = value.StoreID.ToString();
        Text_StoreName.text   = value.StoreName;;
        Text_LeastSales.text  = value.LeastSales.ToString();
        Text_TargetSales.text = value.TargetSales.ToString();
        Input_TodayEnterCustomerCount.text = value.TodayEnterCustomerNumber.ToString();
        Input_MonthEnterCustomerCount.text = value.MonthEnterCustomerNubmer.ToString();
        Text_TodayTransaction.text         = value.TodyTransaction.ToString();
        Text_TodaySales.text        = value.TodaySales.ToString();
        Input_MonthTransaction.text = value.MonthTransaction.ToString();
        Input_MonthSales.text       = value.MonthTotalSales.ToString();

        Text_TodayProductTransactions.text = "";
        for (int i = 0; i < value.TodayProductTransactions.Count; i++)
        {
            ProductTransactionInfo trans = value.TodayProductTransactions[i];
            Text_TodayProductTransactions.text += string.Format("{0}*{1}  ", trans.ProductName, trans.TransactionCount);
        }
        Input_CompleteRate.text     = value.CompletionRate.ToString();
        Input_OldCustomerCount.text = value.OldCustomerCount.ToString();
        Input_OldCustomerSales.text = value.OldCustomerSales.ToString();
        Input_NewCustomerCount.text = value.NewCustomerCount.ToString();
        Input_NewCustomerSales.text = value.NewCustomerSales.ToString();
        Toggle.group = gameObject.GetComponentInParent <ToggleGroup>();
    }
    public ProductTransactionInfo Clone()
    {
        ProductTransactionInfo newinfo = new ProductTransactionInfo();

        newinfo.ProductId        = ProductId;
        newinfo.ProductName      = ProductName;
        newinfo.TransactionCount = TransactionCount;
        return(newinfo);
    }
Exemplo n.º 3
0
    public ProductTransactionInfo GetTransactionInfo(int productId, string productName)
    {
        ProductTransactionInfo trans = null;

        for (int i = 0; i < ProductTransactionInfos.Count; i++)
        {
            if (ProductTransactionInfos[i].ProductId == productId)
            {
                trans = ProductTransactionInfos[i];
                break;
            }
        }
        if (trans == null)
        {
            trans             = new ProductTransactionInfo();
            trans.ProductId   = productId;
            trans.ProductName = productName;
            ProductTransactionInfos.Add(trans);
        }
        return(trans);
    }
    /// <summary>
    /// 根据输入的数据计算每日销售信息
    /// 门店销售信息,月销售信息
    /// </summary>
    /// <param name="date"></param>
    public void CalculateData(string date)
    {
        string         day         = date.Substring(6, 2);
        DailySalesData thisDayData = LoadDailyData(date);

        if (int.Parse(day) == 1)
        {
            thisDayData.Reset();
        }
        else
        {
            DailySalesData lastDayData = LoadLastDailyData(date);
            thisDayData.TotalSales          = 0;
            thisDayData.MonthSaleDataToDate = lastDayData.MonthSaleDataToDate.Clone();
            thisDayData.ProductTransactionInfos.Clear();
            #region storeDailyDate
            for (int i = 0; i < lastDayData.AllStoreDailySaleData.Count; i++)
            {
                StoreDailyInfo lastStoreDayInfo  = lastDayData.AllStoreDailySaleData[i];
                StoreDailyInfo todaystoreDayinfo = thisDayData.GetStoreDailyInfo(lastStoreDayInfo.StoreID);
                todaystoreDayinfo.MonthEnterCustomerNubmer = lastStoreDayInfo.MonthEnterCustomerNubmer + todaystoreDayinfo.TodayEnterCustomerNumber;
                todaystoreDayinfo.MonthTransaction         = lastStoreDayInfo.MonthTransaction;
                todaystoreDayinfo.MonthTotalSales          = lastStoreDayInfo.MonthTotalSales;
                todaystoreDayinfo.OldCustomerCount         = lastStoreDayInfo.OldCustomerCount;;
                todaystoreDayinfo.OldCustomerSales         = lastStoreDayInfo.OldCustomerSales;
                todaystoreDayinfo.NewCustomerCount         = lastStoreDayInfo.NewCustomerCount;
                todaystoreDayinfo.NewCustomerSales         = lastStoreDayInfo.NewCustomerSales;
                todaystoreDayinfo.CompletionRate           = lastStoreDayInfo.CompletionRate;
            }
            for (int i = 0; i < thisDayData.AllStoreDailySaleData.Count; i++)
            {
                StoreDailyInfo todayStoreDayInfo = thisDayData.AllStoreDailySaleData[i];
                todayStoreDayInfo.TodaySales      = 0;
                todayStoreDayInfo.TodyTransaction = 0;
                todayStoreDayInfo.TodayProductTransactions.Clear();
            }
            #endregion
            #region RankingInfo
            for (int i = 0; i < lastDayData.AllSalesPersonRankInfos.Count; i++)
            {
                SalesPersonRankInfo lastRankingInfo  = lastDayData.AllSalesPersonRankInfos[i];
                SalesPersonRankInfo todayRankingInfo = thisDayData.GetSalePersonRankInfo(lastRankingInfo.SalePersonID);
                if (todayRankingInfo == null)
                {
                    continue;
                }
                todayRankingInfo.Ranking          = lastRankingInfo.Ranking;
                todayRankingInfo.PerformanceSales = lastRankingInfo.PerformanceSales;
                todayRankingInfo.CompleteRate     = lastRankingInfo.CompleteRate;
            }
            for (int i = 0; i < thisDayData.AllSalesPersonRankInfos.Count; i++)
            {
                SalesPersonRankInfo todayRankinfo   = thisDayData.AllSalesPersonRankInfos[i];
                SalesPersonRankInfo lastRankingInfo = lastDayData.GetSalePersonRankInfo(todayRankinfo.SalePersonID);
                todayRankinfo.Ranking          = lastRankingInfo.Ranking;
                todayRankinfo.PerformanceSales = lastRankingInfo.PerformanceSales;
                todayRankinfo.CompleteRate     = lastRankingInfo.CompleteRate;
            }
            #endregion
        }
        for (int i = 0; i < thisDayData.AllSingleSalesData.Count; i++)
        {
            SingleSalesData singleSaleData = thisDayData.AllSingleSalesData[i];
            thisDayData.TotalSales += singleSaleData.TotalPrice;
            ProductTransactionInfo trans = thisDayData.GetTransactionInfo(singleSaleData.ProductID, singleSaleData.ProductName);
            trans.TransactionCount += singleSaleData.SaleCount;
            #region 计算门店每日数据
            StoreDailyInfo storeDayInfo = thisDayData.GetStoreDailyInfo(singleSaleData.StoreID);
            if (singleSaleData.TransactionPercent > 0)
            {
                storeDayInfo.TodyTransaction += 1;
            }
            if (singleSaleData.TransactionPercent > 0)
            {
                storeDayInfo.MonthTransaction += 1;
            }
            storeDayInfo.TodaySales += singleSaleData.TotalPrice;
            ProductTransactionInfo transaction = storeDayInfo.GetTransactionInfo(singleSaleData.ProductID, singleSaleData.ProductName);
            transaction.TransactionCount += singleSaleData.SaleCount;
            storeDayInfo.MonthTotalSales += singleSaleData.TotalPrice;
            storeDayInfo.CompletionRate   = storeDayInfo.MonthTotalSales / storeDayInfo.TargetSales;
            if (singleSaleData.IsNewCustomer)
            {
                if (singleSaleData.TransactionPercent > 0)
                {
                    storeDayInfo.NewCustomerCount += 1;
                }
                storeDayInfo.NewCustomerSales += singleSaleData.TotalPrice;
            }
            else
            {
                if (singleSaleData.TransactionPercent > 0)
                {
                    storeDayInfo.OldCustomerCount += 1;
                }
                storeDayInfo.OldCustomerSales += singleSaleData.TotalPrice;
            }
            #endregion
            #region 计算本月数据
            thisDayData.MonthSaleDataToDate.TotalSales += singleSaleData.TotalPrice;
            if (singleSaleData.IsNewCustomer)
            {
                thisDayData.MonthSaleDataToDate.NewCustomerTransactions += (1 * singleSaleData.TransactionPercent);
                thisDayData.MonthSaleDataToDate.NewCustomerSales        += singleSaleData.TotalPrice;
            }
            else
            {
                thisDayData.MonthSaleDataToDate.OldCustomerTransactions += (1 * singleSaleData.TransactionPercent);
                thisDayData.MonthSaleDataToDate.OldCustomerSales        += singleSaleData.TotalPrice;
            }
            #endregion
            #region
            int salesPersonId = SalesDataSystem.SystemDatas.SalesPersonData.GetSalesPersonIdByName(singleSaleData.SalesPerson1);
            SalesPersonRankInfo salesPersonRankingInfo = thisDayData.GetSalePersonRankInfo(salesPersonId);
            salesPersonRankingInfo.PerformanceSales += singleSaleData.TotalPrice;
            #endregion
        }
        for (int i = 0; i < thisDayData.AllStoreDailySaleData.Count; i++)
        {
            StoreDailyInfo todayStoreDayInfo = thisDayData.AllStoreDailySaleData[i];
            todayStoreDayInfo.CompletionRate = todayStoreDayInfo.MonthTotalSales / todayStoreDayInfo.TargetSales;
        }
        thisDayData.AllSalesPersonRankInfos.Sort((a, b) =>
        {
            if (a.PerformanceSales > b.PerformanceSales)
            {
                return(-1);
            }
            else if (a.PerformanceSales == b.PerformanceSales)
            {
                return(0);
            }
            else
            {
                return(1);
            }
        });
        for (int i = 0; i < thisDayData.AllSalesPersonRankInfos.Count; i++)
        {
            SalesPersonRankInfo rankinginfo = thisDayData.AllSalesPersonRankInfos[i];
            rankinginfo.Ranking      = i + 1;
            rankinginfo.CompleteRate = rankinginfo.PerformanceSales / rankinginfo.TargetSales;
        }
    }
Exemplo n.º 5
0
    /// <summary>
    /// 格式化销售产品数据
    /// </summary>
    /// <param name="newinfo"></param>
    /// <returns></returns>
    private static string GetMonthProductTransactionInfo(DailySalesData newinfo)
    {
        string productTransactionInfo = string.Empty;
        Dictionary <string, string> productTransactionDict = new Dictionary <string, string>();

        for (int i = 0; i < newinfo.ProductTransactionInfos.Count; i++)
        {
            ProductTransactionInfo trans       = newinfo.ProductTransactionInfos[i];
            eProductType           productType = SalesDataSystem.SystemDatas.ProductSysData.GetProductTypeByID(trans.ProductId);
            string exportName   = SalesDataSystem.SystemDatas.ProductSysData.GetProductExportNameByID(trans.ProductId);
            string exportSuffix = SalesDataSystem.SystemDatas.ProductSysData.GetProductExportSuffixByID(trans.ProductId);
            string key          = null;
            string addValue     = null;
            switch (productType)
            {
            case eProductType.Classic:
                key      = "经典款:";
                addValue = string.Format("{0} * {1}{2}、", exportName, trans.TransactionCount, exportSuffix);
                break;

            case eProductType.Glory:
                key      = "荣耀款:";
                addValue = string.Format("{0} * {1}{2}、", exportName, trans.TransactionCount, exportSuffix);
                break;

            case eProductType.Exclusive:
                key      = "尊享款:";
                addValue = string.Format("{0} * {1}{2}、", exportName, trans.TransactionCount, exportSuffix);
                break;

            case eProductType.DrySwallow:
                key      = "干燕盏:";
                addValue = string.Format("{0} * {1}{2}、", exportName, trans.TransactionCount, exportSuffix);
                break;

            case eProductType.Single:
                key      = trans.ProductName + ":";
                addValue = string.Format("{0} * {1}{2}、", exportName, trans.TransactionCount, exportSuffix);
                break;

            case eProductType.None:
                break;

            case eProductType.GuanYan:
                key      = "冰糖官燕:";
                addValue = string.Format("{0} * {1}{2}、", exportName, trans.TransactionCount, exportSuffix);
                break;

            default:
                break;
            }
            if (!string.IsNullOrEmpty(key))
            {
                if (!productTransactionDict.ContainsKey(key))
                {
                    productTransactionDict[key] = "";
                }
                productTransactionDict[key] += (addValue);
            }
        }

        System.Text.StringBuilder strb = new System.Text.StringBuilder(100);
        foreach (var p in productTransactionDict)
        {
            strb.Append(p.Key);
            strb.Append(p.Value);
            strb.Append(Environment.NewLine);
        }
        productTransactionInfo = strb.ToString();
        return(productTransactionInfo);
    }