Commit 1208acac authored by liudong1993's avatar liudong1993

课程评论调整

parent c48d2e31
......@@ -24,15 +24,15 @@ namespace Mall.Education
//ServiceBase.Run(ServicesToRun);
Console.WriteLine("进来了");
string FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx";
string[] patharr = FilePath.Split('/');
string kjkj = "";
for (var i = 3; i < patharr.Length - 1; i++)
{
kjkj += patharr[i] + "/";
}
Console.WriteLine("2:" + kjkj);
//string FilePath = "https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/Test/Upload/Education/wkxq.docx";
//string[] patharr = FilePath.Split('/');
//string kjkj = "";
//for (var i = 3; i < patharr.Length - 1; i++)
//{
// kjkj += patharr[i] + "/";
//}
//Console.WriteLine("2:" + kjkj);
......
......@@ -12138,6 +12138,34 @@ namespace Mall.Module.Product
}
};
goods_OrderDetailRepository.Update(keyValues, wheres);
#region 更新课程评分
var goodsModel = goodsRepository.GetEntity(demodel.GoodsId ?? 0);
if (goodsModel != null && goodsModel.GoodsClassify == 2)
{
var gcsModel = goods_CommentRepository.GetGoodsCommentScore(demodel.GoodsId ?? 0);
if (gcsModel != null)
{
decimal score = 0;
if (gcsModel.CommentNum > 0)
{
score = Math.Round(Convert.ToDecimal(gcsModel.CommentScore ?? 0) / gcsModel.CommentNum, 2, MidpointRounding.AwayFromZero);
}
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Goods.CourseScore),score}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Goods.Id),
FiledValue=demodel.GoodsId,
OperatorEnum=OperatorEnum.Equal
}
};
goodsRepository.Update(keyValues1, wheres1);
}
}
#endregion
if (OrderId < 0)
{
var dlist = goods_OrderDetailRepository.GetOrderDetailList(new RB_Goods_OrderDetail_Extend() { OrderId = OrderId, IsComment = 2, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
......
......@@ -342,6 +342,16 @@ from rb_goods_comment as c where {where} GROUP BY OrderDetailId) as t GROUP BY t
return Get<RB_Goods_Comment_Extend>(sql).ToList();
}
/// <summary>
/// 获取商品评分
/// </summary>
/// <param name="goodsId"></param>
/// <returns></returns>
public RB_Goods_Comment_Extend GetGoodsCommentScore(int goodsId) {
string sql = $@"SELECT SUM(CommentScore) AS CommentScore, COUNT(0) AS CommentNum FROM rb_goods_comment WHERE Status =0 and GoodsId = {goodsId}";
return Get<RB_Goods_Comment_Extend>(sql).FirstOrDefault();
}
}
}
......@@ -616,6 +616,7 @@ namespace Mall.WebApi.Controllers.Education
demodel.IntegralComment ??= 0;//评论反积分
demodel.IntegralCommentType ??= 1;
demodel.GoodsPageType ??= GoodsPageTypeEnum.All;
demodel.CourseScore ??= 0;
bool flag = educationModule.SetProductGoodsInfo(demodel);
if (flag)
......
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