public void Add(ApplyCredit ApplyCredit, string code, string comeurl, List <int> Bank)
 {
     if (code.ToUpper() != Session.GetCheckCode())
     {
         Response.Write("<script>alert('验证码错误');history.go(-1);</script>");
         return;
     }
     Session.ClearCheckCode();
     foreach (int p in Bank)
     {
         ApplyCredit AC = new ApplyCredit();
         AC               = Request.ConvertRequestToModel <ApplyCredit>(AC, ApplyCredit);
         AC.BankId        = p;
         AC.UId           = 0;
         AC.AId           = 0;
         AC.State         = 1;
         AC.AddTime       = DateTime.Now;
         AC.AgentId       = 0;
         AC.AgentAId      = 0;
         AC.PayState      = 0;
         AC.AgentPay      = 0;
         AC.CompanyNature = string.Empty;
         //这里是利润计算==========
         AC.Amoney     = AC.GetPrice(Entity); //获取价格
         AC.AIdMoney   = AC.Amoney;           //总利润
         AC.AgentMoney = 0;                   //分支机构佣金设置为0,待分润计算后再写入
         Entity.ApplyCredit.AddObject(AC);
     }
     Entity.SaveChanges();
     Response.Write("<script>location.href=\"success.html?comeurl=" + comeurl + "\";</script>");
 }
Esempio n. 2
0
 public ActionResult Edit(ApplyCredit ApplyCredit)
 {
     if (ApplyCredit.Id != 0)
     {
         ApplyCredit = Entity.ApplyCredit.FirstOrDefault(n => n.Id == ApplyCredit.Id);
     }
     if (ApplyCredit.PayState != 1)
     {
         ViewBag.ErrorMsg = "未支付,不能结算!";
         return(View("Error"));
     }
     if (ApplyCredit.AgentPay != 0)
     {
         ViewBag.ErrorMsg = "已经结算,不能重复结算!";
         return(View("Error"));
     }
     if (ApplyCredit == null)
     {
         ViewBag.ErrorMsg = "数据不存在";
         return(View("Error"));
     }
     ViewBag.ApplyCredit = ApplyCredit;
     if (Request.UrlReferrer != null)
     {
         Session["Url"] = Request.UrlReferrer.ToString();
     }
     return(View());
 }
Esempio n. 3
0
        public void Save(ApplyCredit ApplyCredit)
        {
            ApplyCredit baseApplyCredit = Entity.ApplyCredit.FirstOrDefault(n => n.Id == ApplyCredit.Id);

            baseApplyCredit.AgentPay = 1;
            Entity.SaveChanges();
            BaseRedirect();
        }
Esempio n. 4
0
        public void Save(ApplyCredit ApplyCredit)
        {
            ApplyCredit baseApplyCredit = Entity.ApplyCredit.FirstOrDefault(n => n.Id == ApplyCredit.Id);

            baseApplyCredit = Request.ConvertRequestToModel <ApplyCredit>(baseApplyCredit, ApplyCredit);
            Entity.SaveChanges();
            BaseRedirect();
        }
Esempio n. 5
0
        public void ChangeStatus(ApplyCredit ApplyCredit, string InfoList, string Clomn, string Value)
        {
            if (string.IsNullOrEmpty(InfoList))
            {
                InfoList = ApplyCredit.Id.ToString();
            }
            int Ret = Entity.ChangeEntity <ApplyCredit>(InfoList, Clomn, Value);

            Entity.SaveChanges();
            Response.Write(Ret);
        }
        public void CheckUnique()
        {
            DateTime    Today       = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            ApplyCredit ApplyCredit = Entity.ApplyCredit.FirstOrDefault(A => A.UId == BasicUsers.Id && A.AddTime > Today);

            if (ApplyCredit != null)
            {
                Response.Write("1");
            }
            else
            {
                Response.Write("OK");
            }
        }
Esempio n. 7
0
        public CommandResponse Handle(ApplyCredit command)
        {
            if (command.AccountId.IsSameOrEqualTo(Guid.Empty))
            {
                throw new InvalidOperationException("Cannot apply a credit with an empty account id.");
            }

            if (command.CorrelationId.IsSameOrEqualTo(Guid.Empty))
            {
                throw new InvalidOperationException("Cannot apply a credit with an empty correlation id.");
            }

            if (!_repo.TryGetById <Account>(command.AccountId, out var account))
            {
                throw new InvalidOperationException($"ApplyCredit: Account {{{command.AccountId}}} not found.");
            }

            account.ApplyCredit(command.AccountId, command.Amount, command.CorrelationId, command.MsgId);

            _repo.Save(account, Guid.NewGuid());
            return(command.Succeed());
        }
Esempio n. 8
0
 public ActionResult Edit(ApplyCredit ApplyCredit)
 {
     if (ApplyCredit.Id != 0)
     {
         ApplyCredit = Entity.ApplyCredit.FirstOrDefault(n => n.Id == ApplyCredit.Id);
     }
     if (ApplyCredit == null)
     {
         ViewBag.ErrorMsg = "数据不存在";
         return(View("Error"));
     }
     ViewBag.ApplyCredit   = ApplyCredit;
     ViewBag.BasicBank     = Entity.BasicBank.FirstOrNew(n => n.Id == ApplyCredit.BankId);
     ViewBag.BasicProvince = Entity.BasicProvince.FirstOrNew(n => n.Id == ApplyCredit.ComProvince);
     ViewBag.BasicCity     = Entity.BasicCity.FirstOrNew(n => n.Id == ApplyCredit.ComCity);
     ViewBag.BasicDistrict = Entity.BasicDistrict.FirstOrNew(n => n.Id == ApplyCredit.ComDistrict);
     if (Request.UrlReferrer != null)
     {
         Session["Url"] = Request.UrlReferrer.ToString();
     }
     return(View());
 }
        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("[ApplyCredit]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            ApplyCredit ApplyCredit = new ApplyCredit();

            ApplyCredit = JsonToObject.ConvertJsonToModel(ApplyCredit, json);

            Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == ApplyCredit.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 <ApplyCredit> p = new EFPagingInfo <ApplyCredit>();

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

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

            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyCredit> List   = Entity.Selects <ApplyCredit>(p);
            IList <BasicBank>          BBList = Entity.BasicBank.Where(n => n.State == 1).ToList();

            foreach (var pp in List)
            {
                if (!pp.BankId.IsNullOrEmpty())
                {
                    pp.BankName = BBList.FirstOrNew(n => n.Id == pp.BankId).Name;
                }
            }
            IList <ApplyCredit> 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();
        }
Esempio n. 10
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());
        }
Esempio n. 11
0
        public ActionResult Index(ApplyCredit ApplyCredit, EFPagingInfo <ApplyCredit> p, int IsFirst = 0)
        {
            if (ApplyCredit.STime.IsNullOrEmpty())
            {
                ApplyCredit.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (ApplyCredit.ETime.IsNullOrEmpty())
            {
                // ApplyCredit.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                ApplyCredit.ETime = DateTime.Now;
            }
            if (IsFirst == 0)
            {
                PageOfItems <ApplyCredit> ApplyCreditList1 = new PageOfItems <ApplyCredit>(new List <ApplyCredit>(), 0, 10, 0, new Hashtable());
                ViewBag.ApplyCreditList = ApplyCreditList1;
                ViewBag.ApplyCredit     = ApplyCredit;
                ViewBag.BasicBankList   = Entity.BasicBank.Where(n => n.State == 1).ToList();
                return(View());
            }

            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())
            {
                p.SqlWhere.Add(f => f.AgentAId == ApplyCredit.AgentAId);
            }
            if (checkPower("ALL"))
            {
                p.SqlWhere.Add(f => f.AgentId == BasicAgent.Id);//读取全部分支机构
            }
            else
            {
                p.SqlWhere.Add(f => f.AgentAId == AdminUser.Id);//读取用户
            }
            if (!ApplyCredit.STime.IsNullOrEmpty() && !ApplyCredit.ETime.IsNullOrEmpty())
            {
                DateTime ETime = ApplyCredit.ETime;
                p.SqlWhere.Add(f => f.AddTime > ApplyCredit.STime && f.AddTime < ETime);
            }
            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyCredit> ApplyCreditList = Entity.Selects <ApplyCredit>(p);

            ViewBag.ApplyCreditList = ApplyCreditList;
            ViewBag.ApplyCredit     = ApplyCredit;
            ViewBag.BasicBankList   = Entity.BasicBank.Where(n => n.State == 1).ToList();
            return(View());
        }
Esempio n. 12
0
        public ActionResult Index(ApplyCredit ApplyCredit, EFPagingInfo <ApplyCredit> p, bool?IsShowSupAgent, int IsFirst = 0)
        {
            if (ApplyCredit.STime.IsNullOrEmpty())
            {
                ApplyCredit.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (ApplyCredit.ETime.IsNullOrEmpty())
            {
                // ApplyCredit.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                ApplyCredit.ETime = DateTime.Now;
            }
            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.HasSheBao.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasSheBao == (ApplyCredit.HasSheBao == 99 ? 0 : ApplyCredit.HasSheBao));
            }
            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             = 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 == ApplyCredit.AgentAId);
                }
            }
            if (!ApplyCredit.STime.IsNullOrEmpty() && !ApplyCredit.ETime.IsNullOrEmpty())
            {
                DateTime ETime = ApplyCredit.ETime;
                p.SqlWhere.Add(f => f.PayTime > ApplyCredit.STime && f.PayTime < ETime);
            }
            p.SqlWhere.Add(f => f.PayState == 1);
            p.PageSize = 99999999;
            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();
            IList <ApplyCredit> List    = ApplyCreditList.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.SelectSysAgentList = Entity.SysAgent.Where(n => n.Tier == 1).ToList();
            ViewBag.IsShowSupAgent     = IsShowSupAgent;
            ViewBag.Xls = this.checkPower("Xls");
            return(View());
        }
Esempio n. 13
0
        public void XLSDo(ApplyCredit ApplyCredit, EFPagingInfo <ApplyCredit> p)
        {
            if (ApplyCredit.STime.IsNullOrEmpty())
            {
                ApplyCredit.STime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
            }
            if (ApplyCredit.ETime.IsNullOrEmpty())
            {
                //ApplyCredit.ETime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));
                ApplyCredit.ETime = DateTime.Now;
            }
            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.HasSheBao.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.HasSheBao == (ApplyCredit.HasSheBao == 99 ? 0 : ApplyCredit.HasSheBao));
            }
            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())
            {
                p.SqlWhere.Add(f => f.AgentAId == ApplyCredit.AgentAId);
            }
            if (!ApplyCredit.STime.IsNullOrEmpty() && !ApplyCredit.ETime.IsNullOrEmpty())
            {
                DateTime ETime = ApplyCredit.ETime;
                p.SqlWhere.Add(f => f.PayTime > ApplyCredit.STime && f.PayTime < ETime);
            }
            p.SqlWhere.Add(f => f.PayState == 1);
            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <ApplyCredit> ApplyCreditList = Entity.Selects <ApplyCredit>(p);
            IList <BasicBank>          BasicBankList   = Entity.BasicBank.Where(n => n.State == 1).ToList();
            IList <ApplyCredit>        List            = ApplyCreditList.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 => AgentId.Contains(n.Id) && n.Tier == 1).ToList();

            if (SysAgentList.Count > 0)
            {
                //加载对应银行模板
                string       tempname = "AgentCredit.xlsx";
                string       file     = Server.MapPath("/template") + "\\" + tempname;
                ExcelPackage package  = new ExcelPackage(new FileInfo(file), true);
                //设置数据开始行
                int Befor  = 2;
                int maxCol = 7;//最大列数
                //加载模板第一张表
                var     sheet      = package.Workbook.Worksheets[1];
                var     cells      = sheet.Cells;
                decimal TotalMoney = 0; //计算总金额
                decimal TotalPrice = 0; //计算总金额
                int     Rows       = ApplyCreditList.Count() + SysAgentList.Count();
                sheet.InsertRow(Befor + 1, Rows - 1, Befor);
                int i = Befor;
                foreach (var item in SysAgentList)
                {
                    IList <ApplyCredit> ListSub    = ApplyCreditList.Where(n => n.AgentId == item.Id).ToList();
                    decimal             AgentMoney = 0; //计算供应商金额
                    decimal             AgentPrice = 0; //计算供应商金额
                    foreach (var s in ListSub)
                    {
                        sheet.Row(i).Height = 20;//设置行高
                        BasicBank BasicBank = BasicBankList.FirstOrNew(n => n.Id == s.BankId);
                        //分支机构
                        cells["A" + i].Value = item.Name;
                        //编号
                        cells["B" + i].Value = s.Id;
                        //姓名
                        cells["C" + i].Value = s.TrueName;
                        //申请银行
                        cells["D" + i].Value = BasicBank.Name;
                        //售出金额
                        cells["E" + i].Value = s.Amoney;
                        //售出时间
                        cells["F" + i].Value = s.PayTime;
                        //结算金额
                        cells["G" + i].Value = s.AgentMoney;
                        AgentMoney          += s.Amoney;
                        AgentPrice          += s.AgentMoney;
                        i++;
                    }
                    sheet.Row(i).Height = 28;//设置行高
                    //交易金额汇总
                    cells["E" + i].Value = AgentMoney;
                    //结算金额汇总
                    cells["G" + 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["E" + i].Value = TotalMoney;
                //结算金额汇总
                cells["G" + 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, 5, i, 5].Style.Numberformat.Format      = "\"¥\"#,##0.00_);[Red](\"¥\"#,##0.00)";
                sheet.Cells[Befor, 6, i, 6].Style.Numberformat.Format      = "yyyy-mm-dd hh:mm";
                sheet.Cells[Befor, 7, i, 7].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 ApplyCreditCard(ApplyCredit ApplyCredit)
 {
     ViewBag.BasicUsers    = BasicUsers;
     ViewBag.BasicBankList = Entity.BasicBank.Where(n => n.CreditCardUrl != null).ToList();
     return(View());
 }
        public void AddNew(ApplyCredit ApplyCredit, int BankId, string IDcard)
        {
            IList <SMSCode> List = Entity.SMSCode.Where(n => n.UId == BasicUsers.Id && n.Mobile == ApplyCredit.Mobile && n.CType == 1 && n.State == 1).ToList();

            foreach (var p in List)
            {
                p.State = 0;
            }
            Entity.SaveChanges();
            IList <SysAgent> parentAgents = BasicAgent.GetAgentsById(Entity);
            string           Agents       = "|";

            foreach (var item in parentAgents)
            {
                Agents += item.Id + "|";
            }
            ApplyCreditCard AC = new ApplyCreditCard()
            {
                AgentId               = BasicAgent.Id,
                BankId                = BankId,
                Uid                   = BasicUsers.Id,
                FirstAgentAmount      = 0,
                FirstAgentAmountState = 0,
                UserName              = ApplyCredit.TrueName,
                UserMobile            = ApplyCredit.Mobile,
                UserIdCard            = IDcard,
                FirstAgentId          = BasicAgent.GetTopAgent(Entity).Id,
                Relation              = Agents,
                OrderNum              = DateTime.Now.ToString("yyyyMMddHHmmssfff"),
                SettlementAmount      = 0,
                SettlementState       = 0,
                AddTime               = DateTime.Now,
                State                 = 1
            };

            //已审核之前的状态不添加第二条数据 包括已审核的状态
            if (Entity.ApplyCreditCard.FirstOrDefault(ACC => ACC.BankId == BankId && ACC.UserIdCard == IDcard && ACC.State < 3) == null)
            {
                Entity.ApplyCreditCard.AddObject(AC);
                Entity.SaveChanges();
            }

            //ApplyCredit AC = new ApplyCredit();
            //AC = Request.ConvertRequestToModel<ApplyCredit>(AC, ApplyCredit);
            //AC.BankId = BankId;
            //AC.UId = BasicUsers.Id;
            //AC.AId = 0;
            //AC.State = 1;
            //AC.AddTime = DateTime.Now;
            //AC.AgentId = BasicAgent.Id;
            //AC.AgentAId = AdminUser.Id;
            //AC.PayState = 0;
            //AC.AgentPay = 0;
            ////这里是利润计算==========
            //AC.Amoney = 0;//获取价格
            //AC.AIdMoney = AC.Amoney;//总利润
            //AC.AgentMoney = 0;//分支机构佣金设置为0,待分润计算后再写入
            //AC.Company = "";
            //AC.CompanyNature = "";
            //AC.SheBao = "";
            //AC.HasSheBao = 0;
            //AC.Marry = 0;
            //AC.HasCar = 0;
            //AC.HasCredit = 0;
            //Entity.ApplyCredit.AddObject(AC);
            //Entity.SaveChanges();
            Response.Write("<script>location.href=\"" + Entity.BasicBank.FirstOrNew(b => b.Id == BankId).CreditCardUrl + "\";</script>");
        }
        public static void Main(string[] args)
        {
            Console.WriteLine("************************Kredi Hesaplama************************");
            PersonalFinanceLoanManager personalFinanceLoanManager = new PersonalFinanceLoanManager();

            personalFinanceLoanManager.Calculate();

            VehicleLoanManager vehicleLoanManager = new VehicleLoanManager();

            vehicleLoanManager.Calculate();

            MortgageLoanManager mortgageLoanManager = new MortgageLoanManager();

            mortgageLoanManager.Calculate();

            //YADA
            Console.WriteLine();
            Console.WriteLine("************************YADA************************");
            ICreditService personalFinanceLoanManager2 = new PersonalFinanceLoanManager();

            personalFinanceLoanManager2.Calculate();

            ICreditService vehicleLoanManager2 = new VehicleLoanManager();

            vehicleLoanManager2.Calculate();

            ICreditService mortgageLoanManager2 = new MortgageLoanManager();

            mortgageLoanManager2.Calculate();

            //Başvuru Kısmı
            Console.WriteLine();
            Console.WriteLine("************************Başvuru Kısmı************************");
            ICreditService personalFinanceLoanManager3 = new PersonalFinanceLoanManager();

            ICreditService vehicleLoanManager3 = new VehicleLoanManager();

            ICreditService mortgageLoanManager3 = new MortgageLoanManager();

            ApplyCredit applyCredit = new ApplyCredit();

            applyCredit.Apply(personalFinanceLoanManager3);
            applyCredit.Apply(vehicleLoanManager3);
            applyCredit.Apply(mortgageLoanManager3);

            //Başvuru Bilgilendirme
            Console.WriteLine();
            Console.WriteLine("************************Başvuru Bilgilendirme************************");

            List <ICreditService> creditList = new List <ICreditService>()
            {
                personalFinanceLoanManager3, vehicleLoanManager3, mortgageLoanManager3
            };

            applyCredit.ApplyInfo(creditList);


            Console.WriteLine();
            Console.WriteLine("************************Başvuru Kısmı,Loglama Dahil************************");
            ILoggerService databaseLoggerService = new DatabaseLoggerService();
            ILoggerService fileLoggerService     = new FileLoggerService();

            applyCredit.Apply(vehicleLoanManager3, databaseLoggerService);
            applyCredit.Apply(mortgageLoanManager3, fileLoggerService);
        }
Esempio n. 17
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("[ApplyCreditAdd]:", "【Data】" + Data, Ex);
            }
            if (json == null)
            {
                DataObj.OutError("1000");
                return;
            }
            ApplyCredit ApplyCredit = new ApplyCredit();

            ApplyCredit = JsonToObject.ConvertJsonToModel(ApplyCredit, json);

            if (ApplyCredit.Token.IsNullOrEmpty() || ApplyCredit.BankId.IsNullOrEmpty() || ApplyCredit.TrueName.IsNullOrEmpty())
            {
                DataObj.OutError("1000");
                return;
            }

            Users baseUsers = Entity.Users.FirstOrDefault(n => n.Token == ApplyCredit.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;
            }

            ApplyCredit.UId      = baseUsers.Id;
            ApplyCredit.AId      = 0;
            ApplyCredit.State    = 1;
            ApplyCredit.AddTime  = DateTime.Now;
            ApplyCredit.AgentId  = baseUsers.Agent;
            ApplyCredit.AgentAId = baseUsers.AId;
            ApplyCredit.PayState = 0;
            ApplyCredit.AgentPay = 0;
            //这里是利润计算==========
            ApplyCredit.Amoney     = ApplyCredit.GetPrice(Entity); //获取价格
            ApplyCredit.AIdMoney   = ApplyCredit.Amoney;           //总利润
            ApplyCredit.AgentMoney = 0;                            //分支机构佣金设置为0,待分润计算后再写入

            Entity.ApplyCredit.AddObject(ApplyCredit);
            Entity.SaveChanges();

            DataObj.Data = "";
            DataObj.Code = "0000";
            DataObj.OutString();
        }
Esempio n. 18
0
 public CommandResponse Handle(ApplyCredit command)
 {
     return(command.Succeed());
 }