Exemple #1
0
        public ActionResult GetParkDerateQRcodeData(string derateId, int?status, int page)
        {
            try
            {
                int rows  = 10;
                int total = 0;
                List <ParkDerateQRcode> models = ParkDerateQRcodeServices.QueryPage(SellerLoginUser.SellerID, derateId, 0, status, DerateQRCodeSource.Seller, rows, page, out total);
                if (models.Count > 0)
                {
                    ParkSeller seller = ParkSellerServices.QueryBySellerId(SellerLoginUser.SellerID);
                    if (seller == null)
                    {
                        throw new MyException("获取商家信息失败");
                    }

                    List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageId(seller.VID);

                    Dictionary <string, int> result = ParkCarDerateServices.QuerySettlementdCarDerate(models.Select(p => p.RecordID).ToList());
                    foreach (var item in models)
                    {
                        int    useTimes    = result.ContainsKey(item.RecordID) ? result[item.RecordID] : 0;
                        string canUseTimes = item.CanUseTimes == 0 ? "不限" : item.CanUseTimes.ToString();
                        item.UseTimesDes = string.Format("{0}/{1}", canUseTimes, useTimes);
                        BaseParkinfo park = parkings.FirstOrDefault(p => p.PKID == item.PKID);
                        if (park != null)
                        {
                            item.ParkName = park.PKName;
                        }
                    }
                }
                return(Json(MyResult.Success("", models)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "获取优免二维码失败", LogFrom.WeiXin);
                return(Json(MyResult.Error("获取优免二维码失败")));
            }
        }
Exemple #2
0
        public string GetParkDerateQRcodeData()
        {
            StringBuilder strData = new StringBuilder();

            try
            {
                if (string.IsNullOrEmpty(Request.Params["sellerId"]))
                {
                    return(string.Empty);
                }
                string sellerId = Request.Params["sellerId"].ToString();
                string derateId = Request.Params["derateId"].ToString();

                int?queryStatus = null;
                int status      = 0;
                if (!string.IsNullOrWhiteSpace(Request.Params["status"]) && int.TryParse(Request.Params["status"].ToString(), out status))
                {
                    queryStatus = status;
                }
                DerateQRCodeSource?derateQRCodeSource = null;
                int source = 0;
                if (!string.IsNullOrWhiteSpace(Request.Params["DerateQRCodeSource"]) && int.TryParse(Request.Params["DerateQRCodeSource"].ToString(), out source))
                {
                    derateQRCodeSource = (DerateQRCodeSource)source;
                }


                int page  = string.IsNullOrEmpty(Request.Params["page"]) ? 0 : int.Parse(Request.Params["page"]);
                int rows  = string.IsNullOrEmpty(Request.Params["rows"]) ? 0 : int.Parse(Request.Params["rows"]);
                int total = 0;
                List <ParkDerateQRcode> models = ParkDerateQRcodeServices.QueryPage(sellerId, derateId, 1, queryStatus, derateQRCodeSource, rows, page, out total);
                if (models.Count > 0)
                {
                    ParkSeller seller = ParkSellerServices.QueryBySellerId(sellerId);
                    if (seller == null)
                    {
                        throw new MyException("获取商家信息失败");
                    }

                    List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageId(seller.VID);

                    Dictionary <string, int> result = ParkCarDerateServices.QuerySettlementdCarDerate(models.Select(p => p.RecordID).ToList());
                    foreach (var item in models)
                    {
                        int    useTimes    = result.ContainsKey(item.RecordID)?result[item.RecordID]:0;
                        string canUseTimes = item.CanUseTimes == 0 ? "不限" : item.CanUseTimes.ToString();
                        item.UseTimesDes = string.Format("{0}/{1}", canUseTimes, useTimes);
                        BaseParkinfo park = parkings.FirstOrDefault(p => p.PKID == item.PKID);
                        if (park != null)
                        {
                            item.ParkName = park.PKName;
                        }
                    }
                }
                strData.Append("{");
                strData.Append("\"total\":" + total + ",");
                strData.Append("\"rows\":" + JsonHelper.GetJsonString(models) + ",");
                strData.Append("\"index\":" + page);
                strData.Append("}");
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "获取一次性优免二维码失败");
            }
            return(strData.ToString());
        }