126 lines
4.5 KiB
C#
126 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 Infrastructure;
|
|
using ARW.Model;
|
|
using ARW.Repository;
|
|
using ARW.Repository.Business.ShopManager.ShopAddresss;
|
|
using ARW.Service.Business.IBusinessService.ShopManager.ShopAddresss;
|
|
using ARW.Model.Dto.Business.ShopManager.ShopAddresss;
|
|
using ARW.Model.Models.Business.ShopManager.ShopAddresss;
|
|
using ARW.Model.Vo.Business.ShopManager.ShopAddresss;
|
|
using ARW.Model.Models.Business.Custom.Regions;
|
|
using ARW.Repository.System;
|
|
using ARW.Model.Models.Business.ShopManager.Shops;
|
|
|
|
namespace ARW.Service.Business.BusinessService.ShopManager.ShopAddresss
|
|
{
|
|
/// <summary>
|
|
/// 店铺地址接口实现类
|
|
///
|
|
/// @author lwh
|
|
/// @date 2023-06-15
|
|
/// </summary>
|
|
[AppService(ServiceType = typeof(IShopAddressService), ServiceLifetime = LifeTime.Transient)]
|
|
public class ShopAddressServiceImpl : BaseService<ShopAddress>, IShopAddressService
|
|
{
|
|
private readonly ShopAddressRepository _ShopAddressRepository;
|
|
private readonly SysDictDataRepository _SysDictDataRepository;
|
|
|
|
public ShopAddressServiceImpl(ShopAddressRepository ShopAddressRepository, SysDictDataRepository sysDictDataRepository)
|
|
{
|
|
this._ShopAddressRepository = ShopAddressRepository;
|
|
_SysDictDataRepository = sysDictDataRepository;
|
|
}
|
|
|
|
#region 业务逻辑代码
|
|
|
|
|
|
/// <summary>
|
|
/// 查询店铺地址分页列表
|
|
/// </summary>
|
|
public async Task<PagedInfo<ShopAddressVo>> GetShopAddressList(ShopAddressQueryDto parm)
|
|
{
|
|
//开始拼装查询条件d
|
|
var predicate = Expressionable.Create<ShopAddress>();
|
|
|
|
predicate = predicate.AndIF(parm.ShopGuid != 0, s => s.ShopGuid == parm.ShopGuid);
|
|
predicate = predicate.AndIF(parm.ShopAddressType != null, s => s.ShopAddressType == parm.ShopAddressType);
|
|
var query = _ShopAddressRepository
|
|
.Queryable()
|
|
.LeftJoin<Region>((s, d) => s.ProvinceId == d.RegionId)
|
|
.LeftJoin<Region>((s, d, f) => s.CityId == f.RegionId)
|
|
.LeftJoin<Region>((s, d, f, g) => s.DistrictId == g.RegionId)
|
|
.LeftJoin<Shop>((s, d, f, g, c) => s.ShopGuid == c.ShopGuid)
|
|
.Where(predicate.ToExpression())
|
|
.OrderBy(s => s.ShopAddressSort, OrderByType.Asc)
|
|
.Select((s, d, f, g, c) => new ShopAddressVo
|
|
{
|
|
ShopGuid = s.ShopGuid,
|
|
ShopName = c.ShopName,
|
|
ShopAddressId = s.ShopAddressId,
|
|
ShopAddressGuid = s.ShopAddressGuid,
|
|
ShopAddressType = s.ShopAddressType,
|
|
AddressName = d.RegionName + "/" + f.RegionName + "/" + g.RegionName,
|
|
ProvinceId = s.ProvinceId,
|
|
CityId = s.CityId,
|
|
DistrictId = s.DistrictId,
|
|
ShopAddressContactName = s.ShopAddressContactName,
|
|
ShopAddressContactNumber = s.ShopAddressContactNumber,
|
|
ShopAddressDetailedAddress = s.ShopAddressDetailedAddress,
|
|
ShopAddressSort = s.ShopAddressSort,
|
|
CreateTime = s.Create_time.ToString("yyyy-MM-dd HH:mm")
|
|
});
|
|
|
|
|
|
return await query.ToPageAsync(parm);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 添加或修改店铺地址
|
|
/// </summary>
|
|
public async Task<string> AddOrUpdateShopAddress(ShopAddress model)
|
|
{
|
|
if (model.ShopAddressId != 0)
|
|
{
|
|
var response = await _ShopAddressRepository.UpdateAsync(model);
|
|
return "修改成功!";
|
|
}
|
|
else
|
|
{
|
|
|
|
var response = await _ShopAddressRepository.InsertReturnSnowflakeIdAsync(model);
|
|
return "添加成功!";
|
|
}
|
|
}
|
|
|
|
#region Excel处理
|
|
|
|
|
|
/// <summary>
|
|
/// Excel数据导出处理
|
|
/// </summary>
|
|
public async Task<List<ShopAddressVo>> HandleExportData(List<ShopAddressVo> data)
|
|
{
|
|
foreach (var item in data)
|
|
{
|
|
item.ShopAddressTypeName = _SysDictDataRepository.GetDictNameByName("shop_address_type", item.ShopAddressType.ToString());
|
|
}
|
|
|
|
return data;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|