예제 #1
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 order_no  = params_ht["order_no"].ToString();
            string mobile    = params_ht["mobile"].ToString();
            string money     = params_ht["money"].ToString();
            long   paytime   = long.Parse(params_ht["paytime"].ToString());

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

            if (order_ht != null && order_ht.Keys.Count > 0)
            {
                string pay_state = SiteHelper.GetHashTableValueByKey(order_ht, "PayState");
                if (pay_state == "0")
                {
                    Hashtable ht = new Hashtable();
                    ht["OrderNum"] = SiteHelper.GetHashTableValueByKey(order_ht, "OrderNum");
                    ht["TotalFee"] = money;
                    result         = mgr.OrderPayCallback(ht);
                }
            }
            else
            {
                resp.code = "-1";
                resp.msg  = "未找到相关订单";
            }

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

            return(resp);
        }
예제 #2
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);
        }
예제 #3
0
        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);
            }
        }
예제 #4
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);
                    }
                }
            }
        }
예제 #5
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 order_no  = params_ht["order_no"].ToString();

            BaoJiaManager mgr      = new BaoJiaManager();
            Hashtable     order_ht = mgr.GetOrderInfo(order_no);

            if (order_ht != null && order_ht.Keys.Count > 0)
            {
                ServiceAreaManager areaManager = new ServiceAreaManager();

                string vehicleid = SiteHelper.GetHashTableValueByKey(order_ht, "VehicleID");
                string orderid   = SiteHelper.GetHashTableValueByKey(order_ht, "ID");

                GetOrderTracks_Data data = new GetOrderTracks_Data();

                string returnLocType = SiteHelper.GetHashTableValueByKey(order_ht, "ReturnLocType");
                if (returnLocType == "01")
                {
                    data.return_location_address_type = "3";
                    data.return_location_address_msg  = "网点还车";

                    string toParking = SiteHelper.GetHashTableValueByKey(order_ht, "ToParking");
                    if (!string.IsNullOrEmpty(toParking))
                    {
                        Hashtable parking_ht = areaManager.GetInfoByID(toParking);
                        if (parking_ht != null && parking_ht.Keys.Count > 0)
                        {
                            data.return_station_points = SiteHelper.GetHashTableValueByKey(parking_ht, "Coordinates").Replace(";", "|");
                            data.return_station_center = SiteHelper.GetHashTableValueByKey(parking_ht, "Longitude") + "," + SiteHelper.GetHashTableValueByKey(parking_ht, "Latitude");
                        }
                    }
                }
                else if (returnLocType == "02" || returnLocType == "03")
                {
                    data.return_location_address_type = "1";
                    data.return_location_address_msg  = "行驶区域内网点外还车";
                }
                else if (returnLocType == "04")
                {
                    data.return_location_address_type = "2";
                    data.return_location_address_msg  = "行驶区域外还车";

                    Hashtable area_ht = areaManager.GetServiceAreaByVehicleID(vehicleid);
                    if (area_ht != null && area_ht.Keys.Count > 0)
                    {
                        data.return_xianzhi_points = SiteHelper.GetHashTableValueByKey(area_ht, "Coordinates").Replace(";", "|");
                    }
                }

                VehicleManager vm = new VehicleManager();
                DataTable      dt = vm.GetVehicleTrace(vehicleid, orderid, null, null);
                if (dt != null)
                {
                    GetOrderTracks_Data Data = new GetOrderTracks_Data();

                    data.return_location_address_msg = "";
                    data.line_points = "";
                    List <LatLng> pts = new List <LatLng>();
                    foreach (DataRow dr in dt.Rows)
                    {
                        double lng = double.Parse(dr["AMAP_longitude"].ToString());
                        double lat = double.Parse(dr["AMAP_latitude"].ToString());
                        pts.Add(new LatLng(lat, lng));

                        if (data.line_points.Length > 0 && !data.line_points.EndsWith("|"))
                        {
                            data.line_points += "|";
                        }
                        data.line_points += lng + "," + lat;
                    }
                    if (pts.Count > 0)
                    {
                        data.start_lng = pts[0].longitude;
                        data.star_lat  = pts[0].latitude;

                        data.end_lng = pts[pts.Count - 1].longitude;
                        data.end_lat = pts[pts.Count - 1].latitude;
                    }
                    else
                    {
                        LatLng latlng = new LatLng(double.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "EndLatitude")), double.Parse(SiteHelper.GetHashTableValueByKey(order_ht, "EndLongitude")));
                        latlng         = SiteHelper.TransformFromWGSToGCJ(latlng);
                        data.start_lng = latlng.longitude;
                        data.star_lat  = latlng.latitude;
                        data.end_lng   = data.start_lng;
                        data.end_lat   = data.star_lat;
                    }

                    resp.code = "0";
                    resp.msg  = "成功";
                    resp.data = data;
                }
                else
                {
                    resp.code = "-1";
                    resp.msg  = "未找到停车网点";
                }
            }
            else
            {
                resp.code = "-1";
                resp.msg  = "未找到相关订单";
            }

            return(resp);
        }
예제 #6
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();

            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);
        }
예제 #7
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);
        }