Commit e0d649fc authored by liudong1993's avatar liudong1993

活动调整

parent 87cc172c
......@@ -43,6 +43,16 @@ namespace Mall.Model.Extend.Miai
/// </summary>
public int EnrollNum { get; set; }
/// <summary>
/// 只看可报名 1是
/// </summary>
public int IsSelectEnroll { get; set; }
/// <summary>
/// 排序 0默认最新 1报名人数倒序 2回复数量倒序
/// </summary>
public int OrderBy { get; set; }
/// <summary>
/// 活动ids
/// </summary>
......
......@@ -24,5 +24,28 @@ namespace Mall.Model.Extend.TradePavilion
/// 报名状态 1正常 2取消 3查询所有
/// </summary>
public int EnrollState { get; set; }
/// <summary>
/// 活动名称
/// </summary>
public string ActivityName { get; set; }
/// <summary>
/// 活动封面图
/// </summary>
public string CoverImg { get; set; }
/// <summary>
/// 活动开始时间
/// </summary>
public DateTime? StartTime { get; set; }
/// <summary>
/// 活动结束时间
/// </summary>
public DateTime? EndTime { get; set; }
/// <summary>
/// 类型名称
/// </summary>
public string TypeName { get; set; }
}
}
......@@ -194,10 +194,11 @@ namespace Mall.Module.TradePavilion
/// <param name="Id"></param>
/// <param name="Status"></param>
/// <returns></returns>
public bool CancelCommerceConsultModule(int activityId, string cancelRemark, int userId)
public bool CancelCommerceConsultModule(int activityId, string cancelRemark,out int IsCancelConfirm, int userId)
{
bool flag;
var amodel = commerce_ActivityRepository.GetEntity(activityId);
IsCancelConfirm = amodel.IsCancelConfirm;
var cmodel = consultRepository.GetCommerceConsultListRepository(new RB_Commerce_Consult_Extend() { ActivityId = activityId, UserId = userId }).FirstOrDefault();
if (cmodel == null || cmodel.Status == Common.Enum.DateStateEnum.Delete) { return true; }
if (amodel.IsCancelConfirm == 1)
......@@ -216,14 +217,14 @@ namespace Mall.Module.TradePavilion
else
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Commerce_Consult_Extend.Status),1 },
};
{
{nameof(RB_Commerce_Consult_Extend.Status),1 },
};
List<WhereHelper> list = new List<WhereHelper>()
{
new WhereHelper(nameof(RB_Commerce_Consult_Extend.ActivityId), activityId),
new WhereHelper(nameof(RB_Commerce_Consult_Extend.UserId), userId),
};
{
new WhereHelper(nameof(RB_Commerce_Consult_Extend.ActivityId), activityId),
new WhereHelper(nameof(RB_Commerce_Consult_Extend.UserId), userId),
};
flag = consultRepository.Update(fileds, list);
if (flag && cmodel.Money > 0) {
//取消退回使用点数
......@@ -317,5 +318,18 @@ namespace Mall.Module.TradePavilion
}
return flag;
}
/// <summary>
/// 获取我的报名列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Commerce_Consult_Extend> GetUserJoinActivityPageList(int pageIndex, int pageSize, out long rowsCount, RB_Commerce_Consult_Extend dmodel)
{
return consultRepository.GetUserJoinActivityPageList(pageIndex, pageSize, out rowsCount, dmodel);
}
}
}
......@@ -41,6 +41,11 @@ namespace Mall.Repository.Miai
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.UserId)} ={dmodel.UserId}";
}
if (dmodel.IsSelectEnroll == 1)
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.Deadline)} >='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";
}
string sql = $@"select a.*,u.Name as UserName,u.Photo,b.Sex from RB_Miai_Activity a
left join rb_member_user u on a.UserId =u.Id
left join rb_miai_baseinfo b on a.UserId =b.UserId
......@@ -48,6 +53,60 @@ where {where} order by a.Id desc";
return GetPage<RB_Miai_Activity_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 分页列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="dmodel">查询条件</param>
/// <returns></returns>
public List<RB_Miai_Activity_Extend> GetPageList_V2(int pageIndex, int pageSize, out long rowCount, RB_Miai_Activity_Extend dmodel)
{
string where = $" 1=1 and a.{nameof(RB_Miai_Activity_Extend.Status)}=0 ";
if (dmodel.TenantId > 0)
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.MallBaseId)}={dmodel.MallBaseId}";
}
if (!string.IsNullOrEmpty(dmodel.ActivityTitle))
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.ActivityTitle)} like '%{dmodel.ActivityTitle}%'";
}
if (dmodel.ForumId > 0)
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.ForumId)} ={dmodel.ForumId}";
}
if (dmodel.UserId > 0)
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.UserId)} ={dmodel.UserId}";
}
if (dmodel.IsSelectEnroll == 1)
{
where += $@" and a.{nameof(RB_Miai_Activity_Extend.Deadline)} >='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}'";
}
string orderBy = " a.Id DESC";
if (dmodel.OrderBy == 1)
{
orderBy = " e.Number DESC,a.Id DESC";
}
else if (dmodel.OrderBy == 2) {
orderBy = " r.ReplyNum DESC,a.Id DESC";
}
string sql = $@"select a.*,u.Name as UserName,u.Photo,b.Sex,IFNULL(r.ReplyNum,0) as ReplyNum,IFNULL(e.Number,0) as EnrollNum
from RB_Miai_Activity a
left join rb_member_user u on a.UserId =u.Id
left join rb_miai_baseinfo b on a.UserId =b.UserId
left join (select ActivityId,count(0) as ReplyNum from RB_Miai_ActivityDiscuss where Status =0 group by ActivityId) r on r.ActivityId = a.Id
left join (select ActivityId,count(0) as Number from RB_Miai_ActivityEnroll where Status =0 group by ActivityId) e on e.ActivityId = a.Id
where {where} order by {orderBy}";
return GetPage<RB_Miai_Activity_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
......
......@@ -80,6 +80,80 @@ WHERE 1=1
}
return Get<RB_Commerce_Consult_Extend>(builder.ToString(), parameters).ToList();
}
/// <summary>
/// 获取用户的报名列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public List<RB_Commerce_Consult_Extend> GetUserJoinActivityPageList(int pageIndex, int pageSize, out long rowsCount, RB_Commerce_Consult_Extend query)
{
DynamicParameters parameters = new DynamicParameters();
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT c.*,a.ActivityName,a.CoverImg,a.StartTime,a.EndTime,t.TypeName
FROM RB_Commerce_Consult c
left join rb_commerce_activity a on c.ActivityId = a.Id
left join rb_commerce_activitytype t on t.Id = a.ActivityType
WHERE 1=1
");
if (query == null)
{
rowsCount = 0;
return new List<RB_Commerce_Consult_Extend>();
}
else
{
if (query.EnrollState > 0)
{
if (query.EnrollState == 1)
{
builder.AppendFormat(" AND c.{0}={1} ", nameof(RB_Commerce_Consult_Extend.Status), (int)DateStateEnum.Normal);
}
else if (query.EnrollState == 2)
{
builder.AppendFormat(" AND c.{0}={1} ", nameof(RB_Commerce_Consult_Extend.Status), (int)DateStateEnum.Delete);
}
}
else
{
builder.AppendFormat(" AND c.{0}={1} ", nameof(RB_Commerce_Consult_Extend.Status), (int)DateStateEnum.Normal);
}
if (query.TenantId > 0)
{
builder.AppendFormat(" AND c.{0}={1} ", nameof(RB_Commerce_Consult_Extend.TenantId), query.TenantId);
}
if (query.MallBaseId > 0)
{
builder.AppendFormat(" AND c.{0}={1} ", nameof(RB_Commerce_Consult_Extend.MallBaseId), query.MallBaseId);
}
if (!string.IsNullOrEmpty(query.LinkMan))
{
builder.AppendFormat(" AND c.{0} LIKE @Name ", nameof(RB_Commerce_Consult_Extend.LinkMan));
parameters.Add("Name", "%" + query.LinkMan.Trim() + "%");
}
if (query.ActivityId > 0)
{
builder.AppendFormat(" AND c.{0}={1} ", nameof(RB_Commerce_Consult_Extend.ActivityId), query.ActivityId);
}
if (!string.IsNullOrEmpty(query.QActivityIds))
{
builder.AppendFormat(" AND c.{0} IN({1}) ", nameof(RB_Commerce_Consult_Extend.ActivityId), query.QActivityIds);
}
if (!string.IsNullOrEmpty(query.QUserIds))
{
builder.AppendFormat(" AND c.{0} IN({1}) ", nameof(RB_Commerce_Consult_Extend.UserId), query.QUserIds);
}
if (query.UserId > 0)
{
builder.AppendFormat(" AND c.{0}={1} ", nameof(RB_Commerce_Consult_Extend.UserId), query.UserId);
}
}
builder.AppendFormat(" order by c.Id desc");
return GetPage<RB_Commerce_Consult_Extend>(pageIndex, pageSize, out rowsCount, builder.ToString(), parameters).ToList();
}
}
}
......@@ -404,6 +404,46 @@ namespace Mall.WebApi.Controllers.TradePavilion
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 获取活动报名列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetUserJoinActivityPageList()
{
ResultPageModel pageModel = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_Commerce_Consult_Extend dmodel = JsonConvert.DeserializeObject<RB_Commerce_Consult_Extend>(RequestParm.msg.ToString());
var userInfo = AppletUserInfo;
dmodel.MallBaseId = RequestParm.MallBaseId;
dmodel.TenantId = userInfo?.TenantId ?? 0;
dmodel.UserId = userInfo.UserId;
var list = consultModule.GetUserJoinActivityPageList(pageModel.pageIndex, pageModel.pageSize, out long rowsCount, dmodel);
pageModel.count = Convert.ToInt32(rowsCount);
pageModel.pageData = list.Select(x => new
{
x.Id,
x.ActivityId,
x.UserId,
x.LinkMan,
x.LinkTel,
CreateTime = x.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
x.Status,
x.PeopleNum,
x.Money,
x.Remark,
x.IsApplyForCancel,
x.CancelRemark,
x.ApplyForCancelStatus,
x.RejectRemark,
x.ActivityName,
x.CoverImg,
StartTime = x.StartTime.HasValue ? x.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
EndTime = x.EndTime.HasValue ? x.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
x.TypeName
});
return ApiResult.Success(data: pageModel);
}
/// <summary>
/// 新增修改商会活动报名
/// </summary>
......@@ -443,8 +483,8 @@ namespace Mall.WebApi.Controllers.TradePavilion
var ActivityId = jObj.GetInt("ActivityId");
string CancelRemark = jObj.GetStringValue("CancelRemark");
var userInfo = AppletUserInfo;
var flag = consultModule.CancelCommerceConsultModule(ActivityId, CancelRemark, userInfo.UserId);
return flag ? ApiResult.Success() : ApiResult.Failed();
var flag = consultModule.CancelCommerceConsultModule(ActivityId, CancelRemark, out int IsCancelConfirm, userInfo.UserId);
return flag ? ApiResult.Success("", IsCancelConfirm) : ApiResult.Failed();
}
/// <summary>
......
......@@ -339,7 +339,7 @@ namespace Mall.WebApi.Controllers.TradePavilion
ActivityInfo = jObj.GetStringValue("ActivityInfo"),
SignStartTime = jObj.GetDateTime("SignStartTime"),
SignEndTime = jObj.GetDateTime("SignEndTime"),
IsFree = jObj.GetInt("IsFree", 2),
IsFree = jObj.GetInt("IsFree", 1),
Price = jObj.GetInt("Price", 0),
IsCancelConfirm = jObj.GetInt("IsCancelConfirm", 2)
};
......@@ -359,6 +359,9 @@ namespace Mall.WebApi.Controllers.TradePavilion
extModel.CreateDate = DateTime.Now;
extModel.UpdateBy = Uid;
extModel.UpdateDate = DateTime.Now;
if (extModel.IsFree == 1) {
extModel.Price = 0;
}
var flag = activityModule.SetCommerceActivityModule(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
......
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