Commit 01d1685a authored by 黄奎's avatar 黄奎
parents ad00ea6a c687a920
......@@ -25,7 +25,7 @@ namespace Mall.Model.Entity.TradePavilion
public ListTypeEnum ListType { get; set; }
/// <summary>
/// 面向群体 枚举
/// 面向群体 多选,英文逗号分隔 枚举
/// </summary>
public string ObjectTypeIds { get; set; }
......
......@@ -13,6 +13,10 @@ namespace Mall.Model.Extend.TradePavilion
[DB(ConnectionName = "DefaultConnection")]
public class RB_FirstShop_List_Extend : RB_FirstShop_List
{
/// <summary>
/// 面向群体
/// </summary>
public List<string> ObjectTypeList { get; set; }
/// <summary>
/// 面向群里id
......
using Mall.Common.Plugin;
using Mall.Model.Extend.TradePavilion;
using Mall.Repository.TradePavilion;
using Mall.Repository.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB;
namespace Mall.Module.TradePavilion
{
/// <summary>
/// 榜单处理类
/// </summary>
public class FirstShopListModule
{
/// <summary>
/// 榜单
/// </summary>
private readonly RB_FirstShop_ListRepository firstShop_ListRepository = new RB_FirstShop_ListRepository();
/// <summary>
/// 报名
/// </summary>
private readonly RB_FirstShop_ListEnrollRepository firstShop_ListEnrollRepository = new RB_FirstShop_ListEnrollRepository();
/// <summary>
/// 用户
/// </summary>
private readonly RB_Member_UserRepository member_UserRepository = new RB_Member_UserRepository();
/// <summary>
/// 获取榜单分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_FirstShop_List_Extend> GetFirstShopListPageList(int pageIndex, int pageSize, out long rowsCount, RB_FirstShop_List_Extend query)
{
var list = firstShop_ListRepository.GetPageList(pageIndex, pageSize, out rowsCount, query);
if (list.Any()) {
foreach (var item in list) {
if (item.ListState == Common.Enum.TradePavilion.ListStateEnum.Enroll && item.DeadlineDate <= DateTime.Now)
{
item.ListState = Common.Enum.TradePavilion.ListStateEnum.Rating;
}
item.ObjectTypeList = new List<string>();
if (!string.IsNullOrEmpty(item.ObjectTypeIds)) {
List<int> OIdList = JsonHelper.DeserializeObject<List<int>>("[" + item.ObjectTypeIds + "]");
foreach (var qitem in OIdList)
{
item.ObjectTypeList.Add(((Common.Enum.TradePavilion.ListObjectTypeEnum)qitem).GetEnumName());
}
}
}
}
return list;
}
/// <summary>
/// 获取榜单详情
/// </summary>
/// <param name="wishId"></param>
/// <returns></returns>
public RB_FirstShop_List_Extend GetFirstShopListInfo(int listId)
{
return firstShop_ListRepository.GetEntity<RB_FirstShop_List_Extend>(listId);
}
/// <summary>
/// 新增修改榜单
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public string SetFirstShopListInfo(RB_FirstShop_List_Extend demodel)
{
if (demodel.Id > 0)
{
var oldModel = firstShop_ListRepository.GetEntity(demodel.Id);
if (oldModel == null || oldModel.Status == 1 || oldModel.ListState == Common.Enum.TradePavilion.ListStateEnum.Cancel || oldModel.ListState == Common.Enum.TradePavilion.ListStateEnum.Confirmed) {
return "绑单状态不正确";
}
//修改
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_FirstShop_List_Extend.ListType),demodel.ListType },
{ nameof(RB_FirstShop_List_Extend.ObjectTypeIds),demodel.ObjectTypeIds },
{ nameof(RB_FirstShop_List_Extend.Sponsor),demodel.Sponsor },
{ nameof(RB_FirstShop_List_Extend.ListName),demodel.ListName },
{ nameof(RB_FirstShop_List_Extend.CoverImage),demodel.CoverImage },
{ nameof(RB_FirstShop_List_Extend.DeadlineDate),demodel.DeadlineDate },
{ nameof(RB_FirstShop_List_Extend.StartDate),demodel.StartDate },
{ nameof(RB_FirstShop_List_Extend.Content),demodel.Content },
{ nameof(RB_FirstShop_List_Extend.EnableRank),demodel.EnableRank },
{ nameof(RB_FirstShop_List_Extend.PrizeNum),demodel.PrizeNum },
{ nameof(RB_FirstShop_List_Extend.UpdateBy),demodel.UpdateBy },
{ nameof(RB_FirstShop_List_Extend.UpdateDate),demodel.UpdateDate }
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_FirstShop_List_Extend.Id),
FiledValue=demodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = firstShop_ListRepository.Update(keyValues, wheres);
return flag ? "" : "修改失败,请联系管理员";
}
else {
//新增
bool flag = firstShop_ListRepository.Insert(demodel) > 0;
return flag ? "" : "新增失败,请联系管理员";
}
}
/// <summary>
/// 取消榜单
/// </summary>
/// <param name="listId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public string DelFirstShopListInfo(int listId, int mallBaseId)
{
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_FirstShop_List_Extend.ListState), Common.Enum.TradePavilion.ListStateEnum.Cancel}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_FirstShop_List_Extend.Id),
FiledValue=listId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName= nameof(RB_FirstShop_List_Extend.MallBaseId),
FiledValue= mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag = firstShop_ListRepository.Update(keyValues, wheres);
return flag ? "" : "取消失败";
}
}
}
......@@ -69,7 +69,10 @@ namespace Mall.WebApi.Controllers.TradePavilion
/// 会员信息
/// </summary>
private readonly Module.User.UserModule userModule = new Module.User.UserModule();
/// <summary>
/// 榜单
/// </summary>
private readonly FirstShopListModule firstShopListModule = new FirstShopListModule();
/// <summary>
/// 心愿单
/// </summary>
......@@ -1788,6 +1791,190 @@ namespace Mall.WebApi.Controllers.TradePavilion
#endregion
#region 榜单管理
/// <summary>
/// 获取榜单分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetFirstShopPrizeListPageList()
{
var req = base.RequestParm;
ResultPageModel pageModel = JsonHelper.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_FirstShop_List_Extend demodel = JsonHelper.DeserializeObject<RB_FirstShop_List_Extend>(req.msg.ToString());
demodel.TenantId = req.TenantId;
demodel.MallBaseId = req.MallBaseId;
var list = firstShopListModule.GetFirstShopListPageList(pageModel.pageIndex, pageModel.pageSize, out long count, demodel);
return ApiResult.Success("", list.Select(x => new
{
x.Id,
x.ListType,
ListTypeName = x.ListType.GetEnumName(),
x.ObjectTypeIds,
x.ObjectTypeList,
x.Sponsor,
x.ListName,
x.CoverImage,
DeadlineDate = x.DeadlineDate.ToString("yyyy-MM-dd HH:mm"),
StartDate = x.StartDate.ToString("yyyy-MM-dd HH:mm"),
x.Content,
x.EnableRank,
x.PrizeNum,
x.ListState,
ListStateName = x.ListState.GetEnumName(),
UpdateDate = x.UpdateDate.ToString("yyyy-MM-dd HH:mm:ss")
}));
}
/// <summary>
/// 获取榜单详情
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetFistShopPrizeListInfo() {
var req = base.RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int ListId = parms.GetInt("ListId", 0);//榜单id
if (ListId <= 0) {
return ApiResult.ParamIsNull();
}
var model = firstShopListModule.GetFirstShopListInfo(ListId);
if (model == null) { return ApiResult.Failed("榜单不存在"); }
return ApiResult.Success("", new
{
model.Id,
model.ListType,
model.ObjectTypeIds,
model.Sponsor,
model.ListName,
model.CoverImage,
DeadlineDate = model.DeadlineDate.ToString("yyyy-MM-dd HH:mm"),
StartDate = model.StartDate.ToString("yyyy-MM-dd HH:mm"),
model.Content,
model.EnableRank,
model.PrizeNum,
model.ListState
});
}
/// <summary>
/// 设置榜单
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetFistShopPrizeListInfo() {
var req = base.RequestParm;
RB_FirstShop_List_Extend demodel = JsonHelper.DeserializeObject<RB_FirstShop_List_Extend>(req.msg.ToString());
if (string.IsNullOrEmpty(demodel.Sponsor)) {
return ApiResult.ParamIsNull("请输入主办方名称");
}
if (string.IsNullOrEmpty(demodel.ListName)) {
return ApiResult.ParamIsNull("请输入榜单名称");
}
if (string.IsNullOrEmpty(demodel.ObjectTypeIds)) {
return ApiResult.ParamIsNull("请选择面向群体");
}
if (string.IsNullOrEmpty(demodel.CoverImage)) {
return ApiResult.ParamIsNull("请上传封面图");
}
if (string.IsNullOrEmpty(demodel.Content)) {
return ApiResult.ParamIsNull("请输入详情内容");
}
if (demodel.PrizeNum <= 0) {
return ApiResult.ParamIsNull("请输入入围名额");
}
demodel.ListState = Common.Enum.TradePavilion.ListStateEnum.Enroll;
demodel.TenantId = req.TenantId;
demodel.MallBaseId = req.MallBaseId;
demodel.Status = 0;
demodel.CreateBy = req.EmpId;
demodel.CreateDate = DateTime.Now;
demodel.UpdateBy = req.EmpId;
demodel.UpdateDate = DateTime.Now;
string msg = firstShopListModule.SetFirstShopListInfo(demodel);
if (msg == "")
{
return ApiResult.Success();
}
else {
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 取消榜单
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult DelFistShopPrizeListInfo() {
var req = base.RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
int ListId = parms.GetInt("ListId", 0);//榜单id
if (ListId <= 0)
{
return ApiResult.ParamIsNull();
}
string msg = firstShopListModule.DelFirstShopListInfo(ListId, req.MallBaseId);
if (msg == "")
{
return ApiResult.Success();
}
else {
return ApiResult.Failed(msg);
}
}
/// <summary>
/// 获取榜单面向群体枚举列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetListObjectTypeEnumList()
{
var list = EnumHelper.GetEnumList(typeof(Common.Enum.TradePavilion.ListObjectTypeEnum));
return ApiResult.Success("", list.Select(x => new
{
Name = x.Key,
Id = Convert.ToInt32(x.Value)
}));
}
/// <summary>
/// 获取榜单状态枚举列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetListStateEnumList()
{
var list = EnumHelper.GetEnumList(typeof(Common.Enum.TradePavilion.ListStateEnum));
return ApiResult.Success("", list.Select(x => new
{
Name = x.Key,
Id = Convert.ToInt32(x.Value)
}));
}
/// <summary>
/// 获取榜单类型枚举列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetListTypeEnumList()
{
var list = EnumHelper.GetEnumList(typeof(Common.Enum.TradePavilion.ListTypeEnum));
return ApiResult.Success("", list.Select(x => new
{
Name = x.Key,
Id = Convert.ToInt32(x.Value)
}));
}
#endregion
#region 心愿单列表
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment