public ActionResult CheckBill(int AdvertID,int LinkManID)
        {
            ApkDataBLL bll = new ApkDataBLL();
            List<ApkDataDto> list = (List<ApkDataDto>)bll.GetApkDataDtoList(AdvertID,"");
            double sumMoney = list.Sum<ApkDataDto>(t => Convert.ToDouble(t.Money));

            string taskids = string.Empty;
            list.ForEach(t => taskids += t.TaskID + ",");

            AdvertBill bill = new AdvertBill();
            bill.AdvertID = AdvertID;
            bill.LinkManID = LinkManID;
            bill.AdMoney = sumMoney.ToString();
            bill.ApplyTime = DateTime.Now;
            bill.PayMoney = "0";
            bill.Status = 0;//0:未付款
            bill.BillType = 0;//0:广告主
            bill.TaskIds = taskids;
            AdvertBillBLL advertBillBll = new AdvertBillBLL();

            if (advertBillBll.Add(bill))
            {
                TaskBLL taskBll = new TaskBLL();
                bll.UpdateApkDataStatus(AdvertID);
            }
            return MyContent("确认账单成功!请尽快支付款项!","/AdvertBill/AdvertBillList");
        }
        public ActionResult AdvertBillList(int AdvertID =0,int Status = -1,int PageIndex = 0)
        {
            #region 保存查询参数
            ViewBag.AdvertID = AdvertID;
            ViewBag.Status = Status;
            ViewBag.AmIn = "bill";
            #endregion

            AdvertBLL advertBLL = new AdvertBLL();
            ViewBag.AdvertList = advertBLL.GetAll();

            int count;
            int pageSize=10;
            AdvertBillBLL bll = new AdvertBillBLL();
            AdminUser user = CheckLogin.Instance.GetUser();
            ViewBag.BillList = bll.GetList(AdvertID, user.ID, (int)user.RoleType, 0, Status, PageIndex, pageSize, out count);
            ViewBag.PageCount = count % pageSize == 0 ? count / pageSize : (count / pageSize) + 1;
            ViewBag.Record = count;
            ViewBag.CurrentPage = PageIndex;
            return View();
        }
        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 RefuseToPay(int ID)
 {
     AdvertBillBLL bll = new AdvertBillBLL();
     AdvertBill bill = bll.Get(ID);
     bill.PayTime = DateTime.Now;
     bill.Status = 2;//拒绝支付
     bll.Update(bill);
     return MyContent("操作成功!", "/Channel/ChannelBillList");
 }
 public ActionResult Pay(int ID, double PayMoney)
 {
     AdvertBillBLL bll = new AdvertBillBLL();
     AdvertBill bill = bll.Get(ID);
     if (PayMoney > 0)
     {
         bill.PayMoney = PayMoney.ToString();
         bill.PayTime = DateTime.Now;
         bill.Status = 1;
         bll.Update(bill);
     }
     return MyContent("操作成功!", "/Channel/ChannelBillList");
 }
 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();
 }