Пример #1
0
        public ActionResult ModifyTempRuleOfOrder()
        {
            Response resp = new Response();

            #region
            CWTariff cwtarff = new CWTariff();
            int      mainID  = 0;
            string   mID     = Request.Form["MID"];
            if (!string.IsNullOrEmpty(mID))
            {
                TempChargingRule rule = cwtarff.FindTempChgRule(Convert.ToInt32(mID));
                if (rule != null)
                {
                    string preID = Request.Form["PreID"];
                    string tType = Request.Form["TType"];

                    rule.TempChgType = (EnmTempChargeType)Convert.ToInt16(tType);
                    rule.PreChgID    = Convert.ToInt32(preID);

                    cwtarff.UpdateTempChgRule(rule);

                    mainID = rule.ID;
                }
            }

            string orderID = Request.Form["OrderID"];
            if (!string.IsNullOrEmpty(orderID))
            {
                string freetime = Request.Form["FreeTime"];
                string fee      = Request.Form["OrderFee"];

                if (orderID == "0")
                {
                    //添加新的
                    if (mainID != 0)
                    {
                        OrderChargeDetail odetail = new OrderChargeDetail()
                        {
                            TempChgID     = mainID,
                            OrderFreeTime = freetime,
                            Fee           = Convert.ToSingle(fee)
                        };
                        resp = cwtarff.AddOrderDetail(odetail);
                    }
                }
                else
                {
                    OrderChargeDetail order = cwtarff.FindOrderDetail(Convert.ToInt32(orderID));
                    if (order != null)
                    {
                        order.OrderFreeTime = freetime;
                        order.Fee           = Convert.ToSingle(fee);
                        cwtarff.UpdateOrderDetail(order);
                    }
                }
            }
            resp.Message = "修改数据成功";
            #endregion
            return(Json(resp));
        }
Пример #2
0
        public ActionResult ModifyTempRuleOfHour()
        {
            Response resp    = new Response();
            CWTariff cwtarff = new CWTariff();
            int      mainID  = 0;
            string   mID     = Request.Form["MID"];

            if (!string.IsNullOrEmpty(mID))
            {
                TempChargingRule rule = cwtarff.FindTempChgRule(Convert.ToInt32(mID));
                if (rule != null)
                {
                    string preID = Request.Form["PreID"];
                    string tType = Request.Form["TType"];

                    rule.TempChgType = (EnmTempChargeType)Convert.ToInt16(tType);
                    rule.PreChgID    = Convert.ToInt32(preID);

                    cwtarff.UpdateTempChgRule(rule);

                    mainID = rule.ID;
                }
            }
            string hourID = Request.Form["hourID"];

            if (!string.IsNullOrEmpty(hourID))
            {
                string strided = Request.Form["StrideDay"];
                string cyclet  = Request.Form["CycleTime"];
                string topfee  = Request.Form["StrideTopFee"];
                if (hourID == "0")
                {
                    //新增
                    HourChargeDetail hour = new HourChargeDetail
                    {
                        StrideDay   = (EnmStrideDay)Convert.ToInt16(strided),
                        CycleTime   = (EnmCycleTime)Convert.ToInt16(cyclet),
                        CycleTopFee = Convert.ToSingle(topfee),
                        TempChgID   = mainID
                    };
                    resp = cwtarff.AddHourChgDetail(hour);
                }
                else
                {
                    //修改
                    HourChargeDetail detail = cwtarff.FindHourChgDetail(Convert.ToInt32(hourID));
                    if (detail != null)
                    {
                        detail.StrideDay   = (EnmStrideDay)Convert.ToInt16(strided);
                        detail.CycleTime   = (EnmCycleTime)Convert.ToInt16(cyclet);
                        detail.CycleTopFee = Convert.ToSingle(topfee);

                        resp = cwtarff.UpdateHourChgDetail(detail);
                    }
                }
            }
            resp.Message = "修改数据成功";
            return(Json(resp));
        }
Пример #3
0
        public ActionResult AddTempRuleByOrder()
        {
            Response resp   = new Response();
            CWTariff cwtrff = new CWTariff();
            List <TempChargingRule> ruleList = cwtrff.GetTempChgRuleList();

            if (ruleList.Count > 0)
            {
                resp.Code    = 0;
                resp.Message = "系统故障,存在临时类记录,无法完成新增工作!";
                return(Json(resp));
            }
            string preID    = Request.Form["PreID"];
            string tType    = Request.Form["TType"]; //计费类型
            string freetime = Request.Form["FreeTime"];
            string fee      = Request.Form["OrderFee"];

            TempChargingRule rule = new TempChargingRule()
            {
                ICType      = EnmICCardType.Temp,
                TempChgType = (EnmTempChargeType)Convert.ToInt16(tType),
                PreChgID    = Convert.ToInt32(preID)
            };

            resp = cwtrff.AddTempChgRule(rule);
            if (resp.Code == 1)
            {
                //先删除原来的记录
                List <OrderChargeDetail> orderdetailLst = cwtrff.GetOrderDetailList();
                foreach (OrderChargeDetail order in orderdetailLst)
                {
                    cwtrff.DeleteOrderDetail(order.ID);
                }
                //添加新的
                OrderChargeDetail odetail = new OrderChargeDetail()
                {
                    TempChgID     = rule.ID,
                    OrderFreeTime = freetime,
                    Fee           = Convert.ToSingle(fee)
                };
                resp = cwtrff.AddOrderDetail(odetail);

                resp.Data = null;
                if (resp.Code == 1)
                {
                    var da = new
                    {
                        mainID  = rule.ID,
                        orderID = odetail.ID
                    };
                    resp.Data = da;
                }
            }
            return(Json(resp));
        }
Пример #4
0
        public ActionResult AddTempRuleByHour()
        {
            Response resp = new Response();

            CWTariff cwtrff = new CWTariff();
            List <TempChargingRule> ruleList = cwtrff.GetTempChgRuleList();

            if (ruleList.Count > 0)
            {
                resp.Code    = 0;
                resp.Message = "系统故障,存在临时类记录,无法完成新增工作!";
                return(Json(resp));
            }
            string           preID = Request.Form["PreID"];
            string           tType = Request.Form["TType"]; //计费类型
            TempChargingRule rule  = new TempChargingRule()
            {
                ICType      = EnmICCardType.Temp,
                TempChgType = (EnmTempChargeType)Convert.ToInt16(tType),
                PreChgID    = Convert.ToInt32(preID)
            };

            resp = cwtrff.AddTempChgRule(rule);
            if (resp.Code == 1)
            {
                string strided = Request.Form["StrideDay"];
                string cyclet  = Request.Form["CycleTime"];
                string topfee  = Request.Form["StrideTopFee"];

                HourChargeDetail hour = new HourChargeDetail {
                    StrideDay   = (EnmStrideDay)Convert.ToInt16(strided),
                    CycleTime   = (EnmCycleTime)Convert.ToInt16(cyclet),
                    CycleTopFee = Convert.ToSingle(topfee),
                    TempChgID   = rule.ID
                };
                resp = cwtrff.AddHourChgDetail(hour);

                resp.Data = null;
                if (resp.Code == 1)
                {
                    var da = new
                    {
                        mainID = rule.ID,
                        hourID = hour.ID
                    };
                    resp.Data = da;
                }
            }
            return(Json(resp));
        }
Пример #5
0
        public ActionResult DeletePre(int ID)
        {
            CWTariff cwtariff = new CWTariff();
            //同时删除计费绑定的
            TempChargingRule temp = cwtariff.FindTempChgRule(tp => tp.PreChgID == ID);

            if (temp != null)
            {
                temp.PreChgID = 0;
                cwtariff.UpdateTempChgRule(temp);
            }
            FixChargingRule fix = cwtariff.FindFixCharge(fx => fx.PreChgID == ID);

            if (fix != null)
            {
                fix.PreChgID = 0;
                cwtariff.UpdateFixCharge(fix);
            }
            Response resp = cwtariff.DeletePreCharge(ID);

            return(Json(resp, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        /// <summary>
        /// 计算临时用户费用
        /// </summary>
        /// <param name="indate"></param>
        /// <param name="outdate"></param>
        /// <returns></returns>
        public Response CalculateTempFee(DateTime indate, DateTime outdate, out float fee)
        {
            fee = 0;
            Response resp = new Response();
            List <TempChargingRule> tempChgRuleLst = tempManager.FindList().ToList();

            if (tempChgRuleLst.Count == 0)
            {
                resp.Message = "未定义临时类计费规则";
                return(resp);
            }
            TempChargingRule globalRule = tempChgRuleLst[0];

            if (globalRule.TempChgType == EnmTempChargeType.Order)
            {
                #region  次
                OrderChargeDetail orderdetail = orderDetailManager.Find(globalRule.ID);
                if (orderdetail == null)
                {
                    resp.Message = "按次计费类型,但是没有找到按次计费规则表!";
                    return(resp);
                }
                TimeSpan ts           = outdate - indate;
                double   totalMinutes = Math.Ceiling(ts.TotalMinutes);
                TimeSpan span         = TimeSpan.Parse(orderdetail.OrderFreeTime.Trim());
                if (span.TotalMinutes > totalMinutes)
                {
                    fee = orderdetail.Fee;
                }
                resp.Code    = 1;
                resp.Message = "按次费用,查询成功";
                #endregion
            }
            else if (globalRule.TempChgType == EnmTempChargeType.Hour)
            {
                #region  时
                HourChargeDetail hourdetail = hourDetailManager.Find(hc => hc.TempChgID == globalRule.ID);
                if (hourdetail == null)
                {
                    resp.Message = "没有找到 按时计费 规则记录!";
                    return(resp);
                }
                List <HourSectionInfo> sectionInfoLst = hourSectionManager.FindList(hs => hs.HourChgID == hourdetail.ID);
                if (sectionInfoLst.Count == 0)
                {
                    resp.Message = "没有找到 时段 规则记录";
                    return(resp);
                }
                //这里都是24小时制,延续计费的方式进行,后面的,再增加
                //排序
                List <HourSectionInfo> timeslotLst = sectionInfoLst.OrderBy(sc => sc.StartTime).ToList();

                if (hourdetail.CycleTopFee > 0)
                {
                    #region 设置了周期最高计费
                    TimeSpan ts        = outdate - indate;
                    int      days      = ts.Days;
                    bool     isInit    = true;
                    DateTime newIndate = indate;
                    //计算超过天数的停车费用
                    float daysFee = 0;
                    if (days > 0)
                    {
                        daysFee = days * hourdetail.CycleTopFee;
                        isInit  = false;

                        newIndate = indate.AddDays(days);
                    }
                    float otherHoursFee = calcuteHoursFeeHasLimit(newIndate, outdate, timeslotLst, isInit);
                    if (otherHoursFee > 10000)
                    {
                        resp.Message = "系统异常,Fee - " + otherHoursFee;
                        return(resp);
                    }
                    if (otherHoursFee > hourdetail.CycleTopFee)
                    {
                        otherHoursFee = hourdetail.CycleTopFee;
                    }
                    fee = daysFee + otherHoursFee;
                    #endregion
                }
                else
                {
                    //没有周期最高限额限制
                    fee = calcuteHoursFeeNoLimit(indate, outdate, timeslotLst);
                }
                resp.Code    = 1;
                resp.Message = "查询费用成功";
                #endregion
            }
            else
            {
                resp.Message = "未定义计费类型,请核查!";
            }

            return(resp);
        }
Пример #7
0
 /// <summary>
 /// 更新临时类收费记录
 /// </summary>
 /// <param name="temprule"></param>
 /// <returns></returns>
 public Response UpdateTempChgRule(TempChargingRule temprule)
 {
     return(tempManager.Update(temprule));
 }
Пример #8
0
 /// <summary>
 /// 添加临时类收费规则
 /// </summary>
 /// <param name="temprule"></param>
 /// <returns></returns>
 public Response AddTempChgRule(TempChargingRule temprule)
 {
     return(tempManager.Add(temprule));
 }