/// <summary>
        /// 根据业务Id计算相关产品的成本和利润
        /// </summary>
        /// <param name="busId"></param>
        /// <param name="accId"></param>
        /// <returns></returns>
        /// 所有打包产品都算Saas服务
        /// 单独的短信包和维客短信是第三方服务
        /// 话费充值和实物产品算他营产品
        public OrderItemProp GetListItemProps(int busId, int accId)
        {
            StringBuilder strSql    = new StringBuilder();
            OrderItemProp propModel = new OrderItemProp();

            strSql.Append("select * from [i200].[dbo].[T_Order_Project_List] where busId=@busId;");

            try
            {
                List <dynamic> projectList = DapperHelper.Query <dynamic>(strSql.ToString(), new { busId = busId }).ToList();

                //独立产品的处理
                if (projectList.Count == 1)
                {
                    dynamic model = projectList[0];
                    //处理短信
                    if (model.itemId == 1)
                    {
                        propModel.Cost = Convert.ToInt32(model.itemQuantity) * 0.05;
                        //标记为第三方服务
                        propModel.PureSms = "1";
                    }
                    //处理维客短信
                    else if (model.itemName.ToString().IndexOf("维客") >= 0)
                    {
                        T_Sms_ListDAL dal    = new T_Sms_ListDAL();
                        double        smsCnt = dal.GetFreeSmsCnt(accId);
                        propModel.Cost      = smsCnt * 0.05;
                        propModel.isFreeSms = 1;
                        //标记为第三方服务
                        propModel.PureSms = "1";
                    }
                    else if (model.itemName.ToString().IndexOf("充值100") >= 0)
                    {
                        propModel.Cost = 100;
                    }
                    else if (model.itemName.ToString().IndexOf("充值50") >= 0)
                    {
                        propModel.Cost = 50;
                    }
                    else if (model.itemName.ToString().IndexOf("充值30") >= 0)
                    {
                        propModel.Cost = 30;
                    }
                    else
                    {
                        propModel.Cost     = 0;
                        propModel.SelfMark = "1";
                    }
                }
                //组合产品的处理
                else if (projectList.Count > 1)
                {
                    dynamic model = projectList[0];
                    //propModel.SelfMark = "1";

                    //处理维客类套餐
                    if (model.itemName.ToString().IndexOf("维客") >= 0)
                    {
                        T_Sms_ListDAL dal    = new T_Sms_ListDAL();
                        double        smsCnt = dal.GetFreeSmsCnt(accId);
                        propModel.Cost      = smsCnt * 0.06;
                        propModel.isFreeSms = 1;
                        //标记为第三方服务
                        propModel.PureSms = "1";
                    }
                    else
                    {
                        foreach (var item in projectList)
                        {
                            if (item.itemId == 1)
                            {
                                propModel.Cost += Convert.ToInt32(model.itemQuantity) * 0.06;
                            }
                        }
                        propModel.SelfMark = "1";
                    }
                }
                //空列表
                else
                {
                }

                return(propModel);
            }
            catch (Exception ex)
            {
                Logger.Error("获取用户详情订单摘要信息出错", ex);
                return(propModel);
            }
        }
Пример #2
0
        /// <summary>
        /// 得到一个店铺的订单
        /// </summary>
        /// <param name="accid"></param>
        /// <returns></returns>
        public static DetailOrder GetAccountOrder(int accid)
        {
            List <dynamic> orderList = T_OrderInfoBLL.GetListByAccId(accid);
            string         str       = "";

            OrderItemProp propModel  = new OrderItemProp();
            DetailOrder   orderModel = new DetailOrder();

            foreach (dynamic item in orderList)
            {
                str = item.orderPayType.ToString();
                switch (str)
                {
                case "0":
                    item.orderPayType = "平台订单";
                    break;

                case "1":
                    item.orderPayType = "线下订单";
                    break;

                case "2":
                    item.orderPayType = "支付宝";
                    break;

                case "3":
                    item.orderPayType = "财付通";
                    break;

                case "4":
                    item.orderPayType = "快钱";
                    break;

                case "5":
                    item.orderPayType = "微信支付";
                    break;

                case "6":
                    item.orderPayType = "IOS支付";
                    break;

                case "7":
                    item.orderPayType = "安卓支付";
                    break;
                }

                if (item.orderTypeId != 2)
                {
                    OrderItemProp tempModel = T_Order_businessBLL.GetListItemProps(Convert.ToInt32(item.busId), accid);

                    if (propModel.isFreeSms == 1 && tempModel.isFreeSms == 1)
                    {
                        propModel.Profit   += Convert.ToDouble(item.RealPayMoney);
                        propModel.SumMoney += Convert.ToDouble(item.RealPayMoney);
                    }
                    else
                    {
                        propModel.Cost     += tempModel.Cost;
                        propModel.Profit   += Convert.ToDouble(item.RealPayMoney);
                        propModel.SumMoney += Convert.ToDouble(item.RealPayMoney) - tempModel.Cost;
                        propModel.isFreeSms = tempModel.isFreeSms;
                    }
                }
                else
                {
                    propModel.Cost     += Convert.ToDouble(item.busSumMoney);
                    propModel.Profit   += Convert.ToDouble(item.RealPayMoney);
                    propModel.SumMoney += Convert.ToDouble(item.RealPayMoney) - Convert.ToDouble(item.busSumMoney);
                }
            }

            propModel.Cost     = Math.Round(propModel.Cost, 2);
            propModel.Profit   = Math.Round(propModel.Profit, 2);
            propModel.SumMoney = Math.Round(propModel.SumMoney, 2);

            orderModel.DataList = orderList;
            orderModel.SumInfo  = propModel;

            return(orderModel);
        }
Пример #3
0
        /// <summary>
        /// 获取订单信息
        /// </summary>
        /// <param name="stDate"></param>
        /// <param name="edDate"></param>
        /// <returns></returns>
        public static Dictionary <string, decimal> GetOrderInfo(DateTime stDate, DateTime edDate)
        {
            Dictionary <string, decimal> dic = new Dictionary <string, decimal>()
            {
                { "总订单", 0 },
                { "Saas服务", 0 },
                { "短信", 0 },
                { "话费", 0 },
                { "硬件", 0 },
                { "总订单笔数", 0 },
                { "Saas服务笔数", 0 },
                { "短信笔数", 0 },
                { "话费笔数", 0 },
                { "硬件笔数", 0 }
            };

            //获取订单类型
            List <OrderInfoModel> tOrdList = T_OrderInfoBLL.GetOrderInfoByDate(stDate, edDate, 0);
            decimal tSelf     = 0;
            decimal tSms      = 0;
            decimal tMaterial = 0;
            decimal tPhone    = 0;

            foreach (var item in tOrdList)
            {
                OrderItemProp tempModel = T_Order_businessBLL.GetListItemProps(Convert.ToInt32(item.busId), item.accId);
                if (tempModel.SelfMark == "1")
                {
                    tSelf           += Convert.ToDecimal(item.RealPayMoney);
                    dic["Saas服务笔数"] += 1;
                }
                else if (tempModel.PureSms == "1")
                {
                    tSms        += Convert.ToDecimal(item.RealPayMoney);
                    dic["短信笔数"] += 1;
                }
                else
                {
                    tPhone      += Convert.ToDecimal(item.RealPayMoney);
                    dic["话费笔数"] += 1;
                }
            }

            //获取实物商品相关统计(实物商品计入他营产品)
            List <OrderInfoModel> MaterialList = T_OrderInfoBLL.GetOrderInfoByDate(stDate, edDate, 1);

            if (MaterialList != null && MaterialList.Count > 0)
            {
                foreach (var item in MaterialList)
                {
                    tMaterial   += Convert.ToDecimal(item.RealPayMoney);
                    dic["硬件笔数"] += 1;
                }
            }

            dic["Saas服务"] = tSelf;
            dic["短信"]     = tSms;
            dic["话费"]     = tPhone;
            dic["硬件"]     = tMaterial;
            dic["总订单"]    = tSelf + tSms + tPhone + tMaterial;
            dic["总订单笔数"]  = dic["Saas服务笔数"] + dic["短信笔数"] + dic["话费笔数"] + dic["硬件笔数"];

            return(dic);
        }
Пример #4
0
        public static string GetOrderType(string dataType, DateTime BgTime, DateTime EdTime)
        {
            FusionPieModel model = new FusionPieModel();

            string strJson = "";

            DateTime bgTime = new DateTime();
            DateTime edTime = new DateTime();

            if (dataType == "oth")
            {
                bgTime = BgTime;
                edTime = EdTime.AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            else if (dataType == "month")
            {
                DateTime FirstDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
                DateTime LastDay  = FirstDay.AddMonths(1).AddDays(-1);

                bgTime = FirstDay;
                edTime = LastDay.AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            else if (dataType == "lastmonth")
            {
                DateTime nowTime  = DateTime.Now.AddMonths(-1);
                DateTime FirstDay = new DateTime(nowTime.Year, nowTime.Month, 1);
                DateTime LastDay  = FirstDay.AddMonths(1).AddDays(-1);

                bgTime = FirstDay;
                edTime = LastDay.AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            else if (dataType == "3month")
            {
                DateTime nowTime  = DateTime.Now.AddMonths(-2);
                DateTime FirstDay = new DateTime(nowTime.Year, nowTime.Month, 1);
                DateTime LastDay  = FirstDay.AddMonths(3).AddDays(-1);

                bgTime = FirstDay;
                edTime = LastDay.AddHours(23).AddMinutes(59).AddSeconds(59);
            }
            else if (dataType == "today")
            {
                bgTime = DateTime.Today.AddHours(0).AddMinutes(0).AddSeconds(0);
                edTime = DateTime.Today.AddHours(23).AddMinutes(59).AddSeconds(59);
            }

            List <OrderInfoModel> list = T_OrderInfoBLL.GetOrderInfoByDate(bgTime, edTime, 0);
            double self      = 0;
            double other     = 0;
            double otherServ = 0;

            //int count = 0;//调试信息

            foreach (var item in list)
            {
                OrderItemProp tempModel = T_Order_businessBLL.GetListItemProps(Convert.ToInt32(item.busId), item.accId);
                if (tempModel.SelfMark == "1")
                {
                    self += Convert.ToDouble(item.RealPayMoney);
                }
                else if (tempModel.PureSms == "1")
                {
                    otherServ += Convert.ToDouble(item.RealPayMoney);
                    //count++;
                }
                else
                {
                    other += Convert.ToDouble(item.RealPayMoney);
                }
            }

            //获取实物商品相关统计(实物商品计入他营产品)
            List <OrderInfoModel> MaterialList = T_OrderInfoBLL.GetOrderInfoByDate(bgTime, edTime, 1);

            if (MaterialList != null && MaterialList.Count > 0)
            {
                foreach (var item in MaterialList)
                {
                    other += Convert.ToDouble(item.RealPayMoney);
                }
            }

            //获取京东订单那相关统计(订单商品计入他营产品)
            List <OrderInfoModel> JdList = T_OrderInfoBLL.GetOrderInfoByDate(bgTime, edTime, 2);

            if (MaterialList != null && MaterialList.Count > 0)
            {
                foreach (var item in MaterialList)
                {
                    other += Convert.ToDouble(item.RealPayMoney);
                }
            }

            //OrderPartition orderMoney = T_OrderInfoBLL.GetOrderType(bgTime, edTime);

            double allMoney = self + other + otherServ;

            model.chart.caption           = "产品类型比例";
            model.chart.baseFontSize      = "12";
            model.chart.showpercentvalues = "1";

            PieData servData = new PieData();

            servData.label    = "第三方服务";
            servData.value    = GetBaiFen(Convert.ToDouble(otherServ), allMoney);
            servData.toolText = "第三方服务," + GetBaiFen(Convert.ToDouble(otherServ), allMoney) + "% (¥" + ControlHelper.formats(otherServ, 2).ToString() + ")";

            model.data.Add(servData);

            PieData selfData = new PieData();

            selfData.label    = "Saas服务";
            selfData.value    = GetBaiFen(Convert.ToDouble(self), allMoney);
            selfData.toolText = "Saas服务," + GetBaiFen(Convert.ToDouble(self), allMoney) + "% (¥" + ControlHelper.formats(self, 2).ToString() + ")";

            model.data.Add(selfData);

            PieData otherData = new PieData();

            otherData.label    = "他营";
            otherData.value    = GetBaiFen(Convert.ToDouble(other), allMoney);
            otherData.toolText = "他营," + GetBaiFen(Convert.ToDouble(other), allMoney) + "% (¥" + ControlHelper.formats(other, 2).ToString() + ")";

            model.data.Add(otherData);

            return(CommonLib.Helper.JsonSerializeObject(model));
        }