feat 先提交部分
This commit is contained in:
parent
5c3b221287
commit
22d1485e3b
@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.Custom.CustomerAddresses;
|
||||
|
||||
namespace ARW.Model.Dto.Api.Custom.CustomerAddresses
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 客户收货地址查询对象Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public class CustomerAddressQueryDtoApi : PagerInfo
|
||||
{
|
||||
public long CustomerAddressCustomerGuid { get; set; }
|
||||
public string CustomerAddressName { get; set; }
|
||||
public string CustomerAddressPhone { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 客户收货地址详情输入对象Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public class CustomerAddressDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "CustomerAddressGuid不能为空")]
|
||||
public long CustomerAddressGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
33
ARW.Model/Dto/Api/Custom/Regions/RegionApiDto.cs
Normal file
33
ARW.Model/Dto/Api/Custom/Regions/RegionApiDto.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
|
||||
namespace ARW.Model.Dto.Api.Custom.Regions
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 省市区数据表查询对象Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public class RegionQueryDtoApi : PagerInfo
|
||||
{
|
||||
public string RegionName { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 省市区数据表详情输入对象Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public class RegionDtoApi
|
||||
{
|
||||
[Required(ErrorMessage = "RegionGuid不能为空")]
|
||||
public long RegionGuid { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ARW.Model.Vo.Api.Custom.CustomerAddresses
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户收货地址展示对象Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public class CustomerAddressVoApi
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 : id
|
||||
/// </summary>
|
||||
public int CustomerAddressId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 : guid
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long CustomerAddressGuid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :收货人名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :收货电话
|
||||
/// </summary>
|
||||
public string PhoneNumber { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :详细地址
|
||||
/// </summary>
|
||||
public string Address { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 描述 : 是否为默认地址
|
||||
/// </summary>
|
||||
public bool IsDefault { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 客户收货地址详情展示对象Api
|
||||
/// </summary>
|
||||
public class CustomerAddressApiDetailsVo
|
||||
{
|
||||
[EpplusIgnore]
|
||||
public int CustomerAddressId { get; set; }
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusIgnore]
|
||||
public long CustomerAddressGuid { get; set; }
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[EpplusTableColumn(Header = "客户guid")]
|
||||
public long CustomerAddressCustomerGuid { get; set; }
|
||||
[EpplusTableColumn(Header = "省id")]
|
||||
public int CustomerAddressProvinceId { get; set; }
|
||||
[EpplusTableColumn(Header = "市id")]
|
||||
public int CustomerAddressCityId { get; set; }
|
||||
[EpplusTableColumn(Header = "区id")]
|
||||
public int CustomerAddressAreaId { get; set; }
|
||||
[EpplusTableColumn(Header = "收货人名称")]
|
||||
public string CustomerAddressName { get; set; }
|
||||
[EpplusTableColumn(Header = "收货电话")]
|
||||
public string CustomerAddressPhone { get; set; }
|
||||
[EpplusTableColumn(Header = "详细地址")]
|
||||
public string CustomerAddressDetailed { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
85
ARW.Model/Vo/Api/Custom/Regions/RegionApiVo.cs
Normal file
85
ARW.Model/Vo/Api/Custom/Regions/RegionApiVo.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using Newtonsoft.Json;
|
||||
using OfficeOpenXml.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ARW.Model.Vo.Api.Custom.Regions
|
||||
{
|
||||
/// <summary>
|
||||
/// 省市区数据表展示对象Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public class RegionVoApi
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :区划信息ID
|
||||
/// </summary>
|
||||
[EpplusIgnore]
|
||||
public int RegionId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :区划名称
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "区划名称")]
|
||||
public string RegionName { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :父级ID
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "父级ID")]
|
||||
public int RegionPid { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :区划编码
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "区划编码")]
|
||||
public string RegionCode { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 描述 :层级(1省级 2市级 3区/县级)
|
||||
/// </summary>
|
||||
[EpplusTableColumn(Header = "层级(1省级 2市级 3区/县级)")]
|
||||
public int RegionLevel { get; set; }
|
||||
|
||||
public string ParentName { get; set; }
|
||||
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<RegionVoApi> Children { get; set; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 省市区数据表详情展示对象Api
|
||||
/// </summary>
|
||||
public class RegionApiDetailsVo
|
||||
{
|
||||
[EpplusIgnore]
|
||||
public int RegionId { get; set; }
|
||||
[EpplusTableColumn(Header = "区划名称")]
|
||||
public string RegionName { get; set; }
|
||||
[EpplusTableColumn(Header = "父级ID")]
|
||||
public int RegionPid { get; set; }
|
||||
[EpplusTableColumn(Header = "区划编码")]
|
||||
public string RegionCode { get; set; }
|
||||
[EpplusTableColumn(Header = "层级(1省级 2市级 3区/县级)")]
|
||||
public int RegionLevel { get; set; }
|
||||
|
||||
public string ParentName { get; set; }
|
||||
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<RegionVoApi> Children { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.Custom.Customers;
|
||||
|
||||
namespace ARW.Repository.Business.Custom.Customers
|
||||
{
|
||||
/// <summary>
|
||||
/// 小程序客户仓储
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-05
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class CustomerRepository : BaseRepository<Customer>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
20
ARW.Repository/Business/Custom/Regions/RegionRepository.cs
Normal file
20
ARW.Repository/Business/Custom/Regions/RegionRepository.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Infrastructure.Attribute;
|
||||
using ARW.Repository.System;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
|
||||
namespace ARW.Repository.Business.Custom.Regions
|
||||
{
|
||||
/// <summary>
|
||||
/// 省市区数据表仓储
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
[AppService(ServiceLifetime = LifeTime.Transient)]
|
||||
public class RegionRepository : BaseRepository<Region>
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
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
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
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.Regions;
|
||||
using ARW.Service.Api.IBusinessService.Custom.Regions;
|
||||
using ARW.Model.Dto.Api.Custom.Regions;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
using ARW.Model.Vo.Api.Custom.Regions;
|
||||
|
||||
namespace ARW.Service.Api.BusinessService.Custom.Regions
|
||||
{
|
||||
/// <summary>
|
||||
/// 省市区数据表接口实现类Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IRegionServiceApi), ServiceLifetime = LifeTime.Transient)]
|
||||
public class RegionServiceImplApi : BaseService<Region>, IRegionServiceApi
|
||||
{
|
||||
private readonly RegionRepository _RegionRepository;
|
||||
|
||||
public RegionServiceImplApi(RegionRepository RegionRepository)
|
||||
{
|
||||
this._RegionRepository = RegionRepository;
|
||||
}
|
||||
|
||||
#region Api接口代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询省市区数据表树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<RegionVoApi>> GetRegionTreeListApi(RegionQueryDtoApi parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Region>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.RegionName), it => it.RegionName.Contains(parm.RegionName));
|
||||
var query = _RegionRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.LeftJoin<Region>((s, c) => s.RegionPid == c.RegionGuid)
|
||||
.OrderBy(s => s.RegionId,OrderByType.Asc)
|
||||
.Select((s,c) => new RegionVoApi
|
||||
{
|
||||
RegionId = s.RegionId,
|
||||
RegionName = s.RegionName,
|
||||
RegionPid = s.RegionPid,
|
||||
RegionCode = s.RegionCode,
|
||||
RegionLevel = s.RegionLevel,
|
||||
ParentName = c.RegionName,
|
||||
});
|
||||
|
||||
return await query.ToTreeAsync(it => it.Children, it => it.RegionPid, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询省市区数据表详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public Task<string> GetRegionDetails(RegionDtoApi parm)
|
||||
{
|
||||
|
||||
var query = _RegionRepository
|
||||
.Queryable()
|
||||
.Where(s => s.RegionGuid == parm.RegionGuid)
|
||||
.Select(s => new RegionApiDetailsVo
|
||||
{
|
||||
RegionId = s.RegionId,
|
||||
RegionName = s.RegionName,
|
||||
RegionPid = s.RegionPid,
|
||||
RegionCode = s.RegionCode,
|
||||
RegionLevel = s.RegionLevel,
|
||||
}).Take(1);
|
||||
|
||||
|
||||
return query.ToJsonAsync();
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Api.Custom.CustomerAddresses;
|
||||
using ARW.Model.Models.Business.Custom.CustomerAddresses;
|
||||
using ARW.Model.Vo.Api.Custom.CustomerAddresses;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.Custom.CustomerAddresses
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户收货地址接口类Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public interface ICustomerAddressServiceApi : IBaseService<CustomerAddress>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取客户收货地址分页列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<CustomerAddressVoApi>> GetCustomerAddressListApi(CustomerAddressQueryDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取客户收货地址详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetCustomerAddressDetails(CustomerAddressDtoApi parm);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Api.Custom.Regions;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
using ARW.Model.Vo.Api.Custom.Regions;
|
||||
|
||||
namespace ARW.Service.Api.IBusinessService.Custom.Regions
|
||||
{
|
||||
/// <summary>
|
||||
/// 省市区数据表接口类Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
public interface IRegionServiceApi : IBaseService<Region>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取省市区数据表树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<RegionVoApi>> GetRegionTreeListApi(RegionQueryDtoApi parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取省市区数据表详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> GetRegionDetails(RegionDtoApi parm);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
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.Model.Dto.Business.Custom.Customers;
|
||||
using ARW.Model.Models.Business.Custom.Customers;
|
||||
using ARW.Model.Vo.Business.Custom.Customers;
|
||||
using ARW.Repository.Business.Custom.Customers;
|
||||
using ARW.Service.Business.IBusinessService.Custom.Customers;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.Custom.Customers
|
||||
{
|
||||
/// <summary>
|
||||
/// 小程序客户接口实现类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-05
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ICustomerService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class CustomerServiceImpl : BaseService<Customer>, ICustomerService
|
||||
{
|
||||
private readonly CustomerRepository _CustomerRepository;
|
||||
|
||||
public CustomerServiceImpl(CustomerRepository CustomerRepository)
|
||||
{
|
||||
_CustomerRepository = CustomerRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询小程序客户分页列表
|
||||
/// </summary>
|
||||
public Task<PagedInfo<CustomerVo>> GetCustomerList(CustomerQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Customer>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerXcxOpenid), it => it.CustomerXcxOpenid == parm.CustomerXcxOpenid);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerNickname), it => it.CustomerNickname.Contains(parm.CustomerNickname));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CustomerMobilePhoneNumber), it => it.CustomerMobilePhoneNumber.Contains(parm.CustomerMobilePhoneNumber));
|
||||
predicate = predicate.AndIF(parm.BeginTime != null && parm.EndTime != null, it => it.CustomerLastLoginTime >= parm.BeginTime && it.CustomerLastLoginTime <= parm.EndTime);
|
||||
var query = _CustomerRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
||||
.Select(s => new CustomerVo
|
||||
{
|
||||
CustomerId = s.CustomerId,
|
||||
CustomerGuid = s.CustomerGuid,
|
||||
CustomerXcxOpenid = s.CustomerXcxOpenid,
|
||||
CustomerNickname = s.CustomerNickname,
|
||||
CustomerMobilePhoneNumber = s.CustomerMobilePhoneNumber,
|
||||
CustomerAvatar = s.CustomerAvatar,
|
||||
CustomerGender = s.CustomerGender,
|
||||
CustomerAvailableBalance = s.CustomerAvailableBalance,
|
||||
CustomerAvailablePoints = s.CustomerAvailablePoints,
|
||||
CustomerTotalPaymentAmount = s.CustomerTotalPaymentAmount,
|
||||
CustomerActualConsumptionAmount = s.CustomerActualConsumptionAmount,
|
||||
CustomerLastLoginTime = s.CustomerLastLoginTime,
|
||||
});
|
||||
|
||||
|
||||
return query.ToPageAsync(parm);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改小程序客户
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateCustomer(Customer model)
|
||||
{
|
||||
if (model.CustomerId != 0)
|
||||
{
|
||||
var response = await _CustomerRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var response = await _CustomerRepository.InsertReturnSnowflakeIdAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
#region Excel处理
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel数据导出处理
|
||||
/// </summary>
|
||||
public async Task<List<CustomerVo>> HandleExportData(List<CustomerVo> data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
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.Model.Dto.Business.Custom.Regions;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
using ARW.Model.Vo.Business.Custom.Regions;
|
||||
using ARW.Repository.Business.Custom.Regions;
|
||||
using ARW.Service.Business.IBusinessService.Custom.Regions;
|
||||
|
||||
namespace ARW.Service.Business.BusinessService.Custom.Regions
|
||||
{
|
||||
/// <summary>
|
||||
/// 省市区数据表接口实现类
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IRegionService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class RegionServiceImpl : BaseService<Region>, IRegionService
|
||||
{
|
||||
private readonly RegionRepository _RegionRepository;
|
||||
|
||||
public RegionServiceImpl(RegionRepository RegionRepository)
|
||||
{
|
||||
_RegionRepository = RegionRepository;
|
||||
}
|
||||
|
||||
#region 业务逻辑代码
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询省市区数据表树形列表
|
||||
/// </summary>
|
||||
public async Task<List<RegionVo>> GetRegionTreeList(RegionQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件
|
||||
var predicate = Expressionable.Create<Region>();
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.RegionName), s => s.RegionName.Contains(parm.RegionName));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.RegionCode), s => s.RegionCode == parm.RegionCode);
|
||||
|
||||
var query = _RegionRepository
|
||||
.Queryable()
|
||||
.LeftJoin<Region>((s, c) => s.RegionPid == c.RegionId)
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.RegionId, OrderByType.Asc)
|
||||
.Select((s, c) => new RegionVo
|
||||
{
|
||||
RegionId = s.RegionId,
|
||||
RegionName = s.RegionName,
|
||||
RegionPid = s.RegionPid,
|
||||
RegionCode = s.RegionCode,
|
||||
RegionLevel = s.RegionLevel,
|
||||
ParentName = c.RegionName,
|
||||
});
|
||||
|
||||
return await query.ToTreeAsync(it => it.Children, it => it.RegionPid, 0);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 查询省市区数据表列表
|
||||
/// </summary>
|
||||
public Task<List<RegionVo>> GetRegionList(RegionQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件d
|
||||
var predicate = Expressionable.Create<Region>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.RegionName), it => it.RegionName.Contains(parm.RegionName));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.RegionCode), it => it.RegionCode == parm.RegionCode);
|
||||
var query = _RegionRepository
|
||||
.Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(s => s.RegionId, OrderByType.Asc)
|
||||
.Select(s => new RegionVo
|
||||
{
|
||||
RegionId = s.RegionId,
|
||||
RegionName = s.RegionName,
|
||||
RegionPid = s.RegionPid,
|
||||
RegionCode = s.RegionCode,
|
||||
RegionLevel = s.RegionLevel,
|
||||
});
|
||||
|
||||
|
||||
return query.ToListAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改省市区数据表
|
||||
/// </summary>
|
||||
public async Task<string> AddOrUpdateRegion(Region model)
|
||||
{
|
||||
if (model.RegionId != 0)
|
||||
{
|
||||
var type = await _RegionRepository.GetListAsync(s => s.RegionPid == model.RegionId);
|
||||
if (type != null)
|
||||
{
|
||||
foreach (var item in type)
|
||||
{
|
||||
if (model.RegionPid == item.RegionId) throw new CustomException("上级菜单不能选择自己的子级!");
|
||||
}
|
||||
}
|
||||
if (model.RegionPid == model.RegionId) throw new CustomException("上级菜单不能选择与当前菜单一样的!");
|
||||
var response = await _RegionRepository.UpdateAsync(model);
|
||||
return "修改成功!";
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = _RegionRepository.GetFirst(it => it.RegionId == model.RegionPid);
|
||||
|
||||
var response = await _RegionRepository.InsertAsync(model);
|
||||
return "添加成功!";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取省市区Id
|
||||
/// </summary>
|
||||
/// <param name="RegionCode">省市区编码</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
public async Task<int> GetRegionId(string RegionCode, int level)
|
||||
{
|
||||
var region = await _RegionRepository.GetFirstAsync(s => s.RegionCode == RegionCode && s.RegionLevel == level);
|
||||
if (region == null) throw new Exception("编码不正确");
|
||||
return region.RegionId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region Excel处理
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel数据导出处理
|
||||
/// </summary>
|
||||
public async Task<List<RegionVo>> HandleExportData(List<RegionVo> data)
|
||||
{
|
||||
return data;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Business.Custom.Customers;
|
||||
using ARW.Model.Models.Business.Custom.Customers;
|
||||
using ARW.Model.Vo.Business.Custom.Customers;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.Custom.Customers
|
||||
{
|
||||
/// <summary>
|
||||
/// 小程序客户接口类
|
||||
///
|
||||
/// @author 黎文豪
|
||||
/// @date 2023-06-05
|
||||
/// </summary>
|
||||
public interface ICustomerService : IBaseService<Customer>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取小程序客户分页列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<PagedInfo<CustomerVo>> GetCustomerList(CustomerQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改小程序客户
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateCustomer(Customer parm);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导出
|
||||
/// </summary>
|
||||
Task<List<CustomerVo>> HandleExportData(List<CustomerVo> data);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ARW.Model;
|
||||
using ARW.Model.Dto.Business.Custom.Regions;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
using ARW.Model.Vo.Business.Custom.Regions;
|
||||
|
||||
namespace ARW.Service.Business.IBusinessService.Custom.Regions
|
||||
{
|
||||
public interface IRegionService : IBaseService<Region>
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取省市区数据表树形列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<RegionVo>> GetRegionTreeList(RegionQueryDto parm);
|
||||
|
||||
/// <summary>
|
||||
/// 获取省市区数据表列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<RegionVo>> GetRegionList(RegionQueryDto parm);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 添加或修改省市区数据表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
Task<string> AddOrUpdateRegion(Region parm);
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Excel导出
|
||||
/// </summary>
|
||||
Task<List<RegionVo>> HandleExportData(List<RegionVo> data);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取省市区Id
|
||||
/// </summary>
|
||||
/// <param name="RegionCode">省市区编码</param>
|
||||
/// <returns></returns>
|
||||
Task<int> GetRegionId(string RegionCode,int level);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ARW.Admin.WebApi.Extensions;
|
||||
using ARW.Admin.WebApi.Filters;
|
||||
using ARW.Common;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Dto.Api.Custom.CustomerAddresses;
|
||||
using ARW.Service.Api.IBusinessService.Custom.CustomerAddresses;
|
||||
using ARW.Model.Models.Business.Custom.CustomerAddresses;
|
||||
using ARW.Model.Vo.Api.Custom.CustomerAddresses;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Geocoding;
|
||||
using ARW.Admin.WebApi.Framework;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.Custom.CustomerAddresses
|
||||
{
|
||||
/// <summary>
|
||||
/// 客户收货地址控制器Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("api/[controller]")]
|
||||
public class CustomerAddressApiController : BaseController
|
||||
{
|
||||
private readonly ICustomerAddressServiceApi _CustomerAddressServiceApi;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="CustomerAddressServiceApi">客户收货地址客户收货地址Api服务</param>
|
||||
public CustomerAddressApiController(ICustomerAddressServiceApi CustomerAddressServiceApi)
|
||||
{
|
||||
_CustomerAddressServiceApi = CustomerAddressServiceApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取客户收货地址列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCustomerAddressList")]
|
||||
public async Task<IActionResult> GetCustomerAddressListApi([FromQuery] CustomerAddressQueryDtoApi parm)
|
||||
{
|
||||
var user = JwtUtil.GetLoginUser(App.HttpContext);
|
||||
parm.CustomerAddressCustomerGuid = user.UserId;
|
||||
var res = await _CustomerAddressServiceApi.GetCustomerAddressListApi(parm);
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取CustomerAddress详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCustomerAddressDetails")]
|
||||
public async Task<IActionResult> GetCustomerAddressDetails([FromQuery] CustomerAddressDtoApi parm)
|
||||
{
|
||||
if (parm == null) throw new CustomException("参数错误!");
|
||||
|
||||
var res = await _CustomerAddressServiceApi.GetCustomerAddressDetails(parm);
|
||||
|
||||
if (res != "[]")
|
||||
{
|
||||
res = res.Remove(0, 1);
|
||||
res = res.Substring(0, res.Length - 1);
|
||||
var data = res.FromJSON<CustomerAddressApiDetailsVo>();
|
||||
return SUCCESS(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUCCESS(res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ARW.Admin.WebApi.Extensions;
|
||||
using ARW.Admin.WebApi.Filters;
|
||||
using ARW.Common;
|
||||
using ARW.Admin.WebApi.Controllers;
|
||||
using ARW.Model.Dto.Api.Custom.Regions;
|
||||
using ARW.Service.Api.IBusinessService.Custom.Regions;
|
||||
using ARW.Model.Models.Business.Custom.Regions;
|
||||
using ARW.Model.Vo.Api.Custom.Regions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Geocoding;
|
||||
|
||||
namespace ARW.WebApi.Controllers.Api.Custom.Regions
|
||||
{
|
||||
/// <summary>
|
||||
/// 省市区数据表控制器Api
|
||||
///
|
||||
/// @author admin
|
||||
/// @date 2023-06-09
|
||||
/// </summary>
|
||||
[Verify]
|
||||
[Route("api/[controller]")]
|
||||
public class RegionApiController : BaseController
|
||||
{
|
||||
private readonly IRegionServiceApi _RegionServiceApi;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖注入
|
||||
/// </summary>
|
||||
/// <param name="RegionServiceApi">省市区数据表省市区数据表Api服务</param>
|
||||
public RegionApiController(IRegionServiceApi RegionServiceApi)
|
||||
{
|
||||
_RegionServiceApi = RegionServiceApi;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取省市区数据表树形列表(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getRegionTreeList")]
|
||||
public async Task<IActionResult> GetRegionTreeListApi([FromQuery] RegionQueryDtoApi parm)
|
||||
{
|
||||
var res = await _RegionServiceApi.GetRegionTreeListApi(parm);
|
||||
if (res == null)
|
||||
res = new List<RegionVoApi>();
|
||||
|
||||
return SUCCESS(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Region详情(Api)
|
||||
/// </summary>
|
||||
/// <param name="parm">查询参数</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getRegionDetails")]
|
||||
public async Task<IActionResult> GetRegionDetails([FromQuery] RegionDtoApi parm)
|
||||
{
|
||||
//if (parm == null) throw new CustomException("参数错误!");
|
||||
|
||||
var res = await _RegionServiceApi.GetRegionDetails(parm);
|
||||
|
||||
if (res != "[]")
|
||||
{
|
||||
res = res.Remove(0, 1);
|
||||
res = res.Substring(0, res.Length - 1);
|
||||
var data = res.FromJSON<RegionApiDetailsVo>();
|
||||
return SUCCESS(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
return SUCCESS(res);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user