/// <summary> /// 删除规则 /// </summary> /// <returns></returns> public ActionResult DelMsgRules() { result = new PlatReturnMsg(); int appId = Utility.IO.Context.GetRequestInt("appId", 0); int ruleId = Utility.IO.Context.GetRequestInt("ruleId", 0); if (appId <= 0 || ruleId <= 0) { result.Msg = "参数错误"; return(Json(result)); } PlatMsgRule model = PlatMsgRuleBLL.SingleModel.GetMsgRules(appId, ruleId); if (model == null) { result.Msg = "数据不存在"; return(Json(result)); } model.State = -1; model.UpdateTime = DateTime.Now; if (!PlatMsgRuleBLL.SingleModel.Update(model, "State,UpdateTime")) { result.Msg = "删除异常"; return(Json(result)); } result.isok = true; result.Msg = "删除成功"; return(Json(result)); }
/// <summary> /// 后台手动置顶将未置顶的消息 /// </summary> /// <returns></returns> public ActionResult DoTopMsg() { result = new PlatReturnMsg(); int appId = Utility.IO.Context.GetRequestInt("aid", 0); int Id = Utility.IO.Context.GetRequestInt("Id", 0); int ruleId = Utility.IO.Context.GetRequestInt("ruleId", 0); if (appId <= 0 || Id <= 0) { result.Msg = "参数错误"; return(Json(result)); } PlatMsg model = PlatMsgBLL.SingleModel.GetModel(Id); if (model == null) { result.Msg = "数据不存在"; return(Json(result)); } if (ruleId <= 0) { result.Msg = "请选择置顶时间"; return(Json(result)); } PlatMsgRule platMsgRule = PlatMsgRuleBLL.SingleModel.GetMsgRules(appId, ruleId); if (platMsgRule == null) { result.Msg = "非法操作(置顶时间有误)"; return(Json(result)); } //if (model.Review == 2|| model.Review == 0) //{ // model.ReviewTime = DateTime.Now; //} model.ReviewTime = DateTime.Now; model.TopDay = platMsgRule.ExptimeDay; model.TopCostPrice = platMsgRule.Price; model.IsTop = 1; model.IsDoTop = 1; model.UpdateTime = DateTime.Now; if (PlatMsgBLL.SingleModel.Update(model, "TopDay,TopCostPrice,IsTop,IsDoTop,UpdateTime,ReviewTime")) { result.isok = true; result.Msg = "操作成功"; return(Json(result)); } else { result.Msg = "操作失败"; return(Json(result)); } }
/// <summary> /// 发帖 /// </summary> /// <param name="jsondata"></param> /// <param name="ordertype"></param> /// <param name="paytype"></param> /// <param name="aid"></param> /// <param name="order"></param> /// <param name="MyCardId"></param> /// <returns></returns> public string saveMsg(string jsondata, int ordertype, int paytype, int aid, ref CityMorders order, int userId) { if (string.IsNullOrEmpty(jsondata)) { return("json参数错误"); } SavePlatMsgModel savePlatMsgModelJson = JsonConvert.DeserializeObject <SavePlatMsgModel>(jsondata); if (savePlatMsgModelJson == null) { return("null参数错误"); } double lng = 0.00; double lat = 0.00; //校验手机号码 if (!Regex.IsMatch(savePlatMsgModelJson.Phone, @"\d") || savePlatMsgModelJson.Phone.Length > 11) { return("联系号码不符合"); } if (string.IsNullOrEmpty(savePlatMsgModelJson.Location)) { return("请填写地址"); } if (string.IsNullOrEmpty(savePlatMsgModelJson.MsgDetail)) { return("发布信息不能为空"); } if (!double.TryParse(savePlatMsgModelJson.Lng, out lng) || !double.TryParse(savePlatMsgModelJson.Lat, out lat)) { return("地址坐标错误"); } if (savePlatMsgModelJson.MsgType <= 0) { return("请选择信息类别"); } PlatMyCard platMyCard = PlatMyCardBLL.SingleModel.GetModelByUserId(userId, aid); if (platMyCard == null) { return("请先注册"); } PlatMsg platMsg = new PlatMsg(); platMsg.AddTime = DateTime.Now; platMsg.Aid = aid; platMsg.Lat = savePlatMsgModelJson.Lat; platMsg.Lng = savePlatMsgModelJson.Lng; platMsg.Location = savePlatMsgModelJson.Location; platMsg.MsgDetail = HttpUtility.HtmlEncode(savePlatMsgModelJson.MsgDetail); platMsg.MsgTypeId = savePlatMsgModelJson.MsgType; platMsg.Phone = savePlatMsgModelJson.Phone; platMsg.MyCardId = platMyCard.Id; platMsg.Imgs = savePlatMsgModelJson.Imgs; PlatMsgConf platMsgConf = PlatMsgConfBLL.SingleModel.GetMsgConf(aid); if (platMsgConf == null) { return("商家配置异常"); } switch (platMsgConf.ReviewSetting) { case 0: //不需要审核 if (savePlatMsgModelJson.IsTop == 0) { //不置顶消息 platMsg.State = 1; platMsg.Review = 0; platMsg.PayState = 1; platMsg.ReviewTime = DateTime.Now; } else { platMsg.State = 0; //支付回成功调后再变更1 platMsg.PayState = 0; //支付回成功调后再变更1 platMsg.ReviewTime = DateTime.Now; platMsg.Review = 0; } break; case 1: //先审核后发布 platMsg.State = 0; //审核通过后变为1 platMsg.Review = 1; //审核通过后变为2 审核不通过变为-1 if (savePlatMsgModelJson.IsTop == 0) { //不置顶消息 platMsg.PayState = 1; } else { platMsg.PayState = 0; //支付回成功调后再变更为1 } break; case 2: //先发布后审核 platMsg.ReviewTime = DateTime.Now; if (savePlatMsgModelJson.IsTop == 0) { //不置顶消息 platMsg.State = 1; platMsg.PayState = 1; platMsg.Review = 1; //审核通过后变为2 审核不通过变为-1 } else { platMsg.State = 0; //支付回成功调后再变更为1 platMsg.PayState = 0; //支付回成功调后再变更为1 platMsg.Review = 1; //审核通过后变为2 审核不通过变为-1 } break; } if (savePlatMsgModelJson.IsTop == 0) { //表示不置顶的消息 platMsg.TopDay = 0; platMsg.IsTop = 0; platMsg.TopCostPrice = 0; int msgId = Convert.ToInt32(base.Add(platMsg)); if (msgId <= 0) { return("发布信息异常"); } else { return(string.Empty); } } else { //表示置顶消息 需要 生成微信订单,然后微信支付,支付成功后回调将状态变为1可用 if (savePlatMsgModelJson.RuleId <= 0) { return("请选择置顶时间"); } PlatMsgRule platMsgRule = PlatMsgRuleBLL.SingleModel.GetMsgRules(aid, savePlatMsgModelJson.RuleId); if (platMsgRule == null) { return("非法操作(置顶时间有误)"); } platMsg.TopDay = platMsgRule.ExptimeDay; platMsg.TopCostPrice = platMsgRule.Price; platMsg.IsTop = 1; int msgId = Convert.ToInt32(base.Add(platMsg)); if (msgId <= 0) { return("发布信息异常"); } else { order.Articleid = platMsgRule.Id; order.CommentId = msgId; order.MinisnsId = aid; order.payment_free = platMsg.TopCostPrice; order.ShowNote = $"平台版小程序分类信息发置顶帖付款{order.payment_free * 0.01}元"; return(string.Empty); } } }
/// <summary> /// 编辑或者新增 置顶规则 /// </summary> /// <param name="city_Storemsgrules"></param> /// <returns></returns> public ActionResult SaveMsgRule(PlatMsgRule platMsgRule) { result = new PlatReturnMsg(); if (platMsgRule == null) { result.Msg = "数据不能为空"; return(Json(result)); } if (platMsgRule.Aid <= 0) { result.Msg = "appId非法"; return(Json(result)); } if (!Regex.IsMatch(platMsgRule.ExptimeDay.ToString(), @"^\+?[1-9][0-9]*$")) { result.Msg = "置顶时间天数必须为大于零的整数"; return(Json(result)); } if (!Regex.IsMatch(platMsgRule.Price.ToString(), @"^\+?[0-9][0-9]*$")) { result.Msg = "金额不合法"; return(Json(result)); } int Id = platMsgRule.Id; if (Id == 0) { //表示新增 Id = Convert.ToInt32(PlatMsgRuleBLL.SingleModel.Add(new PlatMsgRule() { ExptimeDay = platMsgRule.ExptimeDay, Price = platMsgRule.Price, AddTime = DateTime.Now, UpdateTime = DateTime.Now, Aid = platMsgRule.Aid, State = 0 })); if (Id > 0) { result.isok = true; result.Msg = "新增成功"; return(Json(result)); } else { result.Msg = "新增失败"; return(Json(result)); } } else { //表示更新 PlatMsgRule model = PlatMsgRuleBLL.SingleModel.GetModel(Id); if (model == null) { result.Msg = "不存在数据库里"; return(Json(result)); } if (model.Aid != platMsgRule.Aid) { result.Msg = "权限不足"; return(Json(result)); } model.UpdateTime = DateTime.Now; model.ExptimeDay = platMsgRule.ExptimeDay; model.Price = platMsgRule.Price; if (PlatMsgRuleBLL.SingleModel.Update(model, "UpdateTime,ExptimeDay,Price")) { result.isok = true; result.Msg = "更新成功"; return(Json(result)); } else { result.Msg = "更新失败"; return(Json(result)); } } }