public ActionResult GetMonthGatherData() { try { int page = string.IsNullOrEmpty(Request.Params["page"]) ? 0 : int.Parse(Request.Params["page"]); int rows = 15; InParams paras = new InParams { ParkingID = Request.Params["parkingid"], StartTime = DateTime.Parse(Request.Params["starttime"] + "-01 00:00:00"), EndTime = DateTime.Parse(Request.Params["endtime"] + "-01 00:00:00").AddSeconds(-1).AddMonths(1) }; Pagination pagination = StatisticsServices.Search_MonthStatistics(paras, rows, page); return(Json(MyResult.Success("", pagination.StatisticsGatherList))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "微信管理端获取月汇总失败"); return(Json(MyResult.Error("获取失败"))); } }
public ActionResult GetSellerDerateData() { JsonResult result = new JsonResult(); try { if (string.IsNullOrEmpty(Request.Params["sellerId"])) { return(result); } string sellerId = Request.Params["sellerId"].ToString(); List <ParkDerate> derates = ParkDerateServices.QueryBySellerID(sellerId); result.Data = derates; return(result); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "优免二维码根据商家编号获取优免信息失败"); return(result); } }
public JsonResult EditMessage(Message model) { try { model.UserID = GetLoginUser.RecordID; model.UserName = GetLoginUser.UserName; if (string.IsNullOrWhiteSpace(model.RecordID)) { model.UserID = GetLoginUser.RecordID; model.UserName = GetLoginUser.UserName; bool result = MessageServices.Add(model); if (!result) { throw new MyException("保存失败"); } } else { bool result = MessageServices.Update(model); 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("保存失败"))); } }
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("获取优免二维码失败"))); } }
public string GetSystemRoles() { StringBuilder strTree = new StringBuilder(); try { List <SysRoles> roles = SysRolesServies.QuerySysRolesByCompanyId(GetCurrentUserCompanyId); strTree.Append("["); int i = 1; foreach (var obj in roles) { strTree.Append("{\"id\":\"" + obj.RecordID + "\","); strTree.Append("\"iconCls\":\"my-role-icon\","); strTree.Append("\"attributes\":{\"type\":0,\"isdefaultrole\":\"" + (int)obj.IsDefaultRole + "\"},"); if (obj.IsDefaultRole == YesOrNo.Yes) { strTree.Append("\"text\":\"" + obj.RoleName + "[系统默认]" + "\""); } else { strTree.Append("\"text\":\"" + obj.RoleName + "\""); } strTree.Append("}"); if (i != roles.Count()) { strTree.Append(","); } i++; } strTree.Append("]"); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "用户角色管理 构建用户角色树失败"); } return(strTree.ToString()); }
public string CreateLoginUserSubVillageTreeData() { try { StringBuilder str = new StringBuilder(); List <BaseCompany> companys = CompanyServices.QueryCompanyAndSubordinateCompany(GetCurrentUserCompanyId); if (companys.Count == 0) { return(str.ToString()); } BaseCompany topCompany = companys.FirstOrDefault(p => p.CPID == GetCurrentUserCompanyId); List <BaseVillage> villages = VillageServices.QueryVillageByCompanyIds(companys.Select(p => p.CPID).ToList()); villages = villages.Where(p => p.CPID != topCompany.CPID).ToList(); if (topCompany == null) { return(str.ToString()); } str.Append("["); str.Append("{\"id\":\"" + topCompany.CPID + "\","); str.Append("\"iconCls\":\"my-company-icon\","); str.Append("\"attributes\":{\"type\":0},"); str.Append("\"text\":\"" + topCompany.CPName + "\""); CreateSubordinateVillageTreeData(companys, villages, topCompany.CPID, str); str.Append("}"); str.Append("]"); return(str.ToString()); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "构建小区树结构失败"); return(string.Empty); } }
public string GetUserTreeData() { StringBuilder sb = new StringBuilder(); try { string queryUserAccount = Request.Params["queryUserAccount"]; 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 totalCount = 0; List <SysUser> users = SysUserServices.QuerySysUserPage(GetCurrentUserCompanyId, queryUserAccount, rows, page, out totalCount); var currObj = from p in users select new { ID = p.ID, RecordID = p.RecordID, UserAccount = p.UserAccount, UserName = p.UserName, IsDefaultUser = (int)p.IsDefaultUser, RoleDescription = GetUserRoleDescription(p), ScopeDescription = GetScopeDescription(p) }; sb.Append("{"); sb.Append("\"total\":" + totalCount + ","); sb.Append("\"rows\":" + JsonHelper.GetJsonString(currObj) + ","); sb.Append("\"index\":" + page); sb.Append("}"); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "获取用户信息失败[用户管理]"); } return(sb.ToString()); }
public ActionResult Edit(string recordId) { try { ParkDerateQRcode derate = new ParkDerateQRcode(); if (!string.IsNullOrWhiteSpace(recordId)) { derate = ParkDerateQRcodeServices.QueryByRecordId(recordId); } else { derate.StartTime = DateTime.Now; derate.EndTime = DateTime.Now.Date.AddDays(1).AddSeconds(-1); } List <ParkDerate> derates = ParkDerateServices.QueryBySellerID(SellerLoginUser.SellerID); List <EnumContext> derateContexts = new List <EnumContext>(); foreach (var item in derates) { EnumContext model = new EnumContext(); model.EnumString = item.DerateID; model.Description = item.Name; model.EnumValue = (int)item.DerateType; derateContexts.Add(model); } ViewBag.DerateContexts = derateContexts; return(View(derate)); } 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 = "操作失败" })); } }
public string GetSellerDerateTree(bool needDefaultValue = false) { try { if (string.IsNullOrEmpty(Request.Params["sellerId"])) { return("[]"); } string sellerId = Request.Params["sellerId"].ToString(); StringBuilder strTree = new StringBuilder(); strTree.Append("["); if (needDefaultValue) { strTree.Append("{\"id\":\"\","); strTree.Append("\"text\":\"不限\""); strTree.Append("}"); } List <ParkDerate> derates = ParkDerateServices.QueryBySellerID(sellerId); foreach (var item in derates) { if (strTree.ToString() != "[") { strTree.Append(","); } strTree.Append("{\"id\":\"" + item.DerateID + "\","); strTree.Append("\"text\":\"" + item.Name + "\""); strTree.Append("}"); } strTree.Append("]"); return(strTree.ToString()); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "优免二维码根据商家编号获取优免信息失败"); return("[]"); } }
public JsonResult AddOrUpdate(AliPayApiConfig config) { try { config.SystemDomain = config.SystemDomain.TrimEnd('/'); bool result = AliPayApiConfigServices.AddOrUpdate(config); if (!result) { throw new MyException("保存失败"); } return(Json(MyResult.Success("", config.RecordId))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "保存支付宝配置信息失败"); return(Json(MyResult.Error("保存失败"))); } }
public string GetScopeTreeData() { StringBuilder strTree = new StringBuilder(); try { strTree.Append("["); var roles = SysScopeServices.QuerySysScopeByCompanyId(GetCurrentUserCompanyId); int i = 1; foreach (var obj in roles) { strTree.Append("{\"id\":\"" + obj.ASID + "\","); strTree.Append("\"attributes\":{\"type\":1,\"isdefault\":\"" + (int)obj.IsDefaultScope + "\"},"); if (obj.IsDefaultScope == Common.Entities.YesOrNo.Yes) { strTree.Append("\"text\":\"" + obj.ASName + "[系统默认]" + "\""); } else { strTree.Append("\"text\":\"" + obj.ASName + "\""); } strTree.Append("}"); if (i != roles.Count()) { strTree.Append(","); } i++; } strTree.Append("]"); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "作用域管理 构建作用域树失败"); } return(strTree.ToString()); }
public JsonResult AddOrUpdate(ParkDerateQRcode model) { try { if (string.IsNullOrWhiteSpace(model.RecordID)) { model.StartTime = DateTime.Now; model.OperatorId = GetLoginUser.RecordID; model.DerateQRcodeType = 1; model.DataSource = DerateQRCodeSource.Platefrom; bool result = ParkDerateQRcodeServices.Add(model); if (!result) { throw new MyException("添加一次性二维码成功"); } } else { model.StartTime = DateTime.Now; bool result = ParkDerateQRcodeServices.Update(model); 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("保存一次性优免二维码失败"))); } }
public JsonResult UpdateCurrLoginPwd(string oldPwd, string newPwd1, string newPwd2) { try { if (newPwd1 != newPwd2) { throw new MyException("两次输入密码不匹配"); } SysUser user = SysUserServices.QuerySysUserByUserAccount(GetLoginUser.UserAccount); if (user == null) { throw new MyException("用户不存在"); } if (!user.Password.Equals(MD5.Encrypt(oldPwd))) { throw new MyException("原始密码不正确"); } bool result = SysUserServices.ResetPassword(user.UserAccount, MD5.Encrypt(newPwd1)); 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("修改密码失败"))); } }
public JsonResult GetCarModelData() { JsonResult json = new JsonResult(); try { if (string.IsNullOrEmpty(Request.Params["parkingId"])) { return(json); } string parkingid = Request.Params["parkingid"].ToString(); List <ParkCarModel> models = ParkCarModelServices.QueryByParkingId(parkingid); var result = from p in models select new { CarModelID = p.CarModelID, CarModelName = p.CarModelName, PlateColor = string.IsNullOrWhiteSpace(p.PlateColor) ? "无" : p.PlateColor, IsDefault = p.IsDefault, IsNaturalDay = p.IsNaturalDay, MaxUseMoney = p.MaxUseMoney, DayMaxMoney = p.DayMaxMoney, NightMaxMoney = p.NightMaxMoney, DayStartTime = p.DayStartTime == DateTime.MinValue? "00:00" : p.DayStartTime.ToString("HH:mm"), DayEndTime = p.DayEndTime == DateTime.MinValue ? "00:00" : p.DayEndTime.ToString("HH:mm"), NightStartTime = p.NightStartTime == DateTime.MinValue ? "00:00" : p.NightStartTime.ToString("HH:mm"), NightEndTime = p.NightEndTime == DateTime.MinValue ? "00:00" : p.NightEndTime.ToString("HH:mm"), DayDes = GetDes(p.DayMaxMoney, p.DayStartTime, p.DayEndTime), NightDes = GetDes(p.NightMaxMoney, p.NightStartTime, p.NightEndTime) }; json.Data = result; } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "车型管理查询车类型集合失败"); } return(json); }
public JsonResult PostWeiXinVerificationFile() { string info = string.Empty; try { HttpFileCollection files = System.Web.HttpContext.Current.Request.Files; if (files.Count > 0) { HttpPostedFile file = files[0]; var extension = Path.GetExtension(file.FileName); if (extension != ".txt") { return(Json(MyResult.Error("上传的文件必须为txt文件"))); } string fileName = System.IO.Path.GetFileName(file.FileName); string path = System.IO.Path.Combine(System.Web.HttpContext.Current.Server.MapPath("~"), fileName); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } //保存上传的文件到指定路径中 file.SaveAs(path); return(Json(MyResult.Success())); } else { return(Json(MyResult.Error("获取上传文件失败"))); } } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "上传支付证书失败"); return(Json(MyResult.Error("上传文件异常"))); } }
public JsonResult GetSellerDerateData() { JsonResult json = new JsonResult(); try { if (string.IsNullOrEmpty(Request.Params["sellerId"])) { return(json); } string sellerId = Request.Params["sellerId"].ToString(); List <ParkDerate> derates = ParkDerateServices.QueryBySellerID(sellerId); var result = from p in derates select new { DerateID = p.DerateID, SellerID = p.SellerID, Name = p.Name, DerateSwparate = (int)p.DerateSwparate, DerateSwparateDes = p.DerateSwparate.GetDescription(), DerateType = (int)p.DerateType, DerateTypeDes = p.DerateType.GetDescription(), DerateMoney = p.DerateMoney, FreeTime = p.FreeTime, StartTime = p.StartTime != DateTime.MinValue?p.StartTime.ToString("HH:mm"):"00:00", EndTime = p.EndTime != DateTime.MinValue ? p.EndTime.ToString("HH:mm") : "00:00", FeeRuleID = p.FeeRuleID, DerateIntervar = GetDerateIntervar(p.DerateIntervar), }; json.Data = result; } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "根据商家编号获取优免信息失败"); } return(json); }
public JsonResult GetKeywordData() { JsonResult json = new JsonResult(); try { if (string.IsNullOrWhiteSpace(Request["companyId"])) { return(json); } List <WX_Keyword> models = WXKeywordServices.QueryALL(Request["companyId"].ToString()); var result = from p in models select new { Id = p.ID, Keyword = p.Keyword, KeywordType = p.KeywordType, KeywordTypeDes = p.KeywordType.GetDescription(), MatchType = p.MatchType, MatchTypeDes = p.MatchType.GetDescription(), ReplyType = p.ReplyType, ReplyTypeDes = p.ReplyType.GetDescription(), Text = p.Text, ArticleGroupID = p.ArticleGroupID, CompanyID = p.CompanyID }; json.Data = result; } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "查询关键字信息失败"); } return(json); }
public JsonResult GetWXArticleData(string companyId) { JsonResult json = new JsonResult(); try { List <WX_Article> models = WXArticleServices.QueryAll(companyId); List <string> groupIds = models.Select(p => p.GroupID).Distinct().ToList(); var result = from p in groupIds select new { GroupId = p, Count = models.Count(o => o.GroupID == p), Title = models.OrderBy(o => o.Sort).First(o => o.GroupID == p).Title }; json.Data = result; } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "查询图文信息失败"); } return(json); }
public string GetOnlyParkingTreeData() { try { StringBuilder strParkingTree = new StringBuilder(); if (GetLoginUserVillages.Count == 0) { return(strParkingTree.ToString()); } List <BaseParkinfo> parkings = ParkingServices.QueryParkingByVillageIds(GetLoginUserVillages.Select(p => p.VID).ToList()); strParkingTree.Append("["); int index = 1; foreach (var item in parkings) { strParkingTree.Append("{"); strParkingTree.AppendFormat("\"id\":\"{0}\"", item.PKID); strParkingTree.Append(",\"iconCls\":\"my-parking-icon\""); strParkingTree.AppendFormat(",\"text\":\"{0}\"", item.PKName); strParkingTree.Append(",\"attributes\":{\"type\":1}"); strParkingTree.Append("}"); if (index != parkings.Count()) { strParkingTree.Append(","); } index++; } strParkingTree.Append("]"); return(strParkingTree.ToString()); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "构建车场树异常"); return(string.Empty); } }
private string GetScopeDescription(SysUser users) { try { StringBuilder strInfo = new StringBuilder(); List <SysScope> scopes = SysScopeServices.QuerySysScopeByUserId(users.RecordID); if (scopes != null && scopes.Count > 0) { foreach (var item in scopes) { strInfo.AppendFormat("{0}<br>", item.ASName); } if (!string.IsNullOrWhiteSpace(strInfo.ToString())) { return(strInfo.ToString().Substring(0, strInfo.Length - 4)); } } return(string.Empty); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "获取作用域描述失败[用户管理]"); return(string.Empty); } }
public JsonResult SaveUser() { try { string userId = !string.IsNullOrWhiteSpace(Request.Params["RecordID"])?Request.Params["RecordID"].ToString():GuidGenerator.GetGuidString(); SysUser smusers = GetSmUsers(userId); List <SysUserRolesMapping> rolesMappings = GetSysUserRolesMappings(userId); List <SysUserScopeMapping> scopeMappings = GetSysUserScopeMappings(userId); bool result = false; if (string.IsNullOrWhiteSpace(Request.Params["RecordID"])) { result = SysUserServices.Add(smusers, rolesMappings, scopeMappings); } else { result = SysUserServices.Update(smusers, rolesMappings, scopeMappings); } if (!result) { throw new MyException("保存失败"); } CacheData.UpdateCacheUserLoginData(GetLoginUser.RecordID); return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "保存用户失败"); return(Json(MyResult.Error("保存失败"))); } }
public string GetScopeTreeData() { StringBuilder strTree = new StringBuilder(); try { List <SysUserScopeMapping> scpoes = new List <SysUserScopeMapping>(); if (!string.IsNullOrWhiteSpace(Request.Params["userId"])) { scpoes = SysUserServices.QuerySysUserScopeMappingByUserId(Request.Params["userId"]); } strTree.Append("[{\"id\":\"0\","); strTree.Append("\"attributes\":{\"type\":0},"); strTree.Append("\"text\":\"用户作用域\""); GetScopeChildTreeData(scpoes, strTree); strTree.Append("}]"); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "获取用户作用域失败[用户管理]"); } return(strTree.ToString()); }
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()); }
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("发放优免券失败"))); } }
public string GetSystemModule() { try { List <SysRoleAuthorize> roles = new List <SysRoleAuthorize>(); XDocument xdoc = XDocument.Load(Server.MapPath("~/SystemModule.xml")); foreach (XElement element in xdoc.Root.Elements()) { string moduleId = element.Attribute("ModuleID").Value; string moduleName = element.Attribute("ModuleName").Value; string parentId = element.Attribute("ParentID").Value; string isSystemDefault = element.Attribute("SystemDefault").Value; SysRoleAuthorize role = new SysRoleAuthorize(); role.ModuleID = moduleId; role.ModuleName = moduleName; role.ParentID = parentId; role.IsSystemDefault = isSystemDefault == "true"; roles.Add(role); } if (string.IsNullOrWhiteSpace(Request.Params["roleId"])) { return("[]"); } string roleId = Request.Params["roleId"].ToString(); SysRoles sysRole = SysRolesServies.QuerySysRolesByRecordId(roleId); StringBuilder strTree = new StringBuilder(); strTree.Append("[{\"id\":\"" + sysRole.RecordID + "\","); strTree.Append("\"attributes\":{\"type\":0},"); strTree.Append("\"text\":\"" + sysRole.RoleName + "[授权]\""); List <SysRoleAuthorize> rootModules = roles.Where(p => p.ParentID == "").ToList(); if (rootModules.Count > 0) { strTree.Append(",\"children\":["); } List <SysRoleAuthorize> roleAuthorizes = SysRoleAuthorizeServices.QuerySysRoleAuthorizeByRoleId(sysRole.RecordID); int i = 1; foreach (var item in rootModules) { strTree.Append("{\"id\":\"" + item.ModuleID + "_" + item.ParentID + "_" + roleId + "\","); strTree.Append("\"text\":\"" + item.ModuleName + "\","); bool isDefaultRole = false; if (sysRole.IsDefaultRole == YesOrNo.Yes && item.IsSystemDefault) { isDefaultRole = true; strTree.Append("\"attributes\":{\"type\":1,\"isdefault\":1},"); strTree.Append("\"checked\":true"); } if (!isDefaultRole) { strTree.Append("\"attributes\":{\"type\":1,\"isdefault\":0}"); } if (!isDefaultRole && roleAuthorizes != null && roleAuthorizes.Exists(p => p.ModuleID == item.ModuleID) && !roleAuthorizes.Exists(p => p.ParentID == item.ModuleID)) { strTree.Append(",\"checked\":true"); } GetChildRoles(sysRole, item, roles, strTree, roleAuthorizes, roleId); strTree.Append("}"); if (i != rootModules.Count()) { strTree.Append(","); } i++; } if (rootModules.Count > 0) { strTree.Append("]"); } strTree.Append("}]"); return(strTree.ToString()); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "获取角色授权模块失败"); return("[]"); } }
public JsonResult SaveRoleModule() { try { if (string.IsNullOrWhiteSpace(Request.Params["roleId"])) { throw new MyException("请选择角色"); } string roleId = Request.Params["roleId"].ToString(); SysRoles role = SysRolesServies.QuerySysRolesByRecordId(roleId); if (role == null) { throw new MyException("获取角色信息失败"); } if (role.IsDefaultRole == YesOrNo.No && string.IsNullOrWhiteSpace(Request.Params["selectModuleIds"])) { throw new MyException("请选择需要授权的模块"); } string roleModules = Request.Params["selectModuleIds"].ToString(); List <SysRoleAuthorize> models = new List <SysRoleAuthorize>(); if (!string.IsNullOrWhiteSpace(roleModules)) { string[] strRoles = roleModules.Split(','); for (int i = 0; i < strRoles.Length; i++) { string[] d = strRoles[i].Split('_'); if (d.Length != 3) { continue; } SysRoleAuthorize model = new SysRoleAuthorize(); model.RecordID = GuidGenerator.GetGuid().ToString(); model.RoleID = role.RecordID; model.ModuleID = d[0]; model.ParentID = d[1]; models.Add(model); } } FillDefaultModule(models, role); if (models.Count == 0) { throw new MyException("获取模块信息失败"); } bool result = SysRoleAuthorizeServices.Add(models); if (!result) { throw new MyException("保存角色模块失败"); } CacheData.UpdateCacheUserLoginData(GetLoginUser.RecordID); return(Json(MyResult.Success())); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "保存角色模块授权失败"); return(Json(MyResult.Error("保存失败"))); } }
public ActionResult QueryWaitPayDetail(string recordId, string carModelId) { try { string errorMsg = string.Empty; ParkIORecord model = ParkIORecordServices.GetIORecord(recordId, out errorMsg); if (!string.IsNullOrWhiteSpace(errorMsg)) { throw new MyException("获取该入场记录失败"); } if (model == null) { throw new MyException("找不到该入场记录"); } if (model.IsExit) { throw new MyException("该车辆已经出场"); } DateTime outTime = DateTime.Now; List <ParkGate> parkGates = ParkGateServices.QueryByParkAreaRecordIds(new List <string>() { model.AreaID }); ParkGate outGate = parkGates.FirstOrDefault(p => p.IoState == IoState.GoOut); if (outGate == null) { throw new MyException("获取出口通道失败"); } ResultAgs billResult = RateProcesser.GetRateResult(model, outGate, outTime, carModelId); if (!string.IsNullOrWhiteSpace(billResult.ValidFailMsg)) { throw new MyException(billResult.ValidFailMsg); } if (billResult.Rate == null) { throw new MyException("计算停车费失败"); } List <ParkIORecord> records = new List <ParkIORecord>() { model }; var result = from p in records select new { RecordID = p.RecordID, EntranceImageUrl = GetImagePath(p.EntranceImage, true, false), EntrancePlateImageUrl = GetImagePath(p.EntranceImage, false, false), PlateNumber = p.PlateNumber, EntranceTime = p.EntranceTime.ToString("yyyy-MM-dd HH:mm:ss"), OutTime = outTime.ToString("yyyy-MM-dd HH:mm:ss"), TotalDuration = p.EntranceTime.GetParkingDuration(outTime), TotalFee = billResult.Rate.Amount.ToString("0.0"), PaySuccess = billResult.Rate.OnlinePayAmount.ToString("0.0"), WaitPay = billResult.Rate.UnPayAmount.ToString("0.0"), DiscountAmount = billResult.Rate.DiscountAmount.ToString("0.0") }; return(Json(MyResult.Success(string.Empty, result))); } catch (MyException ex) { return(Json(MyResult.Error(ex.Message))); } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "中央缴费获取待支付记录失败"); return(Json(MyResult.Error("取待支付记录失败"))); } }
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 = "获取二维码失败" })); } }
public ActionResult TollRelease(decimal waitPay, string recordId, string carModelId) { try { string errorMsg = string.Empty; ParkIORecord model = ParkIORecordServices.GetIORecord(recordId, out errorMsg); if (!string.IsNullOrWhiteSpace(errorMsg)) { throw new MyException("获取该入场记录失败"); } if (model == null) { throw new MyException("找不到该入场记录"); } if (model.IsExit) { throw new MyException("该车辆已经出场"); } DateTime outTime = DateTime.Now; List <ParkGate> parkGates = ParkGateServices.QueryByParkAreaRecordIds(new List <string>() { model.AreaID }); ParkGate outGate = parkGates.FirstOrDefault(p => p.IoState == IoState.GoOut); if (outGate == null) { throw new MyException("获取出口通道失败"); } ResultAgs billResult = RateProcesser.GetRateResult(model, outGate, outTime, carModelId); if (!string.IsNullOrWhiteSpace(billResult.ValidFailMsg)) { throw new MyException(billResult.ValidFailMsg); } if (billResult.Rate == null) { throw new MyException("计算停车费失败"); } if (waitPay != billResult.Rate.UnPayAmount) { throw new MyException("缴费金额与实际金额不匹配,请重新选择入场记录"); } bool result = CentralFeeServices.Payment(recordId, model.ParkingID, billResult, 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("缴费失败"))); } }
public ActionResult Post(string token, string signature, string timestamp, string nonce, string echostr) { WX_ApiConfig config = WXApiConfigServices.QueryByToKen(token); if (config == null || string.IsNullOrWhiteSpace(config.AppId) || string.IsNullOrWhiteSpace(config.AppSecret) || string.IsNullOrWhiteSpace(config.Domain) || string.IsNullOrWhiteSpace(config.Token)) { return(Content(string.Empty)); } //接收数据 //System.IO.StreamReader reader = new System.IO.StreamReader(Request.InputStream); //String xmlData = reader.ReadToEnd(); //XElement xdoc = XElement.Parse(xmlData); //解析XML //var toUserName = xdoc.Element("ToUserName").Value; //var fromUserName = xdoc.Element("FromUserName").Value; //var createTime = xdoc.Element("CreateTime").Value; //string key = xdoc.Element("EventKey").Value; //var content = xdoc.Element("Ticket").Value; //DateTime datatime = DateTime.Now; //if (!string.IsNullOrEmpty(key)) //{ //userin User = wxApi.GetNickname(wxApi.GetToken(config.AppId, config.AppSecret).Accesstoken, fromUserName); // string createSql = "insert into TgCount values('" + key + "','" + createTime + "','" + User.Nickname + "','" + toUserName + "','" + datatime + "')"; // using (DbOperator dboperator = ConnectionManager.CreateReadConnection()) // { // dboperator.ExecuteNonQuery(createSql, 30000); // } //} try { TxtLogServices.WriteTxtLogEx("Api_Post", "AppId:{0};AppSecret:{1};Domain:{2};Token:{3}", config.AppId, config.AppSecret, config.Domain, config.Token); if (!config.Status) { return(Content("该公众账号暂停使用,请稍后再试!")); } if (!WxService.CheckSignature(config.Token, timestamp, nonce, signature)) { return(Content(string.Empty)); } var conversation = new WeiXinConversation(token, Request.InputStream); try { TxtLogServices.WriteTxtLogEx("Api_Post_Request", conversation.RequestDocument.ToString()); //执行微信处理过程 conversation.Execute(); if (conversation.ResponseDocument != null) { TxtLogServices.WriteTxtLogEx("Api_Post_Response", conversation.ResponseDocument.ToString()); } } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "执行微信处理过程失败", LogFrom.WeiXin); TxtLogServices.WriteTxtLogEx("Api_Post_Error", ex); if (conversation.ResponseDocument != null) { TxtLogServices.WriteTxtLogEx("Api_Post_Error", conversation.ResponseDocument.ToString()); } } if (conversation.ResponseDocument != null) { //如果是微信位置推送则不回复 if (conversation.Request.MsgType == WReqType.Event) { WReqEventBase wreqevent = conversation.Request as WReqEventBase; if (wreqevent != null && wreqevent.Event == EventType.Location) { return(Content(string.Empty)); } } return(Content(conversation.ResponseDocument.ToString())); } } catch (Exception ex) { ExceptionsServices.AddExceptions(ex, "微信提交事件处理失败", LogFrom.WeiXin); TxtLogServices.WriteTxtLogEx("Api_Post_Error", ex); } return(Content(string.Empty)); }