mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-05-14 06:27:21 +08:00
添加项目文件。
This commit is contained in:
@@ -0,0 +1,423 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理商表
|
||||
///</summary>
|
||||
[Description("代理商表")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class CoreCmsAgentController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly ICoreCmsAgentServices _coreCmsAgentServices;
|
||||
private readonly ICoreCmsAgentGradeServices _agentGradeServices;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public CoreCmsAgentController(IWebHostEnvironment webHostEnvironment
|
||||
, ICoreCmsAgentServices coreCmsAgentServices, ICoreCmsAgentGradeServices agentGradeServices)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_coreCmsAgentServices = coreCmsAgentServices;
|
||||
_agentGradeServices = agentGradeServices;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/CoreCmsAgent/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<CoreCmsAgent>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<CoreCmsAgent, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"userId" => p => p.userId,
|
||||
"name" => p => p.name,
|
||||
"gradeId" => p => p.gradeId,
|
||||
"mobile" => p => p.mobile,
|
||||
"weixin" => p => p.weixin,
|
||||
"qq" => p => p.qq,
|
||||
"storeName" => p => p.storeName,
|
||||
"storeLogo" => p => p.storeLogo,
|
||||
"storeBanner" => p => p.storeBanner,
|
||||
"storeDesc" => p => p.storeDesc,
|
||||
"verifyStatus" => p => p.verifyStatus,
|
||||
"createTime" => p => p.createTime,
|
||||
"updateTime" => p => p.updateTime,
|
||||
"verifyTime" => p => p.verifyTime,
|
||||
"isDelete" => p => p.isDelete,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//用户Id int
|
||||
var userId = Request.Form["userId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (userId > 0)
|
||||
{
|
||||
where = where.And(p => p.userId == userId);
|
||||
}
|
||||
//代理商名称 nvarchar
|
||||
var name = Request.Form["name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
where = where.And(p => p.name.Contains(name));
|
||||
}
|
||||
//代理商等级 int
|
||||
var gradeId = Request.Form["gradeId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (gradeId > 0)
|
||||
{
|
||||
where = where.And(p => p.gradeId == gradeId);
|
||||
}
|
||||
//手机号 nvarchar
|
||||
var mobile = Request.Form["mobile"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(mobile))
|
||||
{
|
||||
where = where.And(p => p.mobile.Contains(mobile));
|
||||
}
|
||||
//微信号 nvarchar
|
||||
var weixin = Request.Form["weixin"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(weixin))
|
||||
{
|
||||
where = where.And(p => p.weixin.Contains(weixin));
|
||||
}
|
||||
//qq号 nvarchar
|
||||
var qq = Request.Form["qq"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(qq))
|
||||
{
|
||||
where = where.And(p => p.qq.Contains(qq));
|
||||
}
|
||||
//店铺名称 nvarchar
|
||||
var storeName = Request.Form["storeName"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(storeName))
|
||||
{
|
||||
where = where.And(p => p.storeName.Contains(storeName));
|
||||
}
|
||||
//店铺Logo nvarchar
|
||||
var storeLogo = Request.Form["storeLogo"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(storeLogo))
|
||||
{
|
||||
where = where.And(p => p.storeLogo.Contains(storeLogo));
|
||||
}
|
||||
//店铺Banner nvarchar
|
||||
var storeBanner = Request.Form["storeBanner"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(storeBanner))
|
||||
{
|
||||
where = where.And(p => p.storeBanner.Contains(storeBanner));
|
||||
}
|
||||
//店铺简介 nvarchar
|
||||
var storeDesc = Request.Form["storeDesc"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(storeDesc))
|
||||
{
|
||||
where = where.And(p => p.storeDesc.Contains(storeDesc));
|
||||
}
|
||||
//审核状态 int
|
||||
var verifyStatus = Request.Form["verifyStatus"].FirstOrDefault().ObjectToInt(0);
|
||||
if (verifyStatus > 0)
|
||||
{
|
||||
where = where.And(p => p.verifyStatus == verifyStatus);
|
||||
}
|
||||
//创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
if (createTime.Contains("到"))
|
||||
{
|
||||
var dts = createTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
}
|
||||
//更新时间 datetime
|
||||
var updateTime = Request.Form["updateTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(updateTime))
|
||||
{
|
||||
if (updateTime.Contains("到"))
|
||||
{
|
||||
var dts = updateTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = updateTime.ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dt);
|
||||
}
|
||||
}
|
||||
//审核时间 datetime
|
||||
var verifyTime = Request.Form["verifyTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(verifyTime))
|
||||
{
|
||||
if (verifyTime.Contains("到"))
|
||||
{
|
||||
var dts = verifyTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.verifyTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.verifyTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = verifyTime.ObjectToDate();
|
||||
where = where.And(p => p.verifyTime > dt);
|
||||
}
|
||||
}
|
||||
//是否删除 bit
|
||||
var isDelete = Request.Form["isDelete"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(isDelete) && isDelete.ToLowerInvariant() == "true")
|
||||
{
|
||||
where = where.And(p => p.isDelete == true);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(isDelete) && isDelete.ToLowerInvariant() == "false")
|
||||
{
|
||||
where = where.And(p => p.isDelete == false);
|
||||
}
|
||||
//获取数据
|
||||
var list = await _coreCmsAgentServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/CoreCmsAgent/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public async Task<AdminUiCallBack> GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var agentVerifyStatus = EnumHelper.EnumToList<GlobalEnumVars.AgentVerifyStatus>();
|
||||
var grades = await _agentGradeServices.GetCaChe();
|
||||
jm.data = new
|
||||
{
|
||||
agentVerifyStatus,
|
||||
grades
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑数据============================================================
|
||||
// POST: Api/CoreCmsAgent/GetEdit
|
||||
/// <summary>
|
||||
/// 编辑数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑数据")]
|
||||
public async Task<AdminUiCallBack> GetEdit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _coreCmsAgentServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
|
||||
var agentVerifyStatus = EnumHelper.EnumToList<GlobalEnumVars.AgentVerifyStatus>();
|
||||
var grades = await _agentGradeServices.GetCaChe();
|
||||
jm.data = new
|
||||
{
|
||||
model,
|
||||
agentVerifyStatus,
|
||||
grades
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑提交============================================================
|
||||
// POST: Api/CoreCmsAgent/Edit
|
||||
/// <summary>
|
||||
/// 编辑提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑提交")]
|
||||
public async Task<AdminUiCallBack> DoEdit([FromBody] CoreCmsAgent entity)
|
||||
{
|
||||
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await _coreCmsAgentServices.QueryByIdAsync(entity.id);
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//事物处理过程开始
|
||||
oldModel.name = entity.name;
|
||||
oldModel.gradeId = entity.gradeId;
|
||||
oldModel.mobile = entity.mobile;
|
||||
oldModel.weixin = entity.weixin;
|
||||
oldModel.qq = entity.qq;
|
||||
oldModel.verifyStatus = entity.verifyStatus;
|
||||
oldModel.updateTime = DateTime.Now;
|
||||
if (oldModel.verifyStatus == (int)GlobalEnumVars.AgentVerifyStatus.VerifyYes)
|
||||
{
|
||||
oldModel.verifyTime = DateTime.Now;
|
||||
}
|
||||
|
||||
//事物处理过程结束
|
||||
var bl = await _coreCmsAgentServices.UpdateAsync(oldModel);
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
return jm;
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除数据============================================================
|
||||
// POST: Api/CoreCmsAgent/DoDelete/10
|
||||
/// <summary>
|
||||
/// 单选删除
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("单选删除")]
|
||||
public async Task<AdminUiCallBack> DoDelete([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _coreCmsAgentServices.ExistsAsync(p => p.id == entity.id, true);
|
||||
if (!model)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
var bl = await _coreCmsAgentServices.DeleteByIdAsync(entity.id);
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.DeleteSuccess : GlobalConstVars.DeleteFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 预览数据============================================================
|
||||
// POST: Api/CoreCmsAgent/GetDetails/10
|
||||
/// <summary>
|
||||
/// 预览数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("预览数据")]
|
||||
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _coreCmsAgentServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
|
||||
var agentVerifyStatus = EnumHelper.EnumToList<GlobalEnumVars.AgentVerifyStatus>();
|
||||
var grades = await _agentGradeServices.GetCaChe();
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
agentVerifyStatus,
|
||||
grades,
|
||||
model
|
||||
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,395 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Services;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理商品池
|
||||
///</summary>
|
||||
[Description("代理商品池")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class CoreCmsAgentGoodsController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly ICoreCmsAgentGoodsServices _agentGoodsServices;
|
||||
private readonly ICoreCmsGoodsServices _goodsServices;
|
||||
private readonly ICoreCmsAgentGradeServices _agentGradeServices;
|
||||
private readonly ICoreCmsAgentProductsServices _agentProductsServices;
|
||||
private readonly ICoreCmsProductsServices _productsServices;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public CoreCmsAgentGoodsController(IWebHostEnvironment webHostEnvironment
|
||||
, ICoreCmsAgentGoodsServices agentGoodsServices, ICoreCmsGoodsServices goodsServices, ICoreCmsAgentGradeServices agentGradeServices, ICoreCmsAgentProductsServices agentProductsServices, ICoreCmsProductsServices productsServices)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_agentGoodsServices = agentGoodsServices;
|
||||
_goodsServices = goodsServices;
|
||||
_agentGradeServices = agentGradeServices;
|
||||
_agentProductsServices = agentProductsServices;
|
||||
_productsServices = productsServices;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<CoreCmsAgentGoods>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<CoreCmsAgentGoods, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"goodId" => p => p.goodId,
|
||||
"sortId" => p => p.sortId,
|
||||
"isEnable" => p => p.isEnable,
|
||||
"createTime" => p => p.createTime,
|
||||
"updateTime" => p => p.updateTime,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//商品序列 int
|
||||
var goodId = Request.Form["goodId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (goodId > 0)
|
||||
{
|
||||
where = where.And(p => p.goodId == goodId);
|
||||
}
|
||||
//排序 int
|
||||
var sortId = Request.Form["sortId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (sortId > 0)
|
||||
{
|
||||
where = where.And(p => p.sortId == sortId);
|
||||
}
|
||||
//是否启用 bit
|
||||
var isEnable = Request.Form["isEnable"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(isEnable) && isEnable.ToLowerInvariant() == "true")
|
||||
{
|
||||
where = where.And(p => p.isEnable == true);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(isEnable) && isEnable.ToLowerInvariant() == "false")
|
||||
{
|
||||
where = where.And(p => p.isEnable == false);
|
||||
}
|
||||
//创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
if (createTime.Contains("到"))
|
||||
{
|
||||
var dts = createTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
}
|
||||
//最后更新时间 datetime
|
||||
var updateTime = Request.Form["updateTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(updateTime))
|
||||
{
|
||||
if (updateTime.Contains("到"))
|
||||
{
|
||||
var dts = updateTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = updateTime.ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dt);
|
||||
}
|
||||
}
|
||||
//获取数据
|
||||
var list = await _agentGoodsServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建数据============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/GetCreate
|
||||
/// <summary>
|
||||
/// 创建数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建数据")]
|
||||
public async Task<AdminUiCallBack> GetCreate()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var goods = await _goodsServices.QueryEnumEntityAsync();
|
||||
var agentGrade = await _agentGradeServices.GetCaChe();
|
||||
jm.data = new
|
||||
{
|
||||
goods,
|
||||
agentGrade
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建提交============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/DoCreate
|
||||
/// <summary>
|
||||
/// 创建提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建提交")]
|
||||
public async Task<AdminUiCallBack> DoCreate([FromBody] FMCreateAgentGood entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
jm = await _agentGoodsServices.InsertAsync(entity.good, entity.products);
|
||||
jm.data = entity;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑数据============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/GetEdit
|
||||
/// <summary>
|
||||
/// 编辑数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑数据")]
|
||||
public async Task<AdminUiCallBack> GetEdit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _agentGoodsServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
|
||||
var goods = await _goodsServices.QueryEnumEntityAsync();
|
||||
var good = await _goodsServices.QueryByClauseAsync(p => p.id == model.goodId);
|
||||
var products = await _productsServices.QueryListByClauseAsync(p => p.goodsId == model.goodId && p.isDel == false);
|
||||
var agentGrade = await _agentGradeServices.GetCaChe();
|
||||
var agentProducts = await _agentProductsServices.QueryListByClauseAsync(p => p.goodId == model.goodId, p => p.id, OrderByType.Asc);
|
||||
|
||||
var allNew = false;
|
||||
if (agentProducts.Any() && products.Any())
|
||||
{
|
||||
var pIds = products.Select(p => p.id).ToList();
|
||||
var apIds = agentProducts.Select(p => p.productId).ToList();
|
||||
var sameArr = pIds.Intersect(apIds).ToArray();
|
||||
allNew = sameArr.Length <= 0;
|
||||
}
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
model,
|
||||
goods,
|
||||
good,
|
||||
agentGrade,
|
||||
agentProducts,
|
||||
products,
|
||||
allNew
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑提交============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/Edit
|
||||
/// <summary>
|
||||
/// 编辑提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑提交")]
|
||||
public async Task<AdminUiCallBack> DoEdit([FromBody] FMCreateAgentGood entity)
|
||||
{
|
||||
var jm = await _agentGoodsServices.UpdateAsync(entity.good, entity.products);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除数据============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/DoDelete/10
|
||||
/// <summary>
|
||||
/// 单选删除
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("单选删除")]
|
||||
public async Task<AdminUiCallBack> DoDelete([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = await _agentGoodsServices.DeleteByIdAsync(entity.id);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 预览数据============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/GetDetails/10
|
||||
/// <summary>
|
||||
/// 预览数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("预览数据")]
|
||||
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _agentGoodsServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
|
||||
var goods = await _goodsServices.QueryByClauseAsync(p => p.id == model.goodId);
|
||||
var products = await _productsServices.QueryListByClauseAsync(p => p.goodsId == model.goodId && p.isDel == false);
|
||||
var agentGrade = await _agentGradeServices.GetCaChe();
|
||||
var agentProducts = await _agentProductsServices.QueryListByClauseAsync(p => p.goodId == model.goodId, p => p.id, OrderByType.Asc);
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
model,
|
||||
goods,
|
||||
agentGrade,
|
||||
agentProducts,
|
||||
products
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 设置是否启用============================================================
|
||||
// POST: Api/CoreCmsAgentGoods/DoSetisEnable/10
|
||||
/// <summary>
|
||||
/// 设置是否启用
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("设置是否启用")]
|
||||
public async Task<AdminUiCallBack> DoSetisEnable([FromBody] FMUpdateBoolDataByIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await _agentGoodsServices.QueryByIdAsync(entity.id, false);
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
oldModel.isEnable = (bool)entity.data;
|
||||
|
||||
var bl = await _agentGoodsServices.UpdateAsync(p => new CoreCmsAgentGoods() { isEnable = oldModel.isEnable }, p => p.id == oldModel.id);
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,355 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理商等级设置表
|
||||
///</summary>
|
||||
[Description("代理商等级设置表")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class CoreCmsAgentGradeController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly ICoreCmsAgentGradeServices _coreCmsAgentGradeServices;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public CoreCmsAgentGradeController(IWebHostEnvironment webHostEnvironment
|
||||
, ICoreCmsAgentGradeServices coreCmsAgentGradeServices
|
||||
)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_coreCmsAgentGradeServices = coreCmsAgentGradeServices;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<CoreCmsAgentGrade>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<CoreCmsAgentGrade, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"name" => p => p.name,
|
||||
"isDefault" => p => p.isDefault,
|
||||
"isAutoUpGrade" => p => p.isAutoUpGrade,
|
||||
"defaultSalesPriceType" => p => p.defaultSalesPriceType,
|
||||
"defaultSalesPriceNumber" => p => p.defaultSalesPriceNumber,
|
||||
"sortId" => p => p.sortId,
|
||||
"description" => p => p.description,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//等级序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//等级名称 nvarchar
|
||||
var name = Request.Form["name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
where = where.And(p => p.name.Contains(name));
|
||||
}
|
||||
//是否默认等级 bit
|
||||
var isDefault = Request.Form["isDefault"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(isDefault) && isDefault.ToLowerInvariant() == "true")
|
||||
{
|
||||
where = where.And(p => p.isDefault == true);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(isDefault) && isDefault.ToLowerInvariant() == "false")
|
||||
{
|
||||
where = where.And(p => p.isDefault == false);
|
||||
}
|
||||
//是否自动升级 bit
|
||||
var isAutoUpGrade = Request.Form["isAutoUpGrade"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(isAutoUpGrade) && isAutoUpGrade.ToLowerInvariant() == "true")
|
||||
{
|
||||
where = where.And(p => p.isAutoUpGrade == true);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(isAutoUpGrade) && isAutoUpGrade.ToLowerInvariant() == "false")
|
||||
{
|
||||
where = where.And(p => p.isAutoUpGrade == false);
|
||||
}
|
||||
//价格加成方式 int
|
||||
var defaultSalesPriceType = Request.Form["defaultSalesPriceType"].FirstOrDefault().ObjectToInt(0);
|
||||
if (defaultSalesPriceType > 0)
|
||||
{
|
||||
where = where.And(p => p.defaultSalesPriceType == defaultSalesPriceType);
|
||||
}
|
||||
//价格加成值 int
|
||||
var defaultSalesPriceNumber = Request.Form["defaultSalesPriceNumber"].FirstOrDefault().ObjectToInt(0);
|
||||
if (defaultSalesPriceNumber > 0)
|
||||
{
|
||||
where = where.And(p => p.defaultSalesPriceNumber == defaultSalesPriceNumber);
|
||||
}
|
||||
//等级排序 int
|
||||
var sortId = Request.Form["sortId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (sortId > 0)
|
||||
{
|
||||
where = where.And(p => p.sortId == sortId);
|
||||
}
|
||||
//等级说明 nvarchar
|
||||
var description = Request.Form["description"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(description))
|
||||
{
|
||||
where = where.And(p => p.description.Contains(description));
|
||||
}
|
||||
//获取数据
|
||||
var list = await _coreCmsAgentGradeServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var agentDefaultSalesPriceType = EnumHelper.EnumToList<GlobalEnumVars.AgentDefaultSalesPriceType>();
|
||||
jm.data = new
|
||||
{
|
||||
agentDefaultSalesPriceType
|
||||
};
|
||||
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建数据============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/GetCreate
|
||||
/// <summary>
|
||||
/// 创建数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建数据")]
|
||||
public AdminUiCallBack GetCreate()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
var agentDefaultSalesPriceType = EnumHelper.EnumToList<GlobalEnumVars.AgentDefaultSalesPriceType>();
|
||||
jm.data = new
|
||||
{
|
||||
agentDefaultSalesPriceType
|
||||
};
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建提交============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/DoCreate
|
||||
/// <summary>
|
||||
/// 创建提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建提交")]
|
||||
public async Task<AdminUiCallBack> DoCreate([FromBody] CoreCmsAgentGrade entity)
|
||||
{
|
||||
var jm = await _coreCmsAgentGradeServices.InsertAsync(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑数据============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/GetEdit
|
||||
/// <summary>
|
||||
/// 编辑数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑数据")]
|
||||
public async Task<AdminUiCallBack> GetEdit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _coreCmsAgentGradeServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
var agentDefaultSalesPriceType = EnumHelper.EnumToList<GlobalEnumVars.AgentDefaultSalesPriceType>();
|
||||
jm.data = new
|
||||
{
|
||||
model,
|
||||
agentDefaultSalesPriceType
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑提交============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/Edit
|
||||
/// <summary>
|
||||
/// 编辑提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑提交")]
|
||||
public async Task<AdminUiCallBack> DoEdit([FromBody] CoreCmsAgentGrade entity)
|
||||
{
|
||||
var jm = await _coreCmsAgentGradeServices.UpdateAsync(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除数据============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/DoDelete/10
|
||||
/// <summary>
|
||||
/// 单选删除
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("单选删除")]
|
||||
public async Task<AdminUiCallBack> DoDelete([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _coreCmsAgentGradeServices.ExistsAsync(p => p.id == entity.id, true);
|
||||
if (!model)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
jm = await _coreCmsAgentGradeServices.DeleteByIdAsync(entity.id);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 设置是否默认等级============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/DoSetisDefault/10
|
||||
/// <summary>
|
||||
/// 设置是否默认等级
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("设置是否默认等级")]
|
||||
public async Task<AdminUiCallBack> DoSetisDefault([FromBody] FMUpdateBoolDataByIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await _coreCmsAgentGradeServices.QueryByIdAsync(entity.id, false);
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
oldModel.isDefault = (bool)entity.data;
|
||||
|
||||
jm = await _coreCmsAgentGradeServices.UpdateAsync(oldModel);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 设置是否自动升级============================================================
|
||||
// POST: Api/CoreCmsAgentGrade/DoSetisAutoUpGrade/10
|
||||
/// <summary>
|
||||
/// 设置是否自动升级
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("设置是否自动升级")]
|
||||
public async Task<AdminUiCallBack> DoSetisAutoUpGrade([FromBody] FMUpdateBoolDataByIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var oldModel = await _coreCmsAgentGradeServices.QueryByIdAsync(entity.id, false);
|
||||
if (oldModel == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
oldModel.isAutoUpGrade = (bool)entity.data;
|
||||
|
||||
jm = await _coreCmsAgentGradeServices.UpdateAsync(oldModel);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理商订单记录表
|
||||
///</summary>
|
||||
[Description("代理商订单记录表")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class CoreCmsAgentOrderController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly ICoreCmsAgentOrderServices _CoreCmsAgentOrderServices;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public CoreCmsAgentOrderController(IWebHostEnvironment webHostEnvironment
|
||||
, ICoreCmsAgentOrderServices CoreCmsAgentOrderServices
|
||||
)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_CoreCmsAgentOrderServices = CoreCmsAgentOrderServices;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/CoreCmsAgentOrder/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<CoreCmsAgentOrder>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<CoreCmsAgentOrder, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"userId" => p => p.userId,
|
||||
"buyUserId" => p => p.buyUserId,
|
||||
"orderId" => p => p.orderId,
|
||||
"amount" => p => p.amount,
|
||||
"isSettlement" => p => p.isSettlement,
|
||||
"createTime" => p => p.createTime,
|
||||
"updateTime" => p => p.updateTime,
|
||||
"isDelete" => p => p.isDelete,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//用户代理商id int
|
||||
var userId = Request.Form["userId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (userId > 0)
|
||||
{
|
||||
where = where.And(p => p.userId == userId);
|
||||
}
|
||||
//下单用户id int
|
||||
var buyUserId = Request.Form["buyUserId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (buyUserId > 0)
|
||||
{
|
||||
where = where.And(p => p.buyUserId == buyUserId);
|
||||
}
|
||||
//订单编号 nvarchar
|
||||
var orderId = Request.Form["orderId"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(orderId))
|
||||
{
|
||||
where = where.And(p => p.orderId.Contains(orderId));
|
||||
}
|
||||
//是否结算 int
|
||||
var isSettlement = Request.Form["isSettlement"].FirstOrDefault().ObjectToInt(0);
|
||||
if (isSettlement > 0)
|
||||
{
|
||||
where = where.And(p => p.isSettlement == isSettlement);
|
||||
}
|
||||
//创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
if (createTime.Contains("到"))
|
||||
{
|
||||
var dts = createTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
}
|
||||
//更新时间 datetime
|
||||
var updateTime = Request.Form["updateTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(updateTime))
|
||||
{
|
||||
if (updateTime.Contains("到"))
|
||||
{
|
||||
var dts = updateTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = updateTime.ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dt);
|
||||
}
|
||||
}
|
||||
//是否删除 bit
|
||||
var isDelete = Request.Form["isDelete"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(isDelete) && isDelete.ToLowerInvariant() == "true")
|
||||
{
|
||||
where = where.And(p => p.isDelete == true);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(isDelete) && isDelete.ToLowerInvariant() == "false")
|
||||
{
|
||||
where = where.And(p => p.isDelete == false);
|
||||
}
|
||||
//获取数据
|
||||
var list = await _CoreCmsAgentOrderServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/CoreCmsAgentOrder/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var agentOrderSettlementStatus = EnumHelper.EnumToList<GlobalEnumVars.AgentOrderSettlementStatus>();
|
||||
jm.data = new
|
||||
{
|
||||
agentOrderSettlementStatus
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 预览数据============================================================
|
||||
// POST: Api/CoreCmsAgentOrder/GetDetails/10
|
||||
/// <summary>
|
||||
/// 预览数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("预览数据")]
|
||||
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _CoreCmsAgentOrderServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
jm.data = model;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/1/31 21:45:10
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 代理设置表
|
||||
///</summary>
|
||||
[Description("代理设置表")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class CoreCmsAgentSettingController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly ICoreCmsSettingServices _coreCmsSettingServices;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
/// <param name="webHostEnvironment"></param>
|
||||
///<param name="CoreCmsSettingServices"></param>
|
||||
public CoreCmsAgentSettingController(IWebHostEnvironment webHostEnvironment, ICoreCmsSettingServices CoreCmsSettingServices)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_coreCmsSettingServices = CoreCmsSettingServices;
|
||||
}
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/CoreCmsSetting/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public async Task<AdminUiCallBack> GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
var configs = await _coreCmsSettingServices.GetConfigDictionaries();
|
||||
var filesStorageOptionsType = EnumHelper.EnumToList<GlobalEnumVars.FilesStorageOptionsType>();
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
configs,
|
||||
filesStorageOptionsType
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存提交============================================================
|
||||
// POST: Api/CoreCmsSetting/DoSave
|
||||
/// <summary>
|
||||
/// 保存提交
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("保存提交")]
|
||||
public async Task<AdminUiCallBack> DoSave([FromBody] FMCoreCmsSettingDoSaveModel model)
|
||||
{
|
||||
var jm = await _coreCmsSettingServices.UpdateAsync(model);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user