예제 #1
0
        public static void RecordLastTransaction(XDCMessage msgContent, int changeAmount)
        {
            string availableBanlance = XDCUnity.ReadIniData(msgContent.PAN, "AvailableBalance", string.Empty, XDCUnity.UserInfoPath);

            if (string.IsNullOrEmpty(availableBanlance))
            {
                LogHelper.LogError("XDCUnity", "RecordLastTransaction Error.maybe your card is not accept by XDC-Host");
                return;
            }
            double newBalance = double.Parse(availableBanlance);

            newBalance += changeAmount;
            XDCUnity.WriteIniData(msgContent.PAN, "AvailableBalance", newBalance.ToString(), XDCUnity.UserInfoPath);

            //记录账号
            XDCUnity.WriteIniData("LastTransactionNotesDispensed", "Pan", msgContent.PAN, XDCUnity.UserInfoPath);
            //记录金额
            XDCUnity.WriteIniData("LastTransactionNotesDispensed", "Amount", changeAmount.ToString(), XDCUnity.UserInfoPath);

            //记录序列号
            string TSN    = XDCUnity.ReadIniData("LastTransactionNotesDispensed", "LastTransactionSerialNumber", "", XDCUnity.UserInfoPath);
            string newTSN = (int.Parse(TSN) + 1).ToString();

            XDCUnity.WriteIniData("LastTransactionNotesDispensed", "LastTransactionSerialNumber", newTSN.ToString(), XDCUnity.UserInfoPath);
        }
예제 #2
0
        public static void DoReversal()
        {
            //1.取出上次交易的金额
            int    lastAmount    = 0;
            string lastAmountStr = XDCUnity.ReadIniData("LastTransactionNotesDispensed", "Amount", "", XDCUnity.UserInfoPath);

            int.TryParse(lastAmountStr, out lastAmount);

            //2,取出账号
            string Account = XDCUnity.ReadIniData("LastTransactionNotesDispensed", "Pan", "", XDCUnity.UserInfoPath);

            //3.取出用户当前余额
            string AmountStr = XDCUnity.ReadIniData(Account, "AvailableBalance", "", XDCUnity.UserInfoPath);

            //4.计算充正后的余额
            int baseAmount = 0;

            int.TryParse(AmountStr, out baseAmount);

            //5.写入用户数据
            XDCUnity.WriteIniData(Account, "AvailableBalance", (-lastAmount + baseAmount).ToString(), XDCUnity.UserInfoPath);
        }