public void Store(StoreMoneyRequestModel request) { var currency = _currencyRepo.GetAll(s => s.Name.Equals(request.Currency)).FirstOrDefault(); if (currency == null) { throw new Exception($"Selected currency is not yet available."); } var user = _userRepo.Get(request.UserId); if (user == null) { throw new Exception("User does not exist."); } UserMoney money = new UserMoney { Currency = currency }; money.CashIn(request.Amount); user.StoreMoney(money); _userRepo.Update(user); }
protected void EBtnSubmit_Click(object sender, EventArgs e) { if (this.Page.IsValid) { decimal howMany = DataConverter.CDecimal(this.TxtMoney.Text); UserInfo userInfo = this.ShowUserInfo.UserInfo; string reason = this.TxtRemark.Text.Trim(); string text = this.TxtMemo.Text; if (userInfo == null) { AdminPage.WriteErrMsg("<li>找不到指定的会员!</li>"); } else { IEncourageStrategy <decimal> strategy = new UserMoney(); if (strategy.IncreaseForUsers(userInfo.UserId.ToString(), howMany, reason, true, text)) { StringBuilder builder = new StringBuilder(); builder.Append("<li>给会员添加收入成功!</li>"); if (this.ChkIsSendMessage.Checked) { string sendContent = SiteConfig.SmsConfig.IncomeLogMessage.Replace("{$Money}", Math.Abs(howMany).ToString()).Replace("{$Reason}", reason); builder.Append(Users.SendMessageToUser(userInfo, sendContent)); } AdminPage.WriteSuccessMsg(builder.ToString(), "UserShow.aspx?UserID=" + userInfo.UserId); } else { AdminPage.WriteErrMsg("<li>给会员添加收入失败!</li>", "UserShow.aspx?UserID=" + userInfo.UserId); } } } }
public override int GetHashCode() { int hash = 1; if (Ret != 0) { hash ^= Ret.GetHashCode(); } if (userMoney_ != null) { hash ^= UserMoney.GetHashCode(); } if (userDraw_ != null) { hash ^= UserDraw.GetHashCode(); } hash ^= awards_.GetHashCode(); if (userDrawInfo_ != null) { hash ^= UserDrawInfo.GetHashCode(); } if (userItem_ != null) { hash ^= UserItem.GetHashCode(); } return(hash); }
public void MergeFrom(BuyItemRes other) { if (other == null) { return; } if (other.Ret != 0) { Ret = other.Ret; } if (other.userMoney_ != null) { if (userMoney_ == null) { userMoney_ = new global::Com.Proto.UserMoneyPB(); } UserMoney.MergeFrom(other.UserMoney); } if (other.userItem_ != null) { if (userItem_ == null) { userItem_ = new global::Com.Proto.UserItemPB(); } UserItem.MergeFrom(other.UserItem); } }
protected void EBtnSubmit_Click(object sender, EventArgs e) { decimal d = DataConverter.CDecimal(this.TxtMoney.Text); string str = this.TxtReason.Text.Trim(); bool isRecord = this.ChkSaveItem.Checked; bool flag2 = false; string str2 = "批量发奖金成功!"; string str3 = "批量发奖金失败!"; string text = this.TxtMemo.Text; if (string.IsNullOrEmpty(str)) { AdminPage.WriteErrMsg("<li>请输入原因!</li>"); } string strA = this.ViewState["Action"] as string; if (string.CompareOrdinal(strA, "SubtractMoney") == 0) { d = -(d); str2 = "批量扣奖金成功!"; str3 = "批量扣奖金失败!"; } IEncourageStrategy <decimal> strategy = new UserMoney(); switch (this.SelectUser.UserType) { case 0: flag2 = strategy.IncreaseForAll(d, str, isRecord, text); break; case 1: if (string.IsNullOrEmpty(this.SelectUser.GroupId)) { AdminPage.WriteErrMsg("<li>请选择会员组!</li>"); } flag2 = strategy.IncreaseForGroup(this.SelectUser.GroupId, d, str, isRecord, text); break; case 2: if (string.IsNullOrEmpty(this.SelectUser.UserId)) { AdminPage.WriteErrMsg("<li>请指定会员!</li>"); } flag2 = strategy.IncreaseForUsers(this.SelectUser.UserId, d, str, isRecord, text); break; } if (flag2) { AdminPage.WriteSuccessMsg("<li>" + str2 + "</li>", "UserManage.aspx"); } else { AdminPage.WriteErrMsg("<li>" + str3 + "</li>"); } }
public static async Task <System.Net.HttpStatusCode> DeleteCurr(string Currencyname, int userid) { Currencyname.ToUpper(); UserMoney cur = new UserMoney(); cur.Cur = Currencyname; var json = JsonConvert.SerializeObject(cur); var data = new StringContent(json, Encoding.UTF8, "application/json"); var client = new HttpClient(); var content = await client.PutAsync("https://myapi20200525144856.azurewebsites.net/api/MyApi/money/DeleteCur/" + userid, data); System.Net.HttpStatusCode state = content.StatusCode; return(state); }
public async Task <ObjectResult> AddUser([FromBody] UserId item1) { UserList dBUserItemsDBFind = JsonConvert.DeserializeObject <UserList>(System.IO.File.ReadAllText(path)); bool cont = false; UserMoney p2 = new UserMoney { Crypto = "btc-bitcoin" }; List <UserMoney> users2 = new List <UserMoney>(); users2.Add(p2); if (dBUserItemsDBFind == null) { UserInfo p1 = new UserInfo { Id = item1.Id, Real = "usd", Currency = users2 }; List <UserInfo> users = new List <UserInfo>(); users.Add(p1); UserList info = new UserList { users = new List <UserInfo>(users) }; await System.IO.File.WriteAllTextAsync(path, JsonConvert.SerializeObject(info, Formatting.Indented)); dBUserItemsDBFind = JsonConvert.DeserializeObject <UserList>(System.IO.File.ReadAllText(path)); return(new ObjectResult(null)); } if (dBUserItemsDBFind.users.Any(x => x.Id == item1.Id)) { cont = true; Response.StatusCode = 409; return(new ObjectResult(null)); } if (cont == false) { dBUserItemsDBFind.users.Add(new UserInfo { Id = item1.Id, Real = "usd", Currency = users2 }); await System.IO.File.WriteAllTextAsync(path, JsonConvert.SerializeObject(dBUserItemsDBFind, Formatting.Indented)); return(new ObjectResult(null)); } return(new ObjectResult(null)); }
public void Send(SendMoneyRequestModel request) { var userFrom = _userRepo.Get(request.FromUserId); var userTo = _userRepo.Get(request.ToUserId); if (userFrom == null || userTo == null) { throw new Exception("The user/s you specified not found."); } var userFrom_money = userFrom.Money.Where(s => s.Currency.Name.Equals(request.Currency)).FirstOrDefault(); if (userFrom_money == null) { throw new Exception($"The sender dont have a {request.Currency} balance."); } if (!userFrom_money.CanSend(request.Amount)) { throw new Exception($"The sender cannot send the specified amount."); } var currency = _currencyRepo.GetAll(s => s.Name.Equals(request.Currency)).FirstOrDefault(); if (currency == null) { throw new Exception($"Selected currency is not yet available."); } var userTo_money = userTo.Money.Where(s => s.Currency.Name.Equals(request.Currency)).FirstOrDefault(); if (userTo_money == null) { userTo_money = new UserMoney { Currency = currency }; userTo_money.CashIn(request.Amount); userTo.StoreMoney(userTo_money); } userFrom_money.CashOut(request.Amount); _userRepo.Update(userFrom); _userRepo.Update(userTo); }
public override int GetHashCode() { int hash = 1; if (Ret != 0) { hash ^= Ret.GetHashCode(); } if (userMoney_ != null) { hash ^= UserMoney.GetHashCode(); } if (userItem_ != null) { hash ^= UserItem.GetHashCode(); } return(hash); }
public void Default() { uid = 0; profile = new UserProfile(); profile.nm = string.Empty; profile.lv = 1; profile.xp = 1; profile.tt = 10; money = new UserMoney(); money.gld = 500000; ticket = new UserTicket(); ticket.val = 1000; ticket.date = 10000; }
public void MergeFrom(DrawRes other) { if (other == null) { return; } if (other.Ret != 0) { Ret = other.Ret; } if (other.userMoney_ != null) { if (userMoney_ == null) { userMoney_ = new global::Com.Proto.UserMoneyPB(); } UserMoney.MergeFrom(other.UserMoney); } if (other.userDraw_ != null) { if (userDraw_ == null) { userDraw_ = new global::Com.Proto.UserDrawPB(); } UserDraw.MergeFrom(other.UserDraw); } awards_.Add(other.awards_); if (other.userDrawInfo_ != null) { if (userDrawInfo_ == null) { userDrawInfo_ = new global::Com.Proto.UserDrawInfoPB(); } UserDrawInfo.MergeFrom(other.UserDrawInfo); } if (other.userItem_ != null) { if (userItem_ == null) { userItem_ = new global::Com.Proto.UserItemPB(); } UserItem.MergeFrom(other.UserItem); } }
protected void BtnRegStep2_Click(object sender, EventArgs e) { IEncourageStrategy <int> strategy2; if (!this.userSiteConfig.EnableUserReg) { return; } if (!this.Page.IsValid) { return; } this.CheckUserName(); this.CheckEmail(); this.CheckCode(); this.CheckQAofReg(); UserInfo usersInfo = new UserInfo(); usersInfo.Question = this.TxtQuestion.Text; usersInfo.Answer = StringHelper.MD5(this.TxtAnswer.Text); usersInfo.Email = this.TxtEmail.Text; usersInfo.UserFace = this.TxtUserFace.Text; usersInfo.FaceWidth = DataConverter.CLng(this.TxtFaceWidth.Text); usersInfo.FaceHeight = DataConverter.CLng(this.TxtFaceHeight.Text); usersInfo.Sign = this.TxtSign.Text; usersInfo.PrivacySetting = DataConverter.CLng(this.DropPrivacy.SelectedValue); string str = DataSecurity.MakeRandomString(10); usersInfo.LastPassword = str; ContacterInfo contacterInfo = new ContacterInfo(); contacterInfo.TrueName = this.TxtTrueName.Text; contacterInfo.Country = this.Region.Country; contacterInfo.Province = this.Region.Province; contacterInfo.City = this.Region.City; contacterInfo.Address = this.TxtAddress.Text; contacterInfo.ZipCode = this.TxtZipCode.Text; contacterInfo.OfficePhone = this.TxtOfficePhone.Text; contacterInfo.HomePhone = this.TxtHomePhone.Text; contacterInfo.Mobile = this.TxtMobile.Text; contacterInfo.Fax = this.TxtFax.Text; contacterInfo.Homepage = this.TxtHomepage.Text; contacterInfo.Email = this.TxtEmail.Text; contacterInfo.QQ = this.TxtQQ.Text; contacterInfo.Msn = this.TxtMSN.Text; contacterInfo.Icq = this.TxtICQ.Text; contacterInfo.Yahoo = this.TxtYahoo.Text; contacterInfo.UC = this.TxtUC.Text; contacterInfo.Aim = this.TxtAim.Text; contacterInfo.IdCard = this.TxtIDCard.Text; contacterInfo.Sex = (UserSexType)Enum.Parse(typeof(UserSexType), this.DropSex.SelectedValue); contacterInfo.Marriage = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), DataConverter.CLng(this.DropMarriage.SelectedValue).ToString()); if (this.GetDisplayStyle("Income") != "none") { contacterInfo.Income = DataConverter.CLng(this.DropIncome.SelectedValue); } else { contacterInfo.Income = -1; } contacterInfo.Education = -1; contacterInfo.Company = this.TxtCompany.Text; contacterInfo.Department = this.TxtDepartment.Text; contacterInfo.ClientId = 0; contacterInfo.ParentId = 0; contacterInfo.CreateTime = DateTime.Now; contacterInfo.Owner = ""; contacterInfo.UserType = ContacterType.EnterpriceMainContacter; contacterInfo.UpdateTime = DateTime.Now; contacterInfo.UserName = Users.UserNamefilter(this.TxtUserName.Text); contacterInfo.Phs = this.TxtPHS.Text; contacterInfo.Birthday = string.IsNullOrEmpty(this.TxtBirthday.Text) ? null : new DateTime?(this.TxtBirthday.Date); contacterInfo.Position = this.TxtPosTitle.Text; usersInfo.UserName = Users.UserNamefilter(this.TxtUserName.Text); usersInfo.UserPassword = StringHelper.MD5(this.TxtPassword.Text); usersInfo.GroupId = this.userSiteConfig.GroupId; usersInfo.JoinTime = DateTime.Now; usersInfo.RegTime = DateTime.Now; usersInfo.UserExp = (int)this.userSiteConfig.PresentExp; usersInfo.UserPoint = 0; usersInfo.IsInheritGroupRole = true; usersInfo.Status = UserStatus.None; if (this.userSiteConfig.EmailCheckReg) { usersInfo.Status = UserStatus.WaitValidateByEmail; usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10); } if (this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin; } if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail; } usersInfo.EndTime = new DateTime?(DateTime.Now); usersInfo.Balance = 0M; string str2 = ""; if (ApiData.IsAPiEnable()) { str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage); if (str2 != "true") { DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>"); } str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtPassword.Text, "1"); } if (!Users.Add(usersInfo, contacterInfo)) { DynamicPage.WriteErrMsg("<li>注册失败!</li>"); return; } if (this.userSiteConfig.PresentMoney != 0.0) { IEncourageStrategy <decimal> strategy = new UserMoney(); strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱"); } if (this.userSiteConfig.PresentValidNum == 0) { goto Label_0665; } int howMany = 0; if (this.userSiteConfig.PresentValidNum == -1) { howMany = 0x270f; } else { switch (this.userSiteConfig.PresentValidUnit) { case 1: howMany = this.userSiteConfig.PresentValidNum; goto Label_063A; case 2: howMany = this.userSiteConfig.PresentValidNum * 30; goto Label_063A; case 3: howMany = this.userSiteConfig.PresentValidNum * 0x16d; goto Label_063A; } howMany = this.userSiteConfig.PresentValidNum; } Label_063A: strategy2 = new UserDate(); strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期"); Label_0665: if (this.userSiteConfig.PresentPoint != 0) { IEncourageStrategy <int> strategy3 = new UserPoint(); strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券"); } if (this.userSiteConfig.EmailCheckReg) { MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; List <MailAddress> list = new List <MailAddress>(); list.Add(new MailAddress(usersInfo.Email)); mailInfo.MailToAddressList = list; mailInfo.MailBody = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum); mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码"; if (SendMail.Send(mailInfo) == MailState.Ok) { DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx"); } } string str3 = ""; if (this.userSiteConfig.EnableRegCompany) { str3 = "<li><a href='Company/RegCompany.aspx'>继续注册企业?</a></li>"; } if (usersInfo.Status == UserStatus.None) { UserPrincipal principal = new UserPrincipal(); principal.UserName = usersInfo.UserName; principal.LastPassword = usersInfo.LastPassword; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, DateTime.Now, DateTime.Now.AddMinutes(60.0), false, principal.SerializeToString()); string str4 = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4); cookie.HttpOnly = true; cookie.Path = FormsAuthentication.FormsCookiePath; cookie.Secure = FormsAuthentication.RequireSSL; base.Response.Cookies.Add(cookie); } if (SiteConfig.ShopConfig.IsPayPassword) { BasePage.ResponseRedirect("RegisterPayPassword.aspx?Url=Register"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "Default.aspx"); } }
protected void BtnSave_Click(object sender, EventArgs e) { double totalDays; int validNum; IEncourageStrategy <int> strategy2; if (!base.IsValid) { return; } string password = StringHelper.Base64StringEncode(this.TxtPassword.Text); CardInfo cardByNumAndPassword = Cards.GetCardByNumAndPassword(this.TxtCardNum.Text.Trim(), password); if (cardByNumAndPassword.IsNull) { DynamicPage.WriteErrMsg("卡号或密码错误!"); } else { if (cardByNumAndPassword.CardType != 0) { DynamicPage.WriteErrMsg("你输入的充值卡是其他公司的卡,不能在本站进行充值。请尽快去有关公司或网站的充值入口进行充值。"); } if (!string.IsNullOrEmpty(cardByNumAndPassword.UserName)) { DynamicPage.WriteErrMsg("你输入的充值卡已经使用过了!"); } if (cardByNumAndPassword.EndDate < DateTime.Today) { DynamicPage.WriteErrMsg("你输入的充值卡已经失效!此卡的充值截止日期为:" + cardByNumAndPassword.EndDate.ToString("yyyy-MM-dd")); } } UserInfo userInfo = this.showUserInfo.UserInfo; bool flag = false; string groupName = string.Empty; StringBuilder builder = new StringBuilder(); builder.Append("<li>充值成功!</li>"); if (cardByNumAndPassword.ValidUnit == 5) { groupName = UserGroups.GetUserGroupById(cardByNumAndPassword.ValidNum).GroupName; builder.Append("<li><span style='Color:#F00'>恭喜您已升级成\"" + groupName + "\"</span></li>"); } builder.Append("<li>充值卡卡号:" + cardByNumAndPassword.CardNum + "</li>"); builder.Append("<li>充值卡面值:" + cardByNumAndPassword.Money.ToString("N2") + "元</li>"); builder.Append("<li>充值截止日期:" + cardByNumAndPassword.EndDate.ToString("yyyy-MM-dd") + "</li>"); switch (cardByNumAndPassword.ValidUnit) { case 0: { builder.Append("<li>充值卡点数:" + cardByNumAndPassword.ValidNum.ToString() + Cards.GetValidUnitType(cardByNumAndPassword.ValidUnit) + "</li>"); builder.Append("<li>您充值前的" + SiteConfig.UserConfig.PointName + "数:" + userInfo.UserPoint.ToString() + "</li>"); IEncourageStrategy <int> strategy = new UserPoint(); flag = strategy.IncreaseForUsers(userInfo.UserId.ToString(), cardByNumAndPassword.ValidNum, "充值卡充值。卡号:" + cardByNumAndPassword.CardNum, true, ""); string[] strArray2 = new string[] { "<li>您充值后的", SiteConfig.UserConfig.PointName, "数:", (userInfo.UserPoint + cardByNumAndPassword.ValidNum).ToString(), "</li>" }; builder.Append(string.Concat(strArray2)); goto Label_059A; } case 1: case 2: case 3: { builder.Append("<li>充值卡内含有效期:" + cardByNumAndPassword.ValidNum.ToString() + Cards.GetValidUnitType(cardByNumAndPassword.ValidUnit) + "</li>"); TimeSpan span = (TimeSpan)(DataConverter.CDate(userInfo.EndTime).Date - DateTime.Today.Date); totalDays = span.TotalDays; validNum = cardByNumAndPassword.ValidNum; strategy2 = new UserDate(); switch (cardByNumAndPassword.ValidUnit) { case 2: validNum *= 30; break; case 3: validNum *= 0x16d; break; } break; } case 4: { builder.Append("<li>充值卡内含资金:" + cardByNumAndPassword.ValidNum.ToString() + Cards.GetValidUnitType(cardByNumAndPassword.ValidUnit) + "</li>"); builder.Append("<li>您充值前的资金余额为:" + userInfo.Balance.ToString("N2") + "元</li>"); IEncourageStrategy <decimal> strategy3 = new UserMoney(); flag = strategy3.IncreaseForUsers(userInfo.UserId.ToString(), cardByNumAndPassword.ValidNum, "充值卡充值。卡号:" + cardByNumAndPassword.CardNum, true, ""); builder.Append("<li>您充值后的资金余额为:" + ((userInfo.Balance + cardByNumAndPassword.ValidNum)).ToString("N2") + "元</li>"); goto Label_059A; } case 5: builder.Append("<li>会员级别:" + groupName + "</li>"); flag = Users.MoveByUserName(userInfo.UserName, cardByNumAndPassword.ValidNum); goto Label_059A; default: goto Label_059A; } if (totalDays > 0.0) { builder.Append("<li>您充值前的有效期:" + totalDays.ToString() + "天</li>"); flag = strategy2.IncreaseForUsers(userInfo.UserId.ToString(), validNum, "充值卡充值。卡号:" + cardByNumAndPassword.CardNum, true, ""); builder.Append("<li>您充值后的有效期:" + ((totalDays + validNum)).ToString() + "天</li>"); } else { builder.Append("<li>您充值前有效期已经过期" + Math.Abs(totalDays).ToString() + "天</li>"); flag = strategy2.IncreaseForUsers(userInfo.UserId.ToString(), validNum, "充值卡充值。卡号:" + cardByNumAndPassword.CardNum, true, ""); builder.Append("<li>您充值后的有效期:" + validNum.ToString() + "天,开始计算日期:" + DateTime.Today.ToString("yyyy-MM-dd") + "</li>"); } Label_059A: if (flag) { cardByNumAndPassword.UserName = userInfo.UserName; cardByNumAndPassword.UseTime = new DateTime?(DateTime.Now); Cards.Update(cardByNumAndPassword); DynamicPage.WriteSuccessMsg(builder.ToString(), "Recharge.aspx"); } else { DynamicPage.WriteErrMsg("充值失败!"); } }
public async Task <ObjectResult> AddCrypto([FromBody] UserCurrency item, string id) { UserList dBUserItemsDBFind = JsonConvert.DeserializeObject <UserList>(System.IO.File.ReadAllText(path)); Commands comm = new Commands(); comm.DBCheck(comm, dBUserItemsDBFind, id); if (comm.Exist == false) { Response.StatusCode = 404; return(new ObjectResult(null)); } client = new CoinpaprikaAPI.Client(); var coins = await client.GetCoinsAsync(); string s = JsonConvert.SerializeObject(coins); Value st = JsonConvert.DeserializeObject <Value>(s); Dictionary <string, string> names = new Dictionary <string, string>(); int lenght = st.value.Count; for (int i = 0; i < lenght; i++) { st.value[i].Name = st.value[i].Name.ToLower(); names.Add(st.value[i].Id, st.value[i].Name); } item.crypto = item.crypto.ToLower(); item.crypto = names.FirstOrDefault(x => x.Value == item.crypto).Key; string item1 = item.crypto; if (item1 == null) { Response.StatusCode = 400; return(new ObjectResult(null)); } if (dBUserItemsDBFind.users[comm.Index].Currency == null) { UserMoney p1 = new UserMoney { Crypto = item1, }; List <UserMoney> users = new List <UserMoney>(); users.Add(p1); dBUserItemsDBFind.users[comm.Index].Currency = users; await System.IO.File.WriteAllTextAsync(path, JsonConvert.SerializeObject(dBUserItemsDBFind, Formatting.Indented)); } else { for (int i = 0; i < dBUserItemsDBFind.users[comm.Index].Currency.Count; i++) { if (dBUserItemsDBFind.users[comm.Index].Currency[i].Crypto == item1) { Response.StatusCode = 409; item1 = null; return(new ObjectResult(null)); } } dBUserItemsDBFind.users[comm.Index].Currency.Add(new UserMoney() { Crypto = item1 }); } if (dBUserItemsDBFind.users[comm.Index].Real == null) { dBUserItemsDBFind.users[comm.Index].Real = "usd"; } await System.IO.File.WriteAllTextAsync(path, JsonConvert.SerializeObject(dBUserItemsDBFind, Formatting.Indented)); return(new ObjectResult(null)); }
protected void EBtnSubmit_Click(object sender, EventArgs e) { string input = this.HdnUsersId.Value; int orderId = DataConverter.CLng(this.HdnorderId.Value); decimal d = DataConverter.CDecimal(this.TxtMoney.Text); UserInfo userById = Users.GetUserById(DataConverter.CLng(input)); if (userById.IsNull) { AdminPage.WriteErrMsg("<li>找不到指定的会员!</li>", "UserShow.aspx?UserID=" + input); } else { OrderInfo orderInfo = new OrderInfo(true); if ((userById.Balance + DataConverter.CDecimal(userById.UserPurview.Overdraft)) < d) { AdminPage.WriteErrMsg("<li>会员资金余额小于支出金额!</li>", base.Request.UrlReferrer.ToString()); } if (orderId > 0) { orderInfo = Order.GetOrderById(orderId); this.ValidateOrder(orderInfo, DataConverter.CLng(input)); orderInfo.MoneyReceipt += d; if (orderInfo.Status <= OrderStatus.WaitForConfirm) { orderInfo.Status = OrderStatus.Confirmed; } if (!Order.UserPayment(orderInfo.OrderId, orderInfo.MoneyReceipt, orderInfo.Status)) { AdminPage.WriteErrMsg("<li>给订单添加付款失败!</li>", "../Shop/OrderManage.aspx?OrderID=" + orderId); } } IEncourageStrategy <decimal> strategy = new UserMoney(); bool isRecord = true; if (orderId > 0) { isRecord = false; } if (strategy.IncreaseForUsers(input, -(d), this.TxtRemark.Text.Trim(), isRecord, this.TxtMemo.Text)) { if (orderId > 0) { this.AddBankroll(orderInfo, d); AdminPage.WriteSuccessMsg("<li>给订单添加付款成功!</li>", "../Shop/OrderManage.aspx?OrderID=" + orderId); } else { StringBuilder builder = new StringBuilder(); builder.Append("<li>给会员添加支出成功!</li>"); if (this.ChkIsSendMessage.Checked) { string sendContent = SiteConfig.SmsConfig.PayoutLogMessage.Replace("{$Money}", Math.Abs(d).ToString()).Replace("{$Reason}", this.TxtRemark.Text); builder.Append(Users.SendMessageToUser(userById, sendContent)); } AdminPage.WriteSuccessMsg(builder.ToString(), "UserShow.aspx?UserID=" + input); } } else { AdminPage.WriteErrMsg("<li>给会员添加支出失败!</li>"); } } }
public void createUser() { IEncourageStrategy <int> strategy2; this.API.SpeItems[7, 1] = this.API.GetNodeText(this.API.SpeItems[7, 0]); if (!this.CheckUserName() || !this.CheckUserEmail()) { return; } this.API.PrepareData(true); UserInfo usersInfo = new UserInfo(); usersInfo.Question = this.API.SpeItems[8, 1]; usersInfo.Answer = StringHelper.MD5(this.API.SpeItems[9, 1]); usersInfo.Email = this.API.SpeItems[7, 1]; string str = DataSecurity.MakeRandomString(10); usersInfo.LastPassword = str; ContacterInfo contacterInfo = new ContacterInfo(); contacterInfo.TrueName = this.API.SpeItems[11, 1]; contacterInfo.Country = ""; contacterInfo.Province = ""; contacterInfo.City = ""; contacterInfo.Address = this.API.SpeItems[0x12, 1]; contacterInfo.ZipCode = this.API.SpeItems[0x13, 1]; contacterInfo.OfficePhone = this.API.SpeItems[0x11, 1]; contacterInfo.HomePhone = ""; contacterInfo.Mobile = this.API.SpeItems[0x10, 1]; contacterInfo.Fax = ""; contacterInfo.Homepage = this.API.SpeItems[20, 1]; contacterInfo.Email = this.API.SpeItems[7, 1]; contacterInfo.QQ = this.API.SpeItems[14, 1]; contacterInfo.Msn = this.API.SpeItems[15, 1]; contacterInfo.Icq = ""; contacterInfo.Yahoo = ""; contacterInfo.UC = ""; contacterInfo.Aim = ""; contacterInfo.IdCard = ""; if (this.API.SpeItems[12, 1] == "1") { this.API.SpeItems[12, 1] = "Female"; } else if (this.API.SpeItems[12, 1] == "0") { this.API.SpeItems[12, 1] = "Male"; } else { this.API.SpeItems[12, 1] = "Secrecy"; } contacterInfo.Sex = (UserSexType)Enum.Parse(typeof(UserSexType), this.API.SpeItems[12, 1]); contacterInfo.Marriage = UserMarriageType.Secrecy; contacterInfo.Income = -1; contacterInfo.Education = -1; contacterInfo.Company = ""; contacterInfo.Department = ""; contacterInfo.ClientId = 0; contacterInfo.ParentId = 0; contacterInfo.CreateTime = DateTime.Now; contacterInfo.Owner = ""; contacterInfo.UserType = ContacterType.EnterpriceMainContacter; contacterInfo.UpdateTime = DateTime.Now; contacterInfo.UserName = Users.UserNamefilter(this.API.SpeItems[5, 1]); contacterInfo.Phs = ""; contacterInfo.Birthday = string.IsNullOrEmpty(this.API.SpeItems[13, 1]) ? null : new DateTime?(Convert.ToDateTime(this.API.SpeItems[13, 1])); contacterInfo.Position = ""; usersInfo.UserName = Users.UserNamefilter(this.API.SpeItems[5, 1]); usersInfo.UserPassword = StringHelper.MD5(this.API.SpeItems[6, 1]); usersInfo.GroupId = this.userSiteConfig.GroupId; usersInfo.JoinTime = DateTime.Now; usersInfo.RegTime = DateTime.Now; usersInfo.UserExp = (int)this.userSiteConfig.PresentExp; usersInfo.UserPoint = 0; usersInfo.IsInheritGroupRole = true; usersInfo.Status = UserStatus.None; if (this.userSiteConfig.EmailCheckReg) { usersInfo.Status = UserStatus.WaitValidateByEmail; usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10); } if (this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin; } if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail; } usersInfo.EndTime = new DateTime?(DateTime.Now); usersInfo.Balance = 0M; if (!Users.Add(usersInfo, contacterInfo)) { this.API.FoundErr = true; this.API.ErrMsg = "注册失败!"; return; } if (this.userSiteConfig.PresentMoney != 0.0) { IEncourageStrategy <decimal> strategy = new UserMoney(); strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱"); } if (this.userSiteConfig.PresentValidNum == 0) { goto Label_05C6; } int howMany = 0; if (this.userSiteConfig.PresentValidNum == -1) { howMany = 0x270f; } else { switch (this.userSiteConfig.PresentValidUnit) { case 1: howMany = this.userSiteConfig.PresentValidNum; goto Label_059B; case 2: howMany = this.userSiteConfig.PresentValidNum * 30; goto Label_059B; case 3: howMany = this.userSiteConfig.PresentValidNum * 0x16d; goto Label_059B; } howMany = this.userSiteConfig.PresentValidNum; } Label_059B: strategy2 = new UserDate(); strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期"); Label_05C6: if (this.userSiteConfig.PresentPoint != 0) { IEncourageStrategy <int> strategy3 = new UserPoint(); strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券"); } if (this.userSiteConfig.EmailCheckReg) { MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; List <MailAddress> list = new List <MailAddress>(); list.Add(new MailAddress(usersInfo.Email)); mailInfo.MailToAddressList = list; mailInfo.MailBody = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum); mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码"; SendMail.Send(mailInfo); } if (usersInfo.Status == UserStatus.None) { UserPrincipal principal = new UserPrincipal(); principal.UserName = usersInfo.UserName; principal.LastPassword = usersInfo.LastPassword; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, DateTime.Now, DateTime.Now.AddMinutes(60.0), false, principal.SerializeToString()); string str2 = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str2); cookie.HttpOnly = true; cookie.Path = FormsAuthentication.FormsCookiePath; cookie.Secure = FormsAuthentication.RequireSSL; base.Response.Cookies.Add(cookie); } }
protected void BtnRegister_Click(object sender, EventArgs e) { IEncourageStrategy <int> strategy2; if (!this.userSiteConfig.EnableUserReg) { return; } if (!this.Page.IsValid) { return; } this.CheckUserName(); this.CheckEmail(); UserInfo usersInfo = new UserInfo(); usersInfo.Email = this.TxtEmail.Text; usersInfo.FaceWidth = 0; usersInfo.FaceHeight = 0; usersInfo.PrivacySetting = 0; ContacterInfo contacterInfo = new ContacterInfo(); contacterInfo.Sex = (UserSexType)Enum.Parse(typeof(UserSexType), "0"); contacterInfo.Marriage = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), "0"); contacterInfo.Income = -1; contacterInfo.Education = -1; contacterInfo.ClientId = 0; contacterInfo.ParentId = 0; contacterInfo.CreateTime = DateTime.Now; contacterInfo.Owner = ""; contacterInfo.UserType = ContacterType.EnterpriceMainContacter; contacterInfo.UpdateTime = DateTime.Now; contacterInfo.UserName = Users.UserNamefilter(this.TxtRegUserName.Text); contacterInfo.Birthday = null; usersInfo.UserName = Users.UserNamefilter(this.TxtRegUserName.Text); usersInfo.UserPassword = StringHelper.MD5(this.TxtRegPassword.Text); usersInfo.GroupId = this.userSiteConfig.GroupId; usersInfo.JoinTime = DateTime.Now; usersInfo.RegTime = DateTime.Now; usersInfo.UserExp = (int)this.userSiteConfig.PresentExp; usersInfo.UserPoint = 0; usersInfo.IsInheritGroupRole = true; usersInfo.Status = UserStatus.None; string str = DataSecurity.MakeRandomString(10); usersInfo.LastPassword = str; if (this.userSiteConfig.EmailCheckReg) { usersInfo.Status = UserStatus.WaitValidateByEmail; usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10); } if (this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin; } if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg) { usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail; } usersInfo.EndTime = new DateTime?(DateTime.Now); usersInfo.Balance = 0M; string str2 = ""; if (ApiData.IsAPiEnable()) { str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtRegPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage); if (str2 != "true") { DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>"); } str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtRegPassword.Text, "1"); } if (!Users.Add(usersInfo, contacterInfo)) { DynamicPage.WriteErrMsg("<li>注册失败!</li>"); return; } if (this.userSiteConfig.PresentMoney != 0.0) { IEncourageStrategy <decimal> strategy = new UserMoney(); strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱"); } if (this.userSiteConfig.PresentValidNum == 0) { goto Label_03EF; } int howMany = 0; if (this.userSiteConfig.PresentValidNum == -1) { howMany = 0x270f; } else { switch (this.userSiteConfig.PresentValidUnit) { case 1: howMany = this.userSiteConfig.PresentValidNum; goto Label_03C4; case 2: howMany = this.userSiteConfig.PresentValidNum * 30; goto Label_03C4; case 3: howMany = this.userSiteConfig.PresentValidNum * 0x16d; goto Label_03C4; } howMany = this.userSiteConfig.PresentValidNum; } Label_03C4: strategy2 = new UserDate(); strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期"); Label_03EF: if (this.userSiteConfig.PresentPoint != 0) { IEncourageStrategy <int> strategy3 = new UserPoint(); strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券"); } if (this.userSiteConfig.EmailCheckReg) { MailInfo mailInfo = new MailInfo(); mailInfo.IsBodyHtml = true; mailInfo.FromName = SiteConfig.SiteInfo.SiteName; List <MailAddress> list = new List <MailAddress>(); list.Add(new MailAddress(usersInfo.Email)); mailInfo.MailToAddressList = list; mailInfo.MailBody = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum); mailInfo.Subject = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码"; if (SendMail.Send(mailInfo) == MailState.Ok) { DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx"); } } string str3 = ""; if (this.userSiteConfig.EnableRegCompany) { str3 = "<li><a href='/Company/RegCompany.aspx'>继续注册企业?</a></li>"; } if (usersInfo.Status == UserStatus.None) { bool isPersistent = false; DateTime now = DateTime.Now; DateTime expiration = DateTime.Now; isPersistent = false; expiration = now.AddDays(1.0); UserPrincipal principal = new UserPrincipal(); principal.UserName = usersInfo.UserName; principal.LastPassword = usersInfo.LastPassword; FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, now, expiration, isPersistent, principal.SerializeToString()); string str4 = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4); if (isPersistent) { cookie.Expires = expiration; } cookie.HttpOnly = true; cookie.Path = FormsAuthentication.FormsCookiePath; cookie.Secure = FormsAuthentication.RequireSSL; base.Response.Cookies.Add(cookie); this.Session["UserName"] = usersInfo.UserName; } if (SiteConfig.ShopConfig.IsPayPassword) { BasePage.ResponseRedirect("../User/RegisterPayPassword.aspx?Url=FastRegister"); } else { DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "../Shop/Payment.aspx"); } }
public PayOnlineState UpdateOrder(string paymentNum, decimal amount, string eBankInfo, int status, string remark, bool updateDeliverStatus, bool updateOrderStatus) { if (Convert.ToString(PEContext.Current.Context.Session["PaymentNum"]) != paymentNum) { PEContext.Current.Context.Session["PaymentNum"] = paymentNum; StringBuilder payOnlineMessage = new StringBuilder(0x40); paymentNum = DataSecurity.FilterBadChar(paymentNum); eBankInfo = DataSecurity.FilterBadChar(eBankInfo); remark = DataSecurity.FilterBadChar(remark); PayOnlineState state = this.UpdatePaymentLog(paymentNum, amount, eBankInfo, status, remark); if (state != PayOnlineState.Ok) { PEContext.Current.Context.Session["PaymentNum"] = ""; return(state); } if (!updateDeliverStatus) { PEContext.Current.Context.Session["PaymentNum"] = ""; return(PayOnlineState.Ok); } bool doUpdate = !BankrollItem.ExistsPaymentLog(this.m_PaymentLogId); if (!doUpdate) { PEContext.Current.Context.Session["PaymentNum"] = ""; return(PayOnlineState.AccountPaid); } bool isok = false; IEncourageStrategy <decimal> strategy = new UserMoney(); if (updateOrderStatus) { if (this.m_UserId > 0) { strategy.IncreaseForUsers(this.m_UserId.ToString(), this.m_MoneyReceipt, "", false, ""); } BankrollItemInfo bankrollItemInfo = new BankrollItemInfo(); bankrollItemInfo.UserName = this.m_UserName; bankrollItemInfo.ClientId = this.m_ClientID; bankrollItemInfo.Money = this.m_MoneyReceipt; bankrollItemInfo.MoneyType = 3; bankrollItemInfo.EBankId = this.m_PlatformId; bankrollItemInfo.OrderId = this.m_OrderInfo.OrderId; bankrollItemInfo.PaymentId = this.m_PaymentLogId; bankrollItemInfo.Remark = "在线支付单号:" + paymentNum; bankrollItemInfo.DateAndTime = new DateTime?(DateTime.Now); bankrollItemInfo.CurrencyType = 1; isok = BankrollItem.Add(bankrollItemInfo); } if (this.m_OrderInfo.IsNull) { if (this.m_Point > 0) { IEncourageStrategy <int> strategy2 = new UserPoint(); strategy2.IncreaseForUsers(this.m_UserId.ToString(), this.m_Point, "购买" + SiteConfig.UserConfig.PointName, true, ""); BankrollItemInfo info2 = new BankrollItemInfo(); info2.UserName = this.m_UserName; info2.ClientId = this.m_ClientID; info2.Money = (this.m_MoneyReceipt > 0M) ? (-1M * this.m_MoneyReceipt) : this.m_MoneyReceipt; info2.MoneyType = 4; info2.EBankId = 0; info2.OrderId = this.m_OrderInfo.OrderId; info2.PaymentId = 0; info2.Remark = "购买" + SiteConfig.UserConfig.PointName + ",购买数:" + this.m_Point.ToString() + SiteConfig.UserConfig.PointUnit; info2.DateAndTime = new DateTime?(DateTime.Now); info2.CurrencyType = 1; isok = BankrollItem.Add(info2); if (this.m_UserId > 0) { isok = strategy.IncreaseForUsers(this.m_UserId.ToString(), -(this.m_MoneyReceipt), "", false, "");//将decimal.op_UnaryNegation } } PEContext.Current.Context.Session["PaymentNum"] = ""; if (!isok) { return(PayOnlineState.Fail); } return(PayOnlineState.Ok); } if (updateDeliverStatus && ((this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt) <= this.m_MoneyReceipt)) { this.m_OrderInfo.EnableDownload = true; isok = Order.Update(this.m_OrderInfo); } if ((this.m_OrderInfo.MoneyReceipt < this.m_OrderInfo.MoneyTotal) && updateOrderStatus) { bool flag3 = false; if ((this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt) <= this.m_MoneyReceipt) { this.m_MoneyPayout = this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt; this.m_OrderInfo.MoneyReceipt = this.m_OrderInfo.MoneyTotal; flag3 = true; } else if (SiteConfig.ShopConfig.EnablePartPay) { this.m_MoneyPayout = this.m_MoneyReceipt; this.m_OrderInfo.MoneyReceipt += this.m_MoneyReceipt; flag3 = true; } if (flag3) { if (this.m_OrderInfo.Status <= OrderStatus.WaitForConfirm) { this.m_OrderInfo.Status = OrderStatus.Confirmed; } isok = Order.Update(this.m_OrderInfo); BankrollItemInfo info3 = new BankrollItemInfo(); info3.UserName = this.m_UserName; info3.ClientId = this.m_ClientID; info3.Money = (this.m_MoneyPayout > 0M) ? (-1M * this.m_MoneyPayout) : this.m_MoneyPayout; info3.MoneyType = 4; info3.EBankId = 0; info3.OrderId = this.m_OrderInfo.OrderId; info3.PaymentId = 0; info3.Remark = "支付订单费用,订单号:" + this.m_OrderInfo.OrderNum; info3.DateAndTime = new DateTime?(DateTime.Now); info3.CurrencyType = 1; isok = BankrollItem.Add(info3); if (this.m_UserId > 0) { isok = strategy.IncreaseForUsers(this.m_UserId.ToString(), -(this.m_MoneyPayout), "", false, "");//将decimal.op_UnaryNegation改为了- } payOnlineMessage.Append("同时已经为您的订单编号为 " + this.m_OrderInfo.OrderNum + " 的订单支付了 " + this.m_MoneyPayout.ToString("N2") + "元。<br />"); } else { payOnlineMessage.Append("您的支付金额小于订单金额,不能对订单进行支付,资金已经打入您的帐户中做为预付款。<br />"); updateDeliverStatus = false; } } if (updateDeliverStatus) { this.ShowCardInfo(payOnlineMessage, doUpdate, isok); } payOnlineMessage.Append("<a href='../User/Shop/ShowOrder.aspx?OrderId=" + this.m_OrderInfo.OrderId.ToString() + "'>点此查看订单信息</a>"); this.m_Message = payOnlineMessage.ToString(); PEContext.Current.Context.Session["PaymentNum"] = ""; if (!isok) { return(PayOnlineState.Fail); } } return(PayOnlineState.Ok); }
private void AddBankroll(int paymentLogId) { if (!BankrollItem.ExistsPaymentLog(paymentLogId)) { PaymentLogInfo paymentLogById = PaymentLog.GetPaymentLogById(paymentLogId); if (!paymentLogById.IsNull) { IEncourageStrategy <decimal> strategy = new UserMoney(); int userId = 0; UserInfo usersByUserName = new UserInfo(true); if (!string.IsNullOrEmpty(paymentLogById.UserName)) { usersByUserName = Users.GetUsersByUserName(paymentLogById.UserName); userId = usersByUserName.UserId; if (userId > 0) { strategy.IncreaseForUsers(userId.ToString(), paymentLogById.MoneyPay, "", false, ""); BankrollItemInfo bankrollItemInfo = new BankrollItemInfo(); bankrollItemInfo.UserName = paymentLogById.UserName; bankrollItemInfo.Money = paymentLogById.MoneyPay; bankrollItemInfo.MoneyType = 3; bankrollItemInfo.EBankId = paymentLogById.PlatformId; bankrollItemInfo.OrderId = paymentLogById.OrderId; bankrollItemInfo.PaymentId = paymentLogId; bankrollItemInfo.Remark = "在线支付单号:" + paymentLogById.PaymentNum; bankrollItemInfo.DateAndTime = DateTime.Now; bankrollItemInfo.CurrencyType = 1; bankrollItemInfo.ClientId = usersByUserName.ClientId; BankrollItem.Add(bankrollItemInfo); } } if (paymentLogById.OrderId > 0) { OrderInfo orderById = Order.GetOrderById(paymentLogById.OrderId); if (!orderById.IsNull) { decimal d = 0M; if (orderById.MoneyTotal > orderById.MoneyReceipt) { if ((orderById.MoneyTotal - orderById.MoneyReceipt) > paymentLogById.MoneyPay) { if (SiteConfig.ShopConfig.EnablePartPay) { d = paymentLogById.MoneyPay; orderById.MoneyReceipt += paymentLogById.MoneyPay; } } else { d = orderById.MoneyTotal - orderById.MoneyReceipt; orderById.MoneyReceipt = orderById.MoneyTotal; } orderById.Status = OrderStatus.Confirmed; Order.Update(orderById); } if (d > 0M) { strategy.IncreaseForUsers(userId.ToString(), -d, "", false, ""); BankrollItemInfo info5 = new BankrollItemInfo(); info5.UserName = usersByUserName.UserName; info5.ClientId = usersByUserName.ClientId; info5.Money = -d; info5.MoneyType = 4; info5.EBankId = 0; info5.OrderId = orderById.OrderId; info5.PaymentId = 0; info5.Remark = "支付订单费用,订单号:" + orderById.OrderNum; info5.DateAndTime = DateTime.Now; info5.CurrencyType = 1; BankrollItem.Add(info5); } } } else if (paymentLogById.Point > 0) { IEncourageStrategy <int> strategy2 = new UserPoint(); strategy2.IncreaseForUsers(userId.ToString(), paymentLogById.Point, "购买" + SiteConfig.UserConfig.PointName, true, ""); BankrollItemInfo info6 = new BankrollItemInfo(); info6.UserName = usersByUserName.UserName; info6.ClientId = usersByUserName.ClientId; info6.Money = (paymentLogById.MoneyPay > 0M) ? (-1M * paymentLogById.MoneyPay) : paymentLogById.MoneyPay; info6.MoneyType = 4; info6.EBankId = 0; info6.OrderId = 0; info6.PaymentId = 0; info6.Remark = "购买" + SiteConfig.UserConfig.PointName + ",购买数:" + paymentLogById.Point.ToString() + SiteConfig.UserConfig.PointUnit; info6.DateAndTime = new DateTime?(DateTime.Now); info6.CurrencyType = 1; BankrollItem.Add(info6); if (usersByUserName.UserId > 0) { strategy.IncreaseForUsers(usersByUserName.UserId.ToString(), -(paymentLogById.MoneyPay), "", false, ""); } } } } }