//
        // GET: /ApplyCreditCard/

        public ActionResult Index(ApplyCreditCard ApplyCreditCard, EFPagingInfo <ApplyCreditCard> p, DateTime?STime, DateTime?ETime, bool?IsShowSupAgent, int IsFirst = 0)
        {
            if (STime.IsNullOrEmpty())
            {
                STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (ETime.IsNullOrEmpty())
            {
                // ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                ETime = DateTime.Now;
            }
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            ViewBag.Save            = checkPower("Save");
            ViewBag.IsUpLoad        = checkPower("UpLoad");
            ViewBag.ETime           = ETime;
            ViewBag.STime           = STime;
            ViewBag.BasicBankList   = Entity.BasicBank.Where(n => n.CreditCardUrl != null).ToList();
            ViewBag.ApplyCreditCard = ApplyCreditCard;
            ViewBag.SysAgentList    = Entity.SysAgent.Where(n => n.Tier == 1).ToList();
            ViewBag.IsShowSupAgent  = IsShowSupAgent;

            // ETime = ETime.Value.AddDays(1);
            p.SqlWhere.Add(f => f.AddTime > STime && f.AddTime < ETime);
            if (!ApplyCreditCard.BankId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.BankId == ApplyCreditCard.BankId);
            }
            if (!ApplyCreditCard.UserMobile.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.UserMobile == ApplyCreditCard.UserMobile);
            }
            if (!ApplyCreditCard.OrderNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.OrderNum == ApplyCreditCard.OrderNum);
            }
            if (!ApplyCreditCard.UserName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.UserName == ApplyCreditCard.UserName);
            }
            if (!ApplyCreditCard.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == ApplyCreditCard.State);
            }
            if (!ApplyCreditCard.FirstAgentAmount.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.FirstAgentAmount == ApplyCreditCard.FirstAgentAmount);
            }
            if (!ApplyCreditCard.FirstAgentId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.FirstAgentId == ApplyCreditCard.FirstAgentId);
            }
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyCreditCard> ApplyCreditCardList = null;

            if (IsFirst == 0)
            {
                ApplyCreditCardList = new PageOfItems <ApplyCreditCard>(new List <ApplyCreditCard>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                ApplyCreditCardList = Entity.Selects <ApplyCreditCard>(p);
            }
            ViewBag.ApplyCreditCardList = ApplyCreditCardList;

            return(View());
        }
Exemple #2
0
        public void XLSDo(Orders Orders, EFPagingInfo <Orders> p, bool?IsShowSupAgent, int TimeType = 1)
        {
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            p = this.Condition(Orders, p, IsShowSupAgent, TimeType);

            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <Orders> OrdersList = Entity.Selects <Orders>(p);

            if (OrdersList.Count() > 0)
            {
                #region 导出
                string       file    = Server.MapPath("/template") + "\\finorders.xlsx";
                ExcelPackage package = new ExcelPackage(new FileInfo(file), true);
                var          sheet   = package.Workbook.Worksheets[1];
                var          cells   = sheet.Cells;
                int          Rows    = OrdersList.Count();
                //设置数据开始行
                int Befor = 2;
                sheet.InsertRow(Befor + 1, Rows - 1, Befor);
                int i = Befor;
                sheet.Row(i - 1).Height = 22;//设置行高
                int maxCol = 0;
                //获取机构及管理员
                IList <Orders> List = OrdersList.GroupBy(n => n.UId).Select(n => n.First()).ToList();
                List <int>     UId  = new List <int>();
                foreach (var pp in List)
                {
                    UId.Add(pp.UId);
                }
                IList <Users>     UsersList     = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();
                IList <PayConfig> PayConfigList = Entity.PayConfig.Where(n => n.State == 1).ToList();
                IList <SysAgent>  SysAgentList  = Entity.SysAgent.ToList();
                foreach (var item in OrdersList)
                {
                    #region MyRegion
                    string AName = "--";
                    if (item.AId > 0)
                    {
                        SysAgent SA = SysAgentList.FirstOrNew(n => n.Id == item.Agent);
                        if (!SA.Name.IsNullOrEmpty())
                        {
                            AName = SA.Name;
                        }
                    }
                    string BName = "--";
                    Users  OU    = UsersList.FirstOrNew(n => n.Id == item.UId);
                    if (!OU.TrueName.IsNullOrEmpty())
                    {
                        BName = OU.TrueName;
                    }
                    PayConfig PayConfig = PayConfigList.FirstOrNew(n => n.Id == item.PayWay);
                    sheet.Row(i).Height = 22;//设置行高
                    //机构
                    cells["A" + i].Value = AName;
                    //交易号
                    cells["B" + i].Value = item.TNum;
                    //交易商户
                    cells["C" + i].Value = OU.NeekName + "[" + OU.TrueName + "]";
                    //交易类型
                    cells["D" + i].Value = item.GetTTName();
                    //交易内容
                    cells["E" + i].Value = item.GetPayNameWithTName();
                    //交易金额
                    cells["F" + i].Value = item.Amoney.ToString("f2");
                    //交易时间
                    cells["G" + i].Value = item.PayTime;
                    //入账时间
                    cells["H" + i].Value = (item.InTimed != null?Convert.ToDateTime(item.InTimed).ToString():"");
                    //支付方式
                    cells["I" + i].Value = PayConfig.Name;
                    //订单状态
                    cells["J" + i].Value = item.GetState();
                    string temp = string.Empty;
                    if (item.TType == 2 || item.TType == 5)
                    {
                        temp = "T+" + item.TrunType;
                    }
                    if (item.TType == 1 || item.TType == 7 || item.TType == 8 || item.TType == 9)
                    {
                        temp = "T+" + item.LagEntryDay;
                    }
                    //接收方式
                    cells["K" + i].Value = temp;
                    double  I = 0, K = 0, N = 0;
                    decimal J = 0, L = 0, M = 0;
                    string  Is = "";
                    #region MyRegion
                    if (item.TType == 1)
                    {                                                                                                                            //银联卡支付订单
                        OrderRecharge OrderRecharge = Entity.OrderRecharge.FirstOrNew(n => n.OId == item.TNum);
                        I = OrderRecharge.UserRate;                                                                                              //商户费率
                        J = OrderRecharge.Poundage;                                                                                              //手续费
                        K = OrderRecharge.SysRate;                                                                                               //第三方费率
                        L = ((decimal)OrderRecharge.SysRate * OrderRecharge.Amoney).Ceiling();                                                   //第三方手续费
                        N = OrderRecharge.AgentPayGet;                                                                                           //分支机构提成
                        M = OrderRecharge.Poundage - (decimal)OrderRecharge.SysRate * OrderRecharge.Amoney - (decimal)OrderRecharge.AgentPayGet; //利润
                    }
                    if (item.TType == 2)
                    { //提现订单
                        OrderCash OrderCash = Entity.OrderCash.FirstOrNew(n => n.OId == item.TNum);
                        I = 0;
                        if (!OrderCash.ECash.IsNullOrEmpty() && !OrderCash.Cash.IsNullOrEmpty())
                        {
                            Is = OrderCash.ECash.ToMoney() + "+" + (OrderCash.Cash * 100).ToString("F2") + "%";
                        }
                        else if (!OrderCash.ECash.IsNullOrEmpty())
                        {
                            Is = OrderCash.ECash.ToMoney();
                        }
                        else if (!OrderCash.Cash.IsNullOrEmpty())
                        {
                            Is = (OrderCash.Cash * 100).ToString("F2") + "%";
                        }
                        else
                        {
                            Is = "0";
                        }
                        J = (decimal)OrderCash.UserRate;                                                        //手续费
                        K = 0;                                                                                  //第三方费率
                        L = OrderCash.CashRate;                                                                 //第三方手续费
                        N = OrderCash.AgentCashGet;                                                             //分支机构提成
                        M = (decimal)OrderCash.UserRate - OrderCash.CashRate - (decimal)OrderCash.AgentCashGet; //利润
                    }
                    if (item.TType == 3)
                    {                                                                                               //转帐订单
                        OrderTransfer OrderTransfer = Entity.OrderTransfer.FirstOrNew(n => n.OId == item.TNum);
                        I = OrderTransfer.UserRate;                                                                 //商户费率
                        J = OrderTransfer.Poundage;                                                                 //手续费
                        K = OrderTransfer.SysRate;                                                                  //第三方费率
                        L = ((decimal)OrderTransfer.SysRate * OrderTransfer.Amoney).Ceiling();                      //第三方手续费
                        N = OrderTransfer.AgentPayGet;                                                              //分支机构提成
                        M = OrderTransfer.Amoney - OrderTransfer.PayMoney - L - (decimal)OrderTransfer.AgentPayGet; //利润
                    }
                    if (item.TType == 5)
                    {                                                                                      //付房租订单
                        OrderHouse OrderHouse = Entity.OrderHouse.FirstOrNew(n => n.OId == item.TNum);
                        I = OrderHouse.UserRate + (double)OrderHouse.CashRate;                             //商户费率
                        J = OrderHouse.Poundage;                                                           //手续费
                        K = OrderHouse.SysRate;                                                            //第三方费率
                        L = ((decimal)OrderHouse.SysRate * OrderHouse.Amoney).Ceiling();                   //第三方手续费
                        N = OrderHouse.AgentPayGet;                                                        //分支机构提成
                        M = OrderHouse.Amoney - OrderHouse.PayMoney - L - (decimal)OrderHouse.AgentPayGet; //利润
                    }
                    if (item.TType == 6)
                    {                                                                            //升级订单
                        PayConfigOrder PayConfigOrder = Entity.PayConfigOrder.FirstOrNew(n => n.OId == item.TNum);
                        I = 0;                                                                   //商户费率
                        J = PayConfigOrder.Poundage;                                             //手续费
                        K = PayConfigOrder.SysRate;                                              //第三方费率
                        L = ((decimal)PayConfigOrder.SysRate * PayConfigOrder.Amoney).Ceiling(); //第三方手续费
                        N = PayConfigOrder.AgentGet;                                             //分支机构提成
                        M = PayConfigOrder.Amoney - (decimal)PayConfigOrder.AgentGet;            //利润
                    }
                    if (item.TType == 7 || item.TType == 8 || item.TType == 9)
                    {                                                                                                        //当面付
                        OrderF2F OrderF2F = Entity.OrderF2F.FirstOrNew(n => n.OId == item.TNum);
                        I = OrderF2F.UserRate;                                                                               //商户费率
                        J = OrderF2F.Poundage;                                                                               //手续费
                        K = OrderF2F.SysRate;                                                                                //第三方费率
                        L = ((decimal)OrderF2F.SysRate * OrderF2F.Amoney).Ceiling();                                         //第三方手续费
                        N = OrderF2F.AgentPayGet;                                                                            //分支机构提成
                        M = OrderF2F.Poundage - (decimal)OrderF2F.SysRate * OrderF2F.Amoney - (decimal)OrderF2F.AgentPayGet; //利润
                    }
                    if (item.TType == 10)
                    {                                                         //升级订单
                        DaiLiOrder DaiLiOrder = Entity.DaiLiOrder.FirstOrNew(n => n.OId == item.TNum);
                        I = 0;                                                //商户费率
                        J = 0;                                                //手续费
                        K = 0;                                                //第三方费率
                        L = 0;                                                //第三方手续费
                        N = DaiLiOrder.AgentGet;                              //分支机构提成
                        M = DaiLiOrder.Amoney - (decimal)DaiLiOrder.AgentGet; //利润
                    }
                    #endregion
                    //用户费率9
                    if (item.TType == 2)
                    {
                        cells["L" + i].Value = Is;
                    }
                    else
                    {
                        cells["L" + i].Value = I;
                    }
                    //用户手续费10
                    cells["M" + i].Value = J;
                    //支出费率11 系统费率
                    cells["N" + i].Value = K;
                    //支出手续费12
                    cells["O" + i].Value = L;
                    //利润13
                    cells["P" + i].Value = M;
                    //结算金额14
                    cells["Q" + i].Value = N;
                    i++;
                    #endregion
                }
                sheet.Row(i).Height = 40;//设置行高
                //交易总额
                cells["F" + i].Formula = "SUM(F" + Befor + ":F" + (i - 1) + ")";
                //用户手续费10
                cells["M" + i].Formula = "SUM(M" + Befor + ":M" + (i - 1) + ")";
                //支出手续费12
                cells["O" + i].Formula = "SUM(O" + Befor + ":O" + (i - 1) + ")";
                //利润13
                cells["P" + i].Formula = "SUM(P" + Befor + ":P" + (i - 1) + ")";
                //结算金额14
                cells["Q" + i].Formula = "SUM(Q" + Befor + ":Q" + (i - 1) + ")";

                i--;
                maxCol = 17;
                //cells["B" + (i + 2)].Value = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Left.Style   = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Right.Style  = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Top.Style    = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;//居中
                sheet.Cells[Befor, 7, i, 7].Style.Numberformat.Format      = "yyyy-mm-dd HH:mm:ss";
                sheet.Cells[Befor, 8, i, 8].Style.Numberformat.Format      = "yyyy-mm-dd HH:mm:ss";
                sheet.Cells[Befor, 12, i, 12].Style.Numberformat.Format    = "#0.00%";
                sheet.Cells[Befor, 14, i, 14].Style.Numberformat.Format    = "#0.00%";
                i++;
                sheet.Cells[Befor, 6, i, 6].Style.Numberformat.Format   = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                sheet.Cells[Befor, 13, i, 13].Style.Numberformat.Format = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                sheet.Cells[Befor, 15, i, 15].Style.Numberformat.Format = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                sheet.Cells[Befor, 16, i, 16].Style.Numberformat.Format = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                sheet.Cells[Befor, 17, i, 17].Style.Numberformat.Format = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                Response.BinaryWrite(package.GetAsByteArray());
                //输出
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=" + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(10, 99) + ".xlsx");
                #endregion
            }
            else
            {
                Response.Write("暂无符合条件数据");
            }
        }
        public void XLSDo(Orders Orders, EFPagingInfo <Orders> p)
        {
            if (Orders.STime.IsNullOrEmpty())
            {
                Orders.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (Orders.ETime.IsNullOrEmpty())
            {
                Orders.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            p.SqlWhere.Add(f => f.PayState == 1);
            p.SqlWhere.Add(f => f.TState == 2);
            if (!Orders.TNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TNum == Orders.TNum);
            }
            //if (!Orders.UId.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.UId == Orders.UId); }
            if (!Orders.TName.IsNullOrEmpty())
            {
                IList <Users> UList = Entity.Users.Where(n => n.TrueName.Contains(Orders.TName) || n.NeekName.Contains(Orders.TName) || n.UserName == Orders.TName).ToList();
                List <int>    UIds  = new List <int>();
                foreach (var pp in UList)
                {
                    UIds.Add(pp.Id);
                }
                p.SqlWhere.Add(f => UIds.Contains(f.UId));
            }
            if (!Orders.TType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TType == Orders.TType);
            }
            if (!Orders.Agent.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Agent == Orders.Agent);
            }
            if (!Orders.AgentState.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentState == (Orders.AgentState == 99 ? 0 : Orders.AgentState));
            }
            if (!Orders.STime.IsNullOrEmpty() && !Orders.ETime.IsNullOrEmpty())
            {
                DateTime ETime = Orders.ETime;
                p.SqlWhere.Add(f => f.PayTime > Orders.STime && f.PayTime < ETime);
            }
            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <Orders> OrdersList = Entity.Selects <Orders>(p);
            IList <Orders>        List       = OrdersList.GroupBy(n => n.UId).Select(n => n.First()).ToList();
            List <int>            UId        = new List <int>();

            foreach (var pp in List)
            {
                UId.Add(pp.UId);
            }
            IList <Users>  UsersList = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();
            IList <Orders> List1     = OrdersList.GroupBy(n => n.Agent).Select(n => n.First()).ToList();
            List <int>     AgentId   = new List <int>();

            foreach (var pp in List1)
            {
                AgentId.Add(pp.Agent);
            }
            if (this.TempData["SysAgentList"] == null)
            {
                Response.Write("当前页面数据已过期");
            }
            this.TempData.Keep("SysAgentList");
            IList <SysAgent> SysAgentList = this.TempData["SysAgentList"] as IList <SysAgent>;//Entity.SysAgent.Where(n => n.State == 1 && AgentId.Contains(n.Id)).ToList();

            if (SysAgentList != null && SysAgentList.Count > 0)
            {
                //加载对应模板
                string       tempname = "order.xlsx";
                string       file     = Server.MapPath("/template") + "\\" + tempname;
                ExcelPackage package  = new ExcelPackage(new FileInfo(file), true);
                //设置数据开始行
                int Befor  = 2;
                int maxCol = 8;//最大列数
                //加载模板第一张表
                var     sheet      = package.Workbook.Worksheets[1];
                var     cells      = sheet.Cells;
                decimal TotalMoney = 0; //计算总金额
                double  TotalPrice = 0; //计算总金额
                int     Rows       = OrdersList.Count() + SysAgentList.Count();
                sheet.InsertRow(Befor + 1, Rows - 1, Befor);
                int i = Befor;
                foreach (var item in SysAgentList)
                {
                    IList <Orders> ListSub    = OrdersList.Where(n => n.Agent == item.Id).ToList();
                    decimal        AgentMoney = 0; //计算供应商金额
                    double         AgentPrice = 0; //计算供应商金额
                    foreach (var s in ListSub)
                    {
                        sheet.Row(i).Height = 20;//设置行高
                        Users U = UsersList.FirstOrNew(n => n.Id == s.UId);
                        //分支机构
                        cells["A" + i].Value = item.Name;
                        //交易号
                        cells["B" + i].Value = s.TNum;
                        //交易商户
                        cells["C" + i].Value = U.TrueName;
                        //交易类型
                        cells["D" + i].Value = s.GetTTName();
                        //交易内容
                        cells["E" + i].Value = s.GetPayNameWithTName();
                        //交易金额
                        cells["F" + i].Value = s.Amoney;
                        //交易时间
                        cells["G" + i].Value = s.PayTime;
                        //结算金额
                        double agentmoney = s.GetAgentMoney(Entity);
                        cells["H" + i].Value = agentmoney;
                        AgentMoney          += s.Amoney;
                        AgentPrice          += agentmoney;
                        i++;
                    }
                    sheet.Row(i).Height = 28;//设置行高
                    //交易金额汇总
                    cells["F" + i].Value = AgentMoney;
                    //结算金额汇总
                    cells["H" + i].Value = AgentPrice;
                    Color bgColor = ColorTranslator.FromHtml("#DDDDDD");
                    Color fColor  = ColorTranslator.FromHtml("#FF0000");
                    sheet.Cells[i, 1, i, maxCol].Style.Fill.PatternType = ExcelFillStyle.Solid;
                    sheet.Cells[i, 1, i, maxCol].Style.Fill.BackgroundColor.SetColor(bgColor);
                    sheet.Cells[i, 1, i, maxCol].Style.Font.Size = 16;
                    sheet.Cells[i, 1, i, maxCol].Style.Font.Bold = true;
                    sheet.Cells[i, 1, i, maxCol].Style.Font.Color.SetColor(fColor);
                    TotalMoney += AgentMoney;
                    TotalPrice += AgentPrice;
                    i++;
                }
                Color bgColor_ = ColorTranslator.FromHtml("#7030A0");
                Color fColor_  = ColorTranslator.FromHtml("#FFFFFF");
                sheet.Cells[i, 1, i, maxCol].Style.Fill.PatternType = ExcelFillStyle.Solid;
                sheet.Cells[i, 1, i, maxCol].Style.Fill.BackgroundColor.SetColor(bgColor_);
                sheet.Cells[i, 1, i, maxCol].Style.Font.Size = 20;
                sheet.Cells[i, 1, i, maxCol].Style.Font.Bold = true;
                sheet.Cells[i, 1, i, maxCol].Style.Font.Color.SetColor(fColor_);
                sheet.Row(i).Height = 40;//设置行高
                //交易金额汇总
                cells["F" + i].Value = TotalMoney;
                //结算金额汇总
                cells["H" + i].Value = TotalPrice;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Left.Style   = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Right.Style  = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Top.Style    = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 6, i, 6].Style.Numberformat.Format      = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                sheet.Cells[Befor, 7, i, 7].Style.Numberformat.Format      = "yyyy-mm-dd hh:mm";
                sheet.Cells[Befor, 8, i, 8].Style.Numberformat.Format      = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                Response.BinaryWrite(package.GetAsByteArray());//输出
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=" + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(10, 99) + ".xlsx");
            }
            else
            {
                Response.Write("暂无符合条件数据");
            }
        }
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="WTimes"></param>
        public void XlsDo(UserLog UserLog, EFPagingInfo <UserLog> p, DateTime?STime, DateTime?ETime)
        {
            p.SqlWhere.Add(f => f.UId == UserLog.UId);
            p.PageSize = 99999999;
            if (!UserLog.OId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.OId == UserLog.OId);
            }
            if (STime.HasValue)
            {
                p.SqlWhere.Add(f => f.AddTime >= STime);
            }
            if (ETime.HasValue)
            {
                if (ETime < new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day))
                {
                    ETime = new DateTime(ETime.Value.Year, ETime.Value.Month, ETime.Value.Day, 23, 59, 59, 999);
                }
                //else
                //{
                //    ETime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, 999);
                //}
                p.SqlWhere.Add(f => f.AddTime <= ETime);
            }

            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <UserLog> UserLogList = Entity.Selects <UserLog>(p);
            var UsersLogList = UserLogList.ToList();

            if (UsersLogList == null || UsersLogList.Count <= 0)
            {
                Response.Write("暂无符合条件数据");
                return;
            }
            string       tempname = "UserLog.xlsx";
            string       file     = Server.MapPath("/template") + "\\" + tempname;
            ExcelPackage package  = new ExcelPackage(new FileInfo(file), true);
            var          sheet    = package.Workbook.Worksheets[1];
            var          cells    = sheet.Cells;
            int          i        = 3;
            var          typename = "";
            //设置数据开始行
            int Befor = 3;

            foreach (var model in UsersLogList)
            {
                sheet.Row(i).Height = 20;//设置行高

                cells["A" + i].Value = model.OId;
                switch (model.OType)
                {
                case 1:
                    typename = "收款";
                    break;

                case 2:
                    typename = "付款";
                    break;

                case 3:
                    typename = "申请提现";
                    break;

                case 4:
                    typename = "提现";
                    break;

                case 5:
                    typename = "提现失败";
                    break;

                case 6:
                    typename = "退款冲正";
                    break;

                case 7:
                    typename = "奖金";
                    break;

                case 8:
                    typename = "分润";
                    break;

                case 9:
                    typename = "冻结";
                    break;

                case 10:
                    typename = "解冻";
                    break;

                case 11:
                    typename = "退款";
                    break;

                case 12:
                    typename = "扣款";
                    break;
                }
                cells["B" + i].Value = typename;
                cells["C" + i].Value = model.Amount;
                cells["D" + i].Value = model.BeforAmount;
                cells["E" + i].Value = model.BeforFrozen;
                cells["F" + i].Value = model.AfterAmount;
                cells["G" + i].Value = model.AfterFrozen;
                cells["H" + i].Value = model.AddTime.ToString("yyyy-MM-dd HH:mm");
                i++;
            }

            sheet.Cells[Befor, 3, i, 3].Style.Numberformat.Format = "#,##0.00";
            sheet.Cells[Befor, 4, i, 4].Style.Numberformat.Format = "#,##0.00";
            sheet.Cells[Befor, 5, i, 5].Style.Numberformat.Format = "#,##0.00";
            sheet.Cells[Befor, 6, i, 6].Style.Numberformat.Format = "#,##0.00";
            sheet.Cells[Befor, 7, i, 7].Style.Numberformat.Format = "#,##0.00";
            Response.BinaryWrite(package.GetAsByteArray());//输出
            Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            Response.AddHeader("content-disposition", "attachment;  filename=余额变动明细表" + DateTime.Now.ToString("yyyyMMddHHmm") + ".xlsx");
        }
        public ActionResult Index(ApplyLoan ApplyLoan, EFPagingInfo <ApplyLoan> p, bool?IsShowSupAgent, int IsFirst = 0)
        {
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            if (ApplyLoan.STime.IsNullOrEmpty())
            {
                ApplyLoan.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (ApplyLoan.ETime.IsNullOrEmpty())
            {
                //  ApplyLoan.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                ApplyLoan.ETime = DateTime.Now;
            }
            if (IsFirst == 0)
            {
                PageOfItems <ApplyLoan> ApplyLoanList1 = new PageOfItems <ApplyLoan>(new List <ApplyLoan>(), 0, 10, 0, new Hashtable());
                ViewBag.ApplyLoanList  = ApplyLoanList1;
                ViewBag.ApplyLoan      = ApplyLoan;
                ViewBag.SysAgentList   = Entity.SysAgent.Where(n => n.Tier == 1).ToList();
                ViewBag.IsShowSupAgent = IsShowSupAgent;
                ViewBag.Xls            = this.checkPower("Xls");
                return(View());
            }

            if (!ApplyLoan.TrueName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TrueName == ApplyLoan.TrueName);
            }
            if (!ApplyLoan.Education.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Education.Contains(ApplyLoan.Education));
            }
            if (!ApplyLoan.HasSheBao.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasSheBao == (ApplyLoan.HasSheBao == 99 ? 0 : ApplyLoan.HasSheBao));
            }
            if (!ApplyLoan.Marry.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Marry == ApplyLoan.Marry);
            }
            if (!ApplyLoan.HasCar.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasCar == (ApplyLoan.HasCar == 99 ? 0 : ApplyLoan.HasCar));
            }
            if (!ApplyLoan.House.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.House == ApplyLoan.House);
            }
            if (!ApplyLoan.HasCredit.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasCredit == ApplyLoan.HasCredit);
            }
            if (!ApplyLoan.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == ApplyLoan.State);
            }
            if (!ApplyLoan.AgentPay.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentPay == (ApplyLoan.AgentPay == 99 ? 0 : ApplyLoan.AgentPay));
            }
            if (!ApplyLoan.AgentAId.IsNullOrEmpty())
            {
                //是否要显示下级
                if ((bool)IsShowSupAgent)
                {
                    SysAgent         LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == ApplyLoan.AgentAId).FirstOrNew();
                    IList <SysAgent> SysAgentList    = LowerLevelAgent.GetSupAgent(Entity);
                    IList <int>      UID             = new List <int>();
                    foreach (var s in SysAgentList)
                    {
                        UID.Add(s.Id);
                    }
                    p.SqlWhere.Add(f => UID.Contains(f.AgentAId));
                }
                else
                {
                    p.SqlWhere.Add(f => f.AgentAId == ApplyLoan.AgentAId);
                }
            }
            if (!ApplyLoan.STime.IsNullOrEmpty() && !ApplyLoan.ETime.IsNullOrEmpty())
            {
                DateTime ETime = ApplyLoan.ETime;
                p.SqlWhere.Add(f => f.PayTime > ApplyLoan.STime && f.PayTime < ETime);
            }
            p.SqlWhere.Add(f => f.PayState == 1);
            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyLoan> ApplyLoanList = Entity.Selects <ApplyLoan>(p);

            ViewBag.ApplyLoanList = ApplyLoanList;
            ViewBag.ApplyLoan     = ApplyLoan;
            IList <ApplyLoan> List    = ApplyLoanList.GroupBy(n => n.AgentId).Select(n => n.First()).ToList();
            List <int>        AgentId = new List <int>();

            foreach (var pp in List)
            {
                AgentId.Add(pp.AgentId);
            }
            ViewBag.SysAgentList   = Entity.SysAgent.Where(n => AgentId.Contains(n.Id) && n.Tier == 1).ToList();
            ViewBag.IsShowSupAgent = IsShowSupAgent;
            ViewBag.Xls            = this.checkPower("Xls");
            return(View());
        }
Exemple #6
0
        /// <summary>
        /// 统计
        /// </summary>
        /// <returns></returns>
        public ActionResult IndexStats(FastOrder FastOrder, EFPagingInfo <FastOrder> p, bool IsShowSupAgent, int LowerLevel)
        {
            if (FastOrder.STime.IsNullOrEmpty() || FastOrder.ETime.IsNullOrEmpty())
            {
                ViewBag.ErrorMsg = "请选择日期";
                return(View("Error"));
            }
            Dictionary <string, string> dicChar = new Dictionary <string, string>();

            dicChar.Add("STIME", FastOrder.STime.ToString("yyyy-MM-dd HH:mm:ss"));
            dicChar.Add("ETIME", FastOrder.ETime.ToString("yyyy-MM-dd HH:mm:ss"));
            string AGENTID = "";
            string IFALL   = "";

            if ((bool)IsShowSupAgent)
            {
                IFALL = "1";
            }
            else
            {
                IFALL = "0";
            }
            if (LowerLevel != 0)
            {
                AGENTID = LowerLevel.ToString();
            }
            else
            {
                AGENTID = BasicAgent.Id.ToString();//获取所有下级代理商信息
            }
            dicChar.Add("AGENTID", AGENTID);
            dicChar.Add("AGENT", BasicAgent.Id.ToString());

            if (!FastOrder.OType.IsNullOrEmpty())
            {
                dicChar.Add("OType", FastOrder.OType.ToString());
            }
            else
            {
                dicChar.Add("OType", "");
            }
            string State     = "";
            string PayState  = "";
            string TNum      = "";
            string CODE      = "";
            string USERSTATE = "";

            if (!FastOrder.State.IsNullOrEmpty())
            {
                switch (FastOrder.State)
                {
                case 1:    //未付
                    State    = "1";
                    PayState = "0";
                    break;

                case 2:    //已付
                    State    = "1";
                    PayState = "1";
                    break;

                case 99:    //交易关闭
                    State = "0";
                    break;
                }
            }
            //商户号
            if (!FastOrder.TNum.IsNullOrEmpty())
            {
                if (FastOrder.UId == 1)
                {
                    TNum = FastOrder.TNum;
                }
                else
                {
                    CODE = FastOrder.TNum;
                }
            }
            if (!FastOrder.UserState.IsNullOrEmpty())
            {
                USERSTATE = (FastOrder.UserState == 99 ? 0 : FastOrder.UserState).ToString();
            }
            dicChar.Add("State", State);
            dicChar.Add("PayState", PayState);
            dicChar.Add("TNum", TNum);
            dicChar.Add("CODE", CODE);
            dicChar.Add("IFALL", IFALL);
            dicChar.Add("USERSTATE", USERSTATE);
            IList <TongJiFastOrder> TongJiFastOrder = Entity.GetSPExtensions <TongJiFastOrder>("SP_Statistics_Fastorder_sum", dicChar);

            ViewBag.SumAmoney = TongJiFastOrder[0].Amoney;
            ViewBag.SumProfit = TongJiFastOrder[0].Profit;
            return(this.View());
        }
        public FileResult ExcelExport(FastOrder FastOrder, EFPagingInfo <FastOrder> p, bool?IsShowSupAgent)
        {
            p.PageSize = 9999999;
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            p = this.Condition(FastOrder, p, IsShowSupAgent.Value);
            IPageOfItems <FastOrder> FastOrderList = Entity.Selects <FastOrder>(p);
            List <int> UId = FastOrderList.Select(o => o.UId).Distinct().ToList();
            //List<int> AgentIds = FastOrderList.Select(o => o.Agent).Distinct().ToList();
            var UsersList = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();
            //var ResideSysAgentList = Entity.SysAgent.Where(n => AgentIds.Contains(n.Id)).ToList();
            var FastPayWayList = Entity.FastPayWay.ToList();
            var SysAgentList   = Entity.SysAgent.Where(n => n.Tier == 1).ToList();

            DataTable table = new DataTable();
            DataRow   row   = null;

            // 创建 datatable
            table.Columns.Add(new DataColumn("交易号", typeof(string)));
            table.Columns.Add(new DataColumn("交易商户", typeof(string)));
            table.Columns.Add(new DataColumn("总金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("手续费", typeof(decimal)));
            table.Columns.Add(new DataColumn("分润", typeof(decimal)));
            table.Columns.Add(new DataColumn("成本费率‰", typeof(decimal)));
            table.Columns.Add(new DataColumn("成本费用(交易)", typeof(decimal)));
            table.Columns.Add(new DataColumn("成本费用(代付)", typeof(decimal)));
            table.Columns.Add(new DataColumn("用户费率‰", typeof(decimal)));
            table.Columns.Add(new DataColumn("用户费用", typeof(decimal)));
            table.Columns.Add(new DataColumn("利润", typeof(decimal)));
            table.Columns.Add(new DataColumn("交易类型", typeof(string)));
            table.Columns.Add(new DataColumn("交易时间", typeof(string)));
            table.Columns.Add(new DataColumn("交易状态", typeof(string)));
            table.Columns.Add(new DataColumn("用户结算", typeof(string)));
            table.Columns.Add(new DataColumn("代理结算", typeof(string)));
            table.Columns.Add(new DataColumn("支付通道", typeof(string)));
            table.Columns.Add(new DataColumn("支付时间", typeof(string)));
            table.Columns.Add(new DataColumn("分支机构", typeof(string)));
            table.Columns.Add(new DataColumn("同级分润", typeof(decimal)));

            // 填充数据
            foreach (var item in FastOrderList)
            {
                var AgentPathArr = item.AgentPath.Split('|').ToList();
                AgentPathArr.RemoveAll(o => o == string.Empty);
                string TopAgentName = "";
                if (AgentPathArr.Count > 0)
                {
                    int AgentID = 0;
                    if (int.TryParse(AgentPathArr[0], out AgentID))
                    {
                        TopAgentName = SysAgentList.FirstOrNew(o => o.Id == AgentID).Name;
                    }
                }

                row     = table.NewRow();
                row[0]  = item.TNum;
                row[1]  = UsersList.FirstOrNew(o => o.Id == item.UId).TrueName;
                row[2]  = item.Amoney.ToString("F2");
                row[3]  = item.Poundage.ToString("F2");
                row[4]  = item.AgentPayGet.ToString("F2");
                row[5]  = (item.SysRate * 1000).ToString("F2");
                row[6]  = (item.SysRate * item.Amoney).Floor().ToString("F2");
                row[7]  = item.SysCash.ToString("F2");
                row[8]  = (item.UserRate * 1000).ToString("F2");
                row[9]  = item.UserCash.ToString("F2");
                row[10] = item.HFGet.ToString("F2");
                row[11] = Utils.GetFastOrderModel().FirstOrNew(n => n.Id == item.OType).Name;
                row[12] = item.AddTime.ToString("yyyy-MM-dd HH:mm");
                row[13] = item.GetState();
                row[14] = item.GetUserClearingState();
                row[15] = item.GetAgentClearingState();
                row[16] = FastPayWayList.FirstOrNew(o => o.Id == item.PayWay).Title;
                row[17] = item.PayTime.HasValue ? item.PayTime.Value.ToString("yyyy-MM-dd HH:mm") : "";
                row[18] = TopAgentName;
                row[19] = item.SameGet.ToString("F2");
                table.Rows.Add(row);
            }

            return(this.ExportExcelBase(table, "收付直通车"));
        }
        public ActionResult Index(FastOrder FastOrder, EFPagingInfo <Orders> p)
        {
            p.PageSize = 20;
            string STimeStr = string.Empty;
            string ETimeStr = string.Empty;
            string TNumStr  = string.Empty;

            if (FastOrder.STime == null || FastOrder.STime == DateTime.MinValue)
            {
                FastOrder.STime = DateTime.Now.AddDays(-1);
            }
            if (FastOrder.ETime == null || FastOrder.ETime == DateTime.MinValue)
            {
                FastOrder.ETime = DateTime.Now;
            }

            TimeSpan TS   = FastOrder.ETime.Subtract(FastOrder.STime);
            int      Days = TS.Days;

            if (Days > 31)
            {
                ViewBag.ErrorMsg = "统计时间间隔不能超过31天!";
                return(View("Error"));
            }
            STimeStr = " AND L.AddTime >= '" + FastOrder.STime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            ETimeStr = " AND L.AddTime <= '" + FastOrder.ETime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            if (!FastOrder.TNum.IsNullOrEmpty())
            {
                TNumStr = " AND L.TNum = '" + FastOrder.TNum.ToString() + "'";
            }
            int           s        = ((p.PageIndex == 0 ? 1 : p.PageIndex) - 1) * p.PageSize;
            int           e        = (p.PageIndex + 1) * p.PageSize;
            var           DataList = new List <FastShareProfitModel>();
            StringBuilder sql      = new StringBuilder();

            sql.Append(" select * From ( ");
            sql.Append(" select O.Id,row_number() OVER (ORDER BY O.Id DESC) AS RowNumber,O.TNum,O.OType,O.UserState,O.Amoney,ISNULL(L.UId,0) UId,ISNULL(L.LogType,0) LogType,ISNULL(Sum(L.Profit), 0) Profit,L.AddTime  ");
            sql.Append(" From FastOrder(nolock) O Left Join OrderProfitLog(nolock) L ON O.TNum=L.TNum AND L.IsDel=0 ");
            sql.Append(" Where O.IsDel=0 " + STimeStr + ETimeStr + TNumStr);
            sql.Append(" Group By O.Id,O.TNum,L.UId,O.Amoney,O.OType,O.UserState,L.LogType,L.AddTime ");
            sql.Append(" ) AS D Where RowNumber BETWEEN " + s.ToString() + " AND " + e.ToString() + " Order By Id desc");
            DataList = Entity.ExecuteStoreQuery <FastShareProfitModel>(sql.ToString(), null).ToList();

            StringBuilder sql2 = new StringBuilder();

            sql2.Append(" select Count(1) c From ( ");
            sql2.Append(" select O.Id ");
            sql2.Append(" From FastOrder(nolock) O Left Join OrderProfitLog(nolock) L ON O.TNum=L.TNum AND L.IsDel=0 ");
            sql2.Append(" Where O.IsDel=0 " + STimeStr + ETimeStr + TNumStr);
            sql2.Append(" Group By O.Id,O.TNum,L.UId,O.Amoney,O.OType,O.UserState,L.LogType,L.AddTime ");
            sql2.Append(" ) AS D ");
            int c = Entity.ExecuteStoreQuery <int>(sql2.ToString(), null).FirstOrDefault();

            DataList = new PageOfItems <FastShareProfitModel>(DataList, p.PageIndex, p.PageSize, c, null);

            var UIds      = DataList.Select(o => o.UId).ToList();
            var UsersList = this.Entity.Users.Where(o => UIds.Contains(o.Id)).ToList();

            ViewBag.UsersList = UsersList;
            ViewBag.DataList  = DataList;
            ViewBag.FastOrder = FastOrder;
            ViewBag.Xls       = this.checkPower("ExcelExport");
            return(View());
        }
        public FileResult ExcelExport(FastOrder FastOrder, EFPagingInfo <FastOrder> p)
        {
            p.PageSize = 9999999;
            #region 查询条件
            string STimeStr = string.Empty;
            string ETimeStr = string.Empty;
            string TNumStr  = string.Empty;
            if (FastOrder.STime == null || FastOrder.STime == DateTime.MinValue)
            {
                FastOrder.STime = DateTime.Now.AddDays(-1);
            }
            if (FastOrder.ETime == null || FastOrder.ETime == DateTime.MinValue)
            {
                FastOrder.ETime = DateTime.Now;
            }

            TimeSpan TS   = FastOrder.ETime.Subtract(FastOrder.STime);
            int      Days = TS.Days;
            if (Days > 31)
            {
                return(null);
            }
            STimeStr = " AND L.AddTime >= '" + FastOrder.STime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            ETimeStr = " AND L.AddTime <= '" + FastOrder.ETime.ToString("yyyy-MM-dd HH:mm:ss") + "'";
            if (!FastOrder.TNum.IsNullOrEmpty())
            {
                TNumStr = " AND L.TNum = " + FastOrder.TNum.ToString();
            }
            int           s        = ((p.PageIndex == 0 ? 1 : p.PageIndex) - 1) * p.PageSize;
            int           e        = (p.PageIndex + 1) * p.PageSize;
            var           DataList = new List <FastShareProfitModel>();
            StringBuilder sql      = new StringBuilder();
            sql.Append(" select * From ( ");
            sql.Append(" select O.Id,row_number() OVER (ORDER BY O.Id DESC) AS RowNumber,O.TNum,O.OType,O.UserState,O.Amoney,ISNULL(L.UId,0) UId,ISNULL(L.LogType,0) LogType,ISNULL(Sum(L.Profit), 0) Profit,L.AddTime  ");
            sql.Append(" From FastOrder(nolock) O Left Join OrderProfitLog(nolock) L ON O.TNum=L.TNum AND L.IsDel=0 ");
            sql.Append(" Where O.IsDel=0 " + STimeStr + ETimeStr + TNumStr);
            sql.Append(" Group By O.Id,O.TNum,L.UId,O.Amoney,O.OType,O.UserState,L.LogType,L.AddTime ");
            sql.Append(" ) AS D Where RowNumber BETWEEN " + s.ToString() + " AND " + e.ToString() + " Order By Id desc");
            DataList = Entity.ExecuteStoreQuery <FastShareProfitModel>(sql.ToString(), null).ToList();
            var UIds      = DataList.Select(o => o.UId).ToList();
            var UsersList = this.Entity.Users.Where(o => UIds.Contains(o.Id)).ToList();
            #endregion

            DataTable table = new DataTable();
            DataRow   row   = null;

            // 创建 datatable
            table.Columns.Add(new DataColumn("交易号", typeof(string)));
            table.Columns.Add(new DataColumn("交易类型", typeof(string)));
            table.Columns.Add(new DataColumn("交易金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("结算状态", typeof(string)));
            table.Columns.Add(new DataColumn("分润商户", typeof(string)));
            table.Columns.Add(new DataColumn("分润类型", typeof(string)));
            table.Columns.Add(new DataColumn("分润金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("分润时间", typeof(string)));

            // 填充数据
            foreach (var item in DataList)
            {
                var u = UsersList.FirstOrNew(o => o.Id == item.UId);
                row    = table.NewRow();
                row[0] = item.TNum;
                row[1] = Utils.GetFastOrderModel().FirstOrNew(n => n.Id == item.OType).Name;
                row[2] = item.Amoney.ToString("F2");
                row[3] = UserStateName(item.UserState);
                row[4] = u.UserName;
                row[5] = LogTypeName(item.LogType);
                row[6] = item.Profit.ToString("F2");
                row[7] = item.AddTime.ToString("yyyy-MM-dd HH:mm:ss");
                table.Rows.Add(row);
            }

            return(this.ExportExcelBase(table, "直通车分润"));
        }
        public ActionResult Index(FastUserPay FastUserPay, EFPagingInfo <FastUserPay> p, DateTime?STime, DateTime?ETime, int IsFirst = 0)
        {
            #region 筛选条件
            if (!FastUserPay.MerId.IsNullOrEmpty())
            {
                switch (FastUserPay.Bin)
                {
                case "1":
                    var ids = this.Entity.Users.Where(o => o.TrueName.Contains(FastUserPay.MerId)).Select(o => o.Id).ToList();
                    p.SqlWhere.Add(f => ids.Contains(f.UId));
                    break;

                case "2":
                    var uid = this.Entity.Users.Where(o => o.UserName.Contains(FastUserPay.MerId)).Select(o => o.Id).ToList();
                    p.SqlWhere.Add(f => uid.Contains(f.UId));
                    break;
                }
            }
            if (!FastUserPay.MerState.IsNullOrEmpty())
            {
                var MerState = FastUserPay.MerState == 99 ? 0 : FastUserPay.MerState;
                p.SqlWhere.Add(f => f.MerState == MerState);
            }
            if (!FastUserPay.CardState.IsNullOrEmpty())
            {
                var CardState = FastUserPay.CardState == 99 ? 0 : FastUserPay.CardState;
                p.SqlWhere.Add(f => f.CardState == CardState);
            }
            if (!FastUserPay.BusiState.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.BusiState == FastUserPay.BusiState);
            }
            if (!FastUserPay.PayWay.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.PayWay == FastUserPay.PayWay);
            }
            if (STime.HasValue)
            {
                p.SqlWhere.Add(f => f.AddTime >= STime);
            }
            if (ETime.HasValue)
            {
                p.SqlWhere.Add(f => f.AddTime <= ETime);
            }
            #endregion
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <FastUserPay> FastUserPayList = null;
            if (IsFirst == 0)
            {
                FastUserPayList = new PageOfItems <FastUserPay>(new List <FastUserPay>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                FastUserPayList = Entity.Selects <FastUserPay>(p);
            }
            var uids           = FastUserPayList.Select(o => o.UId).ToList();
            var UsersList      = this.Entity.Users.Where(o => uids.Contains(o.Id)).ToList();
            var FastPayWayList = this.Entity.FastPayWay.ToList();
            ViewBag.FastPayWayList  = FastPayWayList;
            ViewBag.UsersList       = UsersList;
            ViewBag.FastUserPayList = FastUserPayList;
            ViewBag.FastUserPay     = FastUserPay;
            ViewBag.STime           = STime;
            ViewBag.ETime           = ETime;

            return(View());
        }
Exemple #11
0
        private EFPagingInfo <OrderProfitLog> Condition(OrderProfitLog OrderProfitLog, EFPagingInfo <OrderProfitLog> p, string TName, DateTime?STime, DateTime?ETime, bool?IsShowSupAgent)
        {
            #region 校验与初始化

            // p.SqlWhere.Add(f => f.PayState == 1);
            if (!OrderProfitLog.TNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TNum == OrderProfitLog.TNum);
            }
            if (!TName.IsNullOrEmpty())
            {
                IList <Users> UList = Entity.Users.Where(n => n.TrueName == TName || n.NeekName == TName || n.UserName == TName).ToList();
                List <int>    UIds  = new List <int>();
                foreach (var pp in UList)
                {
                    UIds.Add(pp.Id);
                }
                p.SqlWhere.Add(f => UIds.Contains(f.UId));
            }

            if (!OrderProfitLog.Agent.IsNullOrEmpty())
            {
                //是否要显示下级
                if ((bool)IsShowSupAgent)
                {
                    SysAgent         LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == OrderProfitLog.Agent).FirstOrNew();
                    IList <SysAgent> AgentsList      = LowerLevelAgent.GetSupAgent(Entity);
                    IList <int>      UID             = new List <int>();
                    foreach (var s in AgentsList)
                    {
                        UID.Add(s.Id);
                    }
                    p.SqlWhere.Add(f => UID.Contains(f.Agent));
                }
                else
                {
                    p.SqlWhere.Add(f => f.Agent == OrderProfitLog.Agent);
                }
            }
            //if (!JobOrders.AgentState.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.AgentState == (JobOrders.AgentState == 99 ? 0 : JobOrders.AgentState)); }
            if (!STime.IsNullOrEmpty() && !ETime.IsNullOrEmpty())
            {
                DateTime ETimes = ETime.Value;
                p.SqlWhere.Add(f => f.AddTime > STime && f.AddTime < ETimes);
            }
            #endregion
            p.SqlWhere.Add(o => o.OrderType == 31);
            p.OrderByList.Add("Id", "DESC");

            return(p);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="JobOrders"></param>
        /// <param name="p"></param>
        /// <param name="IsShowSupAgent">是否显示下级</param>
        /// <param name="LowerLevel">下级代理商</param>
        /// <returns></returns>
        public ActionResult Index(JobOrders JobOrders, EFPagingInfo <JobOrders> p, DateTime?STime, DateTime?ETime, bool?IsShowSupAgent, int?LowerLevel, int IsFirst = 0)
        {
            #region 条件校验
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            LowerLevel = LowerLevel == null ? 0 : LowerLevel;
            p.SqlWhere.Add(f => f.PayState != 0);
            p.SqlWhere.Add(f => f.AgentState != 0);
            if (!JobOrders.TNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TNum == JobOrders.TNum);
            }
            if (!JobOrders.Code.IsNullOrEmpty())
            {
                IList <Users> UList = Entity.Users.Where(n => n.TrueName == JobOrders.Code || n.NeekName == JobOrders.Code || n.UserName == JobOrders.Code).ToList();
                List <int>    UIds  = new List <int>();
                foreach (var pp in UList)
                {
                    UIds.Add(pp.Id);
                }
                p.SqlWhere.Add(f => UIds.Contains(f.UId));
            }
            if (!JobOrders.AgentId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentId == JobOrders.AgentId);
            }
            if (!JobOrders.AgentState.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentState == JobOrders.AgentState);
            }
            if (!STime.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.PayTime > STime);
            }
            else
            {
                STime = DateTime.Now.AddMonths(-1);
            }
            if (!ETime.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.PayTime < ETime);
            }
            else
            {
                ETime = DateTime.Now;
            }
            TimeSpan TS   = ETime.Value.Subtract(STime.Value);
            int      Days = TS.Days;
            if (Days > 31)
            {
                ViewBag.ErrorMsg = "统计时间间隔不能超过31天!";
                return(View("Error"));
            }
            IList <SysAgent> AgentsList = null;
            if ((bool)IsShowSupAgent)
            {
                IList <int> UID = new List <int>();
                if (LowerLevel != 0)
                {
                    SysAgent LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == LowerLevel).FirstOrNew();
                    AgentsList = LowerLevelAgent.GetSupAgent(Entity, true);
                }
                else
                {
                    AgentsList = BasicAgent.GetSupAgent(Entity, true);//获取所有下级代理商信息
                }
                UID = AgentsList.Select(o => o.Id).ToList();
                p.SqlWhere.Add(f => UID.Contains(f.AgentId));
            }
            else
            {
                p.SqlWhere.Add(f => f.AgentId == BasicAgent.Id);//读取全部分支机构
            }
            #endregion
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <JobOrders> JobOrdersList = null;
            if (IsFirst == 0)
            {
                JobOrdersList = new PageOfItems <JobOrders>(new List <JobOrders>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                JobOrdersList = Entity.Selects <JobOrders>(p);
            }

            ViewBag.JobOrdersList = JobOrdersList;
            ViewBag.JobOrders     = JobOrders;
            //统计查询
            if (JobOrdersList.TotalCount > 0)
            {
                var iquery = Entity.JobOrders.AsQueryable();
                foreach (var item in p.SqlWhere)
                {
                    iquery = iquery.Where(item);
                }
                //总金额
                decimal SumAmoney = iquery.Sum(o => o.TotalMoney);
                ViewBag.SumAmoney = SumAmoney;
                //我的总佣金
                decimal?SumMyProfit = Entity.OrderProfitLog.Where(o => o.Agent == BasicAgent.Id && o.OrderType == 31).Join(iquery, op => op.TNum, o => o.TNum, (op, o) => op.Profit).Sum(o => (decimal?)o);
                ViewBag.SumMyProfit = SumMyProfit;
            }

            //商户查询
            IList <JobOrders> List = JobOrdersList.GroupBy(n => n.UId).Select(n => n.First()).ToList();
            List <int>        UId  = new List <int>();
            foreach (var pp in List)
            {
                UId.Add(pp.UId);
            }
            Dictionary <string, decimal> DicOrderProfitLog = new Dictionary <string, decimal>();
            IList <Users> UsersList = Entity.Users.Where(n => UId.Contains(n.Id)).ToList();
            foreach (var item in JobOrdersList)
            {
                DicOrderProfitLog.Add(item.TNum, Entity.OrderProfitLog.Where(o => o.TNum == item.TNum && o.Agent == BasicAgent.Id).Select(o => o.Profit).FirstOrDefault());
            }
            ViewBag.DicOrderProfitLog = DicOrderProfitLog;
            ViewBag.UsersList         = UsersList;
            ViewBag.SysAdminList      = Entity.SysAdmin.Where(n => n.State == 1 && n.AgentId == AdminUser.AgentId).ToList();
            ViewBag.IsShowSupAgent    = IsShowSupAgent;
            ViewBag.BasicAgent        = BasicAgent;
            SysSet SysSet = Entity.SysSet.FirstOrNew();
            ViewBag.SysSet     = SysSet;
            ViewBag.LowerLevel = LowerLevel;
            ViewBag.Edit       = this.checkPower("Edit");
            ViewBag.STime      = STime;
            ViewBag.ETime      = ETime;
            return(View());
        }
Exemple #13
0
        public ActionResult XLSDo(OrderProfitLog OrderProfitLog, EFPagingInfo <OrderProfitLog> p)
        {
            p.SqlWhere.Add(f => f.LogType == 3);
            if (!OrderProfitLog.TNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TNum == OrderProfitLog.TNum);
            }
            if (!OrderProfitLog.LogType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.LogType == OrderProfitLog.LogType);
            }
            if (!OrderProfitLog.Agent.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Agent == OrderProfitLog.Agent);
            }
            if (!OrderProfitLog.STime.IsNullOrEmpty() && !OrderProfitLog.ETime.IsNullOrEmpty())
            {
                DateTime ETime = OrderProfitLog.ETime;
                p.SqlWhere.Add(f => f.AddTime > OrderProfitLog.STime && f.AddTime < ETime);
            }
            p.PageSize = 999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <OrderProfitLog> OrderProfitLogList = null;

            OrderProfitLogList = Entity.Selects <OrderProfitLog>(p);
            IList <OrderProfitLog> List      = OrderProfitLogList.GroupBy(n => n.UId).Select(n => n.First()).ToList();
            List <int>             UId       = OrderProfitLogList.Select(o => o.UId).Distinct().ToList();
            IList <Users>          UsersList = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();

            List <int>       AgentId   = OrderProfitLogList.Select(o => o.Agent).Distinct().ToList();
            IList <SysAgent> AgentList = Entity.SysAgent.Where(n => n.State == 1 && AgentId.Contains(n.Id)).ToList();
            DataTable        table     = new DataTable();
            DataRow          row       = null;

            // 创建 datatable
            table.Columns.Add(new DataColumn("交易号", typeof(string)));
            table.Columns.Add(new DataColumn("交易商户", typeof(string)));
            table.Columns.Add(new DataColumn("交易类型", typeof(string)));
            table.Columns.Add(new DataColumn("交易金额", typeof(string)));
            table.Columns.Add(new DataColumn("分润金额", typeof(string)));
            table.Columns.Add(new DataColumn("分润时间", typeof(string)));
            table.Columns.Add(new DataColumn("代理商名称", typeof(string)));
            table.Columns.Add(new DataColumn("代理商层级", typeof(string)));
            string state = "";

            //订单按照支付时间排序
            foreach (var item in OrderProfitLogList)
            {
                Users    Users    = UsersList.FirstOrNew(n => n.Id == item.UId);
                SysAgent SysAgent = AgentList.FirstOrNew(o => o.Id == item.Agent);
                if (item.OrderType == 21)
                {
                    state = "直通车交易";
                }
                else if (item.OrderType == 10)
                {
                    state = "自助开通代理";
                }
                else if (item.OrderType == 31)
                {
                    state = "刷还交易";
                }
                row    = table.NewRow();
                row[0] = item.TNum;
                row[1] = Users.TrueName;
                row[2] = state;
                row[3] = item.Amoney;
                row[4] = item.Profit;
                row[5] = item.AddTime.ToString("yyyy-MM-dd HH:mm");
                row[6] = SysAgent.Name;
                row[7] = item.Tier + "级";
                table.Rows.Add(row);
            }
            string Time = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(10, 99);

            return(this.ExportExcelBase(table, "同级分润明细-" + Time));
        }
        public void Post()
        {
            string Data = DataObj.GetData();

            if (Data.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }
            JObject json = new JObject();

            try
            {
                json = (JObject)JsonConvert.DeserializeObject(Data);
            }
            catch (Exception Ex)
            {
                Log.Write("[MsgNotice]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            MsgNotice MsgNotice = new MsgNotice();

            MsgNotice = JsonToObject.ConvertJsonToModel(MsgNotice, json);

            Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == MsgNotice.Token);

            if (baseUsers == null)//用户令牌不存在
            {
                DataObj.OutError("2004");
                return;
            }
            if (baseUsers.State != 1)//用户被锁定
            {
                DataObj.OutError("2003");
                return;
            }
            //if (baseUsers.CardStae != 2)//未实名认证
            //{
            //    DataObj.OutError("2006");
            //    return;
            //}
            //if (baseUsers.MiBao != 1)//未设置支付密码
            //{
            //    DataObj.OutError("2008");
            //    return;
            //}

            //下次改版让手机端传AgentId,这让有点伤性能,然后删除这条备注
            SysAgent SysAgent = Entity.SysAgent.FirstOrNew(n => n.Id == baseUsers.Agent);

            SysAgent = SysAgent.GetTopAgent(Entity);

            EFPagingInfo <MsgNotice> p = new EFPagingInfo <MsgNotice>();

            if (!MsgNotice.Pg.IsNullOrEmpty())
            {
                p.PageIndex = MsgNotice.Pg;
            }
            if (!MsgNotice.Pgs.IsNullOrEmpty())
            {
                p.PageSize = MsgNotice.Pgs;
            }

            p.SqlWhere.Add(f => f.NType == 0 || f.NType == 3);
            p.SqlWhere.Add(f => f.State == 1 && f.AddTime > baseUsers.AddTime);
            int AgentId = 999999999;

            if (SysAgent.IsTeiPai == 1)
            {
                AgentId = SysAgent.Id;
            }
            p.SqlWhere.Add(f => f.AgentId == 0 || f.AgentId == AgentId);

            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <MsgNotice> List = Entity.Selects <MsgNotice>(p);

            //处理以读未读
            string UserId = string.Format("|{0}|", baseUsers.Id);

            foreach (var pp in List)
            {
                pp.State = (byte)(pp.ReadUsers != null && pp.ReadUsers.IndexOf(UserId) == -1 ? 1 : 2);
                if (pp.Info != null)
                {
                    pp.Info = Utils.RemoveHtml(pp.Info);
                    pp.Info = pp.Info.Replace("	", "");
                }
            }
            IList <MsgNotice> iList = List.ToList();
            StringBuilder     sb    = new StringBuilder("");

            sb.Append("{");
            sb.Append(List.PageToString());
            sb.Append(",");
            sb.Append(iList.EntityToString());
            sb.Append("}");
            DataObj.Data = sb.ToString();
            DataObj.Code = "0000";
            DataObj.OutString();
        }
Exemple #15
0
        public ActionResult Index(ApplyJoin ApplyJoin, EFPagingInfo <ApplyJoin> p, DateTime?STime, DateTime?ETime, int IsFirst = 0)
        {
            if (STime.IsNullOrEmpty())
            {
                STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (ETime.IsNullOrEmpty())
            {
                // ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                ETime = DateTime.Now;
            }
            ViewBag.ExcelExport = this.checkPower("ExcelExport");
            if (IsFirst == 0)
            {
                PageOfItems <ApplyJoin> ApplyJoinList1 = new PageOfItems <ApplyJoin>(new List <ApplyJoin>(), 0, 10, 0, new Hashtable());
                ViewBag.ETime             = ETime;
                ViewBag.STime             = STime;
                ViewBag.ApplyJoinList     = ApplyJoinList1;
                ViewBag.ApplyJoin         = ApplyJoin;
                ViewBag.BasicProvinceList = Entity.BasicProvince.ToList();
                ViewBag.BasicCityList     = Entity.BasicCity.ToList();
                ViewBag.Save = this.checkPower("Save");
                return(View());
            }
            p.SqlWhere.Add(f => f.AddTime > STime && f.AddTime < ETime);
            if (!ApplyJoin.ServiceType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.ServiceType == ApplyJoin.ServiceType);
            }
            if (!ApplyJoin.ApplyType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.ApplyType == ApplyJoin.ApplyType);
            }
            if (!ApplyJoin.Linker.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Linker.Contains(ApplyJoin.Linker));
            }
            if (!ApplyJoin.Mobile.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Mobile.Contains(ApplyJoin.Mobile));
            }
            if (!ApplyJoin.ComName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.ComName.Contains(ApplyJoin.ComName));
            }
            if (!ApplyJoin.Province.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Province == ApplyJoin.Province);
            }
            if (!ApplyJoin.City.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.City == ApplyJoin.City);
            }
            if (!ApplyJoin.TiePaiAgentId.IsNullOrEmpty())
            {
                if (ApplyJoin.TiePaiAgentId == 1)
                {
                    p.SqlWhere.Add(f => f.TiePaiAgentId != null);
                }
                else
                {
                    p.SqlWhere.Add(f => f.TiePaiAgentId == null);
                }
            }
            if (!ApplyJoin.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == ApplyJoin.State);
            }
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyJoin> ApplyJoinList = Entity.Selects <ApplyJoin>(p);

            ViewBag.ETime             = ETime;
            ViewBag.STime             = STime;
            ViewBag.ApplyJoinList     = ApplyJoinList;
            ViewBag.ApplyJoin         = ApplyJoin;
            ViewBag.BasicProvinceList = Entity.BasicProvince.ToList();
            ViewBag.BasicCityList     = Entity.BasicCity.ToList();
            // ViewBag.SysAgentList = Entity.SysAgent.ToList();

            ViewBag.Save = this.checkPower("Save");
            return(View());
        }
Exemple #16
0
        public void Post()
        {
            string Data = DataObj.GetData();

            if (Data.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }
            JObject json = new JObject();

            try
            {
                json = (JObject)JsonConvert.DeserializeObject(Data);
            }
            catch (Exception Ex)
            {
                Log.Write("[MsgHelp]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            MsgHelp MsgHelp = new MsgHelp();

            MsgHelp = JsonToObject.ConvertJsonToModel(MsgHelp, json);

            Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == MsgHelp.Token);

            if (baseUsers == null)//用户令牌不存在
            {
                DataObj.OutError("2004");
                return;
            }
            if (baseUsers.State != 1)//用户被锁定
            {
                DataObj.OutError("2003");
                return;
            }
            if (baseUsers.CardStae != 2)//未实名认证
            {
                //DataObj.OutError("2006");
                //return;
            }
            if (baseUsers.MiBao != 1)//未设置支付密码
            {
                //DataObj.OutError("2008");
                //return;
            }
            string url = SysImgPath + "/UpLoadFiles/MsgHelp/";
            EFPagingInfo <MsgHelp> p = new EFPagingInfo <MsgHelp>();

            if (!MsgHelp.Pg.IsNullOrEmpty())
            {
                p.PageIndex = MsgHelp.Pg;
            }
            if (!MsgHelp.Pgs.IsNullOrEmpty())
            {
                p.PageSize = MsgHelp.Pgs;
            }
            p.SqlWhere.Add(o => o.State == 1);
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <MsgHelp> List  = Entity.Selects <MsgHelp>(p);
            IList <MsgHelp>        iList = List.ToList();
            StringBuilder          sb    = new StringBuilder("");

            sb.Append("{");
            sb.Append(List.PageToString());
            sb.Append(",");
            sb.Append(iList.EntityToString());

            sb.Append(",\"imgpath\":\"" + url + "\"");

            sb.Append("}");
            DataObj.Data = sb.ToString();
            DataObj.Code = "0000";
            DataObj.OutString();
        }
Exemple #17
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="ApplyJoin"></param>
        /// <param name="p"></param>
        /// <param name="STime"></param>
        /// <param name="ETime"></param>
        /// <param name="IsShowSupAgent"></param>
        /// <returns></returns>
        public FileResult ExcelExport(ApplyJoin ApplyJoin, EFPagingInfo <ApplyJoin> p, DateTime?STime, DateTime?ETime, bool?IsShowSupAgent)
        {
            p.PageSize = 9999999;
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            p.SqlWhere.Add(f => f.AddTime > STime && f.AddTime < ETime);
            if (!ApplyJoin.ServiceType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.ServiceType == ApplyJoin.ServiceType);
            }
            if (!ApplyJoin.ApplyType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.ApplyType == ApplyJoin.ApplyType);
            }
            if (!ApplyJoin.Linker.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Linker.Contains(ApplyJoin.Linker));
            }
            if (!ApplyJoin.Mobile.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Mobile.Contains(ApplyJoin.Mobile));
            }
            if (!ApplyJoin.ComName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.ComName.Contains(ApplyJoin.ComName));
            }
            if (!ApplyJoin.Province.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Province == ApplyJoin.Province);
            }
            if (!ApplyJoin.City.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.City == ApplyJoin.City);
            }
            if (!ApplyJoin.TiePaiAgentId.IsNullOrEmpty())
            {
                if (ApplyJoin.TiePaiAgentId == 1)
                {
                    p.SqlWhere.Add(f => f.TiePaiAgentId != null);
                }
                else
                {
                    p.SqlWhere.Add(f => f.TiePaiAgentId == null);
                }
            }
            if (!ApplyJoin.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == ApplyJoin.State);
            }
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyJoin> ApplyJoinList = Entity.Selects <ApplyJoin>(p);

            DataTable table = new DataTable();
            DataRow   row   = null;

            // 创建 datatable
            table.Columns.Add(new DataColumn("联系人", typeof(string)));
            table.Columns.Add(new DataColumn("手机号", typeof(string)));
            table.Columns.Add(new DataColumn("公司名称", typeof(string)));
            table.Columns.Add(new DataColumn("所在省", typeof(string)));
            table.Columns.Add(new DataColumn("所在市", typeof(string)));
            table.Columns.Add(new DataColumn("申请时间", typeof(string)));
            table.Columns.Add(new DataColumn("状态", typeof(string)));
            table.Columns.Add(new DataColumn("上级代理名", typeof(string)));
            table.Columns.Add(new DataColumn("是否贴牌", typeof(string)));

            // 填充数据
            foreach (var item in ApplyJoinList)
            {
                BasicProvince BasicProvince = Entity.BasicProvince.FirstOrNew(n => n.Id == item.Province);
                BasicCity     BasicCity     = Entity.BasicCity.FirstOrNew(n => n.Id == item.City);
                string        stateName     = "";
                row    = table.NewRow();
                row[0] = item.Linker;
                row[1] = item.Mobile;
                row[2] = item.ComName;
                row[3] = BasicProvince.Name;
                row[4] = BasicCity.Name;
                row[5] = item.AddTime.ToString("yyyy-MM-dd");
                switch (item.State)
                {
                case 1:
                    stateName = "未跟进";
                    break;

                case 2:
                    stateName = "跟进中";
                    break;

                case 3:
                    stateName = "无意向";
                    break;

                case 4:
                    stateName = "已完成";
                    break;

                default:
                    break;
                }

                row[6] = stateName;
                row[7] = item.AgentName;
                row[8] = item.TiePaiAgentId != null ? "是" : "否";

                table.Rows.Add(row);
            }
            string Time = STime.IsNullOrEmpty() ? "" : STime.Value.ToString("yyyy-MM-dd") + "至" + (ETime.IsNullOrEmpty() ? "" : ETime.Value.ToString("yyyy-MM-dd"));

            return(this.ExportExcelBase(table, "合作申请    " + Time));
        }
Exemple #18
0
        public void Post()
        {
            string Data = DataObj.GetData();

            if (Data.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }
            JObject json = new JObject();

            try
            {
                json = (JObject)JsonConvert.DeserializeObject(Data);
            }
            catch (Exception Ex)
            {
                Log.Write("[BaoList]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            BaoLog BaoLog = new BaoLog();

            BaoLog = JsonToObject.ConvertJsonToModel(BaoLog, json);
            if (BaoLog.Token.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }

            Users Users = Entity.Users.FirstOrDefault(n => n.Token == BaoLog.Token);

            if (Users == null)//用户令牌不存在
            {
                DataObj.OutError("2004");
                return;
            }
            if (Users.State != 1)
            {
                DataObj.OutError("2003");
                return;
            }
            if (Users.CardStae != 2)//未实名认证
            {
                DataObj.OutError("2006");
                return;
            }
            if (Users.MiBao != 1)//未设置支付密码
            {
                DataObj.OutError("2008");
                return;
            }

            EFPagingInfo <BaoLog> p = new EFPagingInfo <BaoLog>();

            if (!BaoLog.Pg.IsNullOrEmpty())
            {
                p.PageIndex = BaoLog.Pg;
            }
            if (!BaoLog.Pgs.IsNullOrEmpty())
            {
                p.PageSize = BaoLog.Pgs;
            }
            if (!BaoLog.LType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.LType == BaoLog.LType);
            }

            p.SqlWhere.Add(f => f.UId == Users.Id);
            p.SqlWhere.Add(f => f.LType == 1 || f.LType == 2 || f.LType == 3);
            p.OrderByList.Add("Id", "DESC");

            IPageOfItems <BaoLog> List = Entity.Selects <BaoLog>(p);

            foreach (var P in List)
            {
                if (P.LType == 1)
                {
                    P.LTypeName = "转入";
                }
                if (P.LType == 2)
                {
                    P.LTypeName = "转出";
                }
                if (P.LType == 3)
                {
                    P.LTypeName = "收益";
                }
            }

            IList <BaoLog> iList = List.ToList();

            StringBuilder sb = new StringBuilder("");

            sb.Append("{");
            sb.Append(List.PageToString());
            sb.Append(",");
            sb.Append(iList.EntityToString());
            sb.Append("}");

            DataObj.Data = sb.ToString();
            DataObj.Code = "0000";
            DataObj.OutString();
        }
        private EFPagingInfo <FastOrder> Condition(FastOrder FastOrder, EFPagingInfo <FastOrder> p, bool IsShowSupAgent)
        {
            #region 筛选条件
            if (!FastOrder.PayWay.IsNullOrEmpty())
            {
                p.SqlWhere.Add(o => o.PayWay == FastOrder.PayWay);
            }

            if (!FastOrder.TNum.IsNullOrEmpty())
            {
                if (FastOrder.UId == 1)
                {
                    p.SqlWhere.Add(f => f.TNum == FastOrder.TNum);
                }
                else
                {
                    IList <Users> UList = Entity.Users.Where(n => n.TrueName.Contains(FastOrder.TNum) || n.NeekName.Contains(FastOrder.TNum) || n.UserName == FastOrder.TNum).ToList();
                    List <int>    UIds  = new List <int>();
                    foreach (var pp in UList)
                    {
                        UIds.Add(pp.Id);
                    }
                    p.SqlWhere.Add(f => UIds.Contains(f.UId));
                }
            }

            if (!FastOrder.UserState.IsNullOrEmpty())
            {
                var value = FastOrder.UserState == 99 ? 0 : FastOrder.UserState;
                p.SqlWhere.Add(o => o.UserState == value);
            }
            if (!FastOrder.AgentState.IsNullOrEmpty())
            {
                var value = FastOrder.AgentState == 99 ? 0 : FastOrder.AgentState;
                p.SqlWhere.Add(o => o.AgentState == value);
            }
            //是否选择了分支机构
            if (!FastOrder.Agent.IsNullOrEmpty())
            {
                //是否要显示下级
                if ((bool)IsShowSupAgent)
                {
                    SysAgent         LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == FastOrder.Agent).FirstOrNew();
                    IList <SysAgent> SysAgentList    = LowerLevelAgent.GetSupAgent(Entity, true);
                    IList <int>      UID             = SysAgentList.Select(o => o.Id).ToList();
                    p.SqlWhere.Add(f => UID.Contains(f.Agent));
                }
                else
                {
                    p.SqlWhere.Add(f => f.Agent == FastOrder.Agent);
                }
            }

            if (!FastOrder.STime.IsNullOrEmpty() && !FastOrder.ETime.IsNullOrEmpty())
            {
                DateTime ETime = FastOrder.ETime;
                if (FastOrder.Bin == "1")
                {
                    p.SqlWhere.Add(f => f.AddTime > FastOrder.STime && f.AddTime < ETime);
                }
                else
                {
                    p.SqlWhere.Add(f => f.PayTime > FastOrder.STime && f.PayTime < ETime);
                }
            }

            #region 交易类型条件判断
            if (!FastOrder.OType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.OType == FastOrder.OType);//读取对应的类型
            }

            if (!FastOrder.State.IsNullOrEmpty())
            {
                switch (FastOrder.State)
                {
                case 1:    //未付
                    p.SqlWhere.Add(f => f.State == 1 && f.PayState == 0);
                    break;

                case 2:    //已付
                    p.SqlWhere.Add(f => f.State == 1 && f.PayState == 1);
                    break;

                case 99:    //交易关闭
                    p.SqlWhere.Add(f => f.State == 0);
                    break;
                }
            }
            #endregion

            #endregion
            p.OrderByList.Add("Id", "DESC");

            return(p);
        }
Exemple #20
0
        public ActionResult Index(ApplyCredit ApplyCredit, EFPagingInfo <ApplyCredit> p, bool?IsShowSupAgent, int IsFirst = 0)
        {
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            if (!ApplyCredit.TrueName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TrueName == ApplyCredit.TrueName);
            }
            if (!ApplyCredit.BankId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.BankId == ApplyCredit.BankId);
            }
            if (!ApplyCredit.Education.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Education.Contains(ApplyCredit.Education));
            }
            if (!ApplyCredit.SheBao.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.SheBao == ApplyCredit.SheBao);
            }
            if (!ApplyCredit.Marry.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Marry == ApplyCredit.Marry);
            }
            if (!ApplyCredit.HasCar.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasCar == (ApplyCredit.HasCar == 99 ? 0 : ApplyCredit.HasCar));
            }
            if (!ApplyCredit.House.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.House == ApplyCredit.House);
            }
            if (!ApplyCredit.HasCredit.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasCredit == ApplyCredit.HasCredit);
            }
            if (!ApplyCredit.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == ApplyCredit.State);
            }
            if (!ApplyCredit.AgentPay.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentPay == (ApplyCredit.AgentPay == 99 ? 0 : ApplyCredit.AgentPay));
            }
            if (!ApplyCredit.AgentAId.IsNullOrEmpty())
            {
                //是否要显示下级
                if ((bool)IsShowSupAgent)
                {
                    SysAgent         LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == ApplyCredit.AgentAId).FirstOrNew();
                    IList <SysAgent> SysAgentList    = LowerLevelAgent.GetSupAgent(Entity);
                    IList <int>      UID             = SysAgentList.Select(o => o.Id).ToList();
                    p.SqlWhere.Add(f => UID.Contains(f.AgentAId));
                }
                else
                {
                    p.SqlWhere.Add(f => f.AgentAId == ApplyCredit.AgentAId);
                }
            }
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyCredit> ApplyCreditList = null;

            if (IsFirst == 0)
            {
                ApplyCreditList = new PageOfItems <ApplyCredit>(new List <ApplyCredit>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                ApplyCreditList = Entity.Selects <ApplyCredit>(p);
            }
            ViewBag.ApplyCreditList = ApplyCreditList;
            ViewBag.ApplyCredit     = ApplyCredit;
            ViewBag.BasicBankList   = Entity.BasicBank.Where(n => n.State == 1).ToList();
            ViewBag.SysAgentList    = Entity.SysAgent.Where(n => n.Tier == 1).ToList();
            ViewBag.IsShowSupAgent  = IsShowSupAgent;
            ViewBag.Save            = this.checkPower("Save");
            return(View());
        }
        public FileResult XLSDo(Orders Orders, EFPagingInfo <Orders> p, bool?IsShowSupAgent, bool?IsCloseNextAgent)
        {
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = true;
            }
            if (IsCloseNextAgent == null)
            {
                IsCloseNextAgent = false;
            }
            if (Orders.STime.IsNullOrEmpty())
            {
                Orders.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (Orders.ETime.IsNullOrEmpty())
            {
                Orders.ETime = DateTime.Now;
            }
            Dictionary <string, string> dicChar = new Dictionary <string, string>();

            dicChar.Add("STIME", Orders.STime.ToString("yyyy-MM-dd HH:mm:ss"));
            dicChar.Add("ETIME", Orders.ETime.ToString("yyyy-MM-dd HH:mm:ss"));
            dicChar.Add("Agent", Orders.Agent.ToString());
            dicChar.Add("Agent_ALL", IsShowSupAgent == false ? "0" : "1");
            dicChar.Add("IFOFF", IsCloseNextAgent == false ? "0" : "1");
            var FinUsersModeList = Entity.GetSPExtensions <FinUsersMode>("SP_Statistics_Code", dicChar);

            string    fileName = string.Empty;
            DataTable table    = new DataTable();

            fileName = "按商户汇总";

            // 创建 datatable
            table.Columns.Add(new DataColumn("商户名称", typeof(string)));
            table.Columns.Add(new DataColumn("商户姓名", typeof(string)));
            table.Columns.Add(new DataColumn("银联卡支付.数量", typeof(int)));
            table.Columns.Add(new DataColumn("银联卡支付.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("提现.数量", typeof(int)));
            table.Columns.Add(new DataColumn("提现.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("转帐.数量", typeof(int)));
            table.Columns.Add(new DataColumn("转帐.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("房租.数量", typeof(int)));
            table.Columns.Add(new DataColumn("房租.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("升级.数量", typeof(int)));
            table.Columns.Add(new DataColumn("升级.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("支付宝.数量", typeof(int)));
            table.Columns.Add(new DataColumn("支付宝.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("微信.数量", typeof(int)));
            table.Columns.Add(new DataColumn("微信.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("NFC.数量", typeof(int)));
            table.Columns.Add(new DataColumn("NFC.金额", typeof(decimal)));
            table.Columns.Add(new DataColumn("汇总.数量", typeof(int)));
            table.Columns.Add(new DataColumn("汇总.金额", typeof(decimal)));
            // 填充数据
            DataRow row = null;

            foreach (var item in FinUsersModeList)
            {
                var O = item;
                row     = table.NewRow();
                row[0]  = O.NEEKNAME;
                row[1]  = O.TrueName;
                row[2]  = O.C_Recharge;
                row[3]  = O.A_Recharge.ToMoney();
                row[4]  = O.C_OrderCash;
                row[5]  = O.A_OrderCash.ToMoney();
                row[6]  = O.C_OrderTransfer;
                row[7]  = O.A_OrderTransfer.ToMoney();
                row[8]  = O.C_OrderHouse;
                row[9]  = O.A_OrderHouse.ToMoney();
                row[10] = O.C_PayConfigOrder;
                row[11] = O.A_PayConfigOrder.ToMoney();
                row[12] = O.C_Alipay;
                row[13] = O.A_Alipay.ToMoney();
                row[14] = O.C_Weixin;
                row[15] = O.A_Weixin.ToMoney();
                row[16] = O.C_NFC;
                row[17] = O.A_NFC.ToMoney();
                row[18] = O.C_Total;
                row[19] = O.A_Total.ToMoney();
                table.Rows.Add(row);
            }
            return(this.ExportExcelBase(table, fileName));
        }
        public ActionResult Index(Users Users, EFPagingInfo<Users> p, bool? IsShowSupAgent, int IsFirst = 0)
        {
            #region 条件
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }

            if (Users.CardStae.IsNullOrEmpty())
            {
                Users.CardStae = 2;
            }
            if (!Users.UserName.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.UserName == Users.UserName); }
            if (!Users.TrueName.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.TrueName.Contains(Users.TrueName) || f.NeekName.Contains(Users.TrueName)); }
            if (!Users.Mobile.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.Mobile == Users.Mobile); }
            if (!Users.State.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.State == (Users.State == 99 ? 0 : Users.State)); }
            if (!Users.CardNum.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.CardNum == Users.CardNum); }
            if (!Users.Agent.IsNullOrEmpty())
            {
                //是否要显示下级
                if ((bool)IsShowSupAgent)
                {
                    SysAgent LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == Users.Agent).FirstOrNew();
                    IList<SysAgent> SysAgentList = LowerLevelAgent.GetSupAgent(Entity, true);
                    IList<int> UID = SysAgentList.Select(o => o.Id).ToList();
                    p.SqlWhere.Add(f => UID.Contains(f.Agent));
                }
                else
                {
                    p.SqlWhere.Add(f => f.Agent == Users.Agent);
                }
            }
            if (!Users.CardId.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.CardId == Users.CardId); }
            if (!Users.MyPId.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.MyPId == Users.MyPId && f.ShareType == 1); }
            if (!Users.RegAddress.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.RegAddress.Contains(Users.RegAddress)); }
            if (!Users.CardStae.IsNullOrEmpty())
            {
                int CardStae = Users.CardStae;
                if (CardStae == 99)
                {
                    CardStae = 0;
                }
                if (CardStae != 88)
                {
                    p.SqlWhere.Add(f => f.CardStae == CardStae);
                }
            }
            if (!Users.HasT0.IsNullOrEmpty())
            {
                int HasT0 = Users.HasT0;
                if (HasT0 == 2)
                {
                    HasT0 = 0;
                }
                p.SqlWhere.Add(f => f.HasT0 == HasT0);
            }
            #endregion
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems<Users> UsersList = null;
            if (IsFirst == 0)
            {

                UsersList = new PageOfItems<Users>(new List<Users>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                UsersList = Entity.Selects<Users>(p);
            }
            ViewBag.UsersList = UsersList;
            ViewBag.Users = Users;
            ViewBag.SysAgentList = Entity.SysAgent.Where(n => n.State==1).ToList();
            //显示上级名字
            var ulids = UsersList.Select(o => o.Id).Distinct().ToArray();
            ViewBag.PName = Entity.Users.Select(o => new { o.Id, o.TrueName }).ToDictionary(o => o.Id, o => o.TrueName);
            ViewBag.IsShowSupAgent = IsShowSupAgent;//是否显示下级
            ViewBag.Edit = this.checkPower("Edit");
            ViewBag.DeductMoney = this.checkPower("DeductMoney");
            ViewBag.MyUsers = this.checkPower("MyUsers");
            ViewBag.Save = this.checkPower("Save");
            ViewBag.ClearPId = this.checkPower("ClearPId");
            ViewBag.StopPay = this.checkPower("StopPay");
            ViewBag.StopPaySave = this.checkPower("StopPaySave");
            ViewBag.UnFrozenList = this.checkPower("UnFrozenList");
            ViewBag.UnFrozenAudit = this.checkPower("UnFrozenAudit");
            ViewBag.Clear = this.checkPower("Clear");
            ViewBag.ClearRZ = this.checkPower("ClearRZ");
            ViewBag.UserTrail = this.checkPower("UserTrail", "Index");
            ViewBag.UserMaillist = this.checkPower("UserMaillist", "Index");
            ViewBag.UserIdCard = this.checkPower("UserIdCard", "Index");
            ViewBag.UserIdLog = this.checkPower("UserIdCard", "Log");
            ViewBag.UserLog = this.checkPower("UserLog", "Index");
            ViewBag.ChangeT0BlackList = this.checkPower("Users", "ChangeT0BlackList");
            ViewBag.ExcelInport = this.checkPower("ExcelInport");
            ViewBag.Download = this.checkPower("Download");
            return View();
        }
        public void XLSDo(ApplyLoan ApplyLoan, EFPagingInfo <ApplyLoan> p)
        {
            if (ApplyLoan.STime.IsNullOrEmpty())
            {
                ApplyLoan.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (ApplyLoan.ETime.IsNullOrEmpty())
            {
                //ApplyLoan.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                ApplyLoan.ETime = DateTime.Now;
            }
            if (!ApplyLoan.TrueName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TrueName == ApplyLoan.TrueName);
            }
            if (!ApplyLoan.Education.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Education.Contains(ApplyLoan.Education));
            }
            if (!ApplyLoan.HasSheBao.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasSheBao == (ApplyLoan.HasSheBao == 99 ? 0 : ApplyLoan.HasSheBao));
            }
            if (!ApplyLoan.Marry.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Marry == ApplyLoan.Marry);
            }
            if (!ApplyLoan.HasCar.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasCar == (ApplyLoan.HasCar == 99 ? 0 : ApplyLoan.HasCar));
            }
            if (!ApplyLoan.House.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.House == ApplyLoan.House);
            }
            if (!ApplyLoan.HasCredit.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasCredit == ApplyLoan.HasCredit);
            }
            if (!ApplyLoan.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == ApplyLoan.State);
            }
            if (!ApplyLoan.AgentPay.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentPay == (ApplyLoan.AgentPay == 99 ? 0 : ApplyLoan.AgentPay));
            }
            if (!ApplyLoan.AgentAId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentAId == ApplyLoan.AgentAId);
            }
            if (!ApplyLoan.STime.IsNullOrEmpty() && !ApplyLoan.ETime.IsNullOrEmpty())
            {
                DateTime ETime = ApplyLoan.ETime;
                p.SqlWhere.Add(f => f.PayTime > ApplyLoan.STime && f.PayTime < ETime);
            }
            p.SqlWhere.Add(f => f.PayState == 1);
            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyLoan> ApplyLoanList = Entity.Selects <ApplyLoan>(p);
            IList <ApplyLoan>        List          = ApplyLoanList.GroupBy(n => n.AgentId).Select(n => n.First()).ToList();
            List <int> AgentId = new List <int>();

            foreach (var pp in List)
            {
                AgentId.Add(pp.AgentId);
            }
            IList <SysAgent> SysAgentList = Entity.SysAgent.Where(n => n.State == 1 && AgentId.Contains(n.Id)).ToList();

            if (SysAgentList.Count > 0)
            {
                //加载对应银行模板
                string       tempname = "AgentLoan.xlsx";
                string       file     = Server.MapPath("/template") + "\\" + tempname;
                ExcelPackage package  = new ExcelPackage(new FileInfo(file), true);
                //设置数据开始行
                int Befor  = 2;
                int maxCol = 6;//最大列数
                //加载模板第一张表
                var     sheet      = package.Workbook.Worksheets[1];
                var     cells      = sheet.Cells;
                decimal TotalMoney = 0; //计算总金额
                decimal TotalPrice = 0; //计算总金额
                int     Rows       = ApplyLoanList.Count() + SysAgentList.Count();
                sheet.InsertRow(Befor + 1, Rows - 1, Befor);
                int i = Befor;
                foreach (var item in SysAgentList)
                {
                    IList <ApplyLoan> ListSub    = ApplyLoanList.Where(n => n.AgentId == item.Id).ToList();
                    decimal           AgentMoney = 0; //计算供应商金额
                    decimal           AgentPrice = 0; //计算供应商金额
                    foreach (var s in ListSub)
                    {
                        sheet.Row(i).Height = 20;//设置行高
                        //分支机构
                        cells["A" + i].Value = item.Name;
                        //编号
                        cells["B" + i].Value = s.Id;
                        //姓名
                        cells["C" + i].Value = s.TrueName;
                        //售出金额
                        cells["D" + i].Value = s.Amoney;
                        //售出时间
                        cells["E" + i].Value = s.PayTime;
                        //结算金额
                        cells["F" + i].Value = s.AgentMoney;
                        AgentMoney          += s.Amoney;
                        AgentPrice          += s.AgentMoney;
                        i++;
                    }
                    sheet.Row(i).Height = 28;//设置行高
                    //交易金额汇总
                    cells["D" + i].Value = AgentMoney;
                    //结算金额汇总
                    cells["F" + i].Value = AgentPrice;
                    Color bgColor = ColorTranslator.FromHtml("#DDDDDD");
                    Color fColor  = ColorTranslator.FromHtml("#FF0000");
                    sheet.Cells[i, 1, i, maxCol].Style.Fill.PatternType = ExcelFillStyle.Solid;
                    sheet.Cells[i, 1, i, maxCol].Style.Fill.BackgroundColor.SetColor(bgColor);
                    sheet.Cells[i, 1, i, maxCol].Style.Font.Size = 16;
                    sheet.Cells[i, 1, i, maxCol].Style.Font.Bold = true;
                    sheet.Cells[i, 1, i, maxCol].Style.Font.Color.SetColor(fColor);
                    TotalMoney += AgentMoney;
                    TotalPrice += AgentPrice;
                    i++;
                }
                Color bgColor_ = ColorTranslator.FromHtml("#7030A0");
                Color fColor_  = ColorTranslator.FromHtml("#FFFFFF");
                sheet.Cells[i, 1, i, maxCol].Style.Fill.PatternType = ExcelFillStyle.Solid;
                sheet.Cells[i, 1, i, maxCol].Style.Fill.BackgroundColor.SetColor(bgColor_);
                sheet.Cells[i, 1, i, maxCol].Style.Font.Size = 20;
                sheet.Cells[i, 1, i, maxCol].Style.Font.Bold = true;
                sheet.Cells[i, 1, i, maxCol].Style.Font.Color.SetColor(fColor_);
                sheet.Row(i).Height = 40;//设置行高
                //交易金额汇总
                cells["D" + i].Value = TotalMoney;
                //结算金额汇总
                cells["F" + i].Value = TotalPrice;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Left.Style   = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Right.Style  = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Top.Style    = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 1, i, maxCol].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
                sheet.Cells[Befor, 4, i, 4].Style.Numberformat.Format      = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                sheet.Cells[Befor, 5, i, 5].Style.Numberformat.Format      = "yyyy-mm-dd hh:mm";
                sheet.Cells[Befor, 6, i, 6].Style.Numberformat.Format      = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                Response.BinaryWrite(package.GetAsByteArray());//输出
                Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.AddHeader("content-disposition", "attachment;  filename=" + DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(10, 99) + ".xlsx");
            }
            else
            {
                Response.Write("暂无符合条件数据");
            }
        }
        public ActionResult Index(SysAgent SysAgent, EFPagingInfo <SysAgent> p, int IsFirst = 0)
        {
            bool PayEdit = false;

            if (checkPower("PayEdit"))
            {
                PayEdit = true;
            }
            ViewBag.PayEdit = PayEdit;

            if (IsFirst == 0)
            {
                PageOfItems <SysAgent> SysAgentList1 = new PageOfItems <SysAgent>(new List <SysAgent>(), 0, 10, 0, new Hashtable());
                ViewBag.SysAgentList = SysAgentList1;
                ViewBag.SysAgent     = SysAgent;
                ViewBag.Add          = this.checkPower("Add");
                ViewBag.Info         = this.checkPower("Info");
                ViewBag.Edit         = this.checkPower("Edit");
                ViewBag.Save         = this.checkPower("Save");
                ViewBag.Users        = this.checkPower("Users", "Index");
                ViewBag.Orders       = this.checkPower("Orders", "Index");
                return(View());
            }
            if (!SysAgent.Name.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Name.Contains(SysAgent.Name));
            }
            if (!SysAgent.LinkMobile.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.LinkMobile == SysAgent.LinkMobile);
            }
            if (!SysAgent.APPName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.APPName.Contains(SysAgent.APPName));
            }
            if (!SysAgent.State.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.State == SysAgent.State);
            }
            if (!SysAgent.ExpireTime.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.ExpireTime == SysAgent.ExpireTime);
            }
            if (!SysAgent.Salesman.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Salesman.Contains(SysAgent.Salesman));
            }
            if (!SysAgent.IsTeiPai.IsNullOrEmpty())
            {
                int IsTeiPai = SysAgent.IsTeiPai == 99 ? 0 : SysAgent.IsTeiPai;
                p.SqlWhere.Add(f => f.IsTeiPai == IsTeiPai);
            }
            //if (!SysAgent.Id.IsNullOrEmpty())
            //{
            //    p.SqlWhere.Add(f => f.AgentID == SysAgent.Id);
            //}
            //else
            //{
            //    p.SqlWhere.Add(o => o.AgentID == 0);
            //}
            if (!SysAgent.Tier.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.Tier == SysAgent.Tier);
            }

            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <SysAgent> SysAgentList = Entity.Selects <SysAgent>(p);

            ViewBag.SysAgentList = SysAgentList;
            ViewBag.SysAgent     = SysAgent;
            ViewBag.Add          = this.checkPower("Add");
            ViewBag.Info         = this.checkPower("Info");
            ViewBag.Edit         = this.checkPower("Edit");
            ViewBag.Save         = this.checkPower("Save");
            ViewBag.Users        = this.checkPower("Users", "Index");
            ViewBag.Orders       = this.checkPower("Orders", "Index");
            return(View());
        }
Exemple #25
0
        private EFPagingInfo <Orders> Condition(Orders Orders, EFPagingInfo <Orders> p, bool?IsShowSupAgent, int TimeType = 1)
        {
            if (Orders.STime.IsNullOrEmpty())
            {
                Orders.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (Orders.ETime.IsNullOrEmpty())
            {
                Orders.ETime = DateTime.Now;
            }
            if (!Orders.TType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TType == Orders.TType);
            }
            if (!Orders.UId.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.UId == Orders.UId);
            }
            //是否选择了一个分支机构
            if (!Orders.Agent.IsNullOrEmpty())
            {
                //是否要显示下级
                if ((bool)IsShowSupAgent)
                {
                    SysAgent         LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == Orders.Agent).FirstOrNew();
                    IList <SysAgent> SysAgentList    = LowerLevelAgent.GetSupAgent(Entity);
                    IList <int>      UID             = new List <int>();
                    foreach (var s in SysAgentList)
                    {
                        UID.Add(s.Id);
                    }
                    p.SqlWhere.Add(f => UID.Contains(f.Agent));
                }
                else
                {
                    p.SqlWhere.Add(f => f.Agent == Orders.Agent);
                }
            }
            if (true)
            {
            }
            if (TimeType == 1)//交易时间
            {
                if (!Orders.STime.IsNullOrEmpty() && !Orders.ETime.IsNullOrEmpty())
                {
                    DateTime ETime = Orders.ETime.AddMilliseconds(999);
                    p.SqlWhere.Add(f => f.PayTime > Orders.STime && f.PayTime < ETime);
                }
                #region 交易类型条件判断
                if (!Orders.TType.IsNullOrEmpty())
                {
                    p.SqlWhere.Add(f => f.TType == Orders.TType);//读取对应的类型
                    if (Orders.TType == 1)
                    {
                        if (!Orders.TState.IsNullOrEmpty())
                        {
                            switch (Orders.TState)
                            {
                            case 1:    //未付
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                                break;

                            case 2:    //已付
                                p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 1);
                                break;

                            case 3:    //待传证照
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 1);
                                break;

                            case 4:    //待审核
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 2);
                                break;

                            case 5:    //审核失败
                                p.SqlWhere.Add(f => f.TState == 3 && f.PayState == 1 && f.IdCardState == 4);
                                break;

                            case 6:    //退单
                                p.SqlWhere.Add(f => f.TState == 4);
                                break;

                            case 7:    //待入帐
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 0);
                                break;
                            }
                        }
                    }
                    if (Orders.TType == 2)
                    {
                        //if (!Orders.TState.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.TState == Orders.TState); }
                        switch (Orders.TState)
                        {
                        case 1:    //处理中
                            p.SqlWhere.Add(f => f.TState == 1);
                            break;

                        case 2:    //已汇出
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 2);
                            break;

                        case 3:    //提现失败
                            p.SqlWhere.Add(f => f.TState == 3);
                            break;

                        case 4:    //出款中
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 1);
                            break;
                        }
                    }
                    if (Orders.TType == 3)
                    {
                        switch (Orders.TState)
                        {
                        case 1:    //未付
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                            break;

                        case 2:    //已付
                            p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 1);
                            break;

                        case 3:    //待传证照
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 1);
                            break;

                        case 4:    //待审核
                            p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 2);
                            break;

                        case 5:    //审核失败
                            p.SqlWhere.Add(f => f.TState == 3 && f.PayState == 1 && f.IdCardState == 4);
                            break;
                        }
                    }
                    if (Orders.TType == 5)
                    {
                        if (!Orders.TState.IsNullOrEmpty())
                        {
                            switch (Orders.TState)
                            {
                            case 99:    //未付
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                                break;

                            case 1:    //处理中
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 0);
                                break;

                            case 2:    //已汇出
                                p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 2);
                                break;

                            case 4:    //出款中
                                p.SqlWhere.Add(f => (f.TState == 2 && f.PayState == 2 && f.IdCardState == 0) || (f.TState == 2 && f.PayState == 1 && f.IdCardState == 3));
                                break;

                            case 3:    //审核失败
                                p.SqlWhere.Add(f => (f.TState == 1 || f.TState == 3) && f.PayState == 1 && f.IdCardState == 4);
                                break;

                            case 5:    //退款中
                                p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 3);
                                break;

                            case 6:    //已退款
                                p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 4);
                                break;

                            case 7:    //待传身份证
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 1);
                                break;

                            case 8:    //已传身份证
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.IdCardState == 2);
                                break;
                            }
                        }
                    }
                    if (Orders.TType == 6)
                    {
                        if (!Orders.TState.IsNullOrEmpty())
                        {
                            p.SqlWhere.Add(f => f.TState == Orders.TState);
                        }
                    }
                    if (Orders.TType == 7 || Orders.TType == 8 || Orders.TType == 9)
                    {
                        if (!Orders.TState.IsNullOrEmpty())
                        {
                            if (Orders.TState == 99)
                            {
                                p.SqlWhere.Add(f => f.TState == 0);
                            }
                            if (Orders.TState == 1)
                            {
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 0);
                            }
                            if (Orders.TState == 2)
                            {
                                p.SqlWhere.Add(f => f.TState == 2 && f.PayState == 1);
                            }
                            if (Orders.TState == 3)//退单
                            {
                                p.SqlWhere.Add(f => f.TState == 4);
                            }
                            if (Orders.TState == 4)//待入帐
                            {
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 0);
                            }
                            if (Orders.TState == 5)//待审核
                            {
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 1 && f.IdCardState == 2);
                            }
                            if (Orders.TState == 6)//待传证照
                            {
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 1 && f.IdCardState == 1);
                            }
                            if (Orders.TState == 7)//审核失败
                            {
                                p.SqlWhere.Add(f => f.TState == 1 && f.PayState == 1 && f.InState == 1 && f.IdCardState == 4);
                            }
                        }
                    }
                    if (Orders.TType == 10)
                    {
                        if (!Orders.TState.IsNullOrEmpty())
                        {
                            p.SqlWhere.Add(f => f.TState == Orders.TState);
                        }
                    }
                }
                #endregion
            }
            else
            {
                if (!Orders.STime.IsNullOrEmpty() && !Orders.ETime.IsNullOrEmpty())
                {
                    DateTime ETime = Orders.ETime.AddMilliseconds(999);
                    p.SqlWhere.Add(f => f.InTimed > Orders.STime && f.InTimed < ETime);
                }
                if (!Orders.TType.IsNullOrEmpty())
                {
                    p.SqlWhere.Add(f => f.TType == Orders.TType && f.InState == 1);
                }
                else
                {
                    int[]      temp = { 1, 7, 8, 9 };
                    List <int> UID  = new List <int>(temp);
                    p.SqlWhere.Add(f => UID.Contains(f.TType) && f.InState == 1);
                }
            }
            return(p);
        }
        /// <summary>
        /// 导出
        /// </summary>
        /// <param name="ApplyJoin"></param>
        /// <param name="p"></param>
        /// <param name="STime"></param>
        /// <param name="ETime"></param>
        /// <param name="IsShowSupAgent"></param>
        /// <returns></returns>
        public FileResult ExcelExport(OrderCash OrderCash, EFPagingInfo <OrderCash> p, bool?IsShowSupAgent, int IsFirst = 0, int TimeType = 1)
        {
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }
            p = this.Condition(OrderCash, p, IsShowSupAgent, IsFirst, TimeType);

            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <OrderCash> OrderCashList = Entity.Selects <OrderCash>(p);

            DataTable table = new DataTable();
            DataRow   row   = null;

            // 创建 datatable
            table.Columns.Add(new DataColumn("订单号", typeof(string)));
            table.Columns.Add(new DataColumn("添加时间", typeof(string)));
            table.Columns.Add(new DataColumn("实名认证", typeof(string)));
            table.Columns.Add(new DataColumn("开户名", typeof(string)));
            table.Columns.Add(new DataColumn("手机号码", typeof(string)));
            table.Columns.Add(new DataColumn("银行", typeof(string)));
            table.Columns.Add(new DataColumn("银行账号", typeof(string)));
            table.Columns.Add(new DataColumn("提现方式", typeof(string)));
            table.Columns.Add(new DataColumn("提现金额", typeof(string)));
            table.Columns.Add(new DataColumn("手续费率", typeof(string)));
            table.Columns.Add(new DataColumn("退款状态", typeof(string)));
            table.Columns.Add(new DataColumn("退款时间", typeof(string)));
            table.Columns.Add(new DataColumn("交易备注", typeof(string)));
            List <int> UId = new List <int>();

            foreach (var pp in OrderCashList)
            {
                UId.Add(pp.UId);
            }
            IList <Users> UsersList = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();

            // 填充数据
            foreach (var item in OrderCashList)
            {
                Users Users = UsersList.FirstOrNew(n => n.Id == item.UId);
                row     = table.NewRow();
                row[0]  = item.OId;
                row[1]  = item.AddTime.ToString();
                row[2]  = Users.TrueName;
                row[3]  = item.Owner;
                row[4]  = item.Mobile;
                row[5]  = item.Deposit;
                row[6]  = item.CardNum;
                row[7]  = "T+" + item.TrunType;
                row[8]  = item.Amoney.ToString("F2");
                row[9]  = item.UserRate.ToString("F2");
                row[10] = (item.PayState == 3?"申请中":"已退款");
                row[11] = (item.RefundTime != null ? Convert.ToDateTime(item.RefundTime).ToString("yyyy-MM-dd HH:mm") : "");
                row[12] = item.Remark;
                table.Rows.Add(row);
            }
            string Time = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(10, 99);

            return(this.ExportExcelBase(table, "提现退款审核-" + Time));
        }
Exemple #27
0
        public void Post()
        {
            string Data = DataObj.GetData();

            if (Data.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }
            JObject json = new JObject();

            try
            {
                json = (JObject)JsonConvert.DeserializeObject(Data);
            }
            catch (Exception Ex)
            {
                Log.Write("[MsgCallBack]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            MsgCallBack MsgCallBack = new MsgCallBack();

            MsgCallBack = JsonToObject.ConvertJsonToModel(MsgCallBack, json);
            if (MsgCallBack.Name.IsNullOrEmpty())
            {
                MsgCallBack.Name = "1.0";
            }
            if (MsgCallBack.Name != "2.0")
            {
                MsgCallBack.Name = "1.0";
            }

            Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == MsgCallBack.Token);

            if (baseUsers == null)//用户令牌不存在
            {
                DataObj.OutError("2004");
                return;
            }
            if (baseUsers.State != 1)//用户被锁定
            {
                DataObj.OutError("2003");
                return;
            }
            if (baseUsers.CardStae != 2)//未实名认证
            {
                DataObj.OutError("2006");
                return;
            }
            if (baseUsers.MiBao != 1)//未设置支付密码
            {
                DataObj.OutError("2008");
                return;
            }

            EFPagingInfo <MsgCallBack> p = new EFPagingInfo <MsgCallBack>();

            if (MsgCallBack.Pg.IsNullOrEmpty())
            {
                MsgCallBack.Pg = 1;
            }
            if (!MsgCallBack.Pg.IsNullOrEmpty())
            {
                p.PageIndex = MsgCallBack.Pg;
            }
            if (!MsgCallBack.Pgs.IsNullOrEmpty())
            {
                p.PageSize = MsgCallBack.Pgs;
            }

            p.SqlWhere.Add(f => f.UId == baseUsers.Id);
            p.SqlWhere.Add(f => f.State > 0);

            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <MsgCallBack> List  = Entity.Selects <MsgCallBack>(p);
            IList <MsgCallBack>        iList = new List <MsgCallBack>();

            if (MsgCallBack.Name == "2.0")
            { //处理接口
                var i = 1;
                foreach (var item in List)
                {
                    if (item.State == 2)
                    {
                        if (!item.Result.IsNullOrEmpty())
                        {
                            MsgCallBack Msg = new MsgCallBack();
                            Msg.Id      = i;
                            Msg.Info    = item.Result;
                            Msg.State   = 2;
                            Msg.AddTime = (DateTime)item.EditTime;
                            Msg.Cols    = "Info,State,AddTime";
                            iList.Add(Msg);
                            i++;
                        }
                    }
                    MsgCallBack msg = new MsgCallBack();
                    msg.Id      = i;
                    msg.Info    = item.Info;
                    msg.State   = 1;
                    msg.AddTime = item.AddTime;
                    msg.Cols    = "Info,State,AddTime";
                    iList.Add(msg);
                    i++;
                }
                if (List.TotalPage == MsgCallBack.Pg || List.TotalPage == 0)
                {
                    MsgCallBack msg = new MsgCallBack();
                    msg.Id      = i;
                    msg.Info    = "您好,很高兴为您服务!";
                    msg.State   = 2;
                    msg.AddTime = DateTime.Now;
                    msg.Cols    = "Info,State,AddTime";
                    iList.Add(msg);
                    i++;
                }
                iList = iList.OrderByDescending(n => n.Id).ToList();
            }
            else
            {
                iList = List.ToList();
            }
            StringBuilder sb = new StringBuilder("");

            sb.Append("{");
            sb.Append(List.PageToString());
            sb.Append(",");
            sb.Append(iList.EntityToString());
            sb.Append("}");
            DataObj.Data = sb.ToString();
            DataObj.Code = "0000";
            DataObj.OutString();
        }
 private EFPagingInfo <OrderCash> Condition(OrderCash OrderCash, EFPagingInfo <OrderCash> p, bool?IsShowSupAgent, int IsFirst = 0, int TimeType = 1)
 {
     if (IsShowSupAgent == null)
     {
         IsShowSupAgent = false;
     }
     p.SqlWhere.Add(f => f.OrderState == 2);
     p.SqlWhere.Add(f => f.PayState == 3 || f.PayState == 4);
     //if (!OrderCash.UId.IsNullOrEmpty()) { p.SqlWhere.Add(f => f.UId == OrderCash.UId); }
     if (!OrderCash.Owner.IsNullOrEmpty())
     {
         IList <Users> UList = Entity.Users.Where(n => n.TrueName.Contains(OrderCash.Owner) || n.NeekName.Contains(OrderCash.Owner) || n.UserName == OrderCash.Owner).ToList();
         List <int>    UIds  = new List <int>();
         foreach (var pp in UList)
         {
             UIds.Add(pp.Id);
         }
         p.SqlWhere.Add(f => UIds.Contains(f.UId));
     }
     if (!OrderCash.OId.IsNullOrEmpty())
     {
         p.SqlWhere.Add(f => f.OId == OrderCash.OId);
     }
     if (!OrderCash.Agent.IsNullOrEmpty())
     {
         //是否要显示下级
         if ((bool)IsShowSupAgent)
         {
             SysAgent         LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == OrderCash.Agent).FirstOrNew();
             IList <SysAgent> SysAgentList    = LowerLevelAgent.GetSupAgent(Entity);
             IList <int>      UID             = new List <int>();
             foreach (var s in SysAgentList)
             {
                 UID.Add(s.Id);
             }
             p.SqlWhere.Add(f => UID.Contains(f.Agent));
         }
         else
         {
             p.SqlWhere.Add(f => f.Agent == OrderCash.Agent);
         }
     }
     if (!OrderCash.PayState.IsNullOrEmpty())
     {
         p.SqlWhere.Add(f => f.PayState == OrderCash.PayState);
     }
     if (!OrderCash.AId.IsNullOrEmpty())
     {
         p.SqlWhere.Add(f => f.AId == OrderCash.AId);
     }
     if (!OrderCash.FId.IsNullOrEmpty())
     {
         p.SqlWhere.Add(f => f.FId == OrderCash.FId);
     }
     if (TimeType == 1)
     {
         if (!OrderCash.AddTime.IsNullOrEmpty() && !OrderCash.FTime.IsNullOrEmpty())
         {
             // DateTime FTime = ((DateTime)OrderCash.FTime).AddDays(1);
             DateTime FTime = OrderCash.FTime.Value.AddMilliseconds(999);
             p.SqlWhere.Add(f => f.AddTime > OrderCash.AddTime && f.AddTime < FTime);
         }
     }
     else
     {
         if (!OrderCash.AddTime.IsNullOrEmpty() && !OrderCash.FTime.IsNullOrEmpty())
         {
             DateTime FTime = OrderCash.FTime.Value.AddMilliseconds(999);
             p.SqlWhere.Add(f => f.RefundTime > OrderCash.AddTime && f.RefundTime < FTime);
         }
     }
     return(p);
 }
        public ActionResult Index(Orders Orders, EFPagingInfo <Orders> p, bool?IsShowSupAgent, int IsFirst = 0)
        {
            this.TempData.Remove("SysAgentList");
            #region 校验与初始化
            if (IsShowSupAgent == null)
            {
                IsShowSupAgent = false;
            }

            if (Orders.STime.IsNullOrEmpty())
            {
                Orders.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (Orders.ETime.IsNullOrEmpty())
            {
                //Orders.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                Orders.ETime = DateTime.Now;
            }
            p.SqlWhere.Add(f => f.PayState == 1);
            p.SqlWhere.Add(f => f.TState == 2);
            if (!Orders.TNum.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TNum == Orders.TNum);
            }
            if (!Orders.TName.IsNullOrEmpty())
            {
                IList <Users> UList = Entity.Users.Where(n => n.TrueName == Orders.TName || n.NeekName == Orders.TName || n.UserName == Orders.TName).ToList();
                List <int>    UIds  = new List <int>();
                foreach (var pp in UList)
                {
                    UIds.Add(pp.Id);
                }
                p.SqlWhere.Add(f => UIds.Contains(f.UId));
            }
            if (!Orders.TType.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TType == Orders.TType);
            }
            if (!Orders.Agent.IsNullOrEmpty())
            {
                //是否要显示下级
                if ((bool)IsShowSupAgent)
                {
                    SysAgent         LowerLevelAgent = Entity.SysAgent.Where(s => s.Id == Orders.Agent).FirstOrNew();
                    IList <SysAgent> SysAgentList    = LowerLevelAgent.GetSupAgent(Entity);
                    IList <int>      UID             = new List <int>();
                    foreach (var s in SysAgentList)
                    {
                        UID.Add(s.Id);
                    }
                    p.SqlWhere.Add(f => UID.Contains(f.Agent));
                }
                else
                {
                    p.SqlWhere.Add(f => f.Agent == Orders.Agent);
                }
            }
            if (!Orders.AgentState.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.AgentState == (Orders.AgentState == 99 ? 0 : Orders.AgentState));
            }
            if (!Orders.STime.IsNullOrEmpty() && !Orders.ETime.IsNullOrEmpty())
            {
                DateTime ETime = Orders.ETime;
                p.SqlWhere.Add(f => f.PayTime > Orders.STime && f.PayTime < ETime);
            }
            #endregion
            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <Orders> OrdersList = null;
            if (IsFirst == 0)
            {
                OrdersList = new PageOfItems <Orders>(new List <Orders>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                OrdersList = Entity.Selects <Orders>(p);
            }
            ViewBag.OrdersList = OrdersList;
            ViewBag.Orders     = Orders;
            IList <Orders> List = OrdersList.GroupBy(n => n.UId).Select(n => n.First()).ToList();
            List <int>     UId  = new List <int>();
            foreach (var pp in List)
            {
                UId.Add(pp.UId);
            }
            ViewBag.UsersList     = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();
            ViewBag.PayConfigList = Entity.PayConfig.Where(n => n.State == 1).ToList();
            IList <Orders> List1   = OrdersList.GroupBy(n => n.Agent).Select(n => n.First()).ToList();
            List <int>     AgentId = new List <int>();
            foreach (var pp in List1)
            {
                AgentId.Add(pp.Agent);
            }
            ViewBag.SysAgentList          = Entity.SysAgent.Where(n => AgentId.Contains(n.Id) && n.Tier == 1).ToList();
            this.TempData["SysAgentList"] = ViewBag.SysAgentList;
            ViewBag.SelectSysAgentList    = Entity.SysAgent.Where(n => n.State == 1).ToList();
            ViewBag.IsShowSupAgent        = IsShowSupAgent;
            ViewBag.Xls = this.checkPower("Xls");
            return(View());
        }
        public ActionResult Index(SysAgent SysAgent, EFPagingInfo <APPModule> p, int SourceAgentId = 0)
        {
            var APPModuleList = Entity.APPModule.Where(o => o.AgentId == SysAgent.Id && o.Version == 1 && o.State == 1).OrderBy(o => o.Sort).ToList();

            ViewBag.APPModuleList = APPModuleList;
            var APPBlockList = Entity.APPBlock.Where(o => o.AgentId == SysAgent.Id && o.State == 1).OrderBy(o => o.Sort).ToList();

            ViewBag.APPBlockList = APPBlockList;
            //加载类型选项
            string filename             = HttpContext.Server.MapPath("/ModuleTypeSelectList.json");
            string jsonstr              = System.IO.File.ReadAllText(filename);
            var    ModuleTypeSelectList = JsonConvert.DeserializeObject <SortedList <string, string> >(jsonstr);

            ViewBag.ModuleTypeSelectList = ModuleTypeSelectList;
            string Bottomfilename             = HttpContext.Server.MapPath("/ModuleTypeBottomSelectList.json");
            string Bottomjsonstr              = System.IO.File.ReadAllText(Bottomfilename);
            var    ModuleTypeBottomSelectList = JsonConvert.DeserializeObject <SortedList <string, string> >(Bottomjsonstr);

            ViewBag.ModuleTypeBottomSelectList = ModuleTypeBottomSelectList;
            //加载广告及标识
            AdTag bannerTag = Entity.AdTag.FirstOrDefault(o => o.Tag == "newBanner" && o.State == 1);

            ViewBag.BannerTag = bannerTag;
            if (bannerTag == null)
            {
                ViewBag.ErrorMsg = "无法找到广告标识";
                return(View("Error"));
            }
            var bannerInfos = Entity.AdInfo.OrderBy(o => o.Sort).Where(o => o.TId == bannerTag.Id && o.State == 1 && o.AgentId == SysAgent.Id).ToList();

            ViewBag.bannerInfos = bannerInfos;
            //贴牌代理
            var SysAgentList  = Entity.SysAgent.Where(o => o.IsTeiPai == 1 && o.State == 1).ToList();
            var haofusysagent = new SysAgent()
            {
                Id           = 0,
                Name         = "好付",
                AppBtnNumber = BasicSet.AppBtnNumber,
                APPHasMore   = BasicSet.APPHasMore,
                APPName      = BasicSet.Name,
            };

            SysAgentList.Add(haofusysagent);
            SysAgentList          = SysAgentList.OrderBy(o => o.Id).ToList();
            ViewBag.SysAgentList  = SysAgentList;
            ViewBag.SysAgent      = SysAgentList.FirstOrNew(o => o.Id == SysAgent.Id);
            ViewBag.SourceAgentId = SourceAgentId;
            if (Request.UrlReferrer != null)
            {
                Session["Url"] = Request.UrlReferrer.ToString();
            }

            //取得系统图标
            string PhysicalApplicationPath = this.HttpContext.Request.PhysicalApplicationPath;
            string APPModelPath            = PhysicalApplicationPath + "UpLoadFiles\\APPModule\\";
            var    homeDir      = new System.IO.DirectoryInfo(APPModelPath + "home2");
            var    bottomDefDir = new System.IO.DirectoryInfo(APPModelPath + "bottom2\\default");
            var    bottomActDir = new System.IO.DirectoryInfo(APPModelPath + "bottom2\\activate");

            var homeFiles      = homeDir.GetFiles();
            var bottomDefFiles = bottomDefDir.GetFiles();
            var bottomActFiles = bottomActDir.GetFiles();

            ViewBag.homeFiles          = homeFiles;
            ViewBag.bottomDefaultFiles = bottomDefFiles;
            ViewBag.bottomActFiles     = bottomActFiles;

            //公告
            var Notice = this.Entity.MsgNotice.Where(o => (o.AgentId == 0 || o.AgentId == SysAgent.Id) && (o.NType == 0 || o.NType == 3) && o.State == 1).OrderByDescending(o => o.Id)
                         .Select(o => new { info = o.Info }).FirstOrDefault();
            var ninfo = string.Empty;

            if (Notice != null)
            {
                ninfo += Notice.info.IsNullOrEmpty() ? Notice.info : Utils.RemoveHtml(Notice.info) + "          ";
            }
            ViewBag.ninfo = ninfo;

            this.ViewBag.IsSave       = this.checkSignPower("Save");
            this.ViewBag.IsDelete     = this.checkSignPower("Delete");
            this.ViewBag.IsImportData = this.checkPower("ImportData");
            return(View());
        }