Commit 0d2f5ecb authored by liudong1993's avatar liudong1993
parents b92c6246 5f76c13a
......@@ -31,6 +31,11 @@ namespace Mall.Model.Entity.MarketingCenter
/// </summary>
public int ParentId { get; set; }
/// <summary>
/// 排序
/// </summary>
public int SortNum { get; set; }
/// <summary>
/// 删除状态(1-删除)
/// </summary>
......
......@@ -58,6 +58,11 @@ namespace Mall.Model.Entity.MarketingCenter
/// </summary>
public int SortNum { get; set; }
/// <summary>
/// 启用-1,禁用-0
/// </summary>
public int IsUse { get; set; }
/// <summary>
/// 删除状态(1-删除)
/// </summary>
......
......@@ -12,5 +12,9 @@ namespace Mall.Model.Extend.MarketingCenter
[DB(ConnectionName = "DefaultConnection")]
public class RB_Share_Category_Extend : RB_Share_Category
{
/// <summary>
/// 分类Id
/// </summary>
public string QCateIds { get; set; }
}
}
......@@ -11,6 +11,35 @@ namespace Mall.Model.Extend.MarketingCenter
[DB(ConnectionName = "DefaultConnection")]
public class RB_Share_Friend_Extend : RB_Share_Friend
{
/// <summary>
/// 关键字
/// </summary>
public string KeyWords { get; set; }
/// <summary>
/// 开始时间
/// </summary>
public string QStartDate { get; set; }
/// <summary>
/// 结束时间
/// </summary>
public string QEndDate { get; set; }
/// <summary>
/// 分类Ids【逗号分割】
/// </summary>
public string CateIds { get; set; }
/// <summary>
/// 创建时间字符串
/// </summary>
public string CreateDateStr
{
get
{
return Convert.ToDateTime(this.CreateDate).ToString("yyyy-MM-dd HH:mm:ss");
}
}
}
}
\ No newline at end of file
......@@ -37,6 +37,15 @@ namespace Mall.Module.MarketingCenter
return share_CategoryRepository.GetShareCategoryPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 根据上级编号获取所有子级分类
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Share_Category_Extend> GetChildCategoryListModule(RB_Share_Category_Extend query)
{
return share_CategoryRepository.GetChildCategoryListRepository(query);
}
/// <summary>
/// 获取分享分类列表
......@@ -50,10 +59,10 @@ namespace Mall.Module.MarketingCenter
if (list != null)
{
var leavelList = list.GroupBy(qitem => new { qitem.Level }).OrderBy(qitem => qitem.Key.Level);
foreach (var item in list.Where(qitem => qitem.Level == 1))
foreach (var item in list.Where(qitem => qitem.Level == 1).OrderBy(qitem => qitem.SortNum))
{
List<object> secondList = new List<object>();
var subList = list.Where(qitem => qitem.Level == 2 && qitem.ParentId == item.Id).ToList();
var subList = list.Where(qitem => qitem.Level == 2 && qitem.ParentId == item.Id).OrderBy(qitem => qitem.SortNum).ToList();
foreach (var subItem in subList)
{
var subModel = new
......@@ -62,19 +71,16 @@ namespace Mall.Module.MarketingCenter
subItem.Level,
subItem.Name,
subItem.ParentId,
hasChildren = list.Where(qitem => qitem.Level == 3 && qitem.ParentId == subItem.Id)?.Count() > 0,
children = list.Where(qitem => qitem.Level == 3 && qitem.ParentId == subItem.Id).Select(qitem => new { qitem.Id, qitem.Name, qitem.Level, qitem.ParentId })
children = list.Where(qitem => qitem.Level == 3 && qitem.ParentId == subItem.Id).OrderBy(qitem => qitem.SortNum).Select(qitem => new { qitem.Id, qitem.Name, qitem.Level, qitem.ParentId })
};
secondList.Add(subModel);
}
var rootModel = new
{
item.Id,
item.Level,
item.Name,
item.ParentId,
hasChildren = secondList?.Count>0,
children = secondList
};
resultList.Add(rootModel);
......@@ -93,7 +99,14 @@ namespace Mall.Module.MarketingCenter
/// <returns></returns>
public List<RB_Share_Friend_Extend> GetShareFriendPageListModule(int pageIndex, int pageSize, out long rowsCount, RB_Share_Friend_Extend query)
{
return share_FriendRepository.GetShareFriendPageListRepository(pageIndex, pageSize, out rowsCount, query);
if (query.CateId > 0)
{
var cateList = GetChildCategoryListModule(new RB_Share_Category_Extend() { QCateIds = query.CateId.ToString() });
query.CateId = 0;
query.CateIds = string.Join(",", cateList.Select(qitem => qitem.Id));
}
var list = share_FriendRepository.GetShareFriendPageListRepository(pageIndex, pageSize, out rowsCount, query);
return list;
}
......@@ -123,6 +136,7 @@ namespace Mall.Module.MarketingCenter
{nameof(RB_Share_Category_Extend.Level),extModel.Level },
{nameof(RB_Share_Category_Extend.ParentId),extModel.ParentId },
{nameof(RB_Share_Category_Extend.UpdateDate),extModel.UpdateDate },
{nameof(RB_Share_Category_Extend.SortNum),extModel.SortNum },
};
flag = share_CategoryRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Category_Extend.Id), extModel.Id));
}
......@@ -220,5 +234,73 @@ namespace Mall.Module.MarketingCenter
flag = share_FriendRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Friend_Extend.Id), Id));
return flag;
}
/// <summary>
/// 更新是否置顶
/// </summary>
/// <param name="Id"></param>
/// <param name="IsTop"></param>
/// <returns></returns>
public bool SetShareFriendIsTopModule(object Id,int IsTop)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Friend_Extend.IsTop),IsTop},
};
flag = share_FriendRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Friend_Extend.Id), Id));
return flag;
}
/// <summary>
/// 更新是否启用
/// </summary>
/// <param name="Id"></param>
/// <param name="IsUse"></param>
/// <returns></returns>
public bool SetShareFriendIsUseModule(object Id, int IsUse)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Friend_Extend.IsUse),IsUse},
};
flag = share_FriendRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Friend_Extend.Id), Id));
return flag;
}
/// <summary>
/// 更新排序
/// </summary>
/// <param name="Id"></param>
/// <param name="SortNum"></param>
/// <returns></returns>
public bool SetShareFriendSortNumModule(object Id, int SortNum)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Friend_Extend.SortNum),SortNum},
};
flag = share_FriendRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Friend_Extend.Id), Id));
return flag;
}
/// <summary>
/// 更新文案
/// </summary>
/// <param name="Id"></param>
/// <param name="MaterialInfo"></param>
/// <returns></returns>
public bool SetShareFriendMaterialInfoModule(object Id, string MaterialInfo)
{
bool flag = false;
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Share_Friend_Extend.MaterialInfo),MaterialInfo},
};
flag = share_FriendRepository.Update(fileds, new WhereHelper(nameof(RB_Share_Friend_Extend.Id), Id));
return flag;
}
}
}
......@@ -42,6 +42,14 @@ WHERE 1=1 AND Status=0
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.Name)} like '%{query.Name}%'");
}
if (query.Id > 0)
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.Id)}={query.Id}");
}
if (!string.IsNullOrWhiteSpace(query.QCateIds))
{
builder.AppendFormat(" AND {0} IN ({1}) ", nameof(RB_Share_Category_Extend.Id), query.QCateIds);
}
}
return GetPage<RB_Share_Category_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
......@@ -74,7 +82,35 @@ WHERE 1=1 AND Status=0
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.Name)} like '%{query.Name}%'");
}
if (query.Id > 0)
{
builder.Append($" AND {nameof(RB_Share_Category_Extend.Id)}={query.Id}");
}
if (!string.IsNullOrWhiteSpace(query.QCateIds))
{
builder.AppendFormat(" AND {0} IN ({1}) ", nameof(RB_Share_Category_Extend.Id),query.QCateIds);
}
}
return Get<RB_Share_Category_Extend>(builder.ToString()).ToList();
}
/// <summary>
/// 根据上级编号获取所有子级分类
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Share_Category_Extend> GetChildCategoryListRepository(RB_Share_Category_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT tabA.*
FROM (SELECT * FROM rb_share_category WHERE `Status`=0 AND ParentId>0) tabA,
(SELECT @pid := '{0}') pd
WHERE FIND_IN_SET(ParentId, @pid) > 0 AND @pid := concat(@pid, ',', id)
UNION
SELECT *
FROM rb_share_category
WHERE `Status`=0 AND FIND_IN_SET(Id,@pid) > 0 ",query.QCateIds);
return Get<RB_Share_Category_Extend>(builder.ToString()).ToList();
}
}
......
......@@ -38,6 +38,26 @@ WHERE 1=1 AND Status=0
{
builder.Append($" AND {nameof(RB_Share_Friend_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.CateId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Share_Friend_Extend.CateId),query.CateId);
}
if (!string.IsNullOrWhiteSpace(query.CateIds))
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Share_Friend_Extend.CateId), query.CateIds);
}
if (!string.IsNullOrWhiteSpace(query.KeyWords))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Share_Friend_Extend.MaterialInfo), query.KeyWords);
}
if (!string.IsNullOrWhiteSpace(query.QStartDate))
{
builder.AppendFormat(" AND {0}>='{1}' ", nameof(RB_Share_Friend_Extend.CreateDate), Convert.ToDateTime(query.QStartDate).ToString("yyyy-MM-dd"));
}
if (!string.IsNullOrWhiteSpace(query.QEndDate))
{
builder.AppendFormat(" AND {0}<='{1} 23:59:59' ", nameof(RB_Share_Friend_Extend.CreateDate), Convert.ToDateTime(query.QEndDate).ToString("yyyy-MM-dd"));
}
}
return GetPage<RB_Share_Friend_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString()).ToList();
}
......@@ -66,7 +86,26 @@ WHERE 1=1 AND Status=0
{
builder.Append($" AND {nameof(RB_Share_Friend_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.CateId > 0)
{
builder.AppendFormat(" AND {0}={1} ", nameof(RB_Share_Friend_Extend.CateId), query.CateId);
}
if (!string.IsNullOrWhiteSpace(query.CateIds))
{
builder.AppendFormat(" AND {0} IN({1}) ", nameof(RB_Share_Friend_Extend.CateId), query.CateIds);
}
if (!string.IsNullOrWhiteSpace(query.KeyWords))
{
builder.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Share_Friend_Extend.MaterialInfo), query.KeyWords);
}
if (!string.IsNullOrWhiteSpace(query.QStartDate))
{
builder.AppendFormat(" AND {0}>='{1}' ", nameof(RB_Share_Friend_Extend.CreateDate), Convert.ToDateTime(query.QStartDate).ToString("yyyy-MM-dd"));
}
if (!string.IsNullOrWhiteSpace(query.QEndDate))
{
builder.AppendFormat(" AND {0}<='{1} 23:59:59' ", nameof(RB_Share_Friend_Extend.CreateDate), Convert.ToDateTime(query.QEndDate).ToString("yyyy-MM-dd"));
}
}
return Get<RB_Share_Friend_Extend>(builder.ToString()).ToList();
}
......
......@@ -137,6 +137,7 @@ namespace Mall.WebApi.Controllers.MarketingCenter
extModel.MallBaseId = RequestParm.MallBaseId;
extModel.CreateDate = DateTime.Now;
extModel.UpdateDate = DateTime.Now;
extModel.IsUse = 1;
bool flag = shareModule.SetShareFriendModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......@@ -164,5 +165,59 @@ namespace Mall.WebApi.Controllers.MarketingCenter
var extModel = shareModule.GetShareFriendModule(Id);
return ApiResult.Success(data: extModel);
}
/// <summary>
/// 更新置顶状态
/// </summary>
/// <returns></returns>
public ApiResult SetShareFriendIsTop()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
int IsTop = parm.GetInt("IsTop", 0);
bool flag = shareModule.SetShareFriendIsTopModule(Id, IsTop);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 更新是否启用
/// </summary>
/// <returns></returns>
public ApiResult SetShareFriendIsUse()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
int IsUse = parm.GetInt("IsUse", 0);
bool flag = shareModule.SetShareFriendIsUseModule(Id, IsUse);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 更新排序
/// </summary>
/// <returns></returns>
public ApiResult SetShareFriendSortNum()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
int SortNum = parm.GetInt("SortNum", 0);
bool flag = shareModule.SetShareFriendSortNumModule(Id, SortNum);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 更新文案
/// </summary>
/// <returns></returns>
public ApiResult SetShareFriendMaterialInfo()
{
JObject parm = JObject.Parse(RequestParm.msg.ToString());
int Id = parm.GetInt("Id", 0);
var MaterialInfo = parm.GetStringValue("MaterialInfo");
bool flag = shareModule.SetShareFriendMaterialInfoModule(Id, MaterialInfo);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
}
}
\ No newline at end of file
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