public ActionResult CheckBill(int ChannelID)
        {
            ApkDataBLL bll = new ApkDataBLL();
            ChannelBLL channelBll = new ChannelBLL();
            List<ApkDataDto> list = (List<ApkDataDto>)channelBll.GetApkDataDtoList(ChannelID, "");
            double sumMoney = list.Sum<ApkDataDto>(t => Convert.ToDouble(t.Money));
            
            string taskids = string.Empty;
            list.ForEach(t => taskids += t.TaskID + ",");

            AdminUser user = CheckLogin.Instance.GetUser();
            //明天做
            AdvertBill bill = new AdvertBill();
            bill.AdvertID = ChannelID;
            bill.LinkManID = user.ID;
            bill.AdMoney = sumMoney.ToString();
            bill.ApplyTime = DateTime.Now;
            bill.PayMoney = "0";
            bill.Status = 0;//0:未付款
            bill.BillType = 1;//1:渠道账单
            bill.TaskIds = taskids;
            AdvertBillBLL advertBillBll = new AdvertBillBLL();

            if (advertBillBll.Add(bill))
            {
                TaskBLL taskBll = new TaskBLL();
                bll.UpdateApkDataStatusByChannelID(ChannelID);
            }

            return MyContent("生成一条新的渠道账单!", "/Channel/ChannelBillList");
        }
        public ActionResult ChannelList(int PageIndex = 0, double BeginMoney = -1, double EndMoney = -1, DateTime? BeginTime = null, DateTime? Endtime = null, string IsCounted = "false")
        {
            #region 保存查询条件
            ViewBag.BeginMoney = BeginMoney == -1 ? "" : BeginMoney.ToString();
            ViewBag.EndMoney = EndMoney == -1 ? "" : EndMoney.ToString();
            ViewBag.BeginTime = BeginTime;
            ViewBag.Endtime = Endtime;
            ViewBag.IsCounted = IsCounted;
            ViewBag.AmIn = "bill";
            #endregion

            if (BeginTime == null)
                BeginTime = DateTime.Now.AddYears(-20);
            if (Endtime == null)
                Endtime = DateTime.Now.AddYears(20);
            AdminUser user = CheckLogin.Instance.GetUser();

            ChannelBLL bll = new ChannelBLL();
            int count;
            int pageSize = 10;
            IList<ChannelUserDTO> list = bll.GetList(user.ID, BeginMoney == -1 ? 0 : BeginMoney, EndMoney == -1 ? 0 : EndMoney, (DateTime)BeginTime, (DateTime)Endtime, IsCounted == "on", PageIndex, pageSize, out count);

            ViewBag.ChannelList = list;
            ViewBag.PageCount = count % pageSize == 0 ? count / pageSize : (count / pageSize) + 1;
            ViewBag.Record = count;
            ViewBag.CurrentPage = PageIndex;
            return View();
        }
        public ActionResult BillList(int ChannelID = 0, string UserName = "", string TaskIds = "", string Opt = "check")
        {
            ChannelBLL bll = new ChannelBLL();
            IList<ApkDataDto> list = bll.GetApkDataDtoList(ChannelID, TaskIds);

            double sumMoney = list.Sum<ApkDataDto>(t => Convert.ToDouble(t.Money));
            ViewBag.SumMoney = sumMoney;
            ViewBag.ChannelID = ChannelID;
            ViewBag.Opt = Opt;

            //AdminUserBLL userBll = new AdminUserBLL();
            //AdminUser user = userBll.Get(ChannelID);
            ViewBag.ChannelName = UserName;

            ViewBag.BillList = list;
            return View();
        }
        public ActionResult Index()
        {
            DateTime BeginTime = DateTime.Now.AddDays(-30);
            DateTime EndTime = DateTime.Now;
            ChannelBLL bll = new ChannelBLL();

            //获取相关金额
            Dictionary<string, string> dict = bll.GetChannelMoney(CheckLogin.Instance.GetUser().ID);
            ViewBag.AllMoney = dict["AllMoney"];
            ViewBag.NoApplyMoney = dict["NoApplyMoney"];
            ViewBag.PaiedMoney = dict["PaiedMoney"];
            ViewBag.RefusedToMoney = dict["RefusedToPayMoney"];

            AdminUser user = CheckLogin.Instance.GetUser();
            List<PerDayMoney> list = bll.GetPerDayMoneyList(user.ID, BeginTime, EndTime);
            StringBuilder sbDate = new StringBuilder();
            StringBuilder sbMoney = new StringBuilder();
            int days = (EndTime - BeginTime).Days;
            for (int i = 0; i <= days; i++)
            { 
                var perday = list.Where<PerDayMoney>(t=>(Convert.ToDateTime(t.CreateTime) - BeginTime.AddDays(i)).Days == 0);
                if (perday == null || perday.Count<PerDayMoney>() == 0)
                {
                    sbDate.Append("'");
                    sbDate.Append(BeginTime.AddDays(0).ToString("yyyy-MM-dd"));
                    sbDate.Append("'");
                    sbDate.Append(",");
                    sbMoney.Append(0);
                    sbMoney.Append(",");
                }
                else
                {
                    sbDate.Append("'");
                    sbDate.Append(perday.First<PerDayMoney>().CreateTime);
                    sbDate.Append("'");
                    sbDate.Append(",");
                    sbMoney.Append(perday.First<PerDayMoney>().Money);
                    sbMoney.Append(",");
                }
            }
            ViewBag.CreateDates = sbDate.ToString().TrimEnd(',');
            ViewBag.Money = sbMoney.ToString().TrimEnd(',');
            return View();
        }
 public ActionResult ChannelBillList(int Status = -1, int PageIndex = 0)
 {
     ViewBag.AmIn = "bill";
     ViewBag.Status = Status;
     AdminUser user = CheckLogin.Instance.GetUser();
     if (user.RoleType == (int?)RoleType.渠道)
     { 
         //如果当前登录用户是渠道,则查询相关金额
         ChannelBLL channelBll = new ChannelBLL();
         Dictionary<string,string> dict = channelBll.GetChannelMoney(CheckLogin.Instance.GetUser().ID);
         ViewBag.AllMoney = dict["AllMoney"];
         ViewBag.NoApplyMoney = dict["NoApplyMoney"];
         ViewBag.PaiedMoney = dict["PaiedMoney"];
         ViewBag.RefusedToMoney = dict["RefusedToPayMoney"];
     }
     int count;
     int pageSize = 10;
     AdvertBillBLL bll = new AdvertBillBLL();
     ViewBag.BillList = bll.GetChannelBillList(user.RoleType == (int?)RoleType.渠道 ? user.ID : 0, user.ID, (int)user.RoleType, 1, Status, PageIndex, pageSize, out count);
     ViewBag.PageCount = count % pageSize == 0 ? count / pageSize : (count / pageSize) + 1;
     ViewBag.Record = count;
     ViewBag.CurrentPage = PageIndex;
     return View();
 }