Пример #1
0
        private bool FillLatestAFCStationCodeList()
        {
            bool isSuccess = false;

            try
            {
                using (MobilePayDBEntities dbContext = new MobilePayDBEntities())
                {
                    _latestAFCStationCodeList = dbContext.AFCStationCodes.Where(s => s.RecordFlag.Equals("0")).ToList();

                    if (0 < _latestAFCStationCodeList.Count)
                    {
                        isSuccess = true;
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
                if (null != ex.InnerException)
                {
                    _log.Error(ex.InnerException.Message);
                }
            }

            return(isSuccess);
        }
Пример #2
0
        public bool UnlockAllVoucher()
        {
            bool isSuccess = false;

            try
            {
                using (MobilePayDBEntities dbContext = new MobilePayDBEntities())
                {
                    var lockedVouchers = dbContext.VoucherLists.Where(v => v.IsLocked.Equals(true));
                    foreach (VoucherList eachVoucher in lockedVouchers)
                    {
                        eachVoucher.IsLocked = false;
                    }

                    dbContext.SaveChanges();

                    isSuccess = true;
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
                if (null != ex.InnerException)
                {
                    _log.Error(ex.InnerException.Message);
                }
            }

            return(isSuccess);
        }
Пример #3
0
        /// <summary>
        /// 返回最新票价
        /// </summary>
        /// <returns></returns>
        public List <ODTicketPriceVo> GetLatestODTicketPriceList()
        {
            List <ODTicketPriceVo> ODTicketPriceList = new List <ODTicketPriceVo>();

            try
            {
                using (MobilePayDBEntities dbContext = new MobilePayDBEntities())
                {
                    List <TicketPrice> latestTicketPriceList = dbContext.TicketPrices.Where(p => p.RecordFlag.Equals("0")).ToList();

                    foreach (TicketPrice eachTicketPrice in latestTicketPriceList)
                    {
                        ODTicketPriceVo newODTicketPriceVo = new ODTicketPriceVo()
                        {
                            OriLineId             = eachTicketPrice.BeginLineId,
                            DesLineId             = eachTicketPrice.EndLineId,
                            OriLineChineseName    = eachTicketPrice.BeginLineChineseName,
                            DesLineChineseName    = eachTicketPrice.EndLineChineseName,
                            OriLineEnglishName    = eachTicketPrice.BeginLineEnglishName,
                            DesLineEnglishName    = eachTicketPrice.EndLineEnglishName,
                            OriStationCode        = eachTicketPrice.BeginStationCode,
                            DesStationCode        = eachTicketPrice.EndStationCode,
                            OriStationChineseName = eachTicketPrice.BeginStationChineseName,
                            DesStationChineseName = eachTicketPrice.EndStationChineseName,
                            OriStationEnglishName = eachTicketPrice.BeginStationEnglishName,
                            DesStationEnglishName = eachTicketPrice.EndStationEnglishName,
                            PriceCent             = (int)eachTicketPrice.FareCent
                        };

                        ODTicketPriceList.Add(newODTicketPriceVo);
                    }
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
                if (null != ex.InnerException)
                {
                    _log.Error(ex.InnerException.Message);
                }
            }

            return(ODTicketPriceList);
        }
Пример #4
0
        /// <summary>
        /// 填充已取票车站订单
        /// </summary>
        /// <param name="orderCount"></param>
        /// <param name="ticketTarget"></param>
        /// <returns></returns>
        public int FillCompleteedStationOrder(int orderCount)
        {
            int resultCount = 0;

            string stationOrderNo     = String.Empty;
            string strCityCode        = "020";
            string strDeviceId        = "WebLocalTest";
            string stationChannelType = "04";
            string inputPaymentCode   = "130481063942121998";

            try
            {
                //VoucherBo vb = new VoucherBo();
                //vb.FillNewVoucher(orderCount, DateTime.Now, DateTime.Now.AddYears(1));

                StationOrderBo sbo = new StationOrderBo();

                using (MobilePayDBEntities dbContext = new MobilePayDBEntities())
                {
                    for (int orderIndex = 1; orderIndex <= orderCount; orderIndex++)
                    {
                        //#region 现场车站购票(付款)订单提交

                        //StationOrderPayRequestVo newStationOrderPayRequestVo = new StationOrderPayRequestVo()
                        //{
                        //    ReqSysDateString = DateTime.Now.ToString("yyyyMMddHHmmss"),
                        //    operationCode = "S1-001",
                        //    cityCode = strCityCode,
                        //    DeviceId = strDeviceId,
                        //    channelType = stationChannelType,
                        //    expandAttribute = new List<string>(),
                        //    paymentCode = inputPaymentCode,
                        //    msisdn = String.Empty,
                        //    iccid = String.Empty,
                        //    serviceId = String.Empty,
                        //    paymentVendor = "1002",
                        //    pickupStationCode = "0101",
                        //    getOffStationCode = "0102",
                        //    singlelTicketPrice = 200,
                        //    singlelTicketNum = 2,
                        //    singleTicketType = "0"
                        //};
                        ////Console.WriteLine("StationOrderPayRespondVo");
                        //StationOrderPayRespondVo stationOrderPayRespondVo = sbo.OrderPay(newStationOrderPayRequestVo);
                        ////Console.WriteLine(stationOrderPayRespondVo.RespondCodeString);
                        ////Console.WriteLine(stationOrderPayRespondVo.partnerNo);
                        ////Console.WriteLine(stationOrderPayRespondVo.orderNo);
                        ////Console.WriteLine(stationOrderPayRespondVo.subject);
                        ////Console.WriteLine(stationOrderPayRespondVo.body);
                        ////Console.WriteLine(stationOrderPayRespondVo.payType);
                        ////Console.WriteLine(stationOrderPayRespondVo.amount);
                        ////Console.WriteLine(stationOrderPayRespondVo.account);
                        ////Console.WriteLine(stationOrderPayRespondVo.notifyUrl);
                        ////Console.WriteLine(stationOrderPayRespondVo.merchantCert);
                        ////Console.WriteLine(stationOrderPayRespondVo.timeout);
                        //stationOrderNo = stationOrderPayRespondVo.orderNo;
                        //#endregion 现场车站购票(付款)订单提交


                        //#region 现场车站购票支付结果查询
                        //StationOrderPayResultRequestVo newStationOrderPayResultRequestVo = new StationOrderPayResultRequestVo()
                        //{
                        //    ReqSysDateString = DateTime.Now.ToString("yyyyMMddHHmmss"),
                        //    operationCode = "S1-002",
                        //    cityCode = strCityCode,
                        //    DeviceId = strDeviceId,
                        //    channelType = stationChannelType,
                        //    expandAttribute = new List<string>(),
                        //    orderNo = stationOrderNo
                        //};
                        ////Console.WriteLine("StationOrderPayResultRespondVo");
                        //StationOrderPayResultRespondVo stationOrderPayResultRespondVo = sbo.PayResultQuery(newStationOrderPayResultRequestVo);
                        ////Console.WriteLine(stationOrderPayResultRespondVo.RespondCodeString);
                        ////Console.WriteLine(stationOrderPayResultRespondVo.paymentDateString);
                        ////Console.WriteLine(stationOrderPayResultRespondVo.amount);
                        ////Console.WriteLine(stationOrderPayResultRespondVo.paymentAccount);
                        ////Console.WriteLine(stationOrderPayResultRespondVo.paymentResult);
                        ////Console.WriteLine(stationOrderPayResultRespondVo.paymentDesc);
                        //#endregion 现场车站购票支付结果查询

                        //#region 车站订单开始执行通知
                        //StationOrderProcessRequestVo newStationOrderProcessRequestVo = new StationOrderProcessRequestVo()
                        //{
                        //    ReqSysDateString = DateTime.Now.ToString("yyyyMMddHHmmss"),
                        //    operationCode = "S1-003",
                        //    cityCode = strCityCode,
                        //    DeviceId = strDeviceId,
                        //    channelType = stationChannelType,
                        //    expandAttribute = null,
                        //    orderNo = stationOrderNo
                        //};

                        ////Console.WriteLine("WebOrderProcessRespondVo");
                        //StationOrderProcessRespondVo stationOrderProcessRespondVo = sbo.StationOrderProcess(newStationOrderProcessRequestVo);
                        ////Console.WriteLine(stationOrderProcessRespondVo.RespondCodeString);
                        ////Console.WriteLine(stationOrderProcessRespondVo.respCodeMemo);
                        //#endregion 车站订单开始执行通知

                        //#region 车站订单执行结果通知
                        //StationOrderTakenRequestVo newStationOrderTakenRequestVo = new StationOrderTakenRequestVo()
                        //{
                        //    ReqSysDateString = DateTime.Now.ToString("yyyyMMddHHmmss"),
                        //    operationCode = "S1-004",
                        //    cityCode = strCityCode,
                        //    DeviceId = strDeviceId,
                        //    channelType = stationChannelType,
                        //    expandAttribute = null,
                        //    orderNo = stationOrderNo,
                        //    takeSingleTicketNum = 1.ToString(),
                        //    takeSingleTicketDateString = DateTime.Now.ToString("yyyyMMddHHmmss")
                        //};
                        ////Console.WriteLine("WebOrderTakenRespondVo");
                        //StationOrderTakenRespondVo stationOrderTakenRespondVo = sbo.StationOrderTaken(newStationOrderTakenRequestVo);
                        ////Console.WriteLine(stationOrderTakenRespondVo.RespondCodeString);
                        ////Console.WriteLine(stationOrderTakenRespondVo.respCodeMemo);
                        //#endregion 车站订单执行结果通知

                        StationOrder newStationOrder = new StationOrder();
                        newStationOrder.StationOrderId = Guid.NewGuid();
                        newStationOrder.TradeNo        = String.Format("S{0}", TradeNoHelper.Instance.GetTradeNo());
                        newStationOrder.BuyTime        = DateTime.Now;

                        newStationOrder.OperationCode = String.Empty;
                        newStationOrder.CityCode      = "020";
                        newStationOrder.DeviceId      = "DeviceId";
                        newStationOrder.ChannelType   = "04";
                        newStationOrder.PaymentVendor = "1002";
                        newStationOrder.PaymentCode   = "130481063942121998";

                        newStationOrder.OriAFCStationCode = "0101";
                        newStationOrder.DesAFCStationCode = "0102";
                        newStationOrder.TicketPrice       = 100;
                        newStationOrder.TicketNum         = 1;
                        newStationOrder.SingleTicketType  = "0";
                        newStationOrder.Discount          = 1;
                        newStationOrder.Amount            = newStationOrder.TicketPrice * newStationOrder.TicketNum;
                        newStationOrder.TransactionId     = Guid.NewGuid().ToString();
                        newStationOrder.PayEndTime        = DateTime.Now;
                        newStationOrder.PayEndTimeRaw     = TimeHelper.GetTimeStringYyyyMMddHHmmss(DateTime.Now);
                        newStationOrder.ActualFee         = newStationOrder.Amount;
                        newStationOrder.BankType          = "TestBankType";
                        newStationOrder.UserAccount       = "UserAccount";
                        newStationOrder.UserOpenId        = "UserOpenId";

                        newStationOrder.Step           = EnumHelper.GetStationOrderStepFlagString(StationOrderStep.StationOrderTakenRespond);
                        newStationOrder.OrderStatus    = EnumHelper.GetOrderStatusTypeFlagString(OrderStatusType.TicketOut);
                        newStationOrder.IsValid        = true;
                        newStationOrder.TicketTakeNum  = newStationOrder.TicketNum;
                        newStationOrder.TicketTakeTime = DateTime.Now;
                        dbContext.StationOrders.AddObject(newStationOrder);

                        resultCount++;
                        _log.Debug(resultCount);
                    }

                    dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }

            return(resultCount);
        }
Пример #5
0
        /// <summary>
        /// 生成可用取票凭证
        /// </summary>
        /// <param name="fillCount">范围为1到1,000,000</param>
        /// <param name="effectiveTime"></param>
        /// <param name="expiredTime"></param>
        /// <returns></returns>
        public int FillNewVoucher(int fillCount, DateTime effectiveTime, DateTime expiredTime)
        {
            string strLog = String.Format("Generate new voucher:{0}, from {1} to {2}"
                                          , fillCount
                                          , TimeHelper.GetTimeStringYyyyMMddHHmmss(effectiveTime)
                                          , TimeHelper.GetTimeStringYyyyMMddHHmmss(expiredTime));

            _log.Info(strLog);

            if ((fillCount < 1) ||
                (fillCount > 1000000))
            {
                throw new ArgumentOutOfRangeException("fillCount");
            }
            if (0 < effectiveTime.CompareTo(expiredTime))
            {
                throw new ArgumentException("expiredTime must larger then effectiveTime");
            }

            Stopwatch sw = new Stopwatch();

            sw.Start();

            int filledCount = 0;


            try
            {
                VoucherHelper voucherHelper = new VoucherHelper();
                // 为免重复生成双倍随机数
                int doublefillCount = fillCount * 2;
                // 不重复随机数
                List <string> noRepeatRandomNumList = voucherHelper.GetNoRepeatRandomNumList(doublefillCount, Constants.VoucherLength);
                // 已有随机数字典
                Dictionary <string, string> dictExistVoucherCode = new Dictionary <string, string>();
                // 需添加的新随机数列表,与已有随机数不重复
                List <VoucherList> toAddVoucherList = new List <VoucherList>();
                using (MobilePayDBEntities dbContext = new MobilePayDBEntities())
                {
                    // 填充 已有随机数字典
                    foreach (VoucherList eachVoucher in dbContext.VoucherLists.ToList())
                    {
                        string eachExistVoucherCode = eachVoucher.VoucherCode;
                        dictExistVoucherCode.Add(eachExistVoucherCode, eachExistVoucherCode);
                    }

                    // 填充 需添加的新随机数列表
                    int newVoucherCodeCount = 0;
                    foreach (string eachNewVoucherCode in noRepeatRandomNumList)
                    {
                        if (!dictExistVoucherCode.ContainsKey(eachNewVoucherCode))
                        {
                            VoucherList newVoucherList = new VoucherList();
                            newVoucherList.VoucherId     = Guid.NewGuid();
                            newVoucherList.VoucherCode   = eachNewVoucherCode;
                            newVoucherList.EffectiveTime = effectiveTime;
                            newVoucherList.ExpiredTime   = expiredTime;
                            newVoucherList.IsValid       = true;
                            newVoucherList.IsUsed        = false;
                            newVoucherList.IsLocked      = false;

                            toAddVoucherList.Add(newVoucherList);

                            newVoucherCodeCount++;
                            if (fillCount <= newVoucherCodeCount)
                            {
                                break;
                            }
                        }
                    }

                    DateTime dtGenerateTime = DateTime.Now;
                    foreach (VoucherList eachNewVoucher in toAddVoucherList)
                    {
                        eachNewVoucher.GenerateTime = dtGenerateTime;
                        dbContext.VoucherLists.AddObject(eachNewVoucher);
                    }
                    filledCount = dbContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.Message);
            }

            sw.Stop();
            TimeSpan ts = sw.Elapsed;

            _log.Info(ts.TotalMilliseconds);

            return(filledCount);
        }