public void Save(OrderHouse OrderHouse) { OrderHouse baseOrderHouse = Entity.OrderHouse.FirstOrDefault(n => n.Id == OrderHouse.Id); Orders Orders = Entity.Orders.FirstOrDefault(n => n.TNum == baseOrderHouse.OId); if (BasicSet.CashPayWay == 1)//开启自动结算时执行 { //自动出款 baseOrderHouse.PayCash(Orders, Entity);//去付款 } else { if (baseOrderHouse.OrderState == 2 && baseOrderHouse.PayState == 1 && baseOrderHouse.FState == 0) { baseOrderHouse.PayState = 2; baseOrderHouse.FState = 1; baseOrderHouse.FTime = DateTime.Now; Orders.PayState = 2; Entity.SaveChanges(); //======分润====== baseOrderHouse = baseOrderHouse.PayAgent(Entity, 1); Orders.AgentPayGet = (decimal)baseOrderHouse.AgentPayGet; Entity.SaveChanges(); } } Orders.SendMsg(Entity);//发送消息类 BaseRedirect(); }
public void Save(OrderHouse OrderHouse) { OrderHouse baseOrderHouse = Entity.OrderHouse.FirstOrDefault(n => n.Id == OrderHouse.Id); if (baseOrderHouse.OrderState == 2 && baseOrderHouse.PayState == 3) { baseOrderHouse.PayState = 4; Orders Orders = Entity.Orders.FirstOrDefault(n => n.TNum == baseOrderHouse.OId); Orders.PayState = 4; //退款到余额 Users baseUsers = Entity.Users.FirstOrDefault(n => n.Id == baseOrderHouse.UId); //计算退款金额 //手续费=总房租*付房租系统费率 decimal Poundage = baseOrderHouse.PayMoney * (decimal)baseOrderHouse.UserRate; //退款金额=交易总金额-支付手续费 decimal Amoney = baseOrderHouse.Amoney - Poundage; //帐户变动记录 int USERSID = baseUsers.Id; string TNUM = Orders.TNum; string SP_Ret = Entity.SP_UsersMoney(USERSID, TNUM, Amoney, 6, ""); if (SP_Ret != "3") { Utils.WriteLog(string.Format("U{0},O{1},T{2}:{3}【{4}】", USERSID, TNUM, 6, Amoney, SP_Ret), "SP_UsersMoney"); } baseOrderHouse = baseOrderHouse.PayAgent(Entity, 2); Orders.AgentPayGet = (decimal)baseOrderHouse.AgentPayGet; Entity.SaveChanges(); //======分润====== Orders.SendMsg(Entity);//发送消息类 //T0时增加配额 if (baseOrderHouse.TrunType == 0) { decimal Money = baseOrderHouse.PayMoney; DateTime Today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); TaskTimeSet TaskTimeSet = Entity.TaskTimeSet.FirstOrDefault(n => n.ODate == Today); if (TaskTimeSet != null) { if (TaskTimeSet.UsedMoney >= Money) { TaskTimeSet.UsedMoney -= Money; } else { TaskTimeSet.UsedMoney = 0; } Entity.SaveChanges(); } } } BaseRedirect(); }
public void SaveEdit(OrderHouse OrderHouse) { OrderHouse baseOrderHouse = Entity.OrderHouse.FirstOrDefault(n => n.Id == OrderHouse.Id); Orders Orders = Entity.Orders.FirstOrDefault(n => n.TNum == baseOrderHouse.OId); if (baseOrderHouse.OrderState == 2 && baseOrderHouse.PayState == 3) { baseOrderHouse.PayState = 2; baseOrderHouse.FState = 1; baseOrderHouse.FTime = DateTime.Now; Orders.PayState = 2; Entity.SaveChanges(); //======分润====== baseOrderHouse = baseOrderHouse.PayAgent(Entity, 1); Orders.AgentPayGet = (decimal)baseOrderHouse.AgentPayGet; Entity.SaveChanges(); Orders.SendMsg(Entity);//发送消息类 } BaseRedirect(); }
public void Execute(IJobExecutionContext context) { string JobName = "OrderProfit"; string CanRun = ConfigurationManager.AppSettings["Run" + JobName].ToString(); if (CanRun == "true") { if (!IsRun) { LokFuEntity Entity = new LokFuEntity(); IsRun = true; try { Log.Write(JobName + "任务开始执行!"); //------------------------------------------------------- #region 任务主体 IList <Orders> List = Entity.Orders.Where(n => n.RunSplit == 1).Take(50).ToList(); foreach (var p in List) { p.RunSplit = 2; } Entity.SaveChanges(); foreach (var O in List) { if (O.TType == 1)//银联卡支付 { OrderRecharge OrderRecharge = Entity.OrderRecharge.FirstOrDefault(n => n.OId == O.TNum); if (OrderRecharge != null) { OrderRecharge = OrderRecharge.PayAgent(Entity, 1, O.FrozenState); O.AgentPayGet = (decimal)OrderRecharge.AgentPayGet; O.AgentState = 1; } } if (O.TType == 2)//提现 { OrderCash OrderCash = Entity.OrderCash.FirstOrDefault(n => n.OId == O.TNum); if (OrderCash != null) { OrderCash = OrderCash.PayAgent(Entity, 1); O.AgentPayGet = (decimal)OrderCash.AgentCashGet; } } if (O.TType == 3)//转帐 { OrderTransfer OrderTransfer = Entity.OrderTransfer.FirstOrDefault(n => n.OId == O.TNum); if (OrderTransfer != null) { OrderTransfer = OrderTransfer.PayAgent(Entity, 1); O.AgentPayGet = (decimal)OrderTransfer.AgentPayGet; } } if (O.TType == 5)//房租 { OrderHouse OrderHouse = Entity.OrderHouse.FirstOrDefault(n => n.OId == O.TNum); if (OrderHouse != null) { OrderHouse = OrderHouse.PayAgent(Entity, 1); O.AgentPayGet = (decimal)OrderHouse.AgentPayGet; } } if (O.TType == 6)//升级 { VIPOrder VIPOrder = Entity.VIPOrder.FirstOrDefault(n => n.TNum == O.TNum); if (VIPOrder != null) { VIPOrder = VIPOrder.PayAgent(Entity, 1); O.AgentPayGet = (decimal)VIPOrder.SplitMoney; O.AgentState = 1; } } if (O.TType == 7 || O.TType == 8 || O.TType == 9)//扫码 NFC { OrderF2F OrderF2F = Entity.OrderF2F.FirstOrDefault(n => n.OId == O.TNum); if (OrderF2F != null) { OrderF2F = OrderF2F.PayAgent(Entity, 1, O.FrozenState); O.AgentPayGet = (decimal)OrderF2F.AgentPayGet; } } if (O.TType == 10)//代理自助开通 { DaiLiOrder DaiLiOrder = Entity.DaiLiOrder.FirstOrDefault(n => n.OId == O.TNum); if (DaiLiOrder != null) { DaiLiOrder = DaiLiOrder.PayAgent(Entity, 1); O.AgentPayGet = (decimal)DaiLiOrder.AgentGet; O.AgentState = 1; } } O.RunSplit = 3; Entity.SaveChanges(); } #endregion //------------------------------------------------------- Log.Write(JobName + "任务执行结束![共计" + List.Count + "条]"); } catch (Exception Ex) { Log.Write(JobName + "任务执行过程出错!", Ex); } IsRun = false; } else { Log.Write(JobName + "任务还在执行中!"); } } }