Commit a23108e2 authored by 吴春's avatar 吴春

提交代码

parent 6c6618d1
...@@ -44,5 +44,66 @@ namespace Mall.Model.Extend.Product ...@@ -44,5 +44,66 @@ namespace Mall.Model.Extend.Product
/// 评论总分 /// 评论总分
/// </summary> /// </summary>
public decimal TotalScore { get; set; } public decimal TotalScore { get; set; }
#region 司导信息
/// <summary>
/// 导游名称
/// </summary>
public string GuideName { get; set; }
/// <summary>
/// 车辆名称
/// </summary>
public string CarName { get; set; }
/// <summary>
/// 车辆颜色
/// </summary>
public string CarColorName { get; set; }
/// <summary>
/// 车辆品牌
/// </summary>
public string CarBrandName { get; set; }
#endregion
}
/// <summary>
/// 司导商品评论扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class GoodsComment_Extend
{
/// <summary>
/// 评论总分
/// </summary>
public decimal TotalScore { get; set; }
public int OrderDetailId { get; set; }
public int GoodsId { get; set; }
public string UpdateDate { get; set; }
public int UserId { get; set; }
public int UserPhoto { get; set; }
public int Is_Anonymity { get; set; }
public string UserName { get; set; }
public string UserPhotoPath { get; set; }
public int CommentGrade { get; set; }
/// <summary>
/// 评价
/// </summary>
public List<RB_Goods_Comment_Extend> CommentList { get; set; }
} }
} }
...@@ -3457,7 +3457,7 @@ namespace Mall.Module.Product ...@@ -3457,7 +3457,7 @@ namespace Mall.Module.Product
decimal carScore = 0; decimal carScore = 0;
if (carScoreList != null && carScoreList.Any()) if (carScoreList != null && carScoreList.Any())
{ {
carScore = (carScoreList.FirstOrDefault().TotalScore + (Convert.ToDecimal(list.Where(x=>x.CarId== dmodel.CarId).FirstOrDefault().CommentScore ?? 0))) / (carScoreList.FirstOrDefault().CommentNum + 1); carScore = (carScoreList.FirstOrDefault().TotalScore + (Convert.ToDecimal(list.Where(x => x.CarId == dmodel.CarId).FirstOrDefault().CommentScore ?? 0))) / (carScoreList.FirstOrDefault().CommentNum + 1);
} }
else else
{ {
...@@ -3677,7 +3677,7 @@ namespace Mall.Module.Product ...@@ -3677,7 +3677,7 @@ namespace Mall.Module.Product
x.CarName, x.CarName,
x.RideNum, x.RideNum,
x.GuideCarType, x.GuideCarType,
CarClassStr= x.CarClass.HasValue? EnumHelper.GetEnumName(x.CarClass):"", CarClassStr = x.CarClass.HasValue ? EnumHelper.GetEnumName(x.CarClass) : "",
x.GuideName, x.GuideName,
x.GuidePhoto, x.GuidePhoto,
x.GuideScore, x.GuideScore,
...@@ -3691,6 +3691,93 @@ namespace Mall.Module.Product ...@@ -3691,6 +3691,93 @@ namespace Mall.Module.Product
}); });
} }
/// <summary>
/// 小程序商品详情评论分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<GoodsComment_Extend> GetGoodsDetailPageList(int pageIndex, int pageSize, out long count, RB_Goods_Comment_Extend dmodel)
{
var list = goods_CommentRepository.GetGoodsDetailPageList(pageIndex, pageSize, out count, dmodel);
if (list != null && list.Any())
{
string orderDetailIds = string.Join(",", list.Select(x => x.OrderDetailId));
var carCommentList = goods_CommentRepository.GetCarCommentByOrderDetailId(orderDetailIds, dmodel.TenantId, dmodel.MallBaseId);
var guideCommentList = goods_CommentRepository.GetGuideCommentByOrderDetailId(orderDetailIds, dmodel.TenantId, dmodel.MallBaseId);
List<RB_Member_User_Extend> userList = new List<RB_Member_User_Extend>();
if (list.Where(x => x.UserId > 0).Any())
{
string uids = string.Join(",", list.Where(x => x.UserId > 0).Select(x => x.UserId ));
userList = member_UserRepository.GetList(new RB_Member_User_Extend() { UserIds = uids, TenantId = dmodel.TenantId, MallBaseId = dmodel.MallBaseId });
}
foreach (var item in list)
{
item.CommentList = new List<RB_Goods_Comment_Extend>();
item.CommentList.AddRange(carCommentList.Where(x => x.OrderDetailId == item.OrderDetailId));
item.CommentList.AddRange(guideCommentList.Where(x => x.OrderDetailId == item.OrderDetailId));
foreach (var itemComment in item.CommentList)
{
itemComment.CommentImgList = new List<string>();
if (!string.IsNullOrEmpty(itemComment.CommentImage))
{
itemComment.CommentImgList = JsonConvert.DeserializeObject<List<string>>(itemComment.CommentImage);
}
if (item.UserId > 0)
{
itemComment.UserPhotoPath = userList.Where(x => x.Id == item.UserId).FirstOrDefault()?.Photo ?? "";
}
if (itemComment.UserId == 0 && itemComment.UserPhoto > 0)
{
itemComment.UserPhotoPath = material_InfoRepository.GetEntity(item.UserPhoto)?.Path ?? "";
}
}
}
}
return list;
}
/// <summary>
/// 获取商品评论统计
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public ApiResult GetGuideCarCommentStatistics(int goodsId, int tenantId, int mallBaseId)
{
var list = EnumHelper.GetEnumList(typeof(GoodsCommentTypeEnum));
var clist = goods_CommentRepository.GetGuideCarCommentStatistics(goodsId, tenantId, mallBaseId);
List<object> RList = new List<object>();
foreach (var item in list)
{
var cmodel = clist.Where(x => (int)x.CommentGrade == Convert.ToInt32(item.Value)).FirstOrDefault();
RList.Add(new
{
Id = Convert.ToInt32(item.Value),
Name = item.Key,
Count = cmodel?.CommentNum ?? 0
});
}
return ApiResult.Success("", new
{
TotalNum = clist.Sum(x => x.CommentNum),
List = RList
});
}
#endregion #endregion
} }
} }
...@@ -11070,6 +11070,77 @@ namespace Mall.Module.Product ...@@ -11070,6 +11070,77 @@ namespace Mall.Module.Product
return goods_CommentRepository.Update(keyValues, wheres); return goods_CommentRepository.Update(keyValues, wheres);
} }
/// <summary>
/// 批量操作
/// </summary>
/// <param name="commentIds"></param>
/// <param name="type"></param>
/// <param name="content"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public bool SetCommentBatchByOrderDetailId(string orderDetailIds, int type, string content, int tenantId, int mallBaseId)
{
//1批量回复 2批量隐藏 3批量显示 4批量置顶 5取消置顶 6批量删除
Dictionary<string, object> keyValues = new Dictionary<string, object>() { };
if (type == 1)
{ //回复
keyValues.Add(nameof(RB_Goods_Comment.Reply), content);
keyValues.Add(nameof(RB_Goods_Comment.UpdateDate), DateTime.Now);
}
else if (type == 2)
{ //影藏
keyValues.Add(nameof(RB_Goods_Comment.Is_Show), 2);
keyValues.Add(nameof(RB_Goods_Comment.UpdateDate), DateTime.Now);
}
else if (type == 3)
{
keyValues.Add(nameof(RB_Goods_Comment.Is_Show), 1);
keyValues.Add(nameof(RB_Goods_Comment.UpdateDate), DateTime.Now);
}
else if (type == 4)
{
keyValues.Add(nameof(RB_Goods_Comment.Is_Top), 1);
keyValues.Add(nameof(RB_Goods_Comment.UpdateDate), DateTime.Now);
}
else if (type == 5)
{
keyValues.Add(nameof(RB_Goods_Comment.Is_Top), 2);
keyValues.Add(nameof(RB_Goods_Comment.UpdateDate), DateTime.Now);
}
else if (type == 6)
{
keyValues.Add(nameof(RB_Goods_Comment.Status), 1);
keyValues.Add(nameof(RB_Goods_Comment.UpdateDate), DateTime.Now);
}
else
{
return false;
}
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods_Comment.OrderDetailId),
FiledValue=orderDetailIds,
OperatorEnum=OperatorEnum.IN
},
new WhereHelper(){
FiledName=nameof(RB_Goods_Comment.TenantId),
FiledValue=tenantId,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Goods_Comment.MallBaseId),
FiledValue=mallBaseId,
OperatorEnum=OperatorEnum.Equal
}
};
return goods_CommentRepository.Update(keyValues, wheres);
}
/// <summary> /// <summary>
/// 获取商品评论统计 /// 获取商品评论统计
/// </summary> /// </summary>
......
...@@ -91,11 +91,11 @@ where {where} order by c.Id desc"; ...@@ -91,11 +91,11 @@ where {where} order by c.Id desc";
{ {
where += $@" and c.{nameof(RB_Goods_Comment.CommentGrade)}={(int)dmodel.CommentGrade}"; where += $@" and c.{nameof(RB_Goods_Comment.CommentGrade)}={(int)dmodel.CommentGrade}";
} }
if (dmodel.GoodsId > 0) if (dmodel.GoodsId > 0)
{ {
where += $@" and c.{nameof(RB_Goods_Comment.GoodsId)}={dmodel.GoodsId}"; where += $@" and c.{nameof(RB_Goods_Comment.GoodsId)}={dmodel.GoodsId}";
} }
if (dmodel.UserId > 0) if (dmodel.UserId > 0)
{ {
where += $@" and c.{nameof(RB_Goods_Comment.UserId)}={dmodel.UserId}"; where += $@" and c.{nameof(RB_Goods_Comment.UserId)}={dmodel.UserId}";
} }
...@@ -103,7 +103,8 @@ where {where} order by c.Id desc"; ...@@ -103,7 +103,8 @@ where {where} order by c.Id desc";
{ {
where += $@" and c.{nameof(RB_Goods_Comment.PlatformSource)}={(int)dmodel.PlatformSource}"; where += $@" and c.{nameof(RB_Goods_Comment.PlatformSource)}={(int)dmodel.PlatformSource}";
} }
if (dmodel.Is_Show > 0) { if (dmodel.Is_Show > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.Is_Show)}={dmodel.Is_Show}"; where += $@" and c.{nameof(RB_Goods_Comment.Is_Show)}={dmodel.Is_Show}";
} }
if (!string.IsNullOrEmpty(dmodel.UserName)) if (!string.IsNullOrEmpty(dmodel.UserName))
...@@ -178,6 +179,168 @@ where {where} "; ...@@ -178,6 +179,168 @@ where {where} ";
return Get<RB_Goods_Comment_Extend>(sql).ToList(); return Get<RB_Goods_Comment_Extend>(sql).ToList();
} }
/// <summary>
/// 获取车辆评分信息
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<RB_Goods_Comment_Extend> GetCarCommentByOrderDetailId(string orderDetailIds, int tenantId, int mallBaseId)
{
string where = $" 1=1 and c.{nameof(RB_Goods_Comment.Status)}=0 and c.{nameof(RB_Goods_Comment.Is_Show)}=1 and c.{nameof(RB_Goods_Comment.CarId)}>0 ";
if (tenantId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.TenantId)}={tenantId}";
}
if (mallBaseId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.MallBaseId)}={mallBaseId}";
}
if (!string.IsNullOrWhiteSpace(orderDetailIds))
{
where += $@" and c.{nameof(RB_Goods_Comment.OrderDetailId)}in({orderDetailIds}) ";
}
string sql = $@"SELECT c.*,a.`Name` as CarName,d.ColorName as CarColorName,cb.`Name` as CarBrandName FROM RB_Goods_Comment c
LEFT JOIN rb_guidecar_car as a on c.CarId=a.ID
LEFT JOIN rb_goods as b on b.CarId=a.ID
LEFT JOIN rb_guidecar_carcolor as d on d.ID=b.CarColorId
LEFT JOIN rb_guidecar_carbrand as cb on cb.ID=a.CarBrandId where {where} ";
return Get<RB_Goods_Comment_Extend>(sql).ToList();
}
/// <summary>
/// 获取导游评分信息
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<RB_Goods_Comment_Extend> GetGuideCommentByOrderDetailId(string orderDetailIds, int tenantId, int mallBaseId)
{
string where = $" 1=1 and c.{nameof(RB_Goods_Comment.Status)}=0 and c.{nameof(RB_Goods_Comment.Is_Show)}=1 and c.{nameof(RB_Goods_Comment.GuideId)}>0 ";
if (tenantId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.TenantId)}={tenantId}";
}
if (mallBaseId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.MallBaseId)}={mallBaseId}";
}
if (!string.IsNullOrWhiteSpace(orderDetailIds))
{
where += $@" and c.{nameof(RB_Goods_Comment.OrderDetailId)}in({orderDetailIds}) ";
}
string sql = $@"SELECT c.*,a.`Name` as GuideName FROM RB_Goods_Comment c LEFT JOIN rb_guidecar_guide as a on c.GuideId=a.ID where {where} ";
return Get<RB_Goods_Comment_Extend>(sql).ToList();
}
/// <summary>
/// 小程序商品详情评论分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<GoodsComment_Extend> GetGoodsDetailPageList(int pageIndex, int pageSize, out long count, RB_Goods_Comment_Extend dmodel)
{
string where = $" 1=1 and {nameof(RB_Goods_Comment.Status)}=0 ";
string whereGrade = " where 1=1 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Goods_Comment.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Goods_Comment.MallBaseId)}={dmodel.MallBaseId}";
}
if (dmodel.GoodsId > 0)
{
where += $@" and {nameof(RB_Goods_Comment.GoodsId)}={dmodel.GoodsId}";
}
if (dmodel.UserId > 0)
{
where += $@" and {nameof(RB_Goods_Comment.UserId)}={dmodel.UserId}";
}
if (dmodel.PlatformSource > 0)
{
where += $@" and {nameof(RB_Goods_Comment.PlatformSource)}={(int)dmodel.PlatformSource}";
}
if (dmodel.Is_Show > 0)
{
where += $@" and {nameof(RB_Goods_Comment.Is_Show)}={dmodel.Is_Show}";
}
if (!string.IsNullOrEmpty(dmodel.UserName))
{
where += $@" and {nameof(RB_Goods_Comment.UserName)} like '%{dmodel.UserName}%'";
}
if (!string.IsNullOrEmpty(dmodel.Content))
{
where += $@" and {nameof(RB_Goods_Comment.Content)} like '%{dmodel.Content}%'";
}
if (dmodel.CommentGrade.HasValue)
{
if (dmodel.CommentGrade.Value == Common.Enum.Goods.GoodsCommentTypeEnum.Praise)
{
whereGrade += $@" and t.TotalScore>6";
}
else if (dmodel.CommentGrade.Value == Common.Enum.Goods.GoodsCommentTypeEnum.Medium)
{
whereGrade += $@" and t.TotalScore>3 and t.TotalScore<=6";
}
else
{
whereGrade += $@" and t.TotalScore>=1 and t.TotalScore<=3";
}
}
string sql = $@" SELECT * from(SELECT OrderDetailId,UserId,UserPhoto,Is_Anonymity,SUM(CommentScore) AS TotalScore,GoodsId,DATE_FORMAT(UpdateDate, '%y-%m-%d') AS UpdateDate ,
case
when SUM(CommentScore)<=3 then 3
when SUM(CommentScore)>3 and SUM(CommentScore)<=6 then 2
when SUM(CommentScore)>6 then 1
ELSE 0
end as CommentGrade
from rb_goods_comment where {where} GROUP BY OrderDetailId order by CreateDate ) as t {whereGrade}";
return GetPage<GoodsComment_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取评论数量统计
/// </summary>
/// <param name="goodsId"></param>
/// <param name="tenantId"></param>
/// <param name="mallBaseId"></param>
/// <returns></returns>
public List<RB_Goods_Comment_Extend> GetGuideCarCommentStatistics(int goodsId, int tenantId, int mallBaseId)
{
string where = $" 1=1 and c.{nameof(RB_Goods_Comment.Status)}=0 and c.{nameof(RB_Goods_Comment.Is_Show)}=1";
if (tenantId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.TenantId)}={tenantId}";
}
if (mallBaseId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.MallBaseId)}={mallBaseId}";
}
if (goodsId > 0)
{
where += $@" and c.{nameof(RB_Goods_Comment.GoodsId)}={goodsId}";
}
string sql = $@"SELECT CommentGrade,COUNT(0) as CommentNum from (SELECT OrderDetailId,SUM(CommentScore) as TotalScore,GoodsId ,
case
when SUM(CommentScore)<=3 then 3
when SUM(CommentScore)>3 and SUM(CommentScore)<=6 then 2
when SUM(CommentScore)>6 then 1
ELSE 0
end as CommentGrade
from rb_goods_comment as c where {where} GROUP BY OrderDetailId) as t GROUP BY t.CommentGrade";
return Get<RB_Goods_Comment_Extend>(sql).ToList();
}
} }
} }
...@@ -371,7 +371,7 @@ namespace Mall.WebApi.Controllers.Product ...@@ -371,7 +371,7 @@ namespace Mall.WebApi.Controllers.Product
#endregion #endregion
#region 订单信息 #region 订单信息
#endregion #endregion
...@@ -413,5 +413,67 @@ namespace Mall.WebApi.Controllers.Product ...@@ -413,5 +413,67 @@ namespace Mall.WebApi.Controllers.Product
} }
return ApiResult.Success("", oldLogisticsModel); return ApiResult.Success("", oldLogisticsModel);
} }
/// <summary>
/// 获取商品评论分页列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsCommentPageList(object requestMsg)
{
var parms = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(parms.msg.ToString());
RB_Goods_Comment_Extend demodel = JsonConvert.DeserializeObject<RB_Goods_Comment_Extend>(parms.msg.ToString());
demodel.TenantId = parms.TenantId;
demodel.MallBaseId = parms.MallBaseId;
demodel.Is_Show = 1;
var list = guideCarModule.GetGoodsDetailPageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.GoodsId,
x.UserId,
UserName = x.Is_Anonymity == 1 ? "匿名用户" : x.UserName,
UserPhotoPath = x.UserPhotoPath ?? "",
x.CommentGrade,
CommentGradeName = x.CommentGrade > 0 ? ((Common.Enum.Goods.GoodsCommentTypeEnum)x.CommentGrade).GetEnumName() : "",
CommentList = x.CommentList.Select(y => new
{
y.CommentScore,
y.CommentImgList,
y.Content,
y.Reply,
y.GuideName,
y.CarBrandName,
y.CarColorName,
y.CarName,
CreateDate = y.CreateDate.HasValue ? y.CreateDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : ""
})
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取商品评论统计
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetAppletGoodsCommentStatistics(object requestMsg)
{
var req = JsonConvert.DeserializeObject<RequestParm>(requestMsg.ToString());
JObject parms = JObject.Parse(req.msg.ToString());
int GoodsId = parms.GetInt("GoodsId", 0);
return guideCarModule.GetGuideCarCommentStatistics(GoodsId, req.TenantId, req.MallBaseId);
}
} }
} }
\ No newline at end of file
...@@ -1540,6 +1540,10 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -1540,6 +1540,10 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
return ApiResult.ParamIsNull("请输入评论时间"); return ApiResult.ParamIsNull("请输入评论时间");
} }
if ((demodel.OrderDetailId ?? 0) <= 0)
{
return ApiResult.ParamIsNull("请输入订单详情id");
}
if ((demodel.GoodsId ?? 0) <= 0) if ((demodel.GoodsId ?? 0) <= 0)
{ {
return ApiResult.ParamIsNull("请选择商品"); return ApiResult.ParamIsNull("请选择商品");
......
...@@ -3144,6 +3144,35 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -3144,6 +3144,35 @@ namespace Mall.WebApi.Controllers.MallBase
if (flag) { return ApiResult.Success(); } else { return ApiResult.Failed(); } if (flag) { return ApiResult.Success(); } else { return ApiResult.Failed(); }
} }
/// <summary>
/// 批量操作
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult SetCommentBatchByOrderDetailId()
{
var req = RequestParm;
JObject parms = JObject.Parse(req.msg.ToString());
string orderDetailIds = parms.GetStringValue("OrderDetailIds");
int Type = parms.GetInt("Type", 1);//1批量回复 2批量隐藏 3批量显示 4批量置顶 5取消置顶 6批量删除
string Content = parms.GetStringValue("Content");
if (string.IsNullOrEmpty(orderDetailIds))
{
return ApiResult.ParamIsNull();
}
if (Type == 1)
{
if (string.IsNullOrEmpty(Content))
{
return ApiResult.ParamIsNull("回复内容不能为空");
}
}
bool flag = orderModule.SetCommentBatchByOrderDetailId(orderDetailIds, Type, Content, req.TenantId, req.MallBaseId);
if (flag) { return ApiResult.Success(); } else { return ApiResult.Failed(); }
}
/// <summary> /// <summary>
/// 获取商品评价类型枚举 /// 获取商品评价类型枚举
/// </summary> /// </summary>
......
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