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.Custom.CustomerAddresses; using ARW.Service.Business.IBusinessService.Custom.CustomerAddresses; using ARW.Model.Dto.Business.Custom.CustomerAddresses; using ARW.Model.Vo.Business.Custom.CustomerAddresses; using ARW.Model.Models.Business.Custom.CustomerAddresses; using ARW.Model.Models.Business.Custom.Regions; using ARW.Model.Models.Business.Custom.Customers; using ARW.Repository.Business.Custom.Customers; namespace ARW.Service.Business.BusinessService.Custom.CustomerAddresses { /// /// 客户收货地址接口实现类 /// /// @author admin /// @date 2023-06-05 /// [AppService(ServiceType = typeof(ICustomerAddressService), ServiceLifetime = LifeTime.Transient)] public class CustomerAddressServiceImpl : BaseService, ICustomerAddressService { private readonly CustomerAddressRepository _CustomerAddressRepository; private readonly CustomerRepository _CustomerRepository; public CustomerAddressServiceImpl(CustomerAddressRepository CustomerAddressRepository, CustomerRepository customerRepository) { this._CustomerAddressRepository = CustomerAddressRepository; _CustomerRepository = customerRepository; } #region 业务逻辑代码 /// /// 查询客户收货地址分页列表 /// public async Task> GetCustomerAddressList(CustomerAddressQueryDto parm) { //开始拼装查询条件d var predicate = Expressionable.Create(); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerAddressName), s => s.CustomerAddressName.Contains(parm.CustomerAddressName)); predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerAddressPhone), s => s.CustomerAddressPhone.Contains(parm.CustomerAddressPhone)); var query = _CustomerAddressRepository .Queryable() .LeftJoin((s, c) => s.CustomerAddressCustomerGuid == c.CustomerGuid) .LeftJoin((s, c, d) => s.CustomerAddressProvinceId == d.RegionId) .LeftJoin((s, c, d, f) => s.CustomerAddressCityId == f.RegionId) .LeftJoin((s, c, d, f, g) => s.CustomerAddressAreaId == g.RegionId) .Where(predicate.ToExpression()) .OrderBy(s => s.Create_time, OrderByType.Desc) .Select((s, c, d, f, g) => new CustomerAddressVo { CustomerName = c.CustomerNickname, CustomerAddress = d.RegionName + "/" + f.RegionName + "/" + g.RegionName, 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, }); return await query.ToPageAsync(parm); } /// /// 添加或修改客户收货地址 /// public async Task AddOrUpdateCustomerAddress(CustomerAddress model) { if (model.CustomerAddressId != 0) { var response = await _CustomerAddressRepository.UpdateAsync(model); return "修改成功!"; } else { var response = await _CustomerAddressRepository.InsertReturnSnowflakeIdAsync(model); return "添加成功!"; } } #region Excel处理 /// /// Excel数据导出处理 /// public async Task> HandleExportData(List data) { return data; } #endregion #endregion } }