102 lines
3.7 KiB
C#
102 lines
3.7 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.TableDataManage.CustomerFollows;
|
|
using ARW.Service.Business.IBusinessService.TableDataManage.CustomerFollows;
|
|
using ARW.Model.Dto.Business.TableDataManage.CustomerFollows;
|
|
using ARW.Model.Models.Business.TableDataManage.CustomerFollows;
|
|
using ARW.Model.Vo.Business.TableDataManage.CustomerFollows;
|
|
using ARW.Model.Models.Business.Custom.Customers;
|
|
using ARW.Model.Models.Business.TableDataManage.TableDatas;
|
|
|
|
namespace ARW.Service.Business.BusinessService.TableDataManage.CustomerFollows
|
|
{
|
|
/// <summary>
|
|
/// 客户关注接口实现类
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-11-24
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(ICustomerFollowService), ServiceLifetime = LifeTime.Transient)]
|
|
public class CustomerFollowServiceImpl : BaseService<CustomerFollow>, ICustomerFollowService
|
|
{
|
|
private readonly CustomerFollowRepository _CustomerFollowRepository;
|
|
|
|
public CustomerFollowServiceImpl(CustomerFollowRepository CustomerFollowRepository)
|
|
{
|
|
this._CustomerFollowRepository = CustomerFollowRepository;
|
|
}
|
|
|
|
#region 业务逻辑代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询客户关注分页列表
|
|
/// </summary>
|
|
public async Task<PagedInfo<CustomerFollowVo>> GetCustomerFollowList(CustomerFollowQueryDto parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<CustomerFollow>();
|
|
|
|
var query = _CustomerFollowRepository
|
|
.Queryable()
|
|
.LeftJoin<Customer>((s, c) => s.CustomerGuid == c.CustomerGuid)
|
|
.LeftJoin<TableData>((s, c, d) => s.TableDataGuid == d.TableDataGuid)
|
|
.Where(predicate.ToExpression())
|
|
.WhereIF(!string.IsNullOrEmpty(parm.CustomerName), (s, c, d) => c.CustomerNickname.Contains(parm.CustomerName))
|
|
.WhereIF(!string.IsNullOrEmpty(parm.CustomerName), (s, c, d) => c.CustomerMobilePhoneNumber.Contains(parm.CustomerPhone))
|
|
.WhereIF(!string.IsNullOrEmpty(parm.TableDataProcurementContent), (s, c, d) => d.TableDataProcurementContent.Contains(parm.TableDataProcurementContent))
|
|
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
|
.Select((s, c, d) => new CustomerFollowVo
|
|
{
|
|
CustomerFollowId = s.CustomerFollowId,
|
|
CustomerFollowGuid = s.CustomerFollowGuid,
|
|
CustomerGuid = s.CustomerGuid,
|
|
TableDataGuid = s.TableDataGuid,
|
|
CustomerName = c.CustomerNickname,
|
|
CustomerPhone = c.CustomerMobilePhoneNumber,
|
|
TableDataName = d.TableDataProcurementContent
|
|
});
|
|
|
|
|
|
return await query.ToPageAsync(parm);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加或修改客户关注
|
|
/// </summary>
|
|
public async Task<string> AddOrUpdateCustomerFollow(CustomerFollow model)
|
|
{
|
|
if (model.CustomerFollowId != 0)
|
|
{
|
|
var response = await _CustomerFollowRepository.UpdateAsync(model);
|
|
return "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
|
|
var response = await _CustomerFollowRepository.InsertReturnSnowflakeIdAsync(model);
|
|
return "添加成功!";
|
|
}
|
|
}
|
|
|
|
#region Excel处理
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|