feat 添加配送模板管理
This commit is contained in:
parent
4fa2649fe0
commit
9ffb9fe07a
@ -28,13 +28,13 @@ namespace ARW.Model.Dto.Business.LogisticsManage.DeliveryRules
|
|||||||
public string DeliveryRuleRegionText { get; set; }
|
public string DeliveryRuleRegionText { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "首件(个)/首重(Kg)不能为空")]
|
[Required(ErrorMessage = "首件(个)/首重(Kg)不能为空")]
|
||||||
public int DeliveryRuleFirst { get; set; }
|
public decimal DeliveryRuleFirst { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "运费(元)不能为空")]
|
[Required(ErrorMessage = "运费(元)不能为空")]
|
||||||
public decimal DeliveryRuleFirstFee { get; set; }
|
public decimal DeliveryRuleFirstFee { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "续件/续重不能为空")]
|
[Required(ErrorMessage = "续件/续重不能为空")]
|
||||||
public int DeliveryRuleAdditional { get; set; }
|
public decimal DeliveryRuleAdditional { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "续费(元)不能为空")]
|
[Required(ErrorMessage = "续费(元)不能为空")]
|
||||||
public decimal DeliveryRuleAdditionalFee { get; set; }
|
public decimal DeliveryRuleAdditionalFee { get; set; }
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
|
||||||
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
||||||
|
|
||||||
namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys
|
namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys
|
||||||
@ -27,6 +28,9 @@ namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys
|
|||||||
[Required(ErrorMessage = "计费方式不能为空")]
|
[Required(ErrorMessage = "计费方式不能为空")]
|
||||||
public int DeliveryBillingMethod { get; set; }
|
public int DeliveryBillingMethod { get; set; }
|
||||||
|
|
||||||
|
[Required(ErrorMessage = "配送区域及运费不能为空")]
|
||||||
|
public List<DeliveryRule> DeliveryRuleDataList { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "排序不能为空")]
|
[Required(ErrorMessage = "排序不能为空")]
|
||||||
public int DeliverySort { get; set; }
|
public int DeliverySort { get; set; }
|
||||||
|
|
||||||
@ -47,6 +51,7 @@ namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys
|
|||||||
{
|
{
|
||||||
|
|
||||||
public long? ShopGuid { get; set; }
|
public long? ShopGuid { get; set; }
|
||||||
|
public string ShopName { get; set; }
|
||||||
|
|
||||||
public string DeliveryName { get; set; }
|
public string DeliveryName { get; set; }
|
||||||
|
|
||||||
@ -56,6 +61,17 @@ namespace ARW.Model.Dto.Business.LogisticsManage.Deliverys
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配送模板的配送区域和运费查询对象
|
||||||
|
///
|
||||||
|
/// @author 黎文豪
|
||||||
|
/// @date 2023-06-16
|
||||||
|
/// </summary>
|
||||||
|
public class DeliveryRuleEditDto
|
||||||
|
{
|
||||||
|
public long DeliveryGuid { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace ARW.Model.Models.Business.LogisticsManage.DeliveryRules
|
|||||||
/// 空值 : false
|
/// 空值 : false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "delivery_rule_first")]
|
[SugarColumn(ColumnName = "delivery_rule_first")]
|
||||||
public int DeliveryRuleFirst { get; set; }
|
public decimal DeliveryRuleFirst { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -79,7 +79,7 @@ namespace ARW.Model.Models.Business.LogisticsManage.DeliveryRules
|
|||||||
/// 空值 : false
|
/// 空值 : false
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(ColumnName = "delivery_rule_additional")]
|
[SugarColumn(ColumnName = "delivery_rule_additional")]
|
||||||
public int DeliveryRuleAdditional { get; set; }
|
public decimal DeliveryRuleAdditional { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using OfficeOpenXml.Attributes;
|
using OfficeOpenXml.Attributes;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
|
||||||
|
|
||||||
namespace ARW.Model.Models.Business.LogisticsManage.Deliverys
|
namespace ARW.Model.Models.Business.LogisticsManage.Deliverys
|
||||||
{
|
{
|
||||||
@ -72,7 +73,8 @@ namespace ARW.Model.Models.Business.LogisticsManage.Deliverys
|
|||||||
public int DeliverySort { get; set; }
|
public int DeliverySort { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public List<DeliveryRule> DeliveryRuleDataList { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,4 +51,36 @@ namespace ARW.Model.Vo.Business.Custom.Regions
|
|||||||
[SugarColumn(IsIgnore = true)]
|
[SugarColumn(IsIgnore = true)]
|
||||||
public List<RegionVo> Children { get; set; }
|
public List<RegionVo> Children { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 省市区数据表展示对象(二级)
|
||||||
|
/// </summary>
|
||||||
|
public class SecondRegionVo
|
||||||
|
{
|
||||||
|
[SugarColumn(IsTreeKey = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :区划名称
|
||||||
|
/// </summary>
|
||||||
|
public string Label { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :父级ID
|
||||||
|
/// </summary>
|
||||||
|
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<SecondRegionVo> Children { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
using ARW.Model.Vo.Business.Custom.Regions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using OfficeOpenXml.Attributes;
|
using OfficeOpenXml.Attributes;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules
|
namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules
|
||||||
{
|
{
|
||||||
@ -38,7 +40,9 @@ namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :可配送区域(城市id集)
|
/// 描述 :可配送区域(城市id集)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DeliveryRuleRegion { get; set; }
|
public List<SecondRegionVo> DeliveryRuleRegion { get; set; }
|
||||||
|
|
||||||
|
public string DeliveryRuleRegionName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -50,7 +54,7 @@ namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :首件(个)/首重(Kg)
|
/// 描述 :首件(个)/首重(Kg)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int DeliveryRuleFirst { get; set; }
|
public decimal DeliveryRuleFirst { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -62,7 +66,7 @@ namespace ARW.Model.Vo.Business.LogisticsManage.DeliveryRules
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :续件/续重
|
/// 描述 :续件/续重
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int DeliveryRuleAdditional { get; set; }
|
public decimal DeliveryRuleAdditional { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -34,10 +34,17 @@ namespace ARW.Model.Vo.Business.LogisticsManage.Deliverys
|
|||||||
/// 描述 :店铺guid
|
/// 描述 :店铺guid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonConverter(typeof(ValueToStringConverter))]
|
[JsonConverter(typeof(ValueToStringConverter))]
|
||||||
[EpplusTableColumn(Header = "店铺guid")]
|
[EpplusIgnore]
|
||||||
public long ShopGuid { get; set; }
|
public long ShopGuid { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述 :店铺名称
|
||||||
|
/// </summary>
|
||||||
|
[EpplusTableColumn(Header = "店铺名称")]
|
||||||
|
public string ShopName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 描述 :模板名称
|
/// 描述 :模板名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -62,6 +62,35 @@ namespace ARW.Service.Business.BusinessService.Custom.Regions
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询省市区数据表树形列表(二级)
|
||||||
|
/// </summary>
|
||||||
|
public async Task<List<SecondRegionVo>> GetSecondRegionTreeList(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);
|
||||||
|
predicate = predicate.And(s => s.RegionLevel <= 2);
|
||||||
|
|
||||||
|
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 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询省市区数据表列表
|
/// 查询省市区数据表列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -14,6 +14,18 @@ using ARW.Service.Business.IBusinessService.LogisticsManage.DeliveryRules;
|
|||||||
using ARW.Model.Dto.Business.LogisticsManage.DeliveryRules;
|
using ARW.Model.Dto.Business.LogisticsManage.DeliveryRules;
|
||||||
using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
|
using ARW.Model.Models.Business.LogisticsManage.DeliveryRules;
|
||||||
using ARW.Model.Vo.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
|
namespace ARW.Service.Business.BusinessService.LogisticsManage.DeliveryRules
|
||||||
{
|
{
|
||||||
@ -27,34 +39,34 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.DeliveryRules
|
|||||||
public class DeliveryRuleServiceImpl : BaseService<DeliveryRule>, IDeliveryRuleService
|
public class DeliveryRuleServiceImpl : BaseService<DeliveryRule>, IDeliveryRuleService
|
||||||
{
|
{
|
||||||
private readonly DeliveryRuleRepository _DeliveryRuleRepository;
|
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;
|
this._DeliveryRuleRepository = DeliveryRuleRepository;
|
||||||
|
_DeliveryRepository = deliveryRepository;
|
||||||
|
_RegionRepository = regionRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 业务逻辑代码
|
#region 业务逻辑代码
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询配送模板区域及运费分页列表
|
/// 通过配送模板guid获取配送模板所关联的配送模板区域及运费列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<PagedInfo<DeliveryRuleVo>> GetDeliveryRuleList(DeliveryRuleQueryDto parm)
|
public async Task<List<DeliveryRuleVo>> GetDeliveryRuleList(long deliveryGuid)
|
||||||
{
|
{
|
||||||
//开始拼装查询条件d
|
|
||||||
var predicate = Expressionable.Create<DeliveryRule>();
|
|
||||||
|
|
||||||
predicate = predicate.AndIF(parm.DeliveryGuid != null, s => s.DeliveryGuid == parm.DeliveryGuid);
|
|
||||||
var query = _DeliveryRuleRepository
|
var query = _DeliveryRuleRepository
|
||||||
.Queryable()
|
.Queryable()
|
||||||
.Where(predicate.ToExpression())
|
.Where(s => s.DeliveryGuid == deliveryGuid)
|
||||||
.OrderBy(s => s.Create_time, OrderByType.Desc)
|
.OrderBy(s => s.Create_time, OrderByType.Asc)
|
||||||
.Select(s => new DeliveryRuleVo
|
.Select(s => new DeliveryRuleVo
|
||||||
{
|
{
|
||||||
DeliveryRuleId = s.DeliveryRuleId,
|
DeliveryRuleId = s.DeliveryRuleId,
|
||||||
DeliveryRuleGuid = s.DeliveryRuleGuid,
|
|
||||||
DeliveryGuid = s.DeliveryGuid,
|
DeliveryGuid = s.DeliveryGuid,
|
||||||
DeliveryRuleRegion = s.DeliveryRuleRegion,
|
DeliveryRuleRegionName = s.DeliveryRuleRegion,
|
||||||
|
DeliveryRuleRegion = new List<SecondRegionVo>(),
|
||||||
DeliveryRuleRegionText = s.DeliveryRuleRegionText,
|
DeliveryRuleRegionText = s.DeliveryRuleRegionText,
|
||||||
DeliveryRuleFirst = s.DeliveryRuleFirst,
|
DeliveryRuleFirst = s.DeliveryRuleFirst,
|
||||||
DeliveryRuleFirstFee = s.DeliveryRuleFirstFee,
|
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<int> DeliveryRuleRegionIds = item.DeliveryRuleRegionName.Split(',').Select(int.Parse).ToList();
|
||||||
|
// var regionList = new List<SecondRegionVo>();
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加或修改配送模板区域及运费
|
/// 通过配送模板guid获取配送模板所关联的配送模板区域及运费guid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<string> AddOrUpdateDeliveryRule(DeliveryRule model)
|
/// <param name="deliveryGuid">配送模板guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<List<long>> GetDeliveryRuleGuidListByDeliveryGuid(long deliveryGuid)
|
||||||
{
|
{
|
||||||
if (model.DeliveryRuleId != 0)
|
var list = await _DeliveryRuleRepository.GetListAsync(f => f.DeliveryGuid == deliveryGuid);
|
||||||
{
|
//return list;
|
||||||
var response = await _DeliveryRuleRepository.UpdateAsync(model);
|
return list.Select(x => x.DeliveryRuleGuid).ToList();
|
||||||
return "修改成功!";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
var response = await _DeliveryRuleRepository.InsertReturnSnowflakeIdAsync(model);
|
|
||||||
return "添加成功!";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Excel处理
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
/// <summary>
|
||||||
|
/// 通过配送模板guid获取配送模板所关联的配送模板区域及运费名称
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deliveryGuid">配送模板guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task<string[]> GetDeliveryRuleNameByDeliveryGuid(long deliveryGuid)
|
||||||
|
{
|
||||||
|
var list = await _DeliveryRuleRepository
|
||||||
|
.Queryable()
|
||||||
|
.LeftJoin<DeliveryRule>((s, c) => s.DeliveryRuleGuid == c.DeliveryRuleGuid)
|
||||||
|
.Where((s, c) => s.DeliveryGuid == deliveryGuid)
|
||||||
|
.Select<DeliveryRule>()
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var res = list.Select(x => x.DeliveryRuleRegionText).ToArray();
|
||||||
|
return res;
|
||||||
|
|
||||||
|
//return string.Join(',', list.Select(x => x.DeliveryRuleName));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增配送模板配送模板区域及运费
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deliveryRuleList">配送模板区域及运费列表</param>
|
||||||
|
public async Task InsertDeliveryRuleAsync(List<DeliveryRule> deliveryRuleList)
|
||||||
|
{
|
||||||
|
await _DeliveryRuleRepository.InsertRangeAsync(deliveryRuleList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新配送模板配送模板区域及运费
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deliveryRuleList">配送模板区域及运费列表</param>
|
||||||
|
/// <param name="deliveryGuid">配送模板guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task UpdateDeliveryRuleAsync(List<DeliveryRule> deliveryRuleList, long deliveryGuid)
|
||||||
|
{
|
||||||
|
await _DeliveryRuleRepository.DeleteAsync(s => s.DeliveryGuid == deliveryGuid);
|
||||||
|
await _DeliveryRuleRepository.InsertRangeAsync(deliveryRuleList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +14,10 @@ using ARW.Service.Business.IBusinessService.LogisticsManage.Deliverys;
|
|||||||
using ARW.Model.Dto.Business.LogisticsManage.Deliverys;
|
using ARW.Model.Dto.Business.LogisticsManage.Deliverys;
|
||||||
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
||||||
using ARW.Model.Vo.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
|
namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys
|
||||||
{
|
{
|
||||||
@ -27,10 +31,12 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys
|
|||||||
public class DeliveryServiceImpl : BaseService<Delivery>, IDeliveryService
|
public class DeliveryServiceImpl : BaseService<Delivery>, IDeliveryService
|
||||||
{
|
{
|
||||||
private readonly DeliveryRepository _DeliveryRepository;
|
private readonly DeliveryRepository _DeliveryRepository;
|
||||||
|
private readonly IDeliveryRuleService _DeliveryRuleService;
|
||||||
|
|
||||||
public DeliveryServiceImpl(DeliveryRepository DeliveryRepository)
|
public DeliveryServiceImpl(DeliveryRepository DeliveryRepository, IDeliveryRuleService deliveryRuleService)
|
||||||
{
|
{
|
||||||
this._DeliveryRepository = DeliveryRepository;
|
this._DeliveryRepository = DeliveryRepository;
|
||||||
|
_DeliveryRuleService = deliveryRuleService;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 业务逻辑代码
|
#region 业务逻辑代码
|
||||||
@ -44,18 +50,21 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys
|
|||||||
//开始拼装查询条件d
|
//开始拼装查询条件d
|
||||||
var predicate = Expressionable.Create<Delivery>();
|
var predicate = Expressionable.Create<Delivery>();
|
||||||
|
|
||||||
//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(!string.IsNullOrEmpty(parm.DeliveryName), s => s.DeliveryName.Contains(parm.DeliveryName));
|
||||||
predicate = predicate.AndIF(parm.DeliveryBillingMethod != null, s => s.DeliveryBillingMethod == parm.DeliveryBillingMethod);
|
predicate = predicate.AndIF(parm.DeliveryBillingMethod != null, s => s.DeliveryBillingMethod == parm.DeliveryBillingMethod);
|
||||||
var query = _DeliveryRepository
|
var query = _DeliveryRepository
|
||||||
.Queryable()
|
.Queryable()
|
||||||
|
.LeftJoin<Shop>((s, c) => s.ShopGuid == c.ShopGuid)
|
||||||
.Where(predicate.ToExpression())
|
.Where(predicate.ToExpression())
|
||||||
|
.WhereIF(!string.IsNullOrEmpty(parm.ShopName), (s, c) => c.ShopName.Contains(parm.ShopName))
|
||||||
.OrderBy(s => s.DeliverySort, OrderByType.Asc)
|
.OrderBy(s => s.DeliverySort, OrderByType.Asc)
|
||||||
.Select(s => new DeliveryVo
|
.Select((s,c) => new DeliveryVo
|
||||||
{
|
{
|
||||||
DeliveryId = s.DeliveryId,
|
DeliveryId = s.DeliveryId,
|
||||||
DeliveryGuid = s.DeliveryGuid,
|
DeliveryGuid = s.DeliveryGuid,
|
||||||
ShopGuid = s.ShopGuid,
|
ShopGuid = s.ShopGuid,
|
||||||
|
ShopName = c.ShopName,
|
||||||
DeliveryName = s.DeliveryName,
|
DeliveryName = s.DeliveryName,
|
||||||
DeliveryBillingMethod = s.DeliveryBillingMethod,
|
DeliveryBillingMethod = s.DeliveryBillingMethod,
|
||||||
DeliverySort = s.DeliverySort,
|
DeliverySort = s.DeliverySort,
|
||||||
@ -72,13 +81,24 @@ namespace ARW.Service.Business.BusinessService.LogisticsManage.Deliverys
|
|||||||
{
|
{
|
||||||
if (model.DeliveryId != 0)
|
if (model.DeliveryId != 0)
|
||||||
{
|
{
|
||||||
|
if (model.DeliveryRuleDataList.Count != 0)
|
||||||
|
{
|
||||||
|
await _DeliveryRuleService.UpdateDeliveryRuleAsync(model.DeliveryRuleDataList, model.DeliveryGuid);
|
||||||
|
}
|
||||||
var response = await _DeliveryRepository.UpdateAsync(model);
|
var response = await _DeliveryRepository.UpdateAsync(model);
|
||||||
return "修改成功!";
|
return "修改成功!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
var response = await _DeliveryRepository.InsertReturnSnowflakeIdAsync(model);
|
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 "添加成功!";
|
return "添加成功!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,13 @@ namespace ARW.Service.Business.IBusinessService.Custom.Regions
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<List<RegionVo>> GetRegionTreeList(RegionQueryDto parm);
|
Task<List<RegionVo>> GetRegionTreeList(RegionQueryDto parm);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取省市区数据表树形列表(二级)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<List<SecondRegionVo>> GetSecondRegionTreeList(RegionQueryDto parm);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取省市区数据表列表
|
/// 获取省市区数据表列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -18,24 +18,47 @@ namespace ARW.Service.Business.IBusinessService.LogisticsManage.DeliveryRules
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IDeliveryRuleService : IBaseService<DeliveryRule>
|
public interface IDeliveryRuleService : IBaseService<DeliveryRule>
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 获取配送模板区域及运费分页列表
|
/// <summary>
|
||||||
|
/// 通过配送模板guid获取配送模板所关联的配送模板区域及运费列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="deliveryGuid">配送模板guid</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<PagedInfo<DeliveryRuleVo>> GetDeliveryRuleList(DeliveryRuleQueryDto parm);
|
Task<List<DeliveryRuleVo>> GetDeliveryRuleList(long deliveryGuid);
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 添加或修改配送模板区域及运费
|
/// <summary>
|
||||||
|
/// 通过配送模板guid获取配送模板所关联的配送模板区域及运费guid
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="parm"></param>
|
/// <param name="deliveryGuid">配送模板guid</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
Task<string> AddOrUpdateDeliveryRule(DeliveryRule parm);
|
Task<List<long>> GetDeliveryRuleGuidListByDeliveryGuid(long deliveryGuid);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 通过配送模板guid获取配送模板所关联的配送模板区域及运费名称
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deliveryGuid">配送模板guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<string[]> GetDeliveryRuleNameByDeliveryGuid(long deliveryGuid);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增配送模板配送模板区域及运费
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deliveryRuleList">配送模板区域及运费列表</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task InsertDeliveryRuleAsync(List<DeliveryRule> deliveryRuleList);
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新配送模板配送模板区域及运费
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="deliveryRuleList">配送模板区域及运费列表</param>
|
||||||
|
/// <param name="deliveryGuid">配送模板guid</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task UpdateDeliveryRuleAsync(List<DeliveryRule> deliveryRuleList, long deliveryGuid);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,6 +51,22 @@ namespace ARW.WebApi.Controllers.Business.Custom.Regions
|
|||||||
return SUCCESS(res);
|
return SUCCESS(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取省市区数据表树形列表(二级)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm">查询参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getSecondRegionTreeList")]
|
||||||
|
public async Task<IActionResult> GetSecondRegionList([FromQuery] RegionQueryDto parm)
|
||||||
|
{
|
||||||
|
var res = await _RegionService.GetSecondRegionTreeList(parm);
|
||||||
|
res ??= new List<SecondRegionVo>();
|
||||||
|
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加或修改省市区数据表
|
/// 添加或修改省市区数据表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -15,7 +15,8 @@ using ARW.Model.Models.Business.LogisticsManage.Deliverys;
|
|||||||
using ARW.Model.Vo.Business.LogisticsManage.Deliverys;
|
using ARW.Model.Vo.Business.LogisticsManage.Deliverys;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using ARW.Admin.WebApi.Framework;
|
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
|
namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys
|
||||||
{
|
{
|
||||||
@ -30,14 +31,18 @@ namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys
|
|||||||
public class DeliveryController : BaseController
|
public class DeliveryController : BaseController
|
||||||
{
|
{
|
||||||
private readonly IDeliveryService _DeliveryService;
|
private readonly IDeliveryService _DeliveryService;
|
||||||
|
private readonly IDeliveryRuleService _DeliveryRuleService;
|
||||||
|
private readonly IShopService _ShopService;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 依赖注入
|
/// 依赖注入
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="DeliveryService">配送模板服务</param>
|
/// <param name="DeliveryService">配送模板服务</param>
|
||||||
public DeliveryController(IDeliveryService DeliveryService)
|
public DeliveryController(IDeliveryService DeliveryService, IDeliveryRuleService deliveryRuleService, IShopService shopService)
|
||||||
{
|
{
|
||||||
_DeliveryService = DeliveryService;
|
_DeliveryService = DeliveryService;
|
||||||
|
_DeliveryRuleService = deliveryRuleService;
|
||||||
|
_ShopService = shopService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -50,10 +55,32 @@ namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys
|
|||||||
[ActionPermissionFilter(Permission = "business:delivery:list")]
|
[ActionPermissionFilter(Permission = "business:delivery:list")]
|
||||||
public async Task<IActionResult> GetDeliveryList([FromQuery] DeliveryQueryDto parm)
|
public async Task<IActionResult> 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);
|
var res = await _DeliveryService.GetDeliveryList(parm);
|
||||||
return SUCCESS(res);
|
return SUCCESS(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取配送模板的配送区域和运费列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parm">查询参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet("getDeliveryRuleList")]
|
||||||
|
public async Task<IActionResult> GetDeliveryRuleList([FromQuery] DeliveryRuleEditDto parm)
|
||||||
|
{
|
||||||
|
var res = await _DeliveryRuleService.GetDeliveryRuleList(parm.DeliveryGuid);
|
||||||
|
return SUCCESS(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加或修改配送模板
|
/// 添加或修改配送模板
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -70,6 +97,14 @@ namespace ARW.WebApi.Controllers.Business.LogisticsManage.Deliverys
|
|||||||
if (parm.DeliveryId != 0) modal = parm.Adapt<Delivery>().ToUpdate(HttpContext);
|
if (parm.DeliveryId != 0) modal = parm.Adapt<Delivery>().ToUpdate(HttpContext);
|
||||||
else modal = parm.Adapt<Delivery>().ToCreate(HttpContext);
|
else modal = parm.Adapt<Delivery>().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);
|
var res = await _DeliveryService.AddOrUpdateDelivery(modal);
|
||||||
return SUCCESS(res);
|
return SUCCESS(res);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user