Пример #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="out_order_no"></param>
        /// <param name="plate_no"></param>
        /// <param name="username"></param>
        /// <param name="mobile"></param>
        /// <param name="cardno"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        private bool CreateOrder(string out_order_no, string plate_no, string username, string mobile, string cardno, out string errmsg)
        {
            VehicleManager    vm             = new VehicleManager();
            BaoJiaManager     mgr            = new BaoJiaManager();
            SysSettingManager settingManager = new SysSettingManager();
            Hashtable         vehicle        = vm.GetVehicleInfoByID(plate_no);

            if (vehicle == null || vehicle.Keys.Count == 0)
            {
                //根据车牌号码查询车辆信息
                vehicle = vm.GetVehicleInfoByLicenseNumber(plate_no);
            }
            //判断车辆是否存在
            if (vehicle == null || vehicle.Keys.Count == 0)
            {
                errmsg = "车辆预约失败,未找到车辆相关信息";
                return(false);
            }

            string vehicleid = SiteHelper.GetHashTableValueByKey(vehicle, "ID");
            //判断预约车辆是否离线
            DateTime lastUpdateTime;

            if (string.IsNullOrEmpty(SiteHelper.GetHashTableValueByKey(vehicle, "LastUpdateTime")))
            {
                errmsg = "当前车辆已离线无法约车";
                return(false);
            }
            else
            {
                lastUpdateTime = DateTime.Parse(SiteHelper.GetHashTableValueByKey(vehicle, "LastUpdateTime"));
                if (SiteHelper.ExecDateDiff(lastUpdateTime, DateTime.Now) > 10)
                {
                    errmsg = "当前车辆已离线无法约车";
                    return(false);
                }
            }

            //判断预约车辆电量值
            double electricity = 0.00;

            double.TryParse(SiteHelper.GetHashTableValueByKey(vehicle, "Electricity"), out electricity);
            if (electricity < 20)
            {
                errmsg = "当前车辆电量过低无法约车";
                return(false);
            }

            #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)
                {
                    errmsg = "车辆预约失败,车辆处于运营区域外";
                    return(false);
                }
            }
            #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)
                {
                    errmsg = "车辆预约失败,车辆处于停车网点外";
                    return(false);
                }
            }
            #endregion

            //判断车辆是否可用
            if (SiteHelper.GetHashTableValueByKey(vehicle, "UseState").Trim() == VehicleUseState.Free.GetHashCode().ToString() && SiteHelper.GetHashTableValueByKey(vehicle, "VehicleState").Trim() == VehicleState.Use.GetHashCode().ToString())
            {
                //判断用户是否存在未支付订单
                if (mgr.IsExistUnPayOrderByUser(mobile))
                {
                    errmsg = "您当前有未支付订单,请完成支付后重试";
                    return(false);
                }

                //判断会员是否有条件预约
                bool isExist = mgr.IsExistVehicleOrderByUser(mobile);
                if (isExist)
                {
                    errmsg = "您已经预约过车辆了";
                    return(false);
                }
                else
                {
                    string orderID  = string.Empty;
                    string orderNum = string.Empty;
                    //提交订单
                    bool isSuccess = OrderVehicle(out_order_no, username, mobile, cardno, vehicleid, out orderID, out orderNum);
                    if (isSuccess)
                    {
                        //vm.OpenVehicle(vehicleid);
                        errmsg = "";
                        return(true);
                    }
                    else
                    {
                        errmsg = "车辆预约失败,请联系管理员";
                        return(false);
                    }
                }
            }
            else
            {
                errmsg = "预约失败,车辆不允许预约";
                return(false);
            }
        }
Пример #5
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);
                    }
                }
            }
        }
Пример #6
0
        private bool OrderVehicle(string out_order_no, string username, string mobile, string cardno, string vehicleid, out string orderID, out string orderNum)
        {
            orderID  = CommonHelper.GetGuid;
            orderNum = SiteHelper.GenerateOrderNum();
            bool result = false;

            try
            {
                VehicleManager vm      = new VehicleManager();
                Hashtable      vehicle = vm.GetVehicleInfoByID(vehicleid);

                string km_price = "", minute_price = "";
                VehiclePriceManager vp       = new VehiclePriceManager();
                Hashtable           price_ht = vp.GetVehiclePrice(vehicleid);
                if (price_ht != null && price_ht.Keys.Count > 0)
                {
                    km_price     = price_ht["KmPrice"].ToString();
                    minute_price = price_ht["MinutePrice"].ToString();
                }

                int       renttime        = 0;
                decimal   TotalMoney      = 0;
                decimal   SettlementMoney = TotalMoney;
                Hashtable param           = new Hashtable();
                param["VID"]             = vehicleid;
                param["OID"]             = orderID;
                param["OrderNum"]        = orderNum;
                param["UserID"]          = null;
                param["VehicleID"]       = vehicleid;
                param["KMPrice"]         = km_price;
                param["MinutePrice"]     = minute_price;
                param["Mileage"]         = 0;
                param["Minutes"]         = 0;
                param["PayState"]        = OrderPayState.NotPay.GetHashCode();
                param["PayState"]        = OrderPayState.NotPay.GetHashCode();
                param["OrderState"]      = OrderState.Valid.GetHashCode();
                param["CreateTime"]      = SiteHelper.GetWebServerCurrentTime();
                param["OrderRemark"]     = "";
                param["RentDuration"]    = renttime;
                param["TotalMoney"]      = TotalMoney;
                param["SettlementMoney"] = SettlementMoney;
                param["PayMoney"]        = SettlementMoney;
                param["PayTime"]         = SiteHelper.GetWebServerCurrentTime().ToString();
                param["FinishedTime"]    = SiteHelper.GetWebServerCurrentTime().ToString();
                param["ChangesAmount"]   = -Math.Abs(SettlementMoney);
                param["UserFinancialID"] = CommonHelper.GetGuid;
                param["ChangesTime"]     = SiteHelper.GetWebServerCurrentTime().ToString();
                param["ChangesType"]     = UserFinancialChangesType.Consumption.GetHashCode().ToString();
                param["Remark"]          = "";
                param["Operator"]        = "";
                param["OperatorType"]    = UserFinancialOperatorType.Admin.GetHashCode().ToString();
                param["OperatorWay"]     = UserFinancialOperatorWay.Plat.GetHashCode().ToString();
                param["State"]           = UserFinancialState.Effect.GetHashCode().ToString();
                param["MessageID"]       = CommonHelper.GetGuid;
                param["CityID"]          = SiteHelper.GetHashTableValueByKey(vehicle, "CityID").ToString();
                param["RealName"]        = username;
                param["BindPhone"]       = mobile;
                param["IDCardNum"]       = cardno;
                param["OutOrderNo"]      = out_order_no;
                param["OrderSource"]     = "02";
                param["FromParking"]     = SiteHelper.GetHashTableValueByKey(vehicle, "ParkingID").ToString();

                BaoJiaManager mgr = new BaoJiaManager();
                result = mgr.OrderVehicle(param);
                return(result);
            }
            catch
            {
                return(result);
            }
        }
Пример #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 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);
        }
Пример #8
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);
        }
Пример #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);
        }