Commit c21d4ee7 authored by 黄奎's avatar 黄奎

新增处理类

parent 1b10d783
......@@ -10,5 +10,9 @@ namespace Mall.Model.Extend.TradePavilion
/// </summary>
public class RB_Commerce_Activity_Extend: RB_Commerce_Activity
{
/// <summary>
/// 商会活动详情列表
/// </summary>
public List<RB_Commerce_Details_Extend> CommerceDetailsList { get; set; }
}
}
......@@ -2,7 +2,9 @@
using Mall.Repository.TradePavilion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VT.FW.DB;
namespace Mall.Module.TradePavilion
{
......@@ -26,6 +28,8 @@ namespace Mall.Module.TradePavilion
/// </summary>
private readonly RB_Commerce_DetailsRepository detailsRepository = new RB_Commerce_DetailsRepository();
#region 商户活动管理
/// <summary>
/// 获取商会活动分页列表
/// </summary>
......@@ -39,6 +43,112 @@ namespace Mall.Module.TradePavilion
return commerce_ActivityRepository.GetCommerceActivityPageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 新增修改商户活动
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCommerceActivityModule(RB_Commerce_Activity_Extend model)
{
bool flag;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Commerce_Activity_Extend.ActivityName),model.ActivityName },
{nameof(RB_Commerce_Activity_Extend.StartTime),model.StartTime },
{nameof(RB_Commerce_Activity_Extend.EndTime),model.EndTime },
{nameof(RB_Commerce_Activity_Extend.CoverImg),model.CoverImg },
{nameof(RB_Commerce_Activity_Extend.ActivityType),model.ActivityType },
{nameof(RB_Commerce_Activity_Extend.ActivityInfo),model.ActivityType },
{nameof(RB_Commerce_Activity_Extend.UpdateBy),model.UpdateBy },
{nameof(RB_Commerce_Activity_Extend.UpdateDate),model.UpdateDate },
};
flag = commerce_ActivityRepository.Update(fileds, new WhereHelper(nameof(RB_Commerce_Activity_Extend.Id), model.Id));
}
else
{
var newId = commerce_ActivityRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
//原来的活动详情
var oldDetailsList = GetCommerceDetailsListModule(new RB_Commerce_Details_Extend() { ActivityId = model.Id });
//以前没有活动详情【直接新增】
if (oldDetailsList == null || (oldDetailsList != null && oldDetailsList.Count == 0))
{
if (model.CommerceDetailsList != null && model.CommerceDetailsList.Count > 0)
{
foreach (var item in model.CommerceDetailsList)
{
item.ActivityId = model.Id;
detailsRepository.Insert(item);
}
}
}
else//以前有活动详情
{
//现在没有阶梯报价了【直接删除以前的阶梯报价】
if (model.CommerceDetailsList == null || (model.CommerceDetailsList != null && model.CommerceDetailsList.Count == 0))
{
detailsRepository.DeleteCommerceDetailsRepository(model.Id);
}
//找出差异的数据
var deleteList = oldDetailsList.Where(qitem => !model.CommerceDetailsList.Any(oldItem => qitem.ActivityId == oldItem.ActivityId)).ToList();
foreach (var dItem in deleteList)
{
if (dItem.Id > 0)
{
detailsRepository.Delete(dItem.Id);
}
}
foreach (var priceItem in model.CommerceDetailsList)
{
priceItem.ActivityId = model.Id;
if (priceItem.Id == 0)
{
detailsRepository.Insert(priceItem);
}
else
{
detailsRepository.Update(priceItem);
}
}
}
return flag;
}
/// <summary>
/// 获取修改商户活动详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Commerce_Activity_Extend GetCommerceActivityModule(object Id)
{
return commerce_ActivityRepository.GetEntity<RB_Commerce_Activity_Extend>(Id);
}
/// <summary>
/// 更新商户活动状态
/// </summary>
/// <param name="Id"></param>
/// <param name="Status"></param>
/// <returns></returns>
public bool RemoveCommerceActivityModule(int Id, int Status)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Commerce_Activity_Extend.Status),Status },
};
bool flag = commerce_ActivityRepository.Update(fileds, new WhereHelper(nameof(RB_Commerce_Activity_Extend.Id), Id));
return flag;
}
#endregion
#region 商户活动类型管理
/// <summary>
/// 获取商会活动类型分页列表
......@@ -53,6 +163,63 @@ namespace Mall.Module.TradePavilion
return activityTypeRepository.GetCommerceActivityTypePageListRepository(pageIndex, pageSize, out rowsCount, query);
}
/// <summary>
/// 新增修改商会活动类型
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool SetCommerceActivityTypeModule(RB_Commerce_ActivityType_Extend model)
{
bool flag;
if (model.Id > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Commerce_ActivityType_Extend.TypeName),model.TypeName },
{nameof(RB_Commerce_ActivityType_Extend.UpdateBy),model.UpdateBy },
{nameof(RB_Commerce_ActivityType_Extend.UpdateDate),model.UpdateDate }
};
flag = activityTypeRepository.Update(fileds, new WhereHelper(nameof(RB_Commerce_ActivityType_Extend.Id), model.Id));
}
else
{
var newId = activityTypeRepository.Insert(model);
model.Id = newId;
flag = newId > 0;
}
return flag;
}
/// <summary>
/// 获取商会活动类型详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public RB_Commerce_ActivityType_Extend GetCommerceActivityTypeModule(object Id)
{
return activityTypeRepository.GetEntity<RB_Commerce_ActivityType_Extend>(Id);
}
/// <summary>
/// 更新商户活动类型状态
/// </summary>
/// <param name="Id"></param>
/// <param name="Status"></param>
/// <returns></returns>
public bool RemoveCommerceActivityTypeModule(int Id, int Status)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Commerce_ActivityType_Extend.Status),Status },
};
bool flag = activityTypeRepository.Update(fileds, new WhereHelper(nameof(RB_Commerce_ActivityType_Extend.Id), Id));
return flag;
}
#endregion
#region 商会活动详情管理
/// <summary>
/// 获取商会活动详情列表
/// </summary>
......@@ -62,5 +229,7 @@ namespace Mall.Module.TradePavilion
{
return detailsRepository.GetCommerceDetailsListRepository(query);
}
#endregion
}
}
......@@ -45,5 +45,17 @@ WHERE 1=1
}
return Get<RB_Commerce_Details_Extend>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 根据活动编号删除活动详情
/// </summary>
/// <param name="ActivityId"></param>
/// <returns></returns>
public bool DeleteCommerceDetailsRepository(int ActivityId)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" DELETE FROM RB_Commerce_Details WHERE ActivityId={0} ", ActivityId);
return base.Execute(builder.ToString()) > 0;
}
}
}
\ 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