更新订单
This commit is contained in:
@@ -0,0 +1,226 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using COMCMS.Common;
|
||||
using COMCMS.Core;
|
||||
using XCode;
|
||||
using Newtonsoft.Json;
|
||||
using COMCMS.Web.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
public class GuestbookController : AdminBaseController
|
||||
{
|
||||
#region 留言板分类
|
||||
[MyAuthorize("viewlist", "guestbookkinds")]
|
||||
public IActionResult GuestbookCategorys()
|
||||
{
|
||||
IList<GuestbookCategory> list = GuestbookCategory.FindAll(null, GuestbookCategory._.Rank.Asc(), null, 0, 0);
|
||||
Core.Admin.WriteLogActions("查看留言分类列表页面;");
|
||||
return View(list);
|
||||
}
|
||||
//添加
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "guestbookkinds", "JSON")]
|
||||
public IActionResult AddGuestbookCategory(GuestbookCategory model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.KindName))
|
||||
{
|
||||
tip.Message = "请输入留言分类标题!";
|
||||
return Json(tip);
|
||||
}
|
||||
model.Insert();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "添加成功!";
|
||||
Core.Admin.WriteLogActions("添加留言分类(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//执行编辑操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("edit", "guestbookkinds", "JSON")]
|
||||
public IActionResult EditGuestbookCategory(GuestbookCategory model)
|
||||
{
|
||||
if (model.Id <= 0)
|
||||
{
|
||||
tip.Message = "错误参数传递!";
|
||||
return Json(tip);
|
||||
}
|
||||
GuestbookCategory oldentity = GuestbookCategory.Find(GuestbookCategory._.Id == model.Id);
|
||||
if (oldentity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.KindName))
|
||||
{
|
||||
tip.Message = "请输入留言分类标题!";
|
||||
return Json(tip);
|
||||
}
|
||||
model.Update();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "编辑留言分类成功";
|
||||
Core.Admin.WriteLogActions("编辑留言分类(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
//执行删除操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "guestbookkinds", "JSON")]
|
||||
public JsonResult DelGuestbookCategory(int id)
|
||||
{
|
||||
GuestbookCategory entity = GuestbookCategory.Find(GuestbookCategory._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本留言分类!";
|
||||
return Json(tip);
|
||||
}
|
||||
//删除栏目下所有留言
|
||||
IList<Guestbook> list = Guestbook.FindAll(Guestbook._.KId == entity.Id, null, null, 0, 0);
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
list.Delete();
|
||||
}
|
||||
Core.Admin.WriteLogActions("删除留言分类(id:" + entity.Id + ");");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除留言分类成功";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 留言列表
|
||||
[MyAuthorize("viewlist", "guestbook")]
|
||||
public IActionResult GuestbookList()
|
||||
{
|
||||
IList<GuestbookCategory> list = GuestbookCategory.FindAll(null, GuestbookCategory._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
return View();
|
||||
}
|
||||
[MyAuthorize("viewlist", "guestbook")]
|
||||
public IActionResult GetGuesbookList(string keyword, int page = 1, int limit = 20)
|
||||
{
|
||||
int numPerPage, currentPage, startRowIndex;
|
||||
|
||||
numPerPage = limit;
|
||||
currentPage = page;
|
||||
startRowIndex = (currentPage - 1) * numPerPage;
|
||||
Expression ex = Guestbook._.Id > 0;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
{
|
||||
if (Utils.IsInt(keyword))
|
||||
{
|
||||
ex &= (Guestbook._.Id == int.Parse(keyword) | Guestbook._.Title.Contains(keyword));
|
||||
}
|
||||
else
|
||||
{
|
||||
ex &= Guestbook._.Title.Contains(keyword);
|
||||
}
|
||||
}
|
||||
string kid = Request.Query["kid"];
|
||||
if (Utils.IsInt(kid) && int.Parse(kid) > 0)
|
||||
{
|
||||
ex &= Guestbook._.KId == int.Parse(kid);
|
||||
}
|
||||
IList<Guestbook> list = Guestbook.FindAll(ex, Guestbook._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
long totalCount = Guestbook.FindCount(ex, Guestbook._.Id.Desc(), null, startRowIndex, numPerPage);
|
||||
Core.Admin.WriteLogActions("查看留言列表(page:" + page + ");");
|
||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 编辑留言
|
||||
[MyAuthorize("edit", "guestbook")]
|
||||
public IActionResult EditGuestbook(int id)
|
||||
{
|
||||
IList<GuestbookCategory> list = GuestbookCategory.FindAll(GuestbookCategory._.Id > 0, GuestbookCategory._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
Guestbook entity = Guestbook.Find(Guestbook._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
return EchoTipPage("系统找不到本记录!");
|
||||
}
|
||||
if (entity.IsRead != 1)
|
||||
{
|
||||
entity.IsRead = 1;
|
||||
entity.Update();
|
||||
}
|
||||
|
||||
Core.Admin.WriteLogActions("查看/回复留言(" + id + ");");
|
||||
|
||||
return View(entity);
|
||||
}
|
||||
[HttpPost]
|
||||
[MyAuthorize("edit", "guestbook", "JSON")]
|
||||
public IActionResult EditGuestbook(FormCollection fc)
|
||||
{
|
||||
string id = fc["Id"];
|
||||
if (!Utils.IsInt(id) || int.Parse(id) <= 0)
|
||||
{
|
||||
tip.Message = "错误参数传递!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
Guestbook entity = Guestbook.FindById(int.Parse(id));
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录";
|
||||
return Json(tip);
|
||||
}
|
||||
string kid = fc["KId"];
|
||||
if (Utils.IsInt(kid) && int.Parse(kid) != entity.KId)
|
||||
{
|
||||
entity.KId = int.Parse(kid);
|
||||
}
|
||||
string isverify = fc["IsVerify"];
|
||||
if (!string.IsNullOrEmpty(isverify) && isverify == "1")
|
||||
{
|
||||
entity.IsVerify = 1;
|
||||
}
|
||||
else
|
||||
entity.IsVerify = 0;
|
||||
string replayuser = fc["ReplyUser"];
|
||||
entity.ReplyNickName = replayuser;
|
||||
string reply = fc["Reply"];
|
||||
entity.ReplyContent = reply;
|
||||
if (!string.IsNullOrEmpty(entity.ReplyContent) && entity.ReplyAdminId == 0)
|
||||
{
|
||||
entity.ReplyAdminId = Core.Admin.GetMyInfo().Id;
|
||||
entity.ReplyIP = Utils.GetIP();
|
||||
entity.ReplyAddTime = DateTime.Now;
|
||||
}
|
||||
entity.Update();
|
||||
Core.Admin.WriteLogActions("编辑审核留言(id:" + entity.Id + ");");
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "编辑/审核留言详情成功";
|
||||
tip.ReturnUrl = "close";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除留言
|
||||
//删除文章
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "guestbook", "JSON")]
|
||||
public JsonResult DelGuestbook(int id)
|
||||
{
|
||||
Guestbook entity = Guestbook.Find(Guestbook._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本留言!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
Core.Admin.WriteLogActions("删除留言(id:" + entity.Id + ");");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除留言成功";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using COMCMS.Common;
|
||||
using COMCMS.Core;
|
||||
using XCode;
|
||||
using Newtonsoft.Json;
|
||||
using COMCMS.Web.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
public class OrderController : AdminBaseController
|
||||
{
|
||||
#region 订单列表
|
||||
[MyAuthorize("viewlist", "order")]
|
||||
public IActionResult OrderList()
|
||||
{
|
||||
Core.Admin.WriteLogActions("查看订单列表;");
|
||||
return View();
|
||||
}
|
||||
|
||||
[MyAuthorize("viewlist", "order", "JSON")]
|
||||
public IActionResult GetOrderList(string keyword, int page = 1, int limit = 20, int kid = 0)
|
||||
{
|
||||
int numPerPage, currentPage, startRowIndex;
|
||||
|
||||
numPerPage = limit;
|
||||
currentPage = page;
|
||||
startRowIndex = (currentPage - 1) * numPerPage;
|
||||
Expression ex = Order._.Id > 0 & Order._.MyType == (int)Utils.MyType.商品;
|
||||
string status = Request.Query["status"];
|
||||
if (!string.IsNullOrEmpty(status))
|
||||
ex &= Order._.OrderStatus == status;
|
||||
|
||||
string paystatus = Request.Query["paystatus"];
|
||||
if (!string.IsNullOrEmpty(paystatus))
|
||||
ex &= Order._.PaymentStatus == paystatus;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
ex &= (Order._.Title.Contains(keyword) | Order._.OrderNum.Contains(keyword) | Order._.RealName.Contains(keyword) | Order._.Address.Contains(keyword));
|
||||
|
||||
IList<Order> list = Order.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
long totalCount = Order.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查看/编辑订单详情
|
||||
[MyAuthorize("edit", "order")]
|
||||
public IActionResult EditOrder(int id)
|
||||
{
|
||||
Order entity = Order.Find(Order._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
return EchoTipPage("系统找不到本记录!");
|
||||
}
|
||||
//获取订单详情
|
||||
IList<OrderDetail> list = OrderDetail.FindAll(OrderDetail._.OrderId == entity.Id, null, null, 0, 0);
|
||||
ViewBag.list = list;
|
||||
//日志
|
||||
IList<OrderLog> OrderLogList = OrderLog.FindAll(OrderLog._.OrderId == entity.Id, null, null, 0, 0);
|
||||
ViewBag.OrderLogList = OrderLogList;
|
||||
Core.Admin.WriteLogActions($"查看订单详情(id:{entity.Id});");
|
||||
return View(entity);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除订单
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "order", "JSON")]
|
||||
public IActionResult DelOrder(int id)
|
||||
{
|
||||
Order entity = Order.Find(Order._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本订单";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.PaymentStatus == Utils.PaymentState[1])
|
||||
{
|
||||
tip.Message = "已经支付订单,不能删除!";
|
||||
return Json(tip);
|
||||
}
|
||||
IList<OrderDetail> list = OrderDetail.FindAll(OrderDetail._.OrderId == entity.Id, null, null, 0, 0);
|
||||
IList<OrderLog> OrderLogList = OrderLog.FindAll(OrderLog._.OrderId == entity.Id, null, null, 0, 0);
|
||||
OrderLogList.Delete();
|
||||
list.Delete();
|
||||
Admin.WriteLogActions($"删除订单(id:{id},订单号:{entity.OrderNum},{JsonConvert.SerializeObject(entity)});");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除成功!";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 确认订单
|
||||
[HttpPost]
|
||||
[MyAuthorize("confirm", "order")]
|
||||
public IActionResult ConfirmOrder(int id)
|
||||
{
|
||||
Order entity = Order.Find(Order._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.OrderStatus != Utils.OrdersState[0])
|
||||
{
|
||||
tip.Message = "非未确认订单,无法确认订单!";
|
||||
return Json(tip);
|
||||
}
|
||||
entity.OrderStatus = Utils.OrdersState[1];
|
||||
entity.LastModTime = DateTime.Now;
|
||||
entity.Update();
|
||||
Admin admin = Admin.GetMyInfo();
|
||||
|
||||
//写入记录
|
||||
OrderLog log = new OrderLog()
|
||||
{
|
||||
AddTime = DateTime.Now,
|
||||
Actions = "管理员确认订单",
|
||||
OrderId = entity.Id,
|
||||
OrderNum = entity.OrderNum,
|
||||
UId = -admin.Id
|
||||
};
|
||||
log.Insert();
|
||||
Admin.WriteLogActions($"确认订单(id:{entity.Id});");
|
||||
tip.Message = "确认订单成功!";
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.ReturnUrl = "/AdminCP/Order/EditOrder/" + entity.Id;
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 完成订单
|
||||
[HttpPost]
|
||||
[MyAuthorize("confirm", "order")]
|
||||
public IActionResult CompleteOrder(int id)
|
||||
{
|
||||
Order entity = Order.Find(Order._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.OrderStatus != Utils.OrdersState[1] || entity.PaymentStatus != Utils.PaymentState[1] || string.IsNullOrEmpty(entity.DeliverNO))
|
||||
{
|
||||
tip.Message = "只有已经确认、支付、发货的订单,才能设置成订单已完成!";
|
||||
return Json(tip);
|
||||
}
|
||||
entity.OrderStatus = Utils.OrdersState[2];
|
||||
entity.LastModTime = DateTime.Now;
|
||||
entity.Update();
|
||||
|
||||
//执行分销
|
||||
decimal totalRechargePrice = entity.TotalPrice;
|
||||
Member my = Member.FindById(entity.UId);
|
||||
|
||||
//自己返现
|
||||
if (my.Roles.CashBack > 0)
|
||||
{
|
||||
decimal myreward = entity.TotalPrice * my.Roles.CashBack / 100;
|
||||
//totalRechargePrice = totalRechargePrice - myreward;//减去自己的计算
|
||||
Member.ToCashBack(my.Id, myreward, $"我的销售返现,消费:¥{entity.TotalPrice.ToString("N2")};返现比例({my.Roles.CashBack.ToString("N2")}%),共:¥{myreward.ToString("N2")}", entity.Id, entity.OrderNum);
|
||||
}
|
||||
|
||||
if (my.Parent > 0)
|
||||
{
|
||||
Member.SaleCommission(my.Id, totalRechargePrice, my.Parent, entity.OrderNum, 1, entity.Id, entity.TotalPrice);
|
||||
}
|
||||
if (my.Grandfather > 0)
|
||||
{
|
||||
Member.SaleCommission(my.Id, totalRechargePrice, my.Grandfather, entity.OrderNum, 2, entity.Id, entity.TotalPrice);
|
||||
}
|
||||
|
||||
Admin admin = Admin.GetMyInfo();
|
||||
|
||||
//写入记录
|
||||
OrderLog log = new OrderLog()
|
||||
{
|
||||
AddTime = DateTime.Now,
|
||||
Actions = "管理员设置订单【已完成】",
|
||||
OrderId = entity.Id,
|
||||
OrderNum = entity.OrderNum,
|
||||
UId = -admin.Id
|
||||
};
|
||||
log.Insert();
|
||||
Admin.WriteLogActions($"完成订单(id:{entity.Id});");
|
||||
tip.Message = "确认订单已完成成功!";
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.ReturnUrl = "/AdminCP/Order/EditOrder/" + entity.Id;
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 修改运费
|
||||
[HttpPost]
|
||||
public IActionResult DoChangeOrderFare(int id, decimal fare)
|
||||
{
|
||||
Order entity = Order.Find(Order._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.PaymentStatus != Utils.PaymentState[0])
|
||||
{
|
||||
tip.Message = "非未支付订单,无法修改订单运费!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (fare < 0)
|
||||
{
|
||||
tip.Message = "运费不能小于0!";
|
||||
return Json(tip);
|
||||
}
|
||||
entity.Fare = fare;
|
||||
entity.TotalPay = entity.TotalPrice + fare;
|
||||
entity.LastModTime = DateTime.Now;
|
||||
entity.Update();
|
||||
Admin admin = Admin.GetMyInfo();
|
||||
|
||||
//写入记录
|
||||
OrderLog log = new OrderLog()
|
||||
{
|
||||
AddTime = DateTime.Now,
|
||||
Actions = $"管理员修改订单运费为:¥{entity.Fare.ToString("N2")}",
|
||||
OrderId = entity.Id,
|
||||
OrderNum = entity.OrderNum,
|
||||
UId = -admin.Id
|
||||
};
|
||||
log.Insert();
|
||||
Admin.WriteLogActions($"修改订单运费(id:{entity.Id},fare:{entity.Fare});");
|
||||
tip.Message = "修改订单运费成功!";
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.ReturnUrl = "/AdminCP/Order/EditOrder/" + entity.Id;
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 修改物流信息
|
||||
[HttpPost]
|
||||
public IActionResult DoChangeOrderDeliver(int id, string DeliverType = "", string DeliverNO = "")
|
||||
{
|
||||
Order entity = Order.Find(Order._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.PaymentStatus == Utils.PaymentState[0])
|
||||
{
|
||||
tip.Message = "非已支付订单,无法修改订单配送状态!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.OrderStatus == Utils.OrdersState[2] || entity.OrderStatus == Utils.OrdersState[3])
|
||||
{
|
||||
tip.Message = "订单状态错误,无法修改订单配送状态!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(DeliverNO))
|
||||
{
|
||||
tip.Message = "请输入运单号!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (entity.DeliverType == DeliverType && entity.DeliverNO == DeliverNO)
|
||||
{
|
||||
tip.Message = "物流信息并无修改!";
|
||||
return Json(tip);
|
||||
}
|
||||
entity.DeliverType = DeliverType;
|
||||
entity.DeliverNO = DeliverNO;
|
||||
entity.DeliverStatus = Utils.DeliverState[2];
|
||||
entity.LastModTime = DateTime.Now;
|
||||
entity.Update();
|
||||
Admin admin = Admin.GetMyInfo();
|
||||
//写入记录
|
||||
OrderLog log = new OrderLog()
|
||||
{
|
||||
AddTime = DateTime.Now,
|
||||
Actions = $"发货:物流:{entity.DeliverType};订单号:{entity.DeliverNO}",
|
||||
OrderId = entity.Id,
|
||||
OrderNum = entity.OrderNum,
|
||||
UId = -admin.Id
|
||||
};
|
||||
log.Insert();
|
||||
Admin.WriteLogActions($"修改订单发货状态:物流:{entity.DeliverType};订单号:{entity.DeliverNO};");
|
||||
tip.Message = "修改订单物流配送成功!";
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.ReturnUrl = "/AdminCP/Order/EditOrder/" + entity.Id;
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 在线支付成功记录
|
||||
[MyAuthorize("viewlist", "payonline")]
|
||||
public IActionResult PayOnlineList()
|
||||
{
|
||||
Core.Admin.WriteLogActions("查看在线支付订单列表;");
|
||||
return View();
|
||||
}
|
||||
|
||||
[MyAuthorize("viewlist", "payonline", "JSON")]
|
||||
public IActionResult GetPayOnlineList(string keyword, int page = 1, int limit = 20, int kid = 0)
|
||||
{
|
||||
int numPerPage, currentPage, startRowIndex;
|
||||
|
||||
numPerPage = limit;
|
||||
currentPage = page;
|
||||
startRowIndex = (currentPage - 1) * numPerPage;
|
||||
Expression ex = OnlinePayOrder._.Id > 0 & OnlinePayOrder._.PaymentStatus == Utils.PaymentState[1];
|
||||
|
||||
string mytype = Request.Query["mytype"];
|
||||
if (Utils.IsInt(mytype) && int.Parse(mytype) > 0)
|
||||
{
|
||||
ex &= OnlinePayOrder._.MyType == int.Parse(mytype);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
ex &= OnlinePayOrder._.Title.Contains(keyword);
|
||||
|
||||
IList<OnlinePayOrder> list = OnlinePayOrder.FindAll(ex, null, null, startRowIndex, numPerPage);
|
||||
long totalCount = OnlinePayOrder.FindCount(ex, null, null, startRowIndex, numPerPage);
|
||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,642 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using COMCMS.Common;
|
||||
using COMCMS.Core;
|
||||
using XCode;
|
||||
using Newtonsoft.Json;
|
||||
using COMCMS.Web.Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using COMCMS.Core.Models;
|
||||
|
||||
namespace COMCMS.Web.Areas.AdminCP.Controllers
|
||||
{
|
||||
public class OtherController : AdminBaseController
|
||||
{
|
||||
#region 广告分类管理
|
||||
//查看&编辑广告分类(同一个页面执行)
|
||||
[MyAuthorize("viewlist", "adskinds")]
|
||||
public IActionResult AdsCategoryList()
|
||||
{
|
||||
IList<AdsKind> list = AdsKind.FindAll(null, AdsKind._.Rank.Asc(), null, 0, 0);
|
||||
Core.Admin.WriteLogActions("查看广告分类列表页面;");
|
||||
return View(list);
|
||||
}
|
||||
|
||||
//执行添加操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "adskinds", "JSON")]
|
||||
public IActionResult AddAdsKind(AdsKind model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.KindName))
|
||||
{
|
||||
tip.Message = "广告分类名称不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
model.Insert();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "添加广告分类成功";
|
||||
Core.Admin.WriteLogActions("添加广告栏目(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//执行编辑操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("edit", "adskinds", "JSON")]
|
||||
public IActionResult EditAdsKind(AdsKind model)
|
||||
{
|
||||
if (model.Id <= 0)
|
||||
{
|
||||
tip.Message = "错误参数传递!";
|
||||
return Json(tip);
|
||||
}
|
||||
AdsKind oldentity = AdsKind.Find(AdsKind._.Id == model.Id);
|
||||
if (oldentity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.KindName))
|
||||
{
|
||||
tip.Message = "广告分类名称不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
model.Update();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "编辑广告分类成功";
|
||||
Core.Admin.WriteLogActions("编辑广告栏目(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
//执行删除操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "adskinds", "JSON")]
|
||||
public JsonResult DelAdsKind(int id)
|
||||
{
|
||||
AdsKind entity = AdsKind.Find(AdsKind._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本广告分类!";
|
||||
return Json(tip);
|
||||
}
|
||||
//删除旗下广告
|
||||
IList<Ads> list = Ads.FindAll(Ads._.KId == entity.Id, null, null, 0, 0);
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
list.Delete();
|
||||
}
|
||||
Core.Admin.WriteLogActions("删除广告分类(id:" + entity.Id + ");");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除广告分类成功";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 广告管理
|
||||
[MyAuthorize("viewlist", "ads")]
|
||||
public IActionResult AdsList()
|
||||
{
|
||||
IList<AdsKind> list = AdsKind.FindAll(null, AdsKind._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
Core.Admin.WriteLogActions("查看广告列表;");
|
||||
return View();
|
||||
}
|
||||
//获取分页
|
||||
[MyAuthorize("viewlist", "ads", "JSON")]
|
||||
public IActionResult GetAdsList(string keyword, int page = 1, int limit = 20, int kid = 0)
|
||||
{
|
||||
int numPerPage, currentPage, startRowIndex;
|
||||
|
||||
numPerPage = limit;
|
||||
currentPage = page;
|
||||
startRowIndex = (currentPage - 1) * numPerPage;
|
||||
Expression ex = Ads._.Id > 0;
|
||||
if (kid > 0)
|
||||
ex &= Ads._.KId == kid;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
ex &= Ads._.Title.Contains(keyword);
|
||||
|
||||
IList<Ads> list = Ads.FindAll(ex, Ads._.Sequence.Asc().And(Ads._.Id.Desc()), null, startRowIndex, numPerPage);
|
||||
long totalCount = Ads.FindCount(ex, Ads._.Sequence.Asc().And(Ads._.Id.Desc()), null, startRowIndex, numPerPage);
|
||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
//添加广告页面
|
||||
[MyAuthorize("add", "ads")]
|
||||
public IActionResult AddAds()
|
||||
{
|
||||
IList<AdsKind> list = AdsKind.FindAll(null, AdsKind._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
Core.Admin.WriteLogActions("查看添加广告页面;");
|
||||
return View();
|
||||
}
|
||||
|
||||
//执行添加广告
|
||||
[HttpPost]
|
||||
|
||||
[MyAuthorize("add", "ads", "JSON")]
|
||||
public IActionResult AddAds(Ads model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Title))
|
||||
{
|
||||
tip.Message = "广告标题不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
string content = "";
|
||||
DateTime StartTime, EndTime;
|
||||
StartTime = Convert.ToDateTime("2000-01-01");
|
||||
EndTime = Convert.ToDateTime("2999-01-01");
|
||||
GetRequestAdsString(model.TId, ref content);
|
||||
model.StartTime = StartTime;
|
||||
model.EndTime = EndTime;
|
||||
model.Content = content;
|
||||
model.Insert();
|
||||
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "添加广告成功";
|
||||
tip.ReturnUrl = "close";
|
||||
|
||||
Core.Admin.WriteLogActions("添加广告(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
//编辑广告
|
||||
[MyAuthorize("edit", "ads")]
|
||||
public IActionResult EditAds(int id)
|
||||
{
|
||||
IList<AdsKind> list = AdsKind.FindAll(null, AdsKind._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
|
||||
Ads entity = Ads.Find(Ads._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
return EchoTipPage("系统找不到本记录!");
|
||||
}
|
||||
|
||||
Core.Admin.WriteLogActions("查看/编辑广告(" + id + ");");
|
||||
|
||||
return View(entity);
|
||||
}
|
||||
|
||||
//执行编辑广告
|
||||
[HttpPost]
|
||||
|
||||
[MyAuthorize("edit", "ads", "JSON")]
|
||||
public IActionResult EditAds(Ads model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Title))
|
||||
{
|
||||
tip.Message = "广告标题不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (model.Id <= 0)
|
||||
{
|
||||
tip.Message = "错误参数传递!";
|
||||
Json(tip);
|
||||
}
|
||||
Ads entity = Ads.Find(Ads._.Id == model.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
string content = "";
|
||||
DateTime StartTime, EndTime;
|
||||
StartTime = Convert.ToDateTime("2000-01-01");
|
||||
EndTime = Convert.ToDateTime("2999-01-01");
|
||||
GetRequestAdsString(model.TId, ref content);
|
||||
model.StartTime = StartTime;
|
||||
model.EndTime = EndTime;
|
||||
model.Content = content;
|
||||
model.Update();
|
||||
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "编辑广告成功";
|
||||
tip.ReturnUrl = "close";
|
||||
|
||||
Core.Admin.WriteLogActions("编辑广告(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
//删除广告
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "ads", "JSON")]
|
||||
public JsonResult DelAds(int id)
|
||||
{
|
||||
Ads entity = Ads.Find(Ads._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本广告!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
Core.Admin.WriteLogActions("删除广告(id:" + entity.Id + ");");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除广告成功";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
#region 获取广告代码
|
||||
/// <summary>
|
||||
/// 获取
|
||||
/// </summary>
|
||||
/// <param name="tid">ID</param>
|
||||
/// <returns></returns>
|
||||
private void GetRequestAdsString(int tid, ref string adsString)
|
||||
{
|
||||
JsonTip mytip = new JsonTip();
|
||||
mytip.Status = JsonTip.ERROR;
|
||||
|
||||
string str = "";
|
||||
switch (tid)
|
||||
{
|
||||
case 0://代码
|
||||
ScriptAds script = new ScriptAds();
|
||||
script.content = Request.Form["txtScript"];
|
||||
if (string.IsNullOrEmpty(script.content))
|
||||
{
|
||||
mytip.Message = "代码不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
str = JsonConvert.SerializeObject(script);
|
||||
}
|
||||
break;
|
||||
case 1://文字类
|
||||
TextAds text = new TextAds();
|
||||
text.txt = Request.Form["txt_Txt"];
|
||||
text.link = Request.Form["txt_Link"];
|
||||
text.style = Request.Form["txt_Style"];
|
||||
if (string.IsNullOrEmpty(text.txt))
|
||||
{
|
||||
mytip.Message = "文字内容不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(text.link))
|
||||
{
|
||||
mytip.Message = "文字链接不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
str = JsonConvert.SerializeObject(text);
|
||||
break;
|
||||
case 2://图片类
|
||||
ImgAds img = new ImgAds();
|
||||
img.img = Request.Form["img_Img"];
|
||||
img.link = Request.Form["img_Link"];
|
||||
img.alt = Request.Form["img_Alt"];
|
||||
string iw = Request.Form["img_Width"];
|
||||
string ih = Request.Form["img_Height"];
|
||||
if (!string.IsNullOrEmpty(iw) && Utils.IsInt(iw))
|
||||
img.width = int.Parse(iw);
|
||||
if (!string.IsNullOrEmpty(ih) && Utils.IsInt(ih))
|
||||
img.height = int.Parse(ih);
|
||||
if (string.IsNullOrEmpty(img.img))
|
||||
{
|
||||
mytip.Message = "图片地址不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(img.link))
|
||||
{
|
||||
mytip.Message = "图片链接不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
str = JsonConvert.SerializeObject(img);
|
||||
break;
|
||||
case 3://Flash类
|
||||
FlashAds flash = new FlashAds();
|
||||
flash.swf = Request.Form["flash_Swf"];
|
||||
string fw = Request.Form["flash_Width"];
|
||||
string fh = Request.Form["flash_Height"];
|
||||
if (string.IsNullOrEmpty(flash.swf))
|
||||
{
|
||||
mytip.Message = "Flash 地址不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(fw) || !Utils.IsInt(fw))
|
||||
{
|
||||
mytip.Message = "Flash 宽度不能为空或者不是整数!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
flash.width = int.Parse(fw);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(fh) || !Utils.IsInt(fh))
|
||||
{
|
||||
mytip.Message = "Flash 高度不能为空或者不是整数!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
flash.height = int.Parse(fh);
|
||||
}
|
||||
str = JsonConvert.SerializeObject(flash);
|
||||
break;
|
||||
case 4://幻灯片
|
||||
string sw = Request.Form["slide_Width"];
|
||||
string sh = Request.Form["slide_Height"];
|
||||
if (string.IsNullOrEmpty(sw) || !Utils.IsInt(sw))
|
||||
{
|
||||
mytip.Message = "幻灯片宽度不能为空或者不是整数!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(sh) || !Utils.IsInt(sh))
|
||||
{
|
||||
mytip.Message = "幻灯片高度不能为空或者不是整数!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
string SImg = Request.Form["slide_Img"];
|
||||
string SLink = Request.Form["slide_Link"];
|
||||
string SAlt = Request.Form["slide_Alt"];
|
||||
if (string.IsNullOrEmpty(SImg))
|
||||
{
|
||||
mytip.Message = "幻灯片图片不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(SLink))
|
||||
{
|
||||
mytip.Message = "幻灯片图片链接不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
string[] arrsimg = SImg.Split(new string[] { "," }, StringSplitOptions.None);
|
||||
string[] arrslink = SLink.Split(new string[] { "," }, StringSplitOptions.None);
|
||||
string[] arralt = SAlt.Split(new string[] { "," }, StringSplitOptions.None);
|
||||
List<ImgAds> listimg = new List<ImgAds>();
|
||||
for (int i = 0; i < arrsimg.Length; i++)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(arrsimg[i]) && !string.IsNullOrEmpty(arrslink[i]))//图片跟地址都不为空
|
||||
{
|
||||
ImgAds tplimgads = new ImgAds();
|
||||
tplimgads.img = arrsimg[i];
|
||||
tplimgads.link = arrslink[i];
|
||||
tplimgads.height = int.Parse(sh);
|
||||
tplimgads.width = int.Parse(sw);
|
||||
tplimgads.alt = arralt[i];
|
||||
//listimg.Add(new ImgAds { img = arrsimg[i], link = arrslink[i], height = int.Parse(sh), width = int.Parse(sw), alt = arralt[i] });
|
||||
listimg.Add(tplimgads);
|
||||
}
|
||||
}
|
||||
str = JsonConvert.SerializeObject(listimg);
|
||||
break;
|
||||
case 7://视频广告
|
||||
VideoAds video = new VideoAds();
|
||||
video.poster = Request.Form["video_Poster"];
|
||||
video.src = Request.Form["video_Src"];
|
||||
video.title = Request.Form["video_Title"];
|
||||
string vw = Request.Form["video_Width"];
|
||||
string vh = Request.Form["video_Height"];
|
||||
if (!string.IsNullOrEmpty(vw) && Utils.IsInt(vw))
|
||||
video.width = int.Parse(vw);
|
||||
if (!string.IsNullOrEmpty(vh) && Utils.IsInt(vh))
|
||||
video.height = int.Parse(vh);
|
||||
if (string.IsNullOrEmpty(video.src))
|
||||
{
|
||||
mytip.Message = "视频广告地址不能为空!";
|
||||
mytip.EchoTip();
|
||||
return;
|
||||
}
|
||||
str = JsonConvert.SerializeObject(video);
|
||||
break;
|
||||
}
|
||||
adsString = str;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 友情链接分类管理
|
||||
//查看&编辑友情链接分类(同一个页面执行)
|
||||
[MyAuthorize("viewlist", "adskinds")]
|
||||
public IActionResult LinkCategoryList()
|
||||
{
|
||||
IList<LinkKind> list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0);
|
||||
Core.Admin.WriteLogActions("查看友情链接分类列表页面;");
|
||||
return View(list);
|
||||
}
|
||||
|
||||
//执行添加操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "adskinds", "JSON")]
|
||||
public IActionResult AddLinkKind(LinkKind model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.KindName))
|
||||
{
|
||||
tip.Message = "广告分类名称不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
model.Insert();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "添加友情链接分类成功";
|
||||
Core.Admin.WriteLogActions("添加友情链接分类(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//执行编辑操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("edit", "adskinds", "JSON")]
|
||||
public IActionResult EditLinkKind(LinkKind model)
|
||||
{
|
||||
if (model.Id <= 0)
|
||||
{
|
||||
tip.Message = "错误参数传递!";
|
||||
return Json(tip);
|
||||
}
|
||||
LinkKind oldentity = LinkKind.Find(LinkKind._.Id == model.Id);
|
||||
if (oldentity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.KindName))
|
||||
{
|
||||
tip.Message = "友情链接分类名称不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
model.Update();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "编辑友情链接分类成功";
|
||||
Core.Admin.WriteLogActions("编辑友情链接分类(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
//执行删除操作
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "adskinds", "JSON")]
|
||||
public JsonResult DelLinkKind(int id)
|
||||
{
|
||||
LinkKind entity = LinkKind.Find(LinkKind._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本友情链接分类!";
|
||||
return Json(tip);
|
||||
}
|
||||
//删除下属友情链接
|
||||
IList<Link> list = Link.FindAll(Link._.KId == entity.Id, null, null, 0, 0);
|
||||
if (list != null && list.Count > 0)
|
||||
{
|
||||
list.Delete();
|
||||
}
|
||||
Core.Admin.WriteLogActions("删除友情链接分类(id:" + entity.Id + ");");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除友情链接分类成功";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 友情链接管理
|
||||
//查看友情链接列表
|
||||
[MyAuthorize("viewlist", "link")]
|
||||
public IActionResult LinkList()
|
||||
{
|
||||
IList<LinkKind> list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
Core.Admin.WriteLogActions("查看友情链接列表;");
|
||||
return View();
|
||||
}
|
||||
|
||||
[MyAuthorize("viewlist", "link", "JSON")]
|
||||
public IActionResult GetLinkList(string keyword, int page = 1, int limit = 20, int kid = 0)
|
||||
{
|
||||
int numPerPage, currentPage, startRowIndex;
|
||||
|
||||
numPerPage = limit;
|
||||
currentPage = page;
|
||||
startRowIndex = (currentPage - 1) * numPerPage;
|
||||
Expression ex = Link._.Id > 0;
|
||||
if (kid > 0)
|
||||
ex &= Link._.KId == kid;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(keyword))
|
||||
ex &= Link._.Title.Contains(keyword);
|
||||
|
||||
IList<Link> list = Link.FindAll(ex, Link._.Sequence.Asc().And(Link._.Id.Desc()), null, startRowIndex, numPerPage);
|
||||
long totalCount = Link.FindCount(ex, Link._.Sequence.Asc().And(Link._.Id.Desc()), null, startRowIndex, numPerPage);
|
||||
return Content(Newtonsoft.Json.JsonConvert.SerializeObject(new { total = totalCount, rows = list }), "text/plain");
|
||||
//return Json(new { total = totalCount, rows = list }, JsonRequestBehavior.AllowGet);
|
||||
}
|
||||
//添加友情链接
|
||||
[MyAuthorize("add", "link")]
|
||||
public IActionResult AddLink()
|
||||
{
|
||||
IList<LinkKind> list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
Core.Admin.WriteLogActions("查看添加友情链接页面;");
|
||||
return View();
|
||||
}
|
||||
|
||||
//执行添加友情链接
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "link", "JSON")]
|
||||
public IActionResult AddLink(Link model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Title))
|
||||
{
|
||||
tip.Message = "网站标题不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(model.LinkURL))
|
||||
{
|
||||
tip.Message = "网站链接不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
model.Insert();
|
||||
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "添加友情链接成功";
|
||||
tip.ReturnUrl = "close";
|
||||
|
||||
Core.Admin.WriteLogActions("添加友情链接(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//编辑广告
|
||||
[MyAuthorize("edit", "link")]
|
||||
public IActionResult EditLink(int id)
|
||||
{
|
||||
IList<LinkKind> list = LinkKind.FindAll(null, LinkKind._.Rank.Asc(), null, 0, 0);
|
||||
ViewBag.ListKinds = list;
|
||||
|
||||
Link entity = Link.Find(Link._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
return EchoTipPage("系统找不到本记录!");
|
||||
}
|
||||
|
||||
Core.Admin.WriteLogActions("查看/编辑友情链接(" + id + ");");
|
||||
|
||||
return View(entity);
|
||||
}
|
||||
|
||||
|
||||
//执行编辑广告
|
||||
[HttpPost]
|
||||
[MyAuthorize("add", "link", "JSON")]
|
||||
public IActionResult EditLink(Link model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Title))
|
||||
{
|
||||
tip.Message = "网站标题不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(model.LinkURL))
|
||||
{
|
||||
tip.Message = "网站链接不能为空!";
|
||||
return Json(tip);
|
||||
}
|
||||
Link entity = Link.Find(Link._.Id == model.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本记录!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
model.Update();
|
||||
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "编辑友情链接成功";
|
||||
tip.ReturnUrl = "close";
|
||||
|
||||
Core.Admin.WriteLogActions("编辑友情链接(" + model.Id + ");");
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
//删除友情链接
|
||||
[HttpPost]
|
||||
[MyAuthorize("del", "link", "JSON")]
|
||||
public JsonResult DelLink(int id)
|
||||
{
|
||||
Link entity = Link.Find(Link._.Id == id);
|
||||
if (entity == null)
|
||||
{
|
||||
tip.Message = "系统找不到本友情链接!";
|
||||
return Json(tip);
|
||||
}
|
||||
|
||||
Core.Admin.WriteLogActions("删除友情链接(id:" + entity.Id + ");");
|
||||
entity.Delete();
|
||||
tip.Status = JsonTip.SUCCESS;
|
||||
tip.Message = "删除友情链接成功";
|
||||
return Json(tip);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user