145 lines
5.6 KiB
C#
145 lines
5.6 KiB
C#
using Infrastructure.Attribute;
|
|
using Microsoft.AspNetCore.Http;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Infrastructure;
|
|
using ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.GoodsManager.GoodsComments;
|
|
using ARW.Service.Business.IBusinessService.GoodsManager.GoodsComments;
|
|
using ARW.Model.Dto.Business.GoodsManager.GoodsComments;
|
|
using ARW.Model.Models.Business.GoodsManager.GoodsComments;
|
|
using ARW.Model.Vo.Business.GoodsManager.GoodsComments;
|
|
using ARW.Model.Models.Business.ShopManager.Shops;
|
|
using ARW.Model.Models.Business.GoodsManager.Goodss;
|
|
using ARW.Model.Models.Business.Custom.Customers;
|
|
|
|
namespace ARW.Service.Business.BusinessService.GoodsManager.GoodsComments
|
|
{
|
|
/// <summary>
|
|
/// 商品评价接口实现类
|
|
///
|
|
/// @author admin
|
|
/// @date 2023-07-15
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IGoodsCommentService), ServiceLifetime = LifeTime.Transient)]
|
|
public class GoodsCommentServiceImpl : BaseService<GoodsComment>, IGoodsCommentService
|
|
{
|
|
private readonly GoodsCommentRepository _GoodsCommentRepository;
|
|
|
|
public GoodsCommentServiceImpl(GoodsCommentRepository GoodsCommentRepository)
|
|
{
|
|
this._GoodsCommentRepository = GoodsCommentRepository;
|
|
}
|
|
|
|
#region 业务逻辑代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询商品评价分页列表
|
|
/// </summary>
|
|
public async Task<PagedInfo<GoodsCommentVo>> GetGoodsCommentList(GoodsCommentQueryDto parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<GoodsComment>();
|
|
|
|
predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == parm.ShopGuid);
|
|
predicate = predicate.AndIF(parm.GoodsCommentRecoverStatus != null, s => s.GoodsCommentRecoverStatus == parm.GoodsCommentRecoverStatus);
|
|
predicate = predicate.AndIF(parm.GoodsCommentRatingType != null, s => s.GoodsCommentRatingType == parm.GoodsCommentRatingType);
|
|
predicate = predicate.AndIF(parm.GoodsCommentStatus != null, s => s.GoodsCommentStatus == parm.GoodsCommentStatus);
|
|
var query = _GoodsCommentRepository
|
|
.Queryable()
|
|
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
|
|
.LeftJoin<Goods>((s, c, d) => s.GoodsGuid == d.GoodsGuid)
|
|
.LeftJoin<Customer>((s, c, d, f) => s.CustomerGuid == f.CustomerGuid)
|
|
.WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s, c, d, f) => c.ShopName.Contains(parm.ShopName))
|
|
.WhereIF(!string.IsNullOrEmpty(parm.GoodsName), (s, c, d, f) => d.GoodsName.Contains(parm.GoodsName))
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.GoodsCommentSort, OrderByType.Asc)
|
|
.Select((s, c, d, f) => new GoodsCommentVo
|
|
{
|
|
GoodsCommentId = s.GoodsCommentId,
|
|
GoodsCommentGuid = s.GoodsCommentGuid,
|
|
ShopGuid = s.ShopGuid,
|
|
ShopName = c.ShopName,
|
|
CustomerGuid = s.CustomerGuid,
|
|
CustomerNickname = f.CustomerNickname,
|
|
OrderGuid = s.OrderGuid,
|
|
GoodsGuid = s.GoodsGuid,
|
|
GoodsName = d.GoodsName,
|
|
GoodsPicture = d.GoodsPicture,
|
|
OrderGoodsGuid = s.OrderGoodsGuid,
|
|
GoodsCommentRating = s.GoodsCommentRating,
|
|
GoodsCommentRatingType = s.GoodsCommentRatingType,
|
|
GoodsCommentContent = s.GoodsCommentContent,
|
|
GoodsCommentImages = s.GoodsCommentImages,
|
|
GoodsCommentRecoverStatus = s.GoodsCommentRecoverStatus,
|
|
GoodsCommentRecoverContent = s.GoodsCommentRecoverContent,
|
|
GoodsCommentStatus = s.GoodsCommentStatus,
|
|
GoodsCommentSort = s.GoodsCommentSort,
|
|
});
|
|
|
|
|
|
return await query.ToPageAsync(parm);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加或修改商品评价
|
|
/// </summary>
|
|
public async Task<string> AddOrUpdateGoodsComment(GoodsComment model)
|
|
{
|
|
if (model.GoodsCommentRating < 3)
|
|
{
|
|
model.GoodsCommentRatingType = 3;
|
|
}
|
|
if (model.GoodsCommentRating < 3.5 && model.GoodsCommentRating >= 2.5)
|
|
{
|
|
model.GoodsCommentRatingType = 2;
|
|
}
|
|
if (model.GoodsCommentRating >= 3.5)
|
|
{
|
|
model.GoodsCommentRatingType = 1;
|
|
}
|
|
|
|
if (model.GoodsCommentId != 0)
|
|
{
|
|
var response = await _GoodsCommentRepository.UpdateAsync(model);
|
|
return "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
model.GoodsCommentRecoverStatus = 1;
|
|
var response = await _GoodsCommentRepository.InsertReturnSnowflakeIdAsync(model);
|
|
return "添加成功!";
|
|
}
|
|
}
|
|
|
|
#region Excel处理
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
/// <summary>
|
|
/// 回复
|
|
/// </summary>
|
|
public async Task<string> Recover(GoodsCommentRecoverDto parm)
|
|
{
|
|
var response = await _GoodsCommentRepository.UpdateAsync(f => new GoodsComment
|
|
{
|
|
GoodsCommentRecoverContent = parm.GoodsCommentRecoverContent,
|
|
GoodsCommentRecoverStatus = 2
|
|
}, s => s.GoodsCommentId == parm.GoodsCommentId);
|
|
if (response) return "回复成功";
|
|
else return "回复失败";
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|