public ActionResult Delete(FastPayWay FastPayWay)
 {
     if (FastPayWay.Id != 0)
     {
         FastPayWay = Entity.FastPayWay.FirstOrDefault(n => n.Id == FastPayWay.Id);
     }
     if (FastPayWay == null)
     {
         ViewBag.ErrorMsg = "数据不存在";
         return(View("Error"));
     }
     try
     {
         Entity.FastPayWay.DeleteObject(FastPayWay);
         Entity.SaveChanges();
         APIExtensions.ClearCacheAll();
         ViewBag.Msg = "删除成功";
         return(View("Succeed"));
     }
     catch
     {
         ViewBag.Msg = "删除失败";
         return(View("Error"));
     }
 }
Exemple #2
0
        public void Save(PayConfig PayConfig, string[] queryArray, int?AnsyCash, int?AnsyAgent)
        {
            PayConfig.Cost      = PayConfig.Cost / 1000;
            PayConfig.CostAgent = PayConfig.CostAgent / 1000;
            PayConfig.CostUser  = PayConfig.CostUser / 1000;
            if (PayConfig.Cost < 0 || PayConfig.CostUser < 0 || PayConfig.CostUser > 1 || PayConfig.Cost > 1 || PayConfig.Cost > PayConfig.CostUser)
            {
                Response.Redirect("/Manage/Home/Error.html?IsAjax=1&msg=费率设置有误");
                return;
            }
            PayConfig basePayConfig = Entity.PayConfig.FirstOrDefault(n => n.Id == PayConfig.Id);

            //如果是微信支付配置的子商户号没有填写的话,去掉这个元素
            if (basePayConfig.DllName == "WeiXin")
            {
                if (queryArray[4].IsNullOrEmpty())
                {
                    var temp = new ArrayList(queryArray);
                    temp.RemoveAt(4);
                    queryArray = (string[])temp.ToArray(typeof(string));
                }
            }
            if (queryArray != null)
            {
                basePayConfig.QueryArray = string.Join(",", queryArray);
            }
            basePayConfig = Request.ConvertRequestToModel <PayConfig>(basePayConfig, PayConfig);
            Entity.SaveChanges();
            if (AnsyCash == 1)
            {
                //使用删除全部后根据用户表生成,有效解决了因接口关闭或新增加接口,老用户没有配置问题
                string SQL = "Delete UserPay Where PId=" + basePayConfig.Id;
                Entity.ExecuteStoreCommand(SQL);
                SQL = "INSERT INTO UserPay(UId,PId,Cost,IsDel) Select ID," + basePayConfig.Id + " As PId," + basePayConfig.CostUser + " As Cost, 0 As IsDel From Users";
                Entity.ExecuteStoreCommand(SQL);
            }
            if (AnsyAgent == 1)
            {
                //使用删除全部后根据用户表生成,有效解决了因接口关闭或新增加接口,老用户没有配置问题
                string SQL = "Delete UserPayAgent Where PId=" + basePayConfig.Id;
                Entity.ExecuteStoreCommand(SQL);
                SQL = "INSERT INTO UserPayAgent(AId,PId,Cost,IsDel) Select ID," + basePayConfig.Id + " As PId," + basePayConfig.CostUser + " As Cost, 0 As IsDel From SysAgent";
                Entity.ExecuteStoreCommand(SQL);
            }

            if (AnsyAgent == 1 || AnsyCash == 1)
            {
                APIExtensions.ClearCacheAll();
            }

            BaseRedirect();
        }
Exemple #3
0
        public void MoneySave(SysSet SysSet, int?AnsyCash0, int?AnsyCash1, int?AnsyAgent0, int?AnsyAgent1)
        {
            SysSet.House = SysSet.House / 1000;

            SysSet.Cash0 = SysSet.Cash0 / 1000;
            SysSet.Cash1 = SysSet.Cash1 / 1000;

            SysSet.SysCash0 = SysSet.SysCash0 / 1000;
            SysSet.SysCash1 = SysSet.SysCash1 / 1000;

            SysSet.AgentCash0 = SysSet.AgentCash0 / 1000;
            SysSet.AgentCash1 = SysSet.AgentCash1 / 1000;

            SysSet.PayConfigAgent = SysSet.PayConfigAgent / 100;
            SysSet baseSysSet = BasicSet;

            SysSet.BaoUserAlert   = SysSet.BaoUserAlert ?? string.Empty;
            SysSet.CashAlertMsgT0 = SysSet.CashAlertMsgT0 ?? string.Empty;
            SysSet.CashAlertMsgT1 = SysSet.CashAlertMsgT1 ?? string.Empty;
            baseSysSet            = Request.ConvertRequestToModel <SysSet>(baseSysSet, SysSet);
            Entity.SaveChanges();

            if (AnsyAgent0 == 1)
            {
                string SQL = "Update SysAgent Set ECash0=" + baseSysSet.ECash0 + ",Cash0=" + baseSysSet.Cash0 + ",Cash0Times=" + baseSysSet.Cash0Times;
                Entity.ExecuteStoreCommand(SQL);
            }
            if (AnsyAgent1 == 1)
            {
                string SQL = "Update SysAgent Set ECash1=" + baseSysSet.ECash1 + ",Cash1=" + baseSysSet.Cash1 + ",Cash1Times=" + baseSysSet.Cash1Times;
                Entity.ExecuteStoreCommand(SQL);
            }
            if (AnsyCash0 == 1)
            {
                string SQL = "Update Users Set ECash0=" + baseSysSet.ECash0 + ",Cash0=" + baseSysSet.Cash0;
                Entity.ExecuteStoreCommand(SQL);
            }
            if (AnsyCash1 == 1)
            {
                string SQL = "Update Users Set ECash1=" + baseSysSet.ECash1 + ",Cash1=" + baseSysSet.Cash1;
                Entity.ExecuteStoreCommand(SQL);
            }

            if (AnsyAgent0 == 1 || AnsyAgent1 == 1 || AnsyCash0 == 1 || AnsyCash1 == 1)
            {
                APIExtensions.ClearCacheAll();
            }
            Response.Redirect("/Manage/SysSet/Money.html");
        }
        public ActionResult Save(FastPayWay FastPayWay, string[] queryArray, int STimeHH, int STimemm, int ETimeHH, int ETimemm)
        {
            FastPayWay.Cost  = FastPayWay.Cost / 1000;
            FastPayWay.Cost2 = FastPayWay.Cost2 / 1000;
            FastPayWay.Cost3 = FastPayWay.Cost3 / 1000;

            FastPayWay.BankCost  = FastPayWay.BankCost / 1000;
            FastPayWay.BankCost2 = FastPayWay.BankCost2 / 1000;
            FastPayWay.BankCost3 = FastPayWay.BankCost3 / 1000;

            FastPayWay.InCost  = FastPayWay.InCost / 1000;
            FastPayWay.InCost2 = FastPayWay.InCost2 / 1000;
            FastPayWay.InCost3 = FastPayWay.InCost3 / 1000;
            if (FastPayWay.Cost < 0 || FastPayWay.BankCost < 0 || FastPayWay.Cost >= 1)
            {
                ViewBag.ErrorMsg = "费率设置有误";
                return(View("Error"));
            }
            FastPayWay baseFastPayWay = Entity.FastPayWay.FirstOrDefault(n => n.Id == FastPayWay.Id);

            if (baseFastPayWay != null)//修改直通车通道
            {
                //如果是微信支付配置的子商户号没有填写的话,去掉这个元素
                if (baseFastPayWay.DllName == "WeiXin")
                {
                    if (queryArray[4].IsNullOrEmpty())
                    {
                        var temp = new ArrayList(queryArray);
                        temp.RemoveAt(4);
                        queryArray = (string[])temp.ToArray(typeof(string));
                    }
                }
                if (queryArray != null)
                {
                    baseFastPayWay.QueryArray = string.Join(",", queryArray);
                }
                baseFastPayWay           = Request.ConvertRequestToModel <FastPayWay>(baseFastPayWay, FastPayWay);
                baseFastPayWay.HasAliPay = FastPayWay.HasAliPay;
                baseFastPayWay.HasBank   = FastPayWay.HasBank;
                baseFastPayWay.HasWeiXin = FastPayWay.HasWeiXin;
                DateTime STime = DateTime.Parse("1990-01-01 " + STimeHH + ":" + STimemm + ":00");
                DateTime ETime = DateTime.Parse("1990-01-01 " + ETimeHH + ":" + ETimemm + ":" + (ETimeHH == 23 && ETimemm == 59 ? "59" : "00"));
                baseFastPayWay.STime = STime;
                baseFastPayWay.ETime = ETime;
            }
            else//添加直通车通道
            {
                FastPayWay.Title       = "测试名称";
                FastPayWay.DllName     = "HFJSPay";
                FastPayWay.AddTime     = DateTime.Now;
                FastPayWay.GroupType   = "D0";
                FastPayWay.Version     = "V1.0.0";
                FastPayWay.CanOpenBank = 1;
                DateTime STime = DateTime.Parse("1990-01-01 " + STimeHH + ":" + STimemm + ":00");
                DateTime ETime = DateTime.Parse("1990-01-01 " + ETimeHH + ":" + ETimemm + ":" + (ETimeHH == 23 && ETimemm == 59 ? "59" : "00"));
                FastPayWay.STime = STime;
                FastPayWay.ETime = ETime;

                Entity.FastPayWay.AddObject(FastPayWay);
            }
            Entity.SaveChanges();

            APIExtensions.ClearCacheAll();
            ViewBag.Msg = "操作成功";
            return(View("Succeed"));
        }
Exemple #5
0
        public void Save(int[] PId, double[] Cost, int[] PState, int?AnsyCash, int?AnsyNext)
        {
            bool Check = true;

            for (int i = 0; i < PId.Length; i++)
            {
                int       Pid  = PId[i];
                double    cost = Cost[i] / 1000;
                PayConfig PC   = Entity.PayConfig.FirstOrDefault(n => n.Id == Pid);
                if (PC == null)
                {
                    Check = false;
                }
                if (cost >= PC.CostAgent)
                {
                    UserPayAgent PCT = Entity.UserPayAgent.FirstOrNew(n => n.AId == BasicAgent.Id && n.PId == Pid);
                    PCT.Cost = Cost[i] / 1000;
                    if (PCT.Id.IsNullOrEmpty())
                    {
                        PCT.PId = PId[i];
                        PCT.AId = BasicAgent.Id;
                        Entity.UserPayAgent.AddObject(PCT);
                    }
                }
                else
                {
                    Check = false;
                }
            }
            if (Check)
            {
                Entity.SaveChanges();
            }
            else
            {
                Response.Redirect("/Agent/home/error.html?msg=费率设置有误~");
                return;
            }

            IList <PayConfig>    PayConfigList    = new List <PayConfig>();
            IList <UserPayAgent> UserPayAgentList = new List <UserPayAgent>();
            IList <SysAgent>     AgentList        = new List <SysAgent>();
            string AgentIds = "0";

            if (AnsyCash == 1 || AnsyNext == 1)
            {
                PayConfigList    = Entity.PayConfig.Where(n => n.State == 1).ToList();
                UserPayAgentList = Entity.UserPayAgent.Where(n => n.AId == BasicAgent.Id).ToList();
                //取得代理商所有的下级
                AgentList = BasicAgent.GetSupAgent(Entity, true);
                foreach (var p in AgentList)
                {
                    AgentIds = AgentIds + "," + p.Id;
                }
            }
            if (AnsyCash == 1)
            {
                //使用删除全部后根据用户表生成,有效解决了因接口关闭或新增加接口,老用户没有配置问题
                string SQL = "Delete UserPay Where UId in(Select Id From Users Where Agent in(" + AgentIds + "))";
                Entity.ExecuteStoreCommand(SQL);
                foreach (var p in PayConfigList)
                {
                    double?      cost = p.CostUser;
                    UserPayAgent PCT  = UserPayAgentList.FirstOrNew(n => n.AId == BasicAgent.Id && n.PId == p.Id);
                    if (!PCT.Id.IsNullOrEmpty())
                    {
                        cost = PCT.Cost;
                    }
                    SQL = "INSERT INTO UserPay(UId,PId,Cost,IsDel) Select ID," + p.Id + " As PId," + cost + " As Cost, 0 As IsDel From Users where Id in(Select Id From Users Where Agent in(" + AgentIds + "))";
                    Entity.ExecuteStoreCommand(SQL);
                }
            }
            if (AnsyNext == 1)
            {
                //使用删除全部后根据用户表生成,有效解决了因接口关闭或新增加接口,老用户没有配置问题
                string SQL = "Delete UserPayAgent Where AId in (" + AgentIds + ")";
                Entity.ExecuteStoreCommand(SQL);
                foreach (var p in PayConfigList)
                {
                    double?      cost = p.CostUser;
                    UserPayAgent PCT  = UserPayAgentList.FirstOrNew(n => n.AId == BasicAgent.Id && n.PId == p.Id);
                    if (!PCT.Id.IsNullOrEmpty())
                    {
                        cost = PCT.Cost;
                    }
                    SQL = "INSERT INTO UserPayAgent(AId,PId,Cost,IsDel) Select ID," + p.Id + " As PId," + cost + " As Cost, 0 As IsDel From SysAgent where Id in(" + AgentIds + ")";
                    Entity.ExecuteStoreCommand(SQL);
                }
            }
            if (AnsyCash == 1 || AnsyNext == 1)
            {
                APIExtensions.ClearCacheAll();
            }
            BaseRedirect();
        }