模板批量编辑

dev
嵇文龙 1 month ago
parent b2a9af2d73
commit e6fa12ede7

@ -138,12 +138,24 @@ namespace DS.WMS.Core.Fee.Entity
[SugarColumn(ColumnDescription = "业务来源ID", IsNullable = true)]
public long? SourceId { get; set; }
/// <summary>
/// 业务来源明细ID
/// </summary>
[SugarColumn(ColumnDescription = "业务来源明细ID", IsNullable = true)]
public long? SourceDetailId { get; set; }
/// <summary>
/// 订舱口ID
/// </summary>
[SugarColumn(ColumnDescription = "订舱口ID", IsNullable = true)]
public long? ForwarderId { get; set; }
/// <summary>
/// 分公司ID
/// </summary>
[SugarColumn(ColumnDescription = "分公司ID", IsNullable = true)]
public long? DeptOrgId { get; set; }
/// <summary>
/// 模板明细
/// </summary>

@ -45,6 +45,20 @@ namespace DS.WMS.Core.Fee.Interface
/// <returns></returns>
Task<DataResult> EditAsync(FeeCustTemplate model);
/// <summary>
/// 批量编辑模板
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
Task<DataResult> BulkEditAsync(List<FeeCustTemplate> list);
/// <summary>
/// 批量编辑模板明细
/// </summary>
/// <param name="details"></param>
/// <returns></returns>
Task<DataResult> BulkEditDetailsAsync(List<FeeCustTemplateDetail> details);
/// <summary>
/// 根据ID批量删除
/// </summary>

@ -61,8 +61,10 @@ namespace DS.WMS.Core.Fee.Method
PODCode = x.PODCode,
LaneId = x.LaneId,
SourceId = x.SourceId,
SourceDetailId = x.SourceDetailId,
CarrierId = x.CarrierId,
ForwarderId = x.ForwarderId,
DeptOrgId = x.DeptOrgId,
MBLFrtCode = x.MBLFrtCode,
Condition = x.Condition
}).ToListAsync();
@ -186,9 +188,15 @@ namespace DS.WMS.Core.Fee.Method
if (template.SourceId.HasValue && template.SourceId != order.SourceId)
return null;
if (template.SourceDetailId.HasValue && template.SourceDetailId != order.SourceDetailId)
return null;
if (template.ForwarderId.HasValue && template.ForwarderId != order.ForwarderId)
return null;
//if (template.DeptOrgId.HasValue && template.DeptOrgId != order.DeptOrgId)
// return null;
if (!string.IsNullOrEmpty(template.Condition)) //设置了自定义匹配条件
{
var conditionModel = JsonConvert.DeserializeObject<ConditionContent>(template.Condition);
@ -558,6 +566,7 @@ namespace DS.WMS.Core.Fee.Method
{
if (model.Id == 0)
{
model.DeptOrgId ??= User.OrgId;
await TenantDb.InsertNav(model).Include(x => x.Details).ExecuteCommandAsync();
}
else
@ -579,6 +588,92 @@ namespace DS.WMS.Core.Fee.Method
}
}
/// <summary>
/// 批量编辑模板
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
public async Task<DataResult> BulkEditAsync(List<FeeCustTemplate> list)
{
int rows = await TenantDb.Updateable(list).UpdateColumns(x => new
{
x.StartTime,
x.EndTime,
x.IsDisabled,
x.FeeCategoryId,
x.FeeCategoryName,
x.Priority,
x.PODCode,
x.POLCode,
x.LaneId,
x.CarrierId,
x.MBLFrtCode,
x.SourceId,
x.SourceDetailId,
x.ForwarderId,
x.DeptOrgId
}).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
/// <summary>
/// 批量编辑模板明细
/// </summary>
/// <param name="details"></param>
/// <returns></returns>
public async Task<DataResult> BulkEditDetailsAsync(List<FeeCustTemplateDetail> details)
{
var model = await TenantDb.Queryable<FeeCustTemplate>()
.Where(x => x.Id == details[0].TemplateId).Select(x => new
{
x.CustomerId,
x.CustomerName,
x.FeeType
}).FirstAsync();
if (model == null)
return DataResult.FailedWithDesc(nameof(MultiLanguageConst.EmptyData));
foreach (var item in details)
{
item.TaxRate ??= 0;
item.AccTaxRate ??= 0;
item.Tax = Math.Round(item.TaxUnitPrice.GetValueOrDefault() - item.TaxRate.GetValueOrDefault() / 100 * item.TaxUnitPrice.GetValueOrDefault(), 2, MidpointRounding.AwayFromZero);
item.UnitPrice = item.TaxUnitPrice - item.Tax.GetValueOrDefault();
if (item.ExchangeRate == null)
{
if (item.Currency == FeeCurrency.RMB_CODE)
{
item.ExchangeRate = 1m;
}
else
{
var er = await exchangeService.Value.GetExchangeRateAsync(new ExchangeRate
{
CurrencyFrom = item.Currency,
CurrencyTo = FeeCurrency.RMB_CODE,
FeeType = model.FeeType
});
item.ExchangeRate = er.Data?.Rate;
}
}
if (item.CustomerId == 0 && model.CustomerId.HasValue)
item.CustomerId = model.CustomerId.Value;
if (string.IsNullOrEmpty(item.CustomerName))
item.CustomerName = model.CustomerName;
}
int rows = await TenantDb.Updateable(details).IgnoreColumns(x => new
{
x.TemplateId,
x.CreateTime,
x.CreateBy
}).ExecuteCommandAsync();
return rows > 0 ? DataResult.Success : DataResult.FailedWithDesc(nameof(MultiLanguageConst.Operation_Failed));
}
/// <summary>
/// 根据ID批量删除
/// </summary>

@ -139,6 +139,33 @@ namespace DS.WMS.FeeApi.Controllers
return await _invokeService.EditAsync(model);
}
/// <summary>
/// 批量编辑模板
/// </summary>
/// <param name="list"></param>
/// <returns></returns>
[HttpPost, Route("BulkEdit")]
public async Task<DataResult> BulkEditAsync([FromBody] List<FeeCustTemplate> list)
{
if (list == null || list.Count == 0)
return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest);
return await _invokeService.BulkEditAsync(list);
}
/// <summary>
/// 批量编辑模板明细
/// </summary>
/// <param name="details"></param>
/// <returns></returns>
public async Task<DataResult> BulkEditDetailsAsync([FromBody] List<FeeCustTemplateDetail> details)
{
if (details == null || details.Count == 0)
return DataResult.FailedWithDesc(MultiLanguageConst.IllegalRequest);
return await _invokeService.BulkEditDetailsAsync(details);
}
/// <summary>
/// 详情
/// </summary>
@ -167,10 +194,11 @@ namespace DS.WMS.FeeApi.Controllers
/// <summary>
/// 根据ID删除明细
/// </summary>
/// <param name="detailService"></param>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost, Route("DeleteDetails")]
public async Task<DataResult> DeleteAsync([FromServices] IFeeCustTemplateDetailService detailService, [FromBody] IdModel model)
public async Task<DataResult> DeleteDetailsAsync([FromServices] IFeeCustTemplateDetailService detailService, [FromBody] IdModel model)
{
if (!ModelState.IsValid)
return DataResult.Failed(ModelState.GetErrorMessage(), MultiLanguageConst.IllegalRequest);

Loading…
Cancel
Save