public bool ProcessCharge(string userID, int money) { EnvInfo envInfo = Database.GetInstance().GetEnviroment(); UserInfo manager = Database.GetInstance().GetManager(UserKind.Manager)[0]; int cash = money * envInfo.CashRate; int serviceCash = cash * envInfo.ChargeGivePercent / 100; // 수수료를 관리자에게서 제한다. if (GiveCash(manager.Id, -serviceCash) == false) { return(false); } if (GiveCash(userID, cash) == false) { return(false); } // 고객 충전기록 ChargeHistoryInfo chargeHistoryInfo = new ChargeHistoryInfo(); chargeHistoryInfo.Kind = (int)ChargeKind.Charge; chargeHistoryInfo.Cash = cash; chargeHistoryInfo.StartTime = DateTime.Now; chargeHistoryInfo.EndTime = DateTime.Now; chargeHistoryInfo.OwnId = userID; chargeHistoryInfo.ApproveId = Users.ManagerInfo.Id; chargeHistoryInfo.BankAccount = string.Format("收费 {0}", money - money * envInfo.ChargeGivePercent / 100); if (Database.GetInstance().AddChargeHistory(chargeHistoryInfo) == false) { return(false); } // 관리자 수수료기록 chargeHistoryInfo = new ChargeHistoryInfo(); chargeHistoryInfo.Kind = (int)ChargeKind.Commission; chargeHistoryInfo.Cash = -serviceCash; chargeHistoryInfo.StartTime = DateTime.Now; chargeHistoryInfo.EndTime = DateTime.Now; chargeHistoryInfo.OwnId = manager.Id; chargeHistoryInfo.ApproveId = Users.ManagerInfo.Id; chargeHistoryInfo.BankAccount = string.Format("佣金 {0}", money * envInfo.ChargeGivePercent / 100); if (Database.GetInstance().AddChargeHistory(chargeHistoryInfo) == false) { return(false); } // 2014-02-05: GreenRose // 사용자가에 충전상태를 알린다. UserInfo userInfo = Database.GetInstance().FindUser(userID); Server.GetInstance().Send(userInfo.Socket, NotifyType.Reply_UserInfo, userInfo); // 충전상태를 메세지로 보낸다. BoardInfo chargeBoardInfo = new BoardInfo(); chargeBoardInfo.UserId = Users.ManagerInfo.Id; chargeBoardInfo.SendId = userInfo.Id; chargeBoardInfo.Title = "通知"; chargeBoardInfo.Content = string.Format("{0}缓冲填充. 您当前的缓存是{1}", cash, userInfo.Cash); chargeBoardInfo.Kind = (int)BoardKind.Letter; if (Database.GetInstance().AddBoard(chargeBoardInfo) == false) { return(false); } List <BoardInfo> letters = Database.GetInstance().GetLetters(Users.ManagerInfo.Id); if (letters == null) { return(false); } HomeInfo homeInfo = new HomeInfo(); homeInfo.Letters = letters; for (int i = 0; i < homeInfo.Letters.Count; i++) { if (homeInfo.Letters[i].Readed != 1) { if (homeInfo.Letters[i].SendId == Users.ManagerInfo.Id) { break; } else { UserInfo liveUser = Users.GetInstance().FindUser(homeInfo.Letters[i].SendId); if (liveUser != null) { homeInfo.Notices = Database.GetInstance().GetNotices(liveUser.Id); Server.GetInstance().Send(liveUser.Socket, NotifyType.Reply_NoticeList, homeInfo); } } } } return(true); }
private void MngCash_Load(object sender, EventArgs e) { UserInfo userInfo = Database.GetInstance().FindUser(_UserId); if (userInfo == null) { return; } int cashTotal = 0; int chatTotal = 0; int gameTotal = 0; int presentTotal = 0; List <ChatHistoryInfo> chatHistoryList = Database.GetInstance().GetAllChatHistories(_UserId); if (chatHistoryList != null) { for (int i = 0; i < chatHistoryList.Count; i++) { ChatHistoryInfo historyInfo = chatHistoryList[i]; int total = 0; string targetId = ""; switch (userInfo.Kind) { case (int)UserKind.Buyer: case (int)UserKind.Recommender: case (int)UserKind.RecommendOfficer: total = historyInfo.BuyerTotal; targetId = historyInfo.ServicemanId; break; case (int)UserKind.ServiceWoman: total = historyInfo.ServicemanTotal; targetId = historyInfo.BuyerId; break; case (int)UserKind.ServiceOfficer: total = historyInfo.ServiceOfficerTotal; targetId = historyInfo.ServicemanId; break; case (int)UserKind.Manager: total = historyInfo.ManagerTotal; targetId = historyInfo.ServicemanId; break; } TimeSpan duration = historyInfo.EndTime - historyInfo.StartTime; chatTotal += total; ChatHistoryView.Rows.Add( targetId, string.Format("{0}:{1}:{2}", duration.Hours, duration.Minutes, duration.Seconds), total, BaseInfo.ConvDateToString(historyInfo.StartTime) ); } } List <ChargeHistoryInfo> chargeHistoryList = Database.GetInstance().GetAllChargeList(_UserId); if (chargeHistoryList != null) { for (int i = 0; i < chargeHistoryList.Count; i++) { ChargeHistoryInfo historyInfo = chargeHistoryList[i]; if (historyInfo.Complete != (int)CompleteKind.Agree) { continue; } cashTotal += historyInfo.Cash; ChargeHistoryView.Rows.Add( historyInfo.KindString, historyInfo.Cash, BaseInfo.ConvDateToString(historyInfo.StartTime), BaseInfo.ConvDateToString(historyInfo.EndTime) ); } } List <PresentHistoryInfo> presentHistoryList = Database.GetInstance().GetAllPresentHistories(_UserId); if (presentHistoryList != null) { for (int i = 0; i < presentHistoryList.Count; i++) { PresentHistoryInfo presentHistoryInfo = presentHistoryList[i]; string sendId = presentHistoryInfo.SendId; string receiveId = presentHistoryInfo.ReceiveId; int cash = presentHistoryInfo.Cash; if (sendId == _UserId) { sendId = ""; cash = -cash; } else { receiveId = ""; } PresentHistoryView.Rows.Add( BaseInfo.ConvDateToString(presentHistoryInfo.SendTime), sendId, receiveId, cash ); presentTotal += cash; } } labelChargeSum.Text = "合计: " + cashTotal; labelChatSum.Text = "合计: " + chatTotal; labelGameSum.Text = "合计: " + gameTotal; labelPresentSum.Text = "合计: " + presentTotal; }
public void RefreshChargeHistoryList() { int year = 0; int month = 0; int day = 0; try { year = Convert.ToInt32(comboYear.Text); month = Convert.ToInt32(comboMonth.Text); day = Convert.ToInt32(comboDay.Text); } catch { } _ChargeList = Database.GetInstance().GetChargeDayList(_Kind, 1, year, month, day); if (_ChargeList == null) { MessageBox.Show("不能在资料库获取结算信息."); return; } HistoryView.Rows.Clear(); SumView.Rows.Clear(); int totalSum = 0; for (int i = 0; i < _ChargeList.Count; i++) { ChargeHistoryInfo historyInfo = _ChargeList[i]; UserInfo userInfo = Database.GetInstance().FindUser(historyInfo.OwnId); if (userInfo == null) { continue; } HistoryView.Rows.Add( historyInfo.OwnId, userInfo.Nickname, historyInfo.BankAccount, historyInfo.Cash, historyInfo.ApproveId, BaseInfo.ConvDateToString(historyInfo.EndTime) ); totalSum += historyInfo.Cash; if (historyInfo.Id == _ChargeSelId) { HistoryView.CurrentCell = HistoryView[0, HistoryView.Rows.Count - 1]; } } _ChargeSelId = -1; SumView.Rows.Add("", "", "", totalSum, "", ""); labelSummary.Text = string.Format("总数: {0}", _ChargeList.Count); }