111 lines
4.5 KiB
C#
111 lines
4.5 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 ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.Custom.CustomerAddresses;
|
|
using ARW.Service.Api.IBusinessService.Custom.CustomerAddresses;
|
|
using ARW.Model.Dto.Api.Custom.CustomerAddresses;
|
|
using ARW.Model.Models.Business.Custom.CustomerAddresses;
|
|
using ARW.Model.Vo.Api.Custom.CustomerAddresses;
|
|
using ARW.Model.Models.Business.Custom.Regions;
|
|
using ARW.Model.Models.Business.Custom.Customers;
|
|
using Microsoft.AspNetCore.Server.IISIntegration;
|
|
|
|
namespace ARW.Service.Api.BusinessService.Custom.CustomerAddresses
|
|
{
|
|
/// <summary>
|
|
/// 客户收货地址接口实现类Api
|
|
///
|
|
/// @author admin
|
|
/// @date 2023-06-09
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(ICustomerAddressServiceApi), ServiceLifetime = LifeTime.Transient)]
|
|
public class CustomerAddressServiceImplApi : BaseService<CustomerAddress>, ICustomerAddressServiceApi
|
|
{
|
|
private readonly CustomerAddressRepository _CustomerAddressRepository;
|
|
|
|
public CustomerAddressServiceImplApi(CustomerAddressRepository CustomerAddressRepository)
|
|
{
|
|
this._CustomerAddressRepository = CustomerAddressRepository;
|
|
}
|
|
|
|
#region Api接口代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询客户收货地址列表(Api)
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<CustomerAddressVoApi>> GetCustomerAddressListApi(CustomerAddressQueryDtoApi parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<CustomerAddress>();
|
|
|
|
var query = _CustomerAddressRepository
|
|
.Queryable()
|
|
.LeftJoin<Region>((s, c) => s.CustomerAddressProvinceId == c.RegionId)
|
|
.LeftJoin<Region>((s, c, d) => s.CustomerAddressCityId == d.RegionId)
|
|
.LeftJoin<Region>((s, c, d, f) => s.CustomerAddressAreaId == f.RegionId)
|
|
.LeftJoin<Customer>((s, c, d, f, g) => s.CustomerAddressCustomerGuid == g.CustomerGuid)
|
|
.Where((s) => s.CustomerAddressCustomerGuid == parm.CustomerAddressCustomerGuid)
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.Create_time, OrderByType.Asc)
|
|
.Select((s, c, d, f, g) => new CustomerAddressVoApi
|
|
{
|
|
CustomerAddressId = s.CustomerAddressId,
|
|
CustomerAddressGuid = s.CustomerAddressGuid,
|
|
Name = s.CustomerAddressName,
|
|
PhoneNumber = s.CustomerAddressPhone,
|
|
Address = c.RegionName + d.RegionName + f.RegionName + s.CustomerAddressDetailed,
|
|
IsDefault = s.CustomerAddressGuid == g.CustomerDefaultAddressGuid
|
|
});
|
|
|
|
|
|
return await query.ToListAsync();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询客户收货地址详情(Api)
|
|
/// </summary>
|
|
/// <param name="parm"></param>
|
|
/// <returns></returns>
|
|
public Task<string> GetCustomerAddressDetails(CustomerAddressDtoApi parm)
|
|
{
|
|
|
|
var query = _CustomerAddressRepository
|
|
.Queryable()
|
|
.LeftJoin<Region>((s, c) => s.CustomerAddressProvinceId == c.RegionPid)
|
|
.LeftJoin<Region>((s, c, d) => s.CustomerAddressCityId == d.RegionPid)
|
|
.LeftJoin<Region>((s, c, d, f) => s.CustomerAddressAreaId == f.RegionPid)
|
|
.LeftJoin<Customer>((s, c, d, f, g) => s.CustomerAddressCustomerGuid == g.CustomerGuid)
|
|
.Where(s => s.CustomerAddressGuid == parm.CustomerAddressGuid)
|
|
.Select(s => new CustomerAddressApiDetailsVo
|
|
{
|
|
CustomerAddressId = s.CustomerAddressId,
|
|
CustomerAddressGuid = s.CustomerAddressGuid,
|
|
CustomerAddressCustomerGuid = s.CustomerAddressCustomerGuid,
|
|
CustomerAddressProvinceId = s.CustomerAddressProvinceId,
|
|
CustomerAddressCityId = s.CustomerAddressCityId,
|
|
CustomerAddressAreaId = s.CustomerAddressAreaId,
|
|
CustomerAddressName = s.CustomerAddressName,
|
|
CustomerAddressPhone = s.CustomerAddressPhone,
|
|
CustomerAddressDetailed = s.CustomerAddressDetailed,
|
|
}).Take(1);
|
|
|
|
|
|
return query.ToJsonAsync();
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|