/// <summary> /// 编辑城市门店配置 /// </summary> /// <param name="packageId"></param> /// <param name="regionShops"></param> /// <returns></returns> public ActionResult UpsertPackageRegion(int packageId, string regionShops) { if (packageId < 0) { return(Json(new { Status = false, Msg = "未知的喷漆打折价格体系" }, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrWhiteSpace(regionShops)) { return(Json(new { Status = false, Msg = "请配置门店和城市" }, JsonRequestBehavior.AllowGet)); } var manager = new PaintDiscountConfigManager(); var package = manager.GetPaintDiscountPackage(packageId); if (package == null) { return(Json(new { Status = false, Msg = "未知的喷漆打折价格体系" }, JsonRequestBehavior.AllowGet)); } var regionShopPair = null as List <RegionShopPairModel>; try { regionShopPair = JsonConvert.DeserializeObject <List <RegionShopPairModel> >(regionShops); } catch (Exception) { regionShopPair = null; } if (regionShopPair != null && regionShopPair.Any()) { if (regionShopPair.Any(s => (s.RegionId < 1 && s.ShopIds != null && s.ShopIds.Any()) || (s.ShopIds != null && s.ShopIds.Any(v => v < 1)))) { return(Json(new { Status = false, Msg = $"未知的门店" }, JsonRequestBehavior.AllowGet)); } var list = manager.ConvertToPackageRegionModel(packageId, regionShopPair); var exist = manager.GetRepeatPackageRegion(packageId, package.UserType, list); if (exist != null && exist.Any()) { return(Json(new { Status = false, Msg = string.Join("</br>", exist) }, JsonRequestBehavior.AllowGet)); } var result = manager.UpsertPackageRegion(packageId, package.UserType, list, User.Identity.Name); return(Json(new { Status = result, Msg = $"编辑{(result ? "成功" : "失败")}" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Status = false, Msg = $"请配置门店和城市" }, JsonRequestBehavior.AllowGet)); } }