Пример #1
0
 private bool DoTransfer(int userId, decimal amount, out int transferId)
 {
     transferId = 0;
     if (this._payType == PayType.金币支付)
     {
         UserPurse goldCoinPurse = PurseFactory.UserGoldCoinPurse(userId);
         UserPurse storePurse    = PurseFactory.StoreIncomePurse(AppConfig.GpuStoreId);
         Currency  currency      = new Currency(CurrencyType.RMB, amount);
         BeginTransaction();
         Transfer transfer = new Transfer();
         transfer.ReferenceTransactionFrom(Transaction);
         if (!transfer.DoTransfer(goldCoinPurse, storePurse, currency, (int)TransferReason.升级VIP, "金币升级VIP"))
         {
             Rollback();
             Alert(transfer.PromptInfo);
             return(false);
         }
         Commit();
         transferId = transfer.TransferId;
         return(true);
     }
     else if (this._payType == PayType.现金支付)
     {
         Alert("不支持的支付方式");
         return(false);
     }
     return(true);
 }
Пример #2
0
        private static AccountInfo GetGoldCoinAccount(int userId)
        {
            UserPurse   goldCoinPurse  = PurseFactory.UserGoldCoinPurse(userId);
            var         freezeCurrency = new Currency(goldCoinPurse.CurrencyType, goldCoinPurse.FreezeValue);
            AccountInfo account        = new AccountInfo();

            account.PurseName   = "金币";
            account.PurseType   = (int)eBankAccountType.金币;
            account.Balance     = goldCoinPurse.UsableCurrency.ConvertTo(CurrencyType.RMB, 2).Amount;
            account.FreezeValue = freezeCurrency.ConvertTo(CurrencyType.RMB, 2).Amount;
            return(account);
        }
Пример #3
0
        private bool RechargeGoldCoin(int userId, Currency currency, string remarks, out int transferId)
        {
            UserPurse goldCoinPurse = PurseFactory.UserGoldCoinPurse(userId);
            UserPurse centerBank    = PurseFactory.CenterBankPurse();

            BeginTransaction();
            Transfer transfer = new Transfer();

            transfer.ReferenceTransactionFrom(Transaction);
            if (!transfer.DoTransfer(centerBank, goldCoinPurse, currency, (int)TransferReason.充值金币, remarks))
            {
                Rollback();
                Alert(transfer.PromptInfo);
                transferId = -1;
                return(false);
            }
            transferId = transfer.TransferId;
            Commit();
            return(true);
        }
Пример #4
0
        private bool DoTransfer(int userId, decimal amount, out int transferId)
        {
            UserPurse goldPurse = PurseFactory.UserGoldCoinPurse(userId);
            UserPurse outPurse  = PurseFactory.SystemWelfarePurse();
            Currency  currency  = new Currency(CurrencyType.RMB, amount);

            BeginTransaction();
            Transfer transfer = new Transfer();

            transfer.ReferenceTransactionFrom(Transaction);
            if (!transfer.DoTransfer(outPurse, goldPurse, currency, (int)TransferReason.VIP金币奖励, "VIP金币奖励"))
            {
                Rollback();
                Alert(transfer.PromptInfo);
                transferId = -1;
                return(false);
            }
            Commit();
            transferId = transfer.TransferId;
            return(true);
        }
Пример #5
0
 public override void Init(String baseUrl)
 {
     Goods.Initialize("goods.xml");
     CoffeMachinePurse.Initialize("coffee.xml");
     UserPurse.Initialize("user.xml");
 }
Пример #6
0
 public override void Save(String baseUrl)
 {
     Goods.Save("goods.xml");
     CoffeMachinePurse.Save("coffee.xml");
     UserPurse.Save("user.xml");
 }