diff --git a/COMCMS.Core/Models/JsonTip.cs b/COMCMS.Core/Models/JsonTip.cs index 4ba762d..299c7cb 100644 --- a/COMCMS.Core/Models/JsonTip.cs +++ b/COMCMS.Core/Models/JsonTip.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using System.Web; using Newtonsoft.Json; using COMCMS.Common; +using System.Text; +using System.IO; namespace COMCMS.Core { @@ -58,4 +60,16 @@ namespace COMCMS.Core } } + public static class Extension + { + public static void EchoTip(this JsonTip json) + { + string strJson = JsonTip.GetJsonString(json); + + Byte[] bytes = Encoding.UTF8.GetBytes(strJson); + Stream stream = new MemoryStream(bytes); + MyHttpContext.Current.Response.ContentType = "text/plain"; + MyHttpContext.Current.Response.Body = stream; + } + } } diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/GuestbookController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/GuestbookController.cs new file mode 100644 index 0000000..f7cfe46 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Controllers/GuestbookController.cs @@ -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 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 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 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 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 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 + } +} \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/OrderController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/OrderController.cs new file mode 100644 index 0000000..7a97714 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Controllers/OrderController.cs @@ -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 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 list = OrderDetail.FindAll(OrderDetail._.OrderId == entity.Id, null, null, 0, 0); + ViewBag.list = list; + //日志 + IList 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 list = OrderDetail.FindAll(OrderDetail._.OrderId == entity.Id, null, null, 0, 0); + IList 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 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 + } +} \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Controllers/OtherController.cs b/COMCMS.Web/Areas/AdminCP/Controllers/OtherController.cs new file mode 100644 index 0000000..541e806 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Controllers/OtherController.cs @@ -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 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 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 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 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 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 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 获取广告代码 + /// + /// 获取 + /// + /// ID + /// + 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 listimg = new List(); + 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 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 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 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 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 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 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 + } +} \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Guestbook/AddGuestbookCategory.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/AddGuestbookCategory.cshtml new file mode 100644 index 0000000..ef42207 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/AddGuestbookCategory.cshtml @@ -0,0 +1,7 @@ + +@{ + ViewData["Title"] = "AddGuestbookCategory"; +} + +

AddGuestbookCategory

+ diff --git a/COMCMS.Web/Areas/AdminCP/Views/Guestbook/EditGuestbook.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/EditGuestbook.cshtml new file mode 100644 index 0000000..5b68071 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/EditGuestbook.cshtml @@ -0,0 +1,93 @@ +@model COMCMS.Core.Guestbook +@{ + ViewBag.title = "编辑/审核留言详情"; +} + +
+
+
+
@ViewBag.title
+
+
+
+
+ @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editGuestbookForm", @class = "form-horizontal m-t" })) + { +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+ + + +
+
+ } +
+
+ + +
+ + \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Guestbook/GuestbookCategorys.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/GuestbookCategorys.cshtml new file mode 100644 index 0000000..990cfd0 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/GuestbookCategorys.cshtml @@ -0,0 +1,96 @@ +@model IList +@{ + ViewBag.title = "留言分类管理"; +} + +
+
+
+
@ViewBag.title
+
+
+
+ +
+ +
+ +
+
+ + + + + + + + + + + @if (Model.Count == 0) + { + + } + @foreach (var m in Model) + { + + + + + + + + } + + + + + + + +
ID类别名称排序简单说明操作
暂无记录
+
@m.Id
+ +
+
@m.KindName
+ +
+
@m.Rank
+ +
+
@m.KindInfo
+ +
+ + +
+
+
+
+ + +
+ diff --git a/COMCMS.Web/Areas/AdminCP/Views/Guestbook/GuestbookList.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/GuestbookList.cshtml new file mode 100644 index 0000000..12673a2 --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Guestbook/GuestbookList.cshtml @@ -0,0 +1,163 @@ + +@{ + ViewBag.title = "留言管理"; +} +
+
+
+
@ViewBag.title
+
+
+
+
+
+
筛选条件
+
+
+
+ + + + + + +
+
+
+
+
+ + +
+
+ + +
+ diff --git a/COMCMS.Web/Areas/AdminCP/Views/Order/EditOrder.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Order/EditOrder.cshtml new file mode 100644 index 0000000..425106c --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Order/EditOrder.cshtml @@ -0,0 +1,350 @@ +@model COMCMS.Core.Order +@{ + ViewBag.title = "查看/编辑订单详情"; +} +
+ + @using (Html.BeginForm(null, null, FormMethod.Post, new { id = "editOrderForm", @class = "form-horizontal m-t", onsubmit = "return false;" })) + { +
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + @if (Model.PaymentStatus == "未支付") + { + + } +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ @if (Model.PaymentStatus == Utils.PaymentState[1]) + { +
+ +
+ +
+
+ } + @if (Model.PaymentStatus == Utils.PaymentState[1] && Model.OrderStatus == Utils.OrdersState[1]) + { +
+ +
+ +
+
+ } +
+ +
+ +
+
+
+ +
+ + +
+
+
+ +
+ +
+
+
+ +
+ + + + + + + + + + + + @foreach (OrderDetail item in ViewBag.list) + { + Product p = Product.FindById(item.PId); + + + + + + + + } + +
产品名称产品规格产品单价商品数量金额
@p.Title@item.Spec¥ @item.Price.ToString("N2")@item.Qty¥ @((item.Price * item.Qty).ToString("N2"))
+
+
+
+
+ +
+
+
+ 订单日志 +
+ + + + + + + + + + @foreach (COMCMS.Core.OrderLog item in ViewBag.OrderLogList) + { + + + + + + } + +
ID用户ID操作日志
@item.Id@item.UId@item.Actions
+
+
+
+
+ +
+
+
+
+ + +
+
+
+ } + +
+ + \ No newline at end of file diff --git a/COMCMS.Web/Areas/AdminCP/Views/Order/OrderList.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Order/OrderList.cshtml new file mode 100644 index 0000000..9d6a97f --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Order/OrderList.cshtml @@ -0,0 +1,196 @@ + +@{ + ViewBag.title = "订单管理"; +} + +
+
+
+
@ViewBag.Title
+
+
+
+
+
+
筛选条件
+
+
+
+ + + + + + + +
+
+
+
+
+ + +
+
+ + +
+ diff --git a/COMCMS.Web/Areas/AdminCP/Views/Order/PayOnlineList.cshtml b/COMCMS.Web/Areas/AdminCP/Views/Order/PayOnlineList.cshtml new file mode 100644 index 0000000..a1d940f --- /dev/null +++ b/COMCMS.Web/Areas/AdminCP/Views/Order/PayOnlineList.cshtml @@ -0,0 +1,198 @@ + +@{ + ViewBag.title = "在线支付记录"; +} + +
+
+
+
@ViewBag.Title
+
+
+
+
+
+
筛选条件
+
+
+
+ + + + + +
+
+
+
+
+ + +
+
+ + +
+