/// <summary> /// 删除项目分类 /// </summary> /// <returns></returns> public ActionResult DelType() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId}"); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } int id = Context.GetRequestInt("id", -1); if (id < 0) { return(Json(new { isok = false, msg = "系统繁忙id_null" })); } EntGoodType typeInfo = EntGoodTypeBLL.SingleModel.GetServiceItem(appId, storeModel.Id, (int)GoodProjectType.足浴版服务项目分类, id); if (typeInfo == null) { return(Json(new { isok = false, msg = "系统繁忙info_null" })); } //获取该分类下的项目数目 int serviceCount = EntGoodsBLL.SingleModel.GetServiceCountById(appId, typeInfo.id); if (serviceCount > 0) { return(Json(new { isok = false, msg = $"不可删除:该分类下已关联{serviceCount}个项目" })); } typeInfo.state = 0; bool isok = EntGoodTypeBLL.SingleModel.Update(typeInfo, "state"); string msg = isok ? "已删除" : "删除失败"; return(Json(new { isok = isok, msg = msg })); }
/// <summary> /// 添加编辑包间信息 /// </summary> /// <returns></returns> public ActionResult SaveRoomInfo() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙id_null" })); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙account_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModel($"appId={appId}"); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙store_null" })); } int id = Context.GetRequestInt("id", 0); string name = Context.GetRequest("name", string.Empty); int count = Context.GetRequestInt("count", 0); if (string.IsNullOrEmpty(name)) { return(Json(new { isok = false, msg = "请输入包间名称" })); } if (name.Length > 20) { return(Json(new { isok = false, msg = "包间名称不能超过20字" })); } if (count < 1 || count > 999) { return(Json(new { isok = false, msg = "容纳人数:请输入0~999之间的整数" })); } EntGoodType roomInfo = EntGoodTypeBLL.SingleModel.GetModelByName(appId, storeModel.Id, (int)GoodProjectType.足浴版包间分类, name); bool isok = false; if (roomInfo != null && roomInfo.state > 0 && id <= 0) { return(Json(new { isok = false, msg = "该包间名称已存在" })); } if (roomInfo != null && roomInfo.state > 0 && id > 0 && roomInfo.id != id) { return(Json(new { isok = false, msg = "该包间名称已存在" })); } //添加 if (id <= 0) { roomInfo = new EntGoodType() { aid = appId, type = (int)GoodProjectType.足浴版包间分类, name = name, count = count, state = 1, }; isok = Convert.ToInt32(EntGoodTypeBLL.SingleModel.Add(roomInfo)) > 0; } else { //编辑保存 roomInfo = EntGoodTypeBLL.SingleModel.GetModel(id); if (roomInfo == null || roomInfo.type != (int)GoodProjectType.足浴版包间分类 || roomInfo.state <= 0 || roomInfo.aid != appId) { return(Json(new { isok = false, msg = "数据错误" })); } roomInfo.count = count; roomInfo.name = name; isok = EntGoodTypeBLL.SingleModel.Update(roomInfo, "name,count"); } string msg = isok ? "保存成功" : "保存失败"; return(Json(new { isok = isok, msg = msg })); }
/// <summary> /// 保存(添加|编辑的)分类 /// </summary> /// <returns></returns> public ActionResult SaveType() { int appId = Context.GetRequestInt("appId", 0); if (appId <= 0) { return(Json(new { isok = false, msg = "系统繁忙appid_null" }, JsonRequestBehavior.AllowGet)); } if (dzaccount == null) { return(Json(new { isok = false, msg = "系统繁忙auth_null" })); } XcxAppAccountRelation appAcountRelation = XcxAppAccountRelationBLL.SingleModel.GetModelByaccountidAndAppid(appId, dzaccount.Id.ToString()); if (appAcountRelation == null) { return(Json(new { isok = false, msg = "系统繁忙relation_null" })); } FootBath storeModel = FootBathBLL.SingleModel.GetModelByAppId(appId); if (storeModel == null) { return(Json(new { isok = false, msg = "系统繁忙model_null" })); } int id = Context.GetRequestInt("id", -1); if (id < 0) { return(Json(new { isok = false, msg = "系统繁忙id_null" })); } string name = Context.GetRequest("name", string.Empty); if (string.IsNullOrEmpty(name)) { return(Json(new { isok = false, msg = "请填写分类名称" })); } if (name.Length > 8) { return(Json(new { isok = false, msg = "分类名称不能超过8字" })); } int sort = Context.GetRequestInt("sort", 0); if (sort < 1 || sort > 99) { return(Json(new { isok = false, msg = "排序请填写1~99之间的整数" })); } if (EntGoodTypeBLL.SingleModel.ValidItemName(appId, storeModel.Id, (int)GoodProjectType.足浴版服务项目分类, id, name)) { return(Json(new { isok = false, msg = "该分类名称已存在!" })); } EntGoodType typeInfo = null; bool isok = false; if (id > 0) //保存编辑 { typeInfo = EntGoodTypeBLL.SingleModel.GetServiceItem(appId, storeModel.Id, (int)GoodProjectType.足浴版服务项目分类, id); if (typeInfo == null) { return(Json(new { isok = false, msg = "系统繁忙info_null" })); } typeInfo.name = name; typeInfo.sort = sort; isok = EntGoodTypeBLL.SingleModel.Update(typeInfo, "name,sort"); } else //保存添加 { typeInfo = new EntGoodType(); typeInfo.aid = appId; typeInfo.storeId = storeModel.Id; typeInfo.name = name; typeInfo.sort = sort; typeInfo.type = (int)GoodProjectType.足浴版服务项目分类; typeInfo.state = 1; isok = Convert.ToInt32(EntGoodTypeBLL.SingleModel.Add(typeInfo)) > 0; } if (isok) { List <EntGoodType> goodTypeList = EntGoodTypeBLL.SingleModel.GetServiceItemList(appId, storeModel.Id, (int)GoodProjectType.足浴版服务项目分类); return(Json(new { isok = isok, msg = "保存成功", list = goodTypeList })); } else { return(Json(new { isok = isok, msg = "保存失败" })); } }