Пример #1
0
 public JsonResult SellerCharge(decimal chargeBalance, string SellerID)
 {
     try
     {
         if (chargeBalance <= 0)
         {
             throw new MyException("充值金额不正确");
         }
         bool result = ParkSellerServices.SellerCharge(SellerID, chargeBalance, GetLoginUser.RecordID);
         if (!result)
         {
             throw new MyException("充值失败");
         }
         return(Json(MyResult.Success()));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "商家充值失败");
         return(Json(MyResult.Error("充值失败")));
     }
 }
Пример #2
0
        public string GetParkSellerData()
        {
            StringBuilder strData = new StringBuilder();

            try
            {
                if (string.IsNullOrWhiteSpace(Request["villageId"]))
                {
                    return(string.Empty);
                }

                string villageId  = Request["villageId"].ToString();
                string sellerName = string.Empty;
                if (!string.IsNullOrWhiteSpace(Request["sellerName"]))
                {
                    sellerName = Request["sellerName"].Trim();
                }
                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 <ParkSeller> models = ParkSellerServices.QueryPage(villageId, sellerName, rows, page, out total);

                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());
        }
Пример #3
0
        public string GetSellerTreeData()
        {
            try
            {
                StringBuilder strTree = new StringBuilder();

                if (GetLoginUserVillages.Count == 0)
                {
                    return(strTree.ToString());
                }

                List <ParkSeller> sellers     = ParkSellerServices.QueryByVillageIds(GetLoginUserVillages.Select(p => p.VID).ToList());
                BaseCompany       currCompany = GetLoginUserRoleCompany.FirstOrDefault(p => p.CPID == GetCurrentUserCompanyId);
                if (currCompany == null)
                {
                    return(string.Empty);
                }
                strTree.Append("[{\"id\":\"" + currCompany.CPID + "\",");
                strTree.Append("\"iconCls\":\"my-company-icon\",");
                strTree.Append("\"attributes\":{\"type\":0},");
                strTree.Append("\"text\":\"" + currCompany.CPName + "\"");
                GetVillageTree(sellers, currCompany.CPID, strTree);
                strTree.Append("}]");
                return(strTree.ToString());
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "构建商家树结构失败");
                return(string.Empty);
            }
        }
Пример #4
0
        public ActionResult GetParkingData()
        {
            JsonResult result = new JsonResult();

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

                ParkSeller seller = ParkSellerServices.QueryBySellerId(sellerId);
                if (seller == null)
                {
                    throw new MyException("获取商家信息失败");
                }

                List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageId(seller.VID);
                result.Data = parkings;
                return(result);
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "优免券发放车场信息失败");
                return(result);
            }
        }
Пример #5
0
        /// <summary>
        /// 扫码优免进入
        /// </summary>
        /// <param name="vid">小区编号</param>
        /// <param name="qid">二维码编号</param>
        /// <param name="type">0-长久二维码 1-临时二维码</param>
        /// <param name="sign">签名</param>
        /// <returns></returns>
        public ActionResult Index(string vid, string qid, string sign)
        {
            TxtLogServices.WriteTxtLogEx("QRCodeDerate", "进入扫码打折:vid={0},qid={1},sign={2}", vid, qid, sign);
            try
            {
                if (SourceClient != RequestSourceClient.WeiXin)
                {
                    throw new MyException("请在微信中打开");
                }
                if (!CheckSignature(vid, qid, sign))
                {
                    throw new MyException("验证签名失败");
                }

                if (SourceClient == RequestSourceClient.WeiXin)
                {
                    if (string.IsNullOrWhiteSpace(WeiXinOpenId))
                    {
                        ParkDerate derate = ParkDerateServices.Query(qid);
                        if (derate == null)
                        {
                            throw new MyException("获取优免券信息失败");
                        }

                        ParkSeller seller = ParkSellerServices.QueryBySellerId(derate.SellerID);
                        if (seller == null)
                        {
                            throw new MyException("获取商家信息失败");
                        }

                        BaseVillage village = VillageServices.QueryVillageByRecordId(seller.VID);
                        if (village == null)
                        {
                            throw new MyException("获取小区信息失败");
                        }

                        string id = string.Format("QRCodeDerate_Index_vid={0}^qid={1}^sign={2}^companyId={3}", vid, qid, sign, village.CPID);
                        return(RedirectToAction("Index", "WeiXinAuthorize", new { id = id }));
                    }
                }
                ViewBag.PlateNumber = OnlineOrderServices.QueryLastPaymentPlateNumber(PaymentChannel.WeiXinPay, WeiXinOpenId);
                ViewBag.VillageId   = vid;
                ViewBag.QId         = qid;
                return(View());
            }
            catch (MyException ex) {
                TxtLogServices.WriteTxtLogEx("QRCodeDerate", "扫码打折异常:描述:{0}", ex.Message);
                return(RedirectToAction("Index", "ErrorPrompt", new { message = ex.Message }));
            }
            catch (Exception ex)
            {
                TxtLogServices.WriteTxtLogEx("QRCodeDerate", "扫码打折异常:描述:{0},明细:{1}", ex.Message, ex.StackTrace);
                return(RedirectToAction("Index", "ErrorPrompt", new { message = "扫码失败,未知异常" }));
            }
        }
Пример #6
0
        /// <summary>
        /// 获得所有车场
        /// </summary>
        /// <returns></returns>
        public JsonResult GetSellers()
        {
            JsonResult json = new JsonResult();

            try
            {
                json.Data = ParkSellerServices.QueryByVillageIds(GetLoginUserVillages.Select(p => p.VID).ToList());
            }
            catch { }
            return(json);
        }
Пример #7
0
 public JsonResult AddOrUpdate(ParkSeller model)
 {
     try
     {
         string errorMsg = string.Empty;
         if (string.IsNullOrWhiteSpace(model.SellerID))
         {
             model.PWD = MD5.Encrypt(model.PWD);
             bool result = ParkSellerServices.Add(model);
             if (!result)
             {
                 throw new MyException("添加商家失败");
             }
         }
         else
         {
             ParkSeller dbSeller = ParkSellerServices.QueryBySellerId(model.SellerID);
             if (dbSeller == null)
             {
                 throw new MyException("修改的商家不存在");
             }
             model.PWD     = dbSeller.PWD;
             model.Balance = dbSeller.Balance;
             bool result = ParkSellerServices.ModifySeller(model, out errorMsg);
             if (!result)
             {
                 throw new MyException("修改商家失败");
             }
         }
         return(Json(MyResult.Success()));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "保存商家信息失败");
         return(Json(MyResult.Error("保存失败")));
     }
 }
Пример #8
0
 public JsonResult Delete(string sellerId)
 {
     try
     {
         bool result = ParkSellerServices.Delete(sellerId);
         if (!result)
         {
             throw new MyException("删除失败");
         }
         return(Json(MyResult.Success()));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "删除商家失败");
         return(Json(MyResult.Error("删除商家失败")));
     }
 }
Пример #9
0
 public JsonResult ResetPassword(string sellerId)
 {
     try
     {
         string password = "******";
         bool   result   = ParkSellerServices.UpdatePassword(sellerId, MD5.Encrypt(password));
         if (!result)
         {
             throw new MyException("重置密码失败");
         }
         return(Json(MyResult.Success(string.Format("重置密码成功,密码为:{0}", password))));
     }
     catch (MyException ex)
     {
         return(Json(MyResult.Error(ex.Message)));
     }
     catch (Exception ex)
     {
         ExceptionsServices.AddExceptions(ex, "重置密码失败");
         return(Json(MyResult.Error("重置密码失败")));
     }
 }
Пример #10
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("获取优免二维码失败")));
            }
        }
Пример #11
0
        public JsonResult GetParkFeeRuleTreeData()
        {
            JsonResult json = new JsonResult();

            if (string.IsNullOrEmpty(Request.Params["sellerId"]))
            {
                return(json);
            }

            string     sellerId = Request.Params["sellerId"].ToString();
            ParkSeller seller   = ParkSellerServices.QueryBySellerId(sellerId);

            if (seller == null)
            {
                throw new MyException("获取商家信息失败");
            }

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

            if (parkings.Count == 0)
            {
                return(json);
            }

            List <ParkFeeRule> rules = new List <ParkFeeRule>();

            foreach (var item in parkings)
            {
                List <ParkFeeRule> rule = ParkFeeRuleServices.QueryParkFeeRuleByParkingId(item.PKID);
                if (rule.Count > 0)
                {
                    rules.AddRange(rule);
                }
            }
            json.Data = rules;
            return(json);
        }
Пример #12
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());
        }
Пример #13
0
        public JsonResult GrantCarDerate(string vid, string qid, string sellerName, string derateName, int number)
        {
            try
            {
                if (number <= 0)
                {
                    throw new MyException("发放优免券数量不正确");
                }

                if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                {
                    throw new MyException("获取系统域名失败");
                }
                ParkDerateQRcode qrCode = ParkDerateQRcodeServices.QueryByRecordId(qid);
                if (qrCode == null)
                {
                    throw new MyException("优免券规则不存在");
                }

                ParkDerate derate = ParkDerateServices.Query(qrCode.DerateID);
                if (derate == null)
                {
                    throw new MyException("获取优免规则失败");
                }

                if (derate.DerateType == DerateType.SpecialTimePeriodPayment)
                {
                    string     errorMsg = string.Empty;
                    ParkSeller seller   = ParkSellerServices.GetSeller(derate.SellerID, out errorMsg);
                    if (derate == null)
                    {
                        throw new MyException("获取优免规则失败");
                    }

                    decimal totalAmount = qrCode.DerateValue * number;
                    if ((seller.Creditline + seller.Balance) < totalAmount)
                    {
                        throw new MyException("商家余额不足");
                    }
                }

                BaseVillage village = VillageServices.QueryVillageByRecordId(vid);
                if (village == null)
                {
                    throw new MyException("获取小区信息失败");
                }

                string        folderName   = string.Format("{0}_{1}_{2}", sellerName, derateName, IdGenerator.Instance.GetId().ToString());
                List <string> carDerateIds = new List <string>();
                for (int i = 0; i < number; i++)
                {
                    string carDerateId = GuidGenerator.GetGuidString();
                    string content     = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&did={3}&sign={4}", SystemDefaultConfig.SystemDomain, vid, qid, carDerateId, GetSignature(vid, qid, carDerateId));
                    string result      = QRCodeServices.GenerateQRCode(village.CPID, content, 430, carDerateId, folderName);
                    if (string.IsNullOrWhiteSpace(result))
                    {
                        throw new MyException("创建二维码失败");
                    }
                    carDerateIds.Add(carDerateId);
                }
                string filePath    = string.Format("/Uploads/{0}", folderName);
                string zipFilePath = string.Format("{0}/{1}_{2}.zip", filePath, sellerName, derateName);
                string mapPath     = Server.MapPath("~/");

                ZipHelper.ZipFiles(string.Format("{0}/{1}", mapPath, filePath), string.Format("{0}/{1}", mapPath, zipFilePath));
                if (carDerateIds.Count != number)
                {
                    throw new MyException("二维码数量与待创建的数量不匹配");
                }

                bool grantResult = ParkDerateQRcodeServices.GrantCarDerate(carDerateIds, zipFilePath, qid);
                if (!grantResult)
                {
                    throw new MyException("发放券失败");
                }

                return(Json(MyResult.Success("", zipFilePath)));
            }
            catch (MyException ex)
            {
                return(Json(MyResult.Error(ex.Message)));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "发放优免券失败");
                return(Json(MyResult.Error("发放优免券失败")));
            }
        }
Пример #14
0
        public ActionResult DerateQRCode(string recordId)
        {
            try
            {
                ParkDerateQRcode derateQRcode = ParkDerateQRcodeServices.QueryByRecordId(recordId);
                if (derateQRcode == null)
                {
                    throw new MyException("该二维码不存在");
                }

                ParkDerate derate = ParkDerateServices.Query(derateQRcode.DerateID);
                if (derate == null)
                {
                    throw new MyException("优免规则不存在");
                }
                derateQRcode.DerateName = derate.Name;

                ParkSeller seller = ParkSellerServices.QueryBySellerId(derate.SellerID);
                if (seller == null)
                {
                    throw new MyException("商家不存在");
                }
                derateQRcode.SellerName = seller.SellerName;

                if (string.IsNullOrWhiteSpace(SystemDefaultConfig.SystemDomain))
                {
                    throw new MyException("获取系统域名失败");
                }
                BaseVillage village = VillageServices.QueryVillageByRecordId(seller.VID);
                if (village == null)
                {
                    throw new MyException("获取小区信息失败");
                }

                string content = string.Format("{0}/QRCodeDerate/Index?vid={1}&qid={2}&sign={3}", SystemDefaultConfig.SystemDomain, seller.VID, recordId, GetSignature(seller.VID, recordId));
                using (System.Drawing.Image image = QRCodeServices.GenerateQRCode(content, 430))
                {
                    ImageFormat format = image.RawFormat;
                    byte[]      buffer;
                    using (MemoryStream ms = new MemoryStream())
                    {
                        image.Save(ms, ImageFormat.Jpeg);
                        buffer = new byte[ms.Length];
                        ms.Seek(0, SeekOrigin.Begin);
                        ms.Read(buffer, 0, buffer.Length);
                    }
                    derateQRcode.ImageData = System.Convert.ToBase64String(buffer);
                }
                ViewBag.CompanyID   = village.CPID;
                ViewBag.ShareAction = "XFJMDerateQRCode/DerateQRCode?recordId=" + recordId;
                return(View(derateQRcode));
            }
            catch (MyException ex)
            {
                return(RedirectToAction("Index", "XFJMDerateQRCode", new { RemindUserContent = ex.Message }));
            }
            catch (Exception ex)
            {
                ExceptionsServices.AddExceptions(ex, "微信获取二维码失败", LogFrom.WeiXin);
                return(RedirectToAction("Index", "XFJMDerateQRCode", new { RemindUserContent = "获取二维码失败" }));
            }
        }