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); }
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); }
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); }
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); }