From 9ffb9fe07a1ae91925acb2cfccac7eb3a74cec50 Mon Sep 17 00:00:00 2001 From: lwh <2679599887@qq.com> Date: Sat, 17 Jun 2023 21:07:42 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0=E9=85=8D=E9=80=81?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeliveryRules/DeliveryRuleDto.cs | 4 +- .../LogisticsManage/Deliverys/DeliveryDto.cs | 16 +++ .../DeliveryRules/DeliveryRule.cs | 4 +- .../LogisticsManage/Deliverys/Delivery.cs | 4 +- .../Vo/Business/Custom/Regions/RegionVo.cs | 32 +++++ .../DeliveryRules/DeliveryRuleVo.cs | 10 +- .../LogisticsManage/Deliverys/DeliveryVo.cs | 9 +- .../Custom/Regions/RegionService.cs | 29 ++++ .../DeliveryRules/DeliveryRuleService.cs | 127 ++++++++++++++---- .../Deliverys/DeliveryService.cs | 28 +++- .../Custom/Regions/IRegionService.cs | 7 + .../DeliveryRules/IDeliveryRuleService.cs | 41 ++++-- .../Custom/Regions/RegionController.cs | 16 +++ .../Deliverys/DeliveryController.cs | 39 +++++- 14 files changed, 315 insertions(+), 51 deletions(-) diff --git a/ARW.Model/Dto/Business/LogisticsManage/DeliveryRules/DeliveryRuleDto.cs b/ARW.Model/Dto/Business/LogisticsManage/DeliveryRules/DeliveryRuleDto.cs index c7d8512..faec333 100644 --- a/ARW.Model/Dto/Business/LogisticsManage/DeliveryRules/DeliveryRuleDto.cs +++ b/ARW.Model/Dto/Business/LogisticsManage/DeliveryRules/DeliveryRuleDto.cs @@ -28,13 +28,13 @@ namespace ARW.Model.Dto.Business.LogisticsManage.DeliveryRules public string DeliveryRuleRegionText { get; set; } [Required(ErrorMessage = "首件(个)/首重(Kg)不能为空")] - public int DeliveryRuleFirst { get; set; } + public decimal DeliveryRuleFirst { get; set; } [Required(ErrorMessage = "运费(元)不能为空")] public decimal DeliveryRuleFirstFee { get; set; } [Required(ErrorMessage = "续件/续重不能为空")] - public int DeliveryRuleAdditional { get; set; } + public decimal DeliveryRuleAdditional { get; set; } [Required(ErrorMessage = "续费(元)不能为空")] public decimal DeliveryRuleAdditionalFee { get; set; } diff --git a/ARW.Model/Dto/Business/LogisticsManage/Deliverys/DeliveryDto.cs b/ARW.Model/Dto/Business/LogisticsManage/Deliverys/DeliveryDto.cs index f3c204d..3ea48ff 100644 --- a/ARW.Model/Dto/Business/LogisticsManage/Deliverys/DeliveryDto.cs +++ b/ARW.Model/Dto/Business/LogisticsManage/Deliverys/DeliveryDto.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +using ARW.Model.Models.Business.LogisticsManage.DeliveryRules; using ARW.Model.Models.Business.LogisticsManage.Deliverys; namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys @@ -27,6 +28,9 @@ namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys [Required(ErrorMessage = "计费方式不能为空")] public int DeliveryBillingMethod { get; set; } + [Required(ErrorMessage = "配送区域及运费不能为空")] + public List DeliveryRuleDataList { get; set; } + [Required(ErrorMessage = "排序不能为空")] public int DeliverySort { get; set; } @@ -47,6 +51,7 @@ namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys { public long? ShopGuid { get; set; } + public string ShopName { get; set; } public string DeliveryName { get; set; } @@ -56,6 +61,17 @@ namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys } + /// + /// 配送模板的配送区域和运费查询对象 + /// + /// @author 黎文豪 + /// @date 2023-06-16 + /// + public class DeliveryRuleEditDto + { + public long DeliveryGuid { get; set; } + } + } diff --git a/ARW.Model/Models/Business/LogisticsManage/DeliveryRules/DeliveryRule.cs b/ARW.Model/Models/Business/LogisticsManage/DeliveryRules/DeliveryRule.cs index 4434f28..7f70b54 100644 --- a/ARW.Model/Models/Business/LogisticsManage/DeliveryRules/DeliveryRule.cs +++ b/ARW.Model/Models/Business/LogisticsManage/DeliveryRules/DeliveryRule.cs @@ -63,7 +63,7 @@ namespace ARW.Model.Models.Business.LogisticsManage.DeliveryRules /// 空值 : false /// [SugarColumn(ColumnName = "delivery_rule_first")] - public int DeliveryRuleFirst { get; set; } + public decimal DeliveryRuleFirst { get; set; } /// @@ -79,7 +79,7 @@ namespace ARW.Model.Models.Business.LogisticsManage.DeliveryRules /// 空值 : false /// [SugarColumn(ColumnName = "delivery_rule_additional")] - public int DeliveryRuleAdditional { get; set; } + public decimal DeliveryRuleAdditional { get; set; } /// diff --git a/ARW.Model/Models/Business/LogisticsManage/Deliverys/Delivery.cs b/ARW.Model/Models/Business/LogisticsManage/Deliverys/Delivery.cs index 8031b1c..c33d720 100644 --- a/ARW.Model/Models/Business/LogisticsManage/Deliverys/Delivery.cs +++ b/ARW.Model/Models/Business/LogisticsManage/Deliverys/Delivery.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using SqlSugar; using OfficeOpenXml.Attributes; using Newtonsoft.Json; +using ARW.Model.Models.Business.LogisticsManage.DeliveryRules; namespace ARW.Model.Models.Business.LogisticsManage.Deliverys { @@ -72,7 +73,8 @@ namespace ARW.Model.Models.Business.LogisticsManage.Deliverys public int DeliverySort { get; set; } - + [SugarColumn(IsIgnore = true)] + public List DeliveryRuleDataList { get; set; } diff --git a/ARW.Model/Vo/Business/Custom/Regions/RegionVo.cs b/ARW.Model/Vo/Business/Custom/Regions/RegionVo.cs index aab2bcc..b8c637e 100644 --- a/ARW.Model/Vo/Business/Custom/Regions/RegionVo.cs +++ b/ARW.Model/Vo/Business/Custom/Regions/RegionVo.cs @@ -51,4 +51,36 @@ namespace ARW.Model.Vo.Business.Custom.Regions [SugarColumn(IsIgnore = true)] public List Children { get; set; } } + + + /// + /// 省市区数据表展示对象(二级) + /// + public class SecondRegionVo + { + [SugarColumn(IsTreeKey = true)] + public int Id { get; set; } + + /// + /// 描述 :区划名称 + /// + public string Label { get; set; } + + /// + /// 描述 :父级ID + /// + public int Pid { get; set; } + + public string ParentName { get; set; } + + + public string Code { get; set; } + + + [EpplusIgnore] + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + [SugarColumn(IsIgnore = true)] + public List Children { get; set; } + } + } diff --git a/ARW.Model/Vo/Business/LogisticsManage/DeliveryRules/DeliveryRuleVo.cs b/ARW.Model/Vo/Business/LogisticsManage/DeliveryRules/DeliveryRuleVo.cs index a131dfe..e7dbd43 100644 --- a/ARW.Model/Vo/Business/LogisticsManage/DeliveryRules/DeliveryRuleVo.cs +++ b/ARW.Model/Vo/Business/LogisticsManage/DeliveryRules/DeliveryRuleVo.cs @@ -1,7 +1,9 @@ +using ARW.Model.Vo.Business.Custom.Regions; using Newtonsoft.Json; using OfficeOpenXml.Attributes; using SqlSugar; using System; +using System.Collections.Generic; namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules { @@ -38,7 +40,9 @@ namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules /// /// 描述 :可配送区域(城市id集) /// - public string DeliveryRuleRegion { get; set; } + public List DeliveryRuleRegion { get; set; } + + public string DeliveryRuleRegionName { get; set; } /// @@ -50,7 +54,7 @@ namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules /// /// 描述 :首件(个)/首重(Kg) /// - public int DeliveryRuleFirst { get; set; } + public decimal DeliveryRuleFirst { get; set; } /// @@ -62,7 +66,7 @@ namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules /// /// 描述 :续件/续重 /// - public int DeliveryRuleAdditional { get; set; } + public decimal DeliveryRuleAdditional { get; set; } /// diff --git a/ARW.Model/Vo/Business/LogisticsManage/Deliverys/DeliveryVo.cs b/ARW.Model/Vo/Business/LogisticsManage/Deliverys/DeliveryVo.cs index 8bdedc4..9b5d23c 100644 --- a/ARW.Model/Vo/Business/LogisticsManage/Deliverys/DeliveryVo.cs +++ b/ARW.Model/Vo/Business/LogisticsManage/Deliverys/DeliveryVo.cs @@ -34,10 +34,17 @@ namespace ARW.Model.Vo.Business.LogisticsManage.Deliverys /// 描述 :店铺guid /// [JsonConverter(typeof(ValueToStringConverter))] - [EpplusTableColumn(Header = "店铺guid")] + [EpplusIgnore] public long ShopGuid { get; set; } + /// + /// 描述 :店铺名称 + /// + [EpplusTableColumn(Header = "店铺名称")] + public string ShopName { get; set; } + + /// /// 描述 :模板名称 /// diff --git a/ARW.Service/Business/BusinessService/Custom/Regions/RegionService.cs b/ARW.Service/Business/BusinessService/Custom/Regions/RegionService.cs index 8a0fa96..be84c5a 100644 --- a/ARW.Service/Business/BusinessService/Custom/Regions/RegionService.cs +++ b/ARW.Service/Business/BusinessService/Custom/Regions/RegionService.cs @@ -62,6 +62,35 @@ namespace ARW.Service.Business.BusinessService.Custom.Regions } + /// + /// 查询省市区数据表树形列表(二级) + /// + public async Task> GetSecondRegionTreeList(RegionQueryDto parm) + { + //开始拼装查询条件 + var predicate = Expressionable.Create(); + 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); + predicate = predicate.And(s => s.RegionLevel <= 2); + + var query = _RegionRepository + .Queryable() + .LeftJoin((s, c) => s.RegionPid == c.RegionId) + .Where(predicate.ToExpression()) + .OrderBy(s => s.RegionId, OrderByType.Asc) + .Select((s, c) => new SecondRegionVo + { + Id = s.RegionId, + Label = s.RegionName, + Pid = s.RegionPid, + Code = s.RegionCode, + ParentName = c.RegionName + }); + + return await query.ToTreeAsync(it => it.Children, it => it.Pid, 0); + } + + /// /// 查询省市区数据表列表 /// diff --git a/ARW.Service/Business/BusinessService/LogisticsManage/DeliveryRules/DeliveryRuleService.cs b/ARW.Service/Business/BusinessService/LogisticsManage/DeliveryRules/DeliveryRuleService.cs index 2828c0a..2ffea98 100644 --- a/ARW.Service/Business/BusinessService/LogisticsManage/DeliveryRules/DeliveryRuleService.cs +++ b/ARW.Service/Business/BusinessService/LogisticsManage/DeliveryRules/DeliveryRuleService.cs @@ -14,6 +14,18 @@ using ARW.Service.Business.IBusinessService.LogisticsManage.DeliveryRules; using ARW.Model.Dto.Business.LogisticsManage.DeliveryRules; using ARW.Model.Models.Business.LogisticsManage.DeliveryRules; using ARW.Model.Vo.Business.LogisticsManage.DeliveryRules; +using Newtonsoft.Json; +using Senparc.Weixin.WxOpen.AdvancedAPIs.Tcb; +using System.Text.RegularExpressions; +using ARW.Model.Models.Business.LogisticsManage.Deliverys; +using ARW.Repository.Business.LogisticsManage.Deliverys; +using ARW.Model.Dto.Business.LogisticsManage.Deliverys; +using ARW.Model.Models.Business.ShopManager.Shops; +using ARW.Model.Vo.Business.LogisticsManage.Deliverys; +using ARW.Model.Models.Business.Custom.Regions; +using ARW.Repository.Business.Custom.Regions; +using ARW.Model.Vo.Business.Custom.Regions; +using Org.BouncyCastle.Crypto.Prng; namespace ARW.Service.Business.BusinessService.LogisticsManage.DeliveryRules { @@ -27,34 +39,34 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.DeliveryRules public class DeliveryRuleServiceImpl : BaseService, IDeliveryRuleService { private readonly DeliveryRuleRepository _DeliveryRuleRepository; + private readonly DeliveryRepository _DeliveryRepository; + private readonly RegionRepository _RegionRepository; - public DeliveryRuleServiceImpl(DeliveryRuleRepository DeliveryRuleRepository) + public DeliveryRuleServiceImpl(DeliveryRuleRepository DeliveryRuleRepository, DeliveryRepository deliveryRepository, RegionRepository regionRepository) { this._DeliveryRuleRepository = DeliveryRuleRepository; + _DeliveryRepository = deliveryRepository; + _RegionRepository = regionRepository; } #region 业务逻辑代码 /// - /// 查询配送模板区域及运费分页列表 + /// 通过配送模板guid获取配送模板所关联的配送模板区域及运费列表 /// - public async Task> GetDeliveryRuleList(DeliveryRuleQueryDto parm) + public async Task> GetDeliveryRuleList(long deliveryGuid) { - //开始拼装查询条件d - var predicate = Expressionable.Create(); - - predicate = predicate.AndIF(parm.DeliveryGuid != null, s => s.DeliveryGuid == parm.DeliveryGuid); var query = _DeliveryRuleRepository .Queryable() - .Where(predicate.ToExpression()) - .OrderBy(s => s.Create_time, OrderByType.Desc) + .Where(s => s.DeliveryGuid == deliveryGuid) + .OrderBy(s => s.Create_time, OrderByType.Asc) .Select(s => new DeliveryRuleVo { DeliveryRuleId = s.DeliveryRuleId, - DeliveryRuleGuid = s.DeliveryRuleGuid, DeliveryGuid = s.DeliveryGuid, - DeliveryRuleRegion = s.DeliveryRuleRegion, + DeliveryRuleRegionName = s.DeliveryRuleRegion, + DeliveryRuleRegion = new List(), DeliveryRuleRegionText = s.DeliveryRuleRegionText, DeliveryRuleFirst = s.DeliveryRuleFirst, DeliveryRuleFirstFee = s.DeliveryRuleFirstFee, @@ -63,31 +75,92 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.DeliveryRules }); - return await query.ToPageAsync(parm); + var list = await query.ToListAsync(); + + //foreach (var item in list) + //{ + // List DeliveryRuleRegionIds = item.DeliveryRuleRegionName.Split(',').Select(int.Parse).ToList(); + // var regionList = new List(); + + // foreach (var id in DeliveryRuleRegionIds) + // { + // var region = await _RegionRepository.GetFirstAsync(s => s.RegionId == id); + // if (region == null) throw new CustomException($"找不到Id:{id}的省市区数据"); + // var data = new SecondRegionVo + // { + // Id = region.RegionId, + // Label = region.RegionName, + // Pid = region.RegionPid, + // Code = region.RegionCode + // }; + // regionList.Add(data); + // } + + // item.DeliveryRuleRegion = regionList; + //} + + return list; + } + /// - /// 添加或修改配送模板区域及运费 + /// 通过配送模板guid获取配送模板所关联的配送模板区域及运费guid /// - public async Task AddOrUpdateDeliveryRule(DeliveryRule model) + /// 配送模板guid + /// + public async Task> GetDeliveryRuleGuidListByDeliveryGuid(long deliveryGuid) { - if (model.DeliveryRuleId != 0) - { - var response = await _DeliveryRuleRepository.UpdateAsync(model); - return "修改成功!"; - } - else - { - - var response = await _DeliveryRuleRepository.InsertReturnSnowflakeIdAsync(model); - return "添加成功!"; - } + var list = await _DeliveryRuleRepository.GetListAsync(f => f.DeliveryGuid == deliveryGuid); + //return list; + return list.Select(x => x.DeliveryRuleGuid).ToList(); } - #region Excel处理 - #endregion + /// + /// 通过配送模板guid获取配送模板所关联的配送模板区域及运费名称 + /// + /// 配送模板guid + /// + public async Task GetDeliveryRuleNameByDeliveryGuid(long deliveryGuid) + { + var list = await _DeliveryRuleRepository + .Queryable() + .LeftJoin((s, c) => s.DeliveryRuleGuid == c.DeliveryRuleGuid) + .Where((s, c) => s.DeliveryGuid == deliveryGuid) + .Select() + .ToListAsync(); + + var res = list.Select(x => x.DeliveryRuleRegionText).ToArray(); + return res; + + //return string.Join(',', list.Select(x => x.DeliveryRuleName)); + } + + + + /// + /// 新增配送模板配送模板区域及运费 + /// + /// 配送模板区域及运费列表 + public async Task InsertDeliveryRuleAsync(List deliveryRuleList) + { + await _DeliveryRuleRepository.InsertRangeAsync(deliveryRuleList); + } + + + /// + /// 更新配送模板配送模板区域及运费 + /// + /// 配送模板区域及运费列表 + /// 配送模板guid + /// + public async Task UpdateDeliveryRuleAsync(List deliveryRuleList, long deliveryGuid) + { + await _DeliveryRuleRepository.DeleteAsync(s => s.DeliveryGuid == deliveryGuid); + await _DeliveryRuleRepository.InsertRangeAsync(deliveryRuleList); + } diff --git a/ARW.Service/Business/BusinessService/LogisticsManage/Deliverys/DeliveryService.cs b/ARW.Service/Business/BusinessService/LogisticsManage/Deliverys/DeliveryService.cs index a3945a0..767b58b 100644 --- a/ARW.Service/Business/BusinessService/LogisticsManage/Deliverys/DeliveryService.cs +++ b/ARW.Service/Business/BusinessService/LogisticsManage/Deliverys/DeliveryService.cs @@ -14,6 +14,10 @@ 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; +using Aliyun.OSS; +using ARW.Repository.Business.LogisticsManage.DeliveryRules; +using ARW.Service.Business.IBusinessService.LogisticsManage.DeliveryRules; +using ARW.Model.Models.Business.ShopManager.Shops; namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys { @@ -27,10 +31,12 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys public class DeliveryServiceImpl : BaseService, IDeliveryService { private readonly DeliveryRepository _DeliveryRepository; + private readonly IDeliveryRuleService _DeliveryRuleService; - public DeliveryServiceImpl(DeliveryRepository DeliveryRepository) + public DeliveryServiceImpl(DeliveryRepository DeliveryRepository, IDeliveryRuleService deliveryRuleService) { this._DeliveryRepository = DeliveryRepository; + _DeliveryRuleService = deliveryRuleService; } #region 业务逻辑代码 @@ -44,18 +50,21 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys //开始拼装查询条件d var predicate = Expressionable.Create(); - //predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid.Contains(parm.ShopGuid)); + predicate = predicate.AndIF(parm.ShopGuid != null, s => s.ShopGuid == 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() + .LeftJoin((s, c) => s.ShopGuid == c.ShopGuid) .Where(predicate.ToExpression()) + .WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s, c) => c.ShopName.Contains(parm.ShopName)) .OrderBy(s => s.DeliverySort, OrderByType.Asc) - .Select(s => new DeliveryVo + .Select((s,c) => new DeliveryVo { DeliveryId = s.DeliveryId, DeliveryGuid = s.DeliveryGuid, ShopGuid = s.ShopGuid, + ShopName = c.ShopName, DeliveryName = s.DeliveryName, DeliveryBillingMethod = s.DeliveryBillingMethod, DeliverySort = s.DeliverySort, @@ -72,13 +81,24 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys { if (model.DeliveryId != 0) { + if (model.DeliveryRuleDataList.Count != 0) + { + await _DeliveryRuleService.UpdateDeliveryRuleAsync(model.DeliveryRuleDataList, model.DeliveryGuid); + } var response = await _DeliveryRepository.UpdateAsync(model); return "修改成功!"; } else { - var response = await _DeliveryRepository.InsertReturnSnowflakeIdAsync(model); + if (model.DeliveryRuleDataList.Count != 0 && response > 0) + { + foreach (var item in model.DeliveryRuleDataList) + { + item.DeliveryGuid = response; + } + await _DeliveryRuleService.InsertDeliveryRuleAsync(model.DeliveryRuleDataList); + } return "添加成功!"; } } diff --git a/ARW.Service/Business/IBusinessService/Custom/Regions/IRegionService.cs b/ARW.Service/Business/IBusinessService/Custom/Regions/IRegionService.cs index 704dc7f..bf9ea00 100644 --- a/ARW.Service/Business/IBusinessService/Custom/Regions/IRegionService.cs +++ b/ARW.Service/Business/IBusinessService/Custom/Regions/IRegionService.cs @@ -19,6 +19,13 @@ namespace ARW.Service.Business.IBusinessService.Custom.Regions /// Task> GetRegionTreeList(RegionQueryDto parm); + /// + /// 获取省市区数据表树形列表(二级) + /// + /// + /// + Task> GetSecondRegionTreeList(RegionQueryDto parm); + /// /// 获取省市区数据表列表 /// diff --git a/ARW.Service/Business/IBusinessService/LogisticsManage/DeliveryRules/IDeliveryRuleService.cs b/ARW.Service/Business/IBusinessService/LogisticsManage/DeliveryRules/IDeliveryRuleService.cs index 75fcf6d..5a8cef9 100644 --- a/ARW.Service/Business/IBusinessService/LogisticsManage/DeliveryRules/IDeliveryRuleService.cs +++ b/ARW.Service/Business/IBusinessService/LogisticsManage/DeliveryRules/IDeliveryRuleService.cs @@ -18,24 +18,47 @@ namespace ARW.Service.Business.IBusinessService.LogisticsManage.DeliveryRules /// public interface IDeliveryRuleService : IBaseService { - /// - /// 获取配送模板区域及运费分页列表 + + /// + /// 通过配送模板guid获取配送模板所关联的配送模板区域及运费列表 /// - /// + /// 配送模板guid /// - Task> GetDeliveryRuleList(DeliveryRuleQueryDto parm); + Task> GetDeliveryRuleList(long deliveryGuid); - - /// - /// 添加或修改配送模板区域及运费 + + + /// + /// 通过配送模板guid获取配送模板所关联的配送模板区域及运费guid /// - /// + /// 配送模板guid /// - Task AddOrUpdateDeliveryRule(DeliveryRule parm); + Task> GetDeliveryRuleGuidListByDeliveryGuid(long deliveryGuid); + /// + /// 通过配送模板guid获取配送模板所关联的配送模板区域及运费名称 + /// + /// 配送模板guid + /// + Task GetDeliveryRuleNameByDeliveryGuid(long deliveryGuid); + /// + /// 新增配送模板配送模板区域及运费 + /// + /// 配送模板区域及运费列表 + /// + Task InsertDeliveryRuleAsync(List deliveryRuleList); + + + /// + /// 更新配送模板配送模板区域及运费 + /// + /// 配送模板区域及运费列表 + /// 配送模板guid + /// + Task UpdateDeliveryRuleAsync(List deliveryRuleList, long deliveryGuid); } } diff --git a/ARW.WebApi/Controllers/Business/Custom/Regions/RegionController.cs b/ARW.WebApi/Controllers/Business/Custom/Regions/RegionController.cs index a879ab7..fd816fb 100644 --- a/ARW.WebApi/Controllers/Business/Custom/Regions/RegionController.cs +++ b/ARW.WebApi/Controllers/Business/Custom/Regions/RegionController.cs @@ -51,6 +51,22 @@ namespace ARW.WebApi.Controllers.Business.Custom.Regions return SUCCESS(res); } + + /// + /// 获取省市区数据表树形列表(二级) + /// + /// 查询参数 + /// + [HttpGet("getSecondRegionTreeList")] + public async Task GetSecondRegionList([FromQuery] RegionQueryDto parm) + { + var res = await _RegionService.GetSecondRegionTreeList(parm); + res ??= new List(); + + return SUCCESS(res); + } + + /// /// 添加或修改省市区数据表 /// diff --git a/ARW.WebApi/Controllers/Business/LogisticsManage/Deliverys/DeliveryController.cs b/ARW.WebApi/Controllers/Business/LogisticsManage/Deliverys/DeliveryController.cs index 91883ce..4d4ea85 100644 --- a/ARW.WebApi/Controllers/Business/LogisticsManage/Deliverys/DeliveryController.cs +++ b/ARW.WebApi/Controllers/Business/LogisticsManage/Deliverys/DeliveryController.cs @@ -15,7 +15,8 @@ using ARW.Model.Models.Business.LogisticsManage.Deliverys; using ARW.Model.Vo.Business.LogisticsManage.Deliverys; using Microsoft.AspNetCore.Authorization; using ARW.Admin.WebApi.Framework; - +using ARW.Service.Business.IBusinessService.LogisticsManage.DeliveryRules; +using ARW.Service.Business.IBusinessService.ShopManager.Shops; namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys { @@ -30,14 +31,18 @@ namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys public class DeliveryController : BaseController { private readonly IDeliveryService _DeliveryService; + private readonly IDeliveryRuleService _DeliveryRuleService; + private readonly IShopService _ShopService; /// /// 依赖注入 /// /// 配送模板服务 - public DeliveryController(IDeliveryService DeliveryService) + public DeliveryController(IDeliveryService DeliveryService, IDeliveryRuleService deliveryRuleService, IShopService shopService) { _DeliveryService = DeliveryService; + _DeliveryRuleService = deliveryRuleService; + _ShopService = shopService; } @@ -50,10 +55,32 @@ namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys [ActionPermissionFilter(Permission = "business:delivery:list")] public async Task GetDeliveryList([FromQuery] DeliveryQueryDto parm) { + var user = JwtUtil.GetLoginUser(App.HttpContext); + + if (user.UserId != 1) + { + var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId); + if (shop == null) throw new Exception("当前用户没有店铺"); + parm.ShopGuid = shop.ShopGuid; + } var res = await _DeliveryService.GetDeliveryList(parm); return SUCCESS(res); } + + /// + /// 获取配送模板的配送区域和运费列表 + /// + /// 查询参数 + /// + [HttpGet("getDeliveryRuleList")] + public async Task GetDeliveryRuleList([FromQuery] DeliveryRuleEditDto parm) + { + var res = await _DeliveryRuleService.GetDeliveryRuleList(parm.DeliveryGuid); + return SUCCESS(res); + } + + /// /// 添加或修改配送模板 /// @@ -70,6 +97,14 @@ namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys if (parm.DeliveryId != 0) modal = parm.Adapt().ToUpdate(HttpContext); else modal = parm.Adapt().ToCreate(HttpContext); + var user = JwtUtil.GetLoginUser(App.HttpContext); + if (user.UserId != 1) + { + var shop = await _ShopService.GetFirstAsync(s => s.ShopUserId == user.UserId); + if (shop == null) throw new Exception("当前用户没有店铺"); + modal.ShopGuid = shop.ShopGuid; + } + var res = await _DeliveryService.AddOrUpdateDelivery(modal); return SUCCESS(res); }