Exemplo n.º 1
0
        private bool VehicleControlOpr(string vehicleID, string controlType, bool isTrue)
        {
            VehicleManager vehicleManager = new VehicleManager();
            Hashtable      ht             = vehicleManager.GetVehicleInfoByID(vehicleID);
            string         gps_ID         = string.Empty;

            if (ht != null)
            {
                gps_ID = ht["VEHICLEGPSNUM"].ToString();
            }
            if (controlType == VehicleControlType.Lock.GetHashCode().ToString())
            {
                bool result = false;
                if (isTrue)
                {
                    result = vehicleManager.CloseVehicle(vehicleID);
                }
                else
                {
                    result = vehicleManager.OpenVehicle(vehicleID);
                }
                return(result);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid = res["UID"].ToString().Trim();
                OrdersManager  om    = new OrdersManager();
                VehicleManager vm    = new VehicleManager();
                Hashtable      order = om.GetUserCurrentOrderVehicle(uid);
                Hashtable      ht    = om.GetUserCurrentOrderVehicleGPSNum(uid);
                if (ht == null)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "您没有车辆无法锁车"));
                }
                else
                {
                    //检测车辆当前开关状态,开:unlock,关:lock
                    if ("lock".CompareTo(SiteHelper.GetHashTableValueByKey(order, "LockState")) == 0)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "已临时锁车,如需还车请点击还车,以免额外计费"));
                    }
                    string vid       = SiteHelper.GetHashTableValueByKey(ht, "VID");
                    bool   isSuccess = vm.CloseVehicle(vid);
                    if (!isSuccess)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "临时锁车失败,请稍后重试"));
                    }
                    else
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "success", "已临时锁车,如需还车请点击还车,以免额外计费"));
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 取消订单
        /// </summary>
        /// <param name="order_no"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        private bool CancelOrder(string order_no, string fault_type, out string errmsg)
        {
            bool result = false;

            errmsg = "";
            VehicleManager vm       = new VehicleManager();
            BaoJiaManager  mgr      = new BaoJiaManager();
            Hashtable      order_ht = mgr.GetOrderInfo(order_no);

            if (order_ht != null && order_ht.Keys.Count > 0)
            {
                string order_state = SiteHelper.GetHashTableValueByKey(order_ht, "OrderState");
                if (order_state == "1")
                {
                    string orderid = SiteHelper.GetHashTableValueByKey(order_ht, "ID");
                    string vid     = SiteHelper.GetHashTableValueByKey(order_ht, "VehicleID");
                    vm.CloseVehicle(vid);
                    result = mgr.CancelOrder(orderid);
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["UID"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid = res["UID"].ToString().Trim();
                if (res["Longitude"] != null && res["Longitude"].ToString().Trim().Length > 0)
                {
                    userLng = res["Longitude"].ToString().Trim();
                }
                if (res["Latitude"] != null && res["Latitude"].ToString().Trim().Length > 0)
                {
                    userLat = res["Latitude"].ToString().Trim();
                }
                cacheKey += uid;
                ICache cache = null;
                cache = CacheFactory.GetCache();
                if (!string.IsNullOrEmpty(cache.Get <string>(cacheKey)))
                {
                    if (cache != null)
                    {
                        cache.Dispose();
                    }
                    Logger.Error("还车10秒内," + uid);
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "还车处理中,请勿重复点击"));
                }
                else
                {
                    DateTime dt = DateTime.Now.AddSeconds(10);
                    cache.Set(cacheKey, uid, dt - DateTime.Now);
                    //cache.Dispose();
                }

                /*if (cache != null)
                 * {
                 *   cache.Dispose();
                 * }*/
                UserInfoManager    uim            = new UserInfoManager();
                OrdersManager      om             = new OrdersManager();
                VehicleManager     vm             = new VehicleManager();
                ServiceAreaManager areaManager    = new ServiceAreaManager();
                SysSettingManager  settingManager = new SysSettingManager();
                Hashtable          order          = om.GetUserCurrentOrderVehicle(uid);
                //判断是否有车
                if (order == null)
                {
                    if (cache != null)
                    {
                        cache.Dispose();
                    }
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "您没有车辆无法还车"));
                }
                else
                {
                    //车辆坐标
                    string longitude = SiteHelper.GetHashTableValueByKey(order, "Longitude");
                    string latitude  = SiteHelper.GetHashTableValueByKey(order, "Latitude");
                    string orderNum  = SiteHelper.GetHashTableValueByKey(order, "OrderNum");

                    Hashtable userht = uim.GetUserInfoByUserID(uid);
                    decimal   balance = 0.00m, raiseBalance = 0.00m;
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(userht, "Balance"), out balance);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(userht, "RaiseBalance"), out raiseBalance);
                    //处理订单
                    if (order == null)
                    {
                        if (cache != null)
                        {
                            cache.Dispose();
                        }
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "还车操作失败,请联系管理员"));
                    }
                    else
                    {
                        int renttime = 0;
                        int.TryParse(SiteHelper.GetHashTableValueByKey(order, "RentDuration"), out renttime);
                        decimal  hours = 0.00m;
                        decimal  kmprice = 0.80m;
                        decimal  minuteprice = 0.40m;
                        decimal  mileage = 0;
                        int      minutes = 0;
                        decimal  userprivilegeratio = 1;
                        decimal  raisecommisssionratio = 0.10m;
                        decimal  TotalMoney = 0.00m;
                        decimal  SettlementMoney = 0.00m;
                        decimal  occupyMoney = 0.0m;
                        decimal  payMoney = 0.00m;
                        decimal  RaiseCommissionMoney = 0.00m;
                        decimal  outServiceAreaFee = 0.00m;
                        DateTime createtime = DateTime.Now;
                        DateTime startTime = DateTime.Now;
                        String   returnParkingID = null, returnLocType = null;
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "KMPrice"), out kmprice);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "MinutePrice"), out minuteprice);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "Mileage"), out mileage);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "UserPrivilegeRatio"), out userprivilegeratio);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "RaiseCommissionRatio"), out raisecommisssionratio);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "TotalMoney"), out TotalMoney);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "SettlementMoney"), out SettlementMoney);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "OccupyMoney"), out occupyMoney);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "RaiseCommissionMoney"), out RaiseCommissionMoney);
                        DateTime.TryParse(SiteHelper.GetHashTableValueByKey(order, "CreateTime"), out createtime);
                        DateTime.TryParse(SiteHelper.GetHashTableValueByKey(order, "StartTime"), out startTime);
                        int startminutes = 0;
                        int.TryParse(SiteHelper.GetHashTableValueByKey(order, "StartMinutes"), out startminutes);
                        string strStartTime = SiteHelper.GetHashTableValueByKey(order, "StartTime");

                        LatLng vehicle_pt = new LatLng(double.Parse(latitude), double.Parse(longitude));
                        //车辆GPS坐标转高德坐标
                        vehicle_pt = SiteHelper.GPSToGCJ02(longitude, latitude);
                        vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6), Math.Round(vehicle_pt.longitude, 6));

                        string cityCacheKey = "Vehicle_City_" + SiteHelper.GetHashTableValueByKey(order, "VID");
                        string cityId       = cache.Get <string>(cityCacheKey);
                        if (string.IsNullOrEmpty(cityId))
                        {
                            Hashtable vehicle_ht = vm.GetVehicleInfoByID(SiteHelper.GetHashTableValueByKey(order, "VID"));
                            cityId = vehicle_ht["CITYID"].ToString();
                            DateTime timeSpan = DateTime.Now.AddHours(2);
                            cache.Set(cityCacheKey, cityId, timeSpan - DateTime.Now);
                        }

                        string serviceAreaKey = "Service_Area_" + cityId;
                        string coordinates    = cache.Get <string>(serviceAreaKey);
                        if (string.IsNullOrEmpty(coordinates))
                        {
                            Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(SiteHelper.GetHashTableValueByKey(order, "VID"));
                            if (area_ht != null && area_ht.Keys.Count > 0)
                            {
                                coordinates = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates");
                                if (!string.IsNullOrEmpty(coordinates))
                                {
                                    DateTime timeSpan = DateTime.Now.AddDays(10);
                                    cache.Set(serviceAreaKey, coordinates, timeSpan - DateTime.Now);
                                }
                            }
                        }

                        List <LatLng> area_pts             = new List <LatLng>();
                        bool          isInPoly             = true;
                        string        outServiceAreaReturn = settingManager.GetValueByKey("OutServiceAreaReturn");
                        if (!string.IsNullOrEmpty(coordinates))
                        {
                            foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                            {
                                string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                                LatLng   pt     = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0]));
                                area_pts.Add(pt);
                            }
                            isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, area_pts);
                            if (!isInPoly && "0".Equals(outServiceAreaReturn))
                            {
                                if (cache != null)
                                {
                                    cache.Dispose();
                                }
                                Logger.Info("用户:" + uid + ",订单:" + orderNum + ",在运营区域外被禁止还车");
                                return(SiteHelper.GetJsonFromHashTable(null, "faild", "运营区域外禁止还车,请骑回运营区域再还车"));
                            }
                        }

                        string gpsnum = SiteHelper.GetHashTableValueByKey(order, "VehicleGPSNum");
                        //锁车
                        bool isSuccess = vm.CloseVehicle(SiteHelper.GetHashTableValueByKey(order, "VID"));
                        if (!isSuccess)
                        {
                            Logger.Error("用户:" + uid + ",订单:" + orderNum + ",还车锁车失败:" + gpsnum);
                        }
                        VehiclePriceManager priceManager = new VehiclePriceManager();
                        Hashtable           billing_ht   = priceManager.GetOrderSettlement(SiteHelper.GetHashTableValueByKey(order, "OrderID"));
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "MinutePrice"), out minuteprice);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "KmPrice"), out kmprice);
                        int.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "Minutes"), out minutes);
                        decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "TotalMoney"), out TotalMoney);

                        SettlementMoney = TotalMoney;

                        #region 判断还车点是否在运营区域内,运营区域外加收费用
                        if (TotalMoney > 0 && !string.IsNullOrEmpty(coordinates))
                        {
                            returnLocType = "03";
                            //bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, area_pts);
                            string vehicleInArea = isInPoly ? "在运营区域内还车" : "在运营区域外还车";
                            Logger.Info("用户:" + uid + ",订单:" + SiteHelper.GetHashTableValueByKey(order, "OrderID") + "," + vehicleInArea + "车辆GPS坐标:" + longitude + "," + latitude + ",高德坐标:" + vehicle_pt.longitude + "," + vehicle_pt.latitude);
                            bool isInPoly2 = false;//用户坐标是否在区域内
                            if (!string.IsNullOrEmpty(userLng) && !string.IsNullOrEmpty(userLat))
                            {
                                LatLng user_pt = new LatLng(double.Parse(userLat), double.Parse(userLng));
                                isInPoly2 = SiteHelper.IsPtInPoly(user_pt, area_pts);
                            }
                            //string userInArea = isInPoly2 ? "用户在运营区域内" : "用户在运营区域外";

                            //车辆在运营区域外,不判断用户位置  if (!isInPoly && !isInPoly2)
                            if (!isInPoly)
                            {
                                returnLocType = "04";
                                string serviceFee = settingManager.GetValueByKey("OutServiceAreaFee");
                                if (serviceFee.StartsWith("+"))
                                {
                                    serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                    decimal.TryParse(serviceFee, out outServiceAreaFee);
                                    TotalMoney = TotalMoney + outServiceAreaFee;
                                }
                                else
                                {
                                    serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                    decimal.TryParse(serviceFee, out outServiceAreaFee);
                                    TotalMoney = TotalMoney * outServiceAreaFee;
                                }
                                outServiceAreaFee = TotalMoney - SettlementMoney;
                                Logger.Info("订单: " + orderNum + ",加收调度费值:" + serviceFee + ",加收调度费金额:" + outServiceAreaFee);
                            }
                        }
                        #endregion

                        #region 判断还车点是否在停车点内,否则加收费用
                        string returnVehicleMode = settingManager.GetValueByKey("ReturnVehicleMode");
                        if (TotalMoney > 0 && outServiceAreaFee == 0 && returnVehicleMode == "1")
                        {
                            returnLocType = "01";
                            DataTable parking_dt = areaManager.GetNearestParkingsByCity(vehicle_pt.longitude.ToString(), vehicle_pt.latitude.ToString(), cityId);
                            if (parking_dt != null)
                            {
                                //bool isInPoly = false;
                                bool isInPoly2 = false;//用户坐标是否在区域内
                                foreach (DataRow dr in parking_dt.Rows)
                                {
                                    List <LatLng> parking_pts = new List <LatLng>();
                                    returnParkingID = dr["ID"].ToString();
                                    coordinates     = dr["Coordinates"].ToString();
                                    foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                                    {
                                        string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                                        LatLng   pt     = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0]));
                                        parking_pts.Add(pt);
                                    }
                                    isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, parking_pts);
                                    if (!string.IsNullOrEmpty(userLng) && !string.IsNullOrEmpty(userLat))
                                    {
                                        LatLng user_pt = new LatLng(double.Parse(userLat), double.Parse(userLng));
                                        isInPoly2 = SiteHelper.IsPtInPoly(user_pt, parking_pts);
                                    }

                                    string vehicleInArea = isInPoly ? "在停车点内还车" : "在停车点外还车";
                                    string userInArea    = isInPoly2 ? "用户在停车点内" : "用户在停车点外";
                                    Logger.Info("用户:" + uid + ",订单:" + orderNum + "," + vehicleInArea + ",车辆GPS坐标:" + longitude + "," + latitude + ",高德坐标:" + vehicle_pt.longitude + "," + vehicle_pt.latitude + ",用户高德坐标:" + userLng + "," + userLat + "," + userInArea);
                                    if (isInPoly || isInPoly2)
                                    {
                                        break;
                                    }
                                }
                                if (!isInPoly && !isInPoly2)
                                {
                                    returnLocType   = "02";
                                    returnParkingID = null;
                                    string serviceFee = settingManager.GetValueByKey("OutParkingAreaFee");
                                    if (serviceFee.StartsWith("+"))
                                    {
                                        serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                        decimal.TryParse(serviceFee, out outServiceAreaFee);
                                        TotalMoney = TotalMoney + outServiceAreaFee;
                                    }
                                    else
                                    {
                                        serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                        decimal.TryParse(serviceFee, out outServiceAreaFee);
                                        TotalMoney = TotalMoney * outServiceAreaFee;
                                    }
                                    outServiceAreaFee = TotalMoney - SettlementMoney;
                                    Logger.Info("用户:" + uid + ",订单:" + orderNum + "加收调度费值:" + serviceFee + ",加收调度费金额:" + outServiceAreaFee);
                                }
                            }
                        }
                        #endregion

                        payMoney = TotalMoney;
                        Hashtable userParm = new Hashtable();
                        userParm["VID"]               = SiteHelper.GetHashTableValueByKey(order, "VID");
                        userParm["OrderNum"]          = SiteHelper.GetHashTableValueByKey(order, "OrderNum");
                        userParm["TotalMoney"]        = TotalMoney;
                        userParm["SettlementMoney"]   = SettlementMoney;
                        userParm["PayMoney"]          = payMoney;
                        userParm["PayTime"]           = SiteHelper.GetWebServerCurrentTime().ToString();
                        userParm["EndTime"]           = SiteHelper.GetWebServerCurrentTime().ToString();
                        userParm["FinishedTime"]      = SiteHelper.GetWebServerCurrentTime().ToString();
                        userParm["OID"]               = SiteHelper.GetHashTableValueByKey(order, "orderid");
                        userParm["ChangesAmount"]     = -Math.Abs(TotalMoney);
                        userParm["UserFinancialID"]   = CommonHelper.GetGuid;
                        userParm["UserID"]            = uid;
                        userParm["ChangesTime"]       = SiteHelper.GetWebServerCurrentTime().ToString();
                        userParm["ChangesType"]       = UserFinancialChangesType.Consumption.GetHashCode().ToString();
                        userParm["OrderID"]           = SiteHelper.GetHashTableValueByKey(order, "orderid");
                        userParm["RentDuration"]      = hours;
                        userParm["Remark"]            = "用户还车";
                        userParm["Minutes"]           = minutes;
                        userParm["DiffMoney"]         = TotalMoney;
                        userParm["Operator"]          = "";
                        userParm["OperatorType"]      = UserFinancialOperatorType.Admin.GetHashCode().ToString();
                        userParm["State"]             = UserFinancialState.Effect.GetHashCode().ToString();
                        userParm["MessageID"]         = CommonHelper.GetGuid;
                        userParm["OutServiceAreaFee"] = (int)outServiceAreaFee;
                        userParm["ReturnParkingID"]   = returnParkingID;
                        userParm["ReturnLocType"]     = returnLocType;
                        if (cache != null)
                        {
                            cache.Dispose();
                        }
                        bool isSettlementSuccess = uim.ReturnVehicle(userParm);
                        if (isSettlementSuccess)
                        {
                            om.UpdateOrderGPS(SiteHelper.GetHashTableValueByKey(order, "orderid"), false);
                            Hashtable ht = om.GetOrderByNum(SiteHelper.GetHashTableValueByKey(order, "OrderNum"));
                            return(SiteHelper.GetJsonFromHashTable(ht, "success", "还车成功", "OrderInfo"));
                        }
                        else
                        {
                            return(SiteHelper.GetJsonFromHashTable(null, "faild", "还车失败,请联系管理员"));
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null ||
                res["VehicleID"] == null ||
                res["UID"].ToString().Trim().Length <= 0 ||
                res["VehicleID"].ToString().Trim().Length <= 0)
            {
                return(SiteHelper.GetJsonFromHashTable(null, "faild", "参数不完整"));
            }
            else
            {
                uid       = res["UID"].ToString().Trim();
                vehicleid = res["VehicleID"].ToString().Trim();
                VehicleManager    vm             = new VehicleManager();
                OrdersManager     om             = new OrdersManager();
                UserInfoManager   uim            = new UserInfoManager();
                SysSettingManager settingManager = new SysSettingManager();
                Hashtable         vehicle        = vm.GetVehicleInfoByID(vehicleid);
                if (vehicle == null || vehicle.Keys.Count == 0)
                {
                    //根据车牌号码查询车辆信息
                    vehicle = vm.GetVehicleInfoByLicenseNumber(vehicleid);
                }
                //判断车辆是否存在
                if (vehicle == null || vehicle.Keys.Count == 0)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆预约失败,未找到车辆相关信息"));
                }

                vehicleid = SiteHelper.GetHashTableValueByKey(vehicle, "ID");
                //判断预约车辆是否离线
                DateTime lastUpdateTime;
                if (string.IsNullOrEmpty(SiteHelper.GetHashTableValueByKey(vehicle, "LastUpdateTime")))
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "当前车辆已离线无法约车"));
                }
                else
                {
                    lastUpdateTime = DateTime.Parse(SiteHelper.GetHashTableValueByKey(vehicle, "LastUpdateTime"));
                    if (SiteHelper.ExecDateDiff(lastUpdateTime, DateTime.Now) > 10)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "当前车辆已离线无法约车"));
                    }
                }

                //判断预约车辆电量值
                double electricity = 0.00;
                double.TryParse(SiteHelper.GetHashTableValueByKey(vehicle, "Electricity"), out electricity);
                if (electricity < 30)
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "当前车辆电量过低无法约车"));
                }

                #region 判断车辆是否在运营区域内
                ServiceAreaManager areaManager = new ServiceAreaManager();
                Hashtable          area_ht     = areaManager.GetServiceAreaByVehicleID(vehicleid);
                if (area_ht != null && area_ht.Keys.Count > 0)
                {
                    List <LatLng> area_pts    = new List <LatLng>();
                    string        coordinates = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates");
                    foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                    {
                        string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                        LatLng   pt     = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0]));
                        area_pts.Add(pt);
                    }
                    string longitude  = SiteHelper.GetHashTableValueByKey(vehicle, "longitude");
                    string latitude   = SiteHelper.GetHashTableValueByKey(vehicle, "latitude");
                    LatLng vehicle_pt = new LatLng(double.Parse(latitude), double.Parse(longitude));
                    //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt);
                    vehicle_pt = SiteHelper.GPSToGCJ02(longitude, latitude);
                    vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6), Math.Round(vehicle_pt.longitude, 6));
                    bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, area_pts);
                    if (!isInPoly)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆预约失败,车辆处于运营区域外"));
                    }
                }
                #endregion

                #region 判断车辆是否在停车点内

                /*string returnVehicleMode = settingManager.GetValueByKey("ReturnVehicleMode");
                 * Hashtable parking_ht = areaManager.GetNearestParking(SiteHelper.GetHashTableValueByKey(vehicle, "longitude"), SiteHelper.GetHashTableValueByKey(vehicle, "latitude"), vehicleid);
                 * if (returnVehicleMode == "1" && parking_ht != null && parking_ht.Keys.Count > 0)
                 * {
                 *  List<LatLng> parking_pts = new List<LatLng>();
                 *  string coordinates = SiteHelper.GetHashTableValueByKey(parking_ht, "Coordinates");
                 *  foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                 *  {
                 *      string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                 *      LatLng pt = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0]));
                 *      parking_pts.Add(pt);
                 *  }
                 *  string longitude = SiteHelper.GetHashTableValueByKey(vehicle, "longitude");
                 *  string latitude = SiteHelper.GetHashTableValueByKey(vehicle, "latitude");
                 *  LatLng vehicle_pt = new LatLng(double.Parse(latitude),double.Parse(longitude));
                 *  //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt);
                 *  vehicle_pt = SiteHelper.GPSToGCJ02(longitude,latitude);
                 *  vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6),Math.Round(vehicle_pt.longitude, 6));
                 *  bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, parking_pts);
                 *  if (!isInPoly)
                 *  {
                 *      return SiteHelper.GetJsonFromHashTable(null, "faild", "车辆预约失败,车辆处于停车网点外");
                 *  }
                 * }*/
                #endregion

                //判断车辆是否可用
                if (SiteHelper.GetHashTableValueByKey(vehicle, "UseState").Trim() == VehicleUseState.Free.GetHashCode().ToString() && SiteHelper.GetHashTableValueByKey(vehicle, "VehicleState").Trim() == VehicleState.Use.GetHashCode().ToString())
                {
                    //判断用户余额是否充足
                    Hashtable user = uim.GetUserInfoByUserID(uid);
                    if (user == null || user.Keys.Count <= 0)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "您不是有效会员"));
                    }
                    else
                    {
                        if ("2".CompareTo(user["REALNAMECERTIFICATION"].ToString()) == 0)
                        {
                            return(SiteHelper.GetJsonFromHashTable(null, "faild", "当前认证正在审核中,请耐心等待"));
                        }
                        //验证用户是否经过身份认证
                        if ("4".CompareTo(user["REALNAMECERTIFICATION"].ToString()) != 0)
                        {
                            return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前未完成实名认证,请完成实名认证后重试"));
                        }
                        //验证用户状态是否有效
                        if ("0".CompareTo(user["USERSTATE"].ToString()) == 0)
                        {
                            return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前已被禁用无法预约车辆,如有问题请与客服联系"));
                        }

                        //判断用户是否缴纳押金
                        decimal deposit = 0.00m;
                        decimal.TryParse(user["DEPOSIT"].ToString(), out deposit);
                        if (user["USERTYPE"].ToString() != UserType.OffDepositUser.GetHashCode().ToString() && deposit <= 0.00m)
                        {
                            return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前未缴纳用车押金,请完成押金缴纳后重试"));
                        }
                    }

                    //判断用户是否存在未支付订单
                    if (om.IsExistUnPayOrderByUser(uid))
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前有未支付订单,请完成支付后重试"));
                    }

                    //判断会员是否有条件预约
                    bool isExist = om.IsExistVehicleOrderByUser(uid);
                    if (isExist)
                    {
                        return(SiteHelper.GetJsonFromHashTable(null, "faild", "您已经预约过车辆了"));
                    }
                    else
                    {
                        //如果是扫码用车
                        if (res["isopen"] != null && res["isopen"].ToString() == "1")
                        {
                            string gpsnum = SiteHelper.GetHashTableValueByKey(vehicle, "VehicleGPSNum");
                            //开车
                            bool isOpen = vm.OpenVehicle(vehicleid);
                            if (!isOpen)//开车失败
                            {
                                return(SiteHelper.GetJsonFromHashTable(null, "faild", "非常抱歉,由于车辆启动失败本次扫码用车失败,请选择其他车辆或稍后重试"));
                            }
                            else//开车成功
                            {
                                string orderID  = string.Empty;
                                string orderNum = string.Empty;
                                //提交订单
                                bool isSuccess = OrderVehicle(res, vehicle, user, out orderID, out orderNum);
                                if (!isSuccess)
                                {
                                    isOpen = vm.CloseVehicle(vehicleid);
                                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆预约失败,请联系管理员"));
                                }
                                else
                                {
                                    return(SiteHelper.GetJsonFromHashTable(null, "success", "车辆预约成功并已开启,欢迎驾驶电斑马"));
                                }
                            }
                        }
                        else //不是扫码用车
                        {
                            string orderID  = string.Empty;
                            string orderNum = string.Empty;
                            //提交订单
                            bool isSuccess = OrderVehicle(res, vehicle, user, out orderID, out orderNum);
                            if (isSuccess)
                            {
                                return(SiteHelper.GetJsonFromHashTable(null, "success", "车辆预约成功"));
                            }
                            else
                            {
                                return(SiteHelper.GetJsonFromHashTable(null, "faild", "车辆预约失败,请联系管理员"));
                            }
                        }
                    }
                }
                else
                {
                    return(SiteHelper.GetJsonFromHashTable(null, "faild", "预约失败,车辆不允许预约"));
                }
            }
        }
Exemplo n.º 6
0
        public string Execute(Hashtable params_ht)
        {
            Hashtable res = params_ht;

            if (res["UID"] == null || res["VID"] == null || res["Opr"] == null || res["UID"].ToString().Trim().Length <= 0 || res["VID"].ToString().Trim().Length <= 0 || res["Opr"].ToString().Trim().Length <= 0)
            {
                Hashtable result = new Hashtable();
                result["ErrCode"] = "00";//服务器异常
                return(SiteHelper.GetJsonFromHashTable(result, "faild", "参数不完整"));
            }
            else
            {
                uid = res["UID"].ToString().Trim();
                vid = res["VID"].ToString().Trim();
                //opr,0:开1:关
                opr = res["Opr"].ToString().Trim();
                VehicleManager vm = new VehicleManager();
                Hashtable      ht = vm.GetVehicleInfoByID(vid);
                if (ht == null)
                {
                    Hashtable result = new Hashtable();
                    result["ErrCode"] = "01";//车辆未找到
                    return(SiteHelper.GetJsonFromHashTable(result, "faild", "未找到相关车辆信息"));
                }
                else
                {
                    //客户占用车辆时禁止操作
                    if (ht["USESTATE"].ToString() == VehicleUseState.Order.GetHashCode().ToString() || ht["USESTATE"].ToString() == VehicleUseState.Reservation.GetHashCode().ToString())
                    {
                        Hashtable result = new Hashtable();
                        result["ErrCode"] = "02";//车辆已被占用
                        return(SiteHelper.GetJsonFromHashTable(result, "faild", "指令发送失败,车辆已被客户占用"));
                    }

                    string gpsnum    = SiteHelper.GetHashTableValueByKey(ht, "VehicleGPSNum");
                    bool   isSuccess = false;
                    if (opr == "0")
                    {
                        isSuccess = vm.OpenVehicle(vid);
                    }
                    else
                    {
                        isSuccess = vm.CloseVehicle(vid);
                    }
                    if (!isSuccess)
                    {
                        Hashtable result = new Hashtable();
                        result["ErrCode"] = "04";//指令发送失败
                        return(SiteHelper.GetJsonFromHashTable(result, "faild", "指令发送失败"));
                    }
                    else
                    {
                        Hashtable vht = new Hashtable();
                        vht["ID"]       = vid;
                        vht["UseState"] = opr == "0" ? 4 : 1;
                        vm.AddOrEditVehicleInfo(vht, vid);

                        OPUserManager hum           = new OPUserManager();
                        Hashtable     userOperateHT = new Hashtable();
                        userOperateHT["ID"]              = CommonHelper.GetGuid;
                        userOperateHT["VehicleID"]       = vid;
                        userOperateHT["UserID"]          = uid;
                        userOperateHT["OperateType"]     = opr == "0" ? 1 : 2;
                        userOperateHT["OperateTypeText"] = opr == "0" ? "开车" : "锁车";
                        userOperateHT["Remark"]          = "";
                        userOperateHT["OperateTime"]     = SiteHelper.GetWebServerCurrentTime();
                        hum.AddUserOperate(userOperateHT);

                        return(SiteHelper.GetJsonFromHashTable(null, "success", "指令发送成功"));
                    }
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 还车
        /// </summary>
        /// <param name="order_no"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        private bool ReturnVehicle(string order_no, out string errmsg)
        {
            BaoJiaManager mgr = new BaoJiaManager();

            VehicleManager     vm             = new VehicleManager();
            ServiceAreaManager areaManager    = new ServiceAreaManager();
            SysSettingManager  settingManager = new SysSettingManager();
            Hashtable          order          = mgr.GetOrderInfo(order_no);

            //判断是否有车
            if (order == null)
            {
                errmsg = "未找到相关订单";
                return(false);
            }
            else
            {
                string    vid        = SiteHelper.GetHashTableValueByKey(order, "VehicleID");
                Hashtable vehicle_ht = vm.GetVehicleInfoByID(vid);
                string    longitude  = SiteHelper.GetHashTableValueByKey(vehicle_ht, "Longitude");
                string    latitude   = SiteHelper.GetHashTableValueByKey(vehicle_ht, "Latitude");

                //处理订单
                string order_state = SiteHelper.GetHashTableValueByKey(order, "OrderState");
                if (order_state != "1")
                {
                    errmsg = "订单当前所在状态无法还车";
                    return(false);
                }
                else
                {
                    int renttime = 0;
                    int.TryParse(SiteHelper.GetHashTableValueByKey(order, "RentDuration"), out renttime);
                    decimal  hours = 0.00m;
                    decimal  kmprice = 0.80m;
                    decimal  minuteprice = 0.40m;
                    decimal  mileage = 0;
                    int      minutes = 0;
                    decimal  userprivilegeratio = 1;
                    decimal  raisecommisssionratio = 0.10m;
                    decimal  TotalMoney = 0.00m;
                    decimal  SettlementMoney = 0.00m;
                    decimal  occupyMoney = 0.0m;
                    decimal  payMoney = 0.00m;
                    decimal  RaiseCommissionMoney = 0.00m;
                    decimal  outServiceAreaFee = 0.00m;
                    DateTime createtime = DateTime.Now;
                    DateTime startTime = DateTime.Now;
                    String   returnParkingID = null, returnLocType = null;
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "KMPrice"), out kmprice);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "MinutePrice"), out minuteprice);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "Mileage"), out mileage);
                    //decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "Minutes"), out minutes);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "UserPrivilegeRatio"), out userprivilegeratio);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "RaiseCommissionRatio"), out raisecommisssionratio);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "TotalMoney"), out TotalMoney);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "SettlementMoney"), out SettlementMoney);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "OccupyMoney"), out occupyMoney);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(order, "RaiseCommissionMoney"), out RaiseCommissionMoney);
                    DateTime.TryParse(SiteHelper.GetHashTableValueByKey(order, "CreateTime"), out createtime);
                    DateTime.TryParse(SiteHelper.GetHashTableValueByKey(order, "StartTime"), out startTime);
                    int startminutes = 0;
                    int.TryParse(SiteHelper.GetHashTableValueByKey(order, "StartMinutes"), out startminutes);
                    string strStartTime = SiteHelper.GetHashTableValueByKey(order, "StartTime");

                    string gpsnum = SiteHelper.GetHashTableValueByKey(order, "VehicleGPSNum");
                    //锁车
                    bool isSuccess = vm.CloseVehicle(SiteHelper.GetHashTableValueByKey(order, "VehicleID"));
                    if (!isSuccess)
                    {
                        errmsg = "锁车失败,还车操作失败";
                        return(false);
                    }
                    VehiclePriceManager priceManager = new VehiclePriceManager();
                    Hashtable           billing_ht   = priceManager.GetOrderSettlement(SiteHelper.GetHashTableValueByKey(order, "ID"));
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "MinutePrice"), out minuteprice);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "KmPrice"), out kmprice);
                    int.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "Minutes"), out minutes);
                    decimal.TryParse(SiteHelper.GetHashTableValueByKey(billing_ht, "TotalMoney"), out TotalMoney);

                    SettlementMoney = TotalMoney;

                    #region 判断还车点是否在运营区域内,运营区域外加收费用
                    Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(SiteHelper.GetHashTableValueByKey(order, "VehicleID"));
                    if (area_ht != null && area_ht.Keys.Count > 0)
                    {
                        returnLocType = "03";
                        List <LatLng> area_pts    = new List <LatLng>();
                        string        coordinates = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates");
                        foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                        {
                            string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                            LatLng   pt     = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0]));
                            area_pts.Add(pt);
                        }
                        LatLng vehicle_pt = new LatLng(double.Parse(latitude), double.Parse(longitude));
                        //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt);
                        vehicle_pt = SiteHelper.GPSToGCJ02(longitude, latitude);
                        vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6), Math.Round(vehicle_pt.longitude, 6));
                        bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, area_pts);
                        if (!isInPoly)
                        {
                            returnLocType = "04";
                            string serviceFee = settingManager.GetValueByKey("OutServiceAreaFee");
                            if (serviceFee.StartsWith("+"))
                            {
                                serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                decimal.TryParse(serviceFee, out outServiceAreaFee);
                                TotalMoney = TotalMoney + outServiceAreaFee;
                            }
                            else
                            {
                                serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                decimal.TryParse(serviceFee, out outServiceAreaFee);
                                TotalMoney = TotalMoney * outServiceAreaFee;
                            }
                            outServiceAreaFee = TotalMoney - SettlementMoney;
                        }
                    }
                    #endregion

                    #region 判断还车点是否在停车点内,否则加收费用
                    string returnVehicleMode = settingManager.GetValueByKey("ReturnVehicleMode");
                    if (outServiceAreaFee == 0 && returnVehicleMode == "1")
                    {
                        returnLocType = "01";
                        LatLng vehicle_pt = new LatLng(double.Parse(latitude), double.Parse(longitude));
                        //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt);
                        vehicle_pt = SiteHelper.GPSToGCJ02(longitude, latitude);
                        vehicle_pt = new LatLng(Math.Round(vehicle_pt.latitude, 6), Math.Round(vehicle_pt.longitude, 6));
                        Hashtable parking_ht = areaManager.GetNearestParking(vehicle_pt.longitude.ToString(), vehicle_pt.latitude.ToString(), SiteHelper.GetHashTableValueByKey(order, "VehicleID"));

                        List <LatLng> parking_pts = new List <LatLng>();
                        if (parking_ht != null && parking_ht.Keys.Count > 0)
                        {
                            returnParkingID = SiteHelper.GetHashTableValueByKey(parking_ht, "ID");
                            string coordinates = SiteHelper.GetHashTableValueByKey(parking_ht, "Coordinates");
                            foreach (string str in coordinates.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
                            {
                                string[] pt_arr = str.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                                LatLng   pt     = new LatLng(double.Parse(pt_arr[1]), double.Parse(pt_arr[0]));
                                parking_pts.Add(pt);
                            }
                        }

                        bool isInPoly = SiteHelper.IsPtInPoly(vehicle_pt, parking_pts);
                        if (!isInPoly)
                        {
                            returnLocType   = "02";
                            returnParkingID = null;
                            string serviceFee = settingManager.GetValueByKey("OutParkingAreaFee");
                            if (serviceFee.StartsWith("+"))
                            {
                                serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                decimal.TryParse(serviceFee, out outServiceAreaFee);
                                TotalMoney = TotalMoney + outServiceAreaFee;
                            }
                            else
                            {
                                serviceFee = serviceFee.Substring(1, serviceFee.Length - 1);
                                decimal.TryParse(serviceFee, out outServiceAreaFee);
                                TotalMoney = TotalMoney * outServiceAreaFee;
                            }
                            outServiceAreaFee = TotalMoney - SettlementMoney;
                        }
                    }
                    #endregion

                    payMoney = TotalMoney;

                    Hashtable userParm = new Hashtable();
                    userParm["VID"]               = SiteHelper.GetHashTableValueByKey(order, "VehicleID");
                    userParm["OrderNum"]          = SiteHelper.GetHashTableValueByKey(order, "OrderNum");
                    userParm["TotalMoney"]        = TotalMoney;
                    userParm["SettlementMoney"]   = SettlementMoney;
                    userParm["PayMoney"]          = payMoney;
                    userParm["PayTime"]           = SiteHelper.GetWebServerCurrentTime().ToString();
                    userParm["EndTime"]           = SiteHelper.GetWebServerCurrentTime().ToString();
                    userParm["FinishedTime"]      = SiteHelper.GetWebServerCurrentTime().ToString();
                    userParm["OID"]               = SiteHelper.GetHashTableValueByKey(order, "id");
                    userParm["ChangesAmount"]     = -Math.Abs(TotalMoney);
                    userParm["UserFinancialID"]   = CommonHelper.GetGuid;
                    userParm["UserID"]            = null;
                    userParm["ChangesTime"]       = SiteHelper.GetWebServerCurrentTime().ToString();
                    userParm["ChangesType"]       = UserFinancialChangesType.Consumption.GetHashCode().ToString();
                    userParm["OrderID"]           = SiteHelper.GetHashTableValueByKey(order, "id");
                    userParm["RentDuration"]      = hours;
                    userParm["Remark"]            = "用户还车";
                    userParm["Minutes"]           = minutes;
                    userParm["DiffMoney"]         = TotalMoney;
                    userParm["Operator"]          = "";
                    userParm["OperatorType"]      = UserFinancialOperatorType.Admin.GetHashCode().ToString();
                    userParm["State"]             = UserFinancialState.Effect.GetHashCode().ToString();
                    userParm["MessageID"]         = CommonHelper.GetGuid;
                    userParm["OutServiceAreaFee"] = (int)outServiceAreaFee;
                    userParm["ReturnParkingID"]   = returnParkingID;
                    userParm["ReturnLocType"]     = returnLocType;

                    bool isSettlementSuccess = mgr.ReturnVehicle(userParm);
                    if (isSettlementSuccess)
                    {
                        OrdersManager om = new OrdersManager();
                        om.UpdateOrderGPS(SiteHelper.GetHashTableValueByKey(order, "id"), false);
                        errmsg = "还车成功";
                        return(true);
                    }
                    else
                    {
                        errmsg = "锁车操作失败";
                        return(false);
                    }
                }
            }
        }
Exemplo n.º 8
0
        public void Execute(IJobExecutionContext context)
        {
            //ICache Cache = null;
            try
            {
                foreach (string saas in ConfigHelper.GetSaasList())
                {
                    try
                    {
                        MyWorkerRequest.CreateHttpContext(saas, "", "");
                        //Cache = CacheFactory.GetCache();
                        VehicleManager vm = new VehicleManager();
                        DataTable      dt = vm.GetNoOrderUnlockVehicles();
                        foreach (DataRow row in dt.Rows)
                        {
                            string vid   = row["ID"].ToString();
                            string name  = row["Name"].ToString();
                            string carId = row["VehicleGPSNum"].ToString();

                            /*string keyid = "vehicle_" + carId;
                             * string json_car=Cache.Get<string>(keyid);
                             * string acc = "";
                             * if (!string.IsNullOrEmpty(json_car))
                             * {
                             *  dynamic jsonObj = DynamicJson.Parse(json_car);
                             *  if (jsonObj.IsDefined("data"))
                             *  {
                             *      foreach (var item in jsonObj.data)
                             *      {
                             *          if (item.IsDefined("acc"))
                             *              acc = item.acc;
                             *      }
                             *  }
                             * }*/

                            double speed = 0.00;
                            double.TryParse(row["CurrentSpeed"].ToString(), out speed);
                            //if (acc =="1"){
                            if (vm.CloseVehicle(vid))
                            {
                                Logger.Info("无单锁车成功,车辆号:" + name);
                            }
                            else
                            {
                                Logger.Info("无单锁车失败,车辆号:" + name);
                            }
                            //}
                        }
                        //Cache.Dispose();
                    }
                    catch
                    {
                        /*if (Cache != null)
                         * {
                         *  Cache.Dispose();
                         * }*/
                        continue;
                    }
                }
            }
            catch
            {
                /*if (Cache != null)
                 * {
                 *  Cache.Dispose();
                 * }*/
                Logger.Info("无单车进行断电锁车(NoOrderLock)失败");
            }
        }
Exemplo n.º 9
0
        public ApiResp Execute(System.Collections.Hashtable params_ht)
        {
            ApiResp resp = new ApiResp();

            resp.code = "-1";

            string client_id = params_ht["client_id"].ToString();
            long   timestamp = long.Parse(params_ht["timestamp"].ToString());
            string sign      = params_ht["sign"].ToString();
            string plate_no  = params_ht["plate_no"].ToString();
            string order_no  = params_ht["order_no"].ToString();
            int    op_type   = int.Parse(params_ht["op_type"].ToString());

            bool          result   = false;
            OrdersManager om       = new OrdersManager();
            BaoJiaManager mgr      = new BaoJiaManager();
            Hashtable     order_ht = mgr.GetOrderInfo(order_no);

            if (order_ht != null && order_ht.Keys.Count > 0)
            {
                string         order_state = SiteHelper.GetHashTableValueByKey(order_ht, "OrderState");
                string         vid         = SiteHelper.GetHashTableValueByKey(order_ht, "VehicleID");
                VehicleManager vm          = new VehicleManager();
                if (order_state == "1")
                {
                    switch (op_type)
                    {
                    case 1:
                        result = vm.OpenVehicle(vid);
                        //如果是首次开车订单StartTime设为当前时间
                        if (result && string.IsNullOrEmpty(order_ht["STARTTIME"].ToString()))
                        {
                            mgr.SetCurrentOrderStartTime(order_ht["ID"].ToString());
                            om.UpdateOrderGPS(order_ht["ID"].ToString(), true);
                        }
                        break;

                    case 2:
                        result = vm.CloseVehicle(vid);
                        break;

                    case 3:
                        result = vm.FindVehicle(vid);
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                resp.code = "-1";
                resp.msg  = "未找到相关订单";
            }

            if (result)
            {
                resp.code = "0";
                resp.msg  = "成功";
            }
            else
            {
                resp.code = "-1";
                resp.msg  = "失败";
            }

            return(resp);
        }