Ejemplo n.º 1
0
 /// <summary>
 /// 账号扣费,返费
 /// </summary>
 /// <param name="accountID">扣费账号</param>
 /// <param name="quantity">扣费数 可以为负</param>
 /// <returns></returns>
 public RPCResult AccountDeductSMSCount(string accountID, int quantity)
 {
     try
     {
         if (string.IsNullOrEmpty(accountID))
         {
             LogHelper.LogWarn("SMSService", "SMSService.AccountDeductSMSCharge", "账号为空");
             return(new RPCResult(false, "扣费账号不能为空!"));
         }
         Account account = AccountDB.GetAccount(accountID);// AccountServer.Instance.GetAccount(accountID);
         if (account == null)
         {
             LogHelper.LogWarn("SMSService", "SMSService.AccountDeductSMSCharge", "账号不存在");
             return(new RPCResult(false, "账号不存在"));
         }
         if (AccountDB.DeductAccountSMSCharge(account.AccountID, (int)quantity))
         {
             return(new RPCResult(true, ""));
         }
         LogHelper.LogWarn("SMSService", "SMSService.AccountDeductSMSCharge", "扣费数据库操作失败");
         return(new RPCResult(false, "扣费失败"));
     }
     catch (Exception ex)
     {
         LogHelper.LogError("SMSService", "SMSService.AccountDeductSMSCharge", ex.ToString());
         return(new RPCResult(false, "扣费失败"));
     }
 }
Ejemplo n.º 2
0
        public void AccountTest()
        {
            Account account = new Account()
            {
                AccountID = guid.ToString(),
                SMSNumber = 10
            };
            var b = AccountDB.CreateAccount(account);

            Assert.IsTrue(b);
            b = AccountDB.AccountPrepaid(account.AccountID, 10);
            Assert.IsTrue(b);
            int c = AccountDB.GetSMSNumberByAccount(account.AccountID);

            Assert.AreEqual(20, c);
            var a = AccountDB.GetAccount(account.AccountID);

            Assert.IsNotNull(a);
            Assert.AreEqual(a.AccountID, account.AccountID);
            Assert.AreEqual(a.SMSNumber, 20);

            b = AccountDB.DeductAccountSMSCharge(account.AccountID, 10);
            Assert.IsTrue(b);
            c = AccountDB.GetSMSNumberByAccount(account.AccountID);
            Assert.AreEqual(10, c);
            b = AccountDB.ReAccountSMSCharge(account.AccountID, 10);
            Assert.IsTrue(b);

            c = AccountDB.GetSMSNumberByAccount(account.AccountID);
            Assert.AreEqual(20, c);

            var accs = AccountDB.GetAccounts();

            Assert.IsNotNull(accs);
            Assert.IsTrue(accs.Count > 0);
            b = AccountDB.DelAccount(account.AccountID);
            Assert.IsTrue(b);
        }