public EAccount DeliverGoods(int accountid, int goodsid) { EAccount account = DBBase.Get <EAccount>(accountid); EStore goods = DBBase.Get <EStore>(goodsid); if (goods.Type != "Bag" && goods.Type != "Gold") { return(null); } int getGold = Convert.ToInt32(goods.Name); if (account.Diamond < goods.Price) { return(null); } account.Diamond -= goods.Price; account.Gold += getGold; DBBase.Change(account); EBuyRecord record = new EBuyRecord() { BuyerID = accountid, BuyTime = DateTime.Now, GoodsID = goodsid, Num = 1, NowDiamond = account.Diamond, NowGold = account.Gold, CostDiamond = -goods.Price, CostGold = getGold }; DBBase.Create(record); return(account); }
public string GetUnifiedOrderResult(int accountid, int goodsid) { //统一下单 EAccount account = DBBase.Get <EAccount>(accountid); EStore goods = DBBase.Get <EStore>(goodsid); if (goods.Type != "Damion" && goods.Type != "Vip") { return("-1"); //不用用人民币购买 } string openid = account.OpenID; // "oWsnW06q3aPEkggMC9ZDB2ATohsA"; int totalfee = goods.Price * 100; // 100; WxPayData data = new WxPayData(); data.SetValue("body", "卡五梅-游戏充值"); data.SetValue("attach", "kawumei"); data.SetValue("out_trade_no", WXHelper.GenerateOutTradeNo()); data.SetValue("total_fee", totalfee);//订单总金额,单位为分 data.SetValue("time_start", DateTime.Now.ToString("yyyyMMddHHmmss")); data.SetValue("time_expire", DateTime.Now.AddMinutes(10).ToString("yyyyMMddHHmmss")); data.SetValue("goods_tag", goods.Name); data.SetValue("trade_type", "JSAPI"); data.SetValue("openid", openid); WxPayData result = WXHelper.UnifiedOrder(data); Console.Write(result.ToXml()); return(result.ToXml()); }
public MyResult TaskProcess(int par0, int par1, int par2, string par3) { ETask task = DBBase.Get <ETask>(par0); task.ExecutorID = par1; task.State = par2; ETaskTransfer taskTransfer = new ETaskTransfer() { TaskID = task.ID, AppointPersonID = MySession.UserID, AssignedPersonID = par1, CreateTime = System.DateTime.Now, ToState = task.State, Note = par3 }; DBBase.Change(task); DBBase.Create(taskTransfer); if (MySession.UserID != task.ExecutorID && task.ExecutorID != 0) { EUser myuser = DBBase.Get <EUser>(MySession.UserID); EUser excuteuser = DBBase.Get <EUser>(task.ExecutorID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList(task.Title, "指派人" + myuser.Name, ulist, true); } return(ServiceResult(task.ID)); }
static void SendRemind(object sender, System.Timers.ElapsedEventArgs e) { List <ETask> taskList = DBBase.QueryCustom <ETask>("select * from task where IsReminded=0 and Remind<>'' and Remind is not null"); foreach (var t in taskList) { try { DateTime remindTime = t.BeginTime.Date.AddHours(int.Parse(t.Remind)); if (DateTime.Now > remindTime) { t.IsReminded = true; DBBase.Change(t); EUser excuteuser = DBBase.Get <EUser>(t.ExecutorID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList("你有一个任务需要办理", t.Title, ulist, true); } } catch (Exception ex) { Console.WriteLine(t.Title + " 任务提醒出错" + ex.StackTrace); } } }
public MyResult Create(string par0, string par1) { Assembly asmb = Assembly.GetAssembly(typeof(ServiceReturn)); Type type = asmb.GetType(par0); object obj = JsonConvert.DeserializeObject(par1, type); object newObj = DBBase.Create(obj); if (type == typeof(ETask)) { ETask task = (ETask)obj; if (MySession.UserID != task.ExecutorID && task.ExecutorID != 0) { EUser myuser = DBBase.Get <EUser>(MySession.UserID); EUser excuteuser = DBBase.Get <EUser>(task.ExecutorID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList(task.Title, "指派人" + myuser.Name, ulist, true); } } else if (type == typeof(EPlan)) { EPlan plan = (EPlan)obj; EProject project = DBBase.Get <EProject>(plan.ProjectID); EUserSearch userSearch = new EUserSearch() { IsDefault = false, Name = project.Name + "-" + plan.Name, UserID = MySession.UserID, ProjectID = plan.ProjectID, PlanID = plan.ID }; DBBase.Create(userSearch); } return(ServiceResult(newObj)); }
public MyResult ConfirmConnect(int par0, bool par1) { EPeople people = DBBase.Get <EPeople>(par0); if (par1) { people.State = Entity.Enum.PeopleState.Normal; EPeople other = DBBase.Query <EPeople>(string.Format("UserID={0} and PeopleID={1}", people.PeopleID, people.UserID)).FirstOrDefault(); if (other != null) { other.State = Entity.Enum.PeopleState.Normal; DBBase.Change(other); } DBBase.Change(people); } else { EPeople other = DBBase.Query <EPeople>(string.Format("UserID={0} and PeopleID={1}", people.PeopleID, people.UserID)).FirstOrDefault(); if (other != null) { DBBase.Delete <EPeople>(other.ID); } DBBase.Delete <EPeople>(people.ID); } return(ServiceResult("ok")); }
public MyResult GetPlan(int par0) { EPlan plan = DBBase.Query <EPlan>("ProjectID=" + par0).FirstOrDefault(); MyResult ret = ServiceResult(plan); EProject project = DBBase.Get <EProject>(par0); ret.ServiceReturn.AddData("ProjectName", project.Name); return(ret); }
public string PayNotice() { log4net.ILog log = log4net.LogManager.GetLogger(this.GetType());//获取一个日志记录器 try { ResponseBean responseBean = new ResponseBean(this.Request); var sign = GetSign(responseBean); if (responseBean.p4_status == "1" && sign.Equals(responseBean.p10_sign)) { string[] data = responseBean.p11_remark.Split('|'); log.Info(DateTime.Now.ToString() + ": pay info:uid>" + data[0] + " goodsid>" + data[1]); int uid = Convert.ToInt32(data[0]); int goodsid = Convert.ToInt32(data[1]); EAccount account = DBBase.Get <EAccount>(uid); EStore goods = DBBase.Get <EStore>(goodsid); int oldDiamon = account.Diamond; if (goods.Type == "Damion") { account.Diamond += Convert.ToInt32(goods.Name); } else if (goods.Type == "Vip") { account.Vip = Convert.ToInt32(goods.Name); account.VipBeginTime = DateTime.Now; } DBBase.Change(account); EBuyRecord record = new EBuyRecord() { BuyerID = account.ID, BuyTime = DateTime.Now, GoodsID = goodsid, Num = 1, NowDiamond = account.Diamond, NowGold = account.Gold, CostDiamond = account.Diamond - oldDiamon, CostGold = 0 }; DBBase.Create(record); log.Info(DateTime.Now.ToString() + ": pay success:uid>" + uid + " goodsid>" + goodsid);//写入一条新log //服务器操作 return("success"); } else { log.Info(DateTime.Now.ToString() + ": pay error: status>" + responseBean.p4_status);//写入一条新log return("error"); } } catch (Exception ex) { log.Error(DateTime.Now.ToString() + ": pay error: " + ex.Message + " " + ex.StackTrace);//写入一条新log return("error"); } }
public void JoinBattle(string ip, string port, int accountID, int curGameNum, string battleCode, int takeGold, int taleDiamon) { try { EAccount account = DBBase.Get <EAccount>(accountID); account.BattleIP = ip; account.BattlePort = port; account.BattleCode = battleCode.ToString(); if (curGameNum == 1) { account.Gold += takeGold; account.Diamond += taleDiamon; } DBBase.Change(account); EBattleRecord record = DBBase.Query <EBattleRecord>("BattleCode='" + battleCode + "' and GameNum=" + curGameNum).FirstOrDefault(); if (record == null) { //创建记录 record = new EBattleRecord() { BeginTime = DateTime.Now, EndTime = DateTime.Now, BattleCode = battleCode, Sider1ID = accountID, IsFinished = false, GameNum = curGameNum }; DBBase.Create(record); } else { if (record.Sider1ID == 0) { record.Sider1ID = accountID; } else if (record.Sider2ID == 0) { record.Sider2ID = accountID; } else if (record.Sider3ID == 0) { record.Sider3ID = accountID; } else if (record.Sider4ID == 0) { record.Sider4ID = accountID; } DBBase.Change(record); } } catch (Exception ex) { Console.Write(ex.Message + " " + ex.StackTrace); } }
public int WinGold(int accountid, int goldnum) { EAccount user = DBBase.Get <EAccount>(accountid); if (user == null) { return(-1); } user.Gold += goldnum; DBBase.Change(user); return(0); }
public int SetInviteCode(int accountid, int inviteCode) { EAccount account = DBBase.Get <EAccount>(accountid); if (account == null) { return(-1); } account.ReferrerID = inviteCode; DBBase.Change(account); return(0); }
public void ClearBattleSidesState(Battle battle) { foreach (var s in battle.Sides) { EAccount user = DBBase.Get <EAccount>(Convert.ToInt32(s.AccountID)); if (user != null) { user.BattleCode = ""; user.BattleIP = ""; user.BattlePort = ""; DBBase.Change(user); } } }
public MyResult Get(string par0, int par1) { ServiceReturn ret = new ServiceReturn(); Assembly asmb = Assembly.GetAssembly(typeof(ServiceReturn)); Type type = asmb.GetType(par0); object newObj = null; if (type == typeof(EProject)) { newObj = DBBase.Get <EProject>(par1); } else if (type == typeof(EFeedback)) { newObj = DBBase.Get <EFeedback>(par1); } else if (type == typeof(EMessage)) { newObj = DBBase.Get <EMessage>(par1); } else if (type == typeof(EPeople)) { newObj = DBBase.Get <EPeople>(par1); } else if (type == typeof(EPlan)) { newObj = DBBase.Get <EPlan>(par1); } else if (type == typeof(EProjectTeam)) { newObj = DBBase.Get <EProjectTeam>(par1); } else if (type == typeof(ETask)) { newObj = DBBase.Get <ETask>(par1); } else if (type == typeof(ETaskTransfer)) { newObj = DBBase.Get <ETaskTransfer>(par1); } else if (type == typeof(EUser)) { newObj = DBBase.Get <EUser>(par1); } else if (type == typeof(EUserSearch)) { newObj = DBBase.Get <EUserSearch>(par1); } return(ServiceResult(newObj)); }
public EAccount Day5Sign(int accountid) { EAccount aoount = DBBase.Get <EAccount>(accountid); if (aoount == null) { return(null); } int todayNum = (int)(System.DateTime.Now.Date - aoount.FirstSignTime.Date).TotalDays + 1; if (aoount.FirstSignTime.Year == 1) { todayNum = 1; } if (string.IsNullOrEmpty(aoount.SignRecord)) { aoount.SignRecord = todayNum.ToString(); } else { if (aoount.SignRecord.Split('|').Contains(todayNum.ToString())) { return(null); } aoount.SignRecord += "|" + todayNum; } if (todayNum == 1) { if (aoount.Vip < 1) { aoount.Vip = 1; aoount.VipBeginTime = DateTime.Now; } aoount.FirstSignTime = DateTime.Now; } if (todayNum == 2 || todayNum == 3 || todayNum == 4 || todayNum == 5 || todayNum == 6) { aoount.Gold += 1000; } if (todayNum == 7) { aoount.Diamond += 20; } DBBase.Change(aoount); return(aoount); }
public MyResult SendMessage(string par0) { Type type = typeof(EMessage); object obj = JsonConvert.DeserializeObject(par0, type); EMessage newObj = DBBase.Create(obj) as EMessage; //发送推送 EUser myuser = DBBase.Get <EUser>(newObj.SenderID); if (newObj.Type == MessageType.OneToOne) { //接收者加个提示 ENewTips tips = new ENewTips() { UserID = newObj.ReceiverID, Type = newObj.Type, OwnerID = newObj.SenderID }; DBBase.Create(tips); //推送给接收者 EUser excuteuser = DBBase.Get <EUser>(newObj.ReceiverID); List <string> ulist = new List <string>(); ulist.Add(excuteuser.PushClientID); PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, false); PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, true); } else if (newObj.Type == MessageType.Project) { List <EUser> teamUsers = DBBase.QueryCustom <EUser>("select * from user where ID in(select UserID from projectteam where ProjectID=" + newObj.ReceiverID + ")"); List <string> ulist = new List <string>(); foreach (var u in teamUsers) { ulist.Add(u.PushClientID); //每个人加个提示 ENewTips tips = new ENewTips() { UserID = u.ID, Type = newObj.Type, OwnerID = newObj.ReceiverID }; DBBase.Create(tips); } //推送给所有接收者 PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, false); PushMessageToList.PushToList(newObj.Content, "发送人" + myuser.Name, ulist, true); } return(ServiceResult("ok")); }
public EAccount Get(int accountid) { EAccount user = DBBase.Get <EAccount>(accountid); if (user == null) { throw new Exception("用户不存在"); } List <EBattleServers> serverList = DBBase.Query <EBattleServers>(); EBattleServers server = serverList.FirstOrDefault(c => c.ID == 1); user.CurBattleIP = server.IP; user.CurBattlePort = server.Port; int referrerCount = DBBase.Query <EAccount>("ReferrerID=" + user.ID + "").Count(); user.CurTaskProcess = referrerCount; return(user); }
public void ClearBattleOneSideState(Battle battle, string uid) { foreach (var s in battle.Sides) { if (s.AccountID != uid) { continue; } LogHelper.DebugLog("clear:" + uid); EAccount user = DBBase.Get <EAccount>(Convert.ToInt32(s.AccountID)); if (user != null) { user.BattleCode = ""; user.BattleIP = ""; user.BattlePort = ""; DBBase.Change(user); } } }
public MyResult SetComplated(int par0) { ETask task = DBBase.Get <ETask>(par0); task.IsComplated = true; ETaskTransfer taskTransfer = new ETaskTransfer() { TaskID = task.ID, AppointPersonID = MySession.UserID, AssignedPersonID = 0, CreateTime = System.DateTime.Now, ToState = task.State, Note = "设置为已完成" }; DBBase.Change(task); DBBase.Create(taskTransfer); return(ServiceResult(task.ID)); }
public int AddFriends(int accountid, int friendid) { EAccount friendAoount = DBBase.Get <EAccount>(friendid); if (friendAoount == null) { return(-1); } List <EFriends> oldFriends = DBBase.Query <EFriends>(string.Format("AccountID={0} and FriendID={1}", accountid, friendid)); if (oldFriends.Count > 0) { return(-1); } EFriends friend = new EFriends() { AccountID = accountid, FriendID = friendid }; DBBase.Create(friend); return(0); }
public void FinishedBattle(Battle battle) { int takeDiamon = 0; if (battle.WhoTakeMoney == 1) { if (battle.GameNum == 8) { takeDiamon = -10; } else if (battle.GameNum == 16) { takeDiamon = -20; } } foreach (var s in battle.Sides) { //结算 EAccount user = DBBase.Get <EAccount>(Convert.ToInt32(s.AccountID)); if (user != null) { if (battle.BattleType == BattleType.Gold900) { s.GetMoney = s.TotalScore * 900; user.Gold += s.GetMoney; } else if (battle.BattleType == BattleType.Gold2300) { s.GetMoney = s.TotalScore * 2300; user.Gold += s.GetMoney; } else if (battle.BattleType == BattleType.Gold5300) { s.GetMoney = s.TotalScore * 5300; user.Gold += s.GetMoney; } else if (battle.BattleType == BattleType.Diamon10) { s.GetMoney = s.TotalScore * 10; user.Diamond += s.GetMoney; } else if (battle.BattleType == BattleType.Diamon50) { s.GetMoney = s.TotalScore * 50; user.Diamond += takeDiamon + s.GetMoney; } else if (battle.BattleType == BattleType.Diamon100) { s.GetMoney = s.TotalScore * 100; user.Diamond += takeDiamon + s.GetMoney; } if (user.Gold < 0) { user.Gold = 0; } if (user.Diamond < 0) { user.Diamond = 0; } if (!user.IsAI) { DBBase.Change(user); } } } }