Exemplo n.º 1
0
        private bool Paid(YCTItem item, YCTWallet w, CardPaymentInfo paid, out int balance)
        {
            balance = 0;
            YCTPaymentInfo payment = item.Reader.Prepaid((int)(paid.GetPaying() * 100), w.WalletType, Setting.MaxOfflineMonth);

            if (payment == null)
            {
                return(false);
            }
            //这里应该保存记录,保存记录成功然后再进行下一步
            YCTPaymentRecord record = CreateRecord(payment);

            record.WalletType    = w.WalletType;
            record.EnterDateTime = paid.EnterDateTime.Value;
            record.State         = YCTPaymentRecordState.PaidFail;
            YCTPaymentRecordBll bll    = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect);
            CommandResult       result = bll.Insert(record);

            if (result.Result != ResultCode.Successful)
            {
                return(false);
            }

            string tac = item.Reader.CompletePaid();

            if (string.IsNullOrEmpty(tac))
            {
                int err = item.Reader.LastError;
                //if (err == 0x01) bll.Delete(record); //失败 删除记录
                return(false);
            }
            YCTPaymentRecord newVal = record.Clone();

            if (w.WalletType == 0x02)
            {
                newVal.TAC = tac;                        //cpu钱包将TAC写到记录中
            }
            newVal.State = YCTPaymentRecordState.PaidOk; //标记为完成
            result       = bll.Update(newVal, record);
            balance      = record.BAL;                   //返回余额
            if (w.WalletType == 2)
            {
                balance -= w.MinBalance;                    //CPU钱包可用余额为余额减去最小余额
            }
            return(result.Result == ResultCode.Successful);
        }
Exemplo n.º 2
0
 private void YCTPayment_Thread()
 {
     try
     {
         while (true)
         {
             if (Reader != null)
             {
                 var w = Reader.ReadCard();
                 if (w != null && w.WalletType != 0)
                 {
                     int p = (int)(Payment * 100);
                     if (w.Balance >= p)
                     {
                         var payment = Reader.Paid(p, w.WalletType);
                         if (payment != null)
                         {
                             YCTPaymentRecord record = CreateRecord(payment);
                             record.WalletType    = w.WalletType;
                             record.EnterDateTime = DateTime.Now;
                             record.State         = YCTPaymentRecordState.PaidOk;
                             YCTPaymentRecordBll bll    = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect);
                             CommandResult       result = bll.Insert(record);
                             string msg = string.Format("扣款{0}元  余额{1}元", Payment, (decimal)payment.本次余额 / 100);
                             ShowMessage(msg);
                             if (AppSettings.CurrentSetting.EnableTTS)
                             {
                                 Ralid.GeneralLibrary.Speech.TTSSpeech.Instance.Speek(msg);
                             }
                             if (ChargeLed != null)
                             {
                                 ChargeLed.DisplayMsg(msg);
                             }
                             this.DialogResult = DialogResult.OK;
                             break;
                         }
                         else
                         {
                             ShowMessage(Resources.Resource1.FrmYCTPayment_Fail + "  原因:" + Reader.LastErrorDescr);
                             if (AppSettings.CurrentSetting.EnableTTS)
                             {
                                 Ralid.GeneralLibrary.Speech.TTSSpeech.Instance.Speek(Resources.Resource1.FrmYCTPayment_Fail);
                             }
                         }
                     }
                     else
                     {
                         ShowMessage(Resources.Resource1.FrmYCTPayment_BalanceNotEnough);
                         if (AppSettings.CurrentSetting.EnableTTS)
                         {
                             Ralid.GeneralLibrary.Speech.TTSSpeech.Instance.Speek(Resources.Resource1.FrmYCTPayment_BalanceNotEnough);
                         }
                     }
                 }
             }
         }
     }
     catch (ThreadAbortException)
     {
     }
 }