Beispiel #1
0
        /// <summary>
        /// 处理未完成交易记录
        /// </summary>
        /// <param name="item"></param>
        /// <param name="w"></param>
        /// <param name="record"></param>
        private bool HandleUnFinishedPayment(YCTItem item, YCTWallet w, YCTPaymentRecord record, OpenCardEventArgs args)
        {
            string tac = item.Reader.RestorePaid(record.LCN, record.FCN, record.XRN, record.FEE, record.BAL);

            if (string.IsNullOrEmpty(tac))
            {
                //处理失败
                int err = item.Reader.LastError;
                if (err == 0xC2)//返回无对应的记录
                {
                    //无对应交易记录 删除记录
                    (new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect)).Delete(record);
                    return(true);
                }
                return(false);
            }

            //处理成功,生成保存上一次的收费记录
            args.ChargeDateTime = record.TIM;
            if (this.OnPaying != null)
            {
                this.OnPaying(this, args);                        //产生上一次的收费事件
            }
            if (args.Payment == null)
            {
                return(false);
            }
            args.UnFinishedPayment = args.Payment;                            //设置上次未完成的收费信息
            args.Payment           = null;                                    //重置收费记录
            args.ChargeDateTime    = null;                                    //重置计费时间

            args.UnFinishedPayment.Paid        = record.TF * 1.00M / 100.00M; //设置实收费用,羊城通记录里的交易金额是分为单位的,所以这里需要转换成元
            args.UnFinishedPayment.PaymentCode = Ralid.Park.BusinessModel.Enum.PaymentCode.Computer;
            args.UnFinishedPayment.PaymentMode = Ralid.Park.BusinessModel.Enum.PaymentMode.YangChengTong;

            //更新未完整交易记录
            YCTPaymentRecord newVal = record.Clone();

            if (record.WalletType == 0x02)
            {
                newVal.TAC = tac;                        //cpu钱包将TAC写到记录中
            }
            newVal.State = YCTPaymentRecordState.PaidOk; //标记为完成
            YCTPaymentRecordBll bll    = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect);
            CommandResult       result = bll.Update(newVal, record);

            return(result.Result == ResultCode.Successful);
        }
Beispiel #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            YCTPaymentRecordSearchCondition con = new YCTPaymentRecordSearchCondition();

            con.PaymentDateTimeRange = new DateTimeRange(UCChargeDateTime.StartDateTime, UCChargeDateTime.EndDateTime);
            con.LCN = txtCardID.Text;
            if (!string.IsNullOrEmpty(cmbWalletType.Text))
            {
                con.WalletType = cmbWalletType.SelectedIndex;
            }
            if (!string.IsNullOrEmpty(cmbState.Text))
            {
                if (cmbState.Text == "支付成功")
                {
                    con.State = (int)YCTPaymentRecordState.PaidOk;
                }
                else if (cmbState.Text == "服务器已接收")
                {
                    con.State = (int)YCTPaymentRecordState.ServiceAccepted;
                }
                else if (cmbState.Text == "服务器拒绝")
                {
                    con.State = (int)YCTPaymentRecordState.ServiceDenied;
                }
                else if (cmbState.Text == "支付失败")
                {
                    con.State = (int)YCTPaymentRecordState.PaidFail;
                }
            }
            if (chkUnupload.Checked)
            {
                con.UnUploaded = true;
            }
            List <YCTPaymentRecord> records = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects;

            if (records != null && records.Count > 0)
            {
                foreach (var record in records)
                {
                    int row = dataGridView1.Rows.Add();
                    ShowItemOnRow(dataGridView1.Rows[row], record);
                }
            }
            lblMsg.Text = string.Format("共有 {0} 项", records != null ? records.Count : 0);
        }
Beispiel #3
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);
        }
Beispiel #4
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)
     {
     }
 }
Beispiel #5
0
        private void SyncUploadFiles(FtpClient ftp, YCTSetting yct)
        {
            //DateTime dt = DateTime.Now;
            DateTime dt     = DateTime.Today.AddMilliseconds(-1);
            string   m1Zip  = string.Format("XF{0}{1}{2}.ZIP", yct.ServiceCode.ToString().PadLeft(4, '0'), yct.ReaderCode.ToString().PadLeft(4, '0'), dt.ToString("yyyyMMdd"));
            string   cpuZip = string.Format("CX{0}{1}{2}.ZIP", yct.ServiceCode.ToString().PadLeft(4, '0'), yct.ReaderCode.ToString().PadLeft(4, '0'), dt.ToString("yyyyMMddHH"));

            InsertMsg("定位到: " + _WriteFolder);
            ftp.SetWorkingDirectory(_WriteFolder);
            var items = ftp.GetListing(_WriteFolder, FtpListOption.NoPath);

            if (items == null && items.Length == 0 || items.Count(it => it.Name == m1Zip) == 0)
            {
                YCTPaymentRecordSearchCondition con = new YCTPaymentRecordSearchCondition() //获取所有钱包类型为M1钱包且未上传的记录
                {
                    WalletType           = 1,
                    State                = (int)YCTPaymentRecordState.PaidOk,
                    UnUploaded           = true,
                    PaymentDateTimeRange = new DateTimeRange(new DateTime(2010, 1, 1), dt)
                };
                List <YCTPaymentRecord> records = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects;
                if (records != null && records.Count > 0)
                {
                    YCTBlacklistSearchCondition ycon = new YCTBlacklistSearchCondition();
                    ycon.WalletType     = 1; //M
                    ycon.OnlyCatched    = true;
                    ycon.OnlyUnUploaded = true;
                    List <YCTBlacklist> blacks = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(ycon).QueryObjects;
                    string zip = YCTUploadFileFactory.CreateM1UploadFile(dt, m1Zip, records, blacks);
                    if (!string.IsNullOrEmpty(zip))
                    {
                        InsertMsg("上传文件" + m1Zip);
                        using (FileStream fs = new FileStream(zip, FileMode.Open, FileAccess.Read))
                        {
                            ftp.Upload(m1Zip, fs);
                            new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(records, m1Zip);
                            if (blacks != null && blacks.Count > 0)
                            {
                                new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(blacks, m1Zip);
                            }
                        }
                    }
                }
            }

            if (items == null && items.Length == 0 || items.Count(it => it.Name == cpuZip) == 0)
            {
                YCTPaymentRecordSearchCondition con = new YCTPaymentRecordSearchCondition() //获取所有钱包类型为CPU钱包且未上传的记录
                {
                    WalletType           = 2,
                    State                = (int)YCTPaymentRecordState.PaidOk,
                    UnUploaded           = true,
                    PaymentDateTimeRange = new DateTimeRange(new DateTime(2010, 1, 1), dt)
                };
                List <YCTPaymentRecord> records = new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(con).QueryObjects;
                if (records != null && records.Count > 0)
                {
                    YCTBlacklistSearchCondition ycon = new YCTBlacklistSearchCondition();
                    ycon.WalletType     = 2; //cpu
                    ycon.OnlyCatched    = true;
                    ycon.OnlyUnUploaded = true;
                    List <YCTBlacklist> blacks = new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).GetItems(ycon).QueryObjects;
                    string zip = YCTUploadFileFactory.CreateCPUUploadFile(dt, cpuZip, records, blacks);
                    if (!string.IsNullOrEmpty(zip))
                    {
                        InsertMsg("上传文件" + cpuZip);
                        using (FileStream fs = new FileStream(zip, FileMode.Open, FileAccess.Read))
                        {
                            ftp.Upload(cpuZip, fs);
                            new YCTPaymentRecordBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(records, cpuZip);
                            if (blacks != null && blacks.Count > 0)
                            {
                                new YCTBlacklistBll(AppSettings.CurrentSetting.MasterParkConnect).BatchChangeUploadFile(blacks, cpuZip);
                            }
                        }
                    }
                }
            }
        }