private GetBatchOrderState_Item GetOrderState(string order_no) { BaoJiaManager mgr = new BaoJiaManager(); Hashtable ht = mgr.GetOrderInfo(order_no); if (ht == null) { return(null); } else { GetBatchOrderState_Item data = new GetBatchOrderState_Item(); decimal kmprice = 0.80m, minuteprice = 0.40m, mileage = 0, TotalMoney = 0.00m, SettlementMoney = 0.00m, outServiceAreaFee = 0.00m; int minutes = 0; string returnLocType = ""; ServiceAreaManager areaManager = new ServiceAreaManager(); SysSettingManager settingManager = new SysSettingManager(); VehiclePriceManager priceManager = new VehiclePriceManager(); Hashtable billing_ht = priceManager.GetOrderSettlement(SiteHelper.GetHashTableValueByKey(ht, "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); decimal.TryParse(SiteHelper.GetHashTableValueByKey(ht, "SettlementMoney"), out SettlementMoney); returnLocType = SiteHelper.GetHashTableValueByKey(ht, "ReturnLocType"); decimal.TryParse(SiteHelper.GetHashTableValueByKey(ht, "OutServiceAreaFee"), out outServiceAreaFee); string orderState = SiteHelper.GetHashTableValueByKey(ht, "OrderState"); if (orderState == "1") { SettlementMoney = TotalMoney; VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByIDORNumber(SiteHelper.GetHashTableValueByKey(ht, "VehicleID")); string lat = vehicle_ht["LATITUDE"].ToString(); string lng = vehicle_ht["LONGITUDE"].ToString(); #region 判断还车点是否在运营区域内,运营区域外加收费用 Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(SiteHelper.GetHashTableValueByKey(ht, "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(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); 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(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); 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(ht, "VehicleID")); List <LatLng> parking_pts = new List <LatLng>(); if (parking_ht != null && parking_ht.Keys.Count > 0) { 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"; 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 } data.order_no = order_no; data.amount = (double)(SettlementMoney + outServiceAreaFee);; data.order_status = 10000; if (orderState == "1") { data.order_status = 10000; } else if (orderState == "0") { data.order_status = 10301; } else if (orderState == "2" || orderState == "5" || orderState == "3") { data.order_status = 80200; } data.timestamp = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds; return(data); } }
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", "还车失败,请联系管理员")); } } } } }
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(); GetFeeData data = new GetFeeData(); BaoJiaManager mgr = new BaoJiaManager(); Hashtable ht = mgr.GetOrderInfo(order_no); if (ht == null) { resp.msg = "未找到相关订单"; resp.code = "-1"; } else { decimal kmprice = 0.80m, minuteprice = 0.40m, mileage = 0, TotalMoney = 0.00m, SettlementMoney = 0.00m, outServiceAreaFee = 0.00m; int minutes = 0; string returnLocType = "", lng = "0", lat = "0"; ServiceAreaManager areaManager = new ServiceAreaManager(); SysSettingManager settingManager = new SysSettingManager(); VehiclePriceManager priceManager = new VehiclePriceManager(); Hashtable billing_ht = priceManager.GetOrderSettlement(SiteHelper.GetHashTableValueByKey(ht, "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); decimal.TryParse(SiteHelper.GetHashTableValueByKey(ht, "SettlementMoney"), out SettlementMoney); returnLocType = SiteHelper.GetHashTableValueByKey(ht, "ReturnLocType"); decimal.TryParse(SiteHelper.GetHashTableValueByKey(ht, "OutServiceAreaFee"), out outServiceAreaFee); string orderState = SiteHelper.GetHashTableValueByKey(ht, "OrderState"); VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByIDORNumber(SiteHelper.GetHashTableValueByKey(ht, "VehicleID")); lat = vehicle_ht["LATITUDE"].ToString(); lng = vehicle_ht["LONGITUDE"].ToString(); if (orderState == "1") { SettlementMoney = TotalMoney; #region 判断还车点是否在运营区域内,运营区域外加收费用 Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(SiteHelper.GetHashTableValueByKey(ht, "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(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); 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(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); 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(ht, "VehicleID")); List <LatLng> parking_pts = new List <LatLng>(); if (parking_ht != null && parking_ht.Keys.Count > 0) { 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"; 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 } SettlementMoney = Math.Round(SettlementMoney, 2); data.order_no = order_no; data.all_mile = double.Parse(SiteHelper.GetHashTableValueByKey(ht, "Mileage")); data.location_address_type = "3"; if (returnLocType == "01") { data.location_address_type = "3"; } if (returnLocType == "02" || returnLocType == "03") { data.location_address_type = "1"; } if (returnLocType == "04") { data.location_address_type = "2"; } data.location_address_msg = ""; data.order_status = 10000; if (orderState == "1") { data.order_status = 10000; } else if (orderState == "0") { data.order_status = 10301; } else if (orderState == "2" || orderState == "5" || orderState == "3") { data.order_status = 80200; } data.total_fee = (double)(SettlementMoney + outServiceAreaFee); data.timestamp = (long)(DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalSeconds; data.lng = double.Parse(lng); data.lat = double.Parse(lat); data.details = new List <GetFeeData_Fee>(); GetFeeData_Fee item1 = new GetFeeData_Fee(); item1.name = "用车费用"; item1.amount = (double)SettlementMoney; data.details.Add(item1); if (returnLocType == "04") { GetFeeData_Fee item2 = new GetFeeData_Fee(); item2.name = "行驶区域外还车调度费"; item2.amount = (double)(outServiceAreaFee); data.details.Add(item2); } if (returnLocType == "02") { GetFeeData_Fee item3 = new GetFeeData_Fee(); item3.name = "停车点外还车调度费"; item3.amount = (double)(outServiceAreaFee); data.details.Add(item3); } data.isLock = "1"; int cnt = -1; DataTable parking_dt = areaManager.GetNearParking(9999, lng.ToString(), lat.ToString(), 1, 9999, ref cnt); if (parking_dt != null && parking_dt.Rows.Count > 0) { List <GetFeeData_StationItem> station_list = new List <GetFeeData_StationItem>(); foreach (DataRow dr in parking_dt.Rows) { GetFeeData_StationItem station = new GetFeeData_StationItem(); station.parkType = "2"; station.coordinatePoints = dr["Coordinates"].ToString().Replace(";", "|"); station.coordinate_center = dr["Longitude"].ToString() + "," + dr["Latitude"].ToString(); station_list.Add(station); } data.stationList = station_list; } resp.data = data; resp.code = "0"; } return(resp); }
/// <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); } } } }
public string Execute(Hashtable params_ht) { try { 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(); Hashtable ht = om.GetUserCurrentOrderVehicle(uid); if (ht == null) { return(SiteHelper.GetJsonFromHashTable(null, "faild", "您当前没有预约车辆")); } else { cacheKey += uid; string orderCacheKey = cacheKey; ICache cache = CacheFactory.GetCache(); /*string result = cache.Get<string>(orderCacheKey); * if (!string.IsNullOrEmpty(result)) * { * if (cache != null) * { * cache.Dispose(); * } * Logger.Error("获取订单信息120秒内," + uid); * return result; * } * else * {*/ string lat = ht["LATITUDE"].ToString(); string lng = ht["LONGITUDE"].ToString(); if (!string.IsNullOrEmpty(lng) && !string.IsNullOrEmpty(lat)) { if (res["Client"] != null && "iOS" == res["Client"].ToString()) { LatLng ll = new LatLng(double.Parse(lat), double.Parse(lng)); ll = SiteHelper.TransformFromWGSToGCJ(ll); ht["LONGITUDE"] = ll.longitude; ht["LATITUDE"] = ll.latitude; } else { /*LatLng latlng = SiteHelper.GetBaiduByGPS(lat, lng); * if (latlng != null) * { * ht["LATITUDE"] = latlng.latitude; * ht["LONGITUDE"] = latlng.longitude; * if (ht["ADDRESS"].ToString().Length <= 0) * { * ht["ADDRESS"] = SiteHelper.GetLocationByGPS(ht["LATITUDE"].ToString(), ht["LONGITUDE"].ToString()); * } * }*/ LatLng ll = new LatLng(double.Parse(lat), double.Parse(lng)); ll = SiteHelper.TransformFromWGSToGCJ(ll); ht["LONGITUDE"] = ll.longitude; ht["LATITUDE"] = ll.latitude; ht["ADDRESS"] = SiteHelper.GetLocationByGPS(ht["LATITUDE"].ToString(), ht["LONGITUDE"].ToString(), "wgs84ll"); } } decimal kmprice = 0.80m, minuteprice = 0.40m, mileage = 0, TotalMoney = 0.00m, SettlementMoney = 0.00m, outServiceAreaFee = 0.00m; int minutes = 0; ServiceAreaManager areaManager = new ServiceAreaManager(); SysSettingManager settingManager = new SysSettingManager(); VehiclePriceManager priceManager = new VehiclePriceManager(); Hashtable billing_ht = priceManager.GetOrderSettlement(SiteHelper.GetHashTableValueByKey(ht, "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 判断还车点是否在运营区域内,运营区域外加收费用 string cityId = ht["CITYID"].ToString(); string serviceAreaKey = "Service_Area_" + cityId; string coordinates = cache.Get <string>(serviceAreaKey); if (string.IsNullOrEmpty(coordinates)) { Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(SiteHelper.GetHashTableValueByKey(ht, "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); } } } if (!string.IsNullOrEmpty(coordinates)) { List <LatLng> area_pts = new List <LatLng>(); 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(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); 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) { 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 (TotalMoney > 0 && outServiceAreaFee == 0 && returnVehicleMode == "1") { LatLng vehicle_pt = new LatLng(double.Parse(lat), double.Parse(lng)); //vehicle_pt = SiteHelper.TransformFromWGSToGCJ(vehicle_pt); vehicle_pt = SiteHelper.GPSToGCJ02(lng, lat); 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(ht, "VID")); * 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) * { * 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; * }*/ DataTable parking_dt = areaManager.GetNearestParkingsByCity(vehicle_pt.longitude.ToString(), vehicle_pt.latitude.ToString(), cityId); if (parking_dt != null) { bool isInPoly = false; foreach (DataRow dr in parking_dt.Rows) { List <LatLng> parking_pts = new List <LatLng>(); 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 (isInPoly) { break; } } if (!isInPoly) { 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 ht["MINUTES"] = minutes; ht["OUTSERVICEAREAFEE"] = (int)outServiceAreaFee; ht["TOTALMONEY"] = TotalMoney; //DateTime dt = DateTime.Now.AddSeconds(120); //cache.Set(orderCacheKey, SiteHelper.GetJsonFromHashTable(ht, "success", "获取数据成功", "OrderVehicle"), dt - DateTime.Now); if (cache != null) { cache.Dispose(); } return(SiteHelper.GetJsonFromHashTable(ht, "success", "获取数据成功", "OrderVehicle")); //} } } } catch (Exception e) { Logger.Error(e.StackTrace + e.Message); return(SiteHelper.GetJsonFromHashTable(null, "faild", "查询失败")); } }