Exemplo n.º 1
0
        public static ParkOrder AddMonthlyRentOrderCS(string parkingId, string carTypeId, string grantId, DateTime originalStartDate, DateTime originalEndDate, DateTime newStartDate, DateTime newEndDate, int renewalMonth, int pkLotQuantit, string operatorId, decimal Amount, DbOperator dbOperator)
        {
            ParkOrder  order   = GenerateMonthCardOrderModelCS(parkingId, carTypeId, grantId, originalEndDate, originalEndDate, newStartDate, newEndDate, renewalMonth, pkLotQuantit, Amount, operatorId);
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.Add(order, dbOperator));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 生存商家充值订单
        /// </summary>
        /// <param name="seller">商家信息</param>
        /// <param name="chargeBalance">充值金额</param>
        /// <param name="operatorId">操作者编号</param>
        /// <param name="dbOperator"></param>
        /// <returns></returns>
        public static ParkOrder MarkSellerChargeOrder(ParkSeller seller, decimal chargeBalance, string operatorId, OrderSource orderSource, OrderPayWay payWay, DbOperator dbOperator)
        {
            ParkOrder  order   = GetSellerChargeOrder(seller, chargeBalance, operatorId, orderSource, payWay);
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.Add(order, dbOperator));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 生存储值卡续费订单
        /// </summary>
        /// <param name="rechargeMoney"></param>
        /// <param name="card"></param>
        /// <param name="operatorId"></param>
        /// <param name="dbOperator"></param>
        /// <returns></returns>
        public static ParkOrder AddStoredValueCarOrder(string parkingId, decimal rechargeMoney, BaseCard card, string operatorId, DbOperator dbOperator)
        {
            ParkOrder  order   = GenerateStoredValueCarOrderModel(parkingId, rechargeMoney, card, operatorId);
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.Add(order, dbOperator));
        }
Exemplo n.º 4
0
        /// <summary>
        /// 生存VIP卡续期订单
        /// </summary>
        /// <param name="grantId"></param>
        /// <param name="originalStartDate"></param>
        /// <param name="originalEndDate"></param>
        /// <param name="newStartDate"></param>
        /// <param name="newEndDate"></param>
        /// <param name="renewalMonth"></param>
        /// <param name="operatorId"></param>
        /// <param name="dbOperator"></param>
        /// <returns></returns>
        public static ParkOrder AddVipCardOrder(string parkingId, string grantId, DateTime originalStartDate, DateTime originalEndDate, DateTime newStartDate, DateTime newEndDate, int renewalMonth, string operatorId, DbOperator dbOperator)
        {
            ParkOrder  order   = GenerateVipCardOrderModel(parkingId, grantId, originalStartDate, originalEndDate, newEndDate, newEndDate, renewalMonth, operatorId);
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.Add(order, dbOperator));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 生存返还卡片押金订单
        /// </summary>
        /// <param name="card"></param>
        /// <param name="operatorId"></param>
        /// <returns></returns>
        public static ParkOrder MarkUserCardDepositRefundOrder(BaseCard card, string operatorId, DbOperator dbOperator)
        {
            ParkOrder  order   = GetUserCardDepositRefundOrder(card, operatorId);
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.Add(order, dbOperator));
        }
Exemplo n.º 6
0
        /// <summary>
        /// 生存中央缴费订单
        /// </summary>
        /// <param name="parkingId">车场编号</param>
        /// <param name="ioRecordId">记录编号</param>
        /// <param name="amount">订单金额</param>
        /// <param name="payAmount">已付金额</param>
        /// <param name="discountAmount">优惠金额</param>
        /// <param name="carderateIds">优免券编号</param>
        /// <param name="feeRuleId">收费规则编号</param>
        /// <param name="cashTime">结余时间</param>
        /// <param name="cashMoney">结余金额</param>
        /// <param name="operatorId">操作员编号</param>
        /// <returns></returns>
        public static ParkOrder AddCentralFeeOrder(string parkingId, string ioRecordId, decimal amount, decimal payAmount, decimal discountAmount,
                                                   List <string> carderateIds, string feeRuleId, DateTime cashTime, decimal cashMoney, string operatorId, DbOperator dbOperator)
        {
            ParkOrder  order   = GenerateCentralFeeOrderModel(parkingId, ioRecordId, amount, payAmount, discountAmount, carderateIds, feeRuleId, cashTime, cashMoney, operatorId);
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.Add(order, dbOperator));
        }
Exemplo n.º 7
0
 public static IParkOrder GetFactory()
 {
     if (factory == null)
     {
         Type type = Type.GetType("Common." + SystemDefaultConfig.DatabaseProvider + "Repository.ParkOrderDAL,Common." + SystemDefaultConfig.DatabaseProvider + "Repository", true);
         factory = (IParkOrder)Activator.CreateInstance(type);
     }
     return(factory);
 }
Exemplo n.º 8
0
        public static List <ParkOrder> GetOrderByTimeseriesIDByStatus(string timeseriesID, int status, out string errorMsg)
        {
            if (timeseriesID.IsEmpty())
            {
                throw new ArgumentNullException("timeseriesID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetOrderByTimeseriesIDByStatus(timeseriesID, status, out errorMsg));
        }
Exemplo n.º 9
0
        public static List <ParkOrder> GetOrderByIORecordIDByStatus(string iorecordID, int status, out string errorMsg)
        {
            if (iorecordID.IsEmpty())
            {
                throw new ArgumentNullException("iorecordID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetOrderByIORecordIDByStatus(iorecordID, status, out errorMsg));
        }
Exemplo n.º 10
0
        public static bool ModifyOrderStatusAndAmount(string recordID, decimal amount, decimal payAmount, decimal unPayamount, int status, decimal Discountamount, string Carderateid, int payWay, out string ErrorMessage)
        {
            if (recordID.IsEmpty())
            {
                throw new ArgumentNullException("recordID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.ModifyOrderStatusAndAmount(recordID, amount, payAmount, unPayamount, status, Discountamount, Carderateid, payWay, out ErrorMessage));
        }
Exemplo n.º 11
0
        public static ParkOrder AddOrder(ParkOrder mode, out string errorMsg)
        {
            if (mode == null)
            {
                throw new ArgumentNullException("mode");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.AddOrder(mode, out errorMsg));
        }
Exemplo n.º 12
0
        public static bool ModifyOrderTagIDAndOrderType(string recordID, string tagid, int orderType, out string errorMsg)
        {
            if (recordID.IsEmpty())
            {
                throw new ArgumentNullException("recordID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.ModifyOrderTagIDAndOrderType(recordID, tagid, orderType, out errorMsg));
        }
Exemplo n.º 13
0
        public static List <ParkOrder> GetOrderByCarDerateID(DateTime startTime, string carDerateID, out string errorMsg)
        {
            if (carDerateID.IsEmpty())
            {
                throw new ArgumentNullException("CarDerateID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetOrderByCarDerateID(startTime, carDerateID, out errorMsg));
        }
Exemplo n.º 14
0
        public static bool ModifyOrderStatusAndAmount(string recordID, decimal payAmount, decimal unPayamount, int status, int payWay, out string errorMsg)
        {
            if (recordID.IsEmpty())
            {
                throw new ArgumentNullException("recordID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.ModifyOrderStatusAndAmount(recordID, payAmount, unPayamount, status, payWay, out errorMsg));
        }
Exemplo n.º 15
0
        public static List <ParkOrder> GetOrderByTagID(string tagID, out string errorMsg)
        {
            if (tagID.IsEmpty())
            {
                throw new ArgumentNullException("tagID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetOrderByTagID(tagID, out errorMsg));
        }
Exemplo n.º 16
0
        public static bool ModifyOrderStatus(string recordID, int status, out string errorMsg)
        {
            if (recordID.IsEmpty())
            {
                throw new ArgumentNullException("recordID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.ModifyOrderStatus(recordID, status, out errorMsg));
        }
Exemplo n.º 17
0
        public static ParkOrder GetCashMoneyCountByPlateNumber(string parkingID, OrderType orderType, string plateNumber, DateTime startTime, DateTime endtime, out string errorMsg)
        {
            if (parkingID.IsEmpty())
            {
                throw new ArgumentNullException("parkingID");
            }
            if (plateNumber.IsEmpty())
            {
                throw new ArgumentNullException("plateNumber");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetCashMoneyCountByPlateNumber(parkingID, orderType, plateNumber, startTime, endtime, out errorMsg));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 过期转临停订单处理
        /// </summary>
        /// <param name="ioRecordIds"></param>
        /// <param name="operatorId"></param>
        /// <param name="dbOperator"></param>
        /// <returns></returns>
        public static bool AddExpiredToProStopOrder(List <string> ioRecordIds, string operatorId, DbOperator dbOperator)
        {
            if (ioRecordIds.Count == 0)
            {
                return(false);
            }

            IParkOrder       factory = ParkOrderFactory.GetFactory();
            List <ParkOrder> orders  = factory.QueryByIORecordIds(ioRecordIds);

            if (orders.Count == 0)
            {
                return(true);
            }

            bool result = factory.UpdateOrderStatusByIORecordIds(ioRecordIds, -1, dbOperator);

            if (!result)
            {
                return(false);
            }

            foreach (var item in orders)
            {
                item.OrderNo     = IdGenerator.Instance.GetId().ToString();
                item.TagID       = item.RecordID;
                item.Status      = 1;
                item.OrderSource = OrderSource.ManageOffice;
                item.OrderTime   = DateTime.Now;
                item.UserID      = operatorId;
                item.Amount      = item.Amount;
                item.PayAmount   = item.PayAmount;
                item.OldMoney    = item.OldMoney;
                item.NewMoney    = item.NewMoney;
                item.PayWay      = OrderPayWay.Cash;
                item.Remark      = "过期转临停关联订单记录:" + item.RecordID;
                item.PayTime     = DateTime.Now;
                item.CashTime    = item.PayTime;
                item.CashMoney   = item.CashMoney;
                item.PayTime     = DateTime.Now;
                ParkOrder order = factory.Add(item, dbOperator);
                if (order == null)
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 19
0
        public static bool AuditingDiffOrder(ParkOrder model, decimal Amount, decimal PayAmount, out string ErrorMessage)
        {
            if (model.RecordID.IsEmpty())
            {
                throw new ArgumentNullException("recordID");
            }

            IParkOrder factory = ParkOrderFactory.GetFactory();
            bool       result  = factory.AuditingDiffOrder(model.RecordID, Amount, PayAmount, out ErrorMessage);

            if (result)
            {
                OperateLogServices.AddOperateLog <ParkOrder>(model, OperateType.Update);
            }
            return(result);
        }
Exemplo n.º 20
0
        public static List <ParkOrder> GetOrdersByPKID(string PKID, DateTime startTime, DateTime endTime)
        {
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetOrdersByPKID(PKID, startTime, endTime));
        }
Exemplo n.º 21
0
        public static List <ParkOrder> GetSellerRechargeOrder(string sellerId, int orderSource, DateTime?start, DateTime?end, int pageIndex, int pageSize, out int total)
        {
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetSellerRechargeOrder(sellerId, orderSource, start, end, pageIndex, pageSize, out total));
        }
Exemplo n.º 22
0
        public static List <ParkOrder> GetDifferenceOrder(DateTime startTime, DateTime endtime, string userid, out string ErrorMessage)
        {
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetDifferenceOrder(startTime, endtime, userid, out ErrorMessage));
        }
Exemplo n.º 23
0
        public static ParkOrder GetIORecordOrderChareFeeCount(string userID, OrderType OrderType, DateTime dt, int releaseType, out string ErrorMessage)
        {
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetIORecordOrderChareFeeCount(userID, OrderType, dt, releaseType, out ErrorMessage));
        }
Exemplo n.º 24
0
        public static List <ParkOrder> GetOrderByStatus(DateTime startTime, DateTime endtime, int status, out string ErrorMessage)
        {
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.GetOrderByStatus(startTime, endtime, status, out ErrorMessage));
        }
Exemplo n.º 25
0
        public static List <ParkOrder> QueryByIORecordIds(List <string> recordIds)
        {
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.QueryByIORecordIds(recordIds));
        }
Exemplo n.º 26
0
        public static decimal CalculateMonthlyRentExpiredWaitPayAmount(DateTime start, string grantId)
        {
            ParkGrant grant = ParkGrantServices.QueryByGrantId(grantId);

            if (grant == null)
            {
                throw new MyException("获取授权失败");
            }
            if (grant.BeginDate == DateTime.MinValue || grant.EndDate == DateTime.MinValue || (grant.EndDate != DateTime.MinValue && grant.EndDate.Date >= DateTime.Now.Date))
            {
                return(0);
            }
            ParkCarType carType = ParkCarTypeServices.QueryParkCarTypeByRecordId(grant.CarTypeID);

            if (carType == null)
            {
                throw new MyException("获取车类失败");
            }

            if (carType.BaseTypeID != BaseCarType.MonthlyRent)
            {
                return(0);
            }

            DateTime startDate = grant.EndDate.AddDays(1).Date;
            DateTime endDate   = start.Date;

            List <string> plateNos = new List <string>();
            EmployeePlate plate    = EmployeePlateServices.Query(grant.PlateID);

            if (plate == null)
            {
                throw new MyException("获取车牌号失败");
            }

            plateNos.Add(plate.PlateNo);

            if (!string.IsNullOrWhiteSpace(grant.PKLot))
            {
                List <ParkGrant> sameGrants = ParkGrantServices.QueryByParkingAndLotAndCarType(grant.PKID, grant.PKLot, BaseCarType.MonthlyRent, grant.GID);
                foreach (var item in sameGrants)
                {
                    int lot1 = grant.PKLot.Split(',').Length;
                    int lot2 = item.PKLot.Split(',').Length;
                    if (lot1 != lot2)
                    {
                        continue;
                    }

                    EmployeePlate plate1 = EmployeePlateServices.Query(item.PlateID);
                    if (plate1 == null)
                    {
                        throw new MyException("获取车牌号失败");
                    }
                    plateNos.Add(plate1.PlateNo);
                }
            }
            IParkOrder factory = ParkOrderFactory.GetFactory();

            return(factory.QueryMonthExpiredNotPayAmount(startDate, endDate, grant.PKID, plateNos));
        }
Exemplo n.º 27
0
        /// <summary>
        /// 当班统计
        /// </summary>
        public void Statistics_OnDuty(string ParkingID)
        {
            try
            {
                IParking                iparking               = ParkingFactory.GetFactory();
                IParkIORecord           iorecordfactory        = ParkIORecordFactory.GetFactory();
                IStatistics_Gather      gatherfactory          = Statistics_GatherFactory.GetFactory();
                IParkChangeshiftrecord  ichangeshift           = ParkChangeshiftrecordFactory.GetFactory();
                IParkOrder              iorder                 = ParkOrderFactory.GetFactory();
                IParkBox                iparkbox               = ParkBoxFactory.GetFactory();
                IStatistics_ChangeShift istatisticschangeshift = Statistics_ChangeShiftFactory.GetFactory();
                BaseParkinfo            parking                = iparking.QueryParkingByParkingID(ParkingID);
                List <ParkBox>          boxlist                = iparkbox.QueryByParkingID(parking.PKID);
                if (boxlist != null && boxlist.Count > 0)
                {
                    foreach (ParkBox box in boxlist)
                    {
                        List <ParkChangeshiftrecord> ondutys = ichangeshift.GetChangeShiftRecord(box.BoxID);
                        if (ondutys == null || ondutys.Count == 0)
                        {
                            continue;
                        }
                        foreach (ParkChangeshiftrecord onduty in ondutys)
                        {
                            Statistics_ChangeShift changeshift = new Statistics_ChangeShift
                            {
                                BoxID         = onduty.BoxID,
                                ParkingName   = parking.PKName,
                                StartWorkTime = onduty.StartWorkTime,
                                EndWorkTime   = onduty.EndWorkTime,
                                ParkingID     = parking.PKID,
                                AdminID       = onduty.UserID,
                                ChangeShiftID = onduty.RecordID
                            };
                            DateTime starttime = onduty.StartWorkTime;
                            DateTime endtime   = DateTime.Now;
                            if (onduty.EndWorkTime > DateTime.MinValue)
                            {
                                endtime = onduty.EndWorkTime;
                            }
                            //统计相关信息
                            //查询进场数
                            changeshift.Entrance_Count = iorecordfactory.EntranceCountByBox(box.BoxID, starttime, endtime);
                            //查询出场数
                            changeshift.Exit_Count = iorecordfactory.ExitCountByBox(box.BoxID, starttime, endtime);
                            #region 进场卡片类型
                            List <KeyValue> _InCardType = iorecordfactory.GetInCardTypeByBoxID(box.BoxID, starttime, endtime);
                            if (_InCardType != null && _InCardType.Count > 0)
                            {
                                foreach (var k in _InCardType)
                                {
                                    switch (k.KeyName)
                                    {
                                    case "0":
                                        changeshift.VIPCard = k.Key_Value;
                                        break;

                                    case "1":
                                        changeshift.StordCard = k.Key_Value;
                                        break;

                                    case "2":
                                        changeshift.MonthCard = k.Key_Value;
                                        break;

                                    case "3":
                                        changeshift.TempCard = k.Key_Value;
                                        break;

                                    case "4":
                                        changeshift.JobCard = k.Key_Value;
                                        break;

                                    default:
                                        break;
                                    }
                                }
                            }
                            #endregion

                            #region 统计放行类型
                            List <KeyValue> _ReleaseType = iorecordfactory.GetReleaseTypeByBox(box.BoxID, starttime, endtime);
                            if (_ReleaseType != null && _ReleaseType.Count > 0)
                            {
                                foreach (KeyValue k in _ReleaseType)
                                {
                                    switch (k.KeyName)
                                    {
                                    case "0":
                                        changeshift.ReleaseType_Normal = k.Key_Value;
                                        break;

                                    case "1":
                                        changeshift.ReleaseType_Charge = k.Key_Value;
                                        break;

                                    case "2":
                                        changeshift.ReleaseType_Free = k.Key_Value;
                                        break;

                                    case "3":
                                        changeshift.ReleaseType_Catch = k.Key_Value;
                                        break;
                                    }
                                }
                            }
                            #endregion

                            #region 统计费用相关
                            List <ParkOrder> _orderfee = iorder.GetOrdersByBoxID(parking.PKID, onduty.BoxID, starttime, endtime);
                            if (_orderfee != null && _orderfee.Count > 0)
                            {
                                foreach (ParkOrder o in _orderfee)
                                {
                                    changeshift.Receivable_Amount += o.Amount;
                                    changeshift.Diff_Amount       += o.UnPayAmount;
                                    changeshift.Real_Amount        = (changeshift.Receivable_Amount - changeshift.Diff_Amount);
                                    //支付方式(1.现金、2.微信、3.支付宝、4.网银、5.电子钱包、6.优免卷7.余额
                                    switch (o.PayWay)
                                    {
                                    case OrderPayWay.Cash:
                                        changeshift.Cash_Amount += o.PayAmount;
                                        changeshift.Cash_Count++;

                                        if (o.DiscountAmount > 0)
                                        {
                                            changeshift.CashDiscount_Amount += o.DiscountAmount;
                                            changeshift.CashDiscount_Count++;

                                            changeshift.Discount_Amount += o.DiscountAmount;
                                            changeshift.Discount_Count++;
                                        }
                                        break;

                                    case OrderPayWay.WeiXin:
                                    case OrderPayWay.Alipay:
                                    case OrderPayWay.OnlineBanking:
                                    case OrderPayWay.Wallet:
                                        changeshift.OnLine_Amount += o.PayAmount;
                                        changeshift.OnLine_Count++;

                                        if (o.DiscountAmount > 0)
                                        {
                                            changeshift.OnLineDiscount_Amount += o.DiscountAmount;
                                            changeshift.OnLineDiscount_Count++;

                                            changeshift.Discount_Amount += o.DiscountAmount;
                                            changeshift.Discount_Count++;
                                        }
                                        break;

                                    case OrderPayWay.PreferentialTicket:
                                        changeshift.Discount_Amount += o.DiscountAmount;
                                        changeshift.Discount_Count++;
                                        break;

                                    case OrderPayWay.ValueCard:
                                        changeshift.StordCard_Amount += o.PayAmount;
                                        changeshift.StordCard_Count++;
                                        break;
                                    }
                                    switch (o.OrderType)
                                    {
                                    //临时卡缴费
                                    case OrderType.TempCardPayment:
                                    case OrderType.AreaTempCardPayment:
                                        switch (o.PayWay)
                                        {
                                        case OrderPayWay.WeiXin:
                                        case OrderPayWay.Alipay:
                                        case OrderPayWay.OnlineBanking:
                                        case OrderPayWay.Wallet:
                                            changeshift.OnLineTemp_Amount += o.PayAmount;
                                            changeshift.OnLineTemp_Count++;
                                            break;

                                        default:
                                            changeshift.Temp_Amount += o.PayAmount;
                                            changeshift.Temp_Count++;
                                            break;
                                        }
                                        break;

                                    //月卡续期
                                    case OrderType.MonthCardPayment:
                                        switch (o.PayWay)
                                        {
                                        case OrderPayWay.WeiXin:
                                        case OrderPayWay.Alipay:
                                        case OrderPayWay.OnlineBanking:
                                        case OrderPayWay.Wallet:
                                            changeshift.OnLineMonthCardExtend_Amount += o.PayAmount;
                                            changeshift.OnLineMonthCardExtend_Count++;
                                            break;

                                        default:
                                            changeshift.MonthCardExtend_Amount += o.PayAmount;
                                            changeshift.MonthCardExtend_Count++;
                                            break;
                                        }
                                        break;

                                    //VIP卡续期
                                    case OrderType.VIPCardRenewal:
                                        changeshift.VIPExtend_Count++;
                                        break;

                                    //储值卡充值
                                    case OrderType.ValueCardRecharge:
                                        switch (o.PayWay)
                                        {
                                        case OrderPayWay.WeiXin:
                                        case OrderPayWay.Alipay:
                                        case OrderPayWay.OnlineBanking:
                                        case OrderPayWay.Wallet:
                                            changeshift.OnLineStordCard_Amount += o.PayAmount;
                                            changeshift.OnLineStordCard_Count++;
                                            break;

                                        default:
                                            changeshift.StordCardRecharge_Amount += o.PayAmount;
                                            changeshift.StordCardRecharge_Count++;
                                            break;
                                        }
                                        break;
                                    }
                                }
                            }
                            #endregion
                            using (DbOperator dboperator = ConnectionManager.CreateReadConnection())
                            {
                                try
                                {
                                    dboperator.BeginTransaction();
                                    istatisticschangeshift.Delete(onduty.RecordID, dboperator);
                                    istatisticschangeshift.Insert(changeshift, dboperator);
                                    dboperator.CommitTransaction();
                                }
                                catch (Exception ex)
                                {
                                    TxtLogServices.WriteTxtLog("添加当班信息异常 异常信息:{0}", ex.Message);
                                    dboperator.RollbackTransaction();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TxtLogServices.WriteTxtLog("当班统计异常 异常信息:{0}", ex.Message);
            }
        }
Exemplo n.º 28
0
        public void Statistics_DailyByGate(List <ParkGate> gatelist, BaseParkinfo park, DateTime startdate, DateTime enddate)
        {
            #region 统计通道的实收应收  按小时
            if (gatelist == null || gatelist.Count == 0)
            {
                return;
            }
            IParkIORecord          iorecordfactory = ParkIORecordFactory.GetFactory();
            IParkOrder             iorder          = ParkOrderFactory.GetFactory();
            IStatistics_GatherGate igathergate     = Statistics_GatherGateFactory.GetFactory();
            foreach (var g in gatelist)
            {
                int hours    = 0;
                int maxhours = 23;
                List <Statistics_GatherGate> gathergates = new List <Statistics_GatherGate>();
                List <DateTime> DeleteGather             = new List <DateTime>();

                if (startdate.ToString("yyyyMMdd") == startdate.ToString("yyyyMMdd"))
                {
                    maxhours = startdate.Hour;
                }
                while (hours <= maxhours)
                {
                    System.Threading.Thread.Sleep(50);
                    Statistics_GatherGate gather = new Statistics_GatherGate();
                    DateTime tempstartdate       = startdate.AddHours(hours);
                    DateTime tempenddate         = enddate.AddHours(hours);
                    gather.StatisticsGatherID = System.Guid.NewGuid().ToString();
                    gather.ParkingID          = park.PKID;
                    gather.ParkingName        = park.PKName;
                    gather.GatherTime         = tempstartdate;
                    gather.BoxID    = g.BoxID;
                    gather.BoxName  = g.BoxName;
                    gather.GateID   = g.GateID;
                    gather.GateName = g.GateName;

                    if (startdate.ToString("yyyyMMdd") == startdate.ToString("yyyyMMdd"))
                    {
                        if (hours == maxhours || hours == maxhours - 1)
                        {
                            DeleteGather.Add(tempstartdate);
                        }
                        else
                        {
                            if (igathergate.IsExists(g.GateID, tempstartdate))
                            {
                                hours++;
                                continue;
                            }
                        }
                    }
                    else
                    {
                        if (igathergate.IsExists(g.GateID, tempstartdate))
                        {
                            hours++;
                            continue;
                        }
                    }

                    //查询进场数
                    gather.Entrance_Count = iorecordfactory.EntranceCountByGate(g.GateID, tempstartdate, tempenddate);
                    //查询出场数
                    gather.Exit_Count = iorecordfactory.ExitCountByGate(g.GateID, tempstartdate, tempenddate);

                    #region 进场卡片类型
                    List <KeyValue> _InCardType = iorecordfactory.GetInCardTypeByGateID(g.GateID, tempstartdate, tempenddate);
                    if (_InCardType != null && _InCardType.Count > 0)
                    {
                        foreach (var kv in _InCardType)
                        {
                            switch (kv.KeyName)
                            {
                            case "0":
                                gather.VIPCard = kv.Key_Value;
                                break;

                            case "1":
                                gather.StordCard = kv.Key_Value;
                                break;

                            case "2":
                                gather.MonthCard = kv.Key_Value;
                                break;

                            case "3":
                                gather.TempCard = kv.Key_Value;
                                break;

                            case "4":
                                gather.JobCard = kv.Key_Value;
                                break;

                            default:
                                break;
                            }
                        }
                    }
                    #endregion

                    #region 统计放行类型
                    List <KeyValue> _ReleaseType = iorecordfactory.GetReleaseTypeByGate(g.GateID, tempstartdate, tempenddate);
                    if (_ReleaseType != null && _ReleaseType.Count > 0)
                    {
                        foreach (var kv in _ReleaseType)
                        {
                            switch (kv.KeyName)
                            {
                            case "0":
                                gather.ReleaseType_Normal = kv.Key_Value;
                                break;

                            case "1":
                                gather.ReleaseType_Charge = kv.Key_Value;
                                break;

                            case "2":
                                gather.ReleaseType_Free = kv.Key_Value;
                                break;

                            case "3":
                                gather.ReleaseType_Catch = kv.Key_Value;
                                break;
                            }
                        }
                    }
                    #endregion

                    #region 统计费用相关
                    List <ParkOrder> _orderfee = iorder.GetOrdersByGateID(park.PKID, g.GateID, tempstartdate, tempenddate);
                    if (_orderfee != null && _orderfee.Count > 0)
                    {
                        foreach (var o in _orderfee)
                        {
                            gather.Receivable_Amount += o.Amount;
                            gather.Real_Amount       += o.PayAmount;
                            gather.Diff_Amount       += o.UnPayAmount;
                            //支付方式(1.现金、2.微信、3.支付宝、4.网银、5.电子钱包、6.优免卷7.余额
                            switch (o.PayWay)
                            {
                            case OrderPayWay.Cash:
                                gather.Cash_Amount += o.PayAmount;
                                gather.Cash_Count++;

                                if (o.DiscountAmount > 0)
                                {
                                    gather.CashDiscount_Amount += o.DiscountAmount;
                                    gather.CashDiscount_Count++;

                                    gather.Discount_Amount += o.DiscountAmount;
                                    gather.Discount_Count++;
                                }

                                break;

                            case OrderPayWay.WeiXin:
                            case OrderPayWay.Alipay:
                            case OrderPayWay.OnlineBanking:
                            case OrderPayWay.Wallet:
                                gather.OnLine_Amount += o.PayAmount;
                                gather.OnLine_Count++;

                                if (o.DiscountAmount > 0)
                                {
                                    gather.OnLineDiscount_Amount += o.DiscountAmount;
                                    gather.OnLineDiscount_Count++;

                                    gather.Discount_Amount += o.DiscountAmount;
                                    gather.Discount_Count++;
                                }
                                break;

                            case OrderPayWay.PreferentialTicket:
                                gather.Discount_Amount += o.DiscountAmount;
                                gather.Discount_Count++;
                                break;

                            case OrderPayWay.ValueCard:
                                gather.StordCard_Amount += o.PayAmount;
                                gather.StordCard_Count++;
                                break;
                            }
                            switch (o.OrderType)
                            {
                            //临时卡缴费
                            case OrderType.TempCardPayment:
                            case OrderType.AreaTempCardPayment:
                                switch (o.PayWay)
                                {
                                case OrderPayWay.WeiXin:
                                case OrderPayWay.Alipay:
                                case OrderPayWay.OnlineBanking:
                                case OrderPayWay.Wallet:
                                    gather.OnLineTemp_Amount += o.PayAmount;
                                    gather.OnLineTemp_Count++;
                                    break;

                                default:
                                    gather.Temp_Amount += o.PayAmount;
                                    gather.Temp_Count++;
                                    break;
                                }
                                break;

                            //月卡续期
                            case OrderType.MonthCardPayment:
                                switch (o.PayWay)
                                {
                                case OrderPayWay.WeiXin:
                                case OrderPayWay.Alipay:
                                case OrderPayWay.OnlineBanking:
                                case OrderPayWay.Wallet:
                                    gather.OnLineMonthCardExtend_Amount += o.PayAmount;
                                    gather.OnLineMonthCardExtend_Count++;
                                    break;

                                default:
                                    gather.MonthCardExtend_Amount += o.PayAmount;
                                    gather.MonthCardExtend_Count++;
                                    break;
                                }
                                break;

                            //VIP卡续期
                            case OrderType.VIPCardRenewal:
                                gather.VIPExtend_Count++;
                                break;

                            //储值卡充值
                            case OrderType.ValueCardRecharge:
                                switch (o.PayWay)
                                {
                                case OrderPayWay.WeiXin:
                                case OrderPayWay.Alipay:
                                case OrderPayWay.OnlineBanking:
                                case OrderPayWay.Wallet:
                                    gather.OnLineStordCard_Amount += o.PayAmount;
                                    gather.OnLineStordCard_Count++;
                                    break;

                                default:
                                    gather.StordCardRecharge_Amount += o.PayAmount;
                                    gather.StordCardRecharge_Count++;
                                    break;
                                }
                                break;
                            }
                        }
                    }
                    #endregion

                    gathergates.Add(gather);
                    hours++;
                }
                if (gathergates != null)
                {
                    using (DbOperator dboperator = ConnectionManager.CreateReadConnection())
                    {
                        try
                        {
                            dboperator.BeginTransaction();
                            foreach (DateTime d in DeleteGather)
                            {
                                igathergate.Delete(park.PKID, startdate, dboperator);
                            }
                            foreach (var gate in gathergates)
                            {
                                if (!igathergate.Insert(gate, dboperator))
                                {
                                    throw new Exception("插入通道统计数据失败");
                                }
                            }
                            dboperator.CommitTransaction();
                        }
                        catch (Exception ex)
                        {
                            Common.Services.TxtLogServices.WriteTxtLog("添加通道统计信息异常 异常信息:{0}", ex.Message);
                            dboperator.RollbackTransaction();
                        }
                    }
                }
            }
            #endregion
        }