diff --git a/ARW.Model/Dto/Business/LogisticsManage/Deliverys/DeliveryDto.cs b/ARW.Model/Dto/Business/LogisticsManage/Deliverys/DeliveryDto.cs new file mode 100644 index 0000000..f3c204d --- /dev/null +++ b/ARW.Model/Dto/Business/LogisticsManage/Deliverys/DeliveryDto.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.LogisticsManage.Deliverys; + +namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys +{ + /// + /// 配送模板输入对象 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + public class DeliveryDto + { + + public int DeliveryId { get; set; } + + public long DeliveryGuid { get; set; } + + [Required(ErrorMessage = "店铺guid不能为空")] + public long ShopGuid { get; set; } + + [Required(ErrorMessage = "模板名称不能为空")] + public string DeliveryName { get; set; } + + [Required(ErrorMessage = "计费方式不能为空")] + public int DeliveryBillingMethod { get; set; } + + [Required(ErrorMessage = "排序不能为空")] + public int DeliverySort { get; set; } + + + + + + } + + + /// + /// 配送模板查询对象 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + public class DeliveryQueryDto : PagerInfo + { + + public long? ShopGuid { get; set; } + + public string DeliveryName { get; set; } + + public int? DeliveryBillingMethod { get; set; } + + public string ids { get; set; } + } + + + + +} diff --git a/ARW.Model/Models/Business/LogisticsManage/Deliverys/Delivery.cs b/ARW.Model/Models/Business/LogisticsManage/Deliverys/Delivery.cs new file mode 100644 index 0000000..8031b1c --- /dev/null +++ b/ARW.Model/Models/Business/LogisticsManage/Deliverys/Delivery.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using SqlSugar; +using OfficeOpenXml.Attributes; +using Newtonsoft.Json; + +namespace ARW.Model.Models.Business.LogisticsManage.Deliverys +{ + /// + /// 配送模板,数据实体对象 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + [SugarTable("tb_delivery")] + public class Delivery : BusinessBase + { + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "DeliveryId")] + [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "delivery_id")] + public int DeliveryId { get; set; } + + + /// + /// 描述 : + /// 空值 : false + /// + [EpplusTableColumn(Header = "DeliveryGuid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(IsPrimaryKey = true, IsIdentity = false, ColumnName = "delivery_guid")] + public long DeliveryGuid { get; set; } + + + /// + /// 描述 :店铺guid + /// 空值 : false + /// + [EpplusTableColumn(Header = "店铺guid")] + [JsonConverter(typeof(ValueToStringConverter))] + [SugarColumn(ColumnName = "shop_guid")] + public long ShopGuid { get; set; } + + + /// + /// 描述 :模板名称 + /// 空值 : false + /// + [EpplusTableColumn(Header = "模板名称")] + [SugarColumn(ColumnName = "delivery_name")] + public string DeliveryName { get; set; } + + + /// + /// 描述 :计费方式 + /// 空值 : false + /// + [EpplusTableColumn(Header = "计费方式")] + [SugarColumn(ColumnName = "delivery_billing_method")] + public int DeliveryBillingMethod { get; set; } + + + /// + /// 描述 :排序 + /// 空值 : false + /// + [EpplusTableColumn(Header = "排序")] + [SugarColumn(ColumnName = "delivery_sort")] + public int DeliverySort { get; set; } + + + + + + + } +} \ No newline at end of file diff --git a/ARW.Model/Vo/Business/LogisticsManage/Deliverys/DeliveryVo.cs b/ARW.Model/Vo/Business/LogisticsManage/Deliverys/DeliveryVo.cs new file mode 100644 index 0000000..8bdedc4 --- /dev/null +++ b/ARW.Model/Vo/Business/LogisticsManage/Deliverys/DeliveryVo.cs @@ -0,0 +1,62 @@ +using Newtonsoft.Json; +using OfficeOpenXml.Attributes; +using SqlSugar; +using System; + +namespace ARW.Model.Vo.Business.LogisticsManage.Deliverys +{ + /// + /// 配送模板展示对象 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + public class DeliveryVo + { + + + /// + /// 描述 : + /// + [EpplusIgnore] + public int DeliveryId { get; set; } + + + /// + /// 描述 : + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusIgnore] + public long DeliveryGuid { get; set; } + + + /// + /// 描述 :店铺guid + /// + [JsonConverter(typeof(ValueToStringConverter))] + [EpplusTableColumn(Header = "店铺guid")] + public long ShopGuid { get; set; } + + + /// + /// 描述 :模板名称 + /// + [EpplusTableColumn(Header = "模板名称")] + public string DeliveryName { get; set; } + + + /// + /// 描述 :计费方式 + /// + [EpplusTableColumn(Header = "计费方式")] + public int DeliveryBillingMethod { get; set; } + + + /// + /// 描述 :排序 + /// + [EpplusTableColumn(Header = "排序")] + public int DeliverySort { get; set; } + + } +} diff --git a/ARW.Repository/Business/LogisticsManage/Deliverys/DeliveryRepository.cs b/ARW.Repository/Business/LogisticsManage/Deliverys/DeliveryRepository.cs new file mode 100644 index 0000000..20462c1 --- /dev/null +++ b/ARW.Repository/Business/LogisticsManage/Deliverys/DeliveryRepository.cs @@ -0,0 +1,20 @@ +using System; +using Infrastructure.Attribute; +using ARW.Repository.System; +using ARW.Model.Models.Business.LogisticsManage.Deliverys; + +namespace ARW.Repository.Business.LogisticsManage.Deliverys +{ + /// + /// 配送模板仓储 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + [AppService(ServiceLifetime = LifeTime.Transient)] + public class DeliveryRepository : BaseRepository + { + #region 业务逻辑代码 + #endregion + } +} \ No newline at end of file diff --git a/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs b/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs index e9a5706..209bbe0 100644 --- a/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs +++ b/ARW.Service/Business/BusinessService/GoodsManager/ShopGoodsCategorys/ShopGoodsCategoryService.cs @@ -196,16 +196,16 @@ namespace ARW.Service.Business.BusinessService.GoodsManager.ShopGoodsCategorys { try { - var category = await HandleImportData(ShopGoodsCategoryVo, user.UserId,index); + var category = await HandleImportData(ShopGoodsCategoryVo, user.UserId, index); var ShopGoodsCategory = new ShopGoodsCategory { - ShopGoodsCategoryId= category.ShopGoodsCategoryId, - ShopGoodsCategoryGuid= category.ShopGoodsCategoryGuid, + ShopGoodsCategoryId = category.ShopGoodsCategoryId, + ShopGoodsCategoryGuid = category.ShopGoodsCategoryGuid, ShopGuid = category.ShopGuid, ShopGoodsCategoryParentGuid = category.ShopGoodsCategoryParentGuid, ShopGoodsCategoryName = category.ShopGoodsCategoryName, ShopGoodsCategoryDisplayStatus = category.ShopGoodsCategoryDisplayStatus, - ShopGoodsCategorySort = category.ShopGoodsCategorySort + ShopGoodsCategorySort = category.ShopGoodsCategorySort }; if (isUpdateSupport) diff --git a/ARW.Service/Business/BusinessService/LogisticsManage/Deliverys/DeliveryService.cs b/ARW.Service/Business/BusinessService/LogisticsManage/Deliverys/DeliveryService.cs new file mode 100644 index 0000000..a3945a0 --- /dev/null +++ b/ARW.Service/Business/BusinessService/LogisticsManage/Deliverys/DeliveryService.cs @@ -0,0 +1,104 @@ +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.LogisticsManage.Deliverys; +using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys; +using ARW.Model.Dto.Business.LogisticsManage.Deliverys; +using ARW.Model.Models.Business.LogisticsManage.Deliverys; +using ARW.Model.Vo.Business.LogisticsManage.Deliverys; + +namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys +{ + /// + /// 配送模板接口实现类 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + [AppService(ServiceType = typeof(IDeliveryService), ServiceLifetime = LifeTime.Transient)] + public class DeliveryServiceImpl : BaseService, IDeliveryService + { + private readonly DeliveryRepository _DeliveryRepository; + + public DeliveryServiceImpl(DeliveryRepository DeliveryRepository) + { + this._DeliveryRepository = DeliveryRepository; + } + + #region 业务逻辑代码 + + + /// + /// 查询配送模板分页列表 + /// + public async Task> GetDeliveryList(DeliveryQueryDto parm) + { + //开始拼装查询条件d + var predicate = Expressionable.Create(); + + //predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid.Contains(parm.ShopGuid)); + predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.DeliveryName), s => s.DeliveryName.Contains(parm.DeliveryName)); + predicate = predicate.AndIF(parm.DeliveryBillingMethod != null, s => s.DeliveryBillingMethod == parm.DeliveryBillingMethod); + var query = _DeliveryRepository + .Queryable() + .Where(predicate.ToExpression()) + .OrderBy(s => s.DeliverySort, OrderByType.Asc) + .Select(s => new DeliveryVo + { + DeliveryId = s.DeliveryId, + DeliveryGuid = s.DeliveryGuid, + ShopGuid = s.ShopGuid, + DeliveryName = s.DeliveryName, + DeliveryBillingMethod = s.DeliveryBillingMethod, + DeliverySort = s.DeliverySort, + }); + + + return await query.ToPageAsync(parm); + } + + /// + /// 添加或修改配送模板 + /// + public async Task AddOrUpdateDelivery(Delivery model) + { + if (model.DeliveryId != 0) + { + var response = await _DeliveryRepository.UpdateAsync(model); + return "修改成功!"; + } + else + { + + var response = await _DeliveryRepository.InsertReturnSnowflakeIdAsync(model); + return "添加成功!"; + } + } + + #region Excel处理 + + + /// + /// Excel数据导出处理 + /// + public async Task> HandleExportData(List data) + { + return data; + } + + #endregion + + + + #endregion + + } +} diff --git a/ARW.Service/Business/IBusinessService/LogisticsManage/Deliverys/IDeliveryService.cs b/ARW.Service/Business/IBusinessService/LogisticsManage/Deliverys/IDeliveryService.cs new file mode 100644 index 0000000..d0908ab --- /dev/null +++ b/ARW.Service/Business/IBusinessService/LogisticsManage/Deliverys/IDeliveryService.cs @@ -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.LogisticsManage.Deliverys; +using ARW.Model.Models.Business.LogisticsManage.Deliverys; +using ARW.Model.Vo.Business.LogisticsManage.Deliverys; + +namespace ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys +{ + /// + /// 配送模板接口类 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + public interface IDeliveryService : IBaseService + { + /// + /// 获取配送模板分页列表 + /// + /// + /// + Task> GetDeliveryList(DeliveryQueryDto parm); + + + /// + /// 添加或修改配送模板 + /// + /// + /// + Task AddOrUpdateDelivery(Delivery parm); + + + + /// + /// Excel导出 + /// + Task> HandleExportData(List data); + + + } +} diff --git a/ARW.WebApi/Controllers/Business/LogisticsManage/Deliverys/DeliveryController.cs b/ARW.WebApi/Controllers/Business/LogisticsManage/Deliverys/DeliveryController.cs new file mode 100644 index 0000000..91883ce --- /dev/null +++ b/ARW.WebApi/Controllers/Business/LogisticsManage/Deliverys/DeliveryController.cs @@ -0,0 +1,132 @@ +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.Model.Dto.Business.LogisticsManage.Deliverys; +using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys; +using ARW.Admin.WebApi.Controllers; +using ARW.Model.Models.Business.LogisticsManage.Deliverys; +using ARW.Model.Vo.Business.LogisticsManage.Deliverys; +using Microsoft.AspNetCore.Authorization; +using ARW.Admin.WebApi.Framework; + + +namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys +{ + /// + /// 配送模板控制器 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + [Verify] + [Route("business/[controller]")] + public class DeliveryController : BaseController + { + private readonly IDeliveryService _DeliveryService; + + /// + /// 依赖注入 + /// + /// 配送模板服务 + public DeliveryController(IDeliveryService DeliveryService) + { + _DeliveryService = DeliveryService; + } + + + /// + /// 获取配送模板列表 + /// + /// 查询参数 + /// + [HttpGet("getDeliveryList")] + [ActionPermissionFilter(Permission = "business:delivery:list")] + public async Task GetDeliveryList([FromQuery] DeliveryQueryDto parm) + { + var res = await _DeliveryService.GetDeliveryList(parm); + return SUCCESS(res); + } + + /// + /// 添加或修改配送模板 + /// + /// + /// + [HttpPost("addOrUpdateDelivery")] + [ActionPermissionFilter(Permission = "business:delivery:addOrUpdate")] + [Log(Title = "添加或修改配送模板", BusinessType = BusinessType.ADDORUPDATE)] + public async Task AddOrUpdateDelivery([FromBody] DeliveryDto parm) + { + if (parm == null) { throw new CustomException("请求参数错误"); } + + var modal = new Delivery(); + if (parm.DeliveryId != 0) modal = parm.Adapt().ToUpdate(HttpContext); + else modal = parm.Adapt().ToCreate(HttpContext); + + var res = await _DeliveryService.AddOrUpdateDelivery(modal); + return SUCCESS(res); + } + + /// + /// 删除配送模板 + /// + /// + [HttpDelete("{ids}")] + [ActionPermissionFilter(Permission = "business:delivery:delete")] + [Log(Title = "配送模板删除", BusinessType = BusinessType.DELETE)] + public IActionResult Delete(string ids) + { + long[] idsArr = Tools.SpitLongArrary(ids); + if (idsArr.Length <= 0) { return ToResponse(ApiResult.Error($"删除失败Id 不能为空")); } + var response = _DeliveryService.Delete(idsArr); + return SUCCESS("删除成功!"); + } + + + /// + /// 导出配送模板 + /// + /// + [Log(Title = "配送模板导出", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)] + [HttpGet("exportDelivery")] + [ActionPermissionFilter(Permission = "business:delivery:export")] + public async Task ExportExcel([FromQuery] DeliveryQueryDto parm) + { + parm.PageSize = 10000; + var list = await _DeliveryService.GetDeliveryList(parm); + var data = list.Result; + + // 选中数据 + if (!string.IsNullOrEmpty(parm.ids)) + { + int[] idsArr = Tools.SpitIntArrary(parm.ids); + var selectDataList = new List(); + foreach (var item in idsArr) + { + var select_data = data.Where(s => s.DeliveryId == item).First(); + selectDataList.Add(select_data); + } + data = selectDataList; + } + + + + // 导出数据处理 + var handleData = await _DeliveryService.HandleExportData(data); + + string sFileName = ExportExcel(handleData, "Delivery", "配送模板列表"); + return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName }); + } + + + + + } +}