Commit dff7b061 authored by 吴春's avatar 吴春

提交代码

parent 25af830c
......@@ -1645,7 +1645,7 @@ namespace Mall.Module.Product
string SiteName = SiteRepository.GetGuideCarSiteList(new RB_GuideCar_Site_Extend() { ID = model.SiteId ?? 0 }).FirstOrDefault()?.SiteName ?? "";
var guideModel = GuideRepository.GetGuideCarGuideList(new RB_GuideCar_Guide_Extend() { ID = model.GuideId ?? 0 }).FirstOrDefault();
model.GuideName = guideModel?.Name ?? "";
model.GuidePhoto= guideModel?.GuidePhoto ?? "";
model.GuidePhoto = guideModel?.GuidePhoto ?? "";
model.GuideScore = guideModel?.Score ?? 5;
model.Introduction = guideModel?.Introduction ?? "";
model.GuideWorkYears = guideModel?.WorkYears ?? 1;
......@@ -2321,7 +2321,7 @@ namespace Mall.Module.Product
date_enable = false;
}
var targetModel = targetList.FirstOrDefault();
if (targetModel.ReserveNum + (item.Number ?? 0) > (gmodel.RideNum ?? 0))
if (targetModel.ReserveNum + (item.Number ?? 0) > (gmodel.RideNum ?? 0))
{
date_enable = false;
}
......@@ -3538,6 +3538,88 @@ namespace Mall.Module.Product
return flag;
}
/// <summary>
/// 管理新增评论
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public bool SetGoodsCommentInfo_V2(List<RB_Goods_Comment_Extend> list)
{
RB_Goods_OrderDetail dmodel = new RB_Goods_OrderDetail();
dmodel.CarId = list.Where(x => x.CarId > 0).FirstOrDefault()?.CarId;
dmodel.GuideId = list.Where(x => x.GuideId > 0).FirstOrDefault()?.GuideId;
dmodel.TenantId = list.FirstOrDefault()?.TenantId ?? 0;
dmodel.MallBaseId = list.FirstOrDefault()?.MallBaseId ?? 0;
bool flag = goods_CommentRepository.InsertBatch(list);
if (flag)
{
if (list.FirstOrDefault().OrderDetailId > 0)
{
//更新订单对应对应的车辆和导游评分
//先查找已评论的车辆信息
if (dmodel.CarId.HasValue && dmodel.CarId.Value > 0)
{
var carScoreList = goods_CommentRepository.GetAppletGoodsCommentscore(dmodel.CarId.Value, 0, dmodel.TenantId, dmodel.MallBaseId);
decimal carScore = 0;
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);
}
else
{
carScore = Convert.ToDecimal(list.Where(x => x.CarId == dmodel.CarId).FirstOrDefault().CommentScore);
}
if (carScore > 0)//更新车辆的评分
{
//更新订单商品为已评价
Dictionary<string, object> keyValuesCar = new Dictionary<string, object>() {
{ nameof(RB_GuideCar_Car.Score),Math.Round(carScore,1, MidpointRounding.AwayFromZero)}
};
List<WhereHelper> wheresCar = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_GuideCar_Car.ID),
FiledValue=dmodel.CarId,
OperatorEnum=OperatorEnum.Equal
}
};
GuideCarRepository.Update(keyValuesCar, wheresCar);
}
}
if (dmodel.GuideId.HasValue && dmodel.GuideId.Value > 0)
{
decimal guidScore = 0;
var guideScoreList = goods_CommentRepository.GetAppletGoodsCommentscore(0, dmodel.GuideId.Value, dmodel.TenantId, dmodel.MallBaseId);
if (guideScoreList != null && guideScoreList.Any())
{
guidScore = (guideScoreList.FirstOrDefault().TotalScore + (Convert.ToDecimal(list.Where(x => x.GuideId == dmodel.GuideId).FirstOrDefault().CommentScore ?? 0))) / (guideScoreList.FirstOrDefault().CommentNum + 1);
}
else
{
guidScore = Convert.ToDecimal(list.Where(x => x.GuideId == dmodel.GuideId).FirstOrDefault().CommentScore);
}
if (guidScore > 0)//更新车辆的评分
{
//更新订单商品为已评价
Dictionary<string, object> keyValuesCar = new Dictionary<string, object>() {
{ nameof(RB_GuideCar_Guide.Score),Math.Round(guidScore,1, MidpointRounding.AwayFromZero)}
};
List<WhereHelper> wheresCar = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_GuideCar_Guide.ID),
FiledValue=dmodel.GuideId,
OperatorEnum=OperatorEnum.Equal
}
};
GuideRepository.Update(keyValuesCar, wheresCar);
}
}
}
}
return flag;
}
/// <summary>
/// 小程序我的订单列表
/// </summary>
......@@ -3738,7 +3820,7 @@ namespace Mall.Module.Product
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 ));
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)
......@@ -3771,7 +3853,7 @@ namespace Mall.Module.Product
}
/// <summary>
/// 获取商品评论统计
......
......@@ -1614,16 +1614,21 @@ namespace Mall.WebApi.Controllers.MallBase
{
return ApiResult.ParamIsNull("请输入评价内容");
}
if (!demodel.CommentGrade.HasValue)
{
return ApiResult.ParamIsNull("请选择评分");
}
demodel.CommentScore ??= 5;
demodel.CommentImage = "";
if (demodel.CommentImgList != null && demodel.CommentImgList.Any())
{
demodel.CommentImage = JsonConvert.SerializeObject(demodel.CommentImgList);
}
demodel.CommentGrade ??= Common.Enum.Goods.GoodsCommentTypeEnum.Praise;
demodel.CommentScore ??= 5;
if (demodel.CommentScore == 3 || demodel.CommentScore == 2)
{
demodel.CommentGrade = Common.Enum.Goods.GoodsCommentTypeEnum.Medium;
}
else if (demodel.CommentScore == 1)
{
demodel.CommentGrade = Common.Enum.Goods.GoodsCommentTypeEnum.Negative;
}
demodel.UserPhoto ??= 0;
demodel.Is_Top ??= 2;
demodel.Is_Show ??= 1;
......@@ -1634,11 +1639,10 @@ namespace Mall.WebApi.Controllers.MallBase
demodel.MallBaseId = req.MallBaseId;
demodel.Status = 0;
demodel.UpdateDate = DateTime.Now;
demodel.CreateDate = DateTime.Now;
}
bool flag = guideCarModule.SetGoodsCommentInfo(list);
bool flag = guideCarModule.SetGoodsCommentInfo_V2(list);
if (flag) { return ApiResult.Success(); } else { return ApiResult.Failed(); }
}
#endregion
......
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