public int AddBlance(int shopUserId, decimal amount) { if (amount <= 0) { return 0; } try { ShopSearchEntity sse = new ShopSearchEntity("Accounts_UsersExp"); sse["UserID"] = shopUserId; sse.AddSearch("Balance"); var uexp = sse.LoadEntity<Shop_Accounts_UsersExp>(); using (var scope = new TransactionScope()) { #region 更新余额 var balance = uexp.Balance + amount; uexp["UserID"] = shopUserId; uexp.Balance = balance; uexp.Save(); #endregion #region 添加充值记录 Shop_Pay_BalanceDetails detail = new Shop_Pay_BalanceDetails(); detail.UserId = shopUserId; detail.TradeDate = DateTime.Now; detail.TradeType = 1; detail.Income = amount; detail.Balance = balance; detail.Remark = "线下充值"; detail.Save(); #endregion scope.Complete(); } } catch { return 0; } return 1; }
public int Pay(int bid) { try { int shopUserId = 0; decimal balance = 0; string phoneNum = null; decimal cost = 0; var isMoneyEnough = WebSite.Controllers.MemberController.IsMoneyEnouth(bid, out balance, out shopUserId, out phoneNum, out cost); if (isMoneyEnough == -1)//余额不足 { return -1; } else if (isMoneyEnough == 0)//检查失败 { return 0; } using (var scope = new TransactionScope()) { var updateBRoom = new HQ_BookRoom(); updateBRoom["id"] = bid; updateBRoom.OStatus = 3; updateBRoom.LastOperateTime = DateTime.Now; updateBRoom.Save(); #region 更改余额 Shop_Accounts_UsersExp uexp = new Shop_Accounts_UsersExp(); uexp["UserID"] = shopUserId; uexp["Balance"] = balance; uexp.Save(); #endregion #region 记录扣款记录 Shop_Pay_BalanceDetails detail = new Shop_Pay_BalanceDetails(); detail.UserId = shopUserId; detail.TradeDate = DateTime.Now; detail.TradeType = 2; detail.Expenses = cost; detail.Balance = balance; detail.Remark = "订房扣款"; detail.Save(); #endregion scope.Complete(); } try { if (balance < 500) { NM.Util.SendUserInfo _U = new NM.Util.SendUserInfo() { isLog = 1, orgid = 555, username = phoneNum }; NM.Util.MsgSend.DirectSend("尊敬的会员您好,您的账户余额已不足500元,为不影响您度假旅行,请及时充值。", phoneNum, _U); } } catch { } return 1; } catch { return 0; } }